From owner-svn-src-stable@freebsd.org Sun Oct 16 22:02:59 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F9FCC141EF; Sun, 16 Oct 2016 22:02:59 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1AC39159D; Sun, 16 Oct 2016 22:02:59 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GM2wkE091018; Sun, 16 Oct 2016 22:02:58 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GM2oaf090944; Sun, 16 Oct 2016 22:02:50 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162202.u9GM2oaf090944@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:02:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307403 - in stable/10: bin/chio bin/freebsd-version bin/pkill bin/setfacl games/morse games/random sbin/adjkerntz sbin/atm/atmconfig sbin/camcontrol sbin/dhclient sbin/ffsinfo sbin/fsi... X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:02:59 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:02:50 2016 New Revision: 307403 URL: https://svnweb.freebsd.org/changeset/base/307403 Log: MFC r267667: use .Mt to mark up email addresses consistently (part1) PR: 191174 Submitted by: Franco Fichtner Modified: stable/10/bin/chio/chio.1 stable/10/bin/freebsd-version/freebsd-version.1 stable/10/bin/pkill/pkill.1 stable/10/bin/setfacl/setfacl.1 stable/10/games/morse/morse.6 stable/10/games/random/random.6 stable/10/sbin/adjkerntz/adjkerntz.8 stable/10/sbin/atm/atmconfig/atmconfig.8 stable/10/sbin/camcontrol/camcontrol.8 stable/10/sbin/dhclient/dhclient-script.8 stable/10/sbin/dhclient/dhclient.8 stable/10/sbin/dhclient/dhclient.conf.5 stable/10/sbin/dhclient/dhclient.leases.5 stable/10/sbin/dhclient/dhcp-options.5 stable/10/sbin/ffsinfo/ffsinfo.8 stable/10/sbin/fsirand/fsirand.8 stable/10/sbin/gbde/gbde.8 stable/10/sbin/geom/class/cache/gcache.8 stable/10/sbin/geom/class/concat/gconcat.8 stable/10/sbin/geom/class/eli/geli.8 stable/10/sbin/geom/class/journal/gjournal.8 stable/10/sbin/geom/class/label/glabel.8 stable/10/sbin/geom/class/mirror/gmirror.8 stable/10/sbin/geom/class/mountver/gmountver.8 stable/10/sbin/geom/class/multipath/gmultipath.8 stable/10/sbin/geom/class/nop/gnop.8 stable/10/sbin/geom/class/part/gpart.8 stable/10/sbin/geom/class/raid/graid.8 stable/10/sbin/geom/class/raid3/graid3.8 stable/10/sbin/geom/class/sched/gsched.8 stable/10/sbin/geom/class/shsec/gshsec.8 stable/10/sbin/geom/class/stripe/gstripe.8 stable/10/sbin/geom/class/virstor/gvirstor.8 stable/10/sbin/geom/core/geom.8 stable/10/sbin/ggate/ggatec/ggatec.8 stable/10/sbin/ggate/ggated/ggated.8 stable/10/sbin/ggate/ggatel/ggatel.8 stable/10/sbin/growfs/growfs.8 stable/10/sbin/gvinum/gvinum.8 stable/10/sbin/hastctl/hastctl.8 stable/10/sbin/hastd/hast.conf.5 stable/10/sbin/hastd/hastd.8 stable/10/sbin/ipfw/ipfw.8 stable/10/sbin/kldconfig/kldconfig.8 stable/10/sbin/kldload/kldload.8 stable/10/sbin/kldstat/kldstat.8 stable/10/sbin/kldunload/kldunload.8 stable/10/sbin/md5/md5.1 stable/10/sbin/mdconfig/mdconfig.8 stable/10/sbin/mount/mount.conf.8 stable/10/sbin/mount_cd9660/mount_cd9660.8 stable/10/sbin/mount_msdosfs/mount_msdosfs.8 stable/10/sbin/mount_unionfs/mount_unionfs.8 stable/10/sbin/natd/natd.8 stable/10/sbin/newfs_msdos/newfs_msdos.8 stable/10/sbin/newfs_nandfs/newfs_nandfs.8 stable/10/sbin/nos-tun/nos-tun.8 stable/10/sbin/nvmecontrol/nvmecontrol.8 stable/10/sbin/rcorder/rcorder.8 stable/10/sbin/reboot/nextboot.8 stable/10/sbin/recoverdisk/recoverdisk.1 stable/10/sbin/sconfig/sconfig.8 stable/10/share/examples/mdoc/example.1 stable/10/share/examples/mdoc/example.3 stable/10/share/examples/mdoc/example.4 stable/10/share/examples/mdoc/example.9 stable/10/share/examples/scsi_target/scsi_target.8 stable/10/tools/tools/ether_reflect/ether_reflect.1 stable/10/tools/tools/fixwhite/fixwhite.1 stable/10/tools/tools/mcgrab/mcgrab.1 stable/10/tools/tools/mctest/mctest.1 stable/10/tools/tools/sysdoc/sysdoc.sh stable/10/tools/tools/vimage/vimage.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/chio/chio.1 ============================================================================== --- stable/10/bin/chio/chio.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/bin/chio/chio.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -302,13 +302,11 @@ first appeared in The .Nm program and SCSI changer driver were written by -.An Jason R. Thorpe Aq thorpej@and.com +.An Jason R. Thorpe Aq Mt thorpej@and.com for And Communications, .Pa http://www.and.com/ . .Pp Additional work by -.An Hans Huebner -.Aq hans@artcom.de +.An Hans Huebner Aq Mt hans@artcom.de and -.An Steve Gunn -.Aq csg@waterspout.com . +.An Steve Gunn Aq Mt csg@waterspout.com . Modified: stable/10/bin/freebsd-version/freebsd-version.1 ============================================================================== --- stable/10/bin/freebsd-version/freebsd-version.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/bin/freebsd-version/freebsd-version.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -121,4 +121,4 @@ command appeared in The .Nm utility and this manual page were written by -.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org . +.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org . Modified: stable/10/bin/pkill/pkill.1 ============================================================================== --- stable/10/bin/pkill/pkill.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/bin/pkill/pkill.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -291,5 +291,4 @@ Solaris 7. They made their first appearance in .Fx 5.3 . .Sh AUTHORS -.An Andrew Doran -.Aq ad@NetBSD.org +.An Andrew Doran Aq Mt ad@NetBSD.org Modified: stable/10/bin/setfacl/setfacl.1 ============================================================================== --- stable/10/bin/setfacl/setfacl.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/bin/setfacl/setfacl.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -487,6 +487,6 @@ NFSv4 ACL support was introduced in The .Nm utility was written by -.An Chris D. Faulhaber Aq jedgar@fxp.org . +.An Chris D. Faulhaber Aq Mt jedgar@fxp.org . NFSv4 ACL support was implemented by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . +.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org . Modified: stable/10/games/morse/morse.6 ============================================================================== --- stable/10/games/morse/morse.6 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/games/morse/morse.6 Sun Oct 16 22:02:50 2016 (r307403) @@ -177,7 +177,7 @@ device file Sound support for .Nm added by -.An Lyndon Nerenberg (VE6BBM) Aq lyndon@orthanc.ca . +.An Lyndon Nerenberg (VE6BBM) Aq Mt lyndon@orthanc.ca . .Pp Ability to key an external device added by .An J\(:org Wunsch Modified: stable/10/games/random/random.6 ============================================================================== --- stable/10/games/random/random.6 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/games/random/random.6 Sun Oct 16 22:02:50 2016 (r307403) @@ -117,7 +117,7 @@ instead of newlines. .Sh HISTORY The functionality to randomizing lines and words was added in 2003 by -.An "Sean Chittenden" Aq seanc@FreeBSD.org . +.An Sean Chittenden Aq Mt seanc@FreeBSD.org . .Sh BUGS No index is used when printing out tokens from the list which makes it rather slow for large files (10MB+). Modified: stable/10/sbin/adjkerntz/adjkerntz.8 ============================================================================== --- stable/10/sbin/adjkerntz/adjkerntz.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/adjkerntz/adjkerntz.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -190,4 +190,4 @@ The utility appeared in .Fx 1.0 . .Sh AUTHORS -.An Andrey A. Chernov Aq ache@astral.msk.su +.An Andrey A. Chernov Aq Mt ache@astral.msk.su Modified: stable/10/sbin/atm/atmconfig/atmconfig.8 ============================================================================== --- stable/10/sbin/atm/atmconfig/atmconfig.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/atm/atmconfig/atmconfig.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -316,4 +316,4 @@ List all NATM routes. .Xr natmip 4 , .Xr atm 8 .Sh AUTHORS -.An Hartmut Brandt Aq harti@FreeBSD.org +.An Hartmut Brandt Aq Mt harti@FreeBSD.org Modified: stable/10/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/10/sbin/camcontrol/camcontrol.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/camcontrol/camcontrol.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -2366,7 +2366,7 @@ and first appeared in in .Fx 2.0.5 . .Sh AUTHORS -.An Kenneth Merry Aq ken@FreeBSD.org +.An Kenneth Merry Aq Mt ken@FreeBSD.org .Sh BUGS The code that parses the generic command line arguments does not know that some of the subcommands take multiple arguments. Modified: stable/10/sbin/dhclient/dhclient-script.8 ============================================================================== --- stable/10/sbin/dhclient/dhclient-script.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/dhclient/dhclient-script.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -273,7 +273,7 @@ but current scripts do not do this. The original version of .Nm was written for the Internet Software Consortium by -.An Ted Lemon Aq mellon@fugue.com +.An Ted Lemon Aq Mt mellon@fugue.com in cooperation with Vixie Enterprises. .Pp The @@ -281,7 +281,7 @@ The implementation of .Nm was written by -.An Kenneth R. Westerback Aq krw@openbsd.org . +.An Kenneth R. Westerback Aq Mt krw@openbsd.org . .Sh BUGS If more than one interface is being used, there is no obvious way to avoid clashes between server-supplied configuration parameters - for Modified: stable/10/sbin/dhclient/dhclient.8 ============================================================================== --- stable/10/sbin/dhclient/dhclient.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/dhclient/dhclient.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -188,9 +188,9 @@ The .Nm utility was written by -.An Ted Lemon Aq mellon@fugue.com +.An Ted Lemon Aq Mt mellon@fugue.com and -.An Elliot Poger Aq elliot@poger.com . +.An Elliot Poger Aq Mt elliot@poger.com . .Pp The current implementation was reworked by -.An Henning Brauer Aq henning@openbsd.org . +.An Henning Brauer Aq Mt henning@openbsd.org . Modified: stable/10/sbin/dhclient/dhclient.conf.5 ============================================================================== --- stable/10/sbin/dhclient/dhclient.conf.5 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/dhclient/dhclient.conf.5 Sun Oct 16 22:02:50 2016 (r307403) @@ -537,8 +537,8 @@ The .Xr dhclient 8 utility was written by -.An Ted Lemon Aq mellon@vix.com +.An Ted Lemon Aq Mt mellon@vix.com under a contract with Vixie Labs. .Pp The current implementation was reworked by -.An Henning Brauer Aq henning@openbsd.org . +.An Henning Brauer Aq Mt henning@openbsd.org . Modified: stable/10/sbin/dhclient/dhclient.leases.5 ============================================================================== --- stable/10/sbin/dhclient/dhclient.leases.5 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/dhclient/dhclient.leases.5 Sun Oct 16 22:02:50 2016 (r307403) @@ -88,8 +88,8 @@ The .Xr dhclient 8 utility was written by -.An Ted Lemon Aq mellon@vix.com +.An Ted Lemon Aq Mt mellon@vix.com under a contract with Vixie Labs. .Pp The current implementation was reworked by -.An Henning Brauer Aq henning@openbsd.org . +.An Henning Brauer Aq Mt henning@openbsd.org . Modified: stable/10/sbin/dhclient/dhcp-options.5 ============================================================================== --- stable/10/sbin/dhclient/dhcp-options.5 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/dhclient/dhcp-options.5 Sun Oct 16 22:02:50 2016 (r307403) @@ -603,8 +603,8 @@ The .Xr dhcpd 8 utility was written by -.An Ted Lemon Aq mellon@vix.com +.An Ted Lemon Aq Mt mellon@vix.com under a contract with Vixie Labs. .Pp The current implementation was reworked by -.An Henning Brauer Aq henning@openbsd.org . +.An Henning Brauer Aq Mt henning@openbsd.org . Modified: stable/10/sbin/ffsinfo/ffsinfo.8 ============================================================================== --- stable/10/sbin/ffsinfo/ffsinfo.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/ffsinfo/ffsinfo.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -134,9 +134,9 @@ The utility first appeared in .Fx 4.4 . .Sh AUTHORS -.An Christoph Herrmann Aq chm@FreeBSD.org -.An Thomas-Henning von Kamptz Aq tomsoft@FreeBSD.org -.An The GROWFS team Aq growfs@Tomsoft.COM +.An Christoph Herrmann Aq Mt chm@FreeBSD.org +.An Thomas-Henning von Kamptz Aq Mt tomsoft@FreeBSD.org +.An The GROWFS team Aq Mt growfs@Tomsoft.COM .Sh BUGS Snapshots are handled like plain files. They should get their own level to provide for independent control of the Modified: stable/10/sbin/fsirand/fsirand.8 ============================================================================== --- stable/10/sbin/fsirand/fsirand.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/fsirand/fsirand.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -107,7 +107,7 @@ A version first appeared in .Fx 2.2.5 . .Sh AUTHORS -.An Todd C. Miller Aq Todd.Miller@courtesan.com +.An Todd C. Miller Aq Mt Todd.Miller@courtesan.com .Sh CAVEATS Since .Nm Modified: stable/10/sbin/gbde/gbde.8 ============================================================================== --- stable/10/sbin/gbde/gbde.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/gbde/gbde.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -243,7 +243,7 @@ To destroy all copies of the masterkey: This software was developed for the .Fx Project by -.An "Poul-Henning Kamp" +.An Poul-Henning Kamp and NAI Labs, the Security Research Division of Network Associates, Inc.\& under DARPA/SPAWAR contract N66001-01-C-8035 .Pq Dq CBOSS , @@ -253,7 +253,7 @@ DARPA CHATS research program. first appeared in .Fx 5.0 . .Sh AUTHORS -.An "Poul-Henning Kamp" Aq phk@FreeBSD.org +.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .Sh BUGS The cryptographic algorithms and the overall design have not been attacked mercilessly for over 10 years by a gang of cryptoanalysts. Modified: stable/10/sbin/geom/class/cache/gcache.8 ============================================================================== --- stable/10/sbin/geom/class/cache/gcache.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/cache/gcache.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -189,4 +189,4 @@ The utility appeared in .Fx 7.0 . .Sh AUTHORS -.An Ruslan Ermilov Aq ru@FreeBSD.org +.An Ruslan Ermilov Aq Mt ru@FreeBSD.org Modified: stable/10/sbin/geom/class/concat/gconcat.8 ============================================================================== --- stable/10/sbin/geom/class/concat/gconcat.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/concat/gconcat.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -194,4 +194,4 @@ The utility appeared in .Fx 5.3 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/geom/class/eli/geli.8 ============================================================================== --- stable/10/sbin/geom/class/eli/geli.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/eli/geli.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -1057,4 +1057,4 @@ metadata version supported by the given .It Li 10.0 Ta 7 .El .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/geom/class/journal/gjournal.8 ============================================================================== --- stable/10/sbin/geom/class/journal/gjournal.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/journal/gjournal.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -343,4 +343,4 @@ The utility appeared in .Fx 7.0 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/geom/class/label/glabel.8 ============================================================================== --- stable/10/sbin/geom/class/label/glabel.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/label/glabel.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -241,4 +241,4 @@ The utility appeared in .Fx 5.3 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/geom/class/mirror/gmirror.8 ============================================================================== --- stable/10/sbin/geom/class/mirror/gmirror.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/mirror/gmirror.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -378,7 +378,7 @@ The utility appeared in .Fx 5.3 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .Sh BUGS There should be a way to change a component's priority inside a running mirror. .Pp Modified: stable/10/sbin/geom/class/mountver/gmountver.8 ============================================================================== --- stable/10/sbin/geom/class/mountver/gmountver.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/mountver/gmountver.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -127,4 +127,4 @@ The utility appeared in .Fx 9.0 . .Sh AUTHORS -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org +.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org Modified: stable/10/sbin/geom/class/multipath/gmultipath.8 ============================================================================== --- stable/10/sbin/geom/class/multipath/gmultipath.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/multipath/gmultipath.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -360,6 +360,6 @@ GEOM_MULTIPATH: da2 added to FRED .Xr mount 8 , .Xr newfs 8 , .Xr sysctl 8 -.Sh AUTHOR -.An Matthew Jacob Aq mjacob@FreeBSD.org -.An Alexander Motin Aq mav@FreeBSD.org +.Sh AUTHORS +.An Matthew Jacob Aq Mt mjacob@FreeBSD.org +.An Alexander Motin Aq Mt mav@FreeBSD.org Modified: stable/10/sbin/geom/class/nop/gnop.8 ============================================================================== --- stable/10/sbin/geom/class/nop/gnop.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/nop/gnop.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -183,4 +183,4 @@ The utility appeared in .Fx 5.3 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/geom/class/part/gpart.8 ============================================================================== --- stable/10/sbin/geom/class/part/gpart.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/part/gpart.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -1331,4 +1331,4 @@ The utility appeared in .Fx 7.0 . .Sh AUTHORS -.An Marcel Moolenaar Aq marcel@FreeBSD.org +.An Marcel Moolenaar Aq Mt marcel@FreeBSD.org Modified: stable/10/sbin/geom/class/raid/graid.8 ============================================================================== --- stable/10/sbin/geom/class/raid/graid.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/raid/graid.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -320,5 +320,5 @@ The utility appeared in .Fx 9.0 . .Sh AUTHORS -.An Alexander Motin Aq mav@FreeBSD.org -.An M. Warner Losh Aq imp@FreeBSD.org +.An Alexander Motin Aq Mt mav@FreeBSD.org +.An M. Warner Losh Aq Mt imp@FreeBSD.org Modified: stable/10/sbin/geom/class/raid3/graid3.8 ============================================================================== --- stable/10/sbin/geom/class/raid3/graid3.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/raid3/graid3.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -248,7 +248,7 @@ The utility appeared in .Fx 5.3 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .Sh BUGS There should be a section with an implementation description. .Pp Modified: stable/10/sbin/geom/class/sched/gsched.8 ============================================================================== --- stable/10/sbin/geom/class/sched/gsched.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/sched/gsched.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -158,5 +158,5 @@ The utility first appeared in .Fx 8.1 . .Sh AUTHORS -.An Fabio Checconi Aq fabio@FreeBSD.org -.An Luigi Rizzo Aq luigi@FreeBSD.org +.An Fabio Checconi Aq Mt fabio@FreeBSD.org +.An Luigi Rizzo Aq Mt luigi@FreeBSD.org Modified: stable/10/sbin/geom/class/shsec/gshsec.8 ============================================================================== --- stable/10/sbin/geom/class/shsec/gshsec.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/shsec/gshsec.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -127,4 +127,4 @@ The utility appeared in .Fx 5.4 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/geom/class/stripe/gstripe.8 ============================================================================== --- stable/10/sbin/geom/class/stripe/gstripe.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/stripe/gstripe.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -240,4 +240,4 @@ The utility appeared in .Fx 5.3 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/geom/class/virstor/gvirstor.8 ============================================================================== --- stable/10/sbin/geom/class/virstor/gvirstor.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/class/virstor/gvirstor.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -293,7 +293,7 @@ and all their structures will be physica of the first virstor component. This could have a significant impact on file system performance .Pq which can in some rare cases be even positive . -.Sh AUTHOR -.An Ivan Voras Aq ivoras@FreeBSD.org +.Sh AUTHORS +.An Ivan Voras Aq Mt ivoras@FreeBSD.org .Pp Sponsored by Google Summer of Code 2006. Modified: stable/10/sbin/geom/core/geom.8 ============================================================================== --- stable/10/sbin/geom/core/geom.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/geom/core/geom.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -203,4 +203,4 @@ The utility appeared in .Fx 5.3 . .Sh AUTHORS -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org Modified: stable/10/sbin/ggate/ggatec/ggatec.8 ============================================================================== --- stable/10/sbin/ggate/ggatec/ggatec.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/ggate/ggatec/ggatec.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -177,4 +177,4 @@ client# mount_cd9660 /dev/ggate0 /cdrom The .Nm utility as well as this manual page was written by -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org . Modified: stable/10/sbin/ggate/ggated/ggated.8 ============================================================================== --- stable/10/sbin/ggate/ggated/ggated.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/ggate/ggated/ggated.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -120,4 +120,4 @@ Export CD-ROM device and a file: The .Nm utility as well as this manual page was written by -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org . Modified: stable/10/sbin/ggate/ggatel/ggatel.8 ============================================================================== --- stable/10/sbin/ggate/ggatel/ggatel.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/ggate/ggatel/ggatel.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -154,4 +154,4 @@ ggatel destroy -u 5 The .Nm utility as well as this manual page was written by -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org . Modified: stable/10/sbin/growfs/growfs.8 ============================================================================== --- stable/10/sbin/growfs/growfs.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/growfs/growfs.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -120,10 +120,10 @@ utility first appeared in The ability to resize mounted file systems was added in .Fx 10.0 . .Sh AUTHORS -.An Christoph Herrmann Aq chm@FreeBSD.org -.An Thomas-Henning von Kamptz Aq tomsoft@FreeBSD.org -.An The GROWFS team Aq growfs@Tomsoft.COM -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org +.An Christoph Herrmann Aq Mt chm@FreeBSD.org +.An Thomas-Henning von Kamptz Aq Mt tomsoft@FreeBSD.org +.An The GROWFS team Aq Mt growfs@Tomsoft.COM +.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org .Sh CAVEATS When expanding a file system mounted read-write, any writes to that file system will be temporarily suspended until the expansion is finished. Modified: stable/10/sbin/gvinum/gvinum.8 ============================================================================== --- stable/10/sbin/gvinum/gvinum.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/gvinum/gvinum.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -395,9 +395,9 @@ and through the 2007 Google Summer of Code program. The documentation have been updated to reflect the new functionality. .Sh AUTHORS -.An Lukas Ertl Aq le@FreeBSD.org -.An Chris Jones Aq soc-cjones@FreeBSD.org -.An Ulf Lilleengen Aq lulf@FreeBSD.org +.An Lukas Ertl Aq Mt le@FreeBSD.org +.An Chris Jones Aq Mt soc-cjones@FreeBSD.org +.An Ulf Lilleengen Aq Mt lulf@FreeBSD.org .Sh BUGS Currently, .Nm Modified: stable/10/sbin/hastctl/hastctl.8 ============================================================================== --- stable/10/sbin/hastctl/hastctl.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/hastctl/hastctl.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -224,5 +224,5 @@ nodeB# application_start The .Nm was developed by -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org under sponsorship of the FreeBSD Foundation. Modified: stable/10/sbin/hastd/hast.conf.5 ============================================================================== --- stable/10/sbin/hastd/hast.conf.5 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/hastd/hast.conf.5 Sun Oct 16 22:02:50 2016 (r307403) @@ -445,5 +445,5 @@ resource tank { The .Nm was written by -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org under sponsorship of the FreeBSD Foundation. Modified: stable/10/sbin/hastd/hastd.8 ============================================================================== --- stable/10/sbin/hastd/hastd.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/hastd/hastd.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -228,5 +228,5 @@ nodeA# mount -o noatime /dev/hast/shared The .Nm was developed by -.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org +.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org under sponsorship of the FreeBSD Foundation. Modified: stable/10/sbin/ipfw/ipfw.8 ============================================================================== --- stable/10/sbin/ipfw/ipfw.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/ipfw/ipfw.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -3381,7 +3381,7 @@ options have been added by various devel .Pp .An -nosplit In-kernel NAT support written by -.An Paolo Pisati Aq piso@FreeBSD.org +.An Paolo Pisati Aq Mt piso@FreeBSD.org as part of a Summer of Code 2005 project. .Pp SCTP Modified: stable/10/sbin/kldconfig/kldconfig.8 ============================================================================== --- stable/10/sbin/kldconfig/kldconfig.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/kldconfig/kldconfig.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -105,4 +105,4 @@ The utility first appeared in .Fx 4.4 . .Sh AUTHORS -.An Peter Pentchev Aq roam@FreeBSD.org +.An Peter Pentchev Aq Mt roam@FreeBSD.org Modified: stable/10/sbin/kldload/kldload.8 ============================================================================== --- stable/10/sbin/kldload/kldload.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/kldload/kldload.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -126,4 +126,4 @@ replacing the .Nm lkm interface. .Sh AUTHORS -.An Doug Rabson Aq dfr@FreeBSD.org +.An Doug Rabson Aq Mt dfr@FreeBSD.org Modified: stable/10/sbin/kldstat/kldstat.8 ============================================================================== --- stable/10/sbin/kldstat/kldstat.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/kldstat/kldstat.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -78,4 +78,4 @@ replacing the .Nm lkm interface. .Sh AUTHORS -.An Doug Rabson Aq dfr@FreeBSD.org +.An Doug Rabson Aq Mt dfr@FreeBSD.org Modified: stable/10/sbin/kldunload/kldunload.8 ============================================================================== --- stable/10/sbin/kldunload/kldunload.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/kldunload/kldunload.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -78,4 +78,4 @@ replacing the .Nm lkm interface. .Sh AUTHORS -.An Doug Rabson Aq dfr@FreeBSD.org +.An Doug Rabson Aq Mt dfr@FreeBSD.org Modified: stable/10/sbin/md5/md5.1 ============================================================================== --- stable/10/sbin/md5/md5.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/md5/md5.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -154,4 +154,4 @@ This program is placed in the public dom RSA Data Security. .Pp Support for SHA-1 and RIPEMD-160 has been added by -.An Oliver Eikemeier Aq eik@FreeBSD.org . +.An Oliver Eikemeier Aq Mt eik@FreeBSD.org . Modified: stable/10/sbin/mdconfig/mdconfig.8 ============================================================================== --- stable/10/sbin/mdconfig/mdconfig.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/mdconfig/mdconfig.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -321,5 +321,4 @@ combo. The .Nm utility was written by -.An Poul-Henning Kamp -.Aq phk@FreeBSD.org . +.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . Modified: stable/10/sbin/mount/mount.conf.8 ============================================================================== --- stable/10/sbin/mount/mount.conf.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/mount/mount.conf.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -247,6 +247,6 @@ The root mount logic in the kernel which parses .Pa /.mount.conf was written by -.An Marcel Moolenaar Aq marcel@FreeBSD.org . +.An Marcel Moolenaar Aq Mt marcel@FreeBSD.org . This man page was written by -.An Craig Rodrigues Aq rodrigc@FreeBSD.org . +.An Craig Rodrigues Aq Mt rodrigc@FreeBSD.org . Modified: stable/10/sbin/mount_cd9660/mount_cd9660.8 ============================================================================== --- stable/10/sbin/mount_cd9660/mount_cd9660.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/mount_cd9660/mount_cd9660.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -147,7 +147,7 @@ utility first appeared in .Bx 4.4 . .Pp The Unicode conversion routine was added by -.An Ryuichiro Imura Aq imura@ryu16.org +.An Ryuichiro Imura Aq Mt imura@ryu16.org in 2003. .Sh BUGS POSIX device node mapping is currently not supported. Modified: stable/10/sbin/mount_msdosfs/mount_msdosfs.8 ============================================================================== --- stable/10/sbin/mount_msdosfs/mount_msdosfs.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/mount_msdosfs/mount_msdosfs.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -213,8 +213,8 @@ of the more aptly-named .Nm . .Pp The character code conversion routine was added by -.An Ryuichiro Imura Aq imura@ryu16.org -at 2003. +.An Ryuichiro Imura Aq Mt imura@ryu16.org +in 2003. .Sh CAVEATS The use of the .Fl 9 Modified: stable/10/sbin/mount_unionfs/mount_unionfs.8 ============================================================================== --- stable/10/sbin/mount_unionfs/mount_unionfs.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/mount_unionfs/mount_unionfs.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -342,9 +342,9 @@ because this is identical to using .An -nosplit In .Fx 7.0 , -.An Masanori OZAWA Aq ozawa@ongs.co.jp +.An Masanori OZAWA Aq Mt ozawa@ongs.co.jp reimplemented handling of locking, whiteout, and file mode bits, and -.An Hiroki Sato Aq hrs@FreeBSD.org +.An Hiroki Sato Aq Mt hrs@FreeBSD.org wrote about the changes in this manual page. .Sh BUGS THIS FILE SYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK) @@ -357,7 +357,7 @@ BATTERIES NOT INCLUDED. .Pp This code also needs an owner in order to be less dangerous - serious hackers can apply by sending mail to -.Aq freebsd-fs@FreeBSD.org +.Aq Mt freebsd-fs@FreeBSD.org and announcing their intent to take it over. .Pp Modified: stable/10/sbin/natd/natd.8 ============================================================================== --- stable/10/sbin/natd/natd.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/natd/natd.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -813,19 +813,19 @@ are forwarded to the appropriate router This program is the result of the efforts of many people at different times: .Pp -.An Archie Cobbs Aq archie@FreeBSD.org +.An Archie Cobbs Aq Mt archie@FreeBSD.org (divert sockets) -.An Charles Mott Aq cm@linktel.net +.An Charles Mott Aq Mt cm@linktel.net (packet aliasing) -.An Eivind Eklund Aq perhaps@yes.no +.An Eivind Eklund Aq Mt perhaps@yes.no (IRC support & misc additions) -.An Ari Suutari Aq suutari@iki.fi +.An Ari Suutari Aq Mt suutari@iki.fi (natd) -.An Dru Nelson Aq dnelson@redwoodsoft.com +.An Dru Nelson Aq Mt dnelson@redwoodsoft.com (early PPTP support) -.An Brian Somers Aq brian@awfulhak.org +.An Brian Somers Aq Mt brian@awfulhak.org (glue) -.An Ruslan Ermilov Aq ru@FreeBSD.org +.An Ruslan Ermilov Aq Mt ru@FreeBSD.org (natd, packet aliasing, glue) -.An Poul-Henning Kamp Aq phk@FreeBSD.org +.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org (multiple instances) Modified: stable/10/sbin/newfs_msdos/newfs_msdos.8 ============================================================================== --- stable/10/sbin/newfs_msdos/newfs_msdos.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/newfs_msdos/newfs_msdos.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -236,4 +236,4 @@ The utility first appeared in .Fx 3.0 . .Sh AUTHORS -.An Robert Nordier Aq rnordier@FreeBSD.org . +.An Robert Nordier Aq Mt rnordier@FreeBSD.org Modified: stable/10/sbin/newfs_nandfs/newfs_nandfs.8 ============================================================================== --- stable/10/sbin/newfs_nandfs/newfs_nandfs.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/newfs_nandfs/newfs_nandfs.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -70,5 +70,5 @@ The .Nm utility first appeared in .Fx 10.0 . -.Sh AUTHOR +.Sh AUTHORS .An Grzegorz Bernacki Modified: stable/10/sbin/nos-tun/nos-tun.8 ============================================================================== --- stable/10/sbin/nos-tun/nos-tun.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/nos-tun/nos-tun.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -82,11 +82,11 @@ tunnel source 192.168.56.45 .Ed .Sh AUTHORS .An -nosplit -.An Nickolay N. Dudorov Aq nnd@itfs.nsk.su +.An Nickolay N. Dudorov Aq Mt nnd@itfs.nsk.su wrote the program, -.An Poul-Henning Kamp Aq phk@FreeBSD.org +.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org wrote the man-page. -.An Isao SEKI Aq iseki@gongon.com +.An Isao SEKI Aq Mt iseki@gongon.com added a new flag, IP protocol number. .Sh BUGS We do not allow for setting our source address for multihomed machines. Modified: stable/10/sbin/nvmecontrol/nvmecontrol.8 ============================================================================== --- stable/10/sbin/nvmecontrol/nvmecontrol.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/nvmecontrol/nvmecontrol.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -124,7 +124,7 @@ nvme0 controller and activate it on the .An -nosplit .Nm was developed by Intel and originally written by -.An Jim Harris Aq jimharris@FreeBSD.org . +.An Jim Harris Aq Mt jimharris@FreeBSD.org . .Pp This man page was written by -.An Jim Harris Aq jimharris@FreeBSD.org . +.An Jim Harris Aq Mt jimharris@FreeBSD.org . Modified: stable/10/sbin/rcorder/rcorder.8 ============================================================================== --- stable/10/sbin/rcorder/rcorder.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/rcorder/rcorder.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -165,9 +165,9 @@ utility first appeared in .Sh AUTHORS .An -nosplit Written by -.An Perry E. Metzger Aq perry@piermont.com +.An Perry E. Metzger Aq Mt perry@piermont.com and -.An Matthew R. Green Aq mrg@eterna.com.au . +.An Matthew R. Green Aq Mt mrg@eterna.com.au . .Sh BUGS The .Dq Li REQUIRE Modified: stable/10/sbin/reboot/nextboot.8 ============================================================================== --- stable/10/sbin/reboot/nextboot.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/reboot/nextboot.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -118,7 +118,7 @@ appeared in .Fx 5.0 . .Sh AUTHORS This manual page was written by -.An Gordon Tetlow Aq gordon@FreeBSD.org . +.An Gordon Tetlow Aq Mt gordon@FreeBSD.org . .Sh BUGS The .Nm Modified: stable/10/sbin/recoverdisk/recoverdisk.1 ============================================================================== --- stable/10/sbin/recoverdisk/recoverdisk.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/recoverdisk/recoverdisk.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -137,9 +137,9 @@ utility first appeared in .Sh AUTHORS .An -nosplit The original implementation was done by -.An Poul-Henning Kamp Aq phk@FreeBSD.org +.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org with minor improvements from -.An Ulrich Sp\(:orlein Aq uqs@FreeBSD.org . +.An Ulrich Sp\(:orlein Aq Mt uqs@FreeBSD.org . .Pp This manual page was written by .An Ulrich Sp\(:orlein . Modified: stable/10/sbin/sconfig/sconfig.8 ============================================================================== --- stable/10/sbin/sconfig/sconfig.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/sbin/sconfig/sconfig.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -595,7 +595,7 @@ versions of the utility are not fully compatible. .\"-------------------------------------------------------------- .Sh AUTHORS -.An Cronyx Engineering Aq info@cronyx.ru +.An Cronyx Engineering Aq Mt info@cronyx.ru .Pp .Pa http://www.cronyx.ru .\"-------------------------------------------------------------- Modified: stable/10/share/examples/mdoc/example.1 ============================================================================== --- stable/10/share/examples/mdoc/example.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/share/examples/mdoc/example.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -150,6 +150,6 @@ manual page example first appeared in .Sh AUTHORS This manual page was written by -.An Mike Pritchard Aq mpp@FreeBSD.org . +.An Mike Pritchard Aq Mt mpp@FreeBSD.org . .Sh BUGS The actual code for this command is vaporware. Modified: stable/10/share/examples/mdoc/example.3 ============================================================================== --- stable/10/share/examples/mdoc/example.3 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/share/examples/mdoc/example.3 Sun Oct 16 22:02:50 2016 (r307403) @@ -330,6 +330,6 @@ manual page example first appeared in .Sh AUTHORS This manual page was written by -.An Mike Pritchard Aq mpp@FreeBSD.org . +.An Mike Pritchard Aq Mt mpp@FreeBSD.org . .Sh BUGS The actual code for this function is vaporware. Modified: stable/10/share/examples/mdoc/example.4 ============================================================================== --- stable/10/share/examples/mdoc/example.4 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/share/examples/mdoc/example.4 Sun Oct 16 22:02:50 2016 (r307403) @@ -118,6 +118,6 @@ manual page example first appeared in .At v6 . .Sh AUTHORS This manual page was written by -.An Mike Pritchard Aq mpp@FreeBSD.org . +.An Mike Pritchard Aq Mt mpp@FreeBSD.org . .Sh BUGS The actual code for this device driver is vaporware. Modified: stable/10/share/examples/mdoc/example.9 ============================================================================== --- stable/10/share/examples/mdoc/example.9 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/share/examples/mdoc/example.9 Sun Oct 16 22:02:50 2016 (r307403) @@ -338,6 +338,6 @@ manual page example first appeared in .Sh AUTHORS This manual page was written by -.An Giorgos Keramidas Aq keramida@FreeBSD.org . +.An Giorgos Keramidas Aq Mt keramida@FreeBSD.org . .Sh BUGS The actual code for this function is vaporware. Modified: stable/10/share/examples/scsi_target/scsi_target.8 ============================================================================== --- stable/10/share/examples/scsi_target/scsi_target.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/share/examples/scsi_target/scsi_target.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -155,4 +155,4 @@ and was written by It was rewritten for .Fx 5.0 by -.An Nate Lawson Aq nate@root.org . +.An Nate Lawson Aq Mt nate@root.org . Modified: stable/10/tools/tools/ether_reflect/ether_reflect.1 ============================================================================== --- stable/10/tools/tools/ether_reflect/ether_reflect.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/tools/tools/ether_reflect/ether_reflect.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -103,6 +103,7 @@ program first appeared in .Sh AUTHORS This manual page was written by -.An George V. Neville-Neil Aq gnn@FreeBSD.org . +.An George V. Neville-Neil Aq Mt gnn@FreeBSD.org . .Sh BUGS -Should be reported to the author or to net@FreeBSD.org. +Should be reported to the author or to +.Aq Mt net@FreeBSD.org . Modified: stable/10/tools/tools/fixwhite/fixwhite.1 ============================================================================== --- stable/10/tools/tools/fixwhite/fixwhite.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/tools/tools/fixwhite/fixwhite.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -45,4 +45,4 @@ If the whitespace at the beginning of a of eight spaces, the whitespace is replaced by tabs. Also, spaces preceding tabs will be merged into the tab character. .Sh AUTHORS -.An Ed Schouten Aq ed@FreeBSD.org +.An Ed Schouten Aq Mt ed@FreeBSD.org Modified: stable/10/tools/tools/mcgrab/mcgrab.1 ============================================================================== --- stable/10/tools/tools/mcgrab/mcgrab.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/tools/tools/mcgrab/mcgrab.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -77,7 +77,7 @@ program first appeared in .Sh AUTHORS This manual page was written by -.An George V. Neville-Neil Aq gnn@FreeBSD.org . +.An George V. Neville-Neil Aq Mt gnn@FreeBSD.org . .Sh BUGS Should be reported to the author or to -.Aq net@FreeBSD.org . +.Aq Mt net@FreeBSD.org . Modified: stable/10/tools/tools/mctest/mctest.1 ============================================================================== --- stable/10/tools/tools/mctest/mctest.1 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/tools/tools/mctest/mctest.1 Sun Oct 16 22:02:50 2016 (r307403) @@ -115,7 +115,7 @@ program first appeared in .Sh AUTHORS This manual page was written by -.An George V. Neville-Neil Aq gnn@FreeBSD.org . +.An George V. Neville-Neil Aq Mt gnn@FreeBSD.org . .Sh BUGS Should be reported to the author or to -.Aq net@FreeBSD.org . +.Aq Mt net@FreeBSD.org . Modified: stable/10/tools/tools/sysdoc/sysdoc.sh ============================================================================== --- stable/10/tools/tools/sysdoc/sysdoc.sh Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/tools/tools/sysdoc/sysdoc.sh Sun Oct 16 22:02:50 2016 (r307403) @@ -59,12 +59,12 @@ implementation, see the respecting manua This manual page is automatically generated by a set of scripts written by .An -nosplit -.An Tom Rhodes Aq trhodes@FreeBSD.org , +.An Tom Rhodes Aq Mt trhodes@FreeBSD.org , with significant contributions from -.An Giorgos Keramidas Aq keramida@FreeBSD.org , -.An Ruslan Ermilov Aq ru@FreeBSD.org , +.An Giorgos Keramidas Aq Mt keramida@FreeBSD.org , +.An Ruslan Ermilov Aq Mt ru@FreeBSD.org , and -.An Marc Silver Aq marcs@draenor.org . +.An Marc Silver Aq Mt marcs@draenor.org . .Sh BUGS Sometimes .Fx Modified: stable/10/tools/tools/vimage/vimage.8 ============================================================================== --- stable/10/tools/tools/vimage/vimage.8 Sun Oct 16 20:59:28 2016 (r307402) +++ stable/10/tools/tools/vimage/vimage.8 Sun Oct 16 22:02:50 2016 (r307403) @@ -188,8 +188,8 @@ of the main FreeBSD tree. As a result of a project sponsored by the FreeBSD Foundation and Stiching NLNet, integrated virtualized network stack first appeared in FreeBSD 8.0. +.Sh AUTHORS +.An Marko Zec Aq Mt zec@fer.hr .Sh BUGS Deletion of vimages / vnets is known to leak kernel memory and fail at stopping various timers, hence may lead to system crashes. -.Sh AUTHOR -.An "Marko Zec" Aq zec@fer.hr From owner-svn-src-stable@freebsd.org Sun Oct 16 22:22:47 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 845FDC1469C; Sun, 16 Oct 2016 22:22:47 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 396751E22; Sun, 16 Oct 2016 22:22:47 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMMk0Y098741; Sun, 16 Oct 2016 22:22:46 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMMkAU098740; Sun, 16 Oct 2016 22:22:46 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162222.u9GMMkAU098740@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:22:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307404 - stable/10/sbin/mount_msdosfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:22:47 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:22:46 2016 New Revision: 307404 URL: https://svnweb.freebsd.org/changeset/base/307404 Log: MFC r306611: Amend history to mention predecessor originated from 386BSD[1] & current implementation from NetBSD[2]. Reword history since the utility was renamed once more in FreeBSD 5.0. Separate out author & historical information regarding character code conversion. Add AUTHORS section. [1] https://groups.google.com/forum/#!search/mount_pcfs.c/comp.unix.bsd/9qhH0v1tZm0/inlPnXZj_2sJ [2] http://cvsweb.netbsd.org/bsdweb.cgi/src/sbin/mount_msdos/mount_msdos.c?rev=1.6&content-type=text/x-cvsweb-markup PR: 212536 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/mount_msdosfs/mount_msdosfs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/mount_msdosfs/mount_msdosfs.8 ============================================================================== --- stable/10/sbin/mount_msdosfs/mount_msdosfs.8 Sun Oct 16 22:02:50 2016 (r307403) +++ stable/10/sbin/mount_msdosfs/mount_msdosfs.8 Sun Oct 16 22:22:46 2016 (r307404) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 3, 2016 .Dt MOUNT_MSDOSFS 8 .Os .Sh NAME @@ -200,21 +200,32 @@ To mount a Japanese MS-DOS file system l List of Localized MS Operating Systems: .Pa http://www.microsoft.com/globaldev/reference/oslocversion.mspx . .Sh HISTORY -The -.Nm -utility first appeared in +The predecessor to +.Nm mount_msdos +utility named +.Nm mount_pcfs +appeared in +.Bx 386 . +It was rewritten in +.Nx 1.0 +and first appeared in .Fx 2.0 . -Its predecessor, the +.Nm mount_msdos +was renamed to the more aptly-named +.Nm +in +.Fx 5.0. +The character code conversion routine was added in 2003. +.Sh AUTHORS +Initial implementation as .Nm mount_pcfs -utility appeared in -.Fx 1.0 , -and was abandoned in favor -of the more aptly-named -.Nm . -.Pp +was written by +.An -nosplit +.An Paul Popelka Aq Mt paulp@uts.amdahl.com . +It was rewritten by +.An Christopher G. Demetriou Aq Mt cgd@NetBSD.org . The character code conversion routine was added by -.An Ryuichiro Imura Aq Mt imura@ryu16.org -in 2003. +.An Ryuichiro Imura Aq Mt imura@ryu16.org . .Sh CAVEATS The use of the .Fl 9 From owner-svn-src-stable@freebsd.org Sun Oct 16 22:26:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 141DFC147DF; Sun, 16 Oct 2016 22:26:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D7F571001; Sun, 16 Oct 2016 22:26:40 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMQd51098953; Sun, 16 Oct 2016 22:26:39 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMQdeI098952; Sun, 16 Oct 2016 22:26:39 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162226.u9GMQdeI098952@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:26:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307405 - stable/11/sbin/mount_nullfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:26:41 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:26:39 2016 New Revision: 307405 URL: https://svnweb.freebsd.org/changeset/base/307405 Log: MFC r306612: Note the name change from mount_null to mount_nullfs in FreeBSD 5.0. PR: 212541 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/mount_nullfs/mount_nullfs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mount_nullfs/mount_nullfs.8 ============================================================================== --- stable/11/sbin/mount_nullfs/mount_nullfs.8 Sun Oct 16 22:22:46 2016 (r307404) +++ stable/11/sbin/mount_nullfs/mount_nullfs.8 Sun Oct 16 22:26:39 2016 (r307405) @@ -33,7 +33,7 @@ .\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95 .\" $FreeBSD$ .\" -.Dd May 1, 1995 +.Dd October 3, 2016 .Dt MOUNT_NULLFS 8 .Os .Sh NAME @@ -240,6 +240,10 @@ UCLA Technical Report CSD-910056, .Em "Stackable Layers: an Architecture for File System Development" . .Sh HISTORY The -.Nm +.Nm mount_null utility first appeared in .Bx 4.4 . +It was renamed to +.Nm +in +.Fx 5.0 . From owner-svn-src-stable@freebsd.org Sun Oct 16 22:27:17 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A19B5C14845; Sun, 16 Oct 2016 22:27:17 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7317B115B; Sun, 16 Oct 2016 22:27:17 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMRG86099040; Sun, 16 Oct 2016 22:27:16 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMRGG8099039; Sun, 16 Oct 2016 22:27:16 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162227.u9GMRGG8099039@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:27:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307406 - stable/10/sbin/mount_nullfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:27:17 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:27:16 2016 New Revision: 307406 URL: https://svnweb.freebsd.org/changeset/base/307406 Log: MFC r306612: Note the name change from mount_null to mount_nullfs in FreeBSD 5.0. PR: 212541 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/mount_nullfs/mount_nullfs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/mount_nullfs/mount_nullfs.8 ============================================================================== --- stable/10/sbin/mount_nullfs/mount_nullfs.8 Sun Oct 16 22:26:39 2016 (r307405) +++ stable/10/sbin/mount_nullfs/mount_nullfs.8 Sun Oct 16 22:27:16 2016 (r307406) @@ -33,7 +33,7 @@ .\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95 .\" $FreeBSD$ .\" -.Dd May 1, 1995 +.Dd October 3, 2016 .Dt MOUNT_NULLFS 8 .Os .Sh NAME @@ -240,6 +240,10 @@ UCLA Technical Report CSD-910056, .Em "Stackable Layers: an Architecture for File System Development" . .Sh HISTORY The -.Nm +.Nm mount_null utility first appeared in .Bx 4.4 . +It was renamed to +.Nm +in +.Fx 5.0 . From owner-svn-src-stable@freebsd.org Sun Oct 16 22:31:11 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95FDCC14A21; Sun, 16 Oct 2016 22:31:11 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 640A116FC; Sun, 16 Oct 2016 22:31:11 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMVAfH099941; Sun, 16 Oct 2016 22:31:10 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMVA6T099940; Sun, 16 Oct 2016 22:31:10 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162231.u9GMVA6T099940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:31:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307407 - stable/11/sbin/mount_unionfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:31:11 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:31:10 2016 New Revision: 307407 URL: https://svnweb.freebsd.org/changeset/base/307407 Log: MFC r306613: Note the change of name in FreeBSD 5.0. PR: 212542 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/mount_unionfs/mount_unionfs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mount_unionfs/mount_unionfs.8 ============================================================================== --- stable/11/sbin/mount_unionfs/mount_unionfs.8 Sun Oct 16 22:27:16 2016 (r307406) +++ stable/11/sbin/mount_unionfs/mount_unionfs.8 Sun Oct 16 22:31:10 2016 (r307407) @@ -31,7 +31,7 @@ .\" @(#)mount_union.8 8.6 (Berkeley) 3/27/94 .\" $FreeBSD$ .\" -.Dd November 30, 2006 +.Dd October 3, 2016 .Dt MOUNT_UNIONFS 8 .Os .Sh NAME @@ -328,9 +328,13 @@ accessible via .Xr mount_nullfs 8 .Sh HISTORY The -.Nm +.Nm mount_null utility first appeared in .Bx 4.4 . +It was renamed to +.Nm +in +.Fx 5.0 . .Pp The .Fl r From owner-svn-src-stable@freebsd.org Sun Oct 16 22:31:52 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C64D7C14CB9; Sun, 16 Oct 2016 22:31:52 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 94AF91A8B; Sun, 16 Oct 2016 22:31:52 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMVphF000126; Sun, 16 Oct 2016 22:31:51 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMVp0q000125; Sun, 16 Oct 2016 22:31:51 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162231.u9GMVp0q000125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:31:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307408 - stable/10/sbin/mount_unionfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:31:52 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:31:51 2016 New Revision: 307408 URL: https://svnweb.freebsd.org/changeset/base/307408 Log: MFC r306613: Note the change of name in FreeBSD 5.0. PR: 212542 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/mount_unionfs/mount_unionfs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/mount_unionfs/mount_unionfs.8 ============================================================================== --- stable/10/sbin/mount_unionfs/mount_unionfs.8 Sun Oct 16 22:31:10 2016 (r307407) +++ stable/10/sbin/mount_unionfs/mount_unionfs.8 Sun Oct 16 22:31:51 2016 (r307408) @@ -31,7 +31,7 @@ .\" @(#)mount_union.8 8.6 (Berkeley) 3/27/94 .\" $FreeBSD$ .\" -.Dd November 30, 2006 +.Dd October 3, 2016 .Dt MOUNT_UNIONFS 8 .Os .Sh NAME @@ -328,9 +328,13 @@ accessible via .Xr mount_nullfs 8 .Sh HISTORY The -.Nm +.Nm mount_null utility first appeared in .Bx 4.4 . +It was renamed to +.Nm +in +.Fx 5.0 . .Pp The .Fl r From owner-svn-src-stable@freebsd.org Sun Oct 16 22:33:05 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28A33C14D88; Sun, 16 Oct 2016 22:33:05 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CF5361CB6; Sun, 16 Oct 2016 22:33:04 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMX3W6002881; Sun, 16 Oct 2016 22:33:03 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMX3BU002880; Sun, 16 Oct 2016 22:33:03 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162233.u9GMX3BU002880@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:33:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307409 - stable/10/sbin/pfctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:33:05 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:33:03 2016 New Revision: 307409 URL: https://svnweb.freebsd.org/changeset/base/307409 Log: MFC r306614: Note the version PF first appeared in FreeBSD & from which version it was ported from. Address the contractions raised by igor. PR: 212574 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/pfctl/pfctl.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/pfctl/pfctl.8 ============================================================================== --- stable/10/sbin/pfctl/pfctl.8 Sun Oct 16 22:31:51 2016 (r307408) +++ stable/10/sbin/pfctl/pfctl.8 Sun Oct 16 22:33:03 2016 (r307409) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 21, 2011 +.Dd October 3, 2016 .Dt PFCTL 8 .Os .Sh NAME @@ -391,7 +391,7 @@ Note that the optimization done automatically by the kernel will skip evaluation of rules where possible. Packets passed statefully are counted in the rule that created the state -(even though the rule isn't evaluated more than once for the entire +(even though the rule is not evaluated more than once for the entire connection). .It Fl s Cm Anchors Show the currently loaded anchors directly attached to the main ruleset. @@ -594,7 +594,7 @@ counters are incremented instead of the .Dq Pass counters when a .Dq stateful -packet is passed but doesn't match the table anymore. +packet is passed but does not match the table anymore. This will happen in our example if someone flushes the table while the .Xr ping 8 command is running. @@ -610,7 +610,7 @@ The flags are defined as follows: For constant tables, which cannot be altered outside .Xr pf.conf 5 . .It p -For persistent tables, which don't get automatically killed when no rules +For persistent tables, which do not get automatically killed when no rules refer to them. .It a For tables which are part of the @@ -649,7 +649,7 @@ Set the debug .Pp .Bl -tag -width xxxxxxxxxxxx -compact .It Fl x Cm none -Don't generate debug messages. +Do not generate debug messages. .It Fl x Cm urgent Generate debug messages only for serious errors. .It Fl x Cm misc @@ -683,5 +683,9 @@ The .Nm program and the .Xr pf 4 -filter mechanism first appeared in +filter mechanism appeared in .Ox 3.0 . +They first appeared in +.Fx 5.3 +ported from the version in +.Ox 3.5 From owner-svn-src-stable@freebsd.org Sun Oct 16 22:33:53 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5B728C14E2C; Sun, 16 Oct 2016 22:33:53 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0FB311E18; Sun, 16 Oct 2016 22:33:52 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMXq1S002983; Sun, 16 Oct 2016 22:33:52 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMXqN4002982; Sun, 16 Oct 2016 22:33:52 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162233.u9GMXqN4002982@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:33:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307410 - stable/11/sbin/pfctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:33:53 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:33:51 2016 New Revision: 307410 URL: https://svnweb.freebsd.org/changeset/base/307410 Log: MFC r306614: Note the version PF first appeared in FreeBSD & from which version it was ported from. Address the contractions raised by igor. PR: 212574 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/pfctl/pfctl.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/pfctl/pfctl.8 ============================================================================== --- stable/11/sbin/pfctl/pfctl.8 Sun Oct 16 22:33:03 2016 (r307409) +++ stable/11/sbin/pfctl/pfctl.8 Sun Oct 16 22:33:51 2016 (r307410) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 21, 2011 +.Dd October 3, 2016 .Dt PFCTL 8 .Os .Sh NAME @@ -390,7 +390,7 @@ Note that the optimization done automatically by the kernel will skip evaluation of rules where possible. Packets passed statefully are counted in the rule that created the state -(even though the rule isn't evaluated more than once for the entire +(even though the rule is not evaluated more than once for the entire connection). .It Fl s Cm Anchors Show the currently loaded anchors directly attached to the main ruleset. @@ -593,7 +593,7 @@ counters are incremented instead of the .Dq Pass counters when a .Dq stateful -packet is passed but doesn't match the table anymore. +packet is passed but does not match the table anymore. This will happen in our example if someone flushes the table while the .Xr ping 8 command is running. @@ -609,7 +609,7 @@ The flags are defined as follows: For constant tables, which cannot be altered outside .Xr pf.conf 5 . .It p -For persistent tables, which don't get automatically killed when no rules +For persistent tables, which do not get automatically killed when no rules refer to them. .It a For tables which are part of the @@ -648,7 +648,7 @@ Set the debug .Pp .Bl -tag -width xxxxxxxxxxxx -compact .It Fl x Cm none -Don't generate debug messages. +Do not generate debug messages. .It Fl x Cm urgent Generate debug messages only for serious errors. .It Fl x Cm misc @@ -682,5 +682,9 @@ The .Nm program and the .Xr pf 4 -filter mechanism first appeared in +filter mechanism appeared in .Ox 3.0 . +They first appeared in +.Fx 5.3 +ported from the version in +.Ox 3.5 From owner-svn-src-stable@freebsd.org Sun Oct 16 22:51:26 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD0BFC14563; Sun, 16 Oct 2016 22:51:26 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AC3171942; Sun, 16 Oct 2016 22:51:26 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMpPic008450; Sun, 16 Oct 2016 22:51:25 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMpPxb008449; Sun, 16 Oct 2016 22:51:25 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162251.u9GMpPxb008449@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:51:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307411 - stable/11/sbin/sconfig X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:51:27 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:51:25 2016 New Revision: 307411 URL: https://svnweb.freebsd.org/changeset/base/307411 Log: MFC r306615: sconfig appeared in FreeBSD 5.2. PR: 212550 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/sconfig/sconfig.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/sconfig/sconfig.8 ============================================================================== --- stable/11/sbin/sconfig/sconfig.8 Sun Oct 16 22:33:51 2016 (r307410) +++ stable/11/sbin/sconfig/sconfig.8 Sun Oct 16 22:51:25 2016 (r307411) @@ -11,7 +11,7 @@ .\" works or modified versions. .\" .\" $FreeBSD$ -.Dd May 19, 2004 +.Dd October 3, 2016 .Dt SCONFIG 8 i386 .Os .Sh NAME @@ -575,7 +575,13 @@ Test error (G.703 only). .Xr spppcontrol 8 .\"-------------------------------------------------------------- .Sh HISTORY -This utility is a replacement for the +The +.Nm +utility appeared in +.Fx 5.2 . +The +.Nm +utility is a replacement for the .Nm cxconfig and .Nm ctconfig From owner-svn-src-stable@freebsd.org Sun Oct 16 22:52:06 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5583EC145C4; Sun, 16 Oct 2016 22:52:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 26F661BF9; Sun, 16 Oct 2016 22:52:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMq5wE010747; Sun, 16 Oct 2016 22:52:05 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMq50x010746; Sun, 16 Oct 2016 22:52:05 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162252.u9GMq50x010746@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:52:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307412 - stable/10/sbin/sconfig X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:52:06 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:52:05 2016 New Revision: 307412 URL: https://svnweb.freebsd.org/changeset/base/307412 Log: MFC r306615: sconfig appeared in FreeBSD 5.2. PR: 212550 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/sconfig/sconfig.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/sconfig/sconfig.8 ============================================================================== --- stable/10/sbin/sconfig/sconfig.8 Sun Oct 16 22:51:25 2016 (r307411) +++ stable/10/sbin/sconfig/sconfig.8 Sun Oct 16 22:52:05 2016 (r307412) @@ -11,7 +11,7 @@ .\" works or modified versions. .\" .\" $FreeBSD$ -.Dd May 19, 2004 +.Dd October 3, 2016 .Dt SCONFIG 8 i386 .Os .Sh NAME @@ -575,7 +575,13 @@ Test error (G.703 only). .Xr spppcontrol 8 .\"-------------------------------------------------------------- .Sh HISTORY -This utility is a replacement for the +The +.Nm +utility appeared in +.Fx 5.2 . +The +.Nm +utility is a replacement for the .Nm cxconfig and .Nm ctconfig From owner-svn-src-stable@freebsd.org Sun Oct 16 22:54:25 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26DD2C1473C; Sun, 16 Oct 2016 22:54:25 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E78EC1E88; Sun, 16 Oct 2016 22:54:24 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GMsNMo010997; Sun, 16 Oct 2016 22:54:23 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GMsNn4010996; Sun, 16 Oct 2016 22:54:23 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162254.u9GMsNn4010996@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 22:54:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307413 - stable/11/sbin/setkey X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 22:54:25 -0000 Author: sevan (doc committer) Date: Sun Oct 16 22:54:23 2016 New Revision: 307413 URL: https://svnweb.freebsd.org/changeset/base/307413 Log: MFC r306616: setkey appeared in FreeBSD 4.0 PR: 212551 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/setkey/setkey.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/setkey/setkey.8 ============================================================================== --- stable/11/sbin/setkey/setkey.8 Sun Oct 16 22:52:05 2016 (r307412) +++ stable/11/sbin/setkey/setkey.8 Sun Oct 16 22:54:23 2016 (r307413) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 3, 2015 +.Dd October 3, 2016 .Dt SETKEY 8 .Os .\" @@ -713,6 +713,8 @@ The .Nm utility first appeared in WIDE Hydrangea IPv6 protocol stack kit. The utility was completely re-designed in June 1998. +It first appeared in +.Fx 4.0 . .\" .Sh BUGS The From owner-svn-src-stable@freebsd.org Sun Oct 16 23:03:49 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0DB7AC14974; Sun, 16 Oct 2016 23:03:49 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C38DE12F4; Sun, 16 Oct 2016 23:03:48 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GN3l94014714; Sun, 16 Oct 2016 23:03:47 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GN3lsp014713; Sun, 16 Oct 2016 23:03:47 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162303.u9GN3lsp014713@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:03:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307414 - stable/11/sbin/shutdown X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:03:49 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:03:47 2016 New Revision: 307414 URL: https://svnweb.freebsd.org/changeset/base/307414 Log: MFC r306617: shutdown appeared as a standalone utility in 4.1BSD. http://mail-index.netbsd.org/source-changes-d/2016/09/13/msg008686.html http://mail-index.netbsd.org/source-changes-d/2016/09/14/msg008691.html PR: 212552 Approved by: bcr (mentor) Obtained from: NetBSD Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/shutdown/shutdown.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/shutdown/shutdown.8 ============================================================================== --- stable/11/sbin/shutdown/shutdown.8 Sun Oct 16 22:54:23 2016 (r307413) +++ stable/11/sbin/shutdown/shutdown.8 Sun Oct 16 23:03:47 2016 (r307414) @@ -28,7 +28,7 @@ .\" @(#)shutdown.8 8.2 (Berkeley) 4/27/95 .\" $FreeBSD$ .\" -.Dd December 15, 2014 +.Dd September 21, 2016 .Dt SHUTDOWN 8 .Os .Sh NAME @@ -215,7 +215,9 @@ a colon (``:'') for backward compatibili .Xr init 8 , .Xr reboot 8 .Sh HISTORY -The +A .Nm -utility appeared in -.Bx 4.0 . +command was originally written by Ian Johnstone for UNSW's modified +.At "6th Edn" . +It was modified and then incorporated in +.Bx 4.1 . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:09:06 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20C66C149E5; Sun, 16 Oct 2016 23:09:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D32B714AC; Sun, 16 Oct 2016 23:09:05 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GN94Li014987; Sun, 16 Oct 2016 23:09:04 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GN94BF014986; Sun, 16 Oct 2016 23:09:04 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162309.u9GN94BF014986@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:09:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307415 - stable/10/bin/echo X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:09:06 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:09:04 2016 New Revision: 307415 URL: https://svnweb.freebsd.org/changeset/base/307415 Log: MFC r306718: Add history section for echo(1) Sourced using the draft copy of the second edition manual http://www.tuhs.org/Archive/PDP-11/Distributions/research/1972_stuff/unix_2nd_edition_manual.pdf PR: 211785 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/bin/echo/echo.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/echo/echo.1 ============================================================================== --- stable/10/bin/echo/echo.1 Sun Oct 16 23:03:47 2016 (r307414) +++ stable/10/bin/echo/echo.1 Sun Oct 16 23:09:04 2016 (r307415) @@ -32,7 +32,7 @@ .\" @(#)echo.1 8.1 (Berkeley) 7/22/93 .\" $FreeBSD$ .\" -.Dd November 12, 2010 +.Dd October 5, 2016 .Dt ECHO 1 .Os .Sh NAME @@ -103,3 +103,8 @@ The utility conforms to .St -p1003.1-2001 as amended by Cor.\& 1-2002. +.Sh HISTORY +The +.Nm +command appeared in +.At v2 . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:09:56 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C267BC14A45; Sun, 16 Oct 2016 23:09:56 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 93F05163F; Sun, 16 Oct 2016 23:09:56 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GN9tpp015083; Sun, 16 Oct 2016 23:09:55 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GN9tYs015082; Sun, 16 Oct 2016 23:09:55 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162309.u9GN9tYs015082@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:09:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307416 - stable/11/bin/echo X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:09:56 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:09:55 2016 New Revision: 307416 URL: https://svnweb.freebsd.org/changeset/base/307416 Log: MFC r306718: Add history section for echo(1) Sourced using the draft copy of the second edition manual http://www.tuhs.org/Archive/PDP-11/Distributions/research/1972_stuff/unix_2nd_edition_manual.pdf PR: 211785 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/bin/echo/echo.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/echo/echo.1 ============================================================================== --- stable/11/bin/echo/echo.1 Sun Oct 16 23:09:04 2016 (r307415) +++ stable/11/bin/echo/echo.1 Sun Oct 16 23:09:55 2016 (r307416) @@ -32,7 +32,7 @@ .\" @(#)echo.1 8.1 (Berkeley) 7/22/93 .\" $FreeBSD$ .\" -.Dd November 12, 2010 +.Dd October 5, 2016 .Dt ECHO 1 .Os .Sh NAME @@ -103,3 +103,8 @@ The utility conforms to .St -p1003.1-2001 as amended by Cor.\& 1-2002. +.Sh HISTORY +The +.Nm +command appeared in +.At v2 . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:11:35 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03D3AC14AC2; Sun, 16 Oct 2016 23:11:35 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6975186C; Sun, 16 Oct 2016 23:11:34 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNBXUU017257; Sun, 16 Oct 2016 23:11:33 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNBX56017256; Sun, 16 Oct 2016 23:11:33 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162311.u9GNBX56017256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:11:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307417 - stable/11/bin/expr X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:11:35 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:11:33 2016 New Revision: 307417 URL: https://svnweb.freebsd.org/changeset/base/307417 Log: MFC r306719: Document origins of expr & authors http://minnie.tuhs.org/cgi-bin/utree.pl?file=PWB1/usr/man/man1/expr.1 PR: 173979 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/bin/expr/expr.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/expr/expr.1 ============================================================================== --- stable/11/bin/expr/expr.1 Sun Oct 16 23:09:55 2016 (r307416) +++ stable/11/bin/expr/expr.1 Sun Oct 16 23:11:33 2016 (r307417) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2012 +.Dd October 5, 2016 .Dt EXPR 1 .Os .Sh NAME @@ -309,3 +309,19 @@ these arguments are treated just as thei The .Fl e flag is an extension. +.Sh HISTORY +An +.Nm +utility first appeared in the Programmer's Workbench (PWB/UNIX). +A public domain version of +.Nm +written by +.An Pace Willisson Aq Mt pace@blitz.com +appeared in +.Bx 386 0.1 . +.Sh AUTHORS +Initial implementation by +.An Pace Willisson Aq Mt pace@blitz.com +was largely rewritten by +.An -nosplit +.An J.T. Conklin Aq Mt jtc@FreeBSD.org . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:12:08 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6DF8CC14BEF; Sun, 16 Oct 2016 23:12:08 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3CF301A29; Sun, 16 Oct 2016 23:12:08 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNC7kr017341; Sun, 16 Oct 2016 23:12:07 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNC7CG017340; Sun, 16 Oct 2016 23:12:07 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162312.u9GNC7CG017340@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:12:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307418 - stable/10/bin/expr X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:12:08 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:12:07 2016 New Revision: 307418 URL: https://svnweb.freebsd.org/changeset/base/307418 Log: MFC r306719: Document origins of expr & authors http://minnie.tuhs.org/cgi-bin/utree.pl?file=PWB1/usr/man/man1/expr.1 PR: 173979 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/bin/expr/expr.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/expr/expr.1 ============================================================================== --- stable/10/bin/expr/expr.1 Sun Oct 16 23:11:33 2016 (r307417) +++ stable/10/bin/expr/expr.1 Sun Oct 16 23:12:07 2016 (r307418) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2012 +.Dd October 5, 2016 .Dt EXPR 1 .Os .Sh NAME @@ -309,3 +309,19 @@ these arguments are treated just as thei The .Fl e flag is an extension. +.Sh HISTORY +An +.Nm +utility first appeared in the Programmer's Workbench (PWB/UNIX). +A public domain version of +.Nm +written by +.An Pace Willisson Aq Mt pace@blitz.com +appeared in +.Bx 386 0.1 . +.Sh AUTHORS +Initial implementation by +.An Pace Willisson Aq Mt pace@blitz.com +was largely rewritten by +.An -nosplit +.An J.T. Conklin Aq Mt jtc@FreeBSD.org . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:13:29 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C1D9C14C5A; Sun, 16 Oct 2016 23:13:29 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1C4E1CA7; Sun, 16 Oct 2016 23:13:28 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNDSJg018721; Sun, 16 Oct 2016 23:13:28 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNDSTS018720; Sun, 16 Oct 2016 23:13:28 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162313.u9GNDSTS018720@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:13:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307419 - stable/10/bin/pwd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:13:29 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:13:27 2016 New Revision: 307419 URL: https://svnweb.freebsd.org/changeset/base/307419 Log: MFC r306720: Add history section of pwd(1) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V5/usr/source/s2/pwd.c PR: 211787 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/bin/pwd/pwd.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/pwd/pwd.1 ============================================================================== --- stable/10/bin/pwd/pwd.1 Sun Oct 16 23:12:07 2016 (r307418) +++ stable/10/bin/pwd/pwd.1 Sun Oct 16 23:13:27 2016 (r307419) @@ -32,7 +32,7 @@ .\" @(#)pwd.1 8.2 (Berkeley) 4/28/95 .\" $FreeBSD$ .\" -.Dd April 12, 2003 +.Dd October 5, 2016 .Dt PWD 1 .Os .Sh NAME @@ -85,6 +85,11 @@ The .Nm utility conforms to .St -p1003.1-2001 . +.Sh HISTORY +The +.Nm +command appeared in +.At v5 . .Sh BUGS In .Xr csh 1 From owner-svn-src-stable@freebsd.org Sun Oct 16 23:14:28 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3031C14CCC; Sun, 16 Oct 2016 23:14:28 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 910981E06; Sun, 16 Oct 2016 23:14:28 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNERwC018827; Sun, 16 Oct 2016 23:14:27 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNERI5018826; Sun, 16 Oct 2016 23:14:27 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162314.u9GNERI5018826@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:14:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307420 - stable/11/bin/pwd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:14:28 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:14:27 2016 New Revision: 307420 URL: https://svnweb.freebsd.org/changeset/base/307420 Log: MFC r306720: Add history section of pwd(1) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V5/usr/source/s2/pwd.c PR: 211787 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/bin/pwd/pwd.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/pwd/pwd.1 ============================================================================== --- stable/11/bin/pwd/pwd.1 Sun Oct 16 23:13:27 2016 (r307419) +++ stable/11/bin/pwd/pwd.1 Sun Oct 16 23:14:27 2016 (r307420) @@ -32,7 +32,7 @@ .\" @(#)pwd.1 8.2 (Berkeley) 4/28/95 .\" $FreeBSD$ .\" -.Dd April 12, 2003 +.Dd October 5, 2016 .Dt PWD 1 .Os .Sh NAME @@ -85,6 +85,11 @@ The .Nm utility conforms to .St -p1003.1-2001 . +.Sh HISTORY +The +.Nm +command appeared in +.At v5 . .Sh BUGS In .Xr csh 1 From owner-svn-src-stable@freebsd.org Sun Oct 16 23:15:34 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C48CFC14D4A; Sun, 16 Oct 2016 23:15:34 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 938BF1F67; Sun, 16 Oct 2016 23:15:34 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNFX2F018933; Sun, 16 Oct 2016 23:15:33 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNFXXq018932; Sun, 16 Oct 2016 23:15:33 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162315.u9GNFXXq018932@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:15:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307421 - stable/11/bin/stty X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:15:34 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:15:33 2016 New Revision: 307421 URL: https://svnweb.freebsd.org/changeset/base/307421 Log: MFC r306721: Add history section for stty(1) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man1/stty.1 PR: 211788 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/bin/stty/stty.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/stty/stty.1 ============================================================================== --- stable/11/bin/stty/stty.1 Sun Oct 16 23:14:27 2016 (r307420) +++ stable/11/bin/stty/stty.1 Sun Oct 16 23:15:33 2016 (r307421) @@ -32,7 +32,7 @@ .\" @(#)stty.1 8.4 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd August 23, 2008 +.Dd October 5, 2016 .Dt STTY 1 .Os .Sh NAME @@ -601,3 +601,8 @@ and .Fl f are extensions to the standard. +.Sh HISTORY +A +.Nm +command appeared in +.At v2 . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:16:06 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 497F7C14DB8; Sun, 16 Oct 2016 23:16:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1938C10BF; Sun, 16 Oct 2016 23:16:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNG5na019018; Sun, 16 Oct 2016 23:16:05 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNG5fQ019017; Sun, 16 Oct 2016 23:16:05 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162316.u9GNG5fQ019017@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:16:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307422 - stable/10/bin/stty X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:16:06 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:16:05 2016 New Revision: 307422 URL: https://svnweb.freebsd.org/changeset/base/307422 Log: MFC r306721: Add history section for stty(1) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man1/stty.1 PR: 211788 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/bin/stty/stty.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/stty/stty.1 ============================================================================== --- stable/10/bin/stty/stty.1 Sun Oct 16 23:15:33 2016 (r307421) +++ stable/10/bin/stty/stty.1 Sun Oct 16 23:16:05 2016 (r307422) @@ -32,7 +32,7 @@ .\" @(#)stty.1 8.4 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd August 23, 2008 +.Dd October 5, 2016 .Dt STTY 1 .Os .Sh NAME @@ -601,3 +601,8 @@ and .Fl f are extensions to the standard. +.Sh HISTORY +A +.Nm +command appeared in +.At v2 . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:18:37 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 054EEC14E71; Sun, 16 Oct 2016 23:18:37 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2B4F122F; Sun, 16 Oct 2016 23:18:36 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNIZuB019161; Sun, 16 Oct 2016 23:18:35 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNIZ2p019160; Sun, 16 Oct 2016 23:18:35 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162318.u9GNIZ2p019160@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:18:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307423 - stable/10/bin/test X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:18:37 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:18:35 2016 New Revision: 307423 URL: https://svnweb.freebsd.org/changeset/base/307423 Log: MFC r306722: Add history section for test(1) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/test.c PR: 211789 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/bin/test/test.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/test/test.1 ============================================================================== --- stable/10/bin/test/test.1 Sun Oct 16 23:16:05 2016 (r307422) +++ stable/10/bin/test/test.1 Sun Oct 16 23:18:35 2016 (r307423) @@ -32,7 +32,7 @@ .\" @(#)test.1 8.1 (Berkeley) 5/31/93 .\" $FreeBSD$ .\" -.Dd June 1, 2013 +.Dd October 5, 2016 .Dt TEST 1 .Os .Sh NAME @@ -376,6 +376,11 @@ The primaries and .Fl O are extensions. +.Sh HISTORY +A +.Nm +utility appeared in +.At v7 . .Sh BUGS Both sides are always evaluated in .Fl a From owner-svn-src-stable@freebsd.org Sun Oct 16 23:19:16 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B722C14ED6; Sun, 16 Oct 2016 23:19:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC2521393; Sun, 16 Oct 2016 23:19:15 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNJFv8019254; Sun, 16 Oct 2016 23:19:15 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNJFwo019253; Sun, 16 Oct 2016 23:19:15 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162319.u9GNJFwo019253@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:19:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307424 - stable/11/bin/test X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:19:16 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:19:14 2016 New Revision: 307424 URL: https://svnweb.freebsd.org/changeset/base/307424 Log: MFC r306722: Add history section for test(1) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/test.c PR: 211789 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/bin/test/test.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/test/test.1 ============================================================================== --- stable/11/bin/test/test.1 Sun Oct 16 23:18:35 2016 (r307423) +++ stable/11/bin/test/test.1 Sun Oct 16 23:19:14 2016 (r307424) @@ -32,7 +32,7 @@ .\" @(#)test.1 8.1 (Berkeley) 5/31/93 .\" $FreeBSD$ .\" -.Dd June 1, 2013 +.Dd October 5, 2016 .Dt TEST 1 .Os .Sh NAME @@ -376,6 +376,11 @@ The primaries and .Fl O are extensions. +.Sh HISTORY +A +.Nm +utility appeared in +.At v7 . .Sh BUGS Both sides are always evaluated in .Fl a From owner-svn-src-stable@freebsd.org Sun Oct 16 23:26:13 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F4013C1411D; Sun, 16 Oct 2016 23:26:12 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C007F180E; Sun, 16 Oct 2016 23:26:12 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNQBZI022945; Sun, 16 Oct 2016 23:26:11 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNQBOY022944; Sun, 16 Oct 2016 23:26:11 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162326.u9GNQBOY022944@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:26:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307425 - stable/11/sbin/atm/atmconfig X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:26:13 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:26:11 2016 New Revision: 307425 URL: https://svnweb.freebsd.org/changeset/base/307425 Log: MFC r306723: Add history section for atmconfig(8) PR: 212415 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/atm/atmconfig/atmconfig.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/atm/atmconfig/atmconfig.8 ============================================================================== --- stable/11/sbin/atm/atmconfig/atmconfig.8 Sun Oct 16 23:19:14 2016 (r307424) +++ stable/11/sbin/atm/atmconfig/atmconfig.8 Sun Oct 16 23:26:11 2016 (r307425) @@ -1,7 +1,7 @@ .\" .\" Copyright (c) 2001-2003 .\" Fraunhofer Institute for Open Communication Systems (FhG Fokus). -.\" All rights reserved. +.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 11, 2003 +.Dd October 5, 2016 .Dt ATMCONFIG 8 .Os .Sh NAME @@ -314,5 +314,10 @@ List all NATM routes. .Sh SEE ALSO .Xr natm 4 , .Xr natmip 4 +.Sh HISTORY +An +.Nm +command appeared in +.Fx 3.0 . .Sh AUTHORS .An Hartmut Brandt Aq Mt harti@FreeBSD.org From owner-svn-src-stable@freebsd.org Sun Oct 16 23:27:05 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09A30C14190; Sun, 16 Oct 2016 23:27:05 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CC83E1979; Sun, 16 Oct 2016 23:27:04 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNR3SW023046; Sun, 16 Oct 2016 23:27:03 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNR3Cd023045; Sun, 16 Oct 2016 23:27:03 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162327.u9GNR3Cd023045@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:27:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307426 - stable/10/sbin/atm/atmconfig X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:27:05 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:27:03 2016 New Revision: 307426 URL: https://svnweb.freebsd.org/changeset/base/307426 Log: MFC r306723: Add history section for atmconfig(8) PR: 212415 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/atm/atmconfig/atmconfig.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/atm/atmconfig/atmconfig.8 ============================================================================== --- stable/10/sbin/atm/atmconfig/atmconfig.8 Sun Oct 16 23:26:11 2016 (r307425) +++ stable/10/sbin/atm/atmconfig/atmconfig.8 Sun Oct 16 23:27:03 2016 (r307426) @@ -1,7 +1,7 @@ .\" .\" Copyright (c) 2001-2003 .\" Fraunhofer Institute for Open Communication Systems (FhG Fokus). -.\" All rights reserved. +.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 11, 2003 +.Dd October 5, 2016 .Dt ATMCONFIG 8 .Os .Sh NAME @@ -315,5 +315,10 @@ List all NATM routes. .Xr natm 4 , .Xr natmip 4 , .Xr atm 8 +.Sh HISTORY +An +.Nm +command appeared in +.Fx 3.0 . .Sh AUTHORS .An Hartmut Brandt Aq Mt harti@FreeBSD.org From owner-svn-src-stable@freebsd.org Sun Oct 16 23:29:00 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 108A6C14214; Sun, 16 Oct 2016 23:29:00 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D61E01ADF; Sun, 16 Oct 2016 23:28:59 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNSxlk023171; Sun, 16 Oct 2016 23:28:59 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNSxsl023170; Sun, 16 Oct 2016 23:28:59 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162328.u9GNSxsl023170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:28:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307427 - stable/10/sbin/bsdlabel X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:29:00 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:28:58 2016 New Revision: 307427 URL: https://svnweb.freebsd.org/changeset/base/307427 Log: MFC r306724: Add history section for bsdlabel(8) http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Tahoe/usr/man/cat8/disklabel.0 Remove tab after space, highlighted by igor PR: 212436 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/bsdlabel/bsdlabel.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/bsdlabel/bsdlabel.8 ============================================================================== --- stable/10/sbin/bsdlabel/bsdlabel.8 Sun Oct 16 23:27:03 2016 (r307426) +++ stable/10/sbin/bsdlabel/bsdlabel.8 Sun Oct 16 23:28:58 2016 (r307427) @@ -31,7 +31,7 @@ .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 5, 2016 .Dt BSDLABEL 8 .Os .Sh NAME @@ -466,7 +466,7 @@ which could be used as a source file for 8 partitions: # size offset fstype [fsize bsize bps/cpg] - a: 400M 16 4.2BSD 4096 16384 75 # (Cyl. 0 - 812*) + a: 400M 16 4.2BSD 4096 16384 75 # (Cyl. 0 - 812*) b: 1G * swap c: * * unused e: 204800 * 4.2BSD @@ -500,3 +500,8 @@ are not generally compatible. .Xr boot0cfg 8 , .Xr gpart 8 , .Xr newfs 8 +.Sh HISTORY +The +.Nm disklabel +utility appeared in +.Bx 4.3 Tahoe . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:29:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D53EEC14275; Sun, 16 Oct 2016 23:29:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A66401C56; Sun, 16 Oct 2016 23:29:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNTe5s023262; Sun, 16 Oct 2016 23:29:40 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNTeHq023261; Sun, 16 Oct 2016 23:29:40 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162329.u9GNTeHq023261@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:29:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307428 - stable/11/sbin/bsdlabel X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:29:41 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:29:40 2016 New Revision: 307428 URL: https://svnweb.freebsd.org/changeset/base/307428 Log: MFC r306724: Add history section for bsdlabel(8) http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Tahoe/usr/man/cat8/disklabel.0 Remove tab after space, highlighted by igor PR: 212436 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/bsdlabel/bsdlabel.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/bsdlabel/bsdlabel.8 ============================================================================== --- stable/11/sbin/bsdlabel/bsdlabel.8 Sun Oct 16 23:28:58 2016 (r307427) +++ stable/11/sbin/bsdlabel/bsdlabel.8 Sun Oct 16 23:29:40 2016 (r307428) @@ -31,7 +31,7 @@ .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 5, 2016 .Dt BSDLABEL 8 .Os .Sh NAME @@ -466,7 +466,7 @@ which could be used as a source file for 8 partitions: # size offset fstype [fsize bsize bps/cpg] - a: 400M 16 4.2BSD 4096 16384 75 # (Cyl. 0 - 812*) + a: 400M 16 4.2BSD 4096 16384 75 # (Cyl. 0 - 812*) b: 1G * swap c: * * unused e: 204800 * 4.2BSD @@ -500,3 +500,8 @@ are not generally compatible. .Xr boot0cfg 8 , .Xr gpart 8 , .Xr newfs 8 +.Sh HISTORY +The +.Nm disklabel +utility appeared in +.Bx 4.3 Tahoe . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:31:17 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 590B2C142F5; Sun, 16 Oct 2016 23:31:17 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 24F881E30; Sun, 16 Oct 2016 23:31:17 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNVGlo024781; Sun, 16 Oct 2016 23:31:16 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNVGSp024780; Sun, 16 Oct 2016 23:31:16 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162331.u9GNVGSp024780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:31:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307429 - stable/11/sbin/clri X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:31:17 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:31:15 2016 New Revision: 307429 URL: https://svnweb.freebsd.org/changeset/base/307429 Log: MFC r306725: Add history section for clri(8) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/man/man8/clri.8 PR: 212438 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/clri/clri.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/clri/clri.8 ============================================================================== --- stable/11/sbin/clri/clri.8 Sun Oct 16 23:29:40 2016 (r307428) +++ stable/11/sbin/clri/clri.8 Sun Oct 16 23:31:15 2016 (r307429) @@ -28,7 +28,7 @@ .\" @(#)clri.8 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd April 19, 1994 +.Dd October 5, 2016 .Dt CLRI 8 .Os .Sh NAME @@ -70,6 +70,11 @@ will be able to clean up the resulting m .Sh SEE ALSO .Xr fsck 8 , .Xr fsdb 8 +.Sh HISTORY +The +.Nm +utility first appeared in +.At v6 . .Sh BUGS If the file is open, the work of .Nm From owner-svn-src-stable@freebsd.org Sun Oct 16 23:32:36 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63818C1442F; Sun, 16 Oct 2016 23:32:36 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 327CD1121; Sun, 16 Oct 2016 23:32:36 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNWZdf027094; Sun, 16 Oct 2016 23:32:35 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNWZ7U027093; Sun, 16 Oct 2016 23:32:35 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162332.u9GNWZ7U027093@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:32:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307430 - stable/10/sbin/clri X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:32:36 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:32:35 2016 New Revision: 307430 URL: https://svnweb.freebsd.org/changeset/base/307430 Log: MFC r306725: Add history section for clri(8) http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/man/man8/clri.8 PR: 212438 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/clri/clri.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/clri/clri.8 ============================================================================== --- stable/10/sbin/clri/clri.8 Sun Oct 16 23:31:15 2016 (r307429) +++ stable/10/sbin/clri/clri.8 Sun Oct 16 23:32:35 2016 (r307430) @@ -28,7 +28,7 @@ .\" @(#)clri.8 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd April 19, 1994 +.Dd October 5, 2016 .Dt CLRI 8 .Os .Sh NAME @@ -70,6 +70,11 @@ will be able to clean up the resulting m .Sh SEE ALSO .Xr fsck 8 , .Xr fsdb 8 +.Sh HISTORY +The +.Nm +utility first appeared in +.At v6 . .Sh BUGS If the file is open, the work of .Nm From owner-svn-src-stable@freebsd.org Sun Oct 16 23:34:22 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C929C144D2; Sun, 16 Oct 2016 23:34:22 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A97612E9; Sun, 16 Oct 2016 23:34:22 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNYLJU027239; Sun, 16 Oct 2016 23:34:21 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNYLiP027238; Sun, 16 Oct 2016 23:34:21 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162334.u9GNYLiP027238@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:34:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307431 - stable/10/sbin/devd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:34:22 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:34:21 2016 New Revision: 307431 URL: https://svnweb.freebsd.org/changeset/base/307431 Log: MFC r306727: Add history section for devd(8) Move sentence to a new line as advised by igor PR: 212439 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/devd/devd.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/devd/devd.8 ============================================================================== --- stable/10/sbin/devd/devd.8 Sun Oct 16 23:32:35 2016 (r307430) +++ stable/10/sbin/devd/devd.8 Sun Oct 16 23:34:21 2016 (r307431) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 14, 2014 +.Dd October 5, 2016 .Dt DEVD 8 .Os .Sh NAME @@ -62,7 +62,8 @@ The default connection limit is 10. Do not process all pending events before becoming a daemon. Instead, call daemon right away. .It Fl q -Quiet mode. Only log messages at priority LOG_WARNING or above. +Quiet mode. +Only log messages at priority LOG_WARNING or above. .El .Sh IMPLEMENTATION NOTES The @@ -153,5 +154,10 @@ A deprecated socket retained for use wit .Sh SEE ALSO .Xr devctl 4 , .Xr devd.conf 5 +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 5.0 . .Sh AUTHORS .An M. Warner Losh From owner-svn-src-stable@freebsd.org Sun Oct 16 23:35:05 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EB74DC1453D; Sun, 16 Oct 2016 23:35:05 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD2281488; Sun, 16 Oct 2016 23:35:05 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNZ4r1027344; Sun, 16 Oct 2016 23:35:04 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNZ4VY027343; Sun, 16 Oct 2016 23:35:04 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162335.u9GNZ4VY027343@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:35:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307432 - stable/11/sbin/devd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:35:06 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:35:04 2016 New Revision: 307432 URL: https://svnweb.freebsd.org/changeset/base/307432 Log: MFC r306727: Add history section for devd(8) Move sentence to a new line as advised by igor PR: 212439 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/devd/devd.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/devd/devd.8 ============================================================================== --- stable/11/sbin/devd/devd.8 Sun Oct 16 23:34:21 2016 (r307431) +++ stable/11/sbin/devd/devd.8 Sun Oct 16 23:35:04 2016 (r307432) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 14, 2014 +.Dd October 5, 2016 .Dt DEVD 8 .Os .Sh NAME @@ -62,7 +62,8 @@ The default connection limit is 10. Do not process all pending events before becoming a daemon. Instead, call daemon right away. .It Fl q -Quiet mode. Only log messages at priority LOG_WARNING or above. +Quiet mode. +Only log messages at priority LOG_WARNING or above. .El .Sh IMPLEMENTATION NOTES The @@ -153,5 +154,10 @@ A deprecated socket retained for use wit .Sh SEE ALSO .Xr devctl 4 , .Xr devd.conf 5 +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 5.0 . .Sh AUTHORS .An M. Warner Losh From owner-svn-src-stable@freebsd.org Sun Oct 16 23:36:53 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 783BEC145BC; Sun, 16 Oct 2016 23:36:53 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4728C1652; Sun, 16 Oct 2016 23:36:53 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNaqda027472; Sun, 16 Oct 2016 23:36:52 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNaqK9027471; Sun, 16 Oct 2016 23:36:52 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162336.u9GNaqK9027471@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:36:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307433 - stable/11/sbin/devfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:36:53 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:36:52 2016 New Revision: 307433 URL: https://svnweb.freebsd.org/changeset/base/307433 Log: MFC r306728: Add history section for devfs(8) Move sentence to a new line as advised by igor. PR: 212441 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/devfs/devfs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/devfs/devfs.8 ============================================================================== --- stable/11/sbin/devfs/devfs.8 Sun Oct 16 23:35:04 2016 (r307432) +++ stable/11/sbin/devfs/devfs.8 Sun Oct 16 23:36:52 2016 (r307433) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 12, 2013 +.Dd October 5, 2016 .Dt DEVFS 8 .Os .Sh NAME @@ -249,7 +249,8 @@ configuration file. .It Pa /etc/devfs.rules Local .Nm -configuration file. Rulesets in here override those in +configuration file. +Rulesets in here override those in .Pa /etc/defaults/devfs.rules with the same ruleset number, otherwise the two files are effectively merged. .It Pa /etc/devfs.conf @@ -374,5 +375,10 @@ this feature can be used to copy ruleset .Xr chown 8 , .Xr jail 8 , .Xr mknod 8 +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 5.0 . .Sh AUTHORS .An Dima Dorfman From owner-svn-src-stable@freebsd.org Sun Oct 16 23:37:16 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0D0FC14626; Sun, 16 Oct 2016 23:37:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BFDAB17B5; Sun, 16 Oct 2016 23:37:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNbFMP027553; Sun, 16 Oct 2016 23:37:15 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNbFvM027552; Sun, 16 Oct 2016 23:37:15 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162337.u9GNbFvM027552@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:37:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307434 - stable/10/sbin/devfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:37:17 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:37:15 2016 New Revision: 307434 URL: https://svnweb.freebsd.org/changeset/base/307434 Log: MFC r306728: Add history section for devfs(8) Move sentence to a new line as advised by igor. PR: 212441 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/devfs/devfs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/devfs/devfs.8 ============================================================================== --- stable/10/sbin/devfs/devfs.8 Sun Oct 16 23:36:52 2016 (r307433) +++ stable/10/sbin/devfs/devfs.8 Sun Oct 16 23:37:15 2016 (r307434) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 12, 2013 +.Dd October 5, 2016 .Dt DEVFS 8 .Os .Sh NAME @@ -249,7 +249,8 @@ configuration file. .It Pa /etc/devfs.rules Local .Nm -configuration file. Rulesets in here override those in +configuration file. +Rulesets in here override those in .Pa /etc/defaults/devfs.rules with the same ruleset number, otherwise the two files are effectively merged. .It Pa /etc/devfs.conf @@ -374,5 +375,10 @@ this feature can be used to copy ruleset .Xr chown 8 , .Xr jail 8 , .Xr mknod 8 +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 5.0 . .Sh AUTHORS .An Dima Dorfman From owner-svn-src-stable@freebsd.org Sun Oct 16 23:39:16 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98C1FC146D4; Sun, 16 Oct 2016 23:39:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5BA431967; Sun, 16 Oct 2016 23:39:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNdFki027680; Sun, 16 Oct 2016 23:39:15 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNdFOl027679; Sun, 16 Oct 2016 23:39:15 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162339.u9GNdFOl027679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:39:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307435 - stable/10/sbin/fdisk X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:39:16 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:39:15 2016 New Revision: 307435 URL: https://svnweb.freebsd.org/changeset/base/307435 Log: MFC r306731: Document the history of fdisk based on the original post to comp.unix.bsd by Julian Elischer [1] and the Mach 2.5 Installation notes [2]. I was unable to pin point the exact version of Mach the fdisk utility appeared as I could not find documentation older than version 2.5 & no source code or repo history. fdisk utility appears as a separate utility[3] in v2.5. Due to this, I have avoided stating the exact version fdisk first appeared in Mach. Add authors section. Make correction pointed by igor [1] https://groups.google.com/d/topic/comp.unix.bsd/Hhi45vAHxDg/discussion [2] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_install.ps [3] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_manpages.ps PR: 212469 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/fdisk/fdisk.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fdisk/fdisk.8 ============================================================================== --- stable/10/sbin/fdisk/fdisk.8 Sun Oct 16 23:37:15 2016 (r307434) +++ stable/10/sbin/fdisk/fdisk.8 Sun Oct 16 23:39:15 2016 (r307435) @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 5, 2016 .Dt FDISK 8 .Os .Sh NAME @@ -177,19 +177,19 @@ An example follows: Information from DOS bootblock is: The data for partition 1 is: sysid 165,(FreeBSD/NetBSD/386BSD) - start 495, size 380160 (185 Meg), flag 0 + start 495, size 380160 (185 Meg), flag 0 beg: cyl 1/ sector 1/ head 0; end: cyl 768/ sector 33/ head 14 The data for partition 2 is: sysid 164,(unknown) - start 378180, size 2475 (1 Meg), flag 0 + start 378180, size 2475 (1 Meg), flag 0 beg: cyl 764/ sector 1/ head 0; end: cyl 768/ sector 33/ head 14 The data for partition 3 is: The data for partition 4 is: sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach) - start 380656, size 224234 (109 Meg), flag 80 + start 380656, size 224234 (109 Meg), flag 80 beg: cyl 769/ sector 2/ head 0; end: cyl 197/ sector 33/ head 14 .Ed @@ -485,6 +485,21 @@ The default boot code. .Xr bsdlabel 8 , .Xr gpart 8 , .Xr newfs 8 +.Sh HISTORY +A version of +.Nm +first appeared in the Mach Operating System. +It was subsequently ported to +.Bx 386 . +.Sh AUTHORS +.An -nosplit +.Nm +for Mach Operating System was written by +.An Robert Baron Aq Mt rvb@cs.cmu.edu . +It was ported to +.Bx 386 +by +.An Julian Elischer Aq Mt julian@tfs.com . .Sh BUGS The default boot code will not necessarily handle all slice types correctly, in particular those introduced since From owner-svn-src-stable@freebsd.org Sun Oct 16 23:40:18 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79D9FC1475B; Sun, 16 Oct 2016 23:40:18 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A58C1ACB; Sun, 16 Oct 2016 23:40:18 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNeHrB027803; Sun, 16 Oct 2016 23:40:17 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNeHrR027802; Sun, 16 Oct 2016 23:40:17 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162340.u9GNeHrR027802@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:40:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307436 - stable/11/sbin/fdisk X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:40:18 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:40:17 2016 New Revision: 307436 URL: https://svnweb.freebsd.org/changeset/base/307436 Log: MFC r306731: Document the history of fdisk based on the original post to comp.unix.bsd by Julian Elischer [1] and the Mach 2. 5 Installation notes [2]. I was unable to pin point the exact version of Mach the fdisk utility appeared as I could not find documentation older than version 2.5 & no source code or repo history. fdisk utility appears as a separate utility[3] in v2.5. Due to this, I have avoided stating the exact version fd isk first appeared in Mach. Add authors section. Make correction pointed by igor [1] https://groups.google.com/d/topic/comp.unix.bsd/Hhi45vAHxDg/discussion [2] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_install.ps [3] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_manpages.ps PR: 212469 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/fdisk/fdisk.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fdisk/fdisk.8 ============================================================================== --- stable/11/sbin/fdisk/fdisk.8 Sun Oct 16 23:39:15 2016 (r307435) +++ stable/11/sbin/fdisk/fdisk.8 Sun Oct 16 23:40:17 2016 (r307436) @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 5, 2016 .Dt FDISK 8 .Os .Sh NAME @@ -177,19 +177,19 @@ An example follows: Information from DOS bootblock is: The data for partition 1 is: sysid 165,(FreeBSD/NetBSD/386BSD) - start 495, size 380160 (185 Meg), flag 0 + start 495, size 380160 (185 Meg), flag 0 beg: cyl 1/ sector 1/ head 0; end: cyl 768/ sector 33/ head 14 The data for partition 2 is: sysid 164,(unknown) - start 378180, size 2475 (1 Meg), flag 0 + start 378180, size 2475 (1 Meg), flag 0 beg: cyl 764/ sector 1/ head 0; end: cyl 768/ sector 33/ head 14 The data for partition 3 is: The data for partition 4 is: sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach) - start 380656, size 224234 (109 Meg), flag 80 + start 380656, size 224234 (109 Meg), flag 80 beg: cyl 769/ sector 2/ head 0; end: cyl 197/ sector 33/ head 14 .Ed @@ -485,6 +485,21 @@ The default boot code. .Xr bsdlabel 8 , .Xr gpart 8 , .Xr newfs 8 +.Sh HISTORY +A version of +.Nm +first appeared in the Mach Operating System. +It was subsequently ported to +.Bx 386 . +.Sh AUTHORS +.An -nosplit +.Nm +for Mach Operating System was written by +.An Robert Baron Aq Mt rvb@cs.cmu.edu . +It was ported to +.Bx 386 +by +.An Julian Elischer Aq Mt julian@tfs.com . .Sh BUGS The default boot code will not necessarily handle all slice types correctly, in particular those introduced since From owner-svn-src-stable@freebsd.org Sun Oct 16 23:42:20 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B6EEC14950; Sun, 16 Oct 2016 23:42:20 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1F3681E9B; Sun, 16 Oct 2016 23:42:20 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNgJZE030543; Sun, 16 Oct 2016 23:42:19 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNgJpN030542; Sun, 16 Oct 2016 23:42:19 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162342.u9GNgJpN030542@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:42:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307437 - stable/11/sbin/fdisk_pc98 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:42:20 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:42:19 2016 New Revision: 307437 URL: https://svnweb.freebsd.org/changeset/base/307437 Log: MFC r306732: Document the history of fdisk based on the original post to comp.unix.bsd by Julian Elischer [1] and the Mach 2.5 Installation notes [2]. I was unable to pin point the exact version of Mach the fdisk utility appeared as I could not find documentation older than version 2.5 & no source code or repo history. fdisk utility appears as a separate utility[3] in v2.5. Due to this, I have avoided stating the exact version fdisk first appeared in Mach. Add authors section. [1] https://groups.google.com/d/topic/comp.unix.bsd/Hhi45vAHxDg/discussion [2] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_install.ps [3] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_manpages.ps PR: 212470 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/fdisk_pc98/fdisk.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fdisk_pc98/fdisk.8 ============================================================================== --- stable/11/sbin/fdisk_pc98/fdisk.8 Sun Oct 16 23:40:17 2016 (r307436) +++ stable/11/sbin/fdisk_pc98/fdisk.8 Sun Oct 16 23:42:19 2016 (r307437) @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd April 30, 2007 +.Dd October 5, 2016 .Dt FDISK 8 .Os .Sh NAME @@ -448,6 +448,21 @@ Example: to make slice 1 the active slic .Xr bsdlabel 8 , .Xr gpart 8 , .Xr newfs 8 +.Sh HISTORY +A version of +.Nm +first appeared in the Mach Operating System. +It was subsequently ported to +.Bx 386 . +.Sh AUTHORS +.An -nosplit +.Nm +for Mach Operating System was written by +.An Robert Baron Aq Mt rvb@cs.cmu.edu . +It was ported to +.Bx 386 +by +.An Julian Elischer Aq Mt julian@tfs.com . .Sh BUGS The default boot code will not necessarily handle all slice types correctly, in particular those introduced since From owner-svn-src-stable@freebsd.org Sun Oct 16 23:44:03 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 856C7C149F3; Sun, 16 Oct 2016 23:44:03 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E0981030; Sun, 16 Oct 2016 23:44:03 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNi2MP031359; Sun, 16 Oct 2016 23:44:02 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNi2iY031358; Sun, 16 Oct 2016 23:44:02 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162344.u9GNi2iY031358@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:44:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307438 - stable/10/sbin/fdisk_pc98 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:44:03 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:44:02 2016 New Revision: 307438 URL: https://svnweb.freebsd.org/changeset/base/307438 Log: MFC r306732: Document the history of fdisk based on the original post to comp.unix.bsd by Julian Elischer [1] and the Mach 2. 5 Installation notes [2]. I was unable to pin point the exact version of Mach the fdisk utility appeared as I could not find documentation older than version 2.5 & no source code or repo history. fdisk utility appears as a separate utility[3] in v2.5. Due to this, I have avoided stating the exact version fd isk first appeared in Mach. Add authors section. [1] https://groups.google.com/d/topic/comp.unix.bsd/Hhi45vAHxDg/discussion [2] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_install.ps [3] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_manpages.ps PR: 212470 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/fdisk_pc98/fdisk.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fdisk_pc98/fdisk.8 ============================================================================== --- stable/10/sbin/fdisk_pc98/fdisk.8 Sun Oct 16 23:42:19 2016 (r307437) +++ stable/10/sbin/fdisk_pc98/fdisk.8 Sun Oct 16 23:44:02 2016 (r307438) @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd April 30, 2007 +.Dd October 5, 2016 .Dt FDISK 8 .Os .Sh NAME @@ -448,6 +448,21 @@ Example: to make slice 1 the active slic .Xr bsdlabel 8 , .Xr gpart 8 , .Xr newfs 8 +.Sh HISTORY +A version of +.Nm +first appeared in the Mach Operating System. +It was subsequently ported to +.Bx 386 . +.Sh AUTHORS +.An -nosplit +.Nm +for Mach Operating System was written by +.An Robert Baron Aq Mt rvb@cs.cmu.edu . +It was ported to +.Bx 386 +by +.An Julian Elischer Aq Mt julian@tfs.com . .Sh BUGS The default boot code will not necessarily handle all slice types correctly, in particular those introduced since From owner-svn-src-stable@freebsd.org Sun Oct 16 23:47:01 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B17B6C14A96; Sun, 16 Oct 2016 23:47:01 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 82FEE11B1; Sun, 16 Oct 2016 23:47:01 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNl0UT031540; Sun, 16 Oct 2016 23:47:00 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNl0JD031539; Sun, 16 Oct 2016 23:47:00 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162347.u9GNl0JD031539@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:47:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307439 - stable/11/sbin/fsck X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:47:01 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:47:00 2016 New Revision: 307439 URL: https://svnweb.freebsd.org/changeset/base/307439 Log: MFC r306733: Add history section to fsck(8) PR: 212472 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/fsck/fsck.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck/fsck.8 ============================================================================== --- stable/11/sbin/fsck/fsck.8 Sun Oct 16 23:44:02 2016 (r307438) +++ stable/11/sbin/fsck/fsck.8 Sun Oct 16 23:47:00 2016 (r307439) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 23, 2014 +.Dd October 5, 2016 .Dt FSCK 8 .Os .Sh NAME @@ -229,3 +229,15 @@ file system table .Xr fsck_ffs 8 , .Xr fsck_msdosfs 8 , .Xr mount 8 +.Sh HISTORY +A +.Nm +utility appeared in +.Bx 4.0 . +It was reimplemented as a filesystem independent wrapper in +.Nx 1.3 +and first appeared in +.Fx 5.0 . +The original filesystem specific utility became +.Xr fsck_ffs 8 +at this point. From owner-svn-src-stable@freebsd.org Sun Oct 16 23:48:25 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1EBD3C14B1D; Sun, 16 Oct 2016 23:48:25 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF0021321; Sun, 16 Oct 2016 23:48:24 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNmNQr031651; Sun, 16 Oct 2016 23:48:23 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNmNhZ031650; Sun, 16 Oct 2016 23:48:23 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162348.u9GNmNhZ031650@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:48:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307440 - stable/11/sbin/fsck_ffs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:48:25 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:48:23 2016 New Revision: 307440 URL: https://svnweb.freebsd.org/changeset/base/307440 Log: MFC r306734: Add history section to fsck_ffs(8) Move sentence to a new line as advised by igor. PR: 212474 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/fsck_ffs/fsck_ffs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/fsck_ffs.8 ============================================================================== --- stable/11/sbin/fsck_ffs/fsck_ffs.8 Sun Oct 16 23:47:00 2016 (r307439) +++ stable/11/sbin/fsck_ffs/fsck_ffs.8 Sun Oct 16 23:48:23 2016 (r307440) @@ -29,7 +29,7 @@ .\" @(#)fsck.8 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd July 30, 2013 +.Dd October 5, 2016 .Dt FSCK_FFS 8 .Os .Sh NAME @@ -268,9 +268,9 @@ do not open the file system for writing. Preen file systems (see above). .It Fl R Instruct fsck_ffs to restart itself if it encounters certain errors that -warrant another run. It will limit itself to a maximum of 10 restarts -in a given run in order to avoid an endless loop with extremely corrupted -filesystems. +warrant another run. +It will limit itself to a maximum of 10 restarts in a given run in order +to avoid an endless loop with extremely corrupted filesystems. .It Fl r Free up excess unused inodes. Decreasing the number of preallocated inodes reduces the @@ -393,3 +393,14 @@ are fully enumerated and explained in Ap .Xr fsdb 8 , .Xr newfs 8 , .Xr reboot 8 +.Sh HISTORY +A +.Nm fsck +utility appeared in +.Bx 4.0 . +It became +.Nm +in +.Fx 5.0 +with the introduction of the filesystem independent wrapper as +.Nm fsck . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:49:10 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55FD2C14B7A; Sun, 16 Oct 2016 23:49:10 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 230FF14CD; Sun, 16 Oct 2016 23:49:10 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNn9Qj031745; Sun, 16 Oct 2016 23:49:09 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNn96d031744; Sun, 16 Oct 2016 23:49:09 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162349.u9GNn96d031744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:49:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307441 - stable/10/sbin/fsck_ffs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:49:10 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:49:09 2016 New Revision: 307441 URL: https://svnweb.freebsd.org/changeset/base/307441 Log: MFC r306734: Add history section to fsck_ffs(8) Move sentence to a new line as advised by igor. PR: 212474 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/fsck_ffs/fsck_ffs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fsck_ffs/fsck_ffs.8 ============================================================================== --- stable/10/sbin/fsck_ffs/fsck_ffs.8 Sun Oct 16 23:48:23 2016 (r307440) +++ stable/10/sbin/fsck_ffs/fsck_ffs.8 Sun Oct 16 23:49:09 2016 (r307441) @@ -29,7 +29,7 @@ .\" @(#)fsck.8 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd July 30, 2013 +.Dd October 5, 2016 .Dt FSCK_FFS 8 .Os .Sh NAME @@ -268,9 +268,9 @@ do not open the file system for writing. Preen file systems (see above). .It Fl R Instruct fsck_ffs to restart itself if it encounters certain errors that -warrant another run. It will limit itself to a maximum of 10 restarts -in a given run in order to avoid an endless loop with extremely corrupted -filesystems. +warrant another run. +It will limit itself to a maximum of 10 restarts in a given run in order +to avoid an endless loop with extremely corrupted filesystems. .It Fl r Free up excess unused inodes. Decreasing the number of preallocated inodes reduces the @@ -393,3 +393,14 @@ are fully enumerated and explained in Ap .Xr fsdb 8 , .Xr newfs 8 , .Xr reboot 8 +.Sh HISTORY +A +.Nm fsck +utility appeared in +.Bx 4.0 . +It became +.Nm +in +.Fx 5.0 +with the introduction of the filesystem independent wrapper as +.Nm fsck . From owner-svn-src-stable@freebsd.org Sun Oct 16 23:50:11 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06B0FC14C86; Sun, 16 Oct 2016 23:50:11 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6EDA177E; Sun, 16 Oct 2016 23:50:10 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNo9tY031868; Sun, 16 Oct 2016 23:50:09 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNo92I031867; Sun, 16 Oct 2016 23:50:09 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162350.u9GNo92I031867@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:50:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307442 - stable/10/sbin/natd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:50:11 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:50:09 2016 New Revision: 307442 URL: https://svnweb.freebsd.org/changeset/base/307442 Log: MFC r306735: Add history section to natd(8) Fix back sentence raised by igor. PR: 212544 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/natd/natd.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/natd/natd.8 ============================================================================== --- stable/10/sbin/natd/natd.8 Sun Oct 16 23:49:09 2016 (r307441) +++ stable/10/sbin/natd/natd.8 Sun Oct 16 23:50:09 2016 (r307442) @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd June 23, 2008 +.Dd October 5, 2016 .Dt NATD 8 .Os .Sh NAME @@ -426,7 +426,7 @@ Options can be divided to several sectio Each section applies to own .Nm instance. -This ability allows to configure one +This ability allows the configuration of one .Nm process for several NAT instances. The first instance that always exists is a "default" instance. @@ -809,6 +809,11 @@ are forwarded to the appropriate router .Xr init 8 , .Xr ipfw 8 , .Xr ppp 8 +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 3.0 . .Sh AUTHORS This program is the result of the efforts of many people at different times: From owner-svn-src-stable@freebsd.org Sun Oct 16 23:51:16 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD0F6C14E65; Sun, 16 Oct 2016 23:51:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 898FA1A5B; Sun, 16 Oct 2016 23:51:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNpFvM031968; Sun, 16 Oct 2016 23:51:15 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNpFLl031967; Sun, 16 Oct 2016 23:51:15 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162351.u9GNpFLl031967@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:51:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307443 - stable/11/sbin/natd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:51:16 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:51:15 2016 New Revision: 307443 URL: https://svnweb.freebsd.org/changeset/base/307443 Log: MFC r306735: Add history section to natd(8) Fix back sentence raised by igor. PR: 212544 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/natd/natd.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/natd/natd.8 ============================================================================== --- stable/11/sbin/natd/natd.8 Sun Oct 16 23:50:09 2016 (r307442) +++ stable/11/sbin/natd/natd.8 Sun Oct 16 23:51:15 2016 (r307443) @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd June 23, 2008 +.Dd October 5, 2016 .Dt NATD 8 .Os .Sh NAME @@ -426,7 +426,7 @@ Options can be divided to several sectio Each section applies to own .Nm instance. -This ability allows to configure one +This ability allows the configuration of one .Nm process for several NAT instances. The first instance that always exists is a "default" instance. @@ -808,6 +808,11 @@ are forwarded to the appropriate router .Xr init 8 , .Xr ipfw 8 , .Xr ppp 8 +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 3.0 . .Sh AUTHORS This program is the result of the efforts of many people at different times: From owner-svn-src-stable@freebsd.org Sun Oct 16 23:52:28 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7E970C14EE1; Sun, 16 Oct 2016 23:52:28 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4AD721CAD; Sun, 16 Oct 2016 23:52:28 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNqRtw035565; Sun, 16 Oct 2016 23:52:27 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNqRF3035564; Sun, 16 Oct 2016 23:52:27 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162352.u9GNqRF3035564@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:52:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307444 - stable/11/sbin/nos-tun X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:52:28 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:52:27 2016 New Revision: 307444 URL: https://svnweb.freebsd.org/changeset/base/307444 Log: MFC r306736: Add history section to nos-tun(8) PR: 212545 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/sbin/nos-tun/nos-tun.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/nos-tun/nos-tun.8 ============================================================================== --- stable/11/sbin/nos-tun/nos-tun.8 Sun Oct 16 23:51:15 2016 (r307443) +++ stable/11/sbin/nos-tun/nos-tun.8 Sun Oct 16 23:52:27 2016 (r307444) @@ -8,7 +8,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 11, 1998 +.Dd October 5, 2016 .Dt NOS-TUN 8 .Os .Sh NAME @@ -80,6 +80,11 @@ tunnel mode nos tunnel destination 192.168.59.34 tunnel source 192.168.56.45 .Ed +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 3.0 . .Sh AUTHORS .An -nosplit .An Nickolay N. Dudorov Aq Mt nnd@itfs.nsk.su From owner-svn-src-stable@freebsd.org Sun Oct 16 23:53:11 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E362FC14F79; Sun, 16 Oct 2016 23:53:11 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B4F771E11; Sun, 16 Oct 2016 23:53:11 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNrAqR035660; Sun, 16 Oct 2016 23:53:10 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNrADS035659; Sun, 16 Oct 2016 23:53:10 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162353.u9GNrADS035659@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:53:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307445 - stable/10/sbin/nos-tun X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:53:12 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:53:10 2016 New Revision: 307445 URL: https://svnweb.freebsd.org/changeset/base/307445 Log: MFC r306736: Add history section to nos-tun(8) PR: 212545 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/sbin/nos-tun/nos-tun.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/nos-tun/nos-tun.8 ============================================================================== --- stable/10/sbin/nos-tun/nos-tun.8 Sun Oct 16 23:52:27 2016 (r307444) +++ stable/10/sbin/nos-tun/nos-tun.8 Sun Oct 16 23:53:10 2016 (r307445) @@ -8,7 +8,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 11, 1998 +.Dd October 5, 2016 .Dt NOS-TUN 8 .Os .Sh NAME @@ -80,6 +80,11 @@ tunnel mode nos tunnel destination 192.168.59.34 tunnel source 192.168.56.45 .Ed +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 3.0 . .Sh AUTHORS .An -nosplit .An Nickolay N. Dudorov Aq Mt nnd@itfs.nsk.su From owner-svn-src-stable@freebsd.org Sun Oct 16 23:54:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55A6EC14051; Sun, 16 Oct 2016 23:54:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 272EE1FD1; Sun, 16 Oct 2016 23:54:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNseos035789; Sun, 16 Oct 2016 23:54:40 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNse7k035788; Sun, 16 Oct 2016 23:54:40 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162354.u9GNse7k035788@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:54:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307446 - stable/10/sbin/devd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:54:41 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:54:40 2016 New Revision: 307446 URL: https://svnweb.freebsd.org/changeset/base/307446 Log: MFC r306840: Sort SEE ALSO section sequentially. Highlighted by mandoc -Tlint PR: 212440 Approved by: imp Differential Revision: https://reviews.freebsd.org/D8192 Modified: stable/10/sbin/devd/devd.conf.5 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/devd/devd.conf.5 ============================================================================== --- stable/10/sbin/devd/devd.conf.5 Sun Oct 16 23:53:10 2016 (r307445) +++ stable/10/sbin/devd/devd.conf.5 Sun Oct 16 23:54:40 2016 (r307446) @@ -41,7 +41,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd April 14, 2016 +.Dd October 8, 2016 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -637,8 +637,8 @@ The installed .Pa /etc/devd.conf has many additional examples. .Sh SEE ALSO +.Xr cam 4 , .Xr coretemp 4 , .Xr devfs 5 , .Xr re_format 7 , -.Xr devd 8 , -.Xr cam 4 +.Xr devd 8 From owner-svn-src-stable@freebsd.org Sun Oct 16 23:55:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF10CC140CB; Sun, 16 Oct 2016 23:55:21 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 908E5112F; Sun, 16 Oct 2016 23:55:21 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GNtK7i035904; Sun, 16 Oct 2016 23:55:20 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GNtKtv035903; Sun, 16 Oct 2016 23:55:20 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610162355.u9GNtKtv035903@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Sun, 16 Oct 2016 23:55:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307447 - stable/11/sbin/devd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 16 Oct 2016 23:55:21 -0000 Author: sevan (doc committer) Date: Sun Oct 16 23:55:20 2016 New Revision: 307447 URL: https://svnweb.freebsd.org/changeset/base/307447 Log: MFC r306840: Sort SEE ALSO section sequentially. Highlighted by mandoc -Tlint PR: 212440 Approved by: imp Differential Revision: https://reviews.freebsd.org/D8192 Modified: stable/11/sbin/devd/devd.conf.5 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/devd/devd.conf.5 ============================================================================== --- stable/11/sbin/devd/devd.conf.5 Sun Oct 16 23:54:40 2016 (r307446) +++ stable/11/sbin/devd/devd.conf.5 Sun Oct 16 23:55:20 2016 (r307447) @@ -41,7 +41,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd April 14, 2016 +.Dd October 8, 2016 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -646,8 +646,8 @@ The installed .Pa /etc/devd.conf has many additional examples. .Sh SEE ALSO +.Xr cam 4 , .Xr coretemp 4 , .Xr devfs 5 , .Xr re_format 7 , -.Xr devd 8 , -.Xr cam 4 +.Xr devd 8 From owner-svn-src-stable@freebsd.org Mon Oct 17 01:47:52 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37DD4C12B8C; Mon, 17 Oct 2016 01:47:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7C1A1805; Mon, 17 Oct 2016 01:47:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H1lpQ6077119; Mon, 17 Oct 2016 01:47:51 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H1ln5K077104; Mon, 17 Oct 2016 01:47:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170147.u9H1ln5K077104@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 01:47:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307448 - in stable/11/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 01:47:52 -0000 Author: sephe Date: Mon Oct 17 01:47:49 2016 New Revision: 307448 URL: https://svnweb.freebsd.org/changeset/base/307448 Log: MFC 302733,302737,302801-302806 302733 hyperv/vmbus: Remove unused code Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7089 302737 hyperv/vmbus: Cleanup channel rescind Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7090 302801 hyperv/vmbus: Remove unused bits Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7091 302802 hyperv: hv_guid -> struct hyperv_guid. This paves way for the further cleanup/disentangle. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7092 302803 hyperv/vmbus: Move channel offer message definition to vmbus_reg.h - Avoid bit fields. - Avoid unnecessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7093 302804 hyperv/vmbus: Switch to vmbus channel message macros Prepare for more cleanup. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7094 302805 hyperv/vmbus: Remove unused bits Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7095 302806 hyperv/vmbus: Get rid of rel{_id,id}, use channel id consistently. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7100 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_if.m stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 01:47:49 2016 (r307448) @@ -82,32 +82,6 @@ typedef uint8_t hv_bool_uint8_t; #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) -/* - * Make maximum size of pipe payload of 16K - */ - -#define HV_MAX_PIPE_DATA_PAYLOAD (sizeof(BYTE) * 16384) - -/* - * Define pipe_mode values - */ - -#define HV_VMBUS_PIPE_TYPE_BYTE 0x00000000 -#define HV_VMBUS_PIPE_TYPE_MESSAGE 0x00000004 - -/* - * The size of the user defined data buffer for non-pipe offers - */ - -#define HV_MAX_USER_DEFINED_BYTES 120 - -/* - * The size of the user defined data buffer for pipe offers - */ - -#define HV_MAX_PIPE_USER_DEFINED_BYTES 116 - - #define HV_MAX_PAGE_BUFFER_COUNT 32 #define HV_MAX_MULTIPAGE_BUFFER_COUNT 32 @@ -121,68 +95,13 @@ typedef uint8_t hv_bool_uint8_t; ((HV_ALIGN_UP(addr+len, PAGE_SIZE) - \ HV_ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT ) -typedef struct hv_guid { - uint8_t data[16]; -} __packed hv_guid; +struct hyperv_guid { + uint8_t hv_guid[16]; +} __packed; #define HYPERV_GUID_STRLEN 40 -int hyperv_guid2str(const struct hv_guid *, char *, size_t); - -#define HV_NIC_GUID \ - .data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, \ - 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} - -#define HV_IDE_GUID \ - .data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, \ - 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5} - -#define HV_SCSI_GUID \ - .data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, \ - 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f} - -/* - * At the center of the Channel Management library is - * the Channel Offer. This struct contains the - * fundamental information about an offer. - */ - -typedef struct hv_vmbus_channel_offer { - hv_guid interface_type; - hv_guid interface_instance; - uint64_t interrupt_latency_in_100ns_units; - uint32_t interface_revision; - uint32_t server_context_area_size; /* in bytes */ - uint16_t channel_flags; - uint16_t mmio_megabytes; /* in bytes * 1024 * 1024 */ - union - { - /* - * Non-pipes: The user has HV_MAX_USER_DEFINED_BYTES bytes. - */ - struct { - uint8_t user_defined[HV_MAX_USER_DEFINED_BYTES]; - } __packed standard; - - /* - * Pipes: The following structure is an integrated pipe protocol, which - * is implemented on top of standard user-defined data. pipe - * clients have HV_MAX_PIPE_USER_DEFINED_BYTES left for their - * own use. - */ - struct { - uint32_t pipe_mode; - uint8_t user_defined[HV_MAX_PIPE_USER_DEFINED_BYTES]; - } __packed pipe; - } u; - - /* - * Sub_channel_index, newly added in Win8. - */ - uint16_t sub_channel_index; - uint16_t padding; - -} __packed hv_vmbus_channel_offer; +int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); typedef struct { uint16_t type; @@ -192,13 +111,6 @@ typedef struct { uint64_t transaction_id; } __packed hv_vm_packet_descriptor; -typedef uint32_t hv_previous_packet_offset; - -typedef struct { - hv_previous_packet_offset previous_packet_start_offset; - hv_vm_packet_descriptor descriptor; -} __packed hv_vm_packet_header; - typedef struct { uint32_t byte_count; uint32_t byte_offset; @@ -213,91 +125,6 @@ typedef struct { hv_vm_transfer_page ranges[1]; } __packed hv_vm_transfer_page_packet_header; -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - uint32_t reserved; -} __packed hv_vm_gpadl_packet_header; - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - uint16_t transfer_page_set_id; - uint16_t reserved; -} __packed hv_vm_add_remove_transfer_page_set; - -/* - * This structure defines a range in guest - * physical space that can be made - * to look virtually contiguous. - */ - -typedef struct { - uint32_t byte_count; - uint32_t byte_offset; - uint64_t pfn_array[0]; -} __packed hv_gpa_range; - -/* - * This is the format for an Establish Gpadl packet, which contains a handle - * by which this GPADL will be known and a set of GPA ranges associated with - * it. This can be converted to a MDL by the guest OS. If there are multiple - * GPA ranges, then the resulting MDL will be "chained," representing multiple - * VA ranges. - */ - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - uint32_t range_count; - hv_gpa_range range[1]; -} __packed hv_vm_establish_gpadl; - -/* - * This is the format for a Teardown Gpadl packet, which indicates that the - * GPADL handle in the Establish Gpadl packet will never be referenced again. - */ - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - /* for alignment to a 8-byte boundary */ - uint32_t reserved; -} __packed hv_vm_teardown_gpadl; - -/* - * This is the format for a GPA-Direct packet, which contains a set of GPA - * ranges, in addition to commands and/or data. - */ - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t reserved; - uint32_t range_count; - hv_gpa_range range[1]; -} __packed hv_vm_data_gpa_direct; - -/* - * This is the format for a Additional data Packet. - */ -typedef struct { - hv_vm_packet_descriptor d; - uint64_t total_bytes; - uint32_t byte_offset; - uint32_t byte_count; - uint8_t data[1]; -} __packed hv_vm_additional_data; - -typedef union { - hv_vm_packet_descriptor simple_header; - hv_vm_transfer_page_packet_header transfer_page_header; - hv_vm_gpadl_packet_header gpadl_header; - hv_vm_add_remove_transfer_page_set add_remove_transfer_page_header; - hv_vm_establish_gpadl establish_gpadl_header; - hv_vm_teardown_gpadl teardown_gpadl_header; - hv_vm_data_gpa_direct data_gpa_direct_header; -} __packed hv_vm_packet_largest_possible_header; - typedef enum { HV_VMBUS_PACKET_TYPE_INVALID = 0x0, HV_VMBUS_PACKET_TYPES_SYNCH = 0x1, @@ -317,86 +144,6 @@ typedef enum { #define HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1 -/* - * Version 1 messages - */ -typedef enum { - HV_CHANNEL_MESSAGE_INVALID = 0, - HV_CHANNEL_MESSAGE_OFFER_CHANNEL = 1, - HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER = 2, - HV_CHANNEL_MESSAGE_REQUEST_OFFERS = 3, - HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED = 4, - HV_CHANNEL_MESSAGE_OPEN_CHANNEL = 5, - HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT = 6, - HV_CHANNEL_MESSAGE_CLOSE_CHANNEL = 7, - HV_CHANNEL_MESSAGEL_GPADL_HEADER = 8, - HV_CHANNEL_MESSAGE_GPADL_BODY = 9, - HV_CHANNEL_MESSAGE_GPADL_CREATED = 10, - HV_CHANNEL_MESSAGE_GPADL_TEARDOWN = 11, - HV_CHANNEL_MESSAGE_GPADL_TORNDOWN = 12, - HV_CHANNEL_MESSAGE_REL_ID_RELEASED = 13, - HV_CHANNEL_MESSAGE_INITIATED_CONTACT = 14, - HV_CHANNEL_MESSAGE_VERSION_RESPONSE = 15, - HV_CHANNEL_MESSAGE_UNLOAD = 16, - HV_CHANNEL_MESSAGE_COUNT -} hv_vmbus_channel_msg_type; - -typedef struct { - hv_vmbus_channel_msg_type message_type; - uint32_t padding; -} __packed hv_vmbus_channel_msg_header; - -/* - * Query VMBus Version parameters - */ -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t version; -} __packed hv_vmbus_channel_query_vmbus_version; - -/* - * Channel Offer parameters - */ -typedef struct { - hv_vmbus_channel_msg_header header; - hv_vmbus_channel_offer offer; - uint32_t child_rel_id; - uint8_t monitor_id; - /* - * This field has been split into a bit field on Win7 - * and higher. - */ - uint8_t monitor_allocated:1; - uint8_t reserved:7; - /* - * Following fields were added in win7 and higher. - * Make sure to check the version before accessing these fields. - * - * If "is_dedicated_interrupt" is set, we must not set the - * associated bit in the channel bitmap while sending the - * interrupt to the host. - * - * connection_id is used in signaling the host. - */ - uint16_t is_dedicated_interrupt:1; - uint16_t reserved1:15; - uint32_t connection_id; -} __packed hv_vmbus_channel_offer_channel; - -/* - * Rescind Offer parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; -} __packed hv_vmbus_channel_rescind_offer; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; -} __packed hv_vmbus_channel_relid_released; - #define HW_MACADDR_LEN 6 /* @@ -505,18 +252,6 @@ typedef enum { HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE, } hv_vmbus_channel_state; -/* - * Connection identifier type - */ -typedef union { - uint32_t as_uint32_t; - struct { - uint32_t id:24; - uint32_t reserved:8; - } u; - -} __packed hv_vmbus_connection_id; - typedef struct hv_vmbus_channel { device_t ch_dev; struct vmbus_softc *vmbus_sc; @@ -603,8 +338,8 @@ typedef struct hv_vmbus_channel { TAILQ_ENTRY(hv_vmbus_channel) ch_link; uint32_t ch_subidx; /* subchan index */ - struct hv_guid ch_guid_type; - struct hv_guid ch_guid_inst; + struct hyperv_guid ch_guid_type; + struct hyperv_guid ch_guid_inst; struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 01:47:49 2016 (r307448) @@ -399,8 +399,8 @@ hn_ifmedia_sts(struct ifnet *ifp, struct } /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ -static const hv_guid g_net_vsc_device_type = { - .data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, +static const struct hyperv_guid g_net_vsc_device_type = { + .hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} }; Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 01:47:49 2016 (r307448) @@ -180,14 +180,14 @@ enum hv_storage_type { #define HV_STORAGE_SUPPORTS_MULTI_CHANNEL 0x1 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */ -static const hv_guid gStorVscDeviceType={ - .data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, +static const struct hyperv_guid gStorVscDeviceType={ + .hv_guid = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f} }; /* {32412632-86cb-44a2-9b5c-50d1417354f5} */ -static const hv_guid gBlkVscDeviceType={ - .data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, +static const struct hyperv_guid gBlkVscDeviceType={ + .hv_guid = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5} }; Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 01:47:49 2016 (r307448) @@ -39,7 +39,7 @@ #include "vmbus_if.h" /* Heartbeat Service */ -static const hv_guid service_guid = { .data = +static const struct hyperv_guid service_guid = { .hv_guid = {0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }; Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 01:47:49 2016 (r307448) @@ -90,7 +90,7 @@ static int hv_kvp_log = 0; log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \ } while (0) -static const hv_guid service_guid = { .data = +static const struct hyperv_guid service_guid = { .hv_guid = {0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6} }; Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 01:47:49 2016 (r307448) @@ -43,7 +43,7 @@ #include "hv_util.h" #include "vmbus_if.h" -static const hv_guid service_guid = { .data = +static const struct hyperv_guid service_guid = { .hv_guid = {0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB} }; Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 01:47:49 2016 (r307448) @@ -55,7 +55,7 @@ typedef struct { } time_sync_data; /* Time Synch Service */ -static const hv_guid service_guid = {.data = +static const struct hyperv_guid service_guid = {.hv_guid = {0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }; Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 01:47:49 2016 (r307448) @@ -897,25 +897,23 @@ vmbus_event_flags_proc(struct vmbus_soft int f; for (f = 0; f < flag_cnt; ++f) { - uint32_t rel_id_base; + uint32_t chid_base; u_long flags; - int bit; + int chid_ofs; if (event_flags[f] == 0) continue; flags = atomic_swap_long(&event_flags[f], 0); - rel_id_base = f << VMBUS_EVTFLAG_SHIFT; + chid_base = f << VMBUS_EVTFLAG_SHIFT; - while ((bit = ffsl(flags)) != 0) { + while ((chid_ofs = ffsl(flags)) != 0) { struct hv_vmbus_channel *channel; - uint32_t rel_id; - --bit; /* NOTE: ffsl is 1-based */ - flags &= ~(1UL << bit); + --chid_ofs; /* NOTE: ffsl is 1-based */ + flags &= ~(1UL << chid_ofs); - rel_id = rel_id_base + bit; - channel = sc->vmbus_chmap[rel_id]; + channel = sc->vmbus_chmap[chid_base + chid_ofs]; /* if channel is closed or closing */ if (channel == NULL || channel->rxq == NULL) Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Oct 17 01:47:49 2016 (r307448) @@ -42,37 +42,40 @@ typedef void (*vmbus_chanmsg_proc_t) static struct hv_vmbus_channel *hv_vmbus_allocate_channel(struct vmbus_softc *); static void vmbus_channel_on_offer_internal(struct vmbus_softc *, - const hv_vmbus_channel_offer_channel *offer); + const struct vmbus_chanmsg_choffer *); static void vmbus_chan_detach_task(void *, int); static void vmbus_channel_on_offer(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, + const struct vmbus_message *); -/** - * Channel message dispatch table +/* + * Vmbus channel message processing. */ + +#define VMBUS_CHANMSG_PROC(name, func) \ + [VMBUS_CHANMSG_TYPE_##name] = func +#define VMBUS_CHANMSG_PROC_WAKEUP(name) \ + VMBUS_CHANMSG_PROC(name, vmbus_msghc_wakeup) + static const vmbus_chanmsg_proc_t -vmbus_chanmsg_process[HV_CHANNEL_MESSAGE_COUNT] = { - [HV_CHANNEL_MESSAGE_OFFER_CHANNEL] = - vmbus_channel_on_offer, - [HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER] = - vmbus_channel_on_offer_rescind, - [HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED] = - vmbus_channel_on_offers_delivered, - [HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT] = - vmbus_msghc_wakeup, - [HV_CHANNEL_MESSAGE_GPADL_CREATED] = - vmbus_msghc_wakeup, - [HV_CHANNEL_MESSAGE_GPADL_TORNDOWN] = - vmbus_msghc_wakeup, - [HV_CHANNEL_MESSAGE_VERSION_RESPONSE] = - vmbus_msghc_wakeup +vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_channel_on_offer), + VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), + VMBUS_CHANMSG_PROC(CHOFFER_DONE,vmbus_channel_on_offers_delivered), + + VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP) }; +#undef VMBUS_CHANMSG_PROC_WAKEUP +#undef VMBUS_CHANMSG_PROC + /** * @brief Allocate and initialize a vmbus channel object */ @@ -110,27 +113,25 @@ vmbus_channel_process_offer(hv_vmbus_cha { struct vmbus_softc *sc = new_channel->vmbus_sc; hv_vmbus_channel* channel; - uint32_t relid; - relid = new_channel->ch_id; /* * Make sure this is a new offer */ mtx_lock(&sc->vmbus_chlist_lock); - if (relid == 0) { + if (new_channel->ch_id == 0) { /* * XXX channel0 will not be processed; skip it. */ printf("VMBUS: got channel0 offer\n"); } else { - sc->vmbus_chmap[relid] = new_channel; + sc->vmbus_chmap[new_channel->ch_id] = new_channel; } TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { if (memcmp(&channel->ch_guid_type, &new_channel->ch_guid_type, - sizeof(hv_guid)) == 0 && + sizeof(struct hyperv_guid)) == 0 && memcmp(&channel->ch_guid_inst, &new_channel->ch_guid_inst, - sizeof(hv_guid)) == 0) + sizeof(struct hyperv_guid)) == 0) break; } @@ -267,18 +268,16 @@ vmbus_channel_select_defcpu(struct hv_vm static void vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_offer_channel *offer; - /* New channel is offered by vmbus */ vmbus_scan_newchan(sc); - offer = (const hv_vmbus_channel_offer_channel *)msg->msg_data; - vmbus_channel_on_offer_internal(sc, offer); + vmbus_channel_on_offer_internal(sc, + (const struct vmbus_chanmsg_choffer *)msg->msg_data); } static void vmbus_channel_on_offer_internal(struct vmbus_softc *sc, - const hv_vmbus_channel_offer_channel *offer) + const struct vmbus_chanmsg_choffer *offer) { hv_vmbus_channel* new_channel; @@ -286,14 +285,14 @@ vmbus_channel_on_offer_internal(struct v * Allocate the channel object and save this offer */ new_channel = hv_vmbus_allocate_channel(sc); - new_channel->ch_id = offer->child_rel_id; - new_channel->ch_subidx = offer->offer.sub_channel_index; - new_channel->ch_guid_type = offer->offer.interface_type; - new_channel->ch_guid_inst = offer->offer.interface_instance; + new_channel->ch_id = offer->chm_chanid; + new_channel->ch_subidx = offer->chm_subidx; + new_channel->ch_guid_type = offer->chm_chtype; + new_channel->ch_guid_inst = offer->chm_chinst; /* Batch reading is on by default */ new_channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; - if (offer->monitor_allocated) + if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; new_channel->ch_monprm = hyperv_dmamem_alloc( @@ -309,15 +308,15 @@ vmbus_channel_on_offer_internal(struct v } new_channel->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; if (sc->vmbus_version != VMBUS_VERSION_WS2008) - new_channel->ch_monprm->mp_connid = offer->connection_id; + new_channel->ch_monprm->mp_connid = offer->chm_connid; if (new_channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { new_channel->ch_montrig_idx = - offer->monitor_id / VMBUS_MONTRIG_LEN; + offer->chm_montrig / VMBUS_MONTRIG_LEN; if (new_channel->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) - panic("invalid monitor id %u", offer->monitor_id); + panic("invalid monitor trigger %u", offer->chm_montrig); new_channel->ch_montrig_mask = - 1 << (offer->monitor_id % VMBUS_MONTRIG_LEN); + 1 << (offer->chm_montrig % VMBUS_MONTRIG_LEN); } /* Select default cpu for this channel. */ @@ -326,33 +325,34 @@ vmbus_channel_on_offer_internal(struct v vmbus_channel_process_offer(new_channel); } -/** - * @brief Rescind offer handler. - * - * We queue a work item to process this offer - * synchronously. - * +/* * XXX pretty broken; need rework. */ static void -vmbus_channel_on_offer_rescind(struct vmbus_softc *sc, +vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_rescind_offer *rescind; - hv_vmbus_channel* channel; + const struct vmbus_chanmsg_chrescind *note; + struct hv_vmbus_channel *chan; + + note = (const struct vmbus_chanmsg_chrescind *)msg->msg_data; + if (note->chm_chanid > VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid rescinded chan%u\n", + note->chm_chanid); + return; + } - rescind = (const hv_vmbus_channel_rescind_offer *)msg->msg_data; if (bootverbose) { - device_printf(sc->vmbus_dev, "chan%u rescind\n", - rescind->child_rel_id); + device_printf(sc->vmbus_dev, "chan%u rescinded\n", + note->chm_chanid); } - channel = sc->vmbus_chmap[rescind->child_rel_id]; - if (channel == NULL) - return; - sc->vmbus_chmap[rescind->child_rel_id] = NULL; + chan = sc->vmbus_chmap[note->chm_chanid]; + if (chan == NULL) + return; + sc->vmbus_chmap[note->chm_chanid] = NULL; - taskqueue_enqueue(taskqueue_thread, &channel->ch_detach_task); + taskqueue_enqueue(taskqueue_thread, &chan->ch_detach_task); } static void @@ -563,7 +563,7 @@ vmbus_chan_msgproc(struct vmbus_softc *s uint32_t msg_type; msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; - if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { + if (msg_type >= VMBUS_CHANMSG_TYPE_MAX) { device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", msg_type); return; Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 01:47:49 2016 (r307448) @@ -56,8 +56,8 @@ typedef struct { typedef struct { uint32_t rel_id; hv_vmbus_channel_state state; - hv_guid interface_type; - hv_guid interface_instance; + struct hyperv_guid interface_type; + struct hyperv_guid interface_instance; uint32_t monitor_id; uint32_t server_monitor_pending; uint32_t server_monitor_latency; @@ -97,67 +97,6 @@ typedef struct hv_vmbus_channel_packet_m hv_vmbus_multipage_buffer range; } __packed hv_vmbus_channel_packet_multipage_buffer; -typedef union { - uint32_t as_uint32_t; - struct { - uint32_t group_enable :4; - uint32_t rsvd_z :28; - } u; -} hv_vmbus_monitor_trigger_state; - -typedef union { - uint64_t as_uint64_t; - struct { - uint32_t pending; - uint32_t armed; - } u; -} hv_vmbus_monitor_trigger_group; - -typedef struct { - hv_vmbus_connection_id connection_id; - uint16_t flag_number; - uint16_t rsvd_z; -} hv_vmbus_monitor_parameter; - -/* - * hv_vmbus_monitor_page Layout - * ------------------------------------------------------ - * | 0 | trigger_state (4 bytes) | Rsvd1 (4 bytes) | - * | 8 | trigger_group[0] | - * | 10 | trigger_group[1] | - * | 18 | trigger_group[2] | - * | 20 | trigger_group[3] | - * | 28 | Rsvd2[0] | - * | 30 | Rsvd2[1] | - * | 38 | Rsvd2[2] | - * | 40 | next_check_time[0][0] | next_check_time[0][1] | - * | ... | - * | 240 | latency[0][0..3] | - * | 340 | Rsvz3[0] | - * | 440 | parameter[0][0] | - * | 448 | parameter[0][1] | - * | ... | - * | 840 | Rsvd4[0] | - * ------------------------------------------------------ - */ - -typedef struct { - hv_vmbus_monitor_trigger_state trigger_state; - uint32_t rsvd_z1; - - hv_vmbus_monitor_trigger_group trigger_group[4]; - uint64_t rsvd_z2[3]; - - int32_t next_check_time[4][32]; - - uint16_t latency[4][32]; - uint64_t rsvd_z3[32]; - - hv_vmbus_monitor_parameter parameter[4][32]; - - uint8_t rsvd_z4[1984]; -} hv_vmbus_monitor_page; - /* * Private, VM Bus functions */ Modified: stable/11/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/vmbus/hyperv.c Mon Oct 17 01:47:49 2016 (r307448) @@ -116,9 +116,9 @@ hypercall_signal_event(bus_addr_t monprm } int -hyperv_guid2str(const struct hv_guid *guid, char *buf, size_t sz) +hyperv_guid2str(const struct hyperv_guid *guid, char *buf, size_t sz) { - const uint8_t *d = guid->data; + const uint8_t *d = guid->hv_guid; return snprintf(buf, sz, "%02x%02x%02x%02x-" "%02x%02x-%02x%02x-%02x%02x-" Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 01:47:49 2016 (r307448) @@ -1051,11 +1051,12 @@ vmbus_get_version_method(device_t bus, d } static int -vmbus_probe_guid_method(device_t bus, device_t dev, const struct hv_guid *guid) +vmbus_probe_guid_method(device_t bus, device_t dev, + const struct hyperv_guid *guid) { const struct hv_vmbus_channel *chan = vmbus_get_channel(dev); - if (memcmp(&chan->ch_guid_type, guid, sizeof(struct hv_guid)) == 0) + if (memcmp(&chan->ch_guid_type, guid, sizeof(struct hyperv_guid)) == 0) return 0; return ENXIO; } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_if.m ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_if.m Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_if.m Mon Oct 17 01:47:49 2016 (r307448) @@ -32,7 +32,7 @@ INTERFACE vmbus; HEADER { - struct hv_guid; + struct hyperv_guid; }; METHOD uint32_t get_version { @@ -43,5 +43,5 @@ METHOD uint32_t get_version { METHOD int probe_guid { device_t bus; device_t dev; - const struct hv_guid *guid; + const struct hyperv_guid *guid; }; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Sun Oct 16 23:55:20 2016 (r307447) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 01:47:49 2016 (r307448) @@ -31,6 +31,7 @@ #include #include +#include /* XXX for hyperv_guid */ /* * Hyper-V SynIC message format. @@ -117,11 +118,14 @@ struct vmbus_gpa_range { /* * Channel messages - * - Embedded in vmbus_message.msg_data, e.g. response. + * - Embedded in vmbus_message.msg_data, e.g. response and notification. * - Embedded in hypercall_postmsg_in.hc_data, e.g. request. */ +#define VMBUS_CHANMSG_TYPE_CHOFFER 1 /* NOTE */ +#define VMBUS_CHANMSG_TYPE_CHRESCIND 2 /* NOTE */ #define VMBUS_CHANMSG_TYPE_CHREQUEST 3 /* REQ */ +#define VMBUS_CHANMSG_TYPE_CHOFFER_DONE 4 /* NOTE */ #define VMBUS_CHANMSG_TYPE_CHOPEN 5 /* REQ */ #define VMBUS_CHANMSG_TYPE_CHOPEN_RESP 6 /* RESP */ #define VMBUS_CHANMSG_TYPE_CHCLOSE 7 /* REQ */ @@ -134,6 +138,7 @@ struct vmbus_gpa_range { #define VMBUS_CHANMSG_TYPE_CONNECT 14 /* REQ */ #define VMBUS_CHANMSG_TYPE_CONNECT_RESP 15 /* RESP */ #define VMBUS_CHANMSG_TYPE_DISCONNECT 16 /* REQ */ +#define VMBUS_CHANMSG_TYPE_MAX 22 struct vmbus_chanmsg_hdr { uint32_t chm_type; /* VMBUS_CHANMSG_TYPE_ */ @@ -241,4 +246,33 @@ struct vmbus_chanmsg_chfree { uint32_t chm_chanid; } __packed; +/* VMBUS_CHANMSG_TYPE_CHRESCIND */ +struct vmbus_chanmsg_chrescind { + struct vmbus_chanmsg_hdr chm_hdr; + uint32_t chm_chanid; +} __packed; + +/* VMBUS_CHANMSG_TYPE_CHOFFER */ +struct vmbus_chanmsg_choffer { + struct vmbus_chanmsg_hdr chm_hdr; + struct hyperv_guid chm_chtype; + struct hyperv_guid chm_chinst; + uint64_t chm_chlat; /* unit: 100ns */ + uint32_t chm_chrev; + uint32_t chm_svrctx_sz; + uint16_t chm_chflags; + uint16_t chm_mmio_sz; /* unit: MB */ + uint8_t chm_udata[120]; + uint16_t chm_subidx; + uint16_t chm_rsvd; + uint32_t chm_chanid; + uint8_t chm_montrig; + uint8_t chm_flags1; /* VMBUS_CHOFFER_FLAG1_ */ + uint16_t chm_flags2; + uint32_t chm_connid; +} __packed; +CTASSERT(sizeof(struct vmbus_chanmsg_choffer) <= VMBUS_MSG_DSIZE_MAX); + +#define VMBUS_CHOFFER_FLAG1_HASMNF 0x01 + #endif /* !_VMBUS_REG_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 01:59:44 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E431C12E58; Mon, 17 Oct 2016 01:59:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A2DD1D5E; Mon, 17 Oct 2016 01:59:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H1xhch081051; Mon, 17 Oct 2016 01:59:43 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H1xgoT081044; Mon, 17 Oct 2016 01:59:42 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170159.u9H1xgoT081044@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 01:59:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307449 - in stable/11/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 01:59:44 -0000 Author: sephe Date: Mon Oct 17 01:59:42 2016 New Revision: 307449 URL: https://svnweb.freebsd.org/changeset/base/307449 Log: MFC 302808-302815 302808 hyperv/vmbus: Alloc/Free monitor param in vmbus channel alloc/free. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7101 302809 hyperv/vmbus: Move device register and channel free to the caller. This paves the way for more cleanup/disentangle. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7102 302810 hyperv/vmbus: Move new channel scan notification to device register And nuke now unnecessary function indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7103 302811 hyperv/vmbus: Cleanup vmbus_chan_msgproc_choffer Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7104 302812 hyperv/vmbus: Nuke the channel open state. Channel is either opened or not-opened. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7105 302813 hyperv/vmbus: Cleanup vmbus_chan_add() Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7106 302814 hyperv/vmbus: Use sub-channel index to detect primary channel In case that VMBUS_CHAN_ISPRIMARY is needed in the early place of channel setup. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7108 302815 hyperv/vmbus: Only add primary channels to vmbus channel list - Make the vmbus_chan_add more straightforward. - Partially fix the hv_vmbus_release_unattached_channels(). Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7109 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 01:47:49 2016 (r307448) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 01:59:42 2016 (r307449) @@ -244,18 +244,9 @@ typedef struct { typedef void (*hv_vmbus_pfn_channel_callback)(void *context); -typedef enum { - HV_CHANNEL_OFFER_STATE, - HV_CHANNEL_OPENING_STATE, - HV_CHANNEL_OPEN_STATE, - HV_CHANNEL_OPENED_STATE, - HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE, -} hv_vmbus_channel_state; - typedef struct hv_vmbus_channel { device_t ch_dev; struct vmbus_softc *vmbus_sc; - hv_vmbus_channel_state state; uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ uint32_t ch_id; /* channel id */ @@ -337,14 +328,15 @@ typedef struct hv_vmbus_channel { struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_link; uint32_t ch_subidx; /* subchan index */ - + volatile uint32_t ch_stflags; /* atomic-op */ + /* VMBUS_CHAN_ST_ */ struct hyperv_guid ch_guid_type; struct hyperv_guid ch_guid_inst; struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; -#define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) +#define VMBUS_CHAN_ISPRIMARY(chan) ((chan)->ch_subidx == 0) #define VMBUS_CHAN_FLAG_HASMNF 0x0001 /* @@ -357,6 +349,9 @@ typedef struct hv_vmbus_channel { */ #define VMBUS_CHAN_FLAG_BATCHREAD 0x0002 +#define VMBUS_CHAN_ST_OPENED_SHIFT 0 +#define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) + static inline void hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on) { Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 01:47:49 2016 (r307448) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 01:59:42 2016 (r307449) @@ -719,11 +719,6 @@ hv_nv_on_device_remove(struct hn_softc * /* Now, we can close the channel safely */ - if (!destroy_channel) { - sc->hn_prichan->state = - HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE; - } - free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); hv_vmbus_channel_close(sc->hn_prichan); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 01:47:49 2016 (r307448) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 01:59:42 2016 (r307449) @@ -2957,7 +2957,7 @@ static void hn_subchan_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan) { - KASSERT(!HV_VMBUS_CHAN_ISPRIMARY(chan), + KASSERT(!VMBUS_CHAN_ISPRIMARY(chan), ("subchannel callback on primary channel")); KASSERT(chan->ch_subidx > 0, ("invalid channel subidx %u", Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 01:47:49 2016 (r307448) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 01:59:42 2016 (r307449) @@ -191,17 +191,9 @@ hv_vmbus_channel_open( return EINVAL; } - mtx_lock(&new_channel->sc_lock); - if (new_channel->state == HV_CHANNEL_OPEN_STATE) { - new_channel->state = HV_CHANNEL_OPENING_STATE; - } else { - mtx_unlock(&new_channel->sc_lock); - if(bootverbose) - printf("VMBUS: Trying to open channel <%p> which in " - "%d state.\n", new_channel, new_channel->state); - return (EINVAL); - } - mtx_unlock(&new_channel->sc_lock); + if (atomic_testandset_int(&new_channel->ch_stflags, + VMBUS_CHAN_ST_OPENED_SHIFT)) + panic("double-open chan%u", new_channel->ch_id); new_channel->on_channel_callback = pfn_on_channel_callback; new_channel->channel_callback_context = context; @@ -223,8 +215,10 @@ hv_vmbus_channel_open( M_DEVBUF, M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); KASSERT(out != NULL, ("Error VMBUS: contigmalloc failed to allocate Ring Buffer!")); - if (out == NULL) - return (ENOMEM); + if (out == NULL) { + ret = ENOMEM; + goto failed; + } in = ((uint8_t *) out + send_ring_buffer_size); @@ -265,7 +259,8 @@ hv_vmbus_channel_open( device_printf(sc->vmbus_dev, "can not get msg hypercall for chopen(chan%u)\n", new_channel->ch_id); - return ENXIO; + ret = ENXIO; + goto failed; } req = vmbus_msghc_dataptr(mh); @@ -284,7 +279,7 @@ hv_vmbus_channel_open( "chopen(chan%u) msg hypercall exec failed: %d\n", new_channel->ch_id, ret); vmbus_msghc_put(sc, mh); - return ret; + goto failed; } msg = vmbus_msghc_wait_result(sc, mh); @@ -294,17 +289,20 @@ hv_vmbus_channel_open( vmbus_msghc_put(sc, mh); if (status == 0) { - new_channel->state = HV_CHANNEL_OPENED_STATE; if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u opened\n", new_channel->ch_id); } - } else { - device_printf(sc->vmbus_dev, "failed to open chan%u\n", - new_channel->ch_id); - ret = ENXIO; + return 0; } - return (ret); + + device_printf(sc->vmbus_dev, "failed to open chan%u\n", + new_channel->ch_id); + ret = ENXIO; + +failed: + atomic_clear_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED); + return ret; } /** @@ -487,7 +485,9 @@ hv_vmbus_channel_close_internal(hv_vmbus struct taskqueue *rxq = channel->rxq; int error; - channel->state = HV_CHANNEL_OPEN_STATE; + /* TODO: stringent check */ + atomic_clear_int(&channel->ch_stflags, VMBUS_CHAN_ST_OPENED); + sysctl_ctx_free(&channel->ch_sysctl_ctx); /* @@ -563,7 +563,7 @@ hv_vmbus_channel_close(hv_vmbus_channel */ TAILQ_FOREACH(sub_channel, &channel->sc_list_anchor, sc_list_entry) { - if (sub_channel->state != HV_CHANNEL_OPENED_STATE) + if ((sub_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) continue; hv_vmbus_channel_close_internal(sub_channel); } Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Oct 17 01:47:49 2016 (r307448) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Oct 17 01:59:42 2016 (r307449) @@ -40,15 +40,12 @@ typedef void (*vmbus_chanmsg_proc_t) (struct vmbus_softc *, const struct vmbus_message *); -static struct hv_vmbus_channel *hv_vmbus_allocate_channel(struct vmbus_softc *); -static void vmbus_channel_on_offer_internal(struct vmbus_softc *, - const struct vmbus_chanmsg_choffer *); static void vmbus_chan_detach_task(void *, int); -static void vmbus_channel_on_offer(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, const struct vmbus_message *); +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, const struct vmbus_message *); @@ -63,7 +60,7 @@ static void vmbus_chan_msgproc_chrescind static const vmbus_chanmsg_proc_t vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE_MAX] = { - VMBUS_CHANMSG_PROC(CHOFFER, vmbus_channel_on_offer), + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer), VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), VMBUS_CHANMSG_PROC(CHOFFER_DONE,vmbus_channel_on_offers_delivered), @@ -76,146 +73,125 @@ vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE #undef VMBUS_CHANMSG_PROC_WAKEUP #undef VMBUS_CHANMSG_PROC -/** - * @brief Allocate and initialize a vmbus channel object - */ static struct hv_vmbus_channel * -hv_vmbus_allocate_channel(struct vmbus_softc *sc) +vmbus_chan_alloc(struct vmbus_softc *sc) { - struct hv_vmbus_channel *channel; + struct hv_vmbus_channel *chan; - channel = malloc(sizeof(*channel), M_DEVBUF, M_WAITOK | M_ZERO); - channel->vmbus_sc = sc; + chan = malloc(sizeof(*chan), M_DEVBUF, M_WAITOK | M_ZERO); - mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF); - TAILQ_INIT(&channel->sc_list_anchor); - TASK_INIT(&channel->ch_detach_task, 0, vmbus_chan_detach_task, channel); + chan->ch_monprm = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &chan->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (chan->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); + free(chan, M_DEVBUF); + return NULL; + } - return (channel); + chan->vmbus_sc = sc; + mtx_init(&chan->sc_lock, "vmbus multi channel", NULL, MTX_DEF); + TAILQ_INIT(&chan->sc_list_anchor); + TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + + return chan; } -/** - * @brief Release the resources used by the vmbus channel object - */ -void -hv_vmbus_free_vmbus_channel(hv_vmbus_channel* channel) +static void +vmbus_chan_free(struct hv_vmbus_channel *chan) { - mtx_destroy(&channel->sc_lock); - free(channel, M_DEVBUF); + /* TODO: assert sub-channel list is empty */ + /* TODO: asset no longer on the primary channel's sub-channel list */ + /* TODO: asset no longer on the vmbus channel list */ + hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); + mtx_destroy(&chan->sc_lock); + free(chan, M_DEVBUF); } -/** - * @brief Process the offer by creating a channel/device - * associated with this offer - */ -static void -vmbus_channel_process_offer(hv_vmbus_channel *new_channel) +static int +vmbus_chan_add(struct hv_vmbus_channel *newchan) { - struct vmbus_softc *sc = new_channel->vmbus_sc; - hv_vmbus_channel* channel; + struct vmbus_softc *sc = newchan->vmbus_sc; + struct hv_vmbus_channel *prichan; - /* - * Make sure this is a new offer - */ - mtx_lock(&sc->vmbus_chlist_lock); - if (new_channel->ch_id == 0) { + if (newchan->ch_id == 0) { /* - * XXX channel0 will not be processed; skip it. + * XXX + * Chan0 will neither be processed nor should be offered; + * skip it. */ - printf("VMBUS: got channel0 offer\n"); - } else { - sc->vmbus_chmap[new_channel->ch_id] = new_channel; + device_printf(sc->vmbus_dev, "got chan0 offer, discard\n"); + return EINVAL; + } else if (newchan->ch_id >= VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid chan%u offer\n", + newchan->ch_id); + return EINVAL; } + sc->vmbus_chmap[newchan->ch_id] = newchan; - TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { - if (memcmp(&channel->ch_guid_type, &new_channel->ch_guid_type, + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u subidx%u offer\n", + newchan->ch_id, newchan->ch_subidx); + } + + mtx_lock(&sc->vmbus_chlist_lock); + TAILQ_FOREACH(prichan, &sc->vmbus_chlist, ch_link) { + if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type, sizeof(struct hyperv_guid)) == 0 && - memcmp(&channel->ch_guid_inst, &new_channel->ch_guid_inst, + memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst, sizeof(struct hyperv_guid)) == 0) break; } - - if (channel == NULL) { - /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, ch_link); - } - mtx_unlock(&sc->vmbus_chlist_lock); - - if (bootverbose) { - char logstr[64]; - - logstr[0] = '\0'; - if (channel != NULL) { - snprintf(logstr, sizeof(logstr), ", primary chan%u", - channel->ch_id); + if (VMBUS_CHAN_ISPRIMARY(newchan)) { + if (prichan == NULL) { + /* Install the new primary channel */ + TAILQ_INSERT_TAIL(&sc->vmbus_chlist, newchan, ch_link); + mtx_unlock(&sc->vmbus_chlist_lock); + return 0; + } else { + mtx_unlock(&sc->vmbus_chlist_lock); + device_printf(sc->vmbus_dev, "duplicated primary " + "chan%u\n", newchan->ch_id); + return EINVAL; } - device_printf(sc->vmbus_dev, "chan%u subchanid%u offer%s\n", - new_channel->ch_id, - new_channel->ch_subidx, logstr); - } - - if (channel != NULL) { - /* - * Check if this is a sub channel. - */ - if (new_channel->ch_subidx != 0) { - /* - * It is a sub channel offer, process it. - */ - new_channel->primary_channel = channel; - new_channel->ch_dev = channel->ch_dev; - mtx_lock(&channel->sc_lock); - TAILQ_INSERT_TAIL(&channel->sc_list_anchor, - new_channel, sc_list_entry); - mtx_unlock(&channel->sc_lock); - - /* - * Insert the new channel to the end of the global - * channel list. - * - * NOTE: - * The new sub-channel MUST be inserted AFTER it's - * primary channel, so that the primary channel will - * be found in the above loop for its baby siblings. - */ - mtx_lock(&sc->vmbus_chlist_lock); - TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, - ch_link); + } else { /* Sub-channel */ + if (prichan == NULL) { mtx_unlock(&sc->vmbus_chlist_lock); - - new_channel->state = HV_CHANNEL_OPEN_STATE; - - /* - * Bump up sub-channel count and notify anyone that is - * interested in this sub-channel, after this sub-channel - * is setup. - */ - mtx_lock(&channel->sc_lock); - channel->subchan_cnt++; - mtx_unlock(&channel->sc_lock); - wakeup(channel); - - return; + device_printf(sc->vmbus_dev, "no primary chan for " + "chan%u\n", newchan->ch_id); + return EINVAL; } - - printf("VMBUS: duplicated primary channel%u\n", - new_channel->ch_id); - hv_vmbus_free_vmbus_channel(new_channel); - return; + /* + * Found the primary channel for this sub-channel and + * move on. + * + * XXX refcnt prichan + */ } + mtx_unlock(&sc->vmbus_chlist_lock); + + /* + * This is a sub-channel; link it with the primary channel. + */ + KASSERT(!VMBUS_CHAN_ISPRIMARY(newchan), + ("new channel is not sub-channel")); + KASSERT(prichan != NULL, ("no primary channel")); - new_channel->state = HV_CHANNEL_OPEN_STATE; + newchan->primary_channel = prichan; + newchan->ch_dev = prichan->ch_dev; + mtx_lock(&prichan->sc_lock); + TAILQ_INSERT_TAIL(&prichan->sc_list_anchor, newchan, sc_list_entry); /* - * Add the new device to the bus. This will kick off device-driver - * binding which eventually invokes the device driver's AddDevice() - * method. - * - * NOTE: - * Error is ignored here; don't have much to do if error really - * happens. + * Bump up sub-channel count and notify anyone that is + * interested in this sub-channel, after this sub-channel + * is setup. */ - hv_vmbus_child_device_register(new_channel); + prichan->subchan_cnt++; + mtx_unlock(&prichan->sc_lock); + wakeup(prichan); + + return 0; } void @@ -250,7 +226,7 @@ vmbus_channel_cpu_rr(struct hv_vmbus_cha } static void -vmbus_channel_select_defcpu(struct hv_vmbus_channel *chan) +vmbus_chan_cpu_default(struct hv_vmbus_channel *chan) { /* * By default, pin the channel to cpu0. Devices having @@ -260,69 +236,68 @@ vmbus_channel_select_defcpu(struct hv_vm vmbus_channel_cpu_set(chan, 0); } -/** - * @brief Handler for channel offers from Hyper-V/Azure - * - * Handler for channel offers from vmbus in parent partition. - */ static void -vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) +vmbus_chan_msgproc_choffer(struct vmbus_softc *sc, + const struct vmbus_message *msg) { - /* New channel is offered by vmbus */ - vmbus_scan_newchan(sc); + const struct vmbus_chanmsg_choffer *offer; + struct hv_vmbus_channel *chan; + int error; - vmbus_channel_on_offer_internal(sc, - (const struct vmbus_chanmsg_choffer *)msg->msg_data); -} + offer = (const struct vmbus_chanmsg_choffer *)msg->msg_data; -static void -vmbus_channel_on_offer_internal(struct vmbus_softc *sc, - const struct vmbus_chanmsg_choffer *offer) -{ - hv_vmbus_channel* new_channel; + chan = vmbus_chan_alloc(sc); + if (chan == NULL) { + device_printf(sc->vmbus_dev, "allocate chan%u failed\n", + offer->chm_chanid); + return; + } - /* - * Allocate the channel object and save this offer - */ - new_channel = hv_vmbus_allocate_channel(sc); - new_channel->ch_id = offer->chm_chanid; - new_channel->ch_subidx = offer->chm_subidx; - new_channel->ch_guid_type = offer->chm_chtype; - new_channel->ch_guid_inst = offer->chm_chinst; + chan->ch_id = offer->chm_chanid; + chan->ch_subidx = offer->chm_subidx; + chan->ch_guid_type = offer->chm_chtype; + chan->ch_guid_inst = offer->chm_chinst; /* Batch reading is on by default */ - new_channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; - if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) - new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + chan->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; - new_channel->ch_monprm = hyperv_dmamem_alloc( - bus_get_dma_tag(sc->vmbus_dev), - HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), - &new_channel->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (new_channel->ch_monprm == NULL) { - device_printf(sc->vmbus_dev, "monprm alloc failed\n"); - /* XXX */ - mtx_destroy(&new_channel->sc_lock); - free(new_channel, M_DEVBUF); - return; - } - new_channel->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; + chan->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; if (sc->vmbus_version != VMBUS_VERSION_WS2008) - new_channel->ch_monprm->mp_connid = offer->chm_connid; + chan->ch_monprm->mp_connid = offer->chm_connid; - if (new_channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { - new_channel->ch_montrig_idx = - offer->chm_montrig / VMBUS_MONTRIG_LEN; - if (new_channel->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) + if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) { + /* + * Setup MNF stuffs. + */ + chan->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + chan->ch_montrig_idx = offer->chm_montrig / VMBUS_MONTRIG_LEN; + if (chan->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) panic("invalid monitor trigger %u", offer->chm_montrig); - new_channel->ch_montrig_mask = + chan->ch_montrig_mask = 1 << (offer->chm_montrig % VMBUS_MONTRIG_LEN); } /* Select default cpu for this channel. */ - vmbus_channel_select_defcpu(new_channel); + vmbus_chan_cpu_default(chan); - vmbus_channel_process_offer(new_channel); + error = vmbus_chan_add(chan); + if (error) { + device_printf(sc->vmbus_dev, "add chan%u failed: %d\n", + chan->ch_id, error); + vmbus_chan_free(chan); + return; + } + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Add device for this primary channel. + * + * NOTE: + * Error is ignored here; don't have much to do if error + * really happens. + */ + hv_vmbus_child_device_register(chan); + } } /* @@ -360,7 +335,7 @@ vmbus_chan_detach_task(void *xchan, int { struct hv_vmbus_channel *chan = xchan; - if (HV_VMBUS_CHAN_ISPRIMARY(chan)) { + if (VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the device */ hv_vmbus_child_device_unregister(chan); /* NOTE: DO NOT free primary channel for now */ @@ -398,10 +373,6 @@ vmbus_chan_detach_task(void *xchan, int } } remove: - mtx_lock(&sc->vmbus_chlist_lock); - TAILQ_REMOVE(&sc->vmbus_chlist, chan, ch_link); - mtx_unlock(&sc->vmbus_chlist_lock); - mtx_lock(&pri_chan->sc_lock); TAILQ_REMOVE(&pri_chan->sc_list_anchor, chan, sc_list_entry); KASSERT(pri_chan->subchan_cnt > 0, @@ -410,7 +381,7 @@ remove: mtx_unlock(&pri_chan->sc_lock); wakeup(pri_chan); - hv_vmbus_free_vmbus_channel(chan); + vmbus_chan_free(chan); } } @@ -439,13 +410,11 @@ hv_vmbus_release_unattached_channels(str while (!TAILQ_EMPTY(&sc->vmbus_chlist)) { channel = TAILQ_FIRST(&sc->vmbus_chlist); + KASSERT(VMBUS_CHAN_ISPRIMARY(channel), ("not primary channel")); TAILQ_REMOVE(&sc->vmbus_chlist, channel, ch_link); - if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { - /* Only primary channel owns the device */ - hv_vmbus_child_device_unregister(channel); - } - hv_vmbus_free_vmbus_channel(channel); + hv_vmbus_child_device_unregister(channel); + vmbus_chan_free(channel); } bzero(sc->vmbus_chmap, sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); @@ -483,7 +452,7 @@ vmbus_select_outgoing_channel(struct hv_ cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) { - if (new_channel->state != HV_CHANNEL_OPENED_STATE){ + if ((new_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) { continue; } Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 01:47:49 2016 (r307448) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 01:59:42 2016 (r307449) @@ -55,7 +55,6 @@ typedef struct { typedef struct { uint32_t rel_id; - hv_vmbus_channel_state state; struct hyperv_guid interface_type; struct hyperv_guid interface_instance; uint32_t monitor_id; @@ -147,7 +146,6 @@ void hv_ring_buffer_read_begin( uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); void hv_vmbus_release_unattached_channels( struct vmbus_softc *); Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 01:47:49 2016 (r307448) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 01:59:42 2016 (r307449) @@ -994,6 +994,9 @@ hv_vmbus_child_device_register(struct hv device_t parent = sc->vmbus_dev; int error = 0; + /* New channel has been offered */ + vmbus_scan_newchan(sc); + chan->ch_dev = device_add_child(parent, NULL, -1); if (chan->ch_dev == NULL) { device_printf(parent, "device_add_child for chan%u failed\n", From owner-svn-src-stable@freebsd.org Mon Oct 17 02:02:46 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99D50C13016; Mon, 17 Oct 2016 02:02:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6E07510F4; Mon, 17 Oct 2016 02:02:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H22jOM084551; Mon, 17 Oct 2016 02:02:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H22j0L084545; Mon, 17 Oct 2016 02:02:45 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170202.u9H22j0L084545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:02:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307450 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:02:46 -0000 Author: sephe Date: Mon Oct 17 02:02:44 2016 New Revision: 307450 URL: https://svnweb.freebsd.org/changeset/base/307450 Log: MFC 302816-302818 302816 hyperv/vmbus: Release vmbus channel lock before detach devices Device detach method may sleep. While I'm here, rename the function, fix indentation and function comment. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7110 302817 hyperv/vmbus: Field renaming to reflect reality Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7111 302818 hyperv/vmbus: Fix the racy channel close. It is not safe to iterate the sub-channel list w/o lock on the close path, while it's even more difficult to hold the lock and iterate the sub-channel list. We leverage the vmbua_{get,rel}_subchan() functions to solve this dilemma. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7112 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 01:59:42 2016 (r307449) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:02:44 2016 (r307450) @@ -326,7 +326,7 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv3; struct task ch_detach_task; - TAILQ_ENTRY(hv_vmbus_channel) ch_link; + TAILQ_ENTRY(hv_vmbus_channel) ch_prilink; /* primary chan link */ uint32_t ch_subidx; /* subchan index */ volatile uint32_t ch_stflags; /* atomic-op */ /* VMBUS_CHAN_ST_ */ Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 01:59:42 2016 (r307449) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:02:44 2016 (r307450) @@ -542,35 +542,40 @@ hv_vmbus_channel_close_internal(hv_vmbus M_DEVBUF); } -/** - * @brief Close the specified channel +/* + * Caller should make sure that all sub-channels have + * been added to 'chan' and all to-be-closed channels + * are not being opened. */ void -hv_vmbus_channel_close(hv_vmbus_channel *channel) +hv_vmbus_channel_close(struct hv_vmbus_channel *chan) { - hv_vmbus_channel* sub_channel; + int subchan_cnt; - if (channel->primary_channel != NULL) { + if (!VMBUS_CHAN_ISPRIMARY(chan)) { /* - * We only close multi-channels when the primary is - * closed. + * Sub-channel is closed when its primary channel + * is closed; done. */ return; } /* - * Close all multi-channels first. + * Close all sub-channels, if any. */ - TAILQ_FOREACH(sub_channel, &channel->sc_list_anchor, - sc_list_entry) { - if ((sub_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) - continue; - hv_vmbus_channel_close_internal(sub_channel); + subchan_cnt = chan->subchan_cnt; + if (subchan_cnt > 0) { + struct hv_vmbus_channel **subchan; + int i; + + subchan = vmbus_get_subchan(chan, subchan_cnt); + for (i = 0; i < subchan_cnt; ++i) + hv_vmbus_channel_close_internal(subchan[i]); + vmbus_rel_subchan(subchan, subchan_cnt); } - /* - * Then close the primary channel. - */ - hv_vmbus_channel_close_internal(channel); + + /* Then close the primary channel. */ + hv_vmbus_channel_close_internal(chan); } /** Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Oct 17 01:59:42 2016 (r307449) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Oct 17 02:02:44 2016 (r307450) @@ -134,8 +134,8 @@ vmbus_chan_add(struct hv_vmbus_channel * newchan->ch_id, newchan->ch_subidx); } - mtx_lock(&sc->vmbus_chlist_lock); - TAILQ_FOREACH(prichan, &sc->vmbus_chlist, ch_link) { + mtx_lock(&sc->vmbus_prichan_lock); + TAILQ_FOREACH(prichan, &sc->vmbus_prichans, ch_prilink) { if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type, sizeof(struct hyperv_guid)) == 0 && memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst, @@ -145,18 +145,19 @@ vmbus_chan_add(struct hv_vmbus_channel * if (VMBUS_CHAN_ISPRIMARY(newchan)) { if (prichan == NULL) { /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&sc->vmbus_chlist, newchan, ch_link); - mtx_unlock(&sc->vmbus_chlist_lock); + TAILQ_INSERT_TAIL(&sc->vmbus_prichans, newchan, + ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); return 0; } else { - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); device_printf(sc->vmbus_dev, "duplicated primary " "chan%u\n", newchan->ch_id); return EINVAL; } } else { /* Sub-channel */ if (prichan == NULL) { - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); device_printf(sc->vmbus_dev, "no primary chan for " "chan%u\n", newchan->ch_id); return EINVAL; @@ -168,7 +169,7 @@ vmbus_chan_add(struct hv_vmbus_channel * * XXX refcnt prichan */ } - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); /* * This is a sub-channel; link it with the primary channel. @@ -398,28 +399,28 @@ vmbus_channel_on_offers_delivered(struct vmbus_scan_done(sc); } -/** - * @brief Release channels that are unattached/unconnected (i.e., no drivers associated) +/* + * Detach all devices and destroy the corresponding primary channels. */ void -hv_vmbus_release_unattached_channels(struct vmbus_softc *sc) +vmbus_chan_destroy_all(struct vmbus_softc *sc) { - hv_vmbus_channel *channel; + struct hv_vmbus_channel *chan; - mtx_lock(&sc->vmbus_chlist_lock); + mtx_lock(&sc->vmbus_prichan_lock); + while ((chan = TAILQ_FIRST(&sc->vmbus_prichans)) != NULL) { + KASSERT(VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel")); + TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); - while (!TAILQ_EMPTY(&sc->vmbus_chlist)) { - channel = TAILQ_FIRST(&sc->vmbus_chlist); - KASSERT(VMBUS_CHAN_ISPRIMARY(channel), ("not primary channel")); - TAILQ_REMOVE(&sc->vmbus_chlist, channel, ch_link); + hv_vmbus_child_device_unregister(chan); + vmbus_chan_free(chan); - hv_vmbus_child_device_unregister(channel); - vmbus_chan_free(channel); + mtx_lock(&sc->vmbus_prichan_lock); } bzero(sc->vmbus_chmap, sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); - - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); } /** Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 01:59:42 2016 (r307449) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 02:02:44 2016 (r307450) @@ -146,9 +146,6 @@ void hv_ring_buffer_read_begin( uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -void hv_vmbus_release_unattached_channels( - struct vmbus_softc *); - int hv_vmbus_child_device_register( struct hv_vmbus_channel *chan); int hv_vmbus_child_device_unregister( Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 01:59:42 2016 (r307449) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 02:02:44 2016 (r307450) @@ -1104,8 +1104,8 @@ vmbus_doattach(struct vmbus_softc *sc) mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF); sc->vmbus_gpadl = VMBUS_GPADL_START; - mtx_init(&sc->vmbus_chlist_lock, "vmbus chlist", NULL, MTX_DEF); - TAILQ_INIT(&sc->vmbus_chlist); + mtx_init(&sc->vmbus_prichan_lock, "vmbus prichan", NULL, MTX_DEF); + TAILQ_INIT(&sc->vmbus_prichans); sc->vmbus_chmap = malloc( sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); @@ -1176,7 +1176,7 @@ cleanup: } free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); - mtx_destroy(&sc->vmbus_chlist_lock); + mtx_destroy(&sc->vmbus_prichan_lock); return (ret); } @@ -1239,7 +1239,7 @@ vmbus_detach(device_t dev) { struct vmbus_softc *sc = device_get_softc(dev); - hv_vmbus_release_unattached_channels(sc); + vmbus_chan_destroy_all(sc); vmbus_disconnect(sc); @@ -1258,7 +1258,7 @@ vmbus_detach(device_t dev) free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); - mtx_destroy(&sc->vmbus_chlist_lock); + mtx_destroy(&sc->vmbus_prichan_lock); return (0); } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 01:59:42 2016 (r307449) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 02:02:44 2016 (r307450) @@ -102,8 +102,9 @@ struct vmbus_softc { #define VMBUS_SCAN_CHCNT_DONE 0x80000000 uint32_t vmbus_scan_devcnt; - struct mtx vmbus_chlist_lock; - TAILQ_HEAD(, hv_vmbus_channel) vmbus_chlist; + /* Primary channels */ + struct mtx vmbus_prichan_lock; + TAILQ_HEAD(, hv_vmbus_channel) vmbus_prichans; }; #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ @@ -138,6 +139,7 @@ void vmbus_handle_intr(struct trapframe void vmbus_et_intr(struct trapframe *); void vmbus_chan_msgproc(struct vmbus_softc *, const struct vmbus_message *); +void vmbus_chan_destroy_all(struct vmbus_softc *); struct vmbus_msghc *vmbus_msghc_get(struct vmbus_softc *, size_t); void vmbus_msghc_put(struct vmbus_softc *, struct vmbus_msghc *); From owner-svn-src-stable@freebsd.org Mon Oct 17 02:12:51 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6925AC13224; Mon, 17 Oct 2016 02:12:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 313EB160D; Mon, 17 Oct 2016 02:12:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2CoZA088455; Mon, 17 Oct 2016 02:12:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2Cn14088447; Mon, 17 Oct 2016 02:12:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170212.u9H2Cn14088447@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:12:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307451 - in stable/11/sys: conf dev/hyperv/include dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:12:51 -0000 Author: sephe Date: Mon Oct 17 02:12:49 2016 New Revision: 307451 URL: https://svnweb.freebsd.org/changeset/base/307451 Log: MFC 302864 hyperv/vmbus: Merge hv_channel_mgmt.c into hv_channel.c Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7126 Deleted: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Modified: stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.i386 stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h stable/11/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Mon Oct 17 02:02:44 2016 (r307450) +++ stable/11/sys/conf/files.amd64 Mon Oct 17 02:12:49 2016 (r307451) @@ -302,7 +302,6 @@ dev/hyperv/utilities/hv_shutdown.c opt dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv -dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/11/sys/conf/files.i386 ============================================================================== --- stable/11/sys/conf/files.i386 Mon Oct 17 02:02:44 2016 (r307450) +++ stable/11/sys/conf/files.i386 Mon Oct 17 02:12:49 2016 (r307451) @@ -259,7 +259,6 @@ dev/hyperv/utilities/hv_shutdown.c opt dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv -dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:02:44 2016 (r307450) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:12:49 2016 (r307451) @@ -293,30 +293,17 @@ typedef struct hv_vmbus_channel { uint32_t target_cpu; /* - * Support for multi-channels. - * The initial offer is considered the primary channel and this - * offer message will indicate if the host supports multi-channels. - * The guest is free to ask for multi-channels to be offerred and can - * open these multi-channels as a normal "primary" channel. However, - * all multi-channels will have the same type and instance guids as the - * primary channel. Requests sent on a given channel will result in a - * response on the same channel. + * If this is a primary channel, ch_subchan* fields + * contain sub-channels belonging to this primary + * channel. */ - - struct mtx sc_lock; - - /* - * Link list of all the multi-channels if this is a primary channel - */ - TAILQ_HEAD(, hv_vmbus_channel) sc_list_anchor; - TAILQ_ENTRY(hv_vmbus_channel) sc_list_entry; - int subchan_cnt; - - /* - * The primary channel this sub-channle belongs to. - * This will be NULL for the primary channel. - */ - struct hv_vmbus_channel *primary_channel; + struct mtx ch_subchan_lock; + TAILQ_HEAD(, hv_vmbus_channel) ch_subchans; + int ch_subchan_cnt; + + /* If this is a sub-channel */ + TAILQ_ENTRY(hv_vmbus_channel) ch_sublink; /* sub-channel link */ + struct hv_vmbus_channel *ch_prichan; /* owner primary chan */ /* * Driver private data Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:02:44 2016 (r307450) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:12:49 2016 (r307451) @@ -53,8 +53,28 @@ __FBSDID("$FreeBSD$"); static void vmbus_chan_send_event(hv_vmbus_channel* channel); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); + static void vmbus_chan_task(void *, int); static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_detach_task(void *, int); + +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, + const struct vmbus_message *); + +/* + * Vmbus channel message processing. + */ +static const vmbus_chanmsg_proc_t +vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer), + VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), + + VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP) +}; /** * @brief Trigger an event notification on the specified channel @@ -100,7 +120,7 @@ vmbus_channel_sysctl_create(hv_vmbus_cha uint16_t sub_ch_id; char name[16]; - hv_vmbus_channel* primary_ch = channel->primary_channel; + hv_vmbus_channel* primary_ch = channel->ch_prichan; if (primary_ch == NULL) { dev = channel->ch_dev; @@ -563,7 +583,7 @@ hv_vmbus_channel_close(struct hv_vmbus_c /* * Close all sub-channels, if any. */ - subchan_cnt = chan->subchan_cnt; + subchan_cnt = chan->ch_subchan_cnt; if (subchan_cnt > 0) { struct hv_vmbus_channel **subchan; int i; @@ -984,3 +1004,463 @@ vmbus_chan_update_evtflagcnt(struct vmbu } } } + +static struct hv_vmbus_channel * +vmbus_chan_alloc(struct vmbus_softc *sc) +{ + struct hv_vmbus_channel *chan; + + chan = malloc(sizeof(*chan), M_DEVBUF, M_WAITOK | M_ZERO); + + chan->ch_monprm = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &chan->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (chan->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); + free(chan, M_DEVBUF); + return NULL; + } + + chan->vmbus_sc = sc; + mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); + TAILQ_INIT(&chan->ch_subchans); + TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + + return chan; +} + +static void +vmbus_chan_free(struct hv_vmbus_channel *chan) +{ + /* TODO: assert sub-channel list is empty */ + /* TODO: asset no longer on the primary channel's sub-channel list */ + /* TODO: asset no longer on the vmbus channel list */ + hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); + mtx_destroy(&chan->ch_subchan_lock); + free(chan, M_DEVBUF); +} + +static int +vmbus_chan_add(struct hv_vmbus_channel *newchan) +{ + struct vmbus_softc *sc = newchan->vmbus_sc; + struct hv_vmbus_channel *prichan; + + if (newchan->ch_id == 0) { + /* + * XXX + * Chan0 will neither be processed nor should be offered; + * skip it. + */ + device_printf(sc->vmbus_dev, "got chan0 offer, discard\n"); + return EINVAL; + } else if (newchan->ch_id >= VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid chan%u offer\n", + newchan->ch_id); + return EINVAL; + } + sc->vmbus_chmap[newchan->ch_id] = newchan; + + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u subidx%u offer\n", + newchan->ch_id, newchan->ch_subidx); + } + + mtx_lock(&sc->vmbus_prichan_lock); + TAILQ_FOREACH(prichan, &sc->vmbus_prichans, ch_prilink) { + /* + * Sub-channel will have the same type GUID and instance + * GUID as its primary channel. + */ + if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type, + sizeof(struct hyperv_guid)) == 0 && + memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst, + sizeof(struct hyperv_guid)) == 0) + break; + } + if (VMBUS_CHAN_ISPRIMARY(newchan)) { + if (prichan == NULL) { + /* Install the new primary channel */ + TAILQ_INSERT_TAIL(&sc->vmbus_prichans, newchan, + ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); + return 0; + } else { + mtx_unlock(&sc->vmbus_prichan_lock); + device_printf(sc->vmbus_dev, "duplicated primary " + "chan%u\n", newchan->ch_id); + return EINVAL; + } + } else { /* Sub-channel */ + if (prichan == NULL) { + mtx_unlock(&sc->vmbus_prichan_lock); + device_printf(sc->vmbus_dev, "no primary chan for " + "chan%u\n", newchan->ch_id); + return EINVAL; + } + /* + * Found the primary channel for this sub-channel and + * move on. + * + * XXX refcnt prichan + */ + } + mtx_unlock(&sc->vmbus_prichan_lock); + + /* + * This is a sub-channel; link it with the primary channel. + */ + KASSERT(!VMBUS_CHAN_ISPRIMARY(newchan), + ("new channel is not sub-channel")); + KASSERT(prichan != NULL, ("no primary channel")); + + newchan->ch_prichan = prichan; + newchan->ch_dev = prichan->ch_dev; + + mtx_lock(&prichan->ch_subchan_lock); + TAILQ_INSERT_TAIL(&prichan->ch_subchans, newchan, ch_sublink); + /* + * Bump up sub-channel count and notify anyone that is + * interested in this sub-channel, after this sub-channel + * is setup. + */ + prichan->ch_subchan_cnt++; + mtx_unlock(&prichan->ch_subchan_lock); + wakeup(prichan); + + return 0; +} + +void +vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu) +{ + KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); + + if (chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WS2008 || + chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WIN7) { + /* Only cpu0 is supported */ + cpu = 0; + } + + chan->target_cpu = cpu; + chan->target_vcpu = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); + + if (bootverbose) { + printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", + chan->ch_id, + chan->target_cpu, chan->target_vcpu); + } +} + +void +vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan) +{ + static uint32_t vmbus_chan_nextcpu; + int cpu; + + cpu = atomic_fetchadd_int(&vmbus_chan_nextcpu, 1) % mp_ncpus; + vmbus_channel_cpu_set(chan, cpu); +} + +static void +vmbus_chan_cpu_default(struct hv_vmbus_channel *chan) +{ + /* + * By default, pin the channel to cpu0. Devices having + * special channel-cpu mapping requirement should call + * vmbus_channel_cpu_{set,rr}(). + */ + vmbus_channel_cpu_set(chan, 0); +} + +static void +vmbus_chan_msgproc_choffer(struct vmbus_softc *sc, + const struct vmbus_message *msg) +{ + const struct vmbus_chanmsg_choffer *offer; + struct hv_vmbus_channel *chan; + int error; + + offer = (const struct vmbus_chanmsg_choffer *)msg->msg_data; + + chan = vmbus_chan_alloc(sc); + if (chan == NULL) { + device_printf(sc->vmbus_dev, "allocate chan%u failed\n", + offer->chm_chanid); + return; + } + + chan->ch_id = offer->chm_chanid; + chan->ch_subidx = offer->chm_subidx; + chan->ch_guid_type = offer->chm_chtype; + chan->ch_guid_inst = offer->chm_chinst; + + /* Batch reading is on by default */ + chan->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; + + chan->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; + if (sc->vmbus_version != VMBUS_VERSION_WS2008) + chan->ch_monprm->mp_connid = offer->chm_connid; + + if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) { + /* + * Setup MNF stuffs. + */ + chan->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + chan->ch_montrig_idx = offer->chm_montrig / VMBUS_MONTRIG_LEN; + if (chan->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) + panic("invalid monitor trigger %u", offer->chm_montrig); + chan->ch_montrig_mask = + 1 << (offer->chm_montrig % VMBUS_MONTRIG_LEN); + } + + /* Select default cpu for this channel. */ + vmbus_chan_cpu_default(chan); + + error = vmbus_chan_add(chan); + if (error) { + device_printf(sc->vmbus_dev, "add chan%u failed: %d\n", + chan->ch_id, error); + vmbus_chan_free(chan); + return; + } + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Add device for this primary channel. + * + * NOTE: + * Error is ignored here; don't have much to do if error + * really happens. + */ + hv_vmbus_child_device_register(chan); + } +} + +/* + * XXX pretty broken; need rework. + */ +static void +vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc, + const struct vmbus_message *msg) +{ + const struct vmbus_chanmsg_chrescind *note; + struct hv_vmbus_channel *chan; + + note = (const struct vmbus_chanmsg_chrescind *)msg->msg_data; + if (note->chm_chanid > VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid rescinded chan%u\n", + note->chm_chanid); + return; + } + + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u rescinded\n", + note->chm_chanid); + } + + chan = sc->vmbus_chmap[note->chm_chanid]; + if (chan == NULL) + return; + sc->vmbus_chmap[note->chm_chanid] = NULL; + + taskqueue_enqueue(taskqueue_thread, &chan->ch_detach_task); +} + +static void +vmbus_chan_detach_task(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* Only primary channel owns the device */ + hv_vmbus_child_device_unregister(chan); + /* NOTE: DO NOT free primary channel for now */ + } else { + struct vmbus_softc *sc = chan->vmbus_sc; + struct hv_vmbus_channel *pri_chan = chan->ch_prichan; + struct vmbus_chanmsg_chfree *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chfree(chan%u)\n", + chan->ch_id); + goto remove; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; + req->chm_chanid = chan->ch_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chfree(chan%u) failed: %d", + chan->ch_id, error); + /* NOTE: Move on! */ + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u freed\n", + chan->ch_id); + } + } +remove: + mtx_lock(&pri_chan->ch_subchan_lock); + TAILQ_REMOVE(&pri_chan->ch_subchans, chan, ch_sublink); + KASSERT(pri_chan->ch_subchan_cnt > 0, + ("invalid subchan_cnt %d", pri_chan->ch_subchan_cnt)); + pri_chan->ch_subchan_cnt--; + mtx_unlock(&pri_chan->ch_subchan_lock); + wakeup(pri_chan); + + vmbus_chan_free(chan); + } +} + +/* + * Detach all devices and destroy the corresponding primary channels. + */ +void +vmbus_chan_destroy_all(struct vmbus_softc *sc) +{ + struct hv_vmbus_channel *chan; + + mtx_lock(&sc->vmbus_prichan_lock); + while ((chan = TAILQ_FIRST(&sc->vmbus_prichans)) != NULL) { + KASSERT(VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel")); + TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); + + hv_vmbus_child_device_unregister(chan); + vmbus_chan_free(chan); + + mtx_lock(&sc->vmbus_prichan_lock); + } + bzero(sc->vmbus_chmap, + sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); + mtx_unlock(&sc->vmbus_prichan_lock); +} + +/** + * @brief Select the best outgoing channel + * + * The channel whose vcpu binding is closest to the currect vcpu will + * be selected. + * If no multi-channel, always select primary channel + * + * @param primary - primary channel + */ +struct hv_vmbus_channel * +vmbus_select_outgoing_channel(struct hv_vmbus_channel *primary) +{ + hv_vmbus_channel *new_channel = NULL; + hv_vmbus_channel *outgoing_channel = primary; + int old_cpu_distance = 0; + int new_cpu_distance = 0; + int cur_vcpu = 0; + int smp_pro_id = PCPU_GET(cpuid); + + if (TAILQ_EMPTY(&primary->ch_subchans)) { + return outgoing_channel; + } + + if (smp_pro_id >= MAXCPU) { + return outgoing_channel; + } + + cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); + + /* XXX need lock */ + TAILQ_FOREACH(new_channel, &primary->ch_subchans, ch_sublink) { + if ((new_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) { + continue; + } + + if (new_channel->target_vcpu == cur_vcpu){ + return new_channel; + } + + old_cpu_distance = ((outgoing_channel->target_vcpu > cur_vcpu) ? + (outgoing_channel->target_vcpu - cur_vcpu) : + (cur_vcpu - outgoing_channel->target_vcpu)); + + new_cpu_distance = ((new_channel->target_vcpu > cur_vcpu) ? + (new_channel->target_vcpu - cur_vcpu) : + (cur_vcpu - new_channel->target_vcpu)); + + if (old_cpu_distance < new_cpu_distance) { + continue; + } + + outgoing_channel = new_channel; + } + + return(outgoing_channel); +} + +struct hv_vmbus_channel ** +vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt) +{ + struct hv_vmbus_channel **ret, *chan; + int i; + + ret = malloc(subchan_cnt * sizeof(struct hv_vmbus_channel *), M_TEMP, + M_WAITOK); + + mtx_lock(&pri_chan->ch_subchan_lock); + + while (pri_chan->ch_subchan_cnt < subchan_cnt) + mtx_sleep(pri_chan, &pri_chan->ch_subchan_lock, 0, "subch", 0); + + i = 0; + TAILQ_FOREACH(chan, &pri_chan->ch_subchans, ch_sublink) { + /* TODO: refcnt chan */ + ret[i] = chan; + + ++i; + if (i == subchan_cnt) + break; + } + KASSERT(i == subchan_cnt, ("invalid subchan count %d, should be %d", + pri_chan->ch_subchan_cnt, subchan_cnt)); + + mtx_unlock(&pri_chan->ch_subchan_lock); + + return ret; +} + +void +vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt __unused) +{ + + free(subchan, M_TEMP); +} + +void +vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan) +{ + mtx_lock(&pri_chan->ch_subchan_lock); + while (pri_chan->ch_subchan_cnt > 0) + mtx_sleep(pri_chan, &pri_chan->ch_subchan_lock, 0, "dsubch", 0); + mtx_unlock(&pri_chan->ch_subchan_lock); +} + +void +vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) +{ + vmbus_chanmsg_proc_t msg_proc; + uint32_t msg_type; + + msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; + KASSERT(msg_type < VMBUS_CHANMSG_TYPE_MAX, + ("invalid message type %u", msg_type)); + + msg_proc = vmbus_chan_msgprocs[msg_type]; + if (msg_proc != NULL) + msg_proc(sc, msg); +} Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 02:02:44 2016 (r307450) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 02:12:49 2016 (r307451) @@ -98,7 +98,12 @@ static int vmbus_req_channels(struct v static void vmbus_disconnect(struct vmbus_softc *); static int vmbus_scan(struct vmbus_softc *); static void vmbus_scan_wait(struct vmbus_softc *); +static void vmbus_scan_newchan(struct vmbus_softc *); static void vmbus_scan_newdev(struct vmbus_softc *); +static void vmbus_scan_done(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chanmsg_handle(struct vmbus_softc *, + const struct vmbus_message *); static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); @@ -122,6 +127,12 @@ static const uint32_t vmbus_version[] = VMBUS_VERSION_WS2008 }; +static const vmbus_chanmsg_proc_t +vmbus_chanmsg_handlers[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER_DONE, vmbus_scan_done), + VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP) +}; + static struct vmbus_msghc * vmbus_msghc_alloc(bus_dma_tag_t parent_dtag) { @@ -480,7 +491,7 @@ vmbus_req_channels(struct vmbus_softc *s return error; } -void +static void vmbus_scan_newchan(struct vmbus_softc *sc) { mtx_lock(&sc->vmbus_scan_lock); @@ -489,8 +500,9 @@ vmbus_scan_newchan(struct vmbus_softc *s mtx_unlock(&sc->vmbus_scan_lock); } -void -vmbus_scan_done(struct vmbus_softc *sc) +static void +vmbus_scan_done(struct vmbus_softc *sc, + const struct vmbus_message *msg __unused) { mtx_lock(&sc->vmbus_scan_lock); sc->vmbus_scan_chcnt |= VMBUS_SCAN_CHCNT_DONE; @@ -560,6 +572,27 @@ vmbus_scan(struct vmbus_softc *sc) } static void +vmbus_chanmsg_handle(struct vmbus_softc *sc, const struct vmbus_message *msg) +{ + vmbus_chanmsg_proc_t msg_proc; + uint32_t msg_type; + + msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; + if (msg_type >= VMBUS_CHANMSG_TYPE_MAX) { + device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", + msg_type); + return; + } + + msg_proc = vmbus_chanmsg_handlers[msg_type]; + if (msg_proc != NULL) + msg_proc(sc, msg); + + /* Channel specific processing */ + vmbus_chan_msgproc(sc, msg); +} + +static void vmbus_msg_task(void *xsc, int pending __unused) { struct vmbus_softc *sc = xsc; @@ -572,7 +605,7 @@ vmbus_msg_task(void *xsc, int pending __ break; } else if (msg->msg_type == HYPERV_MSGTYPE_CHANNEL) { /* Channel message */ - vmbus_chan_msgproc(sc, + vmbus_chanmsg_handle(sc, __DEVOLATILE(const struct vmbus_message *, msg)); } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 02:02:44 2016 (r307450) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 02:12:49 2016 (r307451) @@ -52,6 +52,17 @@ #define VMBUS_CONNID_MESSAGE 1 #define VMBUS_CONNID_EVENT 2 +struct vmbus_message; +struct vmbus_softc; + +typedef void (*vmbus_chanmsg_proc_t)(struct vmbus_softc *, + const struct vmbus_message *); + +#define VMBUS_CHANMSG_PROC(name, func) \ + [VMBUS_CHANMSG_TYPE_##name] = func +#define VMBUS_CHANMSG_PROC_WAKEUP(name) \ + VMBUS_CHANMSG_PROC(name, vmbus_msghc_wakeup) + struct vmbus_pcpu_data { u_long *intr_cnt; /* Hyper-V interrupt counter */ struct vmbus_message *message; /* shared messages */ @@ -151,9 +162,6 @@ const struct vmbus_message *vmbus_msghc_ void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); void vmbus_msghc_reset(struct vmbus_msghc *, size_t); -void vmbus_scan_done(struct vmbus_softc *); -void vmbus_scan_newchan(struct vmbus_softc *); - uint32_t vmbus_gpadl_alloc(struct vmbus_softc *); #endif /* !_VMBUS_VAR_H_ */ Modified: stable/11/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/11/sys/modules/hyperv/vmbus/Makefile Mon Oct 17 02:02:44 2016 (r307450) +++ stable/11/sys/modules/hyperv/vmbus/Makefile Mon Oct 17 02:12:49 2016 (r307451) @@ -5,7 +5,6 @@ KMOD= hv_vmbus SRCS= hv_channel.c \ - hv_channel_mgmt.c \ hv_ring_buffer.c \ hyperv.c \ hyperv_busdma.c \ From owner-svn-src-stable@freebsd.org Mon Oct 17 02:19:56 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF4FFC1348B; Mon, 17 Oct 2016 02:19:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 821F01989; Mon, 17 Oct 2016 02:19:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2JtV8088889; Mon, 17 Oct 2016 02:19:55 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2JtW5088884; Mon, 17 Oct 2016 02:19:55 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170219.u9H2JtW5088884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:19:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307452 - stable/11/sys/dev/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:19:56 -0000 Author: sephe Date: Mon Oct 17 02:19:55 2016 New Revision: 307452 URL: https://svnweb.freebsd.org/changeset/base/307452 Log: MFC 302867-302870 302867 hyperv/vmbus: Remove unused struct Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7127 302868 hyperv/vmbus: Function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7129 302869 hyperv/vmbus: Remove unused function definition/declaration. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7131 302870 hyperv/vmbus: Use iovec for bufring scatter/gather list. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7134 Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:12:49 2016 (r307451) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:19:55 2016 (r307452) @@ -616,7 +616,7 @@ hv_vmbus_channel_send_packet( uint64_t aligned_data; uint32_t packet_len_aligned; boolean_t need_sig; - hv_vmbus_sg_buffer_list buffer_list[3]; + struct iovec iov[3]; packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len; packet_len_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); @@ -630,17 +630,16 @@ hv_vmbus_channel_send_packet( desc.length8 = (uint16_t) (packet_len_aligned >> 3); desc.transaction_id = request_id; - buffer_list[0].data = &desc; - buffer_list[0].length = sizeof(hv_vm_packet_descriptor); + iov[0].iov_base = &desc; + iov[0].iov_len = sizeof(hv_vm_packet_descriptor); - buffer_list[1].data = buffer; - buffer_list[1].length = buffer_len; + iov[1].iov_base = buffer; + iov[1].iov_len = buffer_len; - buffer_list[2].data = &aligned_data; - buffer_list[2].length = packet_len_aligned - packet_len; + iov[2].iov_base = &aligned_data; + iov[2].iov_len = packet_len_aligned - packet_len; - ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3, - &need_sig); + ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig); /* TODO: We should determine if this is optional */ if (ret == 0 && need_sig) @@ -668,7 +667,7 @@ hv_vmbus_channel_send_packet_pagebuffer( uint32_t packet_len; uint32_t page_buflen; uint32_t packetLen_aligned; - hv_vmbus_sg_buffer_list buffer_list[4]; + struct iovec iov[4]; hv_vmbus_channel_packet_page_buffer desc; uint32_t descSize; uint64_t alignedData = 0; @@ -694,20 +693,19 @@ hv_vmbus_channel_send_packet_pagebuffer( desc.transaction_id = request_id; desc.range_count = page_count; - buffer_list[0].data = &desc; - buffer_list[0].length = descSize; + iov[0].iov_base = &desc; + iov[0].iov_len = descSize; - buffer_list[1].data = page_buffers; - buffer_list[1].length = page_buflen; + iov[1].iov_base = page_buffers; + iov[1].iov_len = page_buflen; - buffer_list[2].data = buffer; - buffer_list[2].length = buffer_len; + iov[2].iov_base = buffer; + iov[2].iov_len = buffer_len; - buffer_list[3].data = &alignedData; - buffer_list[3].length = packetLen_aligned - packet_len; + iov[3].iov_base = &alignedData; + iov[3].iov_len = packetLen_aligned - packet_len; - ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 4, - &need_sig); + ret = hv_ring_buffer_write(&channel->outbound, iov, 4, &need_sig); /* TODO: We should determine if this is optional */ if (ret == 0 && need_sig) @@ -735,7 +733,7 @@ hv_vmbus_channel_send_packet_multipagebu uint32_t packet_len_aligned; uint32_t pfn_count; uint64_t aligned_data = 0; - hv_vmbus_sg_buffer_list buffer_list[3]; + struct iovec iov[3]; hv_vmbus_channel_packet_multipage_buffer desc; pfn_count = @@ -772,17 +770,16 @@ hv_vmbus_channel_send_packet_multipagebu memcpy(desc.range.pfn_array, multi_page_buffer->pfn_array, pfn_count * sizeof(uint64_t)); - buffer_list[0].data = &desc; - buffer_list[0].length = desc_size; + iov[0].iov_base = &desc; + iov[0].iov_len = desc_size; - buffer_list[1].data = buffer; - buffer_list[1].length = buffer_len; + iov[1].iov_base = buffer; + iov[1].iov_len = buffer_len; - buffer_list[2].data = &aligned_data; - buffer_list[2].length = packet_len_aligned - packet_len; + iov[2].iov_base = &aligned_data; + iov[2].iov_len = packet_len_aligned - packet_len; - ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3, - &need_sig); + ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig); /* TODO: We should determine if this is optional */ if (ret == 0 && need_sig) @@ -1233,7 +1230,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_ * Error is ignored here; don't have much to do if error * really happens. */ - hv_vmbus_child_device_register(chan); + vmbus_add_child(chan); } } @@ -1274,7 +1271,7 @@ vmbus_chan_detach_task(void *xchan, int if (VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the device */ - hv_vmbus_child_device_unregister(chan); + vmbus_delete_child(chan); /* NOTE: DO NOT free primary channel for now */ } else { struct vmbus_softc *sc = chan->vmbus_sc; @@ -1336,7 +1333,7 @@ vmbus_chan_destroy_all(struct vmbus_soft TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); mtx_unlock(&sc->vmbus_prichan_lock); - hv_vmbus_child_device_unregister(chan); + vmbus_delete_child(chan); vmbus_chan_free(chan); mtx_lock(&sc->vmbus_prichan_lock); Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 02:12:49 2016 (r307451) +++ stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 02:19:55 2016 (r307452) @@ -252,7 +252,7 @@ hv_ring_buffer_needsig_on_write( static uint32_t copy_to_ring_buffer( hv_vmbus_ring_buffer_info* ring_info, uint32_t start_write_offset, - char* src, + const uint8_t *src, uint32_t src_len); static uint32_t copy_from_ring_buffer( @@ -261,16 +261,6 @@ static uint32_t copy_from_ring_buffer( uint32_t dest_len, uint32_t start_read_offset); - -/** - * @brief Get the interrupt mask for the specified ring buffer. - */ -uint32_t -hv_vmbus_get_ring_buffer_interrupt_mask(hv_vmbus_ring_buffer_info *rbi) -{ - return rbi->ring_buffer->interrupt_mask; -} - /** * @brief Initialize the ring buffer. */ @@ -307,8 +297,8 @@ void hv_ring_buffer_cleanup(hv_vmbus_rin int hv_ring_buffer_write( hv_vmbus_ring_buffer_info* out_ring_info, - hv_vmbus_sg_buffer_list sg_buffers[], - uint32_t sg_buffer_count, + const struct iovec iov[], + uint32_t iovlen, boolean_t *need_sig) { int i = 0; @@ -320,8 +310,8 @@ hv_ring_buffer_write( volatile uint32_t next_write_location; uint64_t prev_indices = 0; - for (i = 0; i < sg_buffer_count; i++) { - total_bytes_to_write += sg_buffers[i].length; + for (i = 0; i < iovlen; i++) { + total_bytes_to_write += iov[i].iov_len; } total_bytes_to_write += sizeof(uint64_t); @@ -350,10 +340,9 @@ hv_ring_buffer_write( old_write_location = next_write_location; - for (i = 0; i < sg_buffer_count; i++) { + for (i = 0; i < iovlen; i++) { next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, (char *) sg_buffers[i].data, - sg_buffers[i].length); + next_write_location, iov[i].iov_base, iov[i].iov_len); } /* @@ -492,11 +481,11 @@ hv_ring_buffer_read( * * Assume there is enough room. Handles wrap-around in dest case only! */ -uint32_t +static uint32_t copy_to_ring_buffer( hv_vmbus_ring_buffer_info* ring_info, uint32_t start_write_offset, - char* src, + const uint8_t *src, uint32_t src_len) { char *ring_buffer = get_ring_buffer(ring_info); Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 02:12:49 2016 (r307451) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 02:19:55 2016 (r307452) @@ -35,39 +35,12 @@ #include #include #include +#include #include struct vmbus_softc; -typedef struct { - void* data; - uint32_t length; -} hv_vmbus_sg_buffer_list; - -typedef struct { - uint32_t current_interrupt_mask; - uint32_t current_read_index; - uint32_t current_write_index; - uint32_t bytes_avail_to_read; - uint32_t bytes_avail_to_write; -} hv_vmbus_ring_buffer_debug_info; - -typedef struct { - uint32_t rel_id; - struct hyperv_guid interface_type; - struct hyperv_guid interface_instance; - uint32_t monitor_id; - uint32_t server_monitor_pending; - uint32_t server_monitor_latency; - uint32_t server_monitor_connection_id; - uint32_t client_monitor_pending; - uint32_t client_monitor_latency; - uint32_t client_monitor_connection_id; - hv_vmbus_ring_buffer_debug_info inbound; - hv_vmbus_ring_buffer_debug_info outbound; -} hv_vmbus_channel_debug_info; - /* * The format must be the same as hv_vm_data_gpa_direct */ @@ -118,8 +91,8 @@ void hv_ring_buffer_cleanup( int hv_ring_buffer_write( hv_vmbus_ring_buffer_info *ring_info, - hv_vmbus_sg_buffer_list sg_buffers[], - uint32_t sg_buff_count, + const struct iovec iov[], + uint32_t iovlen, boolean_t *need_sig); int hv_ring_buffer_peek( @@ -133,22 +106,10 @@ int hv_ring_buffer_read( uint32_t buffer_len, uint32_t offset); -uint32_t hv_vmbus_get_ring_buffer_interrupt_mask( - hv_vmbus_ring_buffer_info *ring_info); - -void hv_vmbus_dump_ring_info( - hv_vmbus_ring_buffer_info *ring_info, - char *prefix); - void hv_ring_buffer_read_begin( hv_vmbus_ring_buffer_info *ring_info); uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -int hv_vmbus_child_device_register( - struct hv_vmbus_channel *chan); -int hv_vmbus_child_device_unregister( - struct hv_vmbus_channel *chan); - #endif /* __HYPERV_PRIV_H__ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 02:12:49 2016 (r307451) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 02:19:55 2016 (r307452) @@ -1021,7 +1021,7 @@ vmbus_child_pnpinfo_str(device_t dev, de } int -hv_vmbus_child_device_register(struct hv_vmbus_channel *chan) +vmbus_add_child(struct hv_vmbus_channel *chan) { struct vmbus_softc *sc = chan->vmbus_sc; device_t parent = sc->vmbus_dev; @@ -1046,7 +1046,7 @@ done: } int -hv_vmbus_child_device_unregister(struct hv_vmbus_channel *chan) +vmbus_delete_child(struct hv_vmbus_channel *chan) { int error; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 02:12:49 2016 (r307451) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 02:19:55 2016 (r307452) @@ -146,6 +146,8 @@ struct vmbus_msghc; void vmbus_event_proc(struct vmbus_softc *, int); void vmbus_event_proc_compat(struct vmbus_softc *, int); void vmbus_handle_intr(struct trapframe *); +int vmbus_add_child(struct hv_vmbus_channel *); +int vmbus_delete_child(struct hv_vmbus_channel *); void vmbus_et_intr(struct trapframe *); From owner-svn-src-stable@freebsd.org Mon Oct 17 02:23:06 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D24D1C13759; Mon, 17 Oct 2016 02:23:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AEAF81D54; Mon, 17 Oct 2016 02:23:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2N5Zq092486; Mon, 17 Oct 2016 02:23:05 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2N5TW092484; Mon, 17 Oct 2016 02:23:05 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170223.u9H2N5TW092484@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:23:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307453 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:23:06 -0000 Author: sephe Date: Mon Oct 17 02:23:05 2016 New Revision: 307453 URL: https://svnweb.freebsd.org/changeset/base/307453 Log: MFC 302871,302872 302871 hyperv/vmbus: Add vmbus_chan_gpadl_connect, which takes GPA physaddr Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7139 302872 hyperv/vmbus: Busdma-fy channel bufring. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7140 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:19:55 2016 (r307452) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:23:05 2016 (r307453) @@ -257,13 +257,6 @@ typedef struct hv_vmbus_channel { int ch_montrig_idx; /* MNF trig index */ uint32_t ch_montrig_mask;/* MNF trig mask */ - uint32_t ring_buffer_gpadl_handle; - /* - * Allocated memory for ring buffer - */ - void* ring_buffer_pages; - unsigned long ring_buffer_size; - uint32_t ring_buffer_page_count; /* * send to parent */ @@ -312,6 +305,10 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv2; void *hv_chan_priv3; + void *ch_bufring; /* TX+RX bufrings */ + struct hyperv_dma ch_bufring_dma; + uint32_t ch_bufring_gpadl; + struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_prilink; /* primary chan link */ uint32_t ch_subidx; /* subchan index */ @@ -409,6 +406,9 @@ int hv_vmbus_channel_teardown_gpdal( hv_vmbus_channel* channel, uint32_t gpadl_handle); +int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, + bus_addr_t paddr, int size, uint32_t *gpadl); + struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu); Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:19:55 2016 (r307452) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:23:05 2016 (r307453) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -202,7 +203,7 @@ hv_vmbus_channel_open( struct vmbus_msghc *mh; uint32_t status; int ret = 0; - void *in, *out; + uint8_t *br; if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { device_printf(sc->vmbus_dev, @@ -210,6 +211,10 @@ hv_vmbus_channel_open( user_data_len, new_channel->ch_id); return EINVAL; } + KASSERT((send_ring_buffer_size & PAGE_MASK) == 0, + ("send bufring size is not multiple page")); + KASSERT((recv_ring_buffer_size & PAGE_MASK) == 0, + ("recv bufring size is not multiple page")); if (atomic_testandset_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED_SHIFT)) @@ -230,46 +235,43 @@ hv_vmbus_channel_open( vmbus_chan_task_nobatch, new_channel); } - /* Allocate the ring buffer */ - out = contigmalloc((send_ring_buffer_size + recv_ring_buffer_size), - M_DEVBUF, M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); - KASSERT(out != NULL, - ("Error VMBUS: contigmalloc failed to allocate Ring Buffer!")); - if (out == NULL) { + /* + * Allocate the TX+RX bufrings. + * XXX should use ch_dev dtag + */ + br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + PAGE_SIZE, 0, send_ring_buffer_size + recv_ring_buffer_size, + &new_channel->ch_bufring_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (br == NULL) { + device_printf(sc->vmbus_dev, "bufring allocation failed\n"); ret = ENOMEM; goto failed; } + new_channel->ch_bufring = br; - in = ((uint8_t *) out + send_ring_buffer_size); - - new_channel->ring_buffer_pages = out; - new_channel->ring_buffer_page_count = (send_ring_buffer_size + - recv_ring_buffer_size) >> PAGE_SHIFT; - new_channel->ring_buffer_size = send_ring_buffer_size + - recv_ring_buffer_size; - - hv_vmbus_ring_buffer_init( - &new_channel->outbound, - out, - send_ring_buffer_size); - - hv_vmbus_ring_buffer_init( - &new_channel->inbound, - in, - recv_ring_buffer_size); + /* TX bufring comes first */ + hv_vmbus_ring_buffer_init(&new_channel->outbound, + br, send_ring_buffer_size); + /* RX bufring immediately follows TX bufring */ + hv_vmbus_ring_buffer_init(&new_channel->inbound, + br + send_ring_buffer_size, recv_ring_buffer_size); /* Create sysctl tree for this channel */ vmbus_channel_sysctl_create(new_channel); - /** - * Establish the gpadl for the ring buffer + /* + * Connect the bufrings, both RX and TX, to this channel. */ - new_channel->ring_buffer_gpadl_handle = 0; - - ret = hv_vmbus_channel_establish_gpadl(new_channel, - new_channel->outbound.ring_buffer, + ret = vmbus_chan_gpadl_connect(new_channel, + new_channel->ch_bufring_dma.hv_paddr, send_ring_buffer_size + recv_ring_buffer_size, - &new_channel->ring_buffer_gpadl_handle); + &new_channel->ch_bufring_gpadl); + if (ret != 0) { + device_printf(sc->vmbus_dev, + "failed to connect bufring GPADL to chan%u\n", + new_channel->ch_id); + goto failed; + } /* * Open channel w/ the bufring GPADL on the target CPU. @@ -287,7 +289,7 @@ hv_vmbus_channel_open( req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; req->chm_chanid = new_channel->ch_id; req->chm_openid = new_channel->ch_id; - req->chm_gpadl = new_channel->ring_buffer_gpadl_handle; + req->chm_gpadl = new_channel->ch_bufring_gpadl; req->chm_vcpuid = new_channel->target_vcpu; req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; if (user_data_len) @@ -321,6 +323,16 @@ hv_vmbus_channel_open( ret = ENXIO; failed: + if (new_channel->ch_bufring_gpadl) { + hv_vmbus_channel_teardown_gpdal(new_channel, + new_channel->ch_bufring_gpadl); + new_channel->ch_bufring_gpadl = 0; + } + if (new_channel->ch_bufring != NULL) { + hyperv_dmamem_free(&new_channel->ch_bufring_dma, + new_channel->ch_bufring); + new_channel->ch_bufring = NULL; + } atomic_clear_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED); return ret; } @@ -330,26 +342,33 @@ failed: */ int hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel, - void *contig_buffer, uint32_t size, uint32_t *gpadl0) + void *contig_buffer, uint32_t size, uint32_t *gpadl) { - struct vmbus_softc *sc = channel->vmbus_sc; + return vmbus_chan_gpadl_connect(channel, + hv_get_phys_addr(contig_buffer), size, gpadl); +} + +int +vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr, + int size, uint32_t *gpadl0) +{ + struct vmbus_softc *sc = chan->vmbus_sc; struct vmbus_msghc *mh; struct vmbus_chanmsg_gpadl_conn *req; const struct vmbus_message *msg; size_t reqsz; uint32_t gpadl, status; int page_count, range_len, i, cnt, error; - uint64_t page_id, paddr; + uint64_t page_id; /* * Preliminary checks. */ KASSERT((size & PAGE_MASK) == 0, - ("invalid GPA size %u, not multiple page size", size)); + ("invalid GPA size %d, not multiple page size", size)); page_count = size >> PAGE_SHIFT; - paddr = hv_get_phys_addr(contig_buffer); KASSERT((paddr & PAGE_MASK) == 0, ("GPA is not page aligned %jx", (uintmax_t)paddr)); page_id = paddr >> PAGE_SHIFT; @@ -390,13 +409,13 @@ hv_vmbus_channel_establish_gpadl(struct if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for gpadl->chan%u\n", - channel->ch_id); + chan->ch_id); return EIO; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; - req->chm_chanid = channel->ch_id; + req->chm_chanid = chan->ch_id; req->chm_gpadl = gpadl; req->chm_range_len = range_len; req->chm_range_cnt = 1; @@ -409,7 +428,7 @@ hv_vmbus_channel_establish_gpadl(struct if (error) { device_printf(sc->vmbus_dev, "gpadl->chan%u msg hypercall exec failed: %d\n", - channel->ch_id, error); + chan->ch_id, error); vmbus_msghc_put(sc, mh); return error; } @@ -445,12 +464,12 @@ hv_vmbus_channel_establish_gpadl(struct if (status != 0) { device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " - "status %u\n", channel->ch_id, status); + "status %u\n", chan->ch_id, status); return EIO; } else { if (bootverbose) { device_printf(sc->vmbus_dev, "gpadl->chan%u " - "succeeded\n", channel->ch_id); + "succeeded\n", chan->ch_id); } } return 0; @@ -547,9 +566,10 @@ hv_vmbus_channel_close_internal(hv_vmbus } /* Tear down the gpadl for the channel's ring buffer */ - if (channel->ring_buffer_gpadl_handle) { + if (channel->ch_bufring_gpadl) { hv_vmbus_channel_teardown_gpdal(channel, - channel->ring_buffer_gpadl_handle); + channel->ch_bufring_gpadl); + channel->ch_bufring_gpadl = 0; } /* TODO: Send a msg to release the childRelId */ @@ -558,8 +578,11 @@ hv_vmbus_channel_close_internal(hv_vmbus hv_ring_buffer_cleanup(&channel->outbound); hv_ring_buffer_cleanup(&channel->inbound); - contigfree(channel->ring_buffer_pages, channel->ring_buffer_size, - M_DEVBUF); + if (channel->ch_bufring != NULL) { + hyperv_dmamem_free(&channel->ch_bufring_dma, + channel->ch_bufring); + channel->ch_bufring = NULL; + } } /* From owner-svn-src-stable@freebsd.org Mon Oct 17 02:25:44 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A2B9FC137D7; Mon, 17 Oct 2016 02:25:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6303D1EE1; Mon, 17 Oct 2016 02:25:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2PhWT092630; Mon, 17 Oct 2016 02:25:43 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2PhvA092627; Mon, 17 Oct 2016 02:25:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170225.u9H2PhvA092627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:25:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307454 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:25:44 -0000 Author: sephe Date: Mon Oct 17 02:25:43 2016 New Revision: 307454 URL: https://svnweb.freebsd.org/changeset/base/307454 Log: MFC 302873,302874 302873 hyperv/vmbus: Set vcpuid to 0, if MSR_HV_VP_INDEX does not exist. Mainly for compatibility. While I'm here, rename cpuid related fields in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7141 302874 hyperv/vmbus: Field rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7146 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/vmbus.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:23:05 2016 (r307453) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:25:43 2016 (r307454) @@ -242,7 +242,7 @@ typedef struct { uint32_t ring_data_size; /* ring_size */ } hv_vmbus_ring_buffer_info; -typedef void (*hv_vmbus_pfn_channel_callback)(void *context); +typedef void (*vmbus_chan_callback_t)(void *); typedef struct hv_vmbus_channel { device_t ch_dev; @@ -266,24 +266,21 @@ typedef struct hv_vmbus_channel { */ hv_vmbus_ring_buffer_info inbound; - struct taskqueue * rxq; - struct task channel_task; - hv_vmbus_pfn_channel_callback on_channel_callback; - void* channel_callback_context; + struct taskqueue *ch_tq; + struct task ch_task; + vmbus_chan_callback_t ch_cb; + void *ch_cbarg; struct hyperv_mon_param *ch_monprm; struct hyperv_dma ch_monprm_dma; + int ch_cpuid; /* owner cpu */ /* - * From Win8, this field specifies the target virtual process - * on which to deliver the interrupt from the host to guest. - * Before Win8, all channel interrupts would only be - * delivered on cpu 0. Setting this value to 0 would preserve - * the earlier behavior. - */ - uint32_t target_vcpu; - /* The corresponding CPUID in the guest */ - uint32_t target_cpu; + * Virtual cpuid for ch_cpuid; it is used to communicate cpuid + * related information w/ Hyper-V. If MSR_HV_VP_INDEX does not + * exist, ch_vcpuid will always be 0 for compatibility. + */ + uint32_t ch_vcpuid; /* * If this is a primary channel, ch_subchan* fields @@ -365,9 +362,8 @@ int hv_vmbus_channel_open( uint32_t recv_ring_buffer_size, void* user_data, uint32_t user_data_len, - hv_vmbus_pfn_channel_callback - pfn_on_channel_callback, - void* context); + vmbus_chan_callback_t cb, + void *cbarg); void hv_vmbus_channel_close(hv_vmbus_channel *channel); Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:23:05 2016 (r307453) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:25:43 2016 (r307454) @@ -157,7 +157,7 @@ vmbus_channel_sysctl_create(hv_vmbus_cha &channel->ch_id, 0, "channel id"); } SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, - "cpu", CTLFLAG_RD, &channel->target_cpu, 0, "owner CPU id"); + "cpu", CTLFLAG_RD, &channel->ch_cpuid, 0, "owner CPU id"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, channel, 0, vmbus_channel_sysctl_monalloc, "I", @@ -193,8 +193,8 @@ hv_vmbus_channel_open( uint32_t recv_ring_buffer_size, void* user_data, uint32_t user_data_len, - hv_vmbus_pfn_channel_callback pfn_on_channel_callback, - void* context) + vmbus_chan_callback_t cb, + void *cbarg) { struct vmbus_softc *sc = new_channel->vmbus_sc; const struct vmbus_chanmsg_chopen_resp *resp; @@ -220,19 +220,19 @@ hv_vmbus_channel_open( VMBUS_CHAN_ST_OPENED_SHIFT)) panic("double-open chan%u", new_channel->ch_id); - new_channel->on_channel_callback = pfn_on_channel_callback; - new_channel->channel_callback_context = context; + new_channel->ch_cb = cb; + new_channel->ch_cbarg = cbarg; vmbus_chan_update_evtflagcnt(sc, new_channel); - new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, - new_channel->target_cpu); + new_channel->ch_tq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, + new_channel->ch_cpuid); if (new_channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) { - TASK_INIT(&new_channel->channel_task, 0, - vmbus_chan_task, new_channel); + TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task, + new_channel); } else { - TASK_INIT(&new_channel->channel_task, 0, - vmbus_chan_task_nobatch, new_channel); + TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task_nobatch, + new_channel); } /* @@ -290,7 +290,7 @@ hv_vmbus_channel_open( req->chm_chanid = new_channel->ch_id; req->chm_openid = new_channel->ch_id; req->chm_gpadl = new_channel->ch_bufring_gpadl; - req->chm_vcpuid = new_channel->target_vcpu; + req->chm_vcpuid = new_channel->ch_vcpuid; req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; if (user_data_len) memcpy(req->chm_udata, user_data, user_data_len); @@ -521,7 +521,7 @@ hv_vmbus_channel_close_internal(hv_vmbus struct vmbus_softc *sc = channel->vmbus_sc; struct vmbus_msghc *mh; struct vmbus_chanmsg_chclose *req; - struct taskqueue *rxq = channel->rxq; + struct taskqueue *tq = channel->ch_tq; int error; /* TODO: stringent check */ @@ -530,11 +530,11 @@ hv_vmbus_channel_close_internal(hv_vmbus sysctl_ctx_free(&channel->ch_sysctl_ctx); /* - * set rxq to NULL to avoid more requests be scheduled + * Set ch_tq to NULL to avoid more requests be scheduled */ - channel->rxq = NULL; - taskqueue_drain(rxq, &channel->channel_task); - channel->on_channel_callback = NULL; + channel->ch_tq = NULL; + taskqueue_drain(tq, &channel->ch_task); + channel->ch_cb = NULL; /** * Send a closing message @@ -895,11 +895,8 @@ static void vmbus_chan_task(void *xchan, int pending __unused) { struct hv_vmbus_channel *chan = xchan; - void (*callback)(void *); - void *arg; - - arg = chan->channel_callback_context; - callback = chan->on_channel_callback; + vmbus_chan_callback_t cb = chan->ch_cb; + void *cbarg = chan->ch_cbarg; /* * Optimize host to guest signaling by ensuring: @@ -916,7 +913,7 @@ vmbus_chan_task(void *xchan, int pending for (;;) { uint32_t left; - callback(arg); + cb(cbarg); left = hv_ring_buffer_read_end(&chan->inbound); if (left == 0) { @@ -932,7 +929,7 @@ vmbus_chan_task_nobatch(void *xchan, int { struct hv_vmbus_channel *chan = xchan; - chan->on_channel_callback(chan->channel_callback_context); + chan->ch_cb(chan->ch_cbarg); } static __inline void @@ -961,12 +958,12 @@ vmbus_event_flags_proc(struct vmbus_soft channel = sc->vmbus_chmap[chid_base + chid_ofs]; /* if channel is closed or closing */ - if (channel == NULL || channel->rxq == NULL) + if (channel == NULL || channel->ch_tq == NULL) continue; if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) hv_ring_buffer_read_begin(&channel->inbound); - taskqueue_enqueue(channel->rxq, &channel->channel_task); + taskqueue_enqueue(channel->ch_tq, &channel->ch_task); } } } @@ -1005,7 +1002,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu int flag_cnt; flag_cnt = (chan->ch_id / VMBUS_EVTFLAG_LEN) + 1; - flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->target_cpu); + flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->ch_cpuid); for (;;) { int old_flag_cnt; @@ -1017,8 +1014,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu if (bootverbose) { device_printf(sc->vmbus_dev, "channel%u update cpu%d flag_cnt to %d\n", - chan->ch_id, - chan->target_cpu, flag_cnt); + chan->ch_id, chan->ch_cpuid, flag_cnt); } break; } @@ -1162,13 +1158,12 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch cpu = 0; } - chan->target_cpu = cpu; - chan->target_vcpu = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); + chan->ch_cpuid = cpu; + chan->ch_vcpuid = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); if (bootverbose) { printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", - chan->ch_id, - chan->target_cpu, chan->target_vcpu); + chan->ch_id, chan->ch_cpuid, chan->ch_vcpuid); } } @@ -1401,17 +1396,17 @@ vmbus_select_outgoing_channel(struct hv_ continue; } - if (new_channel->target_vcpu == cur_vcpu){ + if (new_channel->ch_vcpuid == cur_vcpu){ return new_channel; } - old_cpu_distance = ((outgoing_channel->target_vcpu > cur_vcpu) ? - (outgoing_channel->target_vcpu - cur_vcpu) : - (cur_vcpu - outgoing_channel->target_vcpu)); - - new_cpu_distance = ((new_channel->target_vcpu > cur_vcpu) ? - (new_channel->target_vcpu - cur_vcpu) : - (cur_vcpu - new_channel->target_vcpu)); + old_cpu_distance = ((outgoing_channel->ch_vcpuid > cur_vcpu) ? + (outgoing_channel->ch_vcpuid - cur_vcpu) : + (cur_vcpu - outgoing_channel->ch_vcpuid)); + + new_cpu_distance = ((new_channel->ch_vcpuid > cur_vcpu) ? + (new_channel->ch_vcpuid - cur_vcpu) : + (cur_vcpu - new_channel->ch_vcpuid)); if (old_cpu_distance < new_cpu_distance) { continue; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 02:23:05 2016 (r307453) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 02:25:43 2016 (r307454) @@ -726,19 +726,11 @@ vmbus_synic_setup(void *xsc) uint32_t sint; if (hyperv_features & CPUID_HV_MSR_VP_INDEX) { - /* - * Save virtual processor id. - */ + /* Save virtual processor id. */ VMBUS_PCPU_GET(sc, vcpuid, cpu) = rdmsr(MSR_HV_VP_INDEX); } else { - /* - * XXX - * Virtual processoor id is only used by a pretty broken - * channel selection code from storvsc. It's nothing - * critical even if CPUID_HV_MSR_VP_INDEX is not set; keep - * moving on. - */ - VMBUS_PCPU_GET(sc, vcpuid, cpu) = cpu; + /* Set virtual processor id to 0 for compatibility. */ + VMBUS_PCPU_GET(sc, vcpuid, cpu) = 0; } /* From owner-svn-src-stable@freebsd.org Mon Oct 17 02:30:48 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5A4BC13863; Mon, 17 Oct 2016 02:30:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 42C3C107B; Mon, 17 Oct 2016 02:30:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2UlPE092906; Mon, 17 Oct 2016 02:30:47 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2UkQb092892; Mon, 17 Oct 2016 02:30:46 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170230.u9H2UkQb092892@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:30:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307455 - in stable/11/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:30:48 -0000 Author: sephe Date: Mon Oct 17 02:30:45 2016 New Revision: 307455 URL: https://svnweb.freebsd.org/changeset/base/307455 Log: MFC 302875,302876,302878-302881 302875 hyperv/vmbus: Redefine channel packet. The channel packet header will be shared w/ PRP (physical region page) list channel packet and SG (scatter gather) list channel packet. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7155 302876 hyperv/vmbus: Rework sglist sending. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7156 302878 hyeprv/vmbus: Rework prplist sending. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7175 302879 hyperv/vmbus: Move channel packet flags definition to vmbus.h Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7176 302880 hyperv/vmbus: Move channel packet types definition to vmbus.h Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7177 302881 hyperv/vmbus: Cleanup channel sending Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7178 Added: stable/11/sys/dev/hyperv/include/vmbus.h - copied, changed from r302876, head/sys/dev/hyperv/include/vmbus.h Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:30:45 2016 (r307455) @@ -82,19 +82,6 @@ typedef uint8_t hv_bool_uint8_t; #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) -#define HV_MAX_PAGE_BUFFER_COUNT 32 -#define HV_MAX_MULTIPAGE_BUFFER_COUNT 32 - -#define HV_ALIGN_UP(value, align) \ - (((value) & (align-1)) ? \ - (((value) + (align-1)) & ~(align-1) ) : (value)) - -#define HV_ALIGN_DOWN(value, align) ( (value) & ~(align-1) ) - -#define HV_NUM_PAGES_SPANNED(addr, len) \ - ((HV_ALIGN_UP(addr+len, PAGE_SIZE) - \ - HV_ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT ) - struct hyperv_guid { uint8_t hv_guid[16]; } __packed; @@ -125,25 +112,6 @@ typedef struct { hv_vm_transfer_page ranges[1]; } __packed hv_vm_transfer_page_packet_header; -typedef enum { - HV_VMBUS_PACKET_TYPE_INVALID = 0x0, - HV_VMBUS_PACKET_TYPES_SYNCH = 0x1, - HV_VMBUS_PACKET_TYPE_ADD_TRANSFER_PAGE_SET = 0x2, - HV_VMBUS_PACKET_TYPE_REMOVE_TRANSFER_PAGE_SET = 0x3, - HV_VMBUS_PACKET_TYPE_ESTABLISH_GPADL = 0x4, - HV_VMBUS_PACKET_TYPE_TEAR_DOWN_GPADL = 0x5, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND = 0x6, - HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES = 0x7, - HV_VMBUS_PACKET_TYPE_DATA_USING_GPADL = 0x8, - HV_VMBUS_PACKET_TYPE_DATA_USING_GPA_DIRECT = 0x9, - HV_VMBUS_PACKET_TYPE_CANCEL_REQUEST = 0xa, - HV_VMBUS_PACKET_TYPE_COMPLETION = 0xb, - HV_VMBUS_PACKET_TYPE_DATA_USING_ADDITIONAL_PACKETS = 0xc, - HV_VMBUS_PACKET_TYPE_ADDITIONAL_DATA = 0xd -} hv_vmbus_packet_type; - -#define HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1 - #define HW_MACADDR_LEN 6 /* @@ -225,18 +193,6 @@ typedef struct { } __packed hv_vmbus_ring_buffer; typedef struct { - int length; - int offset; - uint64_t pfn; -} __packed hv_vmbus_page_buffer; - -typedef struct { - int length; - int offset; - uint64_t pfn_array[HV_MAX_MULTIPAGE_BUFFER_COUNT]; -} __packed hv_vmbus_multipage_buffer; - -typedef struct { hv_vmbus_ring_buffer* ring_buffer; struct mtx ring_lock; uint32_t ring_data_size; /* ring_size */ @@ -372,23 +328,8 @@ int hv_vmbus_channel_send_packet( void* buffer, uint32_t buffer_len, uint64_t request_id, - hv_vmbus_packet_type type, - uint32_t flags); - -int hv_vmbus_channel_send_packet_pagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_page_buffer page_buffers[], - uint32_t page_count, - void* buffer, - uint32_t buffer_len, - uint64_t request_id); - -int hv_vmbus_channel_send_packet_multipagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_multipage_buffer* multi_page_buffer, - void* buffer, - uint32_t buffer_len, - uint64_t request_id); + uint16_t type, + uint16_t flags); int hv_vmbus_channel_establish_gpadl( hv_vmbus_channel* channel, Copied and modified: stable/11/sys/dev/hyperv/include/vmbus.h (from r302876, head/sys/dev/hyperv/include/vmbus.h) ============================================================================== --- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 06:29:19 2016 (r302876, copy source) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 02:30:45 2016 (r307455) @@ -31,6 +31,15 @@ #include +/* + * GPA stuffs. + */ +struct vmbus_gpa_range { + uint32_t gpa_len; + uint32_t gpa_ofs; + uint64_t gpa_page[0]; +} __packed; + /* This is actually vmbus_gpa_range.gpa_page[1] */ struct vmbus_gpa { uint32_t gpa_len; @@ -38,12 +47,23 @@ struct vmbus_gpa { uint64_t gpa_page; } __packed; -#define VMBUS_CHAN_SGLIST_MAX 32 +#define VMBUS_CHANPKT_TYPE_INBAND 0x0006 +#define VMBUS_CHANPKT_TYPE_RXBUF 0x0007 +#define VMBUS_CHANPKT_TYPE_GPA 0x0009 +#define VMBUS_CHANPKT_TYPE_COMP 0x000b + +#define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */ + +#define VMBUS_CHAN_SGLIST_MAX 32 +#define VMBUS_CHAN_PRPLIST_MAX 32 struct hv_vmbus_channel; int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid); +int vmbus_chan_send_prplist(struct hv_vmbus_channel *chan, + struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, + uint64_t xactid); #endif /* !_VMBUS_H_ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:30:45 2016 (r307455) @@ -185,8 +185,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; } @@ -279,8 +278,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; } @@ -340,7 +338,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); /* * If we failed here, we might as well return and have a leak @@ -408,7 +406,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -474,8 +472,7 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ /* Send the init request */ ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) return (-1); @@ -518,7 +515,7 @@ hv_nv_send_ndis_config(struct hn_softc * /* Send the configuration packet */ ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); if (ret != 0) return (-EINVAL); @@ -597,15 +594,14 @@ hv_nv_connect_to_vsp(struct hn_softc *sc ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); if (ret != 0) { goto cleanup; } /* * TODO: BUGBUG - We have to wait for the above msg since the netvsp * uses KMCL which acknowledges packet (completion packet) - * since our Vmbus always set the - * HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED flag + * since our Vmbus always set the VMBUS_CHANPKT_FLAG_RC flag */ /* sema_wait(&NetVscChannel->channel_init_sema); */ @@ -816,15 +812,13 @@ hv_nv_on_send(struct hv_vmbus_channel *c send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_size = pkt->send_buf_section_size; - if (pkt->page_buf_count) { - ret = hv_vmbus_channel_send_packet_pagebuffer(chan, - pkt->page_buffers, pkt->page_buf_count, + if (pkt->gpa_cnt) { + ret = vmbus_chan_send_sglist(chan, pkt->gpa, pkt->gpa_cnt, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); } else { ret = hv_vmbus_channel_send_packet(chan, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); } return (ret); @@ -853,7 +847,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * All inbound packets other than send completion should be * xfer page packet. */ - if (pkt->type != HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES) { + if (pkt->type != VMBUS_CHANPKT_TYPE_RXBUF) { device_printf(dev, "packet type %d is invalid!\n", pkt->type); return; } @@ -924,7 +918,7 @@ hv_nv_on_receive_completion(struct hv_vm retry_send_cmplt: /* Send the completion */ ret = hv_vmbus_channel_send_packet(chan, &rx_comp_msg, - sizeof(nvsp_msg), tid, HV_VMBUS_PACKET_TYPE_COMPLETION, 0); + sizeof(nvsp_msg), tid, VMBUS_CHANPKT_TYPE_COMP, 0); if (ret == 0) { /* success */ /* no-op */ @@ -1009,14 +1003,14 @@ hv_nv_on_channel_callback(void *xchan) if (bytes_rxed > 0) { desc = (hv_vm_packet_descriptor *)buffer; switch (desc->type) { - case HV_VMBUS_PACKET_TYPE_COMPLETION: + case VMBUS_CHANPKT_TYPE_COMP: hv_nv_on_send_completion(net_dev, chan, desc); break; - case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES: + case VMBUS_CHANPKT_TYPE_RXBUF: hv_nv_on_receive(net_dev, sc, chan, desc); break; - case HV_VMBUS_PACKET_TYPE_DATA_IN_BAND: + case VMBUS_CHANPKT_TYPE_INBAND: hv_nv_send_table(sc, desc); break; default: Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 02:30:45 2016 (r307455) @@ -57,6 +57,7 @@ #include #include +#include #define HN_USE_TXDESC_BUFRING @@ -1082,8 +1083,6 @@ struct hv_vmbus_channel; typedef void (*pfn_on_send_rx_completion)(struct hv_vmbus_channel *, void *); #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) -#define NETVSC_PACKET_MAXPAGE 32 - #define NETVSC_VLAN_PRIO_MASK 0xe000 #define NETVSC_VLAN_PRIO_SHIFT 13 @@ -1132,8 +1131,8 @@ typedef struct netvsc_packet_ { void *rndis_mesg; uint32_t tot_data_buf_len; void *data; - uint32_t page_buf_count; - hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE]; + uint32_t gpa_cnt; + struct vmbus_gpa gpa[VMBUS_CHAN_SGLIST_MAX]; } netvsc_packet; typedef struct { Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 02:30:45 2016 (r307455) @@ -154,7 +154,7 @@ __FBSDID("$FreeBSD$"); #define HN_TX_DATA_MAXSIZE IP_MAXPACKET #define HN_TX_DATA_SEGSIZE PAGE_SIZE #define HN_TX_DATA_SEGCNT_MAX \ - (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) + (VMBUS_CHAN_SGLIST_MAX - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) #define HN_DIRECT_TX_SIZE_DEF 128 @@ -998,7 +998,7 @@ hn_encap(struct hn_tx_ring *txr, struct packet->send_buf_section_idx = send_buf_section_idx; packet->send_buf_section_size = packet->tot_data_buf_len; - packet->page_buf_count = 0; + packet->gpa_cnt = 0; txr->hn_tx_chimney++; goto done; } @@ -1024,24 +1024,24 @@ hn_encap(struct hn_tx_ring *txr, struct } *m_head0 = m_head; - packet->page_buf_count = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; + packet->gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; /* send packet with page buffer */ - packet->page_buffers[0].pfn = atop(txd->rndis_msg_paddr); - packet->page_buffers[0].offset = txd->rndis_msg_paddr & PAGE_MASK; - packet->page_buffers[0].length = rndis_msg_size; + packet->gpa[0].gpa_page = atop(txd->rndis_msg_paddr); + packet->gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; + packet->gpa[0].gpa_len = rndis_msg_size; /* * Fill the page buffers with mbuf info starting at index * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. */ for (i = 0; i < nsegs; ++i) { - hv_vmbus_page_buffer *pb = &packet->page_buffers[ + struct vmbus_gpa *gpa = &packet->gpa[ i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; - pb->pfn = atop(segs[i].ds_addr); - pb->offset = segs[i].ds_addr & PAGE_MASK; - pb->length = segs[i].ds_len; + gpa->gpa_page = atop(segs[i].ds_addr); + gpa->gpa_ofs = segs[i].ds_addr & PAGE_MASK; + gpa->gpa_len = segs[i].ds_len; } packet->send_buf_section_idx = Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 02:30:45 2016 (r307455) @@ -248,26 +248,23 @@ hv_rf_send_request(rndis_device *device, packet->is_data_pkt = FALSE; packet->tot_data_buf_len = request->request_msg.msg_len; - packet->page_buf_count = 1; + packet->gpa_cnt = 1; - packet->page_buffers[0].pfn = + packet->gpa[0].gpa_page = hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; - packet->page_buffers[0].length = request->request_msg.msg_len; - packet->page_buffers[0].offset = + packet->gpa[0].gpa_len = request->request_msg.msg_len; + packet->gpa[0].gpa_ofs = (unsigned long)&request->request_msg & (PAGE_SIZE - 1); - if (packet->page_buffers[0].offset + - packet->page_buffers[0].length > PAGE_SIZE) { - packet->page_buf_count = 2; - packet->page_buffers[0].length = - PAGE_SIZE - packet->page_buffers[0].offset; - packet->page_buffers[1].pfn = + if (packet->gpa[0].gpa_ofs + packet->gpa[0].gpa_len > PAGE_SIZE) { + packet->gpa_cnt = 2; + packet->gpa[0].gpa_len = PAGE_SIZE - packet->gpa[0].gpa_ofs; + packet->gpa[1].gpa_page = hv_get_phys_addr((char*)&request->request_msg + - packet->page_buffers[0].length) >> PAGE_SHIFT; - packet->page_buffers[1].offset = 0; - packet->page_buffers[1].length = - request->request_msg.msg_len - - packet->page_buffers[0].length; + packet->gpa[0].gpa_len) >> PAGE_SHIFT; + packet->gpa[1].gpa_ofs = 0; + packet->gpa[1].gpa_len = request->request_msg.msg_len - + packet->gpa[0].gpa_len; } packet->compl.send.send_completion_context = request; /* packet */ @@ -289,7 +286,7 @@ hv_rf_send_request(rndis_device *device, memcpy(dest, &request->request_msg, request->request_msg.msg_len); packet->send_buf_section_idx = send_buf_section_idx; packet->send_buf_section_size = packet->tot_data_buf_len; - packet->page_buf_count = 0; + packet->gpa_cnt = 0; goto sendit; } /* Failed to allocate chimney send buffer; move on */ @@ -1171,8 +1168,7 @@ hv_rf_on_device_add(struct hn_softc *sc, ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { device_printf(dev, "Fail to allocate subchannel\n"); goto out; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 02:30:45 2016 (r307455) @@ -74,7 +74,6 @@ typedef struct rndis_request_ { /* Simplify allocation by having a netvsc packet inline */ netvsc_packet pkt; - hv_vmbus_page_buffer buffer; /* * The max request size is sizeof(rndis_msg) + PAGE_SIZE. Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:30:45 2016 (r307455) @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "hv_vstorage.h" #include "vmbus_if.h" @@ -100,7 +101,7 @@ struct hv_sgl_page_pool{ boolean_t is_init; } g_hv_sgl_page_pool; -#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * HV_MAX_MULTIPAGE_BUFFER_COUNT +#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * VMBUS_CHAN_PRPLIST_MAX enum storvsc_request_type { WRITE_TYPE, @@ -108,10 +109,16 @@ enum storvsc_request_type { UNKNOWN_TYPE }; +struct hvs_gpa_range { + struct vmbus_gpa_range gpa_range; + uint64_t gpa_page[VMBUS_CHAN_PRPLIST_MAX]; +} __packed; + struct hv_storvsc_request { LIST_ENTRY(hv_storvsc_request) link; struct vstor_packet vstor_packet; - hv_vmbus_multipage_buffer data_buf; + int prp_cnt; + struct hvs_gpa_range prp_list; void *sense_data; uint8_t sense_info_len; uint8_t retries; @@ -354,8 +361,8 @@ storvsc_send_multichannel_request(struct vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); /* wait for 5 seconds */ ret = sema_timedwait(&request->synch_sema, 5 * hz); @@ -425,8 +432,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) goto cleanup; @@ -459,8 +466,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) goto cleanup; @@ -502,8 +509,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if ( ret != 0) goto cleanup; @@ -538,8 +545,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; @@ -628,8 +635,8 @@ hv_storvsc_host_reset(struct storvsc_sof vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)&sc->hs_reset_req, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; @@ -675,29 +682,26 @@ hv_storvsc_io_request(struct storvsc_sof vstor_packet->u.vm_srb.sense_info_len = sense_buffer_size; - vstor_packet->u.vm_srb.transfer_len = request->data_buf.length; + vstor_packet->u.vm_srb.transfer_len = + request->prp_list.gpa_range.gpa_len; vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB; outgoing_channel = vmbus_select_outgoing_channel(sc->hs_chan); mtx_unlock(&request->softc->hs_lock); - if (request->data_buf.length) { - ret = hv_vmbus_channel_send_packet_multipagebuffer( - outgoing_channel, - &request->data_buf, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request); - + if (request->prp_list.gpa_range.gpa_len) { + ret = vmbus_chan_send_prplist(outgoing_channel, + &request->prp_list.gpa_range, request->prp_cnt, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } else { ret = hv_vmbus_channel_send_packet( outgoing_channel, vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); } mtx_lock(&request->softc->hs_lock); @@ -956,7 +960,7 @@ storvsc_attach(device_t dev) /* * Pre-create SG list, each SG list with - * HV_MAX_MULTIPAGE_BUFFER_COUNT segments, each + * VMBUS_CHAN_PRPLIST_MAX segments, each * segment has one page buffer */ for (i = 0; i < STORVSC_MAX_IO_REQUESTS; i++) { @@ -964,10 +968,10 @@ storvsc_attach(device_t dev) M_DEVBUF, M_WAITOK|M_ZERO); sgl_node->sgl_data = - sglist_alloc(HV_MAX_MULTIPAGE_BUFFER_COUNT, + sglist_alloc(VMBUS_CHAN_PRPLIST_MAX, M_WAITOK|M_ZERO); - for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++) { + for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { tmp_buff = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK|M_ZERO); @@ -1054,7 +1058,7 @@ cleanup: while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++) { + for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1117,7 +1121,7 @@ storvsc_detach(device_t dev) while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++){ + for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++){ if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1668,6 +1672,7 @@ create_storvsc_request(union ccb *ccb, s uint32_t pfn_num = 0; uint32_t pfn; uint64_t not_aligned_seg_bits = 0; + struct hvs_gpa_range *prplist; /* refer to struct vmscsi_req for meanings of these two fields */ reqp->vstor_packet.u.vm_srb.port = @@ -1711,22 +1716,23 @@ create_storvsc_request(union ccb *ccb, s return (0); } - reqp->data_buf.length = csio->dxfer_len; + prplist = &reqp->prp_list; + prplist->gpa_range.gpa_len = csio->dxfer_len; switch (ccb->ccb_h.flags & CAM_DATA_MASK) { case CAM_DATA_VADDR: { bytes_to_copy = csio->dxfer_len; phys_addr = vtophys(csio->data_ptr); - reqp->data_buf.offset = phys_addr & PAGE_MASK; + prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; while (bytes_to_copy != 0) { int bytes, page_offset; phys_addr = - vtophys(&csio->data_ptr[reqp->data_buf.length - + vtophys(&csio->data_ptr[prplist->gpa_range.gpa_len - bytes_to_copy]); pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[pfn_num] = pfn; + prplist->gpa_page[pfn_num] = pfn; page_offset = phys_addr & PAGE_MASK; bytes = min(PAGE_SIZE - page_offset, bytes_to_copy); @@ -1734,6 +1740,7 @@ create_storvsc_request(union ccb *ccb, s bytes_to_copy -= bytes; pfn_num++; } + reqp->prp_cnt = pfn_num; break; } @@ -1750,10 +1757,10 @@ create_storvsc_request(union ccb *ccb, s printf("Storvsc: get SG I/O operation, %d\n", reqp->vstor_packet.u.vm_srb.data_in); - if (storvsc_sg_count > HV_MAX_MULTIPAGE_BUFFER_COUNT){ + if (storvsc_sg_count > VMBUS_CHAN_PRPLIST_MAX){ printf("Storvsc: %d segments is too much, " "only support %d segments\n", - storvsc_sg_count, HV_MAX_MULTIPAGE_BUFFER_COUNT); + storvsc_sg_count, VMBUS_CHAN_PRPLIST_MAX); return (EINVAL); } @@ -1806,10 +1813,10 @@ create_storvsc_request(union ccb *ccb, s phys_addr = vtophys(storvsc_sglist[0].ds_addr); } - reqp->data_buf.offset = phys_addr & PAGE_MASK; + prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[0] = pfn; + prplist->gpa_page[0] = pfn; for (i = 1; i < storvsc_sg_count; i++) { if (reqp->not_aligned_seg_bits & (1 << i)) { @@ -1821,27 +1828,31 @@ create_storvsc_request(union ccb *ccb, s } pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[i] = pfn; + prplist->gpa_page[i] = pfn; } + reqp->prp_cnt = i; } else { phys_addr = vtophys(storvsc_sglist[0].ds_addr); - reqp->data_buf.offset = phys_addr & PAGE_MASK; + prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; for (i = 0; i < storvsc_sg_count; i++) { phys_addr = vtophys(storvsc_sglist[i].ds_addr); pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[i] = pfn; + prplist->gpa_page[i] = pfn; } + reqp->prp_cnt = i; /* check the last segment cross boundary or not */ offset = phys_addr & PAGE_MASK; if (offset) { + /* Add one more PRP entry */ phys_addr = vtophys(storvsc_sglist[i-1].ds_addr + PAGE_SIZE - offset); pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[i] = pfn; + prplist->gpa_page[i] = pfn; + reqp->prp_cnt++; } reqp->bounce_sgl_count = 0; Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 02:30:45 2016 (r307455) @@ -35,6 +35,7 @@ #include #include +#include #include "hv_util.h" #include "vmbus_if.h" @@ -87,7 +88,7 @@ hv_heartbeat_cb(void *context) HV_ICMSGHDRFLAG_RESPONSE; hv_vmbus_channel_send_packet(channel, buf, recvlen, requestid, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); } } Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 02:30:45 2016 (r307455) @@ -578,7 +578,7 @@ hv_kvp_respond_host(hv_kvp_sc *sc, int e error = hv_vmbus_channel_send_packet(sc->util_sc.channel, sc->rcv_buf, sc->host_msg_len, sc->host_msg_id, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); if (error) hv_kvp_log_info("%s: hv_kvp_respond_host: sendpacket error:%d\n", Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 02:30:45 2016 (r307455) @@ -40,6 +40,7 @@ #include #include +#include #include "hv_util.h" #include "vmbus_if.h" @@ -106,7 +107,7 @@ hv_shutdown_cb(void *context) hv_vmbus_channel_send_packet(channel, buf, recv_len, request_id, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); } if (execute_shutdown) Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 02:30:45 2016 (r307455) @@ -40,6 +40,7 @@ #include #include +#include #include "hv_util.h" #include "vmbus_if.h" @@ -164,7 +165,7 @@ hv_timesync_cb(void *context) hv_vmbus_channel_send_packet(channel, time_buf, recvlen, requestId, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); } } Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:25:43 2016 (r307454) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:30:45 2016 (r307455) @@ -621,194 +621,119 @@ hv_vmbus_channel_close(struct hv_vmbus_c hv_vmbus_channel_close_internal(chan); } -/** - * @brief Send the specified buffer on the given channel - */ int -hv_vmbus_channel_send_packet( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint64_t request_id, - hv_vmbus_packet_type type, - uint32_t flags) +hv_vmbus_channel_send_packet(struct hv_vmbus_channel *chan, + void *data, uint32_t dlen, uint64_t xactid, uint16_t type, uint16_t flags) { - int ret = 0; - hv_vm_packet_descriptor desc; - uint32_t packet_len; - uint64_t aligned_data; - uint32_t packet_len_aligned; - boolean_t need_sig; - struct iovec iov[3]; - - packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len; - packet_len_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); - aligned_data = 0; - - /* Setup the descriptor */ - desc.type = type; /* HV_VMBUS_PACKET_TYPE_DATA_IN_BAND; */ - desc.flags = flags; /* HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED */ - /* in 8-bytes granularity */ - desc.data_offset8 = sizeof(hv_vm_packet_descriptor) >> 3; - desc.length8 = (uint16_t) (packet_len_aligned >> 3); - desc.transaction_id = request_id; - - iov[0].iov_base = &desc; - iov[0].iov_len = sizeof(hv_vm_packet_descriptor); - - iov[1].iov_base = buffer; - iov[1].iov_len = buffer_len; - - iov[2].iov_base = &aligned_data; - iov[2].iov_len = packet_len_aligned - packet_len; - - ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig); - - /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) - vmbus_chan_send_event(channel); - - return (ret); + struct vmbus_chanpkt pkt; + int pktlen, pad_pktlen, hlen, error; + uint64_t pad = 0; + struct iovec iov[3]; + boolean_t send_evt; + + hlen = sizeof(pkt); + pktlen = hlen + dlen; + pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + + pkt.cp_hdr.cph_type = type; + pkt.cp_hdr.cph_flags = flags; + pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_xactid = xactid; + + iov[0].iov_base = &pkt; + iov[0].iov_len = hlen; + iov[1].iov_base = data; + iov[1].iov_len = dlen; + iov[2].iov_base = &pad; + iov[2].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 3, &send_evt); + if (!error && send_evt) + vmbus_chan_send_event(chan); + return error; } -/** - * @brief Send a range of single-page buffer packets using - * a GPADL Direct packet type - */ int -hv_vmbus_channel_send_packet_pagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_page_buffer page_buffers[], - uint32_t page_count, - void* buffer, - uint32_t buffer_len, - uint64_t request_id) +vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, + struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid) { - - int ret = 0; - boolean_t need_sig; - uint32_t packet_len; - uint32_t page_buflen; - uint32_t packetLen_aligned; - struct iovec iov[4]; - hv_vmbus_channel_packet_page_buffer desc; - uint32_t descSize; - uint64_t alignedData = 0; - - if (page_count > HV_MAX_PAGE_BUFFER_COUNT) - return (EINVAL); - - /* - * Adjust the size down since hv_vmbus_channel_packet_page_buffer - * is the largest size we support - */ - descSize = __offsetof(hv_vmbus_channel_packet_page_buffer, range); - page_buflen = sizeof(hv_vmbus_page_buffer) * page_count; - packet_len = descSize + page_buflen + buffer_len; - packetLen_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); - - /* Setup the descriptor */ - desc.type = HV_VMBUS_PACKET_TYPE_DATA_USING_GPA_DIRECT; - desc.flags = HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; - /* in 8-bytes granularity */ - desc.data_offset8 = (descSize + page_buflen) >> 3; - desc.length8 = (uint16_t) (packetLen_aligned >> 3); - desc.transaction_id = request_id; - desc.range_count = page_count; - - iov[0].iov_base = &desc; - iov[0].iov_len = descSize; - - iov[1].iov_base = page_buffers; - iov[1].iov_len = page_buflen; - - iov[2].iov_base = buffer; - iov[2].iov_len = buffer_len; - - iov[3].iov_base = &alignedData; - iov[3].iov_len = packetLen_aligned - packet_len; - - ret = hv_ring_buffer_write(&channel->outbound, iov, 4, &need_sig); - - /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) - vmbus_chan_send_event(channel); - - return (ret); + struct vmbus_chanpkt_sglist pkt; + int pktlen, pad_pktlen, hlen, error; + struct iovec iov[4]; + boolean_t send_evt; + uint64_t pad = 0; + + KASSERT(sglen < VMBUS_CHAN_SGLIST_MAX, + ("invalid sglist len %d", sglen)); + + hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); + pktlen = hlen + dlen; + pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + + pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; + pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; + pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_xactid = xactid; + pkt.cp_rsvd = 0; + pkt.cp_gpa_cnt = sglen; + + iov[0].iov_base = &pkt; + iov[0].iov_len = sizeof(pkt); + iov[1].iov_base = sg; + iov[1].iov_len = sizeof(struct vmbus_gpa) * sglen; + iov[2].iov_base = data; + iov[2].iov_len = dlen; + iov[3].iov_base = &pad; + iov[3].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); + if (!error && send_evt) + vmbus_chan_send_event(chan); + return error; } -/** - * @brief Send a multi-page buffer packet using a GPADL Direct packet type - */ int -hv_vmbus_channel_send_packet_multipagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_multipage_buffer* multi_page_buffer, - void* buffer, - uint32_t buffer_len, - uint64_t request_id) -{ - - int ret = 0; - uint32_t desc_size; - boolean_t need_sig; - uint32_t packet_len; - uint32_t packet_len_aligned; - uint32_t pfn_count; - uint64_t aligned_data = 0; - struct iovec iov[3]; - hv_vmbus_channel_packet_multipage_buffer desc; - - pfn_count = - HV_NUM_PAGES_SPANNED( - multi_page_buffer->offset, - multi_page_buffer->length); - - if ((pfn_count == 0) || (pfn_count > HV_MAX_MULTIPAGE_BUFFER_COUNT)) - return (EINVAL); - /* - * Adjust the size down since hv_vmbus_channel_packet_multipage_buffer - * is the largest size we support - */ - desc_size = - sizeof(hv_vmbus_channel_packet_multipage_buffer) - - ((HV_MAX_MULTIPAGE_BUFFER_COUNT - pfn_count) * - sizeof(uint64_t)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 02:34:15 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79900C139DC; Mon, 17 Oct 2016 02:34:15 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D28913C6; Mon, 17 Oct 2016 02:34:15 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2YEeD096393; Mon, 17 Oct 2016 02:34:14 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2YD9K096382; Mon, 17 Oct 2016 02:34:13 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170234.u9H2YD9K096382@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:34:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307456 - in stable/11/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:34:15 -0000 Author: sephe Date: Mon Oct 17 02:34:13 2016 New Revision: 307456 URL: https://svnweb.freebsd.org/changeset/base/307456 Log: MFC 302882-302884 302882 hyperv/vmbus: Function rename And reorder the error prone parameters list. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7191 302883 hyperv/vmbus: Field rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7193 302884 hyperv/vmbus: Factor out macros to do channel packet length conversion. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7194 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:34:13 2016 (r307456) @@ -323,14 +323,6 @@ int hv_vmbus_channel_open( void hv_vmbus_channel_close(hv_vmbus_channel *channel); -int hv_vmbus_channel_send_packet( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint64_t request_id, - uint16_t type, - uint16_t flags); - int hv_vmbus_channel_establish_gpadl( hv_vmbus_channel* channel, /* must be phys and virt contiguous */ Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 02:34:13 2016 (r307456) @@ -59,6 +59,8 @@ struct vmbus_gpa { struct hv_vmbus_channel; +int vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, + uint16_t flags, void *data, int dlen, uint64_t xactid); int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid); Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:34:13 2016 (r307456) @@ -183,9 +183,9 @@ hv_nv_init_rx_buffer_with_net_vsp(struct /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) { goto cleanup; } @@ -276,9 +276,9 @@ hv_nv_init_send_buffer_with_net_vsp(stru /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt); if (ret != 0) { goto cleanup; } @@ -335,10 +335,9 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id = NETVSC_RECEIVE_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, - revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), + (uint64_t)(uintptr_t)revoke_pkt); /* * If we failed here, we might as well return and have a leak @@ -403,10 +402,10 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id = NETVSC_SEND_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + (uint64_t)(uintptr_t)revoke_pkt); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -470,9 +469,9 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; /* Send the init request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) return (-1); @@ -513,9 +512,8 @@ hv_nv_send_ndis_config(struct hn_softc * = 1; /* Send the configuration packet */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) return (-EINVAL); @@ -592,9 +590,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc /* Send the init request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) { goto cleanup; } @@ -816,9 +813,9 @@ hv_nv_on_send(struct hv_vmbus_channel *c ret = vmbus_chan_send_sglist(chan, pkt->gpa, pkt->gpa_cnt, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); } else { - ret = hv_vmbus_channel_send_packet(chan, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); } return (ret); @@ -917,8 +914,8 @@ hv_nv_on_receive_completion(struct hv_vm retry_send_cmplt: /* Send the completion */ - ret = hv_vmbus_channel_send_packet(chan, &rx_comp_msg, - sizeof(nvsp_msg), tid, VMBUS_CHANPKT_TYPE_COMP, 0); + ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, 0, + &rx_comp_msg, sizeof(nvsp_msg), tid); if (ret == 0) { /* success */ /* no-op */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 02:34:13 2016 (r307456) @@ -1166,9 +1166,9 @@ hv_rf_on_device_add(struct hn_softc *sc, init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = net_dev->num_channel - 1; - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) { device_printf(dev, "Fail to allocate subchannel\n"); goto out; Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:34:13 2016 (r307456) @@ -356,13 +356,9 @@ storvsc_send_multichannel_request(struct vstor_packet->flags = REQUEST_COMPLETION_FLAG; vstor_packet->u.multi_channels_cnt = request_channels_cnt; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); /* wait for 5 seconds */ ret = sema_timedwait(&request->synch_sema, 5 * hz); @@ -427,13 +423,9 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if (ret != 0) goto cleanup; @@ -461,13 +453,9 @@ hv_storvsc_channel_init(struct storvsc_s /* revision is only significant for Windows guests */ vstor_packet->u.version.revision = 0; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if (ret != 0) goto cleanup; @@ -504,13 +492,9 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet->operation = VSTOR_OPERATION_QUERYPROPERTIES; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if ( ret != 0) goto cleanup; @@ -540,13 +524,9 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if (ret != 0) { goto cleanup; @@ -631,12 +611,10 @@ hv_storvsc_host_reset(struct storvsc_sof vstor_packet->operation = VSTOR_OPERATION_RESETBUS; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet(dev->channel, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)&sc->hs_reset_req, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(dev->channel, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, + (uint64_t)(uintptr_t)&sc->hs_reset_req); if (ret != 0) { goto cleanup; @@ -695,13 +673,9 @@ hv_storvsc_io_request(struct storvsc_sof &request->prp_list.gpa_range, request->prp_cnt, vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } else { - ret = hv_vmbus_channel_send_packet( - outgoing_channel, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(outgoing_channel, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } mtx_lock(&request->softc->hs_lock); Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 02:34:13 2016 (r307456) @@ -87,8 +87,8 @@ hv_heartbeat_cb(void *context) icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - hv_vmbus_channel_send_packet(channel, buf, recvlen, requestid, - VMBUS_CHANPKT_TYPE_INBAND, 0); + vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, + buf, recvlen, requestid); } } Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 02:34:13 2016 (r307456) @@ -575,11 +575,9 @@ hv_kvp_respond_host(hv_kvp_sc *sc, int e hv_icmsg_hdrp->status = error; hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - error = hv_vmbus_channel_send_packet(sc->util_sc.channel, - sc->rcv_buf, - sc->host_msg_len, sc->host_msg_id, - VMBUS_CHANPKT_TYPE_INBAND, 0); - + error = vmbus_chan_send(sc->util_sc.channel, + VMBUS_CHANPKT_TYPE_INBAND, 0, sc->rcv_buf, sc->host_msg_len, + sc->host_msg_id); if (error) hv_kvp_log_info("%s: hv_kvp_respond_host: sendpacket error:%d\n", __func__, error); Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 02:34:13 2016 (r307456) @@ -105,9 +105,8 @@ hv_shutdown_cb(void *context) icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - hv_vmbus_channel_send_packet(channel, buf, - recv_len, request_id, - VMBUS_CHANPKT_TYPE_INBAND, 0); + vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, + buf, recv_len, request_id); } if (execute_shutdown) Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 02:34:13 2016 (r307456) @@ -163,9 +163,8 @@ hv_timesync_cb(void *context) icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - hv_vmbus_channel_send_packet(channel, time_buf, - recvlen, requestId, - VMBUS_CHANPKT_TYPE_INBAND, 0); + vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, + time_buf, recvlen, requestId); } } Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:34:13 2016 (r307456) @@ -622,8 +622,8 @@ hv_vmbus_channel_close(struct hv_vmbus_c } int -hv_vmbus_channel_send_packet(struct hv_vmbus_channel *chan, - void *data, uint32_t dlen, uint64_t xactid, uint16_t type, uint16_t flags) +vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, uint16_t flags, + void *data, int dlen, uint64_t xactid) { struct vmbus_chanpkt pkt; int pktlen, pad_pktlen, hlen, error; @@ -633,12 +633,12 @@ hv_vmbus_channel_send_packet(struct hv_v hlen = sizeof(pkt); pktlen = hlen + dlen; - pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); pkt.cp_hdr.cph_type = type; pkt.cp_hdr.cph_flags = flags; - pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; - pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); pkt.cp_hdr.cph_xactid = xactid; iov[0].iov_base = &pkt; @@ -669,12 +669,12 @@ vmbus_chan_send_sglist(struct hv_vmbus_c hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); pktlen = hlen + dlen; - pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; - pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; - pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); pkt.cp_hdr.cph_xactid = xactid; pkt.cp_rsvd = 0; pkt.cp_gpa_cnt = sglen; @@ -711,12 +711,12 @@ vmbus_chan_send_prplist(struct hv_vmbus_ hlen = __offsetof(struct vmbus_chanpkt_prplist, cp_range[0].gpa_page[prp_cnt]); pktlen = hlen + dlen; - pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; - pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; - pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); pkt.cp_hdr.cph_xactid = xactid; pkt.cp_rsvd = 0; pkt.cp_range_cnt = 1; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 02:30:45 2016 (r307455) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 02:34:13 2016 (r307456) @@ -115,10 +115,18 @@ CTASSERT(sizeof(struct vmbus_mnf) == PAG #define VMBUS_CHANPKT_SIZE_SHIFT 3 #define VMBUS_CHANPKT_SIZE_ALIGN (1 << VMBUS_CHANPKT_SIZE_SHIFT) +#define VMBUS_CHANPKT_SETLEN(pktlen, len) \ +do { \ + (pktlen) = (len) >> VMBUS_CHANPKT_SIZE_SHIFT; \ +} while (0) + +#define VMBUS_CHANPKT_TOTLEN(tlen) \ + roundup2((tlen), VMBUS_CHANPKT_SIZE_ALIGN) + struct vmbus_chanpkt_hdr { uint16_t cph_type; - uint16_t cph_data_ofs; /* in 8 bytes */ - uint16_t cph_len; /* in 8 bytes */ + uint16_t cph_hlen; /* header len, in 8 bytes */ + uint16_t cph_tlen; /* total len, in 8 bytes */ uint16_t cph_flags; uint64_t cph_xactid; } __packed; From owner-svn-src-stable@freebsd.org Mon Oct 17 02:36:51 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50EEAC13B19; Mon, 17 Oct 2016 02:36:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 15334165F; Mon, 17 Oct 2016 02:36:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2aofa096548; Mon, 17 Oct 2016 02:36:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2angm096538; Mon, 17 Oct 2016 02:36:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170236.u9H2angm096538@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:36:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307457 - in stable/11/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:36:51 -0000 Author: sephe Date: Mon Oct 17 02:36:49 2016 New Revision: 307457 URL: https://svnweb.freebsd.org/changeset/base/307457 Log: MFC 302885,302886 302885 hyperv/vmbus: Cleanup channel receiving. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7202 302886 hyperv/vmbus: Cleanup channel packet receiving. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7204 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:36:49 2016 (r307457) @@ -90,28 +90,6 @@ struct hyperv_guid { int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); -typedef struct { - uint16_t type; - uint16_t data_offset8; - uint16_t length8; - uint16_t flags; - uint64_t transaction_id; -} __packed hv_vm_packet_descriptor; - -typedef struct { - uint32_t byte_count; - uint32_t byte_offset; -} __packed hv_vm_transfer_page; - -typedef struct { - hv_vm_packet_descriptor d; - uint16_t transfer_page_set_id; - hv_bool_uint8_t sender_owns_set; - uint8_t reserved; - uint32_t range_count; - hv_vm_transfer_page ranges[1]; -} __packed hv_vm_transfer_page_packet_header; - #define HW_MACADDR_LEN 6 /* @@ -298,20 +276,6 @@ hv_set_channel_read_state(hv_vmbus_chann channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; } -int hv_vmbus_channel_recv_packet( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id); - -int hv_vmbus_channel_recv_packet_raw( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id); - int hv_vmbus_channel_open( hv_vmbus_channel* channel, uint32_t send_ring_buffer_size, Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 02:36:49 2016 (r307457) @@ -47,6 +47,19 @@ struct vmbus_gpa { uint64_t gpa_page; } __packed; +#define VMBUS_CHANPKT_SIZE_SHIFT 3 + +#define VMBUS_CHANPKT_GETLEN(pktlen) \ + (((int)(pktlen)) << VMBUS_CHANPKT_SIZE_SHIFT) + +struct vmbus_chanpkt_hdr { + uint16_t cph_type; /* VMBUS_CHANPKT_TYPE_ */ + uint16_t cph_hlen; /* header len, in 8 bytes */ + uint16_t cph_tlen; /* total len, in 8 bytes */ + uint16_t cph_flags; /* VMBUS_CHANPKT_FLAG_ */ + uint64_t cph_xactid; +} __packed; + #define VMBUS_CHANPKT_TYPE_INBAND 0x0006 #define VMBUS_CHANPKT_TYPE_RXBUF 0x0007 #define VMBUS_CHANPKT_TYPE_GPA 0x0009 @@ -54,11 +67,33 @@ struct vmbus_gpa { #define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */ +#define VMBUS_CHANPKT_CONST_DATA(pkt) \ + (const void *)((const uint8_t *)(pkt) + \ + VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen)) + +struct vmbus_rxbuf_desc { + uint32_t rb_len; + uint32_t rb_ofs; +} __packed; + +struct vmbus_chanpkt_rxbuf { + struct vmbus_chanpkt_hdr cp_hdr; + uint16_t cp_rxbuf_id; + uint16_t cp_rsvd; + uint32_t cp_rxbuf_cnt; + struct vmbus_rxbuf_desc cp_rxbuf[]; +} __packed; + #define VMBUS_CHAN_SGLIST_MAX 32 #define VMBUS_CHAN_PRPLIST_MAX 32 struct hv_vmbus_channel; +int vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen, + uint64_t *xactid); +int vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt, int *pktlen); + int vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, uint16_t flags, void *data, int dlen, uint64_t xactid); int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:36:49 2016 (r307457) @@ -64,12 +64,12 @@ static int hv_nv_destroy_send_buffer(ne static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); static int hv_nv_connect_to_vsp(struct hn_softc *sc); static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt); + struct hv_vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, struct hv_vmbus_channel *chan, - hv_vm_packet_descriptor *pkt); + const struct vmbus_chanpkt_hdr *pkt); /* * @@ -726,13 +726,12 @@ hv_nv_on_device_remove(struct hn_softc * */ static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, - hv_vm_packet_descriptor *pkt) + const struct vmbus_chanpkt_hdr *pkt) { - nvsp_msg *nvsp_msg_pkt; + const nvsp_msg *nvsp_msg_pkt; netvsc_packet *net_vsc_pkt; - nvsp_msg_pkt = - (nvsp_msg *)((unsigned long)pkt + (pkt->data_offset8 << 3)); + nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); if (nvsp_msg_pkt->hdr.msg_type == nvsp_msg_type_init_complete || nvsp_msg_pkt->hdr.msg_type @@ -749,7 +748,7 @@ hv_nv_on_send_completion(netvsc_dev *net nvsp_msg_1_type_send_rndis_pkt_complete) { /* Get the send context */ net_vsc_pkt = - (netvsc_packet *)(unsigned long)pkt->transaction_id; + (netvsc_packet *)(unsigned long)pkt->cph_xactid; if (NULL != net_vsc_pkt) { if (net_vsc_pkt->send_buf_section_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { @@ -829,10 +828,10 @@ hv_nv_on_send(struct hv_vmbus_channel *c */ static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, - struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt) + struct hv_vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { - hv_vm_transfer_page_packet_header *vm_xfer_page_pkt; - nvsp_msg *nvsp_msg_pkt; + const struct vmbus_chanpkt_rxbuf *pkt; + const nvsp_msg *nvsp_msg_pkt; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; device_t dev = sc->hn_dev; @@ -840,43 +839,31 @@ hv_nv_on_receive(netvsc_dev *net_dev, st int i = 0; int status = nvsp_status_success; - /* - * All inbound packets other than send completion should be - * xfer page packet. - */ - if (pkt->type != VMBUS_CHANPKT_TYPE_RXBUF) { - device_printf(dev, "packet type %d is invalid!\n", pkt->type); - return; - } - - nvsp_msg_pkt = (nvsp_msg *)((unsigned long)pkt - + (pkt->data_offset8 << 3)); + nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkthdr); /* Make sure this is a valid nvsp packet */ if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg_1_type_send_rndis_pkt) { - device_printf(dev, "packet hdr type %d is invalid!\n", - pkt->type); + device_printf(dev, "packet hdr type %u is invalid!\n", + nvsp_msg_pkt->hdr.msg_type); return; } - vm_xfer_page_pkt = (hv_vm_transfer_page_packet_header *)pkt; + pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - if (vm_xfer_page_pkt->transfer_page_set_id != - NETVSC_RECEIVE_BUFFER_ID) { - device_printf(dev, "transfer_page_set_id %d is invalid!\n", - vm_xfer_page_pkt->transfer_page_set_id); + if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { + device_printf(dev, "rxbuf_id %d is invalid!\n", + pkt->cp_rxbuf_id); return; } - count = vm_xfer_page_pkt->range_count; + count = pkt->cp_rxbuf_cnt; /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { net_vsc_pkt->status = nvsp_status_success; - net_vsc_pkt->data = (void *)((unsigned long)net_dev->rx_buf + - vm_xfer_page_pkt->ranges[i].byte_offset); - net_vsc_pkt->tot_data_buf_len = - vm_xfer_page_pkt->ranges[i].byte_count; + net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf + + pkt->cp_rxbuf[i].rb_ofs); + net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; hv_rf_on_receive(net_dev, chan, net_vsc_pkt); if (net_vsc_pkt->status != nvsp_status_success) { @@ -889,8 +876,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * messages (not just data messages) will trigger a response * message back to the host. */ - hv_nv_on_receive_completion(chan, vm_xfer_page_pkt->d.transaction_id, - status); + hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid, status); } /* @@ -934,19 +920,19 @@ retry_send_cmplt: * Net VSC receiving vRSS send table from VSP */ static void -hv_nv_send_table(struct hn_softc *sc, hv_vm_packet_descriptor *pkt) +hv_nv_send_table(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { netvsc_dev *net_dev; - nvsp_msg *nvsp_msg_pkt; + const nvsp_msg *nvsp_msg_pkt; int i; - uint32_t count, *table; + uint32_t count; + const uint32_t *table; net_dev = hv_nv_get_inbound_net_device(sc); if (!net_dev) return; - nvsp_msg_pkt = - (nvsp_msg *)((unsigned long)pkt + (pkt->data_offset8 << 3)); + nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg5_type_send_indirection_table) { @@ -962,8 +948,8 @@ hv_nv_send_table(struct hn_softc *sc, hv return; } - table = (uint32_t *) - ((unsigned long)&nvsp_msg_pkt->msgs.vers_5_msgs.send_table + + table = (const uint32_t *) + ((const uint8_t *)&nvsp_msg_pkt->msgs.vers_5_msgs.send_table + nvsp_msg_pkt->msgs.vers_5_msgs.send_table.offset); for (i = 0; i < count; i++) @@ -980,44 +966,40 @@ hv_nv_on_channel_callback(void *xchan) device_t dev = chan->ch_dev; struct hn_softc *sc = device_get_softc(dev); netvsc_dev *net_dev; - uint32_t bytes_rxed; - uint64_t request_id; - hv_vm_packet_descriptor *desc; - uint8_t *buffer; + void *buffer; int bufferlen = NETVSC_PACKET_SIZE; - int ret = 0; net_dev = hv_nv_get_inbound_net_device(sc); if (net_dev == NULL) return; buffer = chan->hv_chan_rdbuf; - do { - ret = hv_vmbus_channel_recv_packet_raw(chan, - buffer, bufferlen, &bytes_rxed, &request_id); + struct vmbus_chanpkt_hdr *pkt = buffer; + uint32_t bytes_rxed; + int ret; + + bytes_rxed = bufferlen; + ret = vmbus_chan_recv_pkt(chan, pkt, &bytes_rxed); if (ret == 0) { if (bytes_rxed > 0) { - desc = (hv_vm_packet_descriptor *)buffer; - switch (desc->type) { + switch (pkt->cph_type) { case VMBUS_CHANPKT_TYPE_COMP: hv_nv_on_send_completion(net_dev, chan, - desc); + pkt); break; case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(net_dev, sc, chan, desc); + hv_nv_on_receive(net_dev, sc, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: - hv_nv_send_table(sc, desc); + hv_nv_send_table(sc, pkt); break; default: device_printf(dev, - "hv_cb recv unknow type %d " - " packet\n", desc->type); + "unknown chan pkt %u\n", + pkt->cph_type); break; } - } else { - break; } } else if (ret == ENOBUFS) { /* Handle large packet */ @@ -1036,6 +1018,9 @@ hv_nv_on_channel_callback(void *xchan) break; } bufferlen = bytes_rxed; + } else { + /* No more packets */ + break; } } while (1); Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:36:49 2016 (r307457) @@ -780,12 +780,10 @@ hv_storvsc_on_channel_callback(void *xch struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; - ret = hv_vmbus_channel_recv_packet( - channel, - packet, - roundup2(VSTOR_PKT_SIZE, 8), - &bytes_recvd, - &request_id); + bytes_recvd = roundup2(VSTOR_PKT_SIZE, 8); + ret = vmbus_chan_recv(channel, packet, &bytes_recvd, &request_id); + KASSERT(ret != ENOBUFS, ("storvsc recvbuf is not large enough")); + /* XXX check bytes_recvd to make sure that it contains enough data */ while ((ret == 0) && (bytes_recvd > 0)) { request = (struct hv_storvsc_request *)(uintptr_t)request_id; @@ -819,12 +817,16 @@ hv_storvsc_on_channel_callback(void *xch break; } } - ret = hv_vmbus_channel_recv_packet( - channel, - packet, - roundup2(VSTOR_PKT_SIZE, 8), - &bytes_recvd, - &request_id); + + bytes_recvd = roundup2(VSTOR_PKT_SIZE, 8), + ret = vmbus_chan_recv(channel, packet, &bytes_recvd, + &request_id); + KASSERT(ret != ENOBUFS, + ("storvsc recvbuf is not large enough")); + /* + * XXX check bytes_recvd to make sure that it contains + * enough data + */ } } Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 02:36:49 2016 (r307457) @@ -52,7 +52,7 @@ hv_heartbeat_cb(void *context) { uint8_t* buf; hv_vmbus_channel* channel; - uint32_t recvlen; + int recvlen; uint64_t requestid; int ret; @@ -64,8 +64,10 @@ hv_heartbeat_cb(void *context) buf = softc->receive_buffer; channel = softc->channel; - ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, &recvlen, - &requestid); + recvlen = PAGE_SIZE; + ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid); + KASSERT(ret != ENOBUFS, ("hvheartbeat recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ if ((ret == 0) && recvlen > 0) { Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 02:36:49 2016 (r307457) @@ -626,8 +626,10 @@ hv_kvp_process_request(void *context, in kvp_buf = sc->util_sc.receive_buffer; channel = sc->util_sc.channel; - ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, - &recvlen, &requestid); + recvlen = 2 * PAGE_SIZE; + ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); + KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ while ((ret == 0) && (recvlen > 0)) { @@ -691,9 +693,11 @@ hv_kvp_process_request(void *context, in /* * Try reading next buffer */ - recvlen = 0; - ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, - &recvlen, &requestid); + recvlen = 2 * PAGE_SIZE; + ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); + KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ + hv_kvp_log_info("%s: read: context %p, ret =%d, recvlen=%d\n", __func__, context, ret, recvlen); } Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 02:36:49 2016 (r307457) @@ -67,8 +67,11 @@ hv_shutdown_cb(void *context) softc = (hv_util_sc*)context; buf = softc->receive_buffer; channel = softc->channel; - ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, - &recv_len, &request_id); + + recv_len = PAGE_SIZE; + ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id); + KASSERT(ret != ENOBUFS, ("hvshutdown recvbuf is not large enough")); + /* XXX check recv_len to make sure that it contains enough data */ if ((ret == 0) && recv_len > 0) { Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 02:36:49 2016 (r307457) @@ -144,8 +144,10 @@ hv_timesync_cb(void *context) channel = softc->util_sc.channel; time_buf = softc->util_sc.receive_buffer; - ret = hv_vmbus_channel_recv_packet(channel, time_buf, - PAGE_SIZE, &recvlen, &requestId); + recvlen = PAGE_SIZE; + ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); + KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ if ((ret == 0) && recvlen > 0) { icmsghdrp = (struct hv_vmbus_icmsg_hdr *) &time_buf[ Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:36:49 2016 (r307457) @@ -736,84 +736,60 @@ vmbus_chan_send_prplist(struct hv_vmbus_ return error; } -/** - * @brief Retrieve the user packet on the specified channel - */ int -hv_vmbus_channel_recv_packet( - hv_vmbus_channel* channel, - void* Buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id) +vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen0, + uint64_t *xactid) { - int ret; - uint32_t user_len; - uint32_t packet_len; - hv_vm_packet_descriptor desc; - - *buffer_actual_len = 0; - *request_id = 0; - - ret = hv_ring_buffer_peek(&channel->inbound, &desc, - sizeof(hv_vm_packet_descriptor)); - if (ret != 0) - return (0); + struct vmbus_chanpkt_hdr pkt; + int error, dlen, hlen; - packet_len = desc.length8 << 3; - user_len = packet_len - (desc.data_offset8 << 3); + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; - *buffer_actual_len = user_len; + hlen = VMBUS_CHANPKT_GETLEN(pkt.cph_hlen); + dlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen) - hlen; - if (user_len > buffer_len) - return (EINVAL); + if (*dlen0 < dlen) { + /* Return the size of this packet's data. */ + *dlen0 = dlen; + return ENOBUFS; + } - *request_id = desc.transaction_id; + *xactid = pkt.cph_xactid; + *dlen0 = dlen; - /* Copy over the packet to the user buffer */ - ret = hv_ring_buffer_read(&channel->inbound, Buffer, user_len, - (desc.data_offset8 << 3)); + /* Skip packet header */ + error = hv_ring_buffer_read(&chan->inbound, data, dlen, hlen); + KASSERT(!error, ("hv_ring_buffer_read failed")); - return (0); + return 0; } -/** - * @brief Retrieve the raw packet on the specified channel - */ int -hv_vmbus_channel_recv_packet_raw( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id) +vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt0, int *pktlen0) { - int ret; - uint32_t packetLen; - hv_vm_packet_descriptor desc; + struct vmbus_chanpkt_hdr pkt; + int error, pktlen; - *buffer_actual_len = 0; - *request_id = 0; + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; + + pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); + if (*pktlen0 < pktlen) { + /* Return the size of this packet. */ + *pktlen0 = pktlen; + return ENOBUFS; + } + *pktlen0 = pktlen; + + /* Include packet header */ + error = hv_ring_buffer_read(&chan->inbound, pkt0, pktlen, 0); + KASSERT(!error, ("hv_ring_buffer_read failed")); - ret = hv_ring_buffer_peek( - &channel->inbound, &desc, - sizeof(hv_vm_packet_descriptor)); - - if (ret != 0) - return (0); - - packetLen = desc.length8 << 3; - *buffer_actual_len = packetLen; - - if (packetLen > buffer_len) - return (ENOBUFS); - - *request_id = desc.transaction_id; - - /* Copy over the entire packet to the user buffer */ - ret = hv_ring_buffer_read(&channel->inbound, buffer, packetLen, 0); - - return (0); + return 0; } static void Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 02:34:13 2016 (r307456) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 02:36:49 2016 (r307457) @@ -112,7 +112,6 @@ CTASSERT(sizeof(struct vmbus_mnf) == PAG * Channel packets */ -#define VMBUS_CHANPKT_SIZE_SHIFT 3 #define VMBUS_CHANPKT_SIZE_ALIGN (1 << VMBUS_CHANPKT_SIZE_SHIFT) #define VMBUS_CHANPKT_SETLEN(pktlen, len) \ @@ -123,14 +122,6 @@ do { \ #define VMBUS_CHANPKT_TOTLEN(tlen) \ roundup2((tlen), VMBUS_CHANPKT_SIZE_ALIGN) -struct vmbus_chanpkt_hdr { - uint16_t cph_type; - uint16_t cph_hlen; /* header len, in 8 bytes */ - uint16_t cph_tlen; /* total len, in 8 bytes */ - uint16_t cph_flags; - uint64_t cph_xactid; -} __packed; - struct vmbus_chanpkt { struct vmbus_chanpkt_hdr cp_hdr; } __packed; From owner-svn-src-stable@freebsd.org Mon Oct 17 02:38:45 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D74E9C13C7D; Mon, 17 Oct 2016 02:38:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B196417EB; Mon, 17 Oct 2016 02:38:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2cipI096665; Mon, 17 Oct 2016 02:38:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2ciOG096661; Mon, 17 Oct 2016 02:38:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170238.u9H2ciOG096661@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:38:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307458 - in stable/11/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:38:45 -0000 Author: sephe Date: Mon Oct 17 02:38:44 2016 New Revision: 307458 URL: https://svnweb.freebsd.org/changeset/base/307458 Log: MFC 302887 hyperv/hn: Busdma-fy rxbuf and chimney sending buffer Nuke unused channel GPADL API. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7211 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:36:49 2016 (r307457) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:38:44 2016 (r307458) @@ -287,14 +287,6 @@ int hv_vmbus_channel_open( void hv_vmbus_channel_close(hv_vmbus_channel *channel); -int hv_vmbus_channel_establish_gpadl( - hv_vmbus_channel* channel, - /* must be phys and virt contiguous */ - void* contig_buffer, - /* page-size multiple */ - uint32_t size, - uint32_t* gpadl_handle); - int hv_vmbus_channel_teardown_gpdal( hv_vmbus_channel* channel, uint32_t gpadl_handle); Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:36:49 2016 (r307457) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:38:44 2016 (r307458) @@ -152,19 +152,27 @@ hv_nv_init_rx_buffer_with_net_vsp(struct return (ENODEV); } - net_dev->rx_buf = contigmalloc(net_dev->rx_buf_size, M_NETVSC, - M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); + net_dev->rx_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), + PAGE_SIZE, 0, net_dev->rx_buf_size, &net_dev->rxbuf_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (net_dev->rx_buf == NULL) { + device_printf(sc->hn_dev, "allocate rxbuf failed\n"); + return ENOMEM; + } /* - * Establish the GPADL handle for this buffer on this channel. - * Note: This call uses the vmbus connection rather than the - * channel to establish the gpadl handle. - * GPADL: Guest physical address descriptor list. - */ - ret = hv_vmbus_channel_establish_gpadl( - sc->hn_prichan, net_dev->rx_buf, - net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle); + * Connect the RXBUF GPADL to the primary channel. + * + * NOTE: + * Only primary channel has RXBUF connected to it. Sub-channels + * just share this RXBUF. + */ + ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size, + &net_dev->rx_buf_gpadl_handle); if (ret != 0) { + device_printf(sc->hn_dev, "rxbuf gpadl connect failed: %d\n", + ret); goto cleanup; } @@ -243,22 +251,27 @@ hv_nv_init_send_buffer_with_net_vsp(stru return (ENODEV); } - net_dev->send_buf = contigmalloc(net_dev->send_buf_size, M_NETVSC, - M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); + net_dev->send_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), + PAGE_SIZE, 0, net_dev->send_buf_size, &net_dev->txbuf_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); if (net_dev->send_buf == NULL) { - ret = ENOMEM; - goto cleanup; + device_printf(sc->hn_dev, "allocate chimney txbuf failed\n"); + return ENOMEM; } /* - * Establish the gpadl handle for this buffer on this channel. - * Note: This call uses the vmbus connection rather than the - * channel to establish the gpadl handle. + * Connect chimney sending buffer GPADL to the primary channel. + * + * NOTE: + * Only primary channel has chimney sending buffer connected to it. + * Sub-channels just share this chimney sending buffer. */ - ret = hv_vmbus_channel_establish_gpadl(sc->hn_prichan, - net_dev->send_buf, net_dev->send_buf_size, + ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size, &net_dev->send_buf_gpadl_handle); if (ret != 0) { + device_printf(sc->hn_dev, "chimney sending buffer gpadl " + "connect failed: %d\n", ret); goto cleanup; } @@ -364,7 +377,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ if (net_dev->rx_buf) { /* Free up the receive buffer */ - contigfree(net_dev->rx_buf, net_dev->rx_buf_size, M_NETVSC); + hyperv_dmamem_free(&net_dev->rxbuf_dma, net_dev->rx_buf); net_dev->rx_buf = NULL; } @@ -432,7 +445,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne if (net_dev->send_buf) { /* Free up the receive buffer */ - contigfree(net_dev->send_buf, net_dev->send_buf_size, M_NETVSC); + hyperv_dmamem_free(&net_dev->txbuf_dma, net_dev->send_buf); net_dev->send_buf = NULL; } Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 02:36:49 2016 (r307457) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 02:38:44 2016 (r307458) @@ -57,6 +57,7 @@ #include #include +#include #include #define HN_USE_TXDESC_BUFRING @@ -1075,6 +1076,8 @@ typedef struct netvsc_dev_ { uint32_t num_channel; + struct hyperv_dma rxbuf_dma; + struct hyperv_dma txbuf_dma; uint32_t vrss_send_table[VRSS_SEND_TABLE_SIZE]; } netvsc_dev; Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:36:49 2016 (r307457) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:38:44 2016 (r307458) @@ -337,17 +337,6 @@ failed: return ret; } -/** - * @brief Establish a GPADL for the specified buffer - */ -int -hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel, - void *contig_buffer, uint32_t size, uint32_t *gpadl) -{ - return vmbus_chan_gpadl_connect(channel, - hv_get_phys_addr(contig_buffer), size, gpadl); -} - int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl0) From owner-svn-src-stable@freebsd.org Mon Oct 17 02:44:29 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D379DC13F13; Mon, 17 Oct 2016 02:44:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 943FE1CBE; Mon, 17 Oct 2016 02:44:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H2iSMm000830; Mon, 17 Oct 2016 02:44:28 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H2iS9o000822; Mon, 17 Oct 2016 02:44:28 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170244.u9H2iS9o000822@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 02:44:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307459 - in stable/11/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 02:44:29 -0000 Author: sephe Date: Mon Oct 17 02:44:27 2016 New Revision: 307459 URL: https://svnweb.freebsd.org/changeset/base/307459 Log: MFC 302888-302892,302986,303020-303022 302888 hyperv/hn: Busdma-fy rxbuf and chimney sending buffer Nuke unused channel GPADL API. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7211 302889 hyperv/vmbus: Back out r302888 temporarily Committed by accident w/ duplicated commit log Sponsored by: Microsoft OSTC 302890 hyperv/vmbus: Function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7212 302891 hyperv/vmbus: Cosmetic vmbus channel close cleanup Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7213 302892 hyperv/vmbus: Cleanup channel sysctl tree creation Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7214 302986 hyperv/vmbus: Cosmetic vmbus channel open cleanup Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7217 303020 hyperv/vmbus: Cleanup cpu based channel selection. And create cpu to channel map at device attach time for storvsc(4). Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7229 303021 hyperv/vmbus: Function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7230 303022 hyperv/vmbus: Temp/internal variable/function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7231 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_util.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:38:44 2016 (r307458) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:44:27 2016 (r307459) @@ -267,42 +267,6 @@ typedef struct hv_vmbus_channel { #define VMBUS_CHAN_ST_OPENED_SHIFT 0 #define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) -static inline void -hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on) -{ - if (!on) - channel->ch_flags &= ~VMBUS_CHAN_FLAG_BATCHREAD; - else - channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; -} - -int hv_vmbus_channel_open( - hv_vmbus_channel* channel, - uint32_t send_ring_buffer_size, - uint32_t recv_ring_buffer_size, - void* user_data, - uint32_t user_data_len, - vmbus_chan_callback_t cb, - void *cbarg); - -void hv_vmbus_channel_close(hv_vmbus_channel *channel); - -int hv_vmbus_channel_teardown_gpdal( - hv_vmbus_channel* channel, - uint32_t gpadl_handle); - -int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, - bus_addr_t paddr, int size, uint32_t *gpadl); - -struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); - -void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu); -void vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan); -struct hv_vmbus_channel ** - vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt); -void vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt); -void vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan); - /** * @brief Get physical address from virtual */ Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 02:38:44 2016 (r307458) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 02:44:27 2016 (r307459) @@ -89,6 +89,27 @@ struct vmbus_chanpkt_rxbuf { struct hv_vmbus_channel; +int vmbus_chan_open(struct hv_vmbus_channel *chan, + int txbr_size, int rxbr_size, const void *udata, int udlen, + vmbus_chan_callback_t cb, void *cbarg); +void vmbus_chan_close(struct hv_vmbus_channel *chan); + +int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, + bus_addr_t paddr, int size, uint32_t *gpadl); +int vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, + uint32_t gpadl); + +void vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu); +void vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan); +struct hv_vmbus_channel * + vmbus_chan_cpu2chan(struct hv_vmbus_channel *chan, int cpu); +void vmbus_chan_set_readbatch(struct hv_vmbus_channel *chan, bool on); + +struct hv_vmbus_channel ** + vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt); +void vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt); +void vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan); + int vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen, uint64_t *xactid); int vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:38:44 2016 (r307458) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:44:27 2016 (r307459) @@ -363,7 +363,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ /* Tear down the gpadl on the vsp end */ if (net_dev->rx_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, + ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, net_dev->rx_buf_gpadl_handle); /* * If we failed here, we might as well return and have a leak @@ -430,7 +430,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne /* Tear down the gpadl on the vsp end */ if (net_dev->send_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, + ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, net_dev->send_buf_gpadl_handle); /* @@ -645,7 +645,7 @@ hv_nv_subchan_attach(struct hv_vmbus_cha { chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); - hv_vmbus_channel_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, + vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hv_nv_on_channel_callback, chan); } @@ -675,7 +675,7 @@ hv_nv_on_device_add(struct hn_softc *sc, /* * Open the channel */ - ret = hv_vmbus_channel_open(chan, + ret = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hv_nv_on_channel_callback, chan); if (ret != 0) { @@ -695,7 +695,7 @@ hv_nv_on_device_add(struct hn_softc *sc, close: /* Now, we can close the channel safely */ free(chan->hv_chan_rdbuf, M_NETVSC); - hv_vmbus_channel_close(chan); + vmbus_chan_close(chan); cleanup: /* @@ -726,7 +726,7 @@ hv_nv_on_device_remove(struct hn_softc * /* Now, we can close the channel safely */ free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); - hv_vmbus_channel_close(sc->hn_prichan); + vmbus_chan_close(sc->hn_prichan); sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 02:38:44 2016 (r307458) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 02:44:27 2016 (r307459) @@ -1586,7 +1586,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } /* Wait for subchannels to be destroyed */ - vmbus_drain_subchan(sc->hn_prichan); + vmbus_subchan_drain(sc->hn_prichan); error = hv_rf_on_device_add(sc, &device_info, sc->hn_rx_ring_inuse); @@ -2950,7 +2950,7 @@ hn_channel_attach(struct hn_softc *sc, s } /* Bind channel to a proper CPU */ - vmbus_channel_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); + vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); } static void @@ -2973,7 +2973,7 @@ hn_subchan_setup(struct hn_softc *sc) int i; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(sc->hn_prichan, subchan_cnt); + subchan = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { @@ -2983,7 +2983,7 @@ hn_subchan_setup(struct hn_softc *sc) } /* Release the sub-channels */ - vmbus_rel_subchan(subchan, subchan_cnt); + vmbus_subchan_rel(subchan, subchan_cnt); if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); } Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:38:44 2016 (r307458) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 02:44:27 2016 (r307459) @@ -147,6 +147,8 @@ struct storvsc_softc { struct hv_storvsc_request hs_init_req; struct hv_storvsc_request hs_reset_req; device_t hs_dev; + + struct hv_vmbus_channel *hs_cpu2chan[MAXCPU]; }; @@ -315,8 +317,8 @@ storvsc_subchan_attach(struct storvsc_so memset(&props, 0, sizeof(props)); new_channel->hv_chan_priv1 = sc; - vmbus_channel_cpu_rr(new_channel); - ret = hv_vmbus_channel_open(new_channel, + vmbus_chan_cpu_rr(new_channel); + ret = vmbus_chan_open(new_channel, sc->hs_drv_props->drv_ringbuffer_size, sc->hs_drv_props->drv_ringbuffer_size, (void *)&props, @@ -377,14 +379,14 @@ storvsc_send_multichannel_request(struct } /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(sc->hs_chan, request_channels_cnt); + subchan = vmbus_subchan_get(sc->hs_chan, request_channels_cnt); /* Attach the sub-channels. */ for (i = 0; i < request_channels_cnt; ++i) storvsc_subchan_attach(sc, subchan[i]); /* Release the sub-channels. */ - vmbus_rel_subchan(subchan, request_channels_cnt); + vmbus_subchan_rel(subchan, request_channels_cnt); if (bootverbose) printf("Storvsc create multi-channel success!\n"); @@ -574,8 +576,8 @@ hv_storvsc_connect_vsp(struct storvsc_so * Open the channel */ KASSERT(sc->hs_chan->hv_chan_priv1 == sc, ("invalid chan priv1")); - vmbus_channel_cpu_rr(sc->hs_chan); - ret = hv_vmbus_channel_open( + vmbus_chan_cpu_rr(sc->hs_chan); + ret = vmbus_chan_open( sc->hs_chan, sc->hs_drv_props->drv_ringbuffer_size, sc->hs_drv_props->drv_ringbuffer_size, @@ -665,7 +667,7 @@ hv_storvsc_io_request(struct storvsc_sof vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB; - outgoing_channel = vmbus_select_outgoing_channel(sc->hs_chan); + outgoing_channel = sc->hs_cpu2chan[curcpu]; mtx_unlock(&request->softc->hs_lock); if (request->prp_list.gpa_range.gpa_len) { @@ -872,6 +874,20 @@ storvsc_probe(device_t dev) return (ret); } +static void +storvsc_create_cpu2chan(struct storvsc_softc *sc) +{ + int cpu; + + CPU_FOREACH(cpu) { + sc->hs_cpu2chan[cpu] = vmbus_chan_cpu2chan(sc->hs_chan, cpu); + if (bootverbose) { + device_printf(sc->hs_dev, "cpu%d -> chan%u\n", + cpu, sc->hs_cpu2chan[cpu]->ch_id); + } + } +} + /** * @brief StorVSC attach function * @@ -969,6 +985,9 @@ storvsc_attach(device_t dev) goto cleanup; } + /* Construct cpu to channel mapping */ + storvsc_create_cpu2chan(sc); + /* * Create the device queue. * Hyper-V maps each target to one SCSI HBA @@ -1083,7 +1102,7 @@ storvsc_detach(device_t dev) * under the protection of the incoming channel lock. */ - hv_vmbus_channel_close(sc->hs_chan); + vmbus_chan_close(sc->hs_chan); mtx_lock(&sc->hs_lock); while (!LIST_EMPTY(&sc->hs_free_list)) { Modified: stable/11/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 02:38:44 2016 (r307458) +++ stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 02:44:27 2016 (r307459) @@ -40,6 +40,7 @@ #include #include +#include #include "hv_util.h" void @@ -89,9 +90,9 @@ hv_util_attach(device_t dev) * Turn off batched reading for all util drivers before we open the * channel. */ - hv_set_channel_read_state(softc->channel, FALSE); + vmbus_chan_set_readbatch(softc->channel, false); - ret = hv_vmbus_channel_open(softc->channel, 4 * PAGE_SIZE, + ret = vmbus_chan_open(softc->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0, softc->callback, softc); @@ -110,7 +111,7 @@ hv_util_detach(device_t dev) { struct hv_util_sc *sc = device_get_softc(dev); - hv_vmbus_channel_close(sc->channel); + vmbus_chan_close(sc->channel); free(sc->receive_buffer, M_DEVBUF); return (0); Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:38:44 2016 (r307458) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:44:27 2016 (r307459) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include -static void vmbus_chan_send_event(hv_vmbus_channel* channel); +static void vmbus_chan_signal_tx(struct hv_vmbus_channel *chan); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); @@ -81,195 +81,194 @@ vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_M * @brief Trigger an event notification on the specified channel */ static void -vmbus_chan_send_event(hv_vmbus_channel *channel) +vmbus_chan_signal_tx(struct hv_vmbus_channel *chan) { - struct vmbus_softc *sc = channel->vmbus_sc; - uint32_t chanid = channel->ch_id; + struct vmbus_softc *sc = chan->vmbus_sc; + uint32_t chanid = chan->ch_id; atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], 1UL << (chanid & VMBUS_EVTFLAG_MASK)); - if (channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { atomic_set_int( - &sc->vmbus_mnf2->mnf_trigs[channel->ch_montrig_idx].mt_pending, - channel->ch_montrig_mask); + &sc->vmbus_mnf2->mnf_trigs[chan->ch_montrig_idx].mt_pending, + chan->ch_montrig_mask); } else { - hypercall_signal_event(channel->ch_monprm_dma.hv_paddr); + hypercall_signal_event(chan->ch_monprm_dma.hv_paddr); } } static int -vmbus_channel_sysctl_monalloc(SYSCTL_HANDLER_ARGS) +vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS) { struct hv_vmbus_channel *chan = arg1; - int alloc = 0; + int mnf = 0; if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) - alloc = 1; - return sysctl_handle_int(oidp, &alloc, 0, req); + mnf = 1; + return sysctl_handle_int(oidp, &mnf, 0, req); } static void -vmbus_channel_sysctl_create(hv_vmbus_channel* channel) +vmbus_chan_sysctl_create(struct hv_vmbus_channel *chan) { - device_t dev; - struct sysctl_oid *devch_sysctl; - struct sysctl_oid *devch_id_sysctl, *devch_sub_sysctl; - struct sysctl_oid *devch_id_in_sysctl, *devch_id_out_sysctl; + struct sysctl_oid *ch_tree, *chid_tree, *br_tree; struct sysctl_ctx_list *ctx; uint32_t ch_id; - uint16_t sub_ch_id; char name[16]; - - hv_vmbus_channel* primary_ch = channel->ch_prichan; - if (primary_ch == NULL) { - dev = channel->ch_dev; - ch_id = channel->ch_id; - } else { - dev = primary_ch->ch_dev; - ch_id = primary_ch->ch_id; - sub_ch_id = channel->ch_subidx; - } - ctx = &channel->ch_sysctl_ctx; + /* + * Add sysctl nodes related to this channel to this + * channel's sysctl ctx, so that they can be destroyed + * independently upon close of this channel, which can + * happen even if the device is not detached. + */ + ctx = &chan->ch_sysctl_ctx; sysctl_ctx_init(ctx); - /* This creates dev.DEVNAME.DEVUNIT.channel tree */ - devch_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - /* This creates dev.DEVNAME.DEVUNIT.channel.CHANID tree */ + + /* + * Create dev.NAME.UNIT.channel tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(chan->ch_dev)), + OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID tree. + */ + if (VMBUS_CHAN_ISPRIMARY(chan)) + ch_id = chan->ch_id; + else + ch_id = chan->ch_prichan->ch_id; snprintf(name, sizeof(name), "%d", ch_id); - devch_id_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_sysctl), - OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - - if (primary_ch != NULL) { - devch_sub_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - snprintf(name, sizeof(name), "%d", sub_ch_id); - devch_id_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_sub_sysctl), - OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - - SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, "chanid", CTLFLAG_RD, - &channel->ch_id, 0, "channel id"); - } - SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, - "cpu", CTLFLAG_RD, &channel->ch_cpuid, 0, "owner CPU id"); - SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, - "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, - channel, 0, vmbus_channel_sysctl_monalloc, "I", - "is monitor allocated to this channel"); - - devch_id_in_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, - "in", - CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - devch_id_out_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, - "out", - CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - hv_ring_buffer_stat(ctx, - SYSCTL_CHILDREN(devch_id_in_sysctl), - &(channel->inbound), - "inbound ring buffer stats"); - hv_ring_buffer_stat(ctx, - SYSCTL_CHILDREN(devch_id_out_sysctl), - &(channel->outbound), - "outbound ring buffer stats"); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + if (!VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Create dev.NAME.UNIT.channel.CHANID.sub tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), + OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID.sub.SUBIDX tree. + * + * NOTE: + * chid_tree is changed to this new sysctl tree. + */ + snprintf(name, sizeof(name), "%d", chan->ch_subidx); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "chanid", CTLFLAG_RD, &chan->ch_id, 0, "channel id"); + } + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "cpu", CTLFLAG_RD, &chan->ch_cpuid, 0, "owner CPU id"); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "mnf", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, + chan, 0, vmbus_chan_sysctl_mnf, "I", + "has monitor notification facilities"); + + /* + * Create sysctl tree for RX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "in", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->inbound, "inbound ring buffer stats"); + } + + /* + * Create sysctl tree for TX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "out", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->outbound, "outbound ring buffer stats"); + } } -/** - * @brief Open the specified channel - */ int -hv_vmbus_channel_open( - hv_vmbus_channel* new_channel, - uint32_t send_ring_buffer_size, - uint32_t recv_ring_buffer_size, - void* user_data, - uint32_t user_data_len, - vmbus_chan_callback_t cb, - void *cbarg) +vmbus_chan_open(struct hv_vmbus_channel *chan, int txbr_size, int rxbr_size, + const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) { - struct vmbus_softc *sc = new_channel->vmbus_sc; + struct vmbus_softc *sc = chan->vmbus_sc; const struct vmbus_chanmsg_chopen_resp *resp; const struct vmbus_message *msg; struct vmbus_chanmsg_chopen *req; struct vmbus_msghc *mh; uint32_t status; - int ret = 0; + int error; uint8_t *br; - if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { + if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { device_printf(sc->vmbus_dev, - "invalid udata len %u for chan%u\n", - user_data_len, new_channel->ch_id); + "invalid udata len %d for chan%u\n", udlen, chan->ch_id); return EINVAL; } - KASSERT((send_ring_buffer_size & PAGE_MASK) == 0, + KASSERT((txbr_size & PAGE_MASK) == 0, ("send bufring size is not multiple page")); - KASSERT((recv_ring_buffer_size & PAGE_MASK) == 0, + KASSERT((rxbr_size & PAGE_MASK) == 0, ("recv bufring size is not multiple page")); - if (atomic_testandset_int(&new_channel->ch_stflags, + if (atomic_testandset_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED_SHIFT)) - panic("double-open chan%u", new_channel->ch_id); + panic("double-open chan%u", chan->ch_id); - new_channel->ch_cb = cb; - new_channel->ch_cbarg = cbarg; + chan->ch_cb = cb; + chan->ch_cbarg = cbarg; - vmbus_chan_update_evtflagcnt(sc, new_channel); + vmbus_chan_update_evtflagcnt(sc, chan); - new_channel->ch_tq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, - new_channel->ch_cpuid); - if (new_channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) { - TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task, - new_channel); - } else { - TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task_nobatch, - new_channel); - } + chan->ch_tq = VMBUS_PCPU_GET(chan->vmbus_sc, event_tq, chan->ch_cpuid); + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task, chan); + else + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); /* * Allocate the TX+RX bufrings. * XXX should use ch_dev dtag */ br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), - PAGE_SIZE, 0, send_ring_buffer_size + recv_ring_buffer_size, - &new_channel->ch_bufring_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); if (br == NULL) { device_printf(sc->vmbus_dev, "bufring allocation failed\n"); - ret = ENOMEM; + error = ENOMEM; goto failed; } - new_channel->ch_bufring = br; + chan->ch_bufring = br; /* TX bufring comes first */ - hv_vmbus_ring_buffer_init(&new_channel->outbound, - br, send_ring_buffer_size); + hv_vmbus_ring_buffer_init(&chan->outbound, br, txbr_size); /* RX bufring immediately follows TX bufring */ - hv_vmbus_ring_buffer_init(&new_channel->inbound, - br + send_ring_buffer_size, recv_ring_buffer_size); + hv_vmbus_ring_buffer_init(&chan->inbound, br + txbr_size, rxbr_size); /* Create sysctl tree for this channel */ - vmbus_channel_sysctl_create(new_channel); + vmbus_chan_sysctl_create(chan); /* * Connect the bufrings, both RX and TX, to this channel. */ - ret = vmbus_chan_gpadl_connect(new_channel, - new_channel->ch_bufring_dma.hv_paddr, - send_ring_buffer_size + recv_ring_buffer_size, - &new_channel->ch_bufring_gpadl); - if (ret != 0) { + error = vmbus_chan_gpadl_connect(chan, chan->ch_bufring_dma.hv_paddr, + txbr_size + rxbr_size, &chan->ch_bufring_gpadl); + if (error) { device_printf(sc->vmbus_dev, - "failed to connect bufring GPADL to chan%u\n", - new_channel->ch_id); + "failed to connect bufring GPADL to chan%u\n", chan->ch_id); goto failed; } @@ -280,26 +279,26 @@ hv_vmbus_channel_open( if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chopen(chan%u)\n", - new_channel->ch_id); - ret = ENXIO; + chan->ch_id); + error = ENXIO; goto failed; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; - req->chm_chanid = new_channel->ch_id; - req->chm_openid = new_channel->ch_id; - req->chm_gpadl = new_channel->ch_bufring_gpadl; - req->chm_vcpuid = new_channel->ch_vcpuid; - req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; - if (user_data_len) - memcpy(req->chm_udata, user_data, user_data_len); + req->chm_chanid = chan->ch_id; + req->chm_openid = chan->ch_id; + req->chm_gpadl = chan->ch_bufring_gpadl; + req->chm_vcpuid = chan->ch_vcpuid; + req->chm_txbr_pgcnt = txbr_size >> PAGE_SHIFT; + if (udlen > 0) + memcpy(req->chm_udata, udata, udlen); - ret = vmbus_msghc_exec(sc, mh); - if (ret != 0) { + error = vmbus_msghc_exec(sc, mh); + if (error) { device_printf(sc->vmbus_dev, "chopen(chan%u) msg hypercall exec failed: %d\n", - new_channel->ch_id, ret); + chan->ch_id, error); vmbus_msghc_put(sc, mh); goto failed; } @@ -313,28 +312,25 @@ hv_vmbus_channel_open( if (status == 0) { if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u opened\n", - new_channel->ch_id); + chan->ch_id); } return 0; } - device_printf(sc->vmbus_dev, "failed to open chan%u\n", - new_channel->ch_id); - ret = ENXIO; + device_printf(sc->vmbus_dev, "failed to open chan%u\n", chan->ch_id); + error = ENXIO; failed: - if (new_channel->ch_bufring_gpadl) { - hv_vmbus_channel_teardown_gpdal(new_channel, - new_channel->ch_bufring_gpadl); - new_channel->ch_bufring_gpadl = 0; - } - if (new_channel->ch_bufring != NULL) { - hyperv_dmamem_free(&new_channel->ch_bufring_dma, - new_channel->ch_bufring); - new_channel->ch_bufring = NULL; + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; + } + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; } - atomic_clear_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED); - return ret; + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); + return error; } int @@ -468,7 +464,7 @@ vmbus_chan_gpadl_connect(struct hv_vmbus * Disconnect the GPA from the target channel */ int -hv_vmbus_channel_teardown_gpdal(struct hv_vmbus_channel *chan, uint32_t gpadl) +vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, uint32_t gpadl) { struct vmbus_softc *sc = chan->vmbus_sc; struct vmbus_msghc *mh; @@ -505,41 +501,45 @@ hv_vmbus_channel_teardown_gpdal(struct h } static void -hv_vmbus_channel_close_internal(hv_vmbus_channel *channel) +vmbus_chan_close_internal(struct hv_vmbus_channel *chan) { - struct vmbus_softc *sc = channel->vmbus_sc; + struct vmbus_softc *sc = chan->vmbus_sc; struct vmbus_msghc *mh; struct vmbus_chanmsg_chclose *req; - struct taskqueue *tq = channel->ch_tq; + struct taskqueue *tq = chan->ch_tq; int error; /* TODO: stringent check */ - atomic_clear_int(&channel->ch_stflags, VMBUS_CHAN_ST_OPENED); - - sysctl_ctx_free(&channel->ch_sysctl_ctx); + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); /* - * Set ch_tq to NULL to avoid more requests be scheduled + * Free this channel's sysctl tree attached to its device's + * sysctl tree. */ - channel->ch_tq = NULL; - taskqueue_drain(tq, &channel->ch_task); - channel->ch_cb = NULL; + sysctl_ctx_free(&chan->ch_sysctl_ctx); - /** - * Send a closing message + /* + * Set ch_tq to NULL to avoid more requests be scheduled. + * XXX pretty broken; need rework. */ + chan->ch_tq = NULL; + taskqueue_drain(tq, &chan->ch_task); + chan->ch_cb = NULL; + /* + * Close this channel. + */ mh = vmbus_msghc_get(sc, sizeof(*req)); if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chclose(chan%u)\n", - channel->ch_id); + chan->ch_id); return; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; - req->chm_chanid = channel->ch_id; + req->chm_chanid = chan->ch_id; error = vmbus_msghc_exec_noresult(mh); vmbus_msghc_put(sc, mh); @@ -547,30 +547,28 @@ hv_vmbus_channel_close_internal(hv_vmbus if (error) { device_printf(sc->vmbus_dev, "chclose(chan%u) msg hypercall exec failed: %d\n", - channel->ch_id, error); + chan->ch_id, error); return; } else if (bootverbose) { - device_printf(sc->vmbus_dev, "close chan%u\n", - channel->ch_id); + device_printf(sc->vmbus_dev, "close chan%u\n", chan->ch_id); } - /* Tear down the gpadl for the channel's ring buffer */ - if (channel->ch_bufring_gpadl) { - hv_vmbus_channel_teardown_gpdal(channel, - channel->ch_bufring_gpadl); - channel->ch_bufring_gpadl = 0; + /* + * Disconnect the TX+RX bufrings from this channel. + */ + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; } - /* TODO: Send a msg to release the childRelId */ - - /* cleanup the ring buffers for this channel */ - hv_ring_buffer_cleanup(&channel->outbound); - hv_ring_buffer_cleanup(&channel->inbound); - - if (channel->ch_bufring != NULL) { - hyperv_dmamem_free(&channel->ch_bufring_dma, - channel->ch_bufring); - channel->ch_bufring = NULL; + /* + * Destroy the TX+RX bufrings. + */ + hv_ring_buffer_cleanup(&chan->outbound); + hv_ring_buffer_cleanup(&chan->inbound); + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; } } @@ -580,7 +578,7 @@ hv_vmbus_channel_close_internal(hv_vmbus * are not being opened. */ void -hv_vmbus_channel_close(struct hv_vmbus_channel *chan) +vmbus_chan_close(struct hv_vmbus_channel *chan) { int subchan_cnt; @@ -600,14 +598,14 @@ hv_vmbus_channel_close(struct hv_vmbus_c struct hv_vmbus_channel **subchan; int i; - subchan = vmbus_get_subchan(chan, subchan_cnt); + subchan = vmbus_subchan_get(chan, subchan_cnt); for (i = 0; i < subchan_cnt; ++i) - hv_vmbus_channel_close_internal(subchan[i]); - vmbus_rel_subchan(subchan, subchan_cnt); + vmbus_chan_close_internal(subchan[i]); + vmbus_subchan_rel(subchan, subchan_cnt); } /* Then close the primary channel. */ - hv_vmbus_channel_close_internal(chan); + vmbus_chan_close_internal(chan); } int @@ -639,7 +637,7 @@ vmbus_chan_send(struct hv_vmbus_channel error = hv_ring_buffer_write(&chan->outbound, iov, 3, &send_evt); if (!error && send_evt) - vmbus_chan_send_event(chan); + vmbus_chan_signal_tx(chan); return error; } @@ -679,7 +677,7 @@ vmbus_chan_send_sglist(struct hv_vmbus_c error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); if (!error && send_evt) - vmbus_chan_send_event(chan); + vmbus_chan_signal_tx(chan); return error; } @@ -721,7 +719,7 @@ vmbus_chan_send_prplist(struct hv_vmbus_ error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); if (!error && send_evt) - vmbus_chan_send_event(chan); + vmbus_chan_signal_tx(chan); return error; } @@ -840,20 +838,20 @@ vmbus_event_flags_proc(struct vmbus_soft chid_base = f << VMBUS_EVTFLAG_SHIFT; while ((chid_ofs = ffsl(flags)) != 0) { - struct hv_vmbus_channel *channel; + struct hv_vmbus_channel *chan; --chid_ofs; /* NOTE: ffsl is 1-based */ flags &= ~(1UL << chid_ofs); - channel = sc->vmbus_chmap[chid_base + chid_ofs]; + chan = sc->vmbus_chmap[chid_base + chid_ofs]; /* if channel is closed or closing */ - if (channel == NULL || channel->ch_tq == NULL) + if (chan == NULL || chan->ch_tq == NULL) continue; - if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - hv_ring_buffer_read_begin(&channel->inbound); - taskqueue_enqueue(channel->ch_tq, &channel->ch_task); + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + hv_ring_buffer_read_begin(&chan->inbound); + taskqueue_enqueue(chan->ch_tq, &chan->ch_task); } } } @@ -1038,7 +1036,7 @@ vmbus_chan_add(struct hv_vmbus_channel * } void -vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu) +vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu) { KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); @@ -1058,13 +1056,13 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch } void -vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan) +vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan) { static uint32_t vmbus_chan_nextcpu; int cpu; cpu = atomic_fetchadd_int(&vmbus_chan_nextcpu, 1) % mp_ncpus; - vmbus_channel_cpu_set(chan, cpu); + vmbus_chan_cpu_set(chan, cpu); } static void @@ -1073,9 +1071,9 @@ vmbus_chan_cpu_default(struct hv_vmbus_c /* * By default, pin the channel to cpu0. Devices having * special channel-cpu mapping requirement should call - * vmbus_channel_cpu_{set,rr}(). + * vmbus_chan_cpu_{set,rr}(). */ - vmbus_channel_cpu_set(chan, 0); + vmbus_chan_cpu_set(chan, 0); } static void @@ -1251,65 +1249,67 @@ vmbus_chan_destroy_all(struct vmbus_soft mtx_unlock(&sc->vmbus_prichan_lock); } -/** - * @brief Select the best outgoing channel - * +/* * The channel whose vcpu binding is closest to the currect vcpu will * be selected. - * If no multi-channel, always select primary channel - * - * @param primary - primary channel + * If no multi-channel, always select primary channel. */ struct hv_vmbus_channel * -vmbus_select_outgoing_channel(struct hv_vmbus_channel *primary) +vmbus_chan_cpu2chan(struct hv_vmbus_channel *prichan, int cpu) { - hv_vmbus_channel *new_channel = NULL; - hv_vmbus_channel *outgoing_channel = primary; - int old_cpu_distance = 0; - int new_cpu_distance = 0; - int cur_vcpu = 0; - int smp_pro_id = PCPU_GET(cpuid); + struct hv_vmbus_channel *sel, *chan; + uint32_t vcpu, sel_dist; - if (TAILQ_EMPTY(&primary->ch_subchans)) { - return outgoing_channel; - } + KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpuid %d", cpu)); + if (TAILQ_EMPTY(&prichan->ch_subchans)) + return prichan; - if (smp_pro_id >= MAXCPU) { - return outgoing_channel; - } + vcpu = VMBUS_PCPU_GET(prichan->vmbus_sc, vcpuid, cpu); - cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); - - /* XXX need lock */ - TAILQ_FOREACH(new_channel, &primary->ch_subchans, ch_sublink) { - if ((new_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) { - continue; - } +#define CHAN_VCPU_DIST(ch, vcpu) \ + (((ch)->ch_vcpuid > (vcpu)) ? \ + ((ch)->ch_vcpuid - (vcpu)) : ((vcpu) - (ch)->ch_vcpuid)) - if (new_channel->ch_vcpuid == cur_vcpu){ - return new_channel; - } +#define CHAN_SELECT(ch) \ +do { \ + sel = ch; \ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 03:07:07 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FD5DC143E7; Mon, 17 Oct 2016 03:07:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 579B4173A; Mon, 17 Oct 2016 03:07:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H376ER009357; Mon, 17 Oct 2016 03:07:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H376G3009353; Mon, 17 Oct 2016 03:07:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170307.u9H376G3009353@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:07:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307460 - in stable/11/sys: conf dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:07:07 -0000 Author: sephe Date: Mon Oct 17 03:07:06 2016 New Revision: 307460 URL: https://svnweb.freebsd.org/changeset/base/307460 Log: MFC 303023 hyperv/vmbus: Rename laundered vmbus channel code Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7232 Added: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c - copied unchanged from r303023, head/sys/dev/hyperv/vmbus/vmbus_chan.c Deleted: stable/11/sys/dev/hyperv/vmbus/hv_channel.c Modified: stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.i386 stable/11/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Mon Oct 17 02:44:27 2016 (r307459) +++ stable/11/sys/conf/files.amd64 Mon Oct 17 03:07:06 2016 (r307460) @@ -301,11 +301,11 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv Modified: stable/11/sys/conf/files.i386 ============================================================================== --- stable/11/sys/conf/files.i386 Mon Oct 17 02:44:27 2016 (r307459) +++ stable/11/sys/conf/files.i386 Mon Oct 17 03:07:06 2016 (r307460) @@ -258,11 +258,11 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv Copied: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c (from r303023, head/sys/dev/hyperv/vmbus/vmbus_chan.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:07:06 2016 (r307460, copy of r303023, head/sys/dev/hyperv/vmbus/vmbus_chan.c) @@ -0,0 +1,1380 @@ +/*- + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2012 NetApp Inc. + * Copyright (c) 2012 Citrix Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +static void vmbus_chan_signal_tx(struct hv_vmbus_channel *chan); +static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, + const struct hv_vmbus_channel *); + +static void vmbus_chan_task(void *, int); +static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_detach_task(void *, int); + +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, + const struct vmbus_message *); + +/* + * Vmbus channel message processing. + */ +static const vmbus_chanmsg_proc_t +vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer), + VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), + + VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP) +}; + +/** + * @brief Trigger an event notification on the specified channel + */ +static void +vmbus_chan_signal_tx(struct hv_vmbus_channel *chan) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + uint32_t chanid = chan->ch_id; + + atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], + 1UL << (chanid & VMBUS_EVTFLAG_MASK)); + + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { + atomic_set_int( + &sc->vmbus_mnf2->mnf_trigs[chan->ch_montrig_idx].mt_pending, + chan->ch_montrig_mask); + } else { + hypercall_signal_event(chan->ch_monprm_dma.hv_paddr); + } +} + +static int +vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS) +{ + struct hv_vmbus_channel *chan = arg1; + int mnf = 0; + + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) + mnf = 1; + return sysctl_handle_int(oidp, &mnf, 0, req); +} + +static void +vmbus_chan_sysctl_create(struct hv_vmbus_channel *chan) +{ + struct sysctl_oid *ch_tree, *chid_tree, *br_tree; + struct sysctl_ctx_list *ctx; + uint32_t ch_id; + char name[16]; + + /* + * Add sysctl nodes related to this channel to this + * channel's sysctl ctx, so that they can be destroyed + * independently upon close of this channel, which can + * happen even if the device is not detached. + */ + ctx = &chan->ch_sysctl_ctx; + sysctl_ctx_init(ctx); + + /* + * Create dev.NAME.UNIT.channel tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(chan->ch_dev)), + OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID tree. + */ + if (VMBUS_CHAN_ISPRIMARY(chan)) + ch_id = chan->ch_id; + else + ch_id = chan->ch_prichan->ch_id; + snprintf(name, sizeof(name), "%d", ch_id); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + if (!VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Create dev.NAME.UNIT.channel.CHANID.sub tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), + OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID.sub.SUBIDX tree. + * + * NOTE: + * chid_tree is changed to this new sysctl tree. + */ + snprintf(name, sizeof(name), "%d", chan->ch_subidx); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "chanid", CTLFLAG_RD, &chan->ch_id, 0, "channel id"); + } + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "cpu", CTLFLAG_RD, &chan->ch_cpuid, 0, "owner CPU id"); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "mnf", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, + chan, 0, vmbus_chan_sysctl_mnf, "I", + "has monitor notification facilities"); + + /* + * Create sysctl tree for RX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "in", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->inbound, "inbound ring buffer stats"); + } + + /* + * Create sysctl tree for TX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "out", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->outbound, "outbound ring buffer stats"); + } +} + +int +vmbus_chan_open(struct hv_vmbus_channel *chan, int txbr_size, int rxbr_size, + const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + const struct vmbus_chanmsg_chopen_resp *resp; + const struct vmbus_message *msg; + struct vmbus_chanmsg_chopen *req; + struct vmbus_msghc *mh; + uint32_t status; + int error; + uint8_t *br; + + if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { + device_printf(sc->vmbus_dev, + "invalid udata len %d for chan%u\n", udlen, chan->ch_id); + return EINVAL; + } + KASSERT((txbr_size & PAGE_MASK) == 0, + ("send bufring size is not multiple page")); + KASSERT((rxbr_size & PAGE_MASK) == 0, + ("recv bufring size is not multiple page")); + + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_OPENED_SHIFT)) + panic("double-open chan%u", chan->ch_id); + + chan->ch_cb = cb; + chan->ch_cbarg = cbarg; + + vmbus_chan_update_evtflagcnt(sc, chan); + + chan->ch_tq = VMBUS_PCPU_GET(chan->vmbus_sc, event_tq, chan->ch_cpuid); + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task, chan); + else + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); + + /* + * Allocate the TX+RX bufrings. + * XXX should use ch_dev dtag + */ + br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (br == NULL) { + device_printf(sc->vmbus_dev, "bufring allocation failed\n"); + error = ENOMEM; + goto failed; + } + chan->ch_bufring = br; + + /* TX bufring comes first */ + hv_vmbus_ring_buffer_init(&chan->outbound, br, txbr_size); + /* RX bufring immediately follows TX bufring */ + hv_vmbus_ring_buffer_init(&chan->inbound, br + txbr_size, rxbr_size); + + /* Create sysctl tree for this channel */ + vmbus_chan_sysctl_create(chan); + + /* + * Connect the bufrings, both RX and TX, to this channel. + */ + error = vmbus_chan_gpadl_connect(chan, chan->ch_bufring_dma.hv_paddr, + txbr_size + rxbr_size, &chan->ch_bufring_gpadl); + if (error) { + device_printf(sc->vmbus_dev, + "failed to connect bufring GPADL to chan%u\n", chan->ch_id); + goto failed; + } + + /* + * Open channel w/ the bufring GPADL on the target CPU. + */ + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chopen(chan%u)\n", + chan->ch_id); + error = ENXIO; + goto failed; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; + req->chm_chanid = chan->ch_id; + req->chm_openid = chan->ch_id; + req->chm_gpadl = chan->ch_bufring_gpadl; + req->chm_vcpuid = chan->ch_vcpuid; + req->chm_txbr_pgcnt = txbr_size >> PAGE_SHIFT; + if (udlen > 0) + memcpy(req->chm_udata, udata, udlen); + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "chopen(chan%u) msg hypercall exec failed: %d\n", + chan->ch_id, error); + vmbus_msghc_put(sc, mh); + goto failed; + } + + msg = vmbus_msghc_wait_result(sc, mh); + resp = (const struct vmbus_chanmsg_chopen_resp *)msg->msg_data; + status = resp->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status == 0) { + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u opened\n", + chan->ch_id); + } + return 0; + } + + device_printf(sc->vmbus_dev, "failed to open chan%u\n", chan->ch_id); + error = ENXIO; + +failed: + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; + } + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; + } + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); + return error; +} + +int +vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr, + int size, uint32_t *gpadl0) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_conn *req; + const struct vmbus_message *msg; + size_t reqsz; + uint32_t gpadl, status; + int page_count, range_len, i, cnt, error; + uint64_t page_id; + + /* + * Preliminary checks. + */ + + KASSERT((size & PAGE_MASK) == 0, + ("invalid GPA size %d, not multiple page size", size)); + page_count = size >> PAGE_SHIFT; + + KASSERT((paddr & PAGE_MASK) == 0, + ("GPA is not page aligned %jx", (uintmax_t)paddr)); + page_id = paddr >> PAGE_SHIFT; + + range_len = __offsetof(struct vmbus_gpa_range, gpa_page[page_count]); + /* + * We don't support multiple GPA ranges. + */ + if (range_len > UINT16_MAX) { + device_printf(sc->vmbus_dev, "GPA too large, %d pages\n", + page_count); + return EOPNOTSUPP; + } + + /* + * Allocate GPADL id. + */ + gpadl = vmbus_gpadl_alloc(sc); + *gpadl0 = gpadl; + + /* + * Connect this GPADL to the target channel. + * + * NOTE: + * Since each message can only hold small set of page + * addresses, several messages may be required to + * complete the connection. + */ + if (page_count > VMBUS_CHANMSG_GPADL_CONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_CONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_conn, + chm_range.gpa_page[cnt]); + mh = vmbus_msghc_get(sc, reqsz); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpadl->chan%u\n", + chan->ch_id); + return EIO; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; + req->chm_chanid = chan->ch_id; + req->chm_gpadl = gpadl; + req->chm_range_len = range_len; + req->chm_range_cnt = 1; + req->chm_range.gpa_len = size; + req->chm_range.gpa_ofs = 0; + for (i = 0; i < cnt; ++i) + req->chm_range.gpa_page[i] = page_id++; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpadl->chan%u msg hypercall exec failed: %d\n", + chan->ch_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + while (page_count > 0) { + struct vmbus_chanmsg_gpadl_subconn *subreq; + + if (page_count > VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_subconn, + chm_gpa_page[cnt]); + vmbus_msghc_reset(mh, reqsz); + + subreq = vmbus_msghc_dataptr(mh); + subreq->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_SUBCONN; + subreq->chm_gpadl = gpadl; + for (i = 0; i < cnt; ++i) + subreq->chm_gpa_page[i] = page_id++; + + vmbus_msghc_exec_noresult(mh); + } + KASSERT(page_count == 0, ("invalid page count %d", page_count)); + + msg = vmbus_msghc_wait_result(sc, mh); + status = ((const struct vmbus_chanmsg_gpadl_connresp *) + msg->msg_data)->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status != 0) { + device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " + "status %u\n", chan->ch_id, status); + return EIO; + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "gpadl->chan%u " + "succeeded\n", chan->ch_id); + } + } + return 0; +} + +/* + * Disconnect the GPA from the target channel + */ +int +vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, uint32_t gpadl) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_disconn *req; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpa x->chan%u\n", + chan->ch_id); + return EBUSY; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_DISCONN; + req->chm_chanid = chan->ch_id; + req->chm_gpadl = gpadl; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpa x->chan%u msg hypercall exec failed: %d\n", + chan->ch_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + vmbus_msghc_wait_result(sc, mh); + /* Discard result; no useful information */ + vmbus_msghc_put(sc, mh); + + return 0; +} + +static void +vmbus_chan_close_internal(struct hv_vmbus_channel *chan) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_chclose *req; + struct taskqueue *tq = chan->ch_tq; + int error; + + /* TODO: stringent check */ + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); + + /* + * Free this channel's sysctl tree attached to its device's + * sysctl tree. + */ + sysctl_ctx_free(&chan->ch_sysctl_ctx); + + /* + * Set ch_tq to NULL to avoid more requests be scheduled. + * XXX pretty broken; need rework. + */ + chan->ch_tq = NULL; + taskqueue_drain(tq, &chan->ch_task); + chan->ch_cb = NULL; + + /* + * Close this channel. + */ + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chclose(chan%u)\n", + chan->ch_id); + return; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; + req->chm_chanid = chan->ch_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chclose(chan%u) msg hypercall exec failed: %d\n", + chan->ch_id, error); + return; + } else if (bootverbose) { + device_printf(sc->vmbus_dev, "close chan%u\n", chan->ch_id); + } + + /* + * Disconnect the TX+RX bufrings from this channel. + */ + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; + } + + /* + * Destroy the TX+RX bufrings. + */ + hv_ring_buffer_cleanup(&chan->outbound); + hv_ring_buffer_cleanup(&chan->inbound); + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; + } +} + +/* + * Caller should make sure that all sub-channels have + * been added to 'chan' and all to-be-closed channels + * are not being opened. + */ +void +vmbus_chan_close(struct hv_vmbus_channel *chan) +{ + int subchan_cnt; + + if (!VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Sub-channel is closed when its primary channel + * is closed; done. + */ + return; + } + + /* + * Close all sub-channels, if any. + */ + subchan_cnt = chan->ch_subchan_cnt; + if (subchan_cnt > 0) { + struct hv_vmbus_channel **subchan; + int i; + + subchan = vmbus_subchan_get(chan, subchan_cnt); + for (i = 0; i < subchan_cnt; ++i) + vmbus_chan_close_internal(subchan[i]); + vmbus_subchan_rel(subchan, subchan_cnt); + } + + /* Then close the primary channel. */ + vmbus_chan_close_internal(chan); +} + +int +vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, uint16_t flags, + void *data, int dlen, uint64_t xactid) +{ + struct vmbus_chanpkt pkt; + int pktlen, pad_pktlen, hlen, error; + uint64_t pad = 0; + struct iovec iov[3]; + boolean_t send_evt; + + hlen = sizeof(pkt); + pktlen = hlen + dlen; + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + + pkt.cp_hdr.cph_type = type; + pkt.cp_hdr.cph_flags = flags; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); + pkt.cp_hdr.cph_xactid = xactid; + + iov[0].iov_base = &pkt; + iov[0].iov_len = hlen; + iov[1].iov_base = data; + iov[1].iov_len = dlen; + iov[2].iov_base = &pad; + iov[2].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 3, &send_evt); + if (!error && send_evt) + vmbus_chan_signal_tx(chan); + return error; +} + +int +vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, + struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid) +{ + struct vmbus_chanpkt_sglist pkt; + int pktlen, pad_pktlen, hlen, error; + struct iovec iov[4]; + boolean_t send_evt; + uint64_t pad = 0; + + KASSERT(sglen < VMBUS_CHAN_SGLIST_MAX, + ("invalid sglist len %d", sglen)); + + hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); + pktlen = hlen + dlen; + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + + pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; + pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); + pkt.cp_hdr.cph_xactid = xactid; + pkt.cp_rsvd = 0; + pkt.cp_gpa_cnt = sglen; + + iov[0].iov_base = &pkt; + iov[0].iov_len = sizeof(pkt); + iov[1].iov_base = sg; + iov[1].iov_len = sizeof(struct vmbus_gpa) * sglen; + iov[2].iov_base = data; + iov[2].iov_len = dlen; + iov[3].iov_base = &pad; + iov[3].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); + if (!error && send_evt) + vmbus_chan_signal_tx(chan); + return error; +} + +int +vmbus_chan_send_prplist(struct hv_vmbus_channel *chan, + struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, + uint64_t xactid) +{ + struct vmbus_chanpkt_prplist pkt; + int pktlen, pad_pktlen, hlen, error; + struct iovec iov[4]; + boolean_t send_evt; + uint64_t pad = 0; + + KASSERT(prp_cnt < VMBUS_CHAN_PRPLIST_MAX, + ("invalid prplist entry count %d", prp_cnt)); + + hlen = __offsetof(struct vmbus_chanpkt_prplist, + cp_range[0].gpa_page[prp_cnt]); + pktlen = hlen + dlen; + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + + pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; + pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); + pkt.cp_hdr.cph_xactid = xactid; + pkt.cp_rsvd = 0; + pkt.cp_range_cnt = 1; + + iov[0].iov_base = &pkt; + iov[0].iov_len = sizeof(pkt); + iov[1].iov_base = prp; + iov[1].iov_len = __offsetof(struct vmbus_gpa_range, gpa_page[prp_cnt]); + iov[2].iov_base = data; + iov[2].iov_len = dlen; + iov[3].iov_base = &pad; + iov[3].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); + if (!error && send_evt) + vmbus_chan_signal_tx(chan); + return error; +} + +int +vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen0, + uint64_t *xactid) +{ + struct vmbus_chanpkt_hdr pkt; + int error, dlen, hlen; + + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; + + hlen = VMBUS_CHANPKT_GETLEN(pkt.cph_hlen); + dlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen) - hlen; + + if (*dlen0 < dlen) { + /* Return the size of this packet's data. */ + *dlen0 = dlen; + return ENOBUFS; + } + + *xactid = pkt.cph_xactid; + *dlen0 = dlen; + + /* Skip packet header */ + error = hv_ring_buffer_read(&chan->inbound, data, dlen, hlen); + KASSERT(!error, ("hv_ring_buffer_read failed")); + + return 0; +} + +int +vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt0, int *pktlen0) +{ + struct vmbus_chanpkt_hdr pkt; + int error, pktlen; + + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; + + pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); + if (*pktlen0 < pktlen) { + /* Return the size of this packet. */ + *pktlen0 = pktlen; + return ENOBUFS; + } + *pktlen0 = pktlen; + + /* Include packet header */ + error = hv_ring_buffer_read(&chan->inbound, pkt0, pktlen, 0); + KASSERT(!error, ("hv_ring_buffer_read failed")); + + return 0; +} + +static void +vmbus_chan_task(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; + vmbus_chan_callback_t cb = chan->ch_cb; + void *cbarg = chan->ch_cbarg; + + /* + * Optimize host to guest signaling by ensuring: + * 1. While reading the channel, we disable interrupts from + * host. + * 2. Ensure that we process all posted messages from the host + * before returning from this callback. + * 3. Once we return, enable signaling from the host. Once this + * state is set we check to see if additional packets are + * available to read. In this case we repeat the process. + * + * NOTE: Interrupt has been disabled in the ISR. + */ + for (;;) { + uint32_t left; + + cb(cbarg); + + left = hv_ring_buffer_read_end(&chan->inbound); + if (left == 0) { + /* No more data in RX bufring; done */ + break; + } + hv_ring_buffer_read_begin(&chan->inbound); + } +} + +static void +vmbus_chan_task_nobatch(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; + + chan->ch_cb(chan->ch_cbarg); +} + +static __inline void +vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, + int flag_cnt) +{ + int f; + + for (f = 0; f < flag_cnt; ++f) { + uint32_t chid_base; + u_long flags; + int chid_ofs; + + if (event_flags[f] == 0) + continue; + + flags = atomic_swap_long(&event_flags[f], 0); + chid_base = f << VMBUS_EVTFLAG_SHIFT; + + while ((chid_ofs = ffsl(flags)) != 0) { + struct hv_vmbus_channel *chan; + + --chid_ofs; /* NOTE: ffsl is 1-based */ + flags &= ~(1UL << chid_ofs); + + chan = sc->vmbus_chmap[chid_base + chid_ofs]; + + /* if channel is closed or closing */ + if (chan == NULL || chan->ch_tq == NULL) + continue; + + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + hv_ring_buffer_read_begin(&chan->inbound); + taskqueue_enqueue(chan->ch_tq, &chan->ch_task); + } + } +} + +void +vmbus_event_proc(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + /* + * On Host with Win8 or above, the event page can be checked directly + * to get the id of the channel that has the pending interrupt. + */ + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + vmbus_event_flags_proc(sc, eventf->evt_flags, + VMBUS_PCPU_GET(sc, event_flags_cnt, cpu)); +} + +void +vmbus_event_proc_compat(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) { + vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags, + VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT); + } +} + +static void +vmbus_chan_update_evtflagcnt(struct vmbus_softc *sc, + const struct hv_vmbus_channel *chan) +{ + volatile int *flag_cnt_ptr; + int flag_cnt; + + flag_cnt = (chan->ch_id / VMBUS_EVTFLAG_LEN) + 1; + flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->ch_cpuid); + + for (;;) { + int old_flag_cnt; + + old_flag_cnt = *flag_cnt_ptr; + if (old_flag_cnt >= flag_cnt) + break; + if (atomic_cmpset_int(flag_cnt_ptr, old_flag_cnt, flag_cnt)) { + if (bootverbose) { + device_printf(sc->vmbus_dev, + "channel%u update cpu%d flag_cnt to %d\n", + chan->ch_id, chan->ch_cpuid, flag_cnt); + } + break; + } + } +} + +static struct hv_vmbus_channel * +vmbus_chan_alloc(struct vmbus_softc *sc) +{ + struct hv_vmbus_channel *chan; + + chan = malloc(sizeof(*chan), M_DEVBUF, M_WAITOK | M_ZERO); + + chan->ch_monprm = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &chan->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (chan->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); + free(chan, M_DEVBUF); + return NULL; + } + + chan->vmbus_sc = sc; + mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); + TAILQ_INIT(&chan->ch_subchans); + TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + + return chan; +} + +static void +vmbus_chan_free(struct hv_vmbus_channel *chan) +{ + /* TODO: assert sub-channel list is empty */ + /* TODO: asset no longer on the primary channel's sub-channel list */ + /* TODO: asset no longer on the vmbus channel list */ + hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); + mtx_destroy(&chan->ch_subchan_lock); + free(chan, M_DEVBUF); +} + +static int +vmbus_chan_add(struct hv_vmbus_channel *newchan) +{ + struct vmbus_softc *sc = newchan->vmbus_sc; + struct hv_vmbus_channel *prichan; + + if (newchan->ch_id == 0) { + /* + * XXX + * Chan0 will neither be processed nor should be offered; + * skip it. + */ + device_printf(sc->vmbus_dev, "got chan0 offer, discard\n"); + return EINVAL; + } else if (newchan->ch_id >= VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid chan%u offer\n", + newchan->ch_id); + return EINVAL; + } + sc->vmbus_chmap[newchan->ch_id] = newchan; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 03:24:05 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F14BC1475E; Mon, 17 Oct 2016 03:24:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 102401EC3; Mon, 17 Oct 2016 03:24:04 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H3O4wL016859; Mon, 17 Oct 2016 03:24:04 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H3O347016850; Mon, 17 Oct 2016 03:24:03 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170324.u9H3O347016850@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:24:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307461 - in stable/11/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:24:05 -0000 Author: sephe Date: Mon Oct 17 03:24:03 2016 New Revision: 307461 URL: https://svnweb.freebsd.org/changeset/base/307461 Log: MFC 303066-303072,303127-303129,303131 303066 hyperv/vmbus: Get rid of unnecessary definition. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7240 303067 hyperv/vmbus: Move IC register definition to Hyper-V utilities Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7241 303068 hyperv/vmbus: Channel struct field rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7242 303069 hyperv/vmbus: Pass channel as the first argument for channel callback The prepares to kill device private fields in channel struct, which are not flexible and extensible. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7243 303070 hyperv/vmbus: Deprecate the device private data in channel struct They are neither flexible nor extensible. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7244 303071 hyperv/vmbus: Hide channel struct definition. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7245 303072 hyperv/vmbus: Save MNF trigger location instead of MNF trigger index. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7246 303127 hyperv/vmbus: Save event flag location and evet flag mask. This avoids unnecessary access to the vmbus_softc struct on sending path. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7257 303128 hyperv/vmbus: Reorder channel fields. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7258 303129 hyperv/vmbus: Shuffle function declaration and macro definition. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7259 303131 hyperv: hv_vmbus_channel -> vmbus_channel Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7260 Added: stable/11/sys/dev/hyperv/utilities/hv_utilreg.h - copied unchanged from r303067, head/sys/dev/hyperv/utilities/hv_utilreg.h stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h - copied, changed from r303071, head/sys/dev/hyperv/vmbus/vmbus_chanvar.h Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis.h stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/utilities/hv_util.c stable/11/sys/dev/hyperv/utilities/hv_util.h stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 03:07:06 2016 (r307460) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 03:24:03 2016 (r307461) @@ -58,30 +58,6 @@ #include #include -typedef uint8_t hv_bool_uint8_t; - -#define HV_S_OK 0x00000000 -#define HV_E_FAIL 0x80004005 -#define HV_ERROR_NOT_SUPPORTED 0x80070032 -#define HV_ERROR_MACHINE_LOCKED 0x800704F7 - -/* - * VMBUS version is 32 bit, upper 16 bit for major_number and lower - * 16 bit for minor_number. - * - * 0.13 -- Windows Server 2008 - * 1.1 -- Windows 7 - * 2.4 -- Windows 8 - * 3.0 -- Windows 8.1 - */ -#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) -#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) -#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) -#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) - -#define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) -#define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) - struct hyperv_guid { uint8_t hv_guid[16]; } __packed; @@ -90,183 +66,6 @@ struct hyperv_guid { int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); -#define HW_MACADDR_LEN 6 - -/* - * Common defines for Hyper-V ICs - */ -#define HV_ICMSGTYPE_NEGOTIATE 0 -#define HV_ICMSGTYPE_HEARTBEAT 1 -#define HV_ICMSGTYPE_KVPEXCHANGE 2 -#define HV_ICMSGTYPE_SHUTDOWN 3 -#define HV_ICMSGTYPE_TIMESYNC 4 -#define HV_ICMSGTYPE_VSS 5 - -#define HV_ICMSGHDRFLAG_TRANSACTION 1 -#define HV_ICMSGHDRFLAG_REQUEST 2 -#define HV_ICMSGHDRFLAG_RESPONSE 4 - -typedef struct hv_vmbus_pipe_hdr { - uint32_t flags; - uint32_t msgsize; -} __packed hv_vmbus_pipe_hdr; - -typedef struct hv_vmbus_ic_version { - uint16_t major; - uint16_t minor; -} __packed hv_vmbus_ic_version; - -typedef struct hv_vmbus_icmsg_hdr { - hv_vmbus_ic_version icverframe; - uint16_t icmsgtype; - hv_vmbus_ic_version icvermsg; - uint16_t icmsgsize; - uint32_t status; - uint8_t ictransaction_id; - uint8_t icflags; - uint8_t reserved[2]; -} __packed hv_vmbus_icmsg_hdr; - -typedef struct hv_vmbus_icmsg_negotiate { - uint16_t icframe_vercnt; - uint16_t icmsg_vercnt; - uint32_t reserved; - hv_vmbus_ic_version icversion_data[1]; /* any size array */ -} __packed hv_vmbus_icmsg_negotiate; - -typedef struct hv_vmbus_shutdown_msg_data { - uint32_t reason_code; - uint32_t timeout_seconds; - uint32_t flags; - uint8_t display_message[2048]; -} __packed hv_vmbus_shutdown_msg_data; - -typedef struct hv_vmbus_heartbeat_msg_data { - uint64_t seq_num; - uint32_t reserved[8]; -} __packed hv_vmbus_heartbeat_msg_data; - -typedef struct { - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t write_index; - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t read_index; - /* - * NOTE: The interrupt_mask field is used only for channels, but - * vmbus connection also uses this data structure - */ - volatile uint32_t interrupt_mask; - /* pad it to PAGE_SIZE so that data starts on a page */ - uint8_t reserved[4084]; - - /* - * WARNING: Ring data starts here - * !!! DO NOT place any fields below this !!! - */ - uint8_t buffer[0]; /* doubles as interrupt mask */ -} __packed hv_vmbus_ring_buffer; - -typedef struct { - hv_vmbus_ring_buffer* ring_buffer; - struct mtx ring_lock; - uint32_t ring_data_size; /* ring_size */ -} hv_vmbus_ring_buffer_info; - -typedef void (*vmbus_chan_callback_t)(void *); - -typedef struct hv_vmbus_channel { - device_t ch_dev; - struct vmbus_softc *vmbus_sc; - uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ - uint32_t ch_id; /* channel id */ - - /* - * These are based on the offer_msg.monitor_id. - * Save it here for easy access. - */ - int ch_montrig_idx; /* MNF trig index */ - uint32_t ch_montrig_mask;/* MNF trig mask */ - - /* - * send to parent - */ - hv_vmbus_ring_buffer_info outbound; - /* - * receive from parent - */ - hv_vmbus_ring_buffer_info inbound; - - struct taskqueue *ch_tq; - struct task ch_task; - vmbus_chan_callback_t ch_cb; - void *ch_cbarg; - - struct hyperv_mon_param *ch_monprm; - struct hyperv_dma ch_monprm_dma; - - int ch_cpuid; /* owner cpu */ - /* - * Virtual cpuid for ch_cpuid; it is used to communicate cpuid - * related information w/ Hyper-V. If MSR_HV_VP_INDEX does not - * exist, ch_vcpuid will always be 0 for compatibility. - */ - uint32_t ch_vcpuid; - - /* - * If this is a primary channel, ch_subchan* fields - * contain sub-channels belonging to this primary - * channel. - */ - struct mtx ch_subchan_lock; - TAILQ_HEAD(, hv_vmbus_channel) ch_subchans; - int ch_subchan_cnt; - - /* If this is a sub-channel */ - TAILQ_ENTRY(hv_vmbus_channel) ch_sublink; /* sub-channel link */ - struct hv_vmbus_channel *ch_prichan; /* owner primary chan */ - - /* - * Driver private data - */ - void *hv_chan_priv1; - void *hv_chan_priv2; - void *hv_chan_priv3; - - void *ch_bufring; /* TX+RX bufrings */ - struct hyperv_dma ch_bufring_dma; - uint32_t ch_bufring_gpadl; - - struct task ch_detach_task; - TAILQ_ENTRY(hv_vmbus_channel) ch_prilink; /* primary chan link */ - uint32_t ch_subidx; /* subchan index */ - volatile uint32_t ch_stflags; /* atomic-op */ - /* VMBUS_CHAN_ST_ */ - struct hyperv_guid ch_guid_type; - struct hyperv_guid ch_guid_inst; - - struct sysctl_ctx_list ch_sysctl_ctx; -} hv_vmbus_channel; - -#define VMBUS_CHAN_ISPRIMARY(chan) ((chan)->ch_subidx == 0) - -#define VMBUS_CHAN_FLAG_HASMNF 0x0001 -/* - * If this flag is set, this channel's interrupt will be masked in ISR, - * and the RX bufring will be drained before this channel's interrupt is - * unmasked. - * - * This flag is turned on by default. Drivers can turn it off according - * to their own requirement. - */ -#define VMBUS_CHAN_FLAG_BATCHREAD 0x0002 - -#define VMBUS_CHAN_ST_OPENED_SHIFT 0 -#define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) - /** * @brief Get physical address from virtual */ @@ -278,10 +77,4 @@ hv_get_phys_addr(void *virt) return (ret); } -static __inline struct hv_vmbus_channel * -vmbus_get_channel(device_t dev) -{ - return device_get_ivars(dev); -} - #endif /* __HYPERV_H__ */ Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 03:07:06 2016 (r307460) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 03:24:03 2016 (r307461) @@ -32,6 +32,23 @@ #include /* + * VMBUS version is 32 bit, upper 16 bit for major_number and lower + * 16 bit for minor_number. + * + * 0.13 -- Windows Server 2008 + * 1.1 -- Windows 7 + * 2.4 -- Windows 8 + * 3.0 -- Windows 8.1 + */ +#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) +#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) +#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) +#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) + +#define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) +#define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) + +/* * GPA stuffs. */ struct vmbus_gpa_range { @@ -87,41 +104,56 @@ struct vmbus_chanpkt_rxbuf { #define VMBUS_CHAN_SGLIST_MAX 32 #define VMBUS_CHAN_PRPLIST_MAX 32 -struct hv_vmbus_channel; +struct vmbus_channel; +struct hyperv_guid; -int vmbus_chan_open(struct hv_vmbus_channel *chan, +typedef void (*vmbus_chan_callback_t)(struct vmbus_channel *, void *); + +static __inline struct vmbus_channel * +vmbus_get_channel(device_t dev) +{ + return device_get_ivars(dev); +} + +int vmbus_chan_open(struct vmbus_channel *chan, int txbr_size, int rxbr_size, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); -void vmbus_chan_close(struct hv_vmbus_channel *chan); +void vmbus_chan_close(struct vmbus_channel *chan); -int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, +int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); -int vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, +int vmbus_chan_gpadl_disconnect(struct vmbus_channel *chan, uint32_t gpadl); -void vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu); -void vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan); -struct hv_vmbus_channel * - vmbus_chan_cpu2chan(struct hv_vmbus_channel *chan, int cpu); -void vmbus_chan_set_readbatch(struct hv_vmbus_channel *chan, bool on); - -struct hv_vmbus_channel ** - vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt); -void vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt); -void vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan); +void vmbus_chan_cpu_set(struct vmbus_channel *chan, int cpu); +void vmbus_chan_cpu_rr(struct vmbus_channel *chan); +struct vmbus_channel * + vmbus_chan_cpu2chan(struct vmbus_channel *chan, int cpu); +void vmbus_chan_set_readbatch(struct vmbus_channel *chan, bool on); + +struct vmbus_channel ** + vmbus_subchan_get(struct vmbus_channel *pri_chan, int subchan_cnt); +void vmbus_subchan_rel(struct vmbus_channel **subchan, int subchan_cnt); +void vmbus_subchan_drain(struct vmbus_channel *pri_chan); -int vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen, +int vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen, uint64_t *xactid); -int vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, +int vmbus_chan_recv_pkt(struct vmbus_channel *chan, struct vmbus_chanpkt_hdr *pkt, int *pktlen); -int vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, +int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, uint16_t flags, void *data, int dlen, uint64_t xactid); -int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, +int vmbus_chan_send_sglist(struct vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid); -int vmbus_chan_send_prplist(struct hv_vmbus_channel *chan, +int vmbus_chan_send_prplist(struct vmbus_channel *chan, struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, uint64_t xactid); +uint32_t vmbus_chan_id(const struct vmbus_channel *chan); +uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan); +bool vmbus_chan_is_primary(const struct vmbus_channel *chan); +const struct hyperv_guid * + vmbus_chan_guid_inst(const struct vmbus_channel *chan); + #endif /* !_VMBUS_H_ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 03:07:06 2016 (r307460) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 03:24:03 2016 (r307461) @@ -49,26 +49,24 @@ #include "hv_rndis.h" #include "hv_rndis_filter.h" -/* priv1 and priv2 are consumed by the main driver */ -#define hv_chan_rdbuf hv_chan_priv3 - MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); /* * Forward declarations */ -static void hv_nv_on_channel_callback(void *xchan); +static void hv_nv_on_channel_callback(struct vmbus_channel *chan, + void *xrxr); static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); static int hv_nv_connect_to_vsp(struct hn_softc *sc); static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); -static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, + struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); +static void hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, - struct hn_softc *sc, struct hv_vmbus_channel *chan, + struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); /* @@ -641,13 +639,14 @@ hv_nv_disconnect_from_vsp(netvsc_dev *ne } void -hv_nv_subchan_attach(struct hv_vmbus_channel *chan) +hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr) { - - chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); + KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), + ("chan%u subidx %u, rxr%d mismatch", + vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, - hv_nv_on_channel_callback, chan); + hv_nv_on_channel_callback, rxr); } /* @@ -656,9 +655,10 @@ hv_nv_subchan_attach(struct hv_vmbus_cha * Callback when the device belonging to this driver is added */ netvsc_dev * -hv_nv_on_device_add(struct hn_softc *sc, void *additional_info) +hv_nv_on_device_add(struct hn_softc *sc, void *additional_info, + struct hn_rx_ring *rxr) { - struct hv_vmbus_channel *chan = sc->hn_prichan; + struct vmbus_channel *chan = sc->hn_prichan; netvsc_dev *net_dev; int ret = 0; @@ -670,18 +670,17 @@ hv_nv_on_device_add(struct hn_softc *sc, sema_init(&net_dev->channel_init_sema, 0, "netdev_sema"); - chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); - /* * Open the channel */ + KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), + ("chan%u subidx %u, rxr%d mismatch", + vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); ret = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, - NULL, 0, hv_nv_on_channel_callback, chan); - if (ret != 0) { - free(chan->hv_chan_rdbuf, M_NETVSC); + NULL, 0, hv_nv_on_channel_callback, rxr); + if (ret != 0) goto cleanup; - } /* * Connect with the NetVsp @@ -694,7 +693,6 @@ hv_nv_on_device_add(struct hn_softc *sc, close: /* Now, we can close the channel safely */ - free(chan->hv_chan_rdbuf, M_NETVSC); vmbus_chan_close(chan); cleanup: @@ -725,7 +723,6 @@ hv_nv_on_device_remove(struct hn_softc * /* Now, we can close the channel safely */ - free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); vmbus_chan_close(sc->hn_prichan); sema_destroy(&net_dev->channel_init_sema); @@ -738,7 +735,7 @@ hv_nv_on_device_remove(struct hn_softc * * Net VSC on send completion */ static void -hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, +hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt) { const nvsp_msg *nvsp_msg_pkt; @@ -802,7 +799,7 @@ hv_nv_on_send_completion(netvsc_dev *net * Returns 0 on success, non-zero on failure. */ int -hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt) +hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt) { nvsp_msg send_msg; int ret; @@ -840,14 +837,13 @@ hv_nv_on_send(struct hv_vmbus_channel *c * with virtual addresses. */ static void -hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, - struct hv_vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) +hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, + struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { const struct vmbus_chanpkt_rxbuf *pkt; const nvsp_msg *nvsp_msg_pkt; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; - device_t dev = sc->hn_dev; int count = 0; int i = 0; int status = nvsp_status_success; @@ -856,7 +852,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Make sure this is a valid nvsp packet */ if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg_1_type_send_rndis_pkt) { - device_printf(dev, "packet hdr type %u is invalid!\n", + if_printf(rxr->hn_ifp, "packet hdr type %u is invalid!\n", nvsp_msg_pkt->hdr.msg_type); return; } @@ -864,7 +860,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { - device_printf(dev, "rxbuf_id %d is invalid!\n", + if_printf(rxr->hn_ifp, "rxbuf_id %d is invalid!\n", pkt->cp_rxbuf_id); return; } @@ -878,7 +874,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st pkt->cp_rxbuf[i].rb_ofs); net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; - hv_rf_on_receive(net_dev, chan, net_vsc_pkt); + hv_rf_on_receive(net_dev, rxr, net_vsc_pkt); if (net_vsc_pkt->status != nvsp_status_success) { status = nvsp_status_failure; } @@ -898,7 +894,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * Send a receive completion packet to RNDIS device (ie NetVsp) */ static void -hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, +hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, uint32_t status) { nvsp_msg rx_comp_msg; @@ -973,11 +969,10 @@ hv_nv_send_table(struct hn_softc *sc, co * Net VSC on channel callback */ static void -hv_nv_on_channel_callback(void *xchan) +hv_nv_on_channel_callback(struct vmbus_channel *chan, void *xrxr) { - struct hv_vmbus_channel *chan = xchan; - device_t dev = chan->ch_dev; - struct hn_softc *sc = device_get_softc(dev); + struct hn_rx_ring *rxr = xrxr; + struct hn_softc *sc = rxr->hn_ifp->if_softc; netvsc_dev *net_dev; void *buffer; int bufferlen = NETVSC_PACKET_SIZE; @@ -986,7 +981,7 @@ hv_nv_on_channel_callback(void *xchan) if (net_dev == NULL) return; - buffer = chan->hv_chan_rdbuf; + buffer = rxr->hn_rdbuf; do { struct vmbus_chanpkt_hdr *pkt = buffer; uint32_t bytes_rxed; @@ -1002,13 +997,13 @@ hv_nv_on_channel_callback(void *xchan) pkt); break; case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(net_dev, sc, chan, pkt); + hv_nv_on_receive(net_dev, rxr, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: hv_nv_send_table(sc, pkt); break; default: - device_printf(dev, + if_printf(rxr->hn_ifp, "unknown chan pkt %u\n", pkt->cph_type); break; @@ -1024,7 +1019,7 @@ hv_nv_on_channel_callback(void *xchan) /* alloc new buffer */ buffer = malloc(bytes_rxed, M_NETVSC, M_NOWAIT); if (buffer == NULL) { - device_printf(dev, + if_printf(rxr->hn_ifp, "hv_cb malloc buffer failed, len=%u\n", bytes_rxed); bufferlen = 0; @@ -1040,5 +1035,5 @@ hv_nv_on_channel_callback(void *xchan) if (bufferlen > NETVSC_PACKET_SIZE) free(buffer, M_NETVSC); - hv_rf_channel_rollup(chan); + hv_rf_channel_rollup(rxr, rxr->hn_txr); } Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 03:07:06 2016 (r307460) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 03:24:03 2016 (r307461) @@ -53,6 +53,7 @@ #include #include +#include #include #include @@ -1065,12 +1066,12 @@ typedef struct netvsc_dev_ { nvsp_msg channel_init_packet; nvsp_msg revoke_packet; - /*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/ + /*uint8_t hw_mac_addr[ETHER_ADDR_LEN];*/ /* Holds rndis device info */ void *extension; - hv_bool_uint8_t destroy; + uint8_t destroy; /* Negotiated NVSP version */ uint32_t nvsp_version; @@ -1081,9 +1082,9 @@ typedef struct netvsc_dev_ { uint32_t vrss_send_table[VRSS_SEND_TABLE_SIZE]; } netvsc_dev; -struct hv_vmbus_channel; +struct vmbus_channel; -typedef void (*pfn_on_send_rx_completion)(struct hv_vmbus_channel *, void *); +typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) @@ -1109,7 +1110,7 @@ typedef void (*pfn_on_send_rx_completion #endif typedef struct netvsc_packet_ { - hv_bool_uint8_t is_data_pkt; /* One byte */ + uint8_t is_data_pkt; /* One byte */ uint16_t vlan_tci; uint32_t status; @@ -1140,7 +1141,7 @@ typedef struct netvsc_packet_ { typedef struct { uint8_t mac_addr[6]; /* Assumption unsigned long */ - hv_bool_uint8_t link_state; + uint8_t link_state; } netvsc_device_info; #ifndef HN_USE_TXDESC_BUFRING @@ -1150,8 +1151,12 @@ SLIST_HEAD(hn_txdesc_list, hn_txdesc); struct buf_ring; #endif +struct hn_tx_ring; + struct hn_rx_ring { struct ifnet *hn_ifp; + struct hn_tx_ring *hn_txr; + void *hn_rdbuf; int hn_rx_idx; /* Trust csum verification on host side */ @@ -1202,7 +1207,7 @@ struct hn_tx_ring { struct mtx hn_tx_lock; struct hn_softc *hn_sc; - struct hv_vmbus_channel *hn_chan; + struct vmbus_channel *hn_chan; int hn_direct_tx_size; int hn_tx_chimney_size; @@ -1241,7 +1246,7 @@ typedef struct hn_softc { /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; netvsc_dev *net_dev; - struct hv_vmbus_channel *hn_prichan; + struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; int hn_rx_ring_inuse; @@ -1265,12 +1270,13 @@ extern int hv_promisc_mode; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, - void *additional_info); + void *additional_info, struct hn_rx_ring *rxr); int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); -int hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt); +int hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt); int hv_nv_get_next_send_section(netvsc_dev *net_dev); -void hv_nv_subchan_attach(struct hv_vmbus_channel *chan); +void hv_nv_subchan_attach(struct vmbus_channel *chan, + struct hn_rx_ring *rxr); #endif /* __HV_NET_VSC_H__ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 03:07:06 2016 (r307460) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 03:24:03 2016 (r307461) @@ -120,9 +120,6 @@ __FBSDID("$FreeBSD$"); #include "hv_rndis_filter.h" #include "vmbus_if.h" -#define hv_chan_rxr hv_chan_priv1 -#define hv_chan_txr hv_chan_priv2 - /* Short for Hyper-V network interface */ #define NETVSC_DEVNAME "hn" @@ -343,8 +340,8 @@ static int hn_encap(struct hn_tx_ring *, static void hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_tx_chimney_size(struct hn_softc *, int); -static void hn_channel_attach(struct hn_softc *, struct hv_vmbus_channel *); -static void hn_subchan_attach(struct hn_softc *, struct hv_vmbus_channel *); +static void hn_channel_attach(struct hn_softc *, struct vmbus_channel *); +static void hn_subchan_attach(struct hn_softc *, struct vmbus_channel *); static void hn_subchan_setup(struct hn_softc *); static int hn_transmit(struct ifnet *, struct mbuf *); @@ -544,7 +541,8 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; - error = hv_rf_on_device_add(sc, &device_info, ring_cnt); + error = hv_rf_on_device_add(sc, &device_info, ring_cnt, + &sc->hn_rx_ring[0]); if (error) goto failed; KASSERT(sc->net_dev->num_channel > 0 && @@ -782,7 +780,7 @@ hn_txeof(struct hn_tx_ring *txr) } static void -hn_tx_done(struct hv_vmbus_channel *chan, void *xpkt) +hn_tx_done(struct vmbus_channel *chan, void *xpkt) { netvsc_packet *packet = xpkt; struct hn_txdesc *txd; @@ -793,9 +791,8 @@ hn_tx_done(struct hv_vmbus_channel *chan txr = txd->txr; KASSERT(txr->hn_chan == chan, - ("channel mismatch, on channel%u, should be channel%u", - chan->ch_subidx, - txr->hn_chan->ch_subidx)); + ("channel mismatch, on chan%u, should be chan%u", + vmbus_chan_subidx(chan), vmbus_chan_subidx(txr->hn_chan))); txr->hn_has_txeof = 1; hn_txdesc_put(txr, txd); @@ -809,12 +806,9 @@ hn_tx_done(struct hv_vmbus_channel *chan } void -netvsc_channel_rollup(struct hv_vmbus_channel *chan) +netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { - struct hn_tx_ring *txr = chan->hv_chan_txr; #if defined(INET) || defined(INET6) - struct hn_rx_ring *rxr = chan->hv_chan_rxr; - tcp_lro_flush_all(&rxr->hn_lro); #endif @@ -1279,12 +1273,11 @@ hn_lro_rx(struct lro_ctrl *lc, struct mb * Note: This is no longer used as a callback */ int -netvsc_recv(struct hv_vmbus_channel *chan, netvsc_packet *packet, +netvsc_recv(struct hn_rx_ring *rxr, netvsc_packet *packet, const rndis_tcp_ip_csum_info *csum_info, const struct rndis_hash_info *hash_info, const struct rndis_hash_value *hash_value) { - struct hn_rx_ring *rxr = chan->hv_chan_rxr; struct ifnet *ifp = rxr->hn_ifp; struct mbuf *m_new; int size, do_lro = 0, do_csum = 1; @@ -1589,7 +1582,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, vmbus_subchan_drain(sc->hn_prichan); error = hv_rf_on_device_add(sc, &device_info, - sc->hn_rx_ring_inuse); + sc->hn_rx_ring_inuse, &sc->hn_rx_ring[0]); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -2223,6 +2216,9 @@ hn_create_rx_data(struct hn_softc *sc, i if (hn_trust_hostip) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; rxr->hn_ifp = sc->hn_ifp; + if (i < sc->hn_tx_ring_cnt) + rxr->hn_txr = &sc->hn_tx_ring[i]; + rxr->hn_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); rxr->hn_rx_idx = i; /* @@ -2335,17 +2331,19 @@ hn_create_rx_data(struct hn_softc *sc, i static void hn_destroy_rx_data(struct hn_softc *sc) { -#if defined(INET) || defined(INET6) int i; -#endif if (sc->hn_rx_ring_cnt == 0) return; + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; + #if defined(INET) || defined(INET6) - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) - tcp_lro_free(&sc->hn_rx_ring[i].hn_lro); + tcp_lro_free(&rxr->hn_lro); #endif + free(rxr->hn_rdbuf, M_NETVSC); + } free(sc->hn_rx_ring, M_NETVSC); sc->hn_rx_ring = NULL; @@ -2913,12 +2911,12 @@ hn_xmit_txeof_taskfunc(void *xtxr, int p } static void -hn_channel_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan) +hn_channel_attach(struct hn_softc *sc, struct vmbus_channel *chan) { struct hn_rx_ring *rxr; int idx; - idx = chan->ch_subidx; + idx = vmbus_chan_subidx(chan); KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, ("invalid channel index %d, should > 0 && < %d", @@ -2928,10 +2926,9 @@ hn_channel_attach(struct hn_softc *sc, s ("RX ring %d already attached", idx)); rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED; - chan->hv_chan_rxr = rxr; if (bootverbose) { if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", - idx, chan->ch_id); + idx, vmbus_chan_id(chan)); } if (idx < sc->hn_tx_ring_inuse) { @@ -2941,11 +2938,10 @@ hn_channel_attach(struct hn_softc *sc, s ("TX ring %d already attached", idx)); txr->hn_tx_flags |= HN_TX_FLAG_ATTACHED; - chan->hv_chan_txr = txr; txr->hn_chan = chan; if (bootverbose) { if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", - idx, chan->ch_id); + idx, vmbus_chan_id(chan)); } } @@ -2954,36 +2950,36 @@ hn_channel_attach(struct hn_softc *sc, s } static void -hn_subchan_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan) +hn_subchan_attach(struct hn_softc *sc, struct vmbus_channel *chan) { - KASSERT(!VMBUS_CHAN_ISPRIMARY(chan), + KASSERT(!vmbus_chan_is_primary(chan), ("subchannel callback on primary channel")); - KASSERT(chan->ch_subidx > 0, - ("invalid channel subidx %u", - chan->ch_subidx)); hn_channel_attach(sc, chan); } static void hn_subchan_setup(struct hn_softc *sc) { - struct hv_vmbus_channel **subchan; + struct vmbus_channel **subchans; int subchan_cnt = sc->net_dev->num_channel - 1; int i; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); + subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { + struct vmbus_channel *subchan = subchans[i]; + /* NOTE: Calling order is critical. */ - hn_subchan_attach(sc, subchan[i]); - hv_nv_subchan_attach(subchan[i]); + hn_subchan_attach(sc, subchan); + hv_nv_subchan_attach(subchan, + &sc->hn_rx_ring[vmbus_chan_subidx(subchan)]); } /* Release the sub-channels */ - vmbus_subchan_rel(subchan, subchan_cnt); + vmbus_subchan_rel(subchans, subchan_cnt); if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); } Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 03:07:06 2016 (r307460) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 03:24:03 2016 (r307461) @@ -1082,13 +1082,14 @@ typedef struct rndismp_rx_bufs_info_ { /* * Externs */ -struct hv_vmbus_channel; +struct hn_rx_ring; +struct hn_tx_ring; -int netvsc_recv(struct hv_vmbus_channel *chan, +int netvsc_recv(struct hn_rx_ring *rxr, netvsc_packet *packet, const rndis_tcp_ip_csum_info *csum_info, const struct rndis_hash_info *hash_info, const struct rndis_hash_value *hash_value); -void netvsc_channel_rollup(struct hv_vmbus_channel *chan); +void netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); void* hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 03:07:06 2016 (r307460) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 03:24:03 2016 (r307461) @@ -34,7 +34,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include @@ -74,8 +76,7 @@ static int hv_rf_send_request(rndis_dev static void hv_rf_receive_response(rndis_device *device, rndis_msg *response); static void hv_rf_receive_indicate_status(rndis_device *device, rndis_msg *response); -static void hv_rf_receive_data(rndis_device *device, rndis_msg *message, - struct hv_vmbus_channel *chan, +static void hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, netvsc_packet *pkt); static int hv_rf_query_device(rndis_device *device, uint32_t oid, void *result, uint32_t *result_size); @@ -85,8 +86,8 @@ static int hv_rf_set_packet_filter(rndi static int hv_rf_init_device(rndis_device *device); static int hv_rf_open_device(rndis_device *device); static int hv_rf_close_device(rndis_device *device); -static void hv_rf_on_send_request_completion(struct hv_vmbus_channel *, void *context); -static void hv_rf_on_send_request_halt_completion(struct hv_vmbus_channel *, void *context); +static void hv_rf_on_send_request_completion(struct vmbus_channel *, void *context); +static void hv_rf_on_send_request_halt_completion(struct vmbus_channel *, void *context); int hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads); @@ -527,12 +528,11 @@ skip: * RNDIS filter receive data */ static void -hv_rf_receive_data(rndis_device *device, rndis_msg *message, - struct hv_vmbus_channel *chan, netvsc_packet *pkt) +hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, + netvsc_packet *pkt) { rndis_packet *rndis_pkt; uint32_t data_offset; - device_t dev = device->net_dev->sc->hn_dev; struct hv_rf_recvinfo info; rndis_pkt = &message->msg.packet; @@ -548,7 +548,7 @@ hv_rf_receive_data(rndis_device *device, pkt->tot_data_buf_len -= data_offset; if (pkt->tot_data_buf_len < rndis_pkt->data_length) { pkt->status = nvsp_status_failure; - device_printf(dev, + if_printf(rxr->hn_ifp, "total length %u is less than data length %u\n", pkt->tot_data_buf_len, rndis_pkt->data_length); return; @@ -559,7 +559,7 @@ hv_rf_receive_data(rndis_device *device, if (hv_rf_find_recvinfo(rndis_pkt, &info)) { pkt->status = nvsp_status_failure; - device_printf(dev, "recvinfo parsing failed\n"); + if_printf(rxr->hn_ifp, "recvinfo parsing failed\n"); return; } @@ -568,7 +568,7 @@ hv_rf_receive_data(rndis_device *device, else pkt->vlan_tci = 0; - netvsc_recv(chan, pkt, info.csum_info, info.hash_info, info.hash_value); + netvsc_recv(rxr, pkt, info.csum_info, info.hash_info, info.hash_value); } /* @@ -576,7 +576,7 @@ hv_rf_receive_data(rndis_device *device, */ int hv_rf_on_receive(netvsc_dev *net_dev, - struct hv_vmbus_channel *chan, netvsc_packet *pkt) + struct hn_rx_ring *rxr, netvsc_packet *pkt) { rndis_device *rndis_dev; rndis_msg *rndis_hdr; @@ -599,7 +599,7 @@ hv_rf_on_receive(netvsc_dev *net_dev, /* data message */ case REMOTE_NDIS_PACKET_MSG: - hv_rf_receive_data(rndis_dev, rndis_hdr, chan, pkt); + hv_rf_receive_data(rxr, rndis_hdr, pkt); break; /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: @@ -699,7 +699,7 @@ cleanup: static inline int hv_rf_query_device_mac(rndis_device *device) { - uint32_t size = HW_MACADDR_LEN; + uint32_t size = ETHER_ADDR_LEN; return (hv_rf_query_device(device, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 03:27:24 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD966C148FC; Mon, 17 Oct 2016 03:27:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A6E31130F; Mon, 17 Oct 2016 03:27:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H3RN97017033; Mon, 17 Oct 2016 03:27:23 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H3RNHM017027; Mon, 17 Oct 2016 03:27:23 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170327.u9H3RNHM017027@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:27:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307462 - stable/11/sys/dev/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:27:25 -0000 Author: sephe Date: Mon Oct 17 03:27:23 2016 New Revision: 307462 URL: https://svnweb.freebsd.org/changeset/base/307462 Log: MFC 303178,303180,303182 303178 hyperv/vmbus: Cosmetic bufring cleanup. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7267 303180 hyperv/vmbus: Cleanup and augment bufring sysctl tree creation Binary state node is added, so that userland programs do not have to parse human readable state string. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7268 303182 hyperv/vmbus: Move vmbus bufring definition to vmbus_reg.h And add more comment about its fields. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7269 Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 03:24:03 2016 (r307461) +++ stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 03:27:23 2016 (r307462) @@ -26,123 +26,154 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include #include #include #include #include "hv_vmbus_priv.h" +#include /* Amount of space to write to */ -#define HV_BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r))? \ - ((z) - ((w) - (r))):((r) - (w)) +#define HV_BYTES_AVAIL_TO_WRITE(r, w, z) \ + ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) + +static uint32_t copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, + uint32_t start_write_offset, const uint8_t *src, + uint32_t src_len); +static uint32_t copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, + char *dest, uint32_t dest_len, uint32_t start_read_offset); static int -hv_rbi_sysctl_stats(SYSCTL_HANDLER_ARGS) +vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS) +{ + const hv_vmbus_ring_buffer_info *br = arg1; + uint32_t rindex, windex, intr_mask, ravail, wavail; + char state[256]; + + rindex = br->ring_buffer->br_rindex; + windex = br->ring_buffer->br_windex; + intr_mask = br->ring_buffer->br_imask; + wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); + ravail = br->ring_data_size - wavail; + + snprintf(state, sizeof(state), + "rindex:%u windex:%u intr_mask:%u ravail:%u wavail:%u", + rindex, windex, intr_mask, ravail, wavail); + return sysctl_handle_string(oidp, state, sizeof(state), req); +} + +/* + * Binary bufring states. + */ +static int +vmbus_br_sysctl_state_bin(SYSCTL_HANDLER_ARGS) { - hv_vmbus_ring_buffer_info* rbi; - uint32_t read_index, write_index, interrupt_mask, sz; - uint32_t read_avail, write_avail; - char rbi_stats[256]; - - rbi = (hv_vmbus_ring_buffer_info*)arg1; - read_index = rbi->ring_buffer->read_index; - write_index = rbi->ring_buffer->write_index; - interrupt_mask = rbi->ring_buffer->interrupt_mask; - sz = rbi->ring_data_size; - write_avail = HV_BYTES_AVAIL_TO_WRITE(read_index, - write_index, sz); - read_avail = sz - write_avail; - snprintf(rbi_stats, sizeof(rbi_stats), - "r_idx:%d " - "w_idx:%d " - "int_mask:%d " - "r_avail:%d " - "w_avail:%d", - read_index, write_index, interrupt_mask, - read_avail, write_avail); +#define BR_STATE_RIDX 0 +#define BR_STATE_WIDX 1 +#define BR_STATE_IMSK 2 +#define BR_STATE_RSPC 3 +#define BR_STATE_WSPC 4 +#define BR_STATE_MAX 5 + + const hv_vmbus_ring_buffer_info *br = arg1; + uint32_t rindex, windex, wavail, state[BR_STATE_MAX]; + + rindex = br->ring_buffer->br_rindex; + windex = br->ring_buffer->br_windex; + wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); + + state[BR_STATE_RIDX] = rindex; + state[BR_STATE_WIDX] = windex; + state[BR_STATE_IMSK] = br->ring_buffer->br_imask; + state[BR_STATE_WSPC] = wavail; + state[BR_STATE_RSPC] = br->ring_data_size - wavail; - return (sysctl_handle_string(oidp, rbi_stats, - sizeof(rbi_stats), req)); + return sysctl_handle_opaque(oidp, state, sizeof(state), req); } void -hv_ring_buffer_stat( - struct sysctl_ctx_list *ctx, - struct sysctl_oid_list *tree_node, - hv_vmbus_ring_buffer_info *rbi, - const char *desc) -{ - SYSCTL_ADD_PROC(ctx, tree_node, OID_AUTO, - "ring_buffer_stats", - CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE, rbi, 0, - hv_rbi_sysctl_stats, "A", desc); +vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, + hv_vmbus_ring_buffer_info *br, const char *name) +{ + struct sysctl_oid *tree; + char desc[64]; + + tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(br_tree), OID_AUTO, + name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (tree == NULL) + return; + + snprintf(desc, sizeof(desc), "%s state", name); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + br, 0, vmbus_br_sysctl_state, "A", desc); + + snprintf(desc, sizeof(desc), "%s binary state", name); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state_bin", + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, + br, 0, vmbus_br_sysctl_state_bin, "IU", desc); } + /** * @brief Get number of bytes available to read and to write to * for the specified ring buffer */ -static inline void -get_ring_buffer_avail_bytes( - hv_vmbus_ring_buffer_info* rbi, - uint32_t* read, - uint32_t* write) +static __inline void +get_ring_buffer_avail_bytes(hv_vmbus_ring_buffer_info *rbi, uint32_t *read, + uint32_t *write) { uint32_t read_loc, write_loc; /* * Capture the read/write indices before they changed */ - read_loc = rbi->ring_buffer->read_index; - write_loc = rbi->ring_buffer->write_index; + read_loc = rbi->ring_buffer->br_rindex; + write_loc = rbi->ring_buffer->br_windex; - *write = HV_BYTES_AVAIL_TO_WRITE( - read_loc, write_loc, rbi->ring_data_size); + *write = HV_BYTES_AVAIL_TO_WRITE(read_loc, write_loc, + rbi->ring_data_size); *read = rbi->ring_data_size - *write; } /** * @brief Get the next write location for the specified ring buffer */ -static inline uint32_t -get_next_write_location(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint32_t +get_next_write_location(hv_vmbus_ring_buffer_info *ring_info) { - uint32_t next = ring_info->ring_buffer->write_index; - return (next); + return ring_info->ring_buffer->br_windex; } /** * @brief Set the next write location for the specified ring buffer */ -static inline void -set_next_write_location( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t next_write_location) +static __inline void +set_next_write_location(hv_vmbus_ring_buffer_info *ring_info, + uint32_t next_write_location) { - ring_info->ring_buffer->write_index = next_write_location; + ring_info->ring_buffer->br_windex = next_write_location; } /** * @brief Get the next read location for the specified ring buffer */ -static inline uint32_t -get_next_read_location(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint32_t +get_next_read_location(hv_vmbus_ring_buffer_info *ring_info) { - uint32_t next = ring_info->ring_buffer->read_index; - return (next); + return ring_info->ring_buffer->br_rindex; } /** * @brief Get the next read location + offset for the specified ring buffer. * This allows the caller to skip. */ -static inline uint32_t -get_next_read_location_with_offset( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t offset) +static __inline uint32_t +get_next_read_location_with_offset(hv_vmbus_ring_buffer_info *ring_info, + uint32_t offset) { - uint32_t next = ring_info->ring_buffer->read_index; + uint32_t next = ring_info->ring_buffer->br_rindex; + next += offset; next %= ring_info->ring_data_size; return (next); @@ -151,28 +182,27 @@ get_next_read_location_with_offset( /** * @brief Set the next read location for the specified ring buffer */ -static inline void -set_next_read_location( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t next_read_location) +static __inline void +set_next_read_location(hv_vmbus_ring_buffer_info *ring_info, + uint32_t next_read_location) { - ring_info->ring_buffer->read_index = next_read_location; + ring_info->ring_buffer->br_rindex = next_read_location; } /** * @brief Get the start of the ring buffer */ -static inline void * -get_ring_buffer(hv_vmbus_ring_buffer_info* ring_info) +static __inline void * +get_ring_buffer(hv_vmbus_ring_buffer_info *ring_info) { - return (void *) ring_info->ring_buffer->buffer; + return ring_info->ring_buffer->br_data; } /** * @brief Get the size of the ring buffer. */ -static inline uint32_t -get_ring_buffer_size(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint32_t +get_ring_buffer_size(hv_vmbus_ring_buffer_info *ring_info) { return ring_info->ring_data_size; } @@ -180,27 +210,25 @@ get_ring_buffer_size(hv_vmbus_ring_buffe /** * Get the read and write indices as uint64_t of the specified ring buffer. */ -static inline uint64_t -get_ring_buffer_indices(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint64_t +get_ring_buffer_indices(hv_vmbus_ring_buffer_info *ring_info) { - return (uint64_t) ring_info->ring_buffer->write_index << 32; + return ((uint64_t)ring_info->ring_buffer->br_windex) << 32; } void -hv_ring_buffer_read_begin( - hv_vmbus_ring_buffer_info* ring_info) +hv_ring_buffer_read_begin(hv_vmbus_ring_buffer_info *ring_info) { - ring_info->ring_buffer->interrupt_mask = 1; + ring_info->ring_buffer->br_imask = 1; mb(); } uint32_t -hv_ring_buffer_read_end( - hv_vmbus_ring_buffer_info* ring_info) +hv_ring_buffer_read_end(hv_vmbus_ring_buffer_info *ring_info) { - uint32_t read, write; + uint32_t read, write; - ring_info->ring_buffer->interrupt_mask = 0; + ring_info->ring_buffer->br_imask = 0; mb(); /* @@ -209,7 +237,6 @@ hv_ring_buffer_read_end( * incoming messages. */ get_ring_buffer_avail_bytes(ring_info, &read, &write); - return (read); } @@ -229,12 +256,11 @@ hv_ring_buffer_read_end( * arrived. */ static boolean_t -hv_ring_buffer_needsig_on_write( - uint32_t old_write_location, - hv_vmbus_ring_buffer_info* rbi) +hv_ring_buffer_needsig_on_write(uint32_t old_write_location, + hv_vmbus_ring_buffer_info *rbi) { mb(); - if (rbi->ring_buffer->interrupt_mask) + if (rbi->ring_buffer->br_imask) return (FALSE); /* Read memory barrier */ @@ -243,41 +269,26 @@ hv_ring_buffer_needsig_on_write( * This is the only case we need to signal when the * ring transitions from being empty to non-empty. */ - if (old_write_location == rbi->ring_buffer->read_index) + if (old_write_location == rbi->ring_buffer->br_rindex) return (TRUE); return (FALSE); } -static uint32_t copy_to_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t start_write_offset, - const uint8_t *src, - uint32_t src_len); - -static uint32_t copy_from_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - char* dest, - uint32_t dest_len, - uint32_t start_read_offset); - /** * @brief Initialize the ring buffer. */ int -hv_vmbus_ring_buffer_init( - hv_vmbus_ring_buffer_info* ring_info, - void* buffer, - uint32_t buffer_len) +hv_vmbus_ring_buffer_init(hv_vmbus_ring_buffer_info *ring_info, void *buffer, + uint32_t buffer_len) { memset(ring_info, 0, sizeof(hv_vmbus_ring_buffer_info)); - ring_info->ring_buffer = (hv_vmbus_ring_buffer*) buffer; - ring_info->ring_buffer->read_index = - ring_info->ring_buffer->write_index = 0; - - ring_info->ring_data_size = buffer_len - sizeof(hv_vmbus_ring_buffer); + ring_info->ring_buffer = buffer; + ring_info->ring_buffer->br_rindex = 0; + ring_info->ring_buffer->br_windex = 0; + ring_info->ring_data_size = buffer_len - sizeof(struct vmbus_bufring); mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN); return (0); @@ -286,7 +297,8 @@ hv_vmbus_ring_buffer_init( /** * @brief Cleanup the ring buffer. */ -void hv_ring_buffer_cleanup(hv_vmbus_ring_buffer_info* ring_info) +void +hv_ring_buffer_cleanup(hv_vmbus_ring_buffer_info *ring_info) { mtx_destroy(&ring_info->ring_lock); } @@ -295,24 +307,19 @@ void hv_ring_buffer_cleanup(hv_vmbus_rin * @brief Write to the ring buffer. */ int -hv_ring_buffer_write( - hv_vmbus_ring_buffer_info* out_ring_info, - const struct iovec iov[], - uint32_t iovlen, - boolean_t *need_sig) +hv_ring_buffer_write(hv_vmbus_ring_buffer_info *out_ring_info, + const struct iovec iov[], uint32_t iovlen, boolean_t *need_sig) { int i = 0; uint32_t byte_avail_to_write; uint32_t byte_avail_to_read; uint32_t old_write_location; uint32_t total_bytes_to_write = 0; - volatile uint32_t next_write_location; uint64_t prev_indices = 0; - for (i = 0; i < iovlen; i++) { - total_bytes_to_write += iov[i].iov_len; - } + for (i = 0; i < iovlen; i++) + total_bytes_to_write += iov[i].iov_len; total_bytes_to_write += sizeof(uint64_t); @@ -326,11 +333,9 @@ hv_ring_buffer_write( * Otherwise, the next time around, we think the ring buffer * is empty since the read index == write index */ - if (byte_avail_to_write <= total_bytes_to_write) { - - mtx_unlock_spin(&out_ring_info->ring_lock); - return (EAGAIN); + mtx_unlock_spin(&out_ring_info->ring_lock); + return (EAGAIN); } /* @@ -341,8 +346,8 @@ hv_ring_buffer_write( old_write_location = next_write_location; for (i = 0; i < iovlen; i++) { - next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, iov[i].iov_base, iov[i].iov_len); + next_write_location = copy_to_ring_buffer(out_ring_info, + next_write_location, iov[i].iov_base, iov[i].iov_len); } /* @@ -350,9 +355,8 @@ hv_ring_buffer_write( */ prev_indices = get_ring_buffer_indices(out_ring_info); - next_write_location = copy_to_ring_buffer( - out_ring_info, next_write_location, - (char *) &prev_indices, sizeof(uint64_t)); + next_write_location = copy_to_ring_buffer(out_ring_info, + next_write_location, (char *)&prev_indices, sizeof(uint64_t)); /* * Full memory barrier before upding the write index. @@ -376,10 +380,8 @@ hv_ring_buffer_write( * @brief Read without advancing the read index. */ int -hv_ring_buffer_peek( - hv_vmbus_ring_buffer_info* in_ring_info, - void* buffer, - uint32_t buffer_len) +hv_ring_buffer_peek(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, + uint32_t buffer_len) { uint32_t bytesAvailToWrite; uint32_t bytesAvailToRead; @@ -388,14 +390,14 @@ hv_ring_buffer_peek( mtx_lock_spin(&in_ring_info->ring_lock); get_ring_buffer_avail_bytes(in_ring_info, &bytesAvailToRead, - &bytesAvailToWrite); + &bytesAvailToWrite); /* * Make sure there is something to read */ if (bytesAvailToRead < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); - return (EAGAIN); + mtx_unlock_spin(&in_ring_info->ring_lock); + return (EAGAIN); } /* @@ -403,8 +405,8 @@ hv_ring_buffer_peek( */ nextReadLocation = get_next_read_location(in_ring_info); - nextReadLocation = copy_from_ring_buffer( - in_ring_info, (char *)buffer, buffer_len, nextReadLocation); + nextReadLocation = copy_from_ring_buffer(in_ring_info, + (char *)buffer, buffer_len, nextReadLocation); mtx_unlock_spin(&in_ring_info->ring_lock); @@ -415,11 +417,8 @@ hv_ring_buffer_peek( * @brief Read and advance the read index. */ int -hv_ring_buffer_read( - hv_vmbus_ring_buffer_info* in_ring_info, - void* buffer, - uint32_t buffer_len, - uint32_t offset) +hv_ring_buffer_read(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, + uint32_t buffer_len, uint32_t offset) { uint32_t bytes_avail_to_write; uint32_t bytes_avail_to_read; @@ -427,37 +426,29 @@ hv_ring_buffer_read( uint64_t prev_indices = 0; if (buffer_len <= 0) - return (EINVAL); + return (EINVAL); mtx_lock_spin(&in_ring_info->ring_lock); - get_ring_buffer_avail_bytes( - in_ring_info, &bytes_avail_to_read, + get_ring_buffer_avail_bytes(in_ring_info, &bytes_avail_to_read, &bytes_avail_to_write); /* * Make sure there is something to read */ if (bytes_avail_to_read < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); - return (EAGAIN); + mtx_unlock_spin(&in_ring_info->ring_lock); + return (EAGAIN); } - next_read_location = get_next_read_location_with_offset( - in_ring_info, + next_read_location = get_next_read_location_with_offset(in_ring_info, offset); - next_read_location = copy_from_ring_buffer( - in_ring_info, - (char *) buffer, - buffer_len, - next_read_location); - - next_read_location = copy_from_ring_buffer( - in_ring_info, - (char *) &prev_indices, - sizeof(uint64_t), - next_read_location); + next_read_location = copy_from_ring_buffer(in_ring_info, (char *)buffer, + buffer_len, next_read_location); + + next_read_location = copy_from_ring_buffer(in_ring_info, + (char *)&prev_indices, sizeof(uint64_t), next_read_location); /* * Make sure all reads are done before we update the read index since @@ -482,23 +473,20 @@ hv_ring_buffer_read( * Assume there is enough room. Handles wrap-around in dest case only! */ static uint32_t -copy_to_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t start_write_offset, - const uint8_t *src, - uint32_t src_len) +copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, + uint32_t start_write_offset, const uint8_t *src, uint32_t src_len) { char *ring_buffer = get_ring_buffer(ring_info); uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); uint32_t fragLen; - if (src_len > ring_buffer_size - start_write_offset) { - /* wrap-around detected! */ - fragLen = ring_buffer_size - start_write_offset; - memcpy(ring_buffer + start_write_offset, src, fragLen); - memcpy(ring_buffer, src + fragLen, src_len - fragLen); + if (src_len > ring_buffer_size - start_write_offset) { + /* wrap-around detected! */ + fragLen = ring_buffer_size - start_write_offset; + memcpy(ring_buffer + start_write_offset, src, fragLen); + memcpy(ring_buffer, src + fragLen, src_len - fragLen); } else { - memcpy(ring_buffer + start_write_offset, src, src_len); + memcpy(ring_buffer + start_write_offset, src, src_len); } start_write_offset += src_len; @@ -512,24 +500,21 @@ copy_to_ring_buffer( * * Assume there is enough room. Handles wrap-around in src case only! */ -uint32_t -copy_from_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - char* dest, - uint32_t dest_len, - uint32_t start_read_offset) +static uint32_t +copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, char *dest, + uint32_t dest_len, uint32_t start_read_offset) { uint32_t fragLen; char *ring_buffer = get_ring_buffer(ring_info); uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); if (dest_len > ring_buffer_size - start_read_offset) { - /* wrap-around detected at the src */ - fragLen = ring_buffer_size - start_read_offset; - memcpy(dest, ring_buffer + start_read_offset, fragLen); - memcpy(dest + fragLen, ring_buffer, dest_len - fragLen); + /* wrap-around detected at the src */ + fragLen = ring_buffer_size - start_read_offset; + memcpy(dest, ring_buffer + start_read_offset, fragLen); + memcpy(dest + fragLen, ring_buffer, dest_len - fragLen); } else { - memcpy(dest, ring_buffer + start_read_offset, dest_len); + memcpy(dest, ring_buffer + start_read_offset, dest_len); } start_read_offset += dest_len; @@ -537,4 +522,3 @@ copy_from_ring_buffer( return (start_read_offset); } - Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 03:24:03 2016 (r307461) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Oct 17 03:27:23 2016 (r307462) @@ -45,13 +45,11 @@ struct vmbus_softc; * Private, VM Bus functions */ struct sysctl_ctx_list; -struct sysctl_oid_list; +struct sysctl_oid; -void hv_ring_buffer_stat( - struct sysctl_ctx_list *ctx, - struct sysctl_oid_list *tree_node, - hv_vmbus_ring_buffer_info *rbi, - const char *desc); +void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, + struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br, + const char *name); int hv_vmbus_ring_buffer_init( hv_vmbus_ring_buffer_info *ring_info, Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:24:03 2016 (r307461) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:27:23 2016 (r307462) @@ -171,24 +171,17 @@ vmbus_chan_sysctl_create(struct vmbus_ch chan, 0, vmbus_chan_sysctl_mnf, "I", "has monitor notification facilities"); - /* - * Create sysctl tree for RX bufring. - */ - br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, - "in", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - if (br_tree != NULL) { - hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), - &chan->ch_rxbr, "inbound ring buffer stats"); - } - - /* - * Create sysctl tree for TX bufring. - */ br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, - "out", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + "br", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); if (br_tree != NULL) { - hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), - &chan->ch_txbr, "outbound ring buffer stats"); + /* + * Create sysctl tree for RX bufring. + */ + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_rxbr, "rx"); + /* + * Create sysctl tree for TX bufring. + */ + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_txbr, "tx"); } } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Mon Oct 17 03:24:03 2016 (r307461) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Mon Oct 17 03:27:23 2016 (r307462) @@ -41,31 +41,7 @@ #include typedef struct { - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t write_index; - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t read_index; - /* - * NOTE: The interrupt_mask field is used only for channels, but - * vmbus connection also uses this data structure - */ - volatile uint32_t interrupt_mask; - /* pad it to PAGE_SIZE so that data starts on a page */ - uint8_t reserved[4084]; - - /* - * WARNING: Ring data starts here - * !!! DO NOT place any fields below this !!! - */ - uint8_t buffer[0]; /* doubles as interrupt mask */ -} __packed hv_vmbus_ring_buffer; - -typedef struct { - hv_vmbus_ring_buffer* ring_buffer; + struct vmbus_bufring *ring_buffer; struct mtx ring_lock; uint32_t ring_data_size; /* ring_size */ } hv_vmbus_ring_buffer_info; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 03:24:03 2016 (r307461) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 03:27:23 2016 (r307462) @@ -102,6 +102,37 @@ struct vmbus_mnf { CTASSERT(sizeof(struct vmbus_mnf) == PAGE_SIZE); /* + * Buffer ring + */ +struct vmbus_bufring { + /* + * If br_windex == br_rindex, this bufring is empty; this + * means we can _not_ write data to the bufring, if the + * write is going to make br_windex same as br_rindex. + */ + volatile uint32_t br_windex; + volatile uint32_t br_rindex; + + /* + * Interrupt mask {0,1} + * + * For TX bufring, host set this to 1, when it is processing + * the TX bufring, so that we can safely skip the TX event + * notification to host. + * + * For RX bufring, once this is set to 1 by us, host will not + * further dispatch interrupts to us, even if there are data + * pending on the RX bufring. This effectively disables the + * interrupt of the channel to which this RX bufring is attached. + */ + volatile uint32_t br_imask; + + uint8_t br_rsvd[4084]; + uint8_t br_data[]; +} __packed; +CTASSERT(sizeof(struct vmbus_bufring) == PAGE_SIZE); + +/* * Channel */ From owner-svn-src-stable@freebsd.org Mon Oct 17 03:29:33 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E9F5C14AA7; Mon, 17 Oct 2016 03:29:33 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 215BF15B7; Mon, 17 Oct 2016 03:29:33 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H3TWQC017155; Mon, 17 Oct 2016 03:29:32 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H3TVXw017148; Mon, 17 Oct 2016 03:29:31 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170329.u9H3TVXw017148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:29:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307463 - in stable/11/sys/dev/hyperv: netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:29:33 -0000 Author: sephe Date: Mon Oct 17 03:29:31 2016 New Revision: 307463 URL: https://svnweb.freebsd.org/changeset/base/307463 Log: MFC 303283 hyperv/vmbus: Rename hv_vmbus_priv.h to vmbus_brvar.h It only contains bufring related bits for a while. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7281 Added: stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h - copied unchanged from r303283, head/sys/dev/hyperv/vmbus/vmbus_brvar.h Deleted: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 03:27:23 2016 (r307462) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 03:29:31 2016 (r307463) @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include "hv_net_vsc.h" #include "hv_rndis.h" #include "hv_rndis_filter.h" Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 03:27:23 2016 (r307462) +++ stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 03:29:31 2016 (r307463) @@ -31,8 +31,8 @@ #include #include -#include "hv_vmbus_priv.h" #include +#include /* Amount of space to write to */ #define HV_BYTES_AVAIL_TO_WRITE(r, w, z) \ Modified: stable/11/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv.c Mon Oct 17 03:27:23 2016 (r307462) +++ stable/11/sys/dev/hyperv/vmbus/hyperv.c Mon Oct 17 03:29:31 2016 (r307463) @@ -43,12 +43,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include -#include #include #include #include +#if 0 #include +#endif #define HYPERV_FREEBSD_BUILD 0ULL #define HYPERV_FREEBSD_VERSION ((uint64_t)__FreeBSD_version) Modified: stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Mon Oct 17 03:27:23 2016 (r307462) +++ stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Mon Oct 17 03:29:31 2016 (r307463) @@ -30,6 +30,7 @@ #define _HYPERV_REG_H_ #include +#include /* * Hyper-V Synthetic MSRs Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 03:27:23 2016 (r307462) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 03:29:31 2016 (r307463) @@ -60,11 +60,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include #include +#include #include #include "acpi_if.h" Copied: stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h (from r303283, head/sys/dev/hyperv/vmbus/vmbus_brvar.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Oct 17 03:29:31 2016 (r307463, copy of r303283, head/sys/dev/hyperv/vmbus/vmbus_brvar.h) @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2012 NetApp Inc. + * Copyright (c) 2012 Citrix Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __HYPERV_PRIV_H__ +#define __HYPERV_PRIV_H__ + +#include +#include +#include +#include +#include + +#include + +struct vmbus_softc; + +/* + * Private, VM Bus functions + */ +struct sysctl_ctx_list; +struct sysctl_oid; + +void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, + struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br, + const char *name); + +int hv_vmbus_ring_buffer_init( + hv_vmbus_ring_buffer_info *ring_info, + void *buffer, + uint32_t buffer_len); + +void hv_ring_buffer_cleanup( + hv_vmbus_ring_buffer_info *ring_info); + +int hv_ring_buffer_write( + hv_vmbus_ring_buffer_info *ring_info, + const struct iovec iov[], + uint32_t iovlen, + boolean_t *need_sig); + +int hv_ring_buffer_peek( + hv_vmbus_ring_buffer_info *ring_info, + void *buffer, + uint32_t buffer_len); + +int hv_ring_buffer_read( + hv_vmbus_ring_buffer_info *ring_info, + void *buffer, + uint32_t buffer_len, + uint32_t offset); + +void hv_ring_buffer_read_begin( + hv_vmbus_ring_buffer_info *ring_info); + +uint32_t hv_ring_buffer_read_end( + hv_vmbus_ring_buffer_info *ring_info); + +#endif /* __HYPERV_PRIV_H__ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:27:23 2016 (r307462) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:29:31 2016 (r307463) @@ -46,10 +46,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include +#include +#include static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct vmbus_channel *); From owner-svn-src-stable@freebsd.org Mon Oct 17 03:35:22 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31884C14D2C; Mon, 17 Oct 2016 03:35:22 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C820D19FA; Mon, 17 Oct 2016 03:35:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H3ZLXg020792; Mon, 17 Oct 2016 03:35:21 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H3ZKFK020788; Mon, 17 Oct 2016 03:35:20 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170335.u9H3ZKFK020788@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:35:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307464 - stable/11/sys/dev/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:35:22 -0000 Author: sephe Date: Mon Oct 17 03:35:20 2016 New Revision: 307464 URL: https://svnweb.freebsd.org/changeset/base/307464 Log: MFC 303284,303329,303361,303362,303366,303368-303370 303284 hyperv/vmbus: Move bufring info definition to vmbus_brvar.h Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7282 303329 hyperv/vmbus: Nuke unnecessary accessor functions. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7303 303361 hyperv/vmbus: Initialize RX/TX bufring mutex at channel creation time Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7312 303362 hyperv/vmbus: Use different struct for RX/TX bufring. So that they can use suitable MP synchronization mechanism. While I'm here change the bufring init/read/write function names. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7313 303366 hyperv/vmbus: Update comment for bufring Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7314 303368 hyperv/vmbus: Cleanup TX bufring write process. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7315 303369 hyperv/vmbus: Stringent RX bufring data length checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7316 303370 hyperv/vmbus: Cleanup RX bufring read process. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7317 Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 03:29:31 2016 (r307463) +++ stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Mon Oct 17 03:35:20 2016 (r307464) @@ -34,32 +34,29 @@ #include #include -/* Amount of space to write to */ -#define HV_BYTES_AVAIL_TO_WRITE(r, w, z) \ - ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) - -static uint32_t copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, - uint32_t start_write_offset, const uint8_t *src, - uint32_t src_len); -static uint32_t copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, - char *dest, uint32_t dest_len, uint32_t start_read_offset); +/* Amount of space available for write */ +#define VMBUS_BR_WAVAIL(r, w, z) \ + (((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w))) + +/* Increase bufing index */ +#define VMBUS_BR_IDXINC(idx, inc, sz) (((idx) + (inc)) % (sz)) static int vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS) { - const hv_vmbus_ring_buffer_info *br = arg1; - uint32_t rindex, windex, intr_mask, ravail, wavail; + const struct vmbus_br *br = arg1; + uint32_t rindex, windex, imask, ravail, wavail; char state[256]; - rindex = br->ring_buffer->br_rindex; - windex = br->ring_buffer->br_windex; - intr_mask = br->ring_buffer->br_imask; - wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); - ravail = br->ring_data_size - wavail; + rindex = br->vbr_rindex; + windex = br->vbr_windex; + imask = br->vbr_imask; + wavail = VMBUS_BR_WAVAIL(rindex, windex, br->vbr_dsize); + ravail = br->vbr_dsize - wavail; snprintf(state, sizeof(state), - "rindex:%u windex:%u intr_mask:%u ravail:%u wavail:%u", - rindex, windex, intr_mask, ravail, wavail); + "rindex:%u windex:%u imask:%u ravail:%u wavail:%u", + rindex, windex, imask, ravail, wavail); return sysctl_handle_string(oidp, state, sizeof(state), req); } @@ -76,25 +73,25 @@ vmbus_br_sysctl_state_bin(SYSCTL_HANDLER #define BR_STATE_WSPC 4 #define BR_STATE_MAX 5 - const hv_vmbus_ring_buffer_info *br = arg1; + const struct vmbus_br *br = arg1; uint32_t rindex, windex, wavail, state[BR_STATE_MAX]; - rindex = br->ring_buffer->br_rindex; - windex = br->ring_buffer->br_windex; - wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); + rindex = br->vbr_rindex; + windex = br->vbr_windex; + wavail = VMBUS_BR_WAVAIL(rindex, windex, br->vbr_dsize); state[BR_STATE_RIDX] = rindex; state[BR_STATE_WIDX] = windex; - state[BR_STATE_IMSK] = br->ring_buffer->br_imask; + state[BR_STATE_IMSK] = br->vbr_imask; state[BR_STATE_WSPC] = wavail; - state[BR_STATE_RSPC] = br->ring_data_size - wavail; + state[BR_STATE_RSPC] = br->vbr_dsize - wavail; return sysctl_handle_opaque(oidp, state, sizeof(state), req); } void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, - hv_vmbus_ring_buffer_info *br, const char *name) + struct vmbus_br *br, const char *name) { struct sysctl_oid *tree; char desc[64]; @@ -115,342 +112,291 @@ vmbus_br_sysctl_create(struct sysctl_ctx br, 0, vmbus_br_sysctl_state_bin, "IU", desc); } -/** - * @brief Get number of bytes available to read and to write to - * for the specified ring buffer - */ -static __inline void -get_ring_buffer_avail_bytes(hv_vmbus_ring_buffer_info *rbi, uint32_t *read, - uint32_t *write) +void +vmbus_rxbr_intr_mask(struct vmbus_rxbr *rbr) { - uint32_t read_loc, write_loc; - - /* - * Capture the read/write indices before they changed - */ - read_loc = rbi->ring_buffer->br_rindex; - write_loc = rbi->ring_buffer->br_windex; - - *write = HV_BYTES_AVAIL_TO_WRITE(read_loc, write_loc, - rbi->ring_data_size); - *read = rbi->ring_data_size - *write; + rbr->rxbr_imask = 1; + mb(); } -/** - * @brief Get the next write location for the specified ring buffer - */ static __inline uint32_t -get_next_write_location(hv_vmbus_ring_buffer_info *ring_info) +vmbus_rxbr_avail(const struct vmbus_rxbr *rbr) { - return ring_info->ring_buffer->br_windex; -} + uint32_t rindex, windex; -/** - * @brief Set the next write location for the specified ring buffer - */ -static __inline void -set_next_write_location(hv_vmbus_ring_buffer_info *ring_info, - uint32_t next_write_location) -{ - ring_info->ring_buffer->br_windex = next_write_location; -} + /* Get snapshot */ + rindex = rbr->rxbr_rindex; + windex = rbr->rxbr_windex; -/** - * @brief Get the next read location for the specified ring buffer - */ -static __inline uint32_t -get_next_read_location(hv_vmbus_ring_buffer_info *ring_info) -{ - return ring_info->ring_buffer->br_rindex; + return (rbr->rxbr_dsize - + VMBUS_BR_WAVAIL(rindex, windex, rbr->rxbr_dsize)); } -/** - * @brief Get the next read location + offset for the specified ring buffer. - * This allows the caller to skip. - */ -static __inline uint32_t -get_next_read_location_with_offset(hv_vmbus_ring_buffer_info *ring_info, - uint32_t offset) +uint32_t +vmbus_rxbr_intr_unmask(struct vmbus_rxbr *rbr) { - uint32_t next = ring_info->ring_buffer->br_rindex; + rbr->rxbr_imask = 0; + mb(); - next += offset; - next %= ring_info->ring_data_size; - return (next); + /* + * Now check to see if the ring buffer is still empty. + * If it is not, we raced and we need to process new + * incoming channel packets. + */ + return vmbus_rxbr_avail(rbr); } -/** - * @brief Set the next read location for the specified ring buffer - */ -static __inline void -set_next_read_location(hv_vmbus_ring_buffer_info *ring_info, - uint32_t next_read_location) +static void +vmbus_br_setup(struct vmbus_br *br, void *buf, int blen) { - ring_info->ring_buffer->br_rindex = next_read_location; + br->vbr = buf; + br->vbr_dsize = blen - sizeof(struct vmbus_bufring); } -/** - * @brief Get the start of the ring buffer - */ -static __inline void * -get_ring_buffer(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_rxbr_init(struct vmbus_rxbr *rbr) { - return ring_info->ring_buffer->br_data; + mtx_init(&rbr->rxbr_lock, "vmbus_rxbr", NULL, MTX_SPIN); } -/** - * @brief Get the size of the ring buffer. - */ -static __inline uint32_t -get_ring_buffer_size(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_rxbr_deinit(struct vmbus_rxbr *rbr) { - return ring_info->ring_data_size; + mtx_destroy(&rbr->rxbr_lock); } -/** - * Get the read and write indices as uint64_t of the specified ring buffer. - */ -static __inline uint64_t -get_ring_buffer_indices(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_rxbr_setup(struct vmbus_rxbr *rbr, void *buf, int blen) { - return ((uint64_t)ring_info->ring_buffer->br_windex) << 32; + vmbus_br_setup(&rbr->rxbr, buf, blen); } void -hv_ring_buffer_read_begin(hv_vmbus_ring_buffer_info *ring_info) +vmbus_txbr_init(struct vmbus_txbr *tbr) { - ring_info->ring_buffer->br_imask = 1; - mb(); + mtx_init(&tbr->txbr_lock, "vmbus_txbr", NULL, MTX_SPIN); } -uint32_t -hv_ring_buffer_read_end(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_txbr_deinit(struct vmbus_txbr *tbr) { - uint32_t read, write; - - ring_info->ring_buffer->br_imask = 0; - mb(); + mtx_destroy(&tbr->txbr_lock); +} - /* - * Now check to see if the ring buffer is still empty. - * If it is not, we raced and we need to process new - * incoming messages. - */ - get_ring_buffer_avail_bytes(ring_info, &read, &write); - return (read); +void +vmbus_txbr_setup(struct vmbus_txbr *tbr, void *buf, int blen) +{ + vmbus_br_setup(&tbr->txbr, buf, blen); } /* - * When we write to the ring buffer, check if the host needs to - * be signaled. Here is the details of this protocol: - * - * 1. The host guarantees that while it is draining the - * ring buffer, it will set the interrupt_mask to - * indicate it does not need to be interrupted when - * new data is placed. + * When we write to the ring buffer, check if the host needs to be + * signaled. * - * 2. The host guarantees that it will completely drain - * the ring buffer before exiting the read loop. Further, - * once the ring buffer is empty, it will clear the - * interrupt_mask and re-check to see if new data has - * arrived. + * The contract: + * - The host guarantees that while it is draining the TX bufring, + * it will set the br_imask to indicate it does not need to be + * interrupted when new data are added. + * - The host guarantees that it will completely drain the TX bufring + * before exiting the read loop. Further, once the TX bufring is + * empty, it will clear the br_imask and re-check to see if new + * data have arrived. */ -static boolean_t -hv_ring_buffer_needsig_on_write(uint32_t old_write_location, - hv_vmbus_ring_buffer_info *rbi) +static __inline boolean_t +vmbus_txbr_need_signal(const struct vmbus_txbr *tbr, uint32_t old_windex) { mb(); - if (rbi->ring_buffer->br_imask) + if (tbr->txbr_imask) return (FALSE); + /* XXX only compiler fence is needed */ /* Read memory barrier */ rmb(); + /* * This is the only case we need to signal when the * ring transitions from being empty to non-empty. */ - if (old_write_location == rbi->ring_buffer->br_rindex) + if (old_windex == tbr->txbr_rindex) return (TRUE); return (FALSE); } -/** - * @brief Initialize the ring buffer. - */ -int -hv_vmbus_ring_buffer_init(hv_vmbus_ring_buffer_info *ring_info, void *buffer, - uint32_t buffer_len) +static __inline uint32_t +vmbus_txbr_avail(const struct vmbus_txbr *tbr) { - memset(ring_info, 0, sizeof(hv_vmbus_ring_buffer_info)); - - ring_info->ring_buffer = buffer; - ring_info->ring_buffer->br_rindex = 0; - ring_info->ring_buffer->br_windex = 0; + uint32_t rindex, windex; - ring_info->ring_data_size = buffer_len - sizeof(struct vmbus_bufring); - mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN); + /* Get snapshot */ + rindex = tbr->txbr_rindex; + windex = tbr->txbr_windex; - return (0); + return VMBUS_BR_WAVAIL(rindex, windex, tbr->txbr_dsize); } -/** - * @brief Cleanup the ring buffer. - */ -void -hv_ring_buffer_cleanup(hv_vmbus_ring_buffer_info *ring_info) +static __inline uint32_t +vmbus_txbr_copyto(const struct vmbus_txbr *tbr, uint32_t windex, + const void *src0, uint32_t cplen) { - mtx_destroy(&ring_info->ring_lock); + const uint8_t *src = src0; + uint8_t *br_data = tbr->txbr_data; + uint32_t br_dsize = tbr->txbr_dsize; + + if (cplen > br_dsize - windex) { + uint32_t fraglen = br_dsize - windex; + + /* Wrap-around detected */ + memcpy(br_data + windex, src, fraglen); + memcpy(br_data, src + fraglen, cplen - fraglen); + } else { + memcpy(br_data + windex, src, cplen); + } + return VMBUS_BR_IDXINC(windex, cplen, br_dsize); } -/** - * @brief Write to the ring buffer. +/* + * Write scattered channel packet to TX bufring. + * + * The offset of this channel packet is written as a 64bits value + * immediately after this channel packet. */ int -hv_ring_buffer_write(hv_vmbus_ring_buffer_info *out_ring_info, - const struct iovec iov[], uint32_t iovlen, boolean_t *need_sig) +vmbus_txbr_write(struct vmbus_txbr *tbr, const struct iovec iov[], int iovlen, + boolean_t *need_sig) { - int i = 0; - uint32_t byte_avail_to_write; - uint32_t byte_avail_to_read; - uint32_t old_write_location; - uint32_t total_bytes_to_write = 0; - volatile uint32_t next_write_location; - uint64_t prev_indices = 0; + uint32_t old_windex, windex, total; + uint64_t save_windex; + int i; + total = 0; for (i = 0; i < iovlen; i++) - total_bytes_to_write += iov[i].iov_len; + total += iov[i].iov_len; + total += sizeof(save_windex); - total_bytes_to_write += sizeof(uint64_t); - - mtx_lock_spin(&out_ring_info->ring_lock); - - get_ring_buffer_avail_bytes(out_ring_info, &byte_avail_to_read, - &byte_avail_to_write); + mtx_lock_spin(&tbr->txbr_lock); /* - * If there is only room for the packet, assume it is full. - * Otherwise, the next time around, we think the ring buffer - * is empty since the read index == write index + * NOTE: + * If this write is going to make br_windex same as br_rindex, + * i.e. the available space for write is same as the write size, + * we can't do it then, since br_windex == br_rindex means that + * the bufring is empty. */ - if (byte_avail_to_write <= total_bytes_to_write) { - mtx_unlock_spin(&out_ring_info->ring_lock); + if (vmbus_txbr_avail(tbr) <= total) { + mtx_unlock_spin(&tbr->txbr_lock); return (EAGAIN); } + /* Save br_windex for later use */ + old_windex = tbr->txbr_windex; + /* - * Write to the ring buffer + * Copy the scattered channel packet to the TX bufring. */ - next_write_location = get_next_write_location(out_ring_info); - - old_write_location = next_write_location; - + windex = old_windex; for (i = 0; i < iovlen; i++) { - next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, iov[i].iov_base, iov[i].iov_len); + windex = vmbus_txbr_copyto(tbr, windex, + iov[i].iov_base, iov[i].iov_len); } /* - * Set previous packet start + * Set the offset of the current channel packet. */ - prev_indices = get_ring_buffer_indices(out_ring_info); - - next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, (char *)&prev_indices, sizeof(uint64_t)); + save_windex = ((uint64_t)old_windex) << 32; + windex = vmbus_txbr_copyto(tbr, windex, &save_windex, + sizeof(save_windex)); /* + * XXX only compiler fence is needed. * Full memory barrier before upding the write index. */ mb(); /* - * Now, update the write location + * Update the write index _after_ the channel packet + * is copied. */ - set_next_write_location(out_ring_info, next_write_location); + tbr->txbr_windex = windex; - mtx_unlock_spin(&out_ring_info->ring_lock); + mtx_unlock_spin(&tbr->txbr_lock); - *need_sig = hv_ring_buffer_needsig_on_write(old_write_location, - out_ring_info); + *need_sig = vmbus_txbr_need_signal(tbr, old_windex); return (0); } -/** - * @brief Read without advancing the read index. - */ -int -hv_ring_buffer_peek(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, - uint32_t buffer_len) +static __inline uint32_t +vmbus_rxbr_copyfrom(const struct vmbus_rxbr *rbr, uint32_t rindex, + void *dst0, int cplen) { - uint32_t bytesAvailToWrite; - uint32_t bytesAvailToRead; - uint32_t nextReadLocation = 0; - - mtx_lock_spin(&in_ring_info->ring_lock); + uint8_t *dst = dst0; + const uint8_t *br_data = rbr->rxbr_data; + uint32_t br_dsize = rbr->rxbr_dsize; + + if (cplen > br_dsize - rindex) { + uint32_t fraglen = br_dsize - rindex; + + /* Wrap-around detected. */ + memcpy(dst, br_data + rindex, fraglen); + memcpy(dst + fraglen, br_data, cplen - fraglen); + } else { + memcpy(dst, br_data + rindex, cplen); + } + return VMBUS_BR_IDXINC(rindex, cplen, br_dsize); +} - get_ring_buffer_avail_bytes(in_ring_info, &bytesAvailToRead, - &bytesAvailToWrite); +int +vmbus_rxbr_peek(struct vmbus_rxbr *rbr, void *data, int dlen) +{ + mtx_lock_spin(&rbr->rxbr_lock); /* - * Make sure there is something to read + * The requested data and the 64bits channel packet + * offset should be there at least. */ - if (bytesAvailToRead < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); + if (vmbus_rxbr_avail(rbr) < dlen + sizeof(uint64_t)) { + mtx_unlock_spin(&rbr->rxbr_lock); return (EAGAIN); } + vmbus_rxbr_copyfrom(rbr, rbr->rxbr_rindex, data, dlen); - /* - * Convert to byte offset - */ - nextReadLocation = get_next_read_location(in_ring_info); - - nextReadLocation = copy_from_ring_buffer(in_ring_info, - (char *)buffer, buffer_len, nextReadLocation); - - mtx_unlock_spin(&in_ring_info->ring_lock); + mtx_unlock_spin(&rbr->rxbr_lock); return (0); } -/** - * @brief Read and advance the read index. +/* + * NOTE: + * We assume (dlen + skip) == sizeof(channel packet). */ int -hv_ring_buffer_read(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, - uint32_t buffer_len, uint32_t offset) +vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, uint32_t skip) { - uint32_t bytes_avail_to_write; - uint32_t bytes_avail_to_read; - uint32_t next_read_location = 0; - uint64_t prev_indices = 0; - - if (buffer_len <= 0) - return (EINVAL); + uint32_t rindex, br_dsize = rbr->rxbr_dsize; - mtx_lock_spin(&in_ring_info->ring_lock); + KASSERT(dlen + skip > 0, ("invalid dlen %d, offset %u", dlen, skip)); - get_ring_buffer_avail_bytes(in_ring_info, &bytes_avail_to_read, - &bytes_avail_to_write); + mtx_lock_spin(&rbr->rxbr_lock); - /* - * Make sure there is something to read - */ - if (bytes_avail_to_read < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); + if (vmbus_rxbr_avail(rbr) < dlen + skip + sizeof(uint64_t)) { + mtx_unlock_spin(&rbr->rxbr_lock); return (EAGAIN); } - next_read_location = get_next_read_location_with_offset(in_ring_info, - offset); - - next_read_location = copy_from_ring_buffer(in_ring_info, (char *)buffer, - buffer_len, next_read_location); + /* + * Copy channel packet from RX bufring. + */ + rindex = VMBUS_BR_IDXINC(rbr->rxbr_rindex, skip, br_dsize); + rindex = vmbus_rxbr_copyfrom(rbr, rindex, data, dlen); - next_read_location = copy_from_ring_buffer(in_ring_info, - (char *)&prev_indices, sizeof(uint64_t), next_read_location); + /* + * Discard this channel packet's 64bits offset, which is useless to us. + */ + rindex = VMBUS_BR_IDXINC(rindex, sizeof(uint64_t), br_dsize); /* + * XXX only compiler fence is needed. * Make sure all reads are done before we update the read index since * the writer may start writing to the read area once the read index * is updated. @@ -458,67 +404,11 @@ hv_ring_buffer_read(hv_vmbus_ring_buffer wmb(); /* - * Update the read index + * Update the read index _after_ the channel packet is fetched. */ - set_next_read_location(in_ring_info, next_read_location); + rbr->rxbr_rindex = rindex; - mtx_unlock_spin(&in_ring_info->ring_lock); + mtx_unlock_spin(&rbr->rxbr_lock); return (0); } - -/** - * @brief Helper routine to copy from source to ring buffer. - * - * Assume there is enough room. Handles wrap-around in dest case only! - */ -static uint32_t -copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, - uint32_t start_write_offset, const uint8_t *src, uint32_t src_len) -{ - char *ring_buffer = get_ring_buffer(ring_info); - uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); - uint32_t fragLen; - - if (src_len > ring_buffer_size - start_write_offset) { - /* wrap-around detected! */ - fragLen = ring_buffer_size - start_write_offset; - memcpy(ring_buffer + start_write_offset, src, fragLen); - memcpy(ring_buffer, src + fragLen, src_len - fragLen); - } else { - memcpy(ring_buffer + start_write_offset, src, src_len); - } - - start_write_offset += src_len; - start_write_offset %= ring_buffer_size; - - return (start_write_offset); -} - -/** - * @brief Helper routine to copy to source from ring buffer. - * - * Assume there is enough room. Handles wrap-around in src case only! - */ -static uint32_t -copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, char *dest, - uint32_t dest_len, uint32_t start_read_offset) -{ - uint32_t fragLen; - char *ring_buffer = get_ring_buffer(ring_info); - uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); - - if (dest_len > ring_buffer_size - start_read_offset) { - /* wrap-around detected at the src */ - fragLen = ring_buffer_size - start_read_offset; - memcpy(dest, ring_buffer + start_read_offset, fragLen); - memcpy(dest + fragLen, ring_buffer, dest_len - fragLen); - } else { - memcpy(dest, ring_buffer + start_read_offset, dest_len); - } - - start_read_offset += dest_len; - start_read_offset %= ring_buffer_size; - - return (start_read_offset); -} Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Oct 17 03:29:31 2016 (r307463) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Oct 17 03:35:20 2016 (r307464) @@ -28,58 +28,66 @@ * $FreeBSD$ */ -#ifndef __HYPERV_PRIV_H__ -#define __HYPERV_PRIV_H__ +#ifndef _VMBUS_BRVAR_H_ +#define _VMBUS_BRVAR_H_ #include #include #include -#include #include -#include +struct vmbus_br { + struct vmbus_bufring *vbr; + uint32_t vbr_dsize; /* total data size */ +}; + +#define vbr_windex vbr->br_windex +#define vbr_rindex vbr->br_rindex +#define vbr_imask vbr->br_imask +#define vbr_data vbr->br_data + +struct vmbus_rxbr { + struct mtx rxbr_lock; + struct vmbus_br rxbr; +}; + +#define rxbr_windex rxbr.vbr_windex +#define rxbr_rindex rxbr.vbr_rindex +#define rxbr_imask rxbr.vbr_imask +#define rxbr_data rxbr.vbr_data +#define rxbr_dsize rxbr.vbr_dsize + +struct vmbus_txbr { + struct mtx txbr_lock; + struct vmbus_br txbr; +}; + +#define txbr_windex txbr.vbr_windex +#define txbr_rindex txbr.vbr_rindex +#define txbr_imask txbr.vbr_imask +#define txbr_data txbr.vbr_data +#define txbr_dsize txbr.vbr_dsize -struct vmbus_softc; - -/* - * Private, VM Bus functions - */ struct sysctl_ctx_list; struct sysctl_oid; -void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, - struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br, - const char *name); - -int hv_vmbus_ring_buffer_init( - hv_vmbus_ring_buffer_info *ring_info, - void *buffer, - uint32_t buffer_len); - -void hv_ring_buffer_cleanup( - hv_vmbus_ring_buffer_info *ring_info); - -int hv_ring_buffer_write( - hv_vmbus_ring_buffer_info *ring_info, - const struct iovec iov[], - uint32_t iovlen, - boolean_t *need_sig); - -int hv_ring_buffer_peek( - hv_vmbus_ring_buffer_info *ring_info, - void *buffer, - uint32_t buffer_len); - -int hv_ring_buffer_read( - hv_vmbus_ring_buffer_info *ring_info, - void *buffer, - uint32_t buffer_len, - uint32_t offset); - -void hv_ring_buffer_read_begin( - hv_vmbus_ring_buffer_info *ring_info); - -uint32_t hv_ring_buffer_read_end( - hv_vmbus_ring_buffer_info *ring_info); +void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, + struct sysctl_oid *br_tree, struct vmbus_br *br, + const char *name); + +void vmbus_rxbr_init(struct vmbus_rxbr *rbr); +void vmbus_rxbr_deinit(struct vmbus_rxbr *rbr); +void vmbus_rxbr_setup(struct vmbus_rxbr *rbr, void *buf, int blen); +int vmbus_rxbr_peek(struct vmbus_rxbr *rbr, void *data, int dlen); +int vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, + uint32_t skip); +void vmbus_rxbr_intr_mask(struct vmbus_rxbr *rbr); +uint32_t vmbus_rxbr_intr_unmask(struct vmbus_rxbr *rbr); + +void vmbus_txbr_init(struct vmbus_txbr *tbr); +void vmbus_txbr_deinit(struct vmbus_txbr *tbr); +void vmbus_txbr_setup(struct vmbus_txbr *tbr, void *buf, int blen); +int vmbus_txbr_write(struct vmbus_txbr *tbr, + const struct iovec iov[], int iovlen, boolean_t *need_sig); -#endif /* __HYPERV_PRIV_H__ */ +#endif /* _VMBUS_BRVAR_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:29:31 2016 (r307463) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:35:20 2016 (r307464) @@ -178,11 +178,11 @@ vmbus_chan_sysctl_create(struct vmbus_ch /* * Create sysctl tree for RX bufring. */ - vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_rxbr, "rx"); + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_rxbr.rxbr, "rx"); /* * Create sysctl tree for TX bufring. */ - vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_txbr, "tx"); + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_txbr.txbr, "tx"); } } @@ -239,9 +239,9 @@ vmbus_chan_open(struct vmbus_channel *ch chan->ch_bufring = br; /* TX bufring comes first */ - hv_vmbus_ring_buffer_init(&chan->ch_txbr, br, txbr_size); + vmbus_txbr_setup(&chan->ch_txbr, br, txbr_size); /* RX bufring immediately follows TX bufring */ - hv_vmbus_ring_buffer_init(&chan->ch_rxbr, br + txbr_size, rxbr_size); + vmbus_rxbr_setup(&chan->ch_rxbr, br + txbr_size, rxbr_size); /* Create sysctl tree for this channel */ vmbus_chan_sysctl_create(chan); @@ -549,8 +549,6 @@ vmbus_chan_close_internal(struct vmbus_c /* * Destroy the TX+RX bufrings. */ - hv_ring_buffer_cleanup(&chan->ch_txbr); - hv_ring_buffer_cleanup(&chan->ch_rxbr); if (chan->ch_bufring != NULL) { hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); chan->ch_bufring = NULL; @@ -620,7 +618,7 @@ vmbus_chan_send(struct vmbus_channel *ch iov[2].iov_base = &pad; iov[2].iov_len = pad_pktlen - pktlen; - error = hv_ring_buffer_write(&chan->ch_txbr, iov, 3, &send_evt); + error = vmbus_txbr_write(&chan->ch_txbr, iov, 3, &send_evt); if (!error && send_evt) vmbus_chan_signal_tx(chan); return error; @@ -660,7 +658,7 @@ vmbus_chan_send_sglist(struct vmbus_chan iov[3].iov_base = &pad; iov[3].iov_len = pad_pktlen - pktlen; - error = hv_ring_buffer_write(&chan->ch_txbr, iov, 4, &send_evt); + error = vmbus_txbr_write(&chan->ch_txbr, iov, 4, &send_evt); if (!error && send_evt) vmbus_chan_signal_tx(chan); return error; @@ -702,7 +700,7 @@ vmbus_chan_send_prplist(struct vmbus_cha iov[3].iov_base = &pad; iov[3].iov_len = pad_pktlen - pktlen; - error = hv_ring_buffer_write(&chan->ch_txbr, iov, 4, &send_evt); + error = vmbus_txbr_write(&chan->ch_txbr, iov, 4, &send_evt); if (!error && send_evt) vmbus_chan_signal_tx(chan); return error; @@ -715,7 +713,7 @@ vmbus_chan_recv(struct vmbus_channel *ch struct vmbus_chanpkt_hdr pkt; int error, dlen, hlen; - error = hv_ring_buffer_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); + error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) return error; @@ -732,8 +730,8 @@ vmbus_chan_recv(struct vmbus_channel *ch *dlen0 = dlen; /* Skip packet header */ - error = hv_ring_buffer_read(&chan->ch_rxbr, data, dlen, hlen); - KASSERT(!error, ("hv_ring_buffer_read failed")); + error = vmbus_rxbr_read(&chan->ch_rxbr, data, dlen, hlen); + KASSERT(!error, ("vmbus_rxbr_read failed")); return 0; } @@ -745,7 +743,7 @@ vmbus_chan_recv_pkt(struct vmbus_channel struct vmbus_chanpkt_hdr pkt; int error, pktlen; - error = hv_ring_buffer_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); + error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) return error; @@ -758,8 +756,8 @@ vmbus_chan_recv_pkt(struct vmbus_channel *pktlen0 = pktlen; /* Include packet header */ - error = hv_ring_buffer_read(&chan->ch_rxbr, pkt0, pktlen, 0); - KASSERT(!error, ("hv_ring_buffer_read failed")); + error = vmbus_rxbr_read(&chan->ch_rxbr, pkt0, pktlen, 0); + KASSERT(!error, ("vmbus_rxbr_read failed")); return 0; } @@ -788,12 +786,12 @@ vmbus_chan_task(void *xchan, int pending cb(chan, cbarg); - left = hv_ring_buffer_read_end(&chan->ch_rxbr); + left = vmbus_rxbr_intr_unmask(&chan->ch_rxbr); if (left == 0) { /* No more data in RX bufring; done */ break; } - hv_ring_buffer_read_begin(&chan->ch_rxbr); + vmbus_rxbr_intr_mask(&chan->ch_rxbr); } } @@ -835,7 +833,7 @@ vmbus_event_flags_proc(struct vmbus_soft continue; if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - hv_ring_buffer_read_begin(&chan->ch_rxbr); + vmbus_rxbr_intr_mask(&chan->ch_rxbr); taskqueue_enqueue(chan->ch_tq, &chan->ch_task); } } @@ -914,6 +912,8 @@ vmbus_chan_alloc(struct vmbus_softc *sc) mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); TAILQ_INIT(&chan->ch_subchans); TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + vmbus_rxbr_init(&chan->ch_rxbr); + vmbus_txbr_init(&chan->ch_txbr); return chan; } @@ -926,6 +926,8 @@ vmbus_chan_free(struct vmbus_channel *ch /* TODO: asset no longer on the vmbus channel list */ hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); + vmbus_rxbr_deinit(&chan->ch_rxbr); + vmbus_txbr_deinit(&chan->ch_txbr); free(chan, M_DEVBUF); } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Mon Oct 17 03:29:31 2016 (r307463) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Mon Oct 17 03:35:20 2016 (r307464) @@ -39,12 +39,7 @@ #include #include #include - -typedef struct { - struct vmbus_bufring *ring_buffer; - struct mtx ring_lock; - uint32_t ring_data_size; /* ring_size */ -} hv_vmbus_ring_buffer_info; +#include struct vmbus_channel { /* @@ -57,7 +52,7 @@ struct vmbus_channel { /* * RX bufring; immediately following ch_txbr. */ - hv_vmbus_ring_buffer_info ch_rxbr; + struct vmbus_rxbr ch_rxbr; struct taskqueue *ch_tq; struct task ch_task; @@ -76,7 +71,7 @@ struct vmbus_channel { * TX bufring and following MNF/evtflags do _not_ fit in * one 64B cacheline. */ - hv_vmbus_ring_buffer_info ch_txbr __aligned(CACHE_LINE_SIZE); + struct vmbus_txbr ch_txbr __aligned(CACHE_LINE_SIZE); uint32_t ch_txflags; /* VMBUS_CHAN_TXF_ */ /* From owner-svn-src-stable@freebsd.org Mon Oct 17 03:42:13 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5382AC11097; Mon, 17 Oct 2016 03:42:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 243971D80; Mon, 17 Oct 2016 03:42:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H3gC40022435; Mon, 17 Oct 2016 03:42:12 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H3gBLH022431; Mon, 17 Oct 2016 03:42:11 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170342.u9H3gBLH022431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:42:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307465 - in stable/11/sys: conf dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:42:13 -0000 Author: sephe Date: Mon Oct 17 03:42:11 2016 New Revision: 307465 URL: https://svnweb.freebsd.org/changeset/base/307465 Log: MFC 303379 hyperv/vmbus: Rename cleaned up bufring code Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7318 Added: stable/11/sys/dev/hyperv/vmbus/vmbus_br.c - copied unchanged from r303379, head/sys/dev/hyperv/vmbus/vmbus_br.c Deleted: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Modified: stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.i386 stable/11/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Mon Oct 17 03:35:20 2016 (r307464) +++ stable/11/sys/conf/files.amd64 Mon Oct 17 03:42:11 2016 (r307465) @@ -301,10 +301,10 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_br.c optional hyperv dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv Modified: stable/11/sys/conf/files.i386 ============================================================================== --- stable/11/sys/conf/files.i386 Mon Oct 17 03:35:20 2016 (r307464) +++ stable/11/sys/conf/files.i386 Mon Oct 17 03:42:11 2016 (r307465) @@ -258,10 +258,10 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_br.c optional hyperv dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv Copied: stable/11/sys/dev/hyperv/vmbus/vmbus_br.c (from r303379, head/sys/dev/hyperv/vmbus/vmbus_br.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_br.c Mon Oct 17 03:42:11 2016 (r307465, copy of r303379, head/sys/dev/hyperv/vmbus/vmbus_br.c) @@ -0,0 +1,414 @@ +/*- + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2012 NetApp Inc. + * Copyright (c) 2012 Citrix Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include +#include + +/* Amount of space available for write */ +#define VMBUS_BR_WAVAIL(r, w, z) \ + (((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w))) + +/* Increase bufing index */ +#define VMBUS_BR_IDXINC(idx, inc, sz) (((idx) + (inc)) % (sz)) + +static int +vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS) +{ + const struct vmbus_br *br = arg1; + uint32_t rindex, windex, imask, ravail, wavail; + char state[256]; + + rindex = br->vbr_rindex; + windex = br->vbr_windex; + imask = br->vbr_imask; + wavail = VMBUS_BR_WAVAIL(rindex, windex, br->vbr_dsize); + ravail = br->vbr_dsize - wavail; + + snprintf(state, sizeof(state), + "rindex:%u windex:%u imask:%u ravail:%u wavail:%u", + rindex, windex, imask, ravail, wavail); + return sysctl_handle_string(oidp, state, sizeof(state), req); +} + +/* + * Binary bufring states. + */ +static int +vmbus_br_sysctl_state_bin(SYSCTL_HANDLER_ARGS) +{ +#define BR_STATE_RIDX 0 +#define BR_STATE_WIDX 1 +#define BR_STATE_IMSK 2 +#define BR_STATE_RSPC 3 +#define BR_STATE_WSPC 4 +#define BR_STATE_MAX 5 + + const struct vmbus_br *br = arg1; + uint32_t rindex, windex, wavail, state[BR_STATE_MAX]; + + rindex = br->vbr_rindex; + windex = br->vbr_windex; + wavail = VMBUS_BR_WAVAIL(rindex, windex, br->vbr_dsize); + + state[BR_STATE_RIDX] = rindex; + state[BR_STATE_WIDX] = windex; + state[BR_STATE_IMSK] = br->vbr_imask; + state[BR_STATE_WSPC] = wavail; + state[BR_STATE_RSPC] = br->vbr_dsize - wavail; + + return sysctl_handle_opaque(oidp, state, sizeof(state), req); +} + +void +vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, + struct vmbus_br *br, const char *name) +{ + struct sysctl_oid *tree; + char desc[64]; + + tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(br_tree), OID_AUTO, + name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (tree == NULL) + return; + + snprintf(desc, sizeof(desc), "%s state", name); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + br, 0, vmbus_br_sysctl_state, "A", desc); + + snprintf(desc, sizeof(desc), "%s binary state", name); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state_bin", + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, + br, 0, vmbus_br_sysctl_state_bin, "IU", desc); +} + +void +vmbus_rxbr_intr_mask(struct vmbus_rxbr *rbr) +{ + rbr->rxbr_imask = 1; + mb(); +} + +static __inline uint32_t +vmbus_rxbr_avail(const struct vmbus_rxbr *rbr) +{ + uint32_t rindex, windex; + + /* Get snapshot */ + rindex = rbr->rxbr_rindex; + windex = rbr->rxbr_windex; + + return (rbr->rxbr_dsize - + VMBUS_BR_WAVAIL(rindex, windex, rbr->rxbr_dsize)); +} + +uint32_t +vmbus_rxbr_intr_unmask(struct vmbus_rxbr *rbr) +{ + rbr->rxbr_imask = 0; + mb(); + + /* + * Now check to see if the ring buffer is still empty. + * If it is not, we raced and we need to process new + * incoming channel packets. + */ + return vmbus_rxbr_avail(rbr); +} + +static void +vmbus_br_setup(struct vmbus_br *br, void *buf, int blen) +{ + br->vbr = buf; + br->vbr_dsize = blen - sizeof(struct vmbus_bufring); +} + +void +vmbus_rxbr_init(struct vmbus_rxbr *rbr) +{ + mtx_init(&rbr->rxbr_lock, "vmbus_rxbr", NULL, MTX_SPIN); +} + +void +vmbus_rxbr_deinit(struct vmbus_rxbr *rbr) +{ + mtx_destroy(&rbr->rxbr_lock); +} + +void +vmbus_rxbr_setup(struct vmbus_rxbr *rbr, void *buf, int blen) +{ + vmbus_br_setup(&rbr->rxbr, buf, blen); +} + +void +vmbus_txbr_init(struct vmbus_txbr *tbr) +{ + mtx_init(&tbr->txbr_lock, "vmbus_txbr", NULL, MTX_SPIN); +} + +void +vmbus_txbr_deinit(struct vmbus_txbr *tbr) +{ + mtx_destroy(&tbr->txbr_lock); +} + +void +vmbus_txbr_setup(struct vmbus_txbr *tbr, void *buf, int blen) +{ + vmbus_br_setup(&tbr->txbr, buf, blen); +} + +/* + * When we write to the ring buffer, check if the host needs to be + * signaled. + * + * The contract: + * - The host guarantees that while it is draining the TX bufring, + * it will set the br_imask to indicate it does not need to be + * interrupted when new data are added. + * - The host guarantees that it will completely drain the TX bufring + * before exiting the read loop. Further, once the TX bufring is + * empty, it will clear the br_imask and re-check to see if new + * data have arrived. + */ +static __inline boolean_t +vmbus_txbr_need_signal(const struct vmbus_txbr *tbr, uint32_t old_windex) +{ + mb(); + if (tbr->txbr_imask) + return (FALSE); + + /* XXX only compiler fence is needed */ + /* Read memory barrier */ + rmb(); + + /* + * This is the only case we need to signal when the + * ring transitions from being empty to non-empty. + */ + if (old_windex == tbr->txbr_rindex) + return (TRUE); + + return (FALSE); +} + +static __inline uint32_t +vmbus_txbr_avail(const struct vmbus_txbr *tbr) +{ + uint32_t rindex, windex; + + /* Get snapshot */ + rindex = tbr->txbr_rindex; + windex = tbr->txbr_windex; + + return VMBUS_BR_WAVAIL(rindex, windex, tbr->txbr_dsize); +} + +static __inline uint32_t +vmbus_txbr_copyto(const struct vmbus_txbr *tbr, uint32_t windex, + const void *src0, uint32_t cplen) +{ + const uint8_t *src = src0; + uint8_t *br_data = tbr->txbr_data; + uint32_t br_dsize = tbr->txbr_dsize; + + if (cplen > br_dsize - windex) { + uint32_t fraglen = br_dsize - windex; + + /* Wrap-around detected */ + memcpy(br_data + windex, src, fraglen); + memcpy(br_data, src + fraglen, cplen - fraglen); + } else { + memcpy(br_data + windex, src, cplen); + } + return VMBUS_BR_IDXINC(windex, cplen, br_dsize); +} + +/* + * Write scattered channel packet to TX bufring. + * + * The offset of this channel packet is written as a 64bits value + * immediately after this channel packet. + */ +int +vmbus_txbr_write(struct vmbus_txbr *tbr, const struct iovec iov[], int iovlen, + boolean_t *need_sig) +{ + uint32_t old_windex, windex, total; + uint64_t save_windex; + int i; + + total = 0; + for (i = 0; i < iovlen; i++) + total += iov[i].iov_len; + total += sizeof(save_windex); + + mtx_lock_spin(&tbr->txbr_lock); + + /* + * NOTE: + * If this write is going to make br_windex same as br_rindex, + * i.e. the available space for write is same as the write size, + * we can't do it then, since br_windex == br_rindex means that + * the bufring is empty. + */ + if (vmbus_txbr_avail(tbr) <= total) { + mtx_unlock_spin(&tbr->txbr_lock); + return (EAGAIN); + } + + /* Save br_windex for later use */ + old_windex = tbr->txbr_windex; + + /* + * Copy the scattered channel packet to the TX bufring. + */ + windex = old_windex; + for (i = 0; i < iovlen; i++) { + windex = vmbus_txbr_copyto(tbr, windex, + iov[i].iov_base, iov[i].iov_len); + } + + /* + * Set the offset of the current channel packet. + */ + save_windex = ((uint64_t)old_windex) << 32; + windex = vmbus_txbr_copyto(tbr, windex, &save_windex, + sizeof(save_windex)); + + /* + * XXX only compiler fence is needed. + * Full memory barrier before upding the write index. + */ + mb(); + + /* + * Update the write index _after_ the channel packet + * is copied. + */ + tbr->txbr_windex = windex; + + mtx_unlock_spin(&tbr->txbr_lock); + + *need_sig = vmbus_txbr_need_signal(tbr, old_windex); + + return (0); +} + +static __inline uint32_t +vmbus_rxbr_copyfrom(const struct vmbus_rxbr *rbr, uint32_t rindex, + void *dst0, int cplen) +{ + uint8_t *dst = dst0; + const uint8_t *br_data = rbr->rxbr_data; + uint32_t br_dsize = rbr->rxbr_dsize; + + if (cplen > br_dsize - rindex) { + uint32_t fraglen = br_dsize - rindex; + + /* Wrap-around detected. */ + memcpy(dst, br_data + rindex, fraglen); + memcpy(dst + fraglen, br_data, cplen - fraglen); + } else { + memcpy(dst, br_data + rindex, cplen); + } + return VMBUS_BR_IDXINC(rindex, cplen, br_dsize); +} + +int +vmbus_rxbr_peek(struct vmbus_rxbr *rbr, void *data, int dlen) +{ + mtx_lock_spin(&rbr->rxbr_lock); + + /* + * The requested data and the 64bits channel packet + * offset should be there at least. + */ + if (vmbus_rxbr_avail(rbr) < dlen + sizeof(uint64_t)) { + mtx_unlock_spin(&rbr->rxbr_lock); + return (EAGAIN); + } + vmbus_rxbr_copyfrom(rbr, rbr->rxbr_rindex, data, dlen); + + mtx_unlock_spin(&rbr->rxbr_lock); + + return (0); +} + +/* + * NOTE: + * We assume (dlen + skip) == sizeof(channel packet). + */ +int +vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, uint32_t skip) +{ + uint32_t rindex, br_dsize = rbr->rxbr_dsize; + + KASSERT(dlen + skip > 0, ("invalid dlen %d, offset %u", dlen, skip)); + + mtx_lock_spin(&rbr->rxbr_lock); + + if (vmbus_rxbr_avail(rbr) < dlen + skip + sizeof(uint64_t)) { + mtx_unlock_spin(&rbr->rxbr_lock); + return (EAGAIN); + } + + /* + * Copy channel packet from RX bufring. + */ + rindex = VMBUS_BR_IDXINC(rbr->rxbr_rindex, skip, br_dsize); + rindex = vmbus_rxbr_copyfrom(rbr, rindex, data, dlen); + + /* + * Discard this channel packet's 64bits offset, which is useless to us. + */ + rindex = VMBUS_BR_IDXINC(rindex, sizeof(uint64_t), br_dsize); + + /* + * XXX only compiler fence is needed. + * Make sure all reads are done before we update the read index since + * the writer may start writing to the read area once the read index + * is updated. + */ + wmb(); + + /* + * Update the read index _after_ the channel packet is fetched. + */ + rbr->rxbr_rindex = rindex; + + mtx_unlock_spin(&rbr->rxbr_lock); + + return (0); +} Modified: stable/11/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/11/sys/modules/hyperv/vmbus/Makefile Mon Oct 17 03:35:20 2016 (r307464) +++ stable/11/sys/modules/hyperv/vmbus/Makefile Mon Oct 17 03:42:11 2016 (r307465) @@ -4,11 +4,11 @@ ${.CURDIR}/../../../dev/hyperv/vmbus/${MACHINE_CPUARCH} KMOD= hv_vmbus -SRCS= hv_ring_buffer.c \ - hyperv.c \ +SRCS= hyperv.c \ hyperv_busdma.c \ hyperv_machdep.c \ vmbus.c \ + vmbus_br.c \ vmbus_chan.c \ vmbus_et.c SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h vmbus_if.h From owner-svn-src-stable@freebsd.org Mon Oct 17 03:48:24 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E52A8C111B3; Mon, 17 Oct 2016 03:48:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B113A10A1; Mon, 17 Oct 2016 03:48:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H3mNP3025019; Mon, 17 Oct 2016 03:48:23 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H3mMh9025003; Mon, 17 Oct 2016 03:48:22 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170348.u9H3mMh9025003@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:48:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307466 - in stable/11/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:48:25 -0000 Author: sephe Date: Mon Oct 17 03:48:22 2016 New Revision: 307466 URL: https://svnweb.freebsd.org/changeset/base/307466 Log: MFC 303421,303422,303470-303473 303421 hyperv/vmbus: Avoid unnecessary mb() Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7333 303422 hyperv/vmbus: Inclusion cleanup Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7334 303470 hyperv/vmbus: Reindent function declarations. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7344 303471 hyperv/vmbus: Forward declare static functions Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7346 303472 hyperv/vmbus: Move driver glue to the beginning of the files Just as most of other drivers do. And move sysinit function close to its SYSINIT. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7347 303473 hyperv/vmbus: Revoke unnecessary exposure of vmbus softc Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7348 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/include/hyperv_busdma.h stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_br.c stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_et.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 03:48:22 2016 (r307466) @@ -28,43 +28,21 @@ * $FreeBSD$ */ -/** - * HyperV definitions for messages that are sent between instances of the - * Channel Management Library in separate partitions, or in some cases, - * back to itself. - */ - -#ifndef __HYPERV_H__ -#define __HYPERV_H__ +#ifndef _HYPERV_H_ +#define _HYPERV_H_ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include -#include #include -#include -#include -#include - struct hyperv_guid { uint8_t hv_guid[16]; } __packed; #define HYPERV_GUID_STRLEN 40 -int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); +int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); /** * @brief Get physical address from virtual @@ -77,4 +55,4 @@ hv_get_phys_addr(void *virt) return (ret); } -#endif /* __HYPERV_H__ */ +#endif /* _HYPERV_H_ */ Modified: stable/11/sys/dev/hyperv/include/hyperv_busdma.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv_busdma.h Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/include/hyperv_busdma.h Mon Oct 17 03:48:22 2016 (r307466) @@ -39,11 +39,11 @@ struct hyperv_dma { bus_dmamap_t hv_dmap; }; -void hyperv_dma_map_paddr(void *arg, bus_dma_segment_t *segs, int nseg, - int error); -void *hyperv_dmamem_alloc(bus_dma_tag_t parent_dtag, bus_size_t alignment, - bus_addr_t boundary, bus_size_t size, struct hyperv_dma *dma, - int flags); -void hyperv_dmamem_free(struct hyperv_dma *dma, void *ptr); +void hyperv_dma_map_paddr(void *arg, bus_dma_segment_t *segs, + int nseg, int error); +void *hyperv_dmamem_alloc(bus_dma_tag_t parent_dtag, + bus_size_t alignment, bus_addr_t boundary, bus_size_t size, + struct hyperv_dma *dma, int flags); +void hyperv_dmamem_free(struct hyperv_dma *dma, void *ptr); #endif /* !_HYPERV_BUSDMA_H_ */ Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 03:48:22 2016 (r307466) @@ -30,6 +30,7 @@ #define _VMBUS_H_ #include +#include /* * VMBUS version is 32 bit, upper 16 bit for major_number and lower @@ -115,45 +116,47 @@ vmbus_get_channel(device_t dev) return device_get_ivars(dev); } -int vmbus_chan_open(struct vmbus_channel *chan, - int txbr_size, int rxbr_size, const void *udata, int udlen, - vmbus_chan_callback_t cb, void *cbarg); -void vmbus_chan_close(struct vmbus_channel *chan); - -int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, - bus_addr_t paddr, int size, uint32_t *gpadl); -int vmbus_chan_gpadl_disconnect(struct vmbus_channel *chan, - uint32_t gpadl); +int vmbus_chan_open(struct vmbus_channel *chan, + int txbr_size, int rxbr_size, const void *udata, int udlen, + vmbus_chan_callback_t cb, void *cbarg); +void vmbus_chan_close(struct vmbus_channel *chan); + +int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, + bus_addr_t paddr, int size, uint32_t *gpadl); +int vmbus_chan_gpadl_disconnect(struct vmbus_channel *chan, + uint32_t gpadl); -void vmbus_chan_cpu_set(struct vmbus_channel *chan, int cpu); -void vmbus_chan_cpu_rr(struct vmbus_channel *chan); +void vmbus_chan_cpu_set(struct vmbus_channel *chan, int cpu); +void vmbus_chan_cpu_rr(struct vmbus_channel *chan); struct vmbus_channel * - vmbus_chan_cpu2chan(struct vmbus_channel *chan, int cpu); -void vmbus_chan_set_readbatch(struct vmbus_channel *chan, bool on); + vmbus_chan_cpu2chan(struct vmbus_channel *chan, int cpu); +void vmbus_chan_set_readbatch(struct vmbus_channel *chan, bool on); struct vmbus_channel ** - vmbus_subchan_get(struct vmbus_channel *pri_chan, int subchan_cnt); -void vmbus_subchan_rel(struct vmbus_channel **subchan, int subchan_cnt); -void vmbus_subchan_drain(struct vmbus_channel *pri_chan); - -int vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen, - uint64_t *xactid); -int vmbus_chan_recv_pkt(struct vmbus_channel *chan, - struct vmbus_chanpkt_hdr *pkt, int *pktlen); - -int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, - uint16_t flags, void *data, int dlen, uint64_t xactid); -int vmbus_chan_send_sglist(struct vmbus_channel *chan, - struct vmbus_gpa sg[], int sglen, void *data, int dlen, - uint64_t xactid); -int vmbus_chan_send_prplist(struct vmbus_channel *chan, - struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, - uint64_t xactid); - -uint32_t vmbus_chan_id(const struct vmbus_channel *chan); -uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan); -bool vmbus_chan_is_primary(const struct vmbus_channel *chan); + vmbus_subchan_get(struct vmbus_channel *pri_chan, + int subchan_cnt); +void vmbus_subchan_rel(struct vmbus_channel **subchan, + int subchan_cnt); +void vmbus_subchan_drain(struct vmbus_channel *pri_chan); + +int vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen, + uint64_t *xactid); +int vmbus_chan_recv_pkt(struct vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt, int *pktlen); + +int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, + uint16_t flags, void *data, int dlen, uint64_t xactid); +int vmbus_chan_send_sglist(struct vmbus_channel *chan, + struct vmbus_gpa sg[], int sglen, void *data, int dlen, + uint64_t xactid); +int vmbus_chan_send_prplist(struct vmbus_channel *chan, + struct vmbus_gpa_range *prp, int prp_cnt, void *data, + int dlen, uint64_t xactid); + +uint32_t vmbus_chan_id(const struct vmbus_channel *chan); +uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan); +bool vmbus_chan_is_primary(const struct vmbus_channel *chan); const struct hyperv_guid * - vmbus_chan_guid_inst(const struct vmbus_channel *chan); + vmbus_chan_guid_inst(const struct vmbus_channel *chan); #endif /* !_VMBUS_H_ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 03:48:22 2016 (r307466) @@ -44,6 +44,7 @@ #include #include #include +#include #include #include Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 03:48:22 2016 (r307466) @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 03:48:22 2016 (r307466) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 03:48:22 2016 (r307466) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 03:48:22 2016 (r307466) @@ -38,6 +38,7 @@ #include #include #include +#include #include #include Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 03:48:22 2016 (r307466) @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include Modified: stable/11/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/vmbus/hyperv.c Mon Oct 17 03:48:22 2016 (r307466) @@ -34,23 +34,14 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include #include -#include -#include -#include -#include -#include #include #include #include #include #include -#if 0 -#include -#endif #define HYPERV_FREEBSD_BUILD 0ULL #define HYPERV_FREEBSD_VERSION ((uint64_t)__FreeBSD_version) @@ -76,13 +67,15 @@ struct hypercall_ctx { struct hyperv_dma hc_dma; }; -static u_int hyperv_get_timecount(struct timecounter *tc); +static u_int hyperv_get_timecount(struct timecounter *); +static bool hyperv_identify(void); +static void hypercall_memfree(void); -u_int hyperv_features; -u_int hyperv_recommends; +u_int hyperv_features; +u_int hyperv_recommends; -static u_int hyperv_pm_features; -static u_int hyperv_features3; +static u_int hyperv_pm_features; +static u_int hyperv_features3; static struct timecounter hyperv_timecounter = { .tc_get_timecount = hyperv_get_timecount, Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Mon Oct 17 03:48:22 2016 (r307466) @@ -38,26 +38,16 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include +#include #include -#include #include -#include -#include -#include #include -#include -#include -#include -#include - -#include #include -#include -#include -#include -#include +#include + +#include #include #include @@ -66,7 +56,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include "acpi_if.h" #include "vmbus_if.h" @@ -92,6 +81,17 @@ struct vmbus_msghc_ctx { #define VMBUS_MSGHC_CTXF_DESTROY 0x0001 +static int vmbus_probe(device_t); +static int vmbus_attach(device_t); +static int vmbus_detach(device_t); +static int vmbus_read_ivar(device_t, device_t, int, + uintptr_t *); +static int vmbus_child_pnpinfo_str(device_t, device_t, + char *, size_t); +static uint32_t vmbus_get_version_method(device_t, device_t); +static int vmbus_probe_guid_method(device_t, device_t, + const struct hyperv_guid *); + static int vmbus_init(struct vmbus_softc *); static int vmbus_connect(struct vmbus_softc *, uint32_t); static int vmbus_req_channels(struct vmbus_softc *sc); @@ -104,8 +104,17 @@ static void vmbus_scan_done(struct vmb const struct vmbus_message *); static void vmbus_chanmsg_handle(struct vmbus_softc *, const struct vmbus_message *); - +static void vmbus_msg_task(void *, int); +static void vmbus_synic_setup(void *); +static void vmbus_synic_teardown(void *); static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); +static int vmbus_dma_alloc(struct vmbus_softc *); +static void vmbus_dma_free(struct vmbus_softc *); +static int vmbus_intr_setup(struct vmbus_softc *); +static void vmbus_intr_teardown(struct vmbus_softc *); +static int vmbus_doattach(struct vmbus_softc *); +static void vmbus_event_proc_dummy(struct vmbus_softc *, + int); static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t); static void vmbus_msghc_ctx_destroy( @@ -116,7 +125,7 @@ static void vmbus_msghc_free(struct vm static struct vmbus_msghc *vmbus_msghc_get1(struct vmbus_msghc_ctx *, uint32_t); -struct vmbus_softc *vmbus_sc; +static struct vmbus_softc *vmbus_sc; extern inthand_t IDTVEC(vmbus_isr); @@ -133,6 +142,46 @@ vmbus_chanmsg_handlers[VMBUS_CHANMSG_TYP VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP) }; +static device_method_t vmbus_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_probe), + DEVMETHOD(device_attach, vmbus_attach), + DEVMETHOD(device_detach, vmbus_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, bus_generic_add_child), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, vmbus_read_ivar), + DEVMETHOD(bus_child_pnpinfo_str, vmbus_child_pnpinfo_str), + + /* Vmbus interface */ + DEVMETHOD(vmbus_get_version, vmbus_get_version_method), + DEVMETHOD(vmbus_probe_guid, vmbus_probe_guid_method), + + DEVMETHOD_END +}; + +static driver_t vmbus_driver = { + "vmbus", + vmbus_methods, + sizeof(struct vmbus_softc) +}; + +static devclass_t vmbus_devclass; + +DRIVER_MODULE(vmbus, acpi, vmbus_driver, vmbus_devclass, NULL, NULL); +MODULE_DEPEND(vmbus, acpi, 1, 1, 1); +MODULE_VERSION(vmbus, 1); + +static __inline struct vmbus_softc * +vmbus_get_softc(void) +{ + return vmbus_sc; +} + static struct vmbus_msghc * vmbus_msghc_alloc(bus_dma_tag_t parent_dtag) { @@ -1239,26 +1288,6 @@ vmbus_attach(device_t dev) return (0); } -static void -vmbus_sysinit(void *arg __unused) -{ - struct vmbus_softc *sc = vmbus_get_softc(); - - if (vm_guest != VM_GUEST_HV || sc == NULL) - return; - -#ifndef EARLY_AP_STARTUP - /* - * If the system has already booted and thread - * scheduling is possible, as indicated by the - * global cold set to zero, we just call the driver - * initialization directly. - */ - if (!cold) -#endif - vmbus_doattach(sc); -} - static int vmbus_detach(device_t dev) { @@ -1288,45 +1317,30 @@ vmbus_detach(device_t dev) return (0); } -static device_method_t vmbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, vmbus_probe), - DEVMETHOD(device_attach, vmbus_attach), - DEVMETHOD(device_detach, vmbus_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_add_child, bus_generic_add_child), - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_read_ivar, vmbus_read_ivar), - DEVMETHOD(bus_child_pnpinfo_str, vmbus_child_pnpinfo_str), - - /* Vmbus interface */ - DEVMETHOD(vmbus_get_version, vmbus_get_version_method), - DEVMETHOD(vmbus_probe_guid, vmbus_probe_guid_method), - - DEVMETHOD_END -}; - -static driver_t vmbus_driver = { - "vmbus", - vmbus_methods, - sizeof(struct vmbus_softc) -}; +#ifndef EARLY_AP_STARTUP -static devclass_t vmbus_devclass; +static void +vmbus_sysinit(void *arg __unused) +{ + struct vmbus_softc *sc = vmbus_get_softc(); -DRIVER_MODULE(vmbus, acpi, vmbus_driver, vmbus_devclass, NULL, NULL); -MODULE_DEPEND(vmbus, acpi, 1, 1, 1); -MODULE_VERSION(vmbus, 1); + if (vm_guest != VM_GUEST_HV || sc == NULL) + return; -#ifndef EARLY_AP_STARTUP + /* + * If the system has already booted and thread + * scheduling is possible, as indicated by the + * global cold set to zero, we just call the driver + * initialization directly. + */ + if (!cold) + vmbus_doattach(sc); +} /* * NOTE: * We have to start as the last step of SI_SUB_SMP, i.e. after SMP is * initialized. */ SYSINIT(vmbus_initialize, SI_SUB_SMP, SI_ORDER_ANY, vmbus_sysinit, NULL); -#endif + +#endif /* !EARLY_AP_STARTUP */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_br.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_br.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_br.c Mon Oct 17 03:48:22 2016 (r307466) @@ -41,6 +41,10 @@ /* Increase bufing index */ #define VMBUS_BR_IDXINC(idx, inc, sz) (((idx) + (inc)) % (sz)) +static int vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS); +static int vmbus_br_sysctl_state_bin(SYSCTL_HANDLER_ARGS); +static void vmbus_br_setup(struct vmbus_br *, void *, int); + static int vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS) { @@ -209,9 +213,7 @@ vmbus_txbr_need_signal(const struct vmbu if (tbr->txbr_imask) return (FALSE); - /* XXX only compiler fence is needed */ - /* Read memory barrier */ - rmb(); + __compiler_membar(); /* * This is the only case we need to signal when the @@ -308,15 +310,10 @@ vmbus_txbr_write(struct vmbus_txbr *tbr, sizeof(save_windex)); /* - * XXX only compiler fence is needed. - * Full memory barrier before upding the write index. - */ - mb(); - - /* * Update the write index _after_ the channel packet * is copied. */ + __compiler_membar(); tbr->txbr_windex = windex; mtx_unlock_spin(&tbr->txbr_lock); @@ -396,16 +393,9 @@ vmbus_rxbr_read(struct vmbus_rxbr *rbr, rindex = VMBUS_BR_IDXINC(rindex, sizeof(uint64_t), br_dsize); /* - * XXX only compiler fence is needed. - * Make sure all reads are done before we update the read index since - * the writer may start writing to the read area once the read index - * is updated. - */ - wmb(); - - /* * Update the read index _after_ the channel packet is fetched. */ + __compiler_membar(); rbr->rxbr_rindex = rindex; mtx_unlock_spin(&rbr->rxbr_lock); Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 03:48:22 2016 (r307466) @@ -31,19 +31,14 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include #include +#include #include +#include #include +#include #include -#include - -#include -#include -#include #include #include @@ -52,17 +47,28 @@ __FBSDID("$FreeBSD$"); #include #include -static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, - const struct vmbus_channel *); - -static void vmbus_chan_task(void *, int); -static void vmbus_chan_task_nobatch(void *, int); -static void vmbus_chan_detach_task(void *, int); - -static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, - const struct vmbus_message *); -static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, - const struct vmbus_message *); +static void vmbus_chan_update_evtflagcnt( + struct vmbus_softc *, + const struct vmbus_channel *); +static void vmbus_chan_close_internal( + struct vmbus_channel *); +static int vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS); +static void vmbus_chan_sysctl_create( + struct vmbus_channel *); +static struct vmbus_channel *vmbus_chan_alloc(struct vmbus_softc *); +static void vmbus_chan_free(struct vmbus_channel *); +static int vmbus_chan_add(struct vmbus_channel *); +static void vmbus_chan_cpu_default(struct vmbus_channel *); + +static void vmbus_chan_task(void *, int); +static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_detach_task(void *, int); + +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind( + struct vmbus_softc *, + const struct vmbus_message *); /* * Vmbus channel message processing. Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Mon Oct 17 03:48:22 2016 (r307466) @@ -155,9 +155,10 @@ struct vmbus_channel { struct vmbus_softc; struct vmbus_message; -void vmbus_event_proc(struct vmbus_softc *, int); -void vmbus_event_proc_compat(struct vmbus_softc *, int); -void vmbus_chan_msgproc(struct vmbus_softc *, const struct vmbus_message *); -void vmbus_chan_destroy_all(struct vmbus_softc *); +void vmbus_event_proc(struct vmbus_softc *, int); +void vmbus_event_proc_compat(struct vmbus_softc *, int); +void vmbus_chan_msgproc(struct vmbus_softc *, + const struct vmbus_message *); +void vmbus_chan_destroy_all(struct vmbus_softc *); #endif /* !_VMBUS_CHANVAR_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_et.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_et.c Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_et.c Mon Oct 17 03:48:22 2016 (r307466) @@ -32,9 +32,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include -#include +#include #include #include @@ -57,8 +56,35 @@ __FBSDID("$FreeBSD$"); CPUID_HV_MSR_SYNIC | \ CPUID_HV_MSR_SYNTIMER) +static void vmbus_et_identify(driver_t *, device_t); +static int vmbus_et_probe(device_t); +static int vmbus_et_attach(device_t); +static int vmbus_et_detach(device_t); +static int vmbus_et_start(struct eventtimer *, sbintime_t, + sbintime_t); + static struct eventtimer vmbus_et; +static device_method_t vmbus_et_methods[] = { + DEVMETHOD(device_identify, vmbus_et_identify), + DEVMETHOD(device_probe, vmbus_et_probe), + DEVMETHOD(device_attach, vmbus_et_attach), + DEVMETHOD(device_detach, vmbus_et_detach), + + DEVMETHOD_END +}; + +static driver_t vmbus_et_driver = { + VMBUS_ET_NAME, + vmbus_et_methods, + 0 +}; + +static devclass_t vmbus_et_devclass; + +DRIVER_MODULE(hv_et, vmbus, vmbus_et_driver, vmbus_et_devclass, NULL, NULL); +MODULE_VERSION(hv_et, 1); + static __inline uint64_t hyperv_sbintime2count(sbintime_t time) { @@ -175,22 +201,3 @@ vmbus_et_detach(device_t dev) { return (et_deregister(&vmbus_et)); } - -static device_method_t vmbus_et_methods[] = { - DEVMETHOD(device_identify, vmbus_et_identify), - DEVMETHOD(device_probe, vmbus_et_probe), - DEVMETHOD(device_attach, vmbus_et_attach), - DEVMETHOD(device_detach, vmbus_et_detach), - - DEVMETHOD_END -}; - -static driver_t vmbus_et_driver = { - VMBUS_ET_NAME, - vmbus_et_methods, - 0 -}; - -static devclass_t vmbus_et_devclass; -DRIVER_MODULE(hv_et, vmbus, vmbus_et_driver, vmbus_et_devclass, NULL, NULL); -MODULE_VERSION(hv_et, 1); Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 03:42:11 2016 (r307465) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Mon Oct 17 03:48:22 2016 (r307466) @@ -30,7 +30,6 @@ #define _VMBUS_VAR_H_ #include -#include #include #include @@ -121,20 +120,6 @@ struct vmbus_softc { #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ #define VMBUS_FLAG_SYNIC 0x0002 /* SynIC was setup */ -extern struct vmbus_softc *vmbus_sc; - -static __inline struct vmbus_softc * -vmbus_get_softc(void) -{ - return vmbus_sc; -} - -static __inline device_t -vmbus_get_device(void) -{ - return vmbus_sc->vmbus_dev; -} - #define VMBUS_PCPU_GET(sc, field, cpu) (sc)->vmbus_pcpu[(cpu)].field #define VMBUS_PCPU_PTR(sc, field, cpu) &(sc)->vmbus_pcpu[(cpu)].field @@ -143,20 +128,23 @@ struct trapframe; struct vmbus_message; struct vmbus_msghc; -void vmbus_handle_intr(struct trapframe *); -int vmbus_add_child(struct vmbus_channel *); -int vmbus_delete_child(struct vmbus_channel *); -void vmbus_et_intr(struct trapframe *); -uint32_t vmbus_gpadl_alloc(struct vmbus_softc *); - -struct vmbus_msghc *vmbus_msghc_get(struct vmbus_softc *, size_t); -void vmbus_msghc_put(struct vmbus_softc *, struct vmbus_msghc *); -void *vmbus_msghc_dataptr(struct vmbus_msghc *); -int vmbus_msghc_exec_noresult(struct vmbus_msghc *); -int vmbus_msghc_exec(struct vmbus_softc *, struct vmbus_msghc *); -const struct vmbus_message *vmbus_msghc_wait_result(struct vmbus_softc *, - struct vmbus_msghc *); -void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); -void vmbus_msghc_reset(struct vmbus_msghc *, size_t); +void vmbus_handle_intr(struct trapframe *); +int vmbus_add_child(struct vmbus_channel *); +int vmbus_delete_child(struct vmbus_channel *); +void vmbus_et_intr(struct trapframe *); +uint32_t vmbus_gpadl_alloc(struct vmbus_softc *); + +struct vmbus_msghc * + vmbus_msghc_get(struct vmbus_softc *, size_t); +void vmbus_msghc_put(struct vmbus_softc *, struct vmbus_msghc *); +void *vmbus_msghc_dataptr(struct vmbus_msghc *); +int vmbus_msghc_exec_noresult(struct vmbus_msghc *); +int vmbus_msghc_exec(struct vmbus_softc *, struct vmbus_msghc *); +const struct vmbus_message * + vmbus_msghc_wait_result(struct vmbus_softc *, + struct vmbus_msghc *); +void vmbus_msghc_wakeup(struct vmbus_softc *, + const struct vmbus_message *); +void vmbus_msghc_reset(struct vmbus_msghc *, size_t); #endif /* !_VMBUS_VAR_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 03:51:57 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 96D0DC114C1; Mon, 17 Oct 2016 03:51:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 653F21505; Mon, 17 Oct 2016 03:51:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H3pu0E028691; Mon, 17 Oct 2016 03:51:56 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H3pu63028690; Mon, 17 Oct 2016 03:51:56 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170351.u9H3pu63028690@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 03:51:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307467 - stable/11/sys/dev/hyperv/storvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 03:51:57 -0000 Author: sephe Date: Mon Oct 17 03:51:56 2016 New Revision: 307467 URL: https://svnweb.freebsd.org/changeset/base/307467 Log: MFC 303474 hyperv/storvsc: Use busdma(9) and enable PIM_UNMAPPED by default. The UNMAPPED I/O greatly improves userland direct disk I/O performance by 35% ~ 135%. Submitted by: Hongjiang Zhang Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7195 Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 03:48:22 2016 (r307466) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 03:51:56 2016 (r307467) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -87,7 +88,10 @@ __FBSDID("$FreeBSD$"); #define VSTOR_PKT_SIZE (sizeof(struct vstor_packet) - vmscsi_size_delta) -#define HV_ALIGN(x, a) roundup2(x, a) +#define STORVSC_DATA_SEGCNT_MAX VMBUS_CHAN_PRPLIST_MAX +#define STORVSC_DATA_SEGSZ_MAX PAGE_SIZE +#define STORVSC_DATA_SIZE_MAX \ + (STORVSC_DATA_SEGCNT_MAX * STORVSC_DATA_SEGSZ_MAX) struct storvsc_softc; @@ -102,7 +106,7 @@ struct hv_sgl_page_pool{ boolean_t is_init; } g_hv_sgl_page_pool; -#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * VMBUS_CHAN_PRPLIST_MAX +#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * STORVSC_DATA_SEGCNT_MAX enum storvsc_request_type { WRITE_TYPE, @@ -110,26 +114,41 @@ enum storvsc_request_type { UNKNOWN_TYPE }; -struct hvs_gpa_range { +SYSCTL_NODE(_hw, OID_AUTO, storvsc, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, + "Hyper-V storage interface"); + +static u_int hv_storvsc_use_pim_unmapped = 1; +SYSCTL_INT(_hw_storvsc, OID_AUTO, use_pim_unmapped, CTLFLAG_RDTUN, + &hv_storvsc_use_pim_unmapped, 0, + "Optimize storvsc by using unmapped I/O"); + +struct hv_storvsc_sysctl { + u_long data_bio_cnt; + u_long data_vaddr_cnt; + u_long data_sg_cnt; +}; + +struct storvsc_gpa_range { struct vmbus_gpa_range gpa_range; - uint64_t gpa_page[VMBUS_CHAN_PRPLIST_MAX]; + uint64_t gpa_page[STORVSC_DATA_SEGCNT_MAX]; } __packed; struct hv_storvsc_request { - LIST_ENTRY(hv_storvsc_request) link; - struct vstor_packet vstor_packet; - int prp_cnt; - struct hvs_gpa_range prp_list; - void *sense_data; - uint8_t sense_info_len; - uint8_t retries; - union ccb *ccb; - struct storvsc_softc *softc; - struct callout callout; - struct sema synch_sema; /*Synchronize the request/response if needed */ - struct sglist *bounce_sgl; - unsigned int bounce_sgl_count; - uint64_t not_aligned_seg_bits; + LIST_ENTRY(hv_storvsc_request) link; + struct vstor_packet vstor_packet; + int prp_cnt; + struct storvsc_gpa_range prp_list; + void *sense_data; + uint8_t sense_info_len; + uint8_t retries; + union ccb *ccb; + struct storvsc_softc *softc; + struct callout callout; + struct sema synch_sema; /*Synchronize the request/response if needed */ + struct sglist *bounce_sgl; + unsigned int bounce_sgl_count; + uint64_t not_aligned_seg_bits; + bus_dmamap_t data_dmap; }; struct storvsc_softc { @@ -148,6 +167,8 @@ struct storvsc_softc { struct hv_storvsc_request hs_init_req; struct hv_storvsc_request hs_reset_req; device_t hs_dev; + bus_dma_tag_t storvsc_req_dtag; + struct hv_storvsc_sysctl sysctl_data; struct vmbus_channel *hs_cpu2chan[MAXCPU]; }; @@ -884,6 +905,77 @@ storvsc_create_cpu2chan(struct storvsc_s } } +static int +storvsc_init_requests(device_t dev) +{ + struct storvsc_softc *sc = device_get_softc(dev); + struct hv_storvsc_request *reqp; + int error, i; + + LIST_INIT(&sc->hs_free_list); + + error = bus_dma_tag_create( + bus_get_dma_tag(dev), /* parent */ + 1, /* alignment */ + PAGE_SIZE, /* boundary */ + BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + STORVSC_DATA_SIZE_MAX, /* maxsize */ + STORVSC_DATA_SEGCNT_MAX, /* nsegments */ + STORVSC_DATA_SEGSZ_MAX, /* maxsegsize */ + 0, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockfuncarg */ + &sc->storvsc_req_dtag); + if (error) { + device_printf(dev, "failed to create storvsc dma tag\n"); + return (error); + } + + for (i = 0; i < sc->hs_drv_props->drv_max_ios_per_target; ++i) { + reqp = malloc(sizeof(struct hv_storvsc_request), + M_DEVBUF, M_WAITOK|M_ZERO); + reqp->softc = sc; + error = bus_dmamap_create(sc->storvsc_req_dtag, 0, + &reqp->data_dmap); + if (error) { + device_printf(dev, "failed to allocate storvsc " + "data dmamap\n"); + goto cleanup; + } + LIST_INSERT_HEAD(&sc->hs_free_list, reqp, link); + } + return (0); + +cleanup: + while ((reqp = LIST_FIRST(&sc->hs_free_list)) != NULL) { + LIST_REMOVE(reqp, link); + bus_dmamap_destroy(sc->storvsc_req_dtag, reqp->data_dmap); + free(reqp, M_DEVBUF); + } + return (error); +} + +static void +storvsc_sysctl(device_t dev) +{ + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; + struct storvsc_softc *sc; + + sc = device_get_softc(dev); + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_bio_cnt", CTLFLAG_RW, + &sc->sysctl_data.data_bio_cnt, "# of bio data block"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_vaddr_cnt", CTLFLAG_RW, + &sc->sysctl_data.data_vaddr_cnt, "# of vaddr data block"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_sg_cnt", CTLFLAG_RW, + &sc->sysctl_data.data_sg_cnt, "# of sg data block"); +} + /** * @brief StorVSC attach function * @@ -928,16 +1020,11 @@ storvsc_attach(device_t dev) sc->hs_unit = device_get_unit(dev); sc->hs_dev = dev; - LIST_INIT(&sc->hs_free_list); mtx_init(&sc->hs_lock, "hvslck", NULL, MTX_DEF); - for (i = 0; i < sc->hs_drv_props->drv_max_ios_per_target; ++i) { - reqp = malloc(sizeof(struct hv_storvsc_request), - M_DEVBUF, M_WAITOK|M_ZERO); - reqp->softc = sc; - - LIST_INSERT_HEAD(&sc->hs_free_list, reqp, link); - } + ret = storvsc_init_requests(dev); + if (ret != 0) + goto cleanup; /* create sg-list page pool */ if (FALSE == g_hv_sgl_page_pool.is_init) { @@ -947,7 +1034,7 @@ storvsc_attach(device_t dev) /* * Pre-create SG list, each SG list with - * VMBUS_CHAN_PRPLIST_MAX segments, each + * STORVSC_DATA_SEGCNT_MAX segments, each * segment has one page buffer */ for (i = 0; i < STORVSC_MAX_IO_REQUESTS; i++) { @@ -955,10 +1042,10 @@ storvsc_attach(device_t dev) M_DEVBUF, M_WAITOK|M_ZERO); sgl_node->sgl_data = - sglist_alloc(VMBUS_CHAN_PRPLIST_MAX, + sglist_alloc(STORVSC_DATA_SEGCNT_MAX, M_WAITOK|M_ZERO); - for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { + for (j = 0; j < STORVSC_DATA_SEGCNT_MAX; j++) { tmp_buff = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK|M_ZERO); @@ -1033,6 +1120,8 @@ storvsc_attach(device_t dev) mtx_unlock(&sc->hs_lock); + storvsc_sysctl(dev); + root_mount_rel(root_mount_token); return (0); @@ -1042,13 +1131,14 @@ cleanup: while (!LIST_EMPTY(&sc->hs_free_list)) { reqp = LIST_FIRST(&sc->hs_free_list); LIST_REMOVE(reqp, link); + bus_dmamap_destroy(sc->storvsc_req_dtag, reqp->data_dmap); free(reqp, M_DEVBUF); } while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { + for (j = 0; j < STORVSC_DATA_SEGCNT_MAX; j++) { if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1103,7 +1193,7 @@ storvsc_detach(device_t dev) while (!LIST_EMPTY(&sc->hs_free_list)) { reqp = LIST_FIRST(&sc->hs_free_list); LIST_REMOVE(reqp, link); - + bus_dmamap_destroy(sc->storvsc_req_dtag, reqp->data_dmap); free(reqp, M_DEVBUF); } mtx_unlock(&sc->hs_lock); @@ -1111,7 +1201,7 @@ storvsc_detach(device_t dev) while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++){ + for (j = 0; j < STORVSC_DATA_SEGCNT_MAX; j++){ if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1296,6 +1386,8 @@ storvsc_action(struct cam_sim *sim, unio cpi->hba_inquiry = PI_TAG_ABLE|PI_SDTR_ABLE; cpi->target_sprt = 0; cpi->hba_misc = PIM_NOBUSRESET; + if (hv_storvsc_use_pim_unmapped) + cpi->hba_misc |= PIM_UNMAPPED; cpi->hba_eng_cnt = 0; cpi->max_target = STORVSC_MAX_TARGETS; cpi->max_lun = sc->hs_drv_props->drv_max_luns_per_target; @@ -1370,6 +1462,7 @@ storvsc_action(struct cam_sim *sim, unio case XPT_SCSI_IO: case XPT_IMMED_NOTIFY: { struct hv_storvsc_request *reqp = NULL; + bus_dmamap_t dmap_saved; if (ccb->csio.cdb_len == 0) { panic("cdl_len is 0\n"); @@ -1388,7 +1481,14 @@ storvsc_action(struct cam_sim *sim, unio reqp = LIST_FIRST(&sc->hs_free_list); LIST_REMOVE(reqp, link); + /* Save the data_dmap before reset request */ + dmap_saved = reqp->data_dmap; + + /* XXX this is ugly */ bzero(reqp, sizeof(struct hv_storvsc_request)); + + /* Restore necessary bits */ + reqp->data_dmap = dmap_saved; reqp->softc = sc; ccb->ccb_h.status |= CAM_SIM_QUEUED; @@ -1644,6 +1744,35 @@ storvsc_check_bounce_buffer_sgl(bus_dma_ } /** + * Copy bus_dma segments to multiple page buffer, which requires + * the pages are compact composed except for the 1st and last pages. + */ +static void +storvsc_xferbuf_prepare(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + struct hv_storvsc_request *reqp = arg; + union ccb *ccb = reqp->ccb; + struct ccb_scsiio *csio = &ccb->csio; + struct storvsc_gpa_range *prplist; + int i; + + prplist = &reqp->prp_list; + prplist->gpa_range.gpa_len = csio->dxfer_len; + prplist->gpa_range.gpa_ofs = segs[0].ds_addr & PAGE_MASK; + + for (i = 0; i < nsegs; i++) { + prplist->gpa_page[i] = atop(segs[i].ds_addr); +#ifdef INVARIANTS + if (i != 0 && i != nsegs - 1) { + KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 && + segs[i].ds_len == PAGE_SIZE, ("not a full page")); + } +#endif + } + reqp->prp_cnt = nsegs; +} + +/** * @brief Fill in a request structure based on a CAM control block * * Fills in a request structure based on the contents of a CAM control @@ -1658,11 +1787,9 @@ create_storvsc_request(union ccb *ccb, s { struct ccb_scsiio *csio = &ccb->csio; uint64_t phys_addr; - uint32_t bytes_to_copy = 0; - uint32_t pfn_num = 0; uint32_t pfn; uint64_t not_aligned_seg_bits = 0; - struct hvs_gpa_range *prplist; + int error; /* refer to struct vmscsi_req for meanings of these two fields */ reqp->vstor_packet.u.vm_srb.port = @@ -1706,36 +1833,26 @@ create_storvsc_request(union ccb *ccb, s return (0); } - prplist = &reqp->prp_list; - prplist->gpa_range.gpa_len = csio->dxfer_len; - switch (ccb->ccb_h.flags & CAM_DATA_MASK) { + case CAM_DATA_BIO: case CAM_DATA_VADDR: - { - bytes_to_copy = csio->dxfer_len; - phys_addr = vtophys(csio->data_ptr); - prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; - - while (bytes_to_copy != 0) { - int bytes, page_offset; - phys_addr = - vtophys(&csio->data_ptr[prplist->gpa_range.gpa_len - - bytes_to_copy]); - pfn = phys_addr >> PAGE_SHIFT; - prplist->gpa_page[pfn_num] = pfn; - page_offset = phys_addr & PAGE_MASK; - - bytes = min(PAGE_SIZE - page_offset, bytes_to_copy); - - bytes_to_copy -= bytes; - pfn_num++; + error = bus_dmamap_load_ccb(reqp->softc->storvsc_req_dtag, + reqp->data_dmap, ccb, storvsc_xferbuf_prepare, reqp, + BUS_DMA_NOWAIT); + if (error) { + xpt_print(ccb->ccb_h.path, + "bus_dmamap_load_ccb failed: %d\n", error); + return (error); } - reqp->prp_cnt = pfn_num; + if ((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_BIO) + reqp->softc->sysctl_data.data_bio_cnt++; + else + reqp->softc->sysctl_data.data_vaddr_cnt++; break; - } case CAM_DATA_SG: { + struct storvsc_gpa_range *prplist; int i = 0; int offset = 0; int ret; @@ -1744,13 +1861,16 @@ create_storvsc_request(union ccb *ccb, s (bus_dma_segment_t *)ccb->csio.data_ptr; u_int16_t storvsc_sg_count = ccb->csio.sglist_cnt; + prplist = &reqp->prp_list; + prplist->gpa_range.gpa_len = csio->dxfer_len; + printf("Storvsc: get SG I/O operation, %d\n", reqp->vstor_packet.u.vm_srb.data_in); - if (storvsc_sg_count > VMBUS_CHAN_PRPLIST_MAX){ + if (storvsc_sg_count > STORVSC_DATA_SEGCNT_MAX){ printf("Storvsc: %d segments is too much, " "only support %d segments\n", - storvsc_sg_count, VMBUS_CHAN_PRPLIST_MAX); + storvsc_sg_count, STORVSC_DATA_SEGCNT_MAX); return (EINVAL); } @@ -1847,6 +1967,7 @@ create_storvsc_request(union ccb *ccb, s reqp->bounce_sgl_count = 0; } + reqp->softc->sysctl_data.data_sg_cnt++; break; } default: From owner-svn-src-stable@freebsd.org Mon Oct 17 05:28:08 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D8B9C1214C; Mon, 17 Oct 2016 05:28:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 108CC1DEA; Mon, 17 Oct 2016 05:28:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H5S7SD063292; Mon, 17 Oct 2016 05:28:07 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H5S6Qc063286; Mon, 17 Oct 2016 05:28:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170528.u9H5S6Qc063286@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 05:28:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307471 - in stable/11/sys/dev/hyperv: include netvsc storvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 05:28:08 -0000 Author: sephe Date: Mon Oct 17 05:28:06 2016 New Revision: 307471 URL: https://svnweb.freebsd.org/changeset/base/307471 Log: MFC 303603-303605,303764 303603 hyperv/vmbus: Remove the artificial entry limit of SG and PRP list. Just make sure that the total channel packet size does not exceed 1/2 data size of the TX bufring. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7359 303604 hyperv/storvsc: Set maxio to 128KB. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7360 303605 hyperv/storvsc: Stringent PRP list assertions Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7361 303764 hyperv/vmbus: Only make sure the TX bufring will not be closed. KVP can write data, whose size is > 1/2 TX bufring size. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7414 Modified: stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 04:30:10 2016 (r307470) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 05:28:06 2016 (r307471) @@ -102,9 +102,6 @@ struct vmbus_chanpkt_rxbuf { struct vmbus_rxbuf_desc cp_rxbuf[]; } __packed; -#define VMBUS_CHAN_SGLIST_MAX 32 -#define VMBUS_CHAN_PRPLIST_MAX 32 - struct vmbus_channel; struct hyperv_guid; Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 04:30:10 2016 (r307470) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 05:28:06 2016 (r307471) @@ -1088,6 +1088,7 @@ struct vmbus_channel; typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) +#define NETVSC_PACKET_MAXPAGE 32 #define NETVSC_VLAN_PRIO_MASK 0xe000 #define NETVSC_VLAN_PRIO_SHIFT 13 @@ -1137,7 +1138,7 @@ typedef struct netvsc_packet_ { uint32_t tot_data_buf_len; void *data; uint32_t gpa_cnt; - struct vmbus_gpa gpa[VMBUS_CHAN_SGLIST_MAX]; + struct vmbus_gpa gpa[NETVSC_PACKET_MAXPAGE]; } netvsc_packet; typedef struct { Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 04:30:10 2016 (r307470) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 05:28:06 2016 (r307471) @@ -152,7 +152,7 @@ __FBSDID("$FreeBSD$"); #define HN_TX_DATA_MAXSIZE IP_MAXPACKET #define HN_TX_DATA_SEGSIZE PAGE_SIZE #define HN_TX_DATA_SEGCNT_MAX \ - (VMBUS_CHAN_SGLIST_MAX - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) + (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) #define HN_DIRECT_TX_SIZE_DEF 128 Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 04:30:10 2016 (r307470) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 05:28:06 2016 (r307471) @@ -88,10 +88,25 @@ __FBSDID("$FreeBSD$"); #define VSTOR_PKT_SIZE (sizeof(struct vstor_packet) - vmscsi_size_delta) -#define STORVSC_DATA_SEGCNT_MAX VMBUS_CHAN_PRPLIST_MAX +/* + * 33 segments are needed to allow 128KB maxio, in case the data + * in the first page is _not_ PAGE_SIZE aligned, e.g. + * + * |<----------- 128KB ----------->| + * | | + * 0 2K 4K 8K 16K 124K 128K 130K + * | | | | | | | | + * +--+--+-----+-----+.......+-----+--+--+ + * | | | | | | | | | DATA + * | | | | | | | | | + * +--+--+-----+-----+.......------+--+--+ + * | | | | + * | 1| 31 | 1| ...... # of segments + */ +#define STORVSC_DATA_SEGCNT_MAX 33 #define STORVSC_DATA_SEGSZ_MAX PAGE_SIZE #define STORVSC_DATA_SIZE_MAX \ - (STORVSC_DATA_SEGCNT_MAX * STORVSC_DATA_SEGSZ_MAX) + ((STORVSC_DATA_SEGCNT_MAX - 1) * STORVSC_DATA_SEGSZ_MAX) struct storvsc_softc; @@ -1388,6 +1403,7 @@ storvsc_action(struct cam_sim *sim, unio cpi->hba_misc = PIM_NOBUSRESET; if (hv_storvsc_use_pim_unmapped) cpi->hba_misc |= PIM_UNMAPPED; + cpi->maxio = STORVSC_DATA_SIZE_MAX; cpi->hba_eng_cnt = 0; cpi->max_target = STORVSC_MAX_TARGETS; cpi->max_lun = sc->hs_drv_props->drv_max_luns_per_target; @@ -1761,13 +1777,28 @@ storvsc_xferbuf_prepare(void *arg, bus_d prplist->gpa_range.gpa_ofs = segs[0].ds_addr & PAGE_MASK; for (i = 0; i < nsegs; i++) { - prplist->gpa_page[i] = atop(segs[i].ds_addr); #ifdef INVARIANTS - if (i != 0 && i != nsegs - 1) { - KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 && - segs[i].ds_len == PAGE_SIZE, ("not a full page")); + if (nsegs > 1) { + if (i == 0) { + KASSERT((segs[i].ds_addr & PAGE_MASK) + + segs[i].ds_len == PAGE_SIZE, + ("invalid 1st page, ofs 0x%jx, len %zu", + (uintmax_t)segs[i].ds_addr, + segs[i].ds_len)); + } else if (i == nsegs - 1) { + KASSERT((segs[i].ds_addr & PAGE_MASK) == 0, + ("invalid last page, ofs 0x%jx", + (uintmax_t)segs[i].ds_addr)); + } else { + KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 && + segs[i].ds_len == PAGE_SIZE, + ("not a full page, ofs 0x%jx, len %zu", + (uintmax_t)segs[i].ds_addr, + segs[i].ds_len)); + } } #endif + prplist->gpa_page[i] = atop(segs[i].ds_addr); } reqp->prp_cnt = nsegs; } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Oct 17 04:30:10 2016 (r307470) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Oct 17 05:28:06 2016 (r307471) @@ -71,6 +71,17 @@ struct vmbus_txbr { struct sysctl_ctx_list; struct sysctl_oid; +static __inline int +vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr) +{ + /* + * - 64 bits for the trailing start index (- sizeof(uint64_t)). + * - The rindex and windex can't be same (- 1). See + * the comment near vmbus_bufring.br_{r,w}index. + */ + return (tbr->txbr_dsize - sizeof(uint64_t) - 1); +} + void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, struct vmbus_br *br, const char *name); Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 04:30:10 2016 (r307470) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 05:28:06 2016 (r307471) @@ -610,6 +610,8 @@ vmbus_chan_send(struct vmbus_channel *ch hlen = sizeof(pkt); pktlen = hlen + dlen; pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr), + ("invalid packet size %d", pad_pktlen)); pkt.cp_hdr.cph_type = type; pkt.cp_hdr.cph_flags = flags; @@ -640,12 +642,11 @@ vmbus_chan_send_sglist(struct vmbus_chan boolean_t send_evt; uint64_t pad = 0; - KASSERT(sglen < VMBUS_CHAN_SGLIST_MAX, - ("invalid sglist len %d", sglen)); - hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); pktlen = hlen + dlen; pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr), + ("invalid packet size %d", pad_pktlen)); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; @@ -681,13 +682,12 @@ vmbus_chan_send_prplist(struct vmbus_cha boolean_t send_evt; uint64_t pad = 0; - KASSERT(prp_cnt < VMBUS_CHAN_PRPLIST_MAX, - ("invalid prplist entry count %d", prp_cnt)); - hlen = __offsetof(struct vmbus_chanpkt_prplist, cp_range[0].gpa_page[prp_cnt]); pktlen = hlen + dlen; pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr), + ("invalid packet size %d", pad_pktlen)); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; From owner-svn-src-stable@freebsd.org Mon Oct 17 05:33:43 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84D7CC1247B; Mon, 17 Oct 2016 05:33:43 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E35D1309; Mon, 17 Oct 2016 05:33:43 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H5XgtL067190; Mon, 17 Oct 2016 05:33:42 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H5XgjC067184; Mon, 17 Oct 2016 05:33:42 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170533.u9H5XgjC067184@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 05:33:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307472 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 05:33:43 -0000 Author: sephe Date: Mon Oct 17 05:33:41 2016 New Revision: 307472 URL: https://svnweb.freebsd.org/changeset/base/307472 Log: MFC 303822-303824 303822 hyperv/ic: Remove never used second parameter of hv_negotiate_version() Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7422 303823 hyperv/ic: Expose the receive buffer length for callers to use. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7423 303824 hyperv/ic: Pass the channel callback to hv_util_attach() The saved channel callback in util softc is actually never used. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7424 Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/utilities/hv_util.c stable/11/sys/dev/hyperv/utilities/hv_util.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 05:28:06 2016 (r307471) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 05:33:41 2016 (r307472) @@ -64,7 +64,7 @@ hv_heartbeat_cb(struct vmbus_channel *ch softc = (hv_util_sc*)context; buf = softc->receive_buffer; - recvlen = PAGE_SIZE; + recvlen = softc->ic_buflen; ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid); KASSERT(ret != ENOBUFS, ("hvheartbeat recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -75,8 +75,7 @@ hv_heartbeat_cb(struct vmbus_channel *ch &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, NULL, buf); - + hv_negotiate_version(icmsghdrp, buf); } else { heartbeat_msg = (struct hv_vmbus_heartbeat_msg_data *) @@ -110,11 +109,7 @@ hv_heartbeat_probe(device_t dev) static int hv_heartbeat_attach(device_t dev) { - hv_util_sc *softc = (hv_util_sc*)device_get_softc(dev); - - softc->callback = hv_heartbeat_cb; - - return hv_util_attach(dev); + return hv_util_attach(dev, hv_heartbeat_cb); } static device_method_t heartbeat_methods[] = { Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 05:28:06 2016 (r307471) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 05:33:41 2016 (r307472) @@ -629,7 +629,7 @@ hv_kvp_process_request(void *context, in kvp_buf = sc->util_sc.receive_buffer; channel = vmbus_get_channel(sc->dev); - recvlen = 2 * PAGE_SIZE; + recvlen = sc->util_sc.ic_buflen; ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -696,7 +696,7 @@ hv_kvp_process_request(void *context, in /* * Try reading next buffer */ - recvlen = 2 * PAGE_SIZE; + recvlen = sc->util_sc.ic_buflen; ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -892,7 +892,6 @@ hv_kvp_attach(device_t dev) hv_kvp_sc *sc = (hv_kvp_sc*)device_get_softc(dev); - sc->util_sc.callback = hv_kvp_callback; sc->dev = dev; sema_init(&sc->dev_sema, 0, "hv_kvp device semaphore"); mtx_init(&sc->pending_mutex, "hv-kvp pending mutex", @@ -920,7 +919,7 @@ hv_kvp_attach(device_t dev) return (error); sc->hv_kvp_dev->si_drv1 = sc; - return hv_util_attach(dev); + return hv_util_attach(dev, hv_kvp_callback); } static int Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 05:28:06 2016 (r307471) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 05:33:41 2016 (r307472) @@ -68,7 +68,7 @@ hv_shutdown_cb(struct vmbus_channel *cha softc = (hv_util_sc*)context; buf = softc->receive_buffer; - recv_len = PAGE_SIZE; + recv_len = softc->ic_buflen; ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id); KASSERT(ret != ENOBUFS, ("hvshutdown recvbuf is not large enough")); /* XXX check recv_len to make sure that it contains enough data */ @@ -79,8 +79,7 @@ hv_shutdown_cb(struct vmbus_channel *cha &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, NULL, buf); - + hv_negotiate_version(icmsghdrp, buf); } else { shutdown_msg = (struct hv_vmbus_shutdown_msg_data *) @@ -132,11 +131,7 @@ hv_shutdown_probe(device_t dev) static int hv_shutdown_attach(device_t dev) { - hv_util_sc *softc = (hv_util_sc*)device_get_softc(dev); - - softc->callback = hv_shutdown_cb; - - return hv_util_attach(dev); + return hv_util_attach(dev, hv_shutdown_cb); } static device_method_t shutdown_methods[] = { Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 05:28:06 2016 (r307471) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 05:33:41 2016 (r307472) @@ -145,7 +145,7 @@ hv_timesync_cb(struct vmbus_channel *cha softc = (hv_timesync_sc*)context; time_buf = softc->util_sc.receive_buffer; - recvlen = PAGE_SIZE; + recvlen = softc->util_sc.ic_buflen; ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -155,7 +155,7 @@ hv_timesync_cb(struct vmbus_channel *cha sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, NULL, time_buf); + hv_negotiate_version(icmsghdrp, time_buf); } else { timedatap = (struct hv_ictimesync_data *) &time_buf[ sizeof(struct hv_vmbus_pipe_hdr) + @@ -189,18 +189,16 @@ hv_timesync_attach(device_t dev) { hv_timesync_sc *softc = device_get_softc(dev); - softc->util_sc.callback = hv_timesync_cb; TASK_INIT(&softc->task, 1, hv_set_host_time, softc); - - return hv_util_attach(dev); + return hv_util_attach(dev, hv_timesync_cb); } static int hv_timesync_detach(device_t dev) { hv_timesync_sc *softc = device_get_softc(dev); - taskqueue_drain(taskqueue_thread, &softc->task); + taskqueue_drain(taskqueue_thread, &softc->task); return hv_util_detach(dev); } Modified: stable/11/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 05:28:06 2016 (r307471) +++ stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 05:33:41 2016 (r307472) @@ -44,12 +44,13 @@ #include #include "hv_util.h" +#define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) + void -hv_negotiate_version( - struct hv_vmbus_icmsg_hdr* icmsghdrp, - struct hv_vmbus_icmsg_negotiate* negop, - uint8_t* buf) +hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf) { + struct hv_vmbus_icmsg_negotiate *negop; + icmsghdrp->icmsgsize = 0x10; negop = (struct hv_vmbus_icmsg_negotiate *)&buf[ @@ -74,16 +75,15 @@ hv_negotiate_version( } int -hv_util_attach(device_t dev) +hv_util_attach(device_t dev, vmbus_chan_callback_t cb) { - struct hv_util_sc* softc; - struct vmbus_channel *chan; - int ret; - - softc = device_get_softc(dev); - softc->receive_buffer = - malloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO); - chan = vmbus_get_channel(dev); + struct hv_util_sc *sc = device_get_softc(dev); + struct vmbus_channel *chan = vmbus_get_channel(dev); + int error; + + sc->ic_buflen = VMBUS_IC_BRSIZE; + sc->receive_buffer = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, + M_WAITOK | M_ZERO); /* * These services are not performance critical and do not need @@ -94,17 +94,13 @@ hv_util_attach(device_t dev) */ vmbus_chan_set_readbatch(chan, false); - ret = vmbus_chan_open(chan, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0, - softc->callback, softc); - - if (ret) - goto error0; - + error = vmbus_chan_open(chan, VMBUS_IC_BRSIZE, VMBUS_IC_BRSIZE, NULL, 0, + cb, sc); + if (error) { + free(sc->receive_buffer, M_DEVBUF); + return (error); + } return (0); - -error0: - free(softc->receive_buffer, M_DEVBUF); - return (ret); } int Modified: stable/11/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 05:28:06 2016 (r307471) +++ stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 05:33:41 2016 (r307472) @@ -31,23 +31,20 @@ #ifndef _HVUTIL_H_ #define _HVUTIL_H_ +#include + /** * hv_util related structures * */ typedef struct hv_util_sc { - /* - * function to process Hyper-V messages - */ - void (*callback)(struct vmbus_channel *, void *); uint8_t *receive_buffer; + int ic_buflen; } hv_util_sc; -void hv_negotiate_version( - struct hv_vmbus_icmsg_hdr* icmsghdrp, - struct hv_vmbus_icmsg_negotiate* negop, - uint8_t* buf); +void hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf); -int hv_util_attach(device_t dev); +int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); int hv_util_detach(device_t dev); + #endif From owner-svn-src-stable@freebsd.org Mon Oct 17 05:37:24 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82801C12501; Mon, 17 Oct 2016 05:37:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 45D5A14BD; Mon, 17 Oct 2016 05:37:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H5bNBt067384; Mon, 17 Oct 2016 05:37:23 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H5bMsV067378; Mon, 17 Oct 2016 05:37:22 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170537.u9H5bMsV067378@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 05:37:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307473 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 05:37:24 -0000 Author: sephe Date: Mon Oct 17 05:37:22 2016 New Revision: 307473 URL: https://svnweb.freebsd.org/changeset/base/307473 Log: MFC 303867,303901 303867 hyperv/hn: Move gpa array out of netvsc_packet. Prepare to deprecate the netvsc_packet. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7436 303901 hyperv/hn: Reorganize send done callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7450 Added: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h - copied unchanged from r303901, head/sys/dev/hyperv/netvsc/if_hnvar.h Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 05:33:41 2016 (r307472) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 05:37:22 2016 (r307473) @@ -68,6 +68,12 @@ static void hv_nv_on_receive_completion( static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); +static void hn_nvs_sent_none(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); + +static struct hn_send_ctx hn_send_ctx_none = + HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); /* * @@ -141,6 +147,7 @@ hv_nv_get_next_send_section(netvsc_dev * static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { + struct hn_send_ctx sndc; netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; @@ -189,9 +196,10 @@ hv_nv_init_rx_buffer_with_net_vsp(struct /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { goto cleanup; } @@ -240,6 +248,7 @@ exit: static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { + struct hn_send_ctx sndc; netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; @@ -287,9 +296,10 @@ hv_nv_init_send_buffer_with_net_vsp(stru /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { goto cleanup; } @@ -348,8 +358,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ ret = vmbus_chan_send(net_dev->sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt); - + (uint64_t)(uintptr_t)&hn_send_ctx_none); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -414,9 +423,8 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne NETVSC_SEND_BUFFER_ID; ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, - revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt); + VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), + (uint64_t)(uintptr_t)&hn_send_ctx_none); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -466,6 +474,7 @@ static int hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, uint32_t nvsp_ver) { + struct hn_send_ctx sndc; nvsp_msg *init_pkt; int ret; @@ -480,9 +489,10 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; /* Send the init request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) return (-1); @@ -524,7 +534,7 @@ hv_nv_send_ndis_config(struct hn_softc * /* Send the configuration packet */ ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) return (-EINVAL); @@ -602,7 +612,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc /* Send the init request */ ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { goto cleanup; } @@ -731,6 +741,43 @@ hv_nv_on_device_remove(struct hn_softc * return (0); } +void +hn_nvs_sent_wakeup(struct hn_send_ctx *sndc __unused, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan __unused, + const struct nvsp_msg_ *msg) +{ + /* Copy the response back */ + memcpy(&net_dev->channel_init_packet, msg, sizeof(nvsp_msg)); + sema_post(&net_dev->channel_init_sema); +} + +static void +hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, + struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + const struct nvsp_msg_ *msg __unused) +{ + /* EMPTY */ +} + +void +hn_chim_free(struct netvsc_dev_ *net_dev, uint32_t chim_idx) +{ + u_long mask; + uint32_t idx; + + idx = chim_idx / BITS_PER_LONG; + KASSERT(idx < net_dev->bitsmap_words, + ("invalid chimney index 0x%x", chim_idx)); + + mask = 1UL << (chim_idx % BITS_PER_LONG); + KASSERT(net_dev->send_section_bitsmap[idx] & mask, + ("index bitmap 0x%lx, chimney index %u, " + "bitmap idx %d, bitmask 0x%lx", + net_dev->send_section_bitsmap[idx], chim_idx, idx, mask)); + + atomic_clear_long(&net_dev->send_section_bitsmap[idx], mask); +} + /* * Net VSC on send completion */ @@ -738,59 +785,15 @@ static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt) { - const nvsp_msg *nvsp_msg_pkt; - netvsc_packet *net_vsc_pkt; + struct hn_send_ctx *sndc; - nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); - - if (nvsp_msg_pkt->hdr.msg_type == nvsp_msg_type_init_complete - || nvsp_msg_pkt->hdr.msg_type - == nvsp_msg_1_type_send_rx_buf_complete - || nvsp_msg_pkt->hdr.msg_type - == nvsp_msg_1_type_send_send_buf_complete - || nvsp_msg_pkt->hdr.msg_type - == nvsp_msg5_type_subchannel) { - /* Copy the response back */ - memcpy(&net_dev->channel_init_packet, nvsp_msg_pkt, - sizeof(nvsp_msg)); - sema_post(&net_dev->channel_init_sema); - } else if (nvsp_msg_pkt->hdr.msg_type == - nvsp_msg_1_type_send_rndis_pkt_complete) { - /* Get the send context */ - net_vsc_pkt = - (netvsc_packet *)(unsigned long)pkt->cph_xactid; - if (NULL != net_vsc_pkt) { - if (net_vsc_pkt->send_buf_section_idx != - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { - u_long mask; - int idx; - - idx = net_vsc_pkt->send_buf_section_idx / - BITS_PER_LONG; - KASSERT(idx < net_dev->bitsmap_words, - ("invalid section index %u", - net_vsc_pkt->send_buf_section_idx)); - mask = 1UL << - (net_vsc_pkt->send_buf_section_idx % - BITS_PER_LONG); - - KASSERT(net_dev->send_section_bitsmap[idx] & - mask, - ("index bitmap 0x%lx, section index %u, " - "bitmap idx %d, bitmask 0x%lx", - net_dev->send_section_bitsmap[idx], - net_vsc_pkt->send_buf_section_idx, - idx, mask)); - atomic_clear_long( - &net_dev->send_section_bitsmap[idx], mask); - } - - /* Notify the layer above us */ - net_vsc_pkt->compl.send.on_send_completion(chan, - net_vsc_pkt->compl.send.send_completion_context); - - } - } + sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; + sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt)); + /* + * NOTE: + * 'sndc' CAN NOT be accessed anymore, since it can be freed by + * its callback. + */ } /* @@ -799,13 +802,14 @@ hv_nv_on_send_completion(netvsc_dev *net * Returns 0 on success, non-zero on failure. */ int -hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt) +hv_nv_on_send(struct vmbus_channel *chan, bool is_data_pkt, + struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) { nvsp_msg send_msg; int ret; send_msg.hdr.msg_type = nvsp_msg_1_type_send_rndis_pkt; - if (pkt->is_data_pkt) { + if (is_data_pkt) { /* 0 is RMC_DATA */ send_msg.msgs.vers_1_msgs.send_rndis_pkt.chan_type = 0; } else { @@ -814,17 +818,17 @@ hv_nv_on_send(struct vmbus_channel *chan } send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_idx = - pkt->send_buf_section_idx; + sndc->hn_chim_idx; send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_size = - pkt->send_buf_section_size; + sndc->hn_chim_sz; - if (pkt->gpa_cnt) { - ret = vmbus_chan_send_sglist(chan, pkt->gpa, pkt->gpa_cnt, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); + if (gpa_cnt) { + ret = vmbus_chan_send_sglist(chan, gpa, gpa_cnt, + &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); } else { ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); + &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); } return (ret); Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 05:33:41 2016 (r307472) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 05:37:22 2016 (r307473) @@ -1112,33 +1112,10 @@ typedef void (*pfn_on_send_rx_completion #endif typedef struct netvsc_packet_ { - uint8_t is_data_pkt; /* One byte */ - uint16_t vlan_tci; - uint32_t status; - - /* Completion */ - union { - struct { - uint64_t rx_completion_tid; - void *rx_completion_context; - /* This is no longer used */ - pfn_on_send_rx_completion on_rx_completion; - } rx; - struct { - uint64_t send_completion_tid; - void *send_completion_context; - /* Still used in netvsc and filter code */ - pfn_on_send_rx_completion on_send_completion; - } send; - } compl; - uint32_t send_buf_section_idx; - uint32_t send_buf_section_size; - - void *rndis_mesg; + uint16_t vlan_tci; + uint32_t status; uint32_t tot_data_buf_len; void *data; - uint32_t gpa_cnt; - struct vmbus_gpa gpa[NETVSC_PACKET_MAXPAGE]; } netvsc_packet; typedef struct { @@ -1216,6 +1193,9 @@ struct hn_tx_ring { bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; + int hn_gpa_cnt; + struct vmbus_gpa hn_gpa[NETVSC_PACKET_MAXPAGE]; + u_long hn_no_txdescs; u_long hn_send_failed; u_long hn_txdma_failed; @@ -1269,13 +1249,15 @@ typedef struct hn_softc { * Externs */ extern int hv_promisc_mode; +struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, void *additional_info, struct hn_rx_ring *rxr); int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); -int hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt); +int hv_nv_on_send(struct vmbus_channel *chan, bool is_data_pkt, + struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); int hv_nv_get_next_send_section(netvsc_dev *net_dev); void hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 05:33:41 2016 (r307472) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 05:37:22 2016 (r307473) @@ -166,7 +166,7 @@ struct hn_txdesc { struct hn_tx_ring *txr; int refs; uint32_t flags; /* HN_TXD_FLAG_ */ - netvsc_packet netvsc_pkt; /* XXX to be removed */ + struct hn_send_ctx send_ctx; bus_dmamap_t data_dmap; @@ -781,14 +781,14 @@ hn_txeof(struct hn_tx_ring *txr) } static void -hn_tx_done(struct vmbus_channel *chan, void *xpkt) +hn_tx_done(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, + struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused) { - netvsc_packet *packet = xpkt; - struct hn_txdesc *txd; + struct hn_txdesc *txd = sndc->hn_cbarg; struct hn_tx_ring *txr; - txd = (struct hn_txdesc *)(uintptr_t) - packet->compl.send.send_completion_tid; + if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) + hn_chim_free(net_dev, sndc->hn_chim_idx); txr = txd->txr; KASSERT(txr->hn_chan == chan, @@ -835,16 +835,14 @@ hn_encap(struct hn_tx_ring *txr, struct bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i; struct mbuf *m_head = *m_head0; - netvsc_packet *packet; rndis_msg *rndis_mesg; rndis_packet *rndis_pkt; rndis_per_packet_info *rppi; struct rndis_hash_value *hash_value; - uint32_t rndis_msg_size; + uint32_t rndis_msg_size, tot_data_buf_len, send_buf_section_idx; + int send_buf_section_size; - packet = &txd->netvsc_pkt; - packet->is_data_pkt = TRUE; - packet->tot_data_buf_len = m_head->m_pkthdr.len; + tot_data_buf_len = m_head->m_pkthdr.len; /* * extension points to the area reserved for the @@ -859,7 +857,7 @@ hn_encap(struct hn_tx_ring *txr, struct rndis_pkt = &rndis_mesg->msg.packet; rndis_pkt->data_offset = sizeof(rndis_packet); - rndis_pkt->data_length = packet->tot_data_buf_len; + rndis_pkt->data_length = tot_data_buf_len; rndis_pkt->per_pkt_info_offset = sizeof(rndis_packet); rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet); @@ -967,15 +965,14 @@ hn_encap(struct hn_tx_ring *txr, struct } } - rndis_mesg->msg_len = packet->tot_data_buf_len + rndis_msg_size; - packet->tot_data_buf_len = rndis_mesg->msg_len; + rndis_mesg->msg_len = tot_data_buf_len + rndis_msg_size; + tot_data_buf_len = rndis_mesg->msg_len; /* * Chimney send, if the packet could fit into one chimney buffer. */ - if (packet->tot_data_buf_len < txr->hn_tx_chimney_size) { + if (tot_data_buf_len < txr->hn_tx_chimney_size) { netvsc_dev *net_dev = txr->hn_sc->net_dev; - uint32_t send_buf_section_idx; txr->hn_tx_chimney_tried++; send_buf_section_idx = @@ -990,10 +987,8 @@ hn_encap(struct hn_tx_ring *txr, struct dest += rndis_msg_size; m_copydata(m_head, 0, m_head->m_pkthdr.len, dest); - packet->send_buf_section_idx = send_buf_section_idx; - packet->send_buf_section_size = - packet->tot_data_buf_len; - packet->gpa_cnt = 0; + send_buf_section_size = tot_data_buf_len; + txr->hn_gpa_cnt = 0; txr->hn_tx_chimney++; goto done; } @@ -1019,19 +1014,19 @@ hn_encap(struct hn_tx_ring *txr, struct } *m_head0 = m_head; - packet->gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; + txr->hn_gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; /* send packet with page buffer */ - packet->gpa[0].gpa_page = atop(txd->rndis_msg_paddr); - packet->gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; - packet->gpa[0].gpa_len = rndis_msg_size; + txr->hn_gpa[0].gpa_page = atop(txd->rndis_msg_paddr); + txr->hn_gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; + txr->hn_gpa[0].gpa_len = rndis_msg_size; /* * Fill the page buffers with mbuf info starting at index * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. */ for (i = 0; i < nsegs; ++i) { - struct vmbus_gpa *gpa = &packet->gpa[ + struct vmbus_gpa *gpa = &txr->hn_gpa[ i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; gpa->gpa_page = atop(segs[i].ds_addr); @@ -1039,16 +1034,14 @@ hn_encap(struct hn_tx_ring *txr, struct gpa->gpa_len = segs[i].ds_len; } - packet->send_buf_section_idx = - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; - packet->send_buf_section_size = 0; + send_buf_section_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + send_buf_section_size = 0; done: txd->m = m_head; /* Set the completion routine */ - packet->compl.send.on_send_completion = hn_tx_done; - packet->compl.send.send_completion_context = packet; - packet->compl.send.send_completion_tid = (uint64_t)(uintptr_t)txd; + hn_send_ctx_init(&txd->send_ctx, hn_tx_done, txd, + send_buf_section_idx, send_buf_section_size); return 0; } @@ -1068,7 +1061,8 @@ again: * Make sure that txd is not freed before ETHER_BPF_MTAP. */ hn_txdesc_hold(txd); - error = hv_nv_on_send(txr->hn_chan, &txd->netvsc_pkt); + error = hv_nv_on_send(txr->hn_chan, true, &txd->send_ctx, + txr->hn_gpa, txr->hn_gpa_cnt); if (!error) { ETHER_BPF_MTAP(ifp, txd->m); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 05:33:41 2016 (r307472) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 05:37:22 2016 (r307473) @@ -85,11 +85,17 @@ static int hv_rf_set_packet_filter(rndi static int hv_rf_init_device(rndis_device *device); static int hv_rf_open_device(rndis_device *device); static int hv_rf_close_device(rndis_device *device); -static void hv_rf_on_send_request_completion(struct vmbus_channel *, void *context); -static void hv_rf_on_send_request_halt_completion(struct vmbus_channel *, void *context); int hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads); + +static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); +static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); + /* * Set the Per-Packet-Info with the specified type */ @@ -238,45 +244,36 @@ static int hv_rf_send_request(rndis_device *device, rndis_request *request, uint32_t message_type) { - int ret; - netvsc_packet *packet; netvsc_dev *net_dev = device->net_dev; - int send_buf_section_idx; + uint32_t send_buf_section_idx, tot_data_buf_len; + struct vmbus_gpa gpa[2]; + int gpa_cnt, send_buf_section_size; + hn_sent_callback_t cb; /* Set up the packet to send it */ - packet = &request->pkt; - - packet->is_data_pkt = FALSE; - packet->tot_data_buf_len = request->request_msg.msg_len; - packet->gpa_cnt = 1; - - packet->gpa[0].gpa_page = - hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; - packet->gpa[0].gpa_len = request->request_msg.msg_len; - packet->gpa[0].gpa_ofs = - (unsigned long)&request->request_msg & (PAGE_SIZE - 1); - - if (packet->gpa[0].gpa_ofs + packet->gpa[0].gpa_len > PAGE_SIZE) { - packet->gpa_cnt = 2; - packet->gpa[0].gpa_len = PAGE_SIZE - packet->gpa[0].gpa_ofs; - packet->gpa[1].gpa_page = - hv_get_phys_addr((char*)&request->request_msg + - packet->gpa[0].gpa_len) >> PAGE_SHIFT; - packet->gpa[1].gpa_ofs = 0; - packet->gpa[1].gpa_len = request->request_msg.msg_len - - packet->gpa[0].gpa_len; - } - - packet->compl.send.send_completion_context = request; /* packet */ - if (message_type != REMOTE_NDIS_HALT_MSG) { - packet->compl.send.on_send_completion = - hv_rf_on_send_request_completion; - } else { - packet->compl.send.on_send_completion = - hv_rf_on_send_request_halt_completion; + tot_data_buf_len = request->request_msg.msg_len; + + gpa_cnt = 1; + gpa[0].gpa_page = hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; + gpa[0].gpa_len = request->request_msg.msg_len; + gpa[0].gpa_ofs = (unsigned long)&request->request_msg & (PAGE_SIZE - 1); + + if (gpa[0].gpa_ofs + gpa[0].gpa_len > PAGE_SIZE) { + gpa_cnt = 2; + gpa[0].gpa_len = PAGE_SIZE - gpa[0].gpa_ofs; + gpa[1].gpa_page = + hv_get_phys_addr((char*)&request->request_msg + + gpa[0].gpa_len) >> PAGE_SHIFT; + gpa[1].gpa_ofs = 0; + gpa[1].gpa_len = request->request_msg.msg_len - gpa[0].gpa_len; } - packet->compl.send.send_completion_tid = (unsigned long)device; - if (packet->tot_data_buf_len < net_dev->send_section_size) { + + if (message_type != REMOTE_NDIS_HALT_MSG) + cb = hn_rndis_sent_cb; + else + cb = hn_rndis_sent_halt; + + if (tot_data_buf_len < net_dev->send_section_size) { send_buf_section_idx = hv_nv_get_next_send_section(net_dev); if (send_buf_section_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { @@ -284,20 +281,20 @@ hv_rf_send_request(rndis_device *device, send_buf_section_idx * net_dev->send_section_size); memcpy(dest, &request->request_msg, request->request_msg.msg_len); - packet->send_buf_section_idx = send_buf_section_idx; - packet->send_buf_section_size = packet->tot_data_buf_len; - packet->gpa_cnt = 0; + send_buf_section_size = tot_data_buf_len; + gpa_cnt = 0; goto sendit; } /* Failed to allocate chimney send buffer; move on */ } - packet->send_buf_section_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; - packet->send_buf_section_size = 0; + send_buf_section_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + send_buf_section_size = 0; sendit: - ret = hv_nv_on_send(device->net_dev->sc->hn_prichan, packet); - - return (ret); + hn_send_ctx_init(&request->send_ctx, cb, request, + send_buf_section_idx, send_buf_section_size); + return hv_nv_on_send(device->net_dev->sc->hn_prichan, false, + &request->send_ctx, gpa, gpa_cnt); } /* @@ -1059,6 +1056,7 @@ int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan, struct hn_rx_ring *rxr) { + struct hn_send_ctx sndc; int ret; netvsc_dev *net_dev; rndis_device *rndis_dev; @@ -1165,9 +1163,10 @@ hv_rf_on_device_add(struct hn_softc *sc, init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = net_dev->num_channel - 1; + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { device_printf(dev, "Fail to allocate subchannel\n"); goto out; @@ -1238,23 +1237,22 @@ hv_rf_on_close(struct hn_softc *sc) return (hv_rf_close_device((rndis_device *)net_dev->extension)); } -/* - * RNDIS filter on send request completion callback - */ -static void -hv_rf_on_send_request_completion(struct vmbus_channel *chan __unused, - void *context __unused) +static void +hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) { + if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) + hn_chim_free(net_dev, sndc->hn_chim_idx); } -/* - * RNDIS filter on send request (halt only) completion callback - */ -static void -hv_rf_on_send_request_halt_completion(struct vmbus_channel *chan __unused, - void *context) +static void +hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) { - rndis_request *request = context; + rndis_request *request = sndc->hn_cbarg; + + if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) + hn_chim_free(net_dev, sndc->hn_chim_idx); /* * Notify hv_rf_halt_device() about halt completion. Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 05:33:41 2016 (r307472) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 05:37:22 2016 (r307473) @@ -33,6 +33,7 @@ #include #include +#include /* * Defines @@ -75,7 +76,7 @@ typedef struct rndis_request_ { uint8_t buf_resp[PAGE_SIZE]; /* Simplify allocation by having a netvsc packet inline */ - netvsc_packet pkt; + struct hn_send_ctx send_ctx; /* * The max request size is sizeof(rndis_msg) + PAGE_SIZE. Copied: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h (from r303901, head/sys/dev/hyperv/netvsc/if_hnvar.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 05:37:22 2016 (r307473, copy of r303901, head/sys/dev/hyperv/netvsc/if_hnvar.h) @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _IF_HNVAR_H_ +#define _IF_HNVAR_H_ + +#include +#include + +struct netvsc_dev_; +struct nvsp_msg_; + +struct vmbus_channel; +struct hn_send_ctx; + +typedef void (*hn_sent_callback_t) + (struct hn_send_ctx *, struct netvsc_dev_ *, + struct vmbus_channel *, const struct nvsp_msg_ *); + +struct hn_send_ctx { + hn_sent_callback_t hn_cb; + void *hn_cbarg; + uint32_t hn_chim_idx; + int hn_chim_sz; +}; + +#define HN_SEND_CTX_INITIALIZER(cb, cbarg) \ +{ \ + .hn_cb = cb, \ + .hn_cbarg = cbarg, \ + .hn_chim_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX, \ + .hn_chim_sz = 0 \ +} + +static __inline void +hn_send_ctx_init(struct hn_send_ctx *sndc, hn_sent_callback_t cb, + void *cbarg, uint32_t chim_idx, int chim_sz) +{ + sndc->hn_cb = cb; + sndc->hn_cbarg = cbarg; + sndc->hn_chim_idx = chim_idx; + sndc->hn_chim_sz = chim_sz; +} + +static __inline void +hn_send_ctx_init_simple(struct hn_send_ctx *sndc, hn_sent_callback_t cb, + void *cbarg) +{ + hn_send_ctx_init(sndc, cb, cbarg, + NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX, 0); +} + +void hn_nvs_sent_wakeup(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); +void hn_chim_free(struct netvsc_dev_ *net_dev, uint32_t chim_idx); + +#endif /* !_IF_HNVAR_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 05:39:46 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C2D5C12574; Mon, 17 Oct 2016 05:39:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BFD81643; Mon, 17 Oct 2016 05:39:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H5djQL067520; Mon, 17 Oct 2016 05:39:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H5djIi067519; Mon, 17 Oct 2016 05:39:45 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170539.u9H5djIi067519@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 05:39:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307474 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 05:39:46 -0000 Author: sephe Date: Mon Oct 17 05:39:45 2016 New Revision: 307474 URL: https://svnweb.freebsd.org/changeset/base/307474 Log: MFC 303944 cam/da: Add quirk for I-O Data USB Flash Disk PR: 211716 Submitted by: Jun Su Reported by: Jun Su Sponsored by: Microsoft Modified: stable/11/sys/cam/scsi/scsi_da.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_da.c Mon Oct 17 05:37:22 2016 (r307473) +++ stable/11/sys/cam/scsi/scsi_da.c Mon Oct 17 05:39:45 2016 (r307474) @@ -814,6 +814,14 @@ static struct da_quirk_entry da_quirk_ta {T_DIRECT, SIP_MEDIA_REMOVABLE, "JetFlash", "Transcend*", "*"}, /*quirks*/ DA_Q_NO_RC16 }, + { + /* + * I-O Data USB Flash Disk + * PR: usb/211716 + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "I-O DATA", "USB Flash Disk*", + "*"}, /*quirks*/ DA_Q_NO_RC16 + }, /* ATA/SATA devices over SAS/USB/... */ { /* Hitachi Advanced Format (4k) drives */ From owner-svn-src-stable@freebsd.org Mon Oct 17 05:53:40 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94305C128C3; Mon, 17 Oct 2016 05:53:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 25F941CC4; Mon, 17 Oct 2016 05:53:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H5rdHr075055; Mon, 17 Oct 2016 05:53:39 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H5rcqb075044; Mon, 17 Oct 2016 05:53:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170553.u9H5rcqb075044@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 05:53:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307475 - in stable/11/sys: conf dev/hyperv/include dev/hyperv/netvsc dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 05:53:40 -0000 Author: sephe Date: Mon Oct 17 05:53:38 2016 New Revision: 307475 URL: https://svnweb.freebsd.org/changeset/base/307475 Log: MFC 303945,303947-303949,303989,303992,303998,304001,304002,304109,304111 303945 hyperv/vmbus: Add macro to get channel packet data length. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7455 303947 hyperv/vmbus: Add APIs for various types of transactions. Reviewed by: Jun Su Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7456 303948 hyperv/hn: Switch to vmbus xact APIs for NVS initialization Reviewed by: Jun Su Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7457 303949 hyperv/vmbus: Use xact APIs to implement post message Hypercall APIs Avoid code duplication. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7458 303989 hyperv/hn: Simplify NDIS configuration. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7466 303992 hyperv/hn: Simplify NDIS initialization. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7467 303998 hyperv/hn: Switch to vmbus xact APIs for NVS RXBUF connection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7469 304001 hyperv/hn: Switch to vmbus xact APIs for NVS chimney buffer connection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7470 304002 hyperv/hn: Simplify RXBUF disconnection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7472 304109 hyperv/hn: Simplify chimney sending buffer disconnection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7479 304111 hyperv/hn: Switch to vmbus xact APIs for sub-channel alloc request. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7480 Added: stable/11/sys/dev/hyperv/include/vmbus_xact.h - copied, changed from r303947, head/sys/dev/hyperv/include/vmbus_xact.h stable/11/sys/dev/hyperv/netvsc/if_hnreg.h - copied, changed from r303948, head/sys/dev/hyperv/netvsc/if_hnreg.h stable/11/sys/dev/hyperv/vmbus/vmbus_xact.c - copied, changed from r303947, head/sys/dev/hyperv/vmbus/vmbus_xact.c Modified: stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.i386 stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis.h stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h stable/11/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/conf/files.amd64 Mon Oct 17 05:53:38 2016 (r307475) @@ -308,6 +308,7 @@ dev/hyperv/vmbus/vmbus_br.c optional dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv +dev/hyperv/vmbus/vmbus_xact.c optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv dev/nfe/if_nfe.c optional nfe pci Modified: stable/11/sys/conf/files.i386 ============================================================================== --- stable/11/sys/conf/files.i386 Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/conf/files.i386 Mon Oct 17 05:53:38 2016 (r307475) @@ -265,6 +265,7 @@ dev/hyperv/vmbus/vmbus_br.c optional dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv +dev/hyperv/vmbus/vmbus_xact.c optional hyperv dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv dev/ichwd/ichwd.c optional ichwd Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 05:53:38 2016 (r307475) @@ -89,6 +89,11 @@ struct vmbus_chanpkt_hdr { (const void *)((const uint8_t *)(pkt) + \ VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen)) +/* Include padding */ +#define VMBUS_CHANPKT_DATALEN(pkt) \ + (VMBUS_CHANPKT_GETLEN((pkt)->cph_tlen) -\ + VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen)) + struct vmbus_rxbuf_desc { uint32_t rb_len; uint32_t rb_ofs; Copied and modified: stable/11/sys/dev/hyperv/include/vmbus_xact.h (from r303947, head/sys/dev/hyperv/include/vmbus_xact.h) ============================================================================== --- head/sys/dev/hyperv/include/vmbus_xact.h Thu Aug 11 05:49:49 2016 (r303947, copy source) +++ stable/11/sys/dev/hyperv/include/vmbus_xact.h Mon Oct 17 05:53:38 2016 (r307475) @@ -36,7 +36,8 @@ struct vmbus_xact; struct vmbus_xact_ctx; struct vmbus_xact_ctx *vmbus_xact_ctx_create(bus_dma_tag_t dtag, - size_t req_size, size_t resp_size); + size_t req_size, size_t resp_size, + size_t priv_size); void vmbus_xact_ctx_destroy(struct vmbus_xact_ctx *ctx); struct vmbus_xact *vmbus_xact_get(struct vmbus_xact_ctx *ctx, size_t req_len); @@ -44,11 +45,15 @@ void vmbus_xact_put(struct vmbus_xact void *vmbus_xact_req_data(const struct vmbus_xact *xact); bus_addr_t vmbus_xact_req_paddr(const struct vmbus_xact *xact); +void *vmbus_xact_priv(const struct vmbus_xact *xact, + size_t priv_len); void vmbus_xact_activate(struct vmbus_xact *xact); void vmbus_xact_deactivate(struct vmbus_xact *xact); const void *vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len); void vmbus_xact_wakeup(struct vmbus_xact *xact, const void *data, size_t dlen); +void vmbus_xact_ctx_wakeup(struct vmbus_xact_ctx *ctx, + const void *data, size_t dlen); #endif /* !_VMBUS_XACT_H_ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 05:53:38 2016 (r307475) @@ -45,9 +45,11 @@ #include #include -#include "hv_net_vsc.h" -#include "hv_rndis.h" -#include "hv_rndis_filter.h" +#include +#include +#include +#include +#include MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); @@ -70,7 +72,7 @@ static void hv_nv_on_receive(netvsc_dev const struct vmbus_chanpkt_hdr *pkt); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg); + const struct nvsp_msg_ *msg, int); static struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); @@ -147,10 +149,14 @@ hv_nv_get_next_send_section(netvsc_dev * static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { + struct vmbus_xact *xact; + struct hn_nvs_rxbuf_conn *conn; + const struct hn_nvs_rxbuf_connresp *resp; + size_t resp_len; struct hn_send_ctx sndc; netvsc_dev *net_dev; - nvsp_msg *init_pkt; - int ret = 0; + uint32_t status; + int error; net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { @@ -162,7 +168,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct BUS_DMA_WAITOK | BUS_DMA_ZERO); if (net_dev->rx_buf == NULL) { device_printf(sc->hn_dev, "allocate rxbuf failed\n"); - return ENOMEM; + return (ENOMEM); } /* @@ -172,74 +178,76 @@ hv_nv_init_rx_buffer_with_net_vsp(struct * Only primary channel has RXBUF connected to it. Sub-channels * just share this RXBUF. */ - ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + error = vmbus_chan_gpadl_connect(sc->hn_prichan, net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle); - if (ret != 0) { - device_printf(sc->hn_dev, "rxbuf gpadl connect failed: %d\n", - ret); + if (error) { + if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n", + error); goto cleanup; } - - /* sema_wait(&ext->channel_init_sema); KYS CHECK */ - /* Notify the NetVsp of the gpadl handle */ - init_pkt = &net_dev->channel_init_packet; + /* + * Connect RXBUF to NVS. + */ - memset(init_pkt, 0, sizeof(nvsp_msg)); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*conn)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs rxbuf conn\n"); + error = ENXIO; + goto cleanup; + } - init_pkt->hdr.msg_type = nvsp_msg_1_type_send_rx_buf; - init_pkt->msgs.vers_1_msgs.send_rx_buf.gpadl_handle = - net_dev->rx_buf_gpadl_handle; - init_pkt->msgs.vers_1_msgs.send_rx_buf.id = - NETVSC_RECEIVE_BUFFER_ID; + conn = vmbus_xact_req_data(xact); + conn->nvs_type = HN_NVS_TYPE_RXBUF_CONN; + conn->nvs_gpadl = net_dev->rx_buf_gpadl_handle; + conn->nvs_sig = HN_NVS_RXBUF_SIG; - /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); - ret = vmbus_chan_send(sc->hn_prichan, + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); - if (ret != 0) { + conn, sizeof(*conn), (uint64_t)(uintptr_t)&sndc); + if (error != 0) { + if_printf(sc->hn_ifp, "send nvs rxbuf conn failed: %d\n", + error); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); goto cleanup; } - sema_wait(&net_dev->channel_init_sema); - - /* Check the response */ - if (init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.status - != nvsp_status_success) { - ret = EINVAL; + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid rxbuf conn resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + error = EINVAL; + goto cleanup; + } + if (resp->nvs_type != HN_NVS_TYPE_RXBUF_CONNRESP) { + if_printf(sc->hn_ifp, "not rxbuf conn resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); + error = EINVAL; goto cleanup; } - net_dev->rx_section_count = - init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.num_sections; - - net_dev->rx_sections = malloc(net_dev->rx_section_count * - sizeof(nvsp_1_rx_buf_section), M_NETVSC, M_WAITOK); - memcpy(net_dev->rx_sections, - init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.sections, - net_dev->rx_section_count * sizeof(nvsp_1_rx_buf_section)); - + status = resp->nvs_status; + vmbus_xact_put(xact); - /* - * For first release, there should only be 1 section that represents - * the entire receive buffer - */ - if (net_dev->rx_section_count != 1 - || net_dev->rx_sections->offset != 0) { - ret = EINVAL; + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status); + error = EIO; goto cleanup; } + net_dev->rx_section_count = 1; - goto exit; + return (0); cleanup: hv_nv_destroy_rx_buffer(net_dev); - -exit: - return (ret); + return (error); } /* @@ -249,9 +257,13 @@ static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { struct hn_send_ctx sndc; + struct vmbus_xact *xact; + struct hn_nvs_chim_conn *chim; + const struct hn_nvs_chim_connresp *resp; + size_t resp_len; + uint32_t status, sectsz; netvsc_dev *net_dev; - nvsp_msg *init_pkt; - int ret = 0; + int error; net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { @@ -263,7 +275,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru BUS_DMA_WAITOK | BUS_DMA_ZERO); if (net_dev->send_buf == NULL) { device_printf(sc->hn_dev, "allocate chimney txbuf failed\n"); - return ENOMEM; + return (ENOMEM); } /* @@ -273,48 +285,77 @@ hv_nv_init_send_buffer_with_net_vsp(stru * Only primary channel has chimney sending buffer connected to it. * Sub-channels just share this chimney sending buffer. */ - ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + error = vmbus_chan_gpadl_connect(sc->hn_prichan, net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size, &net_dev->send_buf_gpadl_handle); - if (ret != 0) { - device_printf(sc->hn_dev, "chimney sending buffer gpadl " - "connect failed: %d\n", ret); + if (error) { + if_printf(sc->hn_ifp, "chimney sending buffer gpadl " + "connect failed: %d\n", error); goto cleanup; } - /* Notify the NetVsp of the gpadl handle */ - - init_pkt = &net_dev->channel_init_packet; + /* + * Connect chimney sending buffer to NVS + */ - memset(init_pkt, 0, sizeof(nvsp_msg)); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*chim)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs chim conn\n"); + error = ENXIO; + goto cleanup; + } - init_pkt->hdr.msg_type = nvsp_msg_1_type_send_send_buf; - init_pkt->msgs.vers_1_msgs.send_rx_buf.gpadl_handle = - net_dev->send_buf_gpadl_handle; - init_pkt->msgs.vers_1_msgs.send_rx_buf.id = - NETVSC_SEND_BUFFER_ID; + chim = vmbus_xact_req_data(xact); + chim->nvs_type = HN_NVS_TYPE_CHIM_CONN; + chim->nvs_gpadl = net_dev->send_buf_gpadl_handle; + chim->nvs_sig = HN_NVS_CHIM_SIG; - /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); - ret = vmbus_chan_send(sc->hn_prichan, + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); - if (ret != 0) { + chim, sizeof(*chim), (uint64_t)(uintptr_t)&sndc); + if (error) { + if_printf(sc->hn_ifp, "send nvs chim conn failed: %d\n", + error); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); goto cleanup; } - sema_wait(&net_dev->channel_init_sema); + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid chim conn resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + error = EINVAL; + goto cleanup; + } + if (resp->nvs_type != HN_NVS_TYPE_CHIM_CONNRESP) { + if_printf(sc->hn_ifp, "not chim conn resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); + error = EINVAL; + goto cleanup; + } - /* Check the response */ - if (init_pkt->msgs.vers_1_msgs.send_send_buf_complete.status - != nvsp_status_success) { - ret = EINVAL; + status = resp->nvs_status; + sectsz = resp->nvs_sectsz; + vmbus_xact_put(xact); + + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "chim conn failed: %x\n", status); + error = EIO; goto cleanup; } + if (sectsz == 0) { + if_printf(sc->hn_ifp, "zero chimney sending buffer " + "section size\n"); + return 0; + } - net_dev->send_section_size = - init_pkt->msgs.vers_1_msgs.send_send_buf_complete.section_size; + net_dev->send_section_size = sectsz; net_dev->send_section_count = net_dev->send_buf_size / net_dev->send_section_size; net_dev->bitsmap_words = howmany(net_dev->send_section_count, @@ -323,13 +364,15 @@ hv_nv_init_send_buffer_with_net_vsp(stru malloc(net_dev->bitsmap_words * sizeof(long), M_NETVSC, M_WAITOK | M_ZERO); - goto exit; + if (bootverbose) { + if_printf(sc->hn_ifp, "chimney sending buffer %u/%u\n", + net_dev->send_section_size, net_dev->send_section_count); + } + return 0; cleanup: hv_nv_destroy_send_buffer(net_dev); - -exit: - return (ret); + return (error); } /* @@ -338,34 +381,27 @@ exit: static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev) { - nvsp_msg *revoke_pkt; int ret = 0; - /* - * If we got a section count, it means we received a - * send_rx_buf_complete msg - * (ie sent nvsp_msg_1_type_send_rx_buf msg) therefore, - * we need to send a revoke msg here - */ if (net_dev->rx_section_count) { - /* Send the revoke receive buffer */ - revoke_pkt = &net_dev->revoke_packet; - memset(revoke_pkt, 0, sizeof(nvsp_msg)); - - revoke_pkt->hdr.msg_type = nvsp_msg_1_type_revoke_rx_buf; - revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id = - NETVSC_RECEIVE_BUFFER_ID; + struct hn_nvs_rxbuf_disconn disconn; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)&hn_send_ctx_none); /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect RXBUF from NVS. */ + memset(&disconn, 0, sizeof(disconn)); + disconn.nvs_type = HN_NVS_TYPE_RXBUF_DISCONN; + disconn.nvs_sig = HN_NVS_RXBUF_SIG; + + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), + (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { + if_printf(net_dev->sc->hn_ifp, + "send rxbuf disconn failed: %d\n", ret); return (ret); } + net_dev->rx_section_count = 0; } /* Tear down the gpadl on the vsp end */ @@ -388,12 +424,6 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ net_dev->rx_buf = NULL; } - if (net_dev->rx_sections) { - free(net_dev->rx_sections, M_NETVSC); - net_dev->rx_sections = NULL; - net_dev->rx_section_count = 0; - } - return (ret); } @@ -403,33 +433,24 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev) { - nvsp_msg *revoke_pkt; int ret = 0; - /* - * If we got a section count, it means we received a - * send_rx_buf_complete msg - * (ie sent nvsp_msg_1_type_send_rx_buf msg) therefore, - * we need to send a revoke msg here - */ if (net_dev->send_section_size) { - /* Send the revoke send buffer */ - revoke_pkt = &net_dev->revoke_packet; - memset(revoke_pkt, 0, sizeof(nvsp_msg)); - - revoke_pkt->hdr.msg_type = - nvsp_msg_1_type_revoke_send_buf; - revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id = - NETVSC_SEND_BUFFER_ID; + struct hn_nvs_chim_disconn disconn; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)&hn_send_ctx_none); /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect chimney sending buffer from NVS. */ + memset(&disconn, 0, sizeof(disconn)); + disconn.nvs_type = HN_NVS_TYPE_CHIM_DISCONN; + disconn.nvs_sig = HN_NVS_CHIM_SIG; + + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), + (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { + if_printf(net_dev->sc->hn_ifp, + "send chim disconn failed: %d\n", ret); return (ret); } } @@ -462,45 +483,64 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne return (ret); } - -/* - * Attempt to negotiate the caller-specified NVSP version - * - * For NVSP v2, Server 2008 R2 does not set - * init_pkt->msgs.init_msgs.init_compl.negotiated_prot_vers - * to the negotiated version, so we cannot rely on that. - */ static int hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, - uint32_t nvsp_ver) + uint32_t nvs_ver) { struct hn_send_ctx sndc; - nvsp_msg *init_pkt; - int ret; - - init_pkt = &net_dev->channel_init_packet; - memset(init_pkt, 0, sizeof(nvsp_msg)); - init_pkt->hdr.msg_type = nvsp_msg_type_init; + struct vmbus_xact *xact; + struct hn_nvs_init *init; + const struct hn_nvs_init_resp *resp; + size_t resp_len; + uint32_t status; + int error; + + xact = vmbus_xact_get(sc->hn_xact, sizeof(*init)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs init\n"); + return (ENXIO); + } + + init = vmbus_xact_req_data(xact); + init->nvs_type = HN_NVS_TYPE_INIT; + init->nvs_ver_min = nvs_ver; + init->nvs_ver_max = nvs_ver; - /* - * Specify parameter as the only acceptable protocol version - */ - init_pkt->msgs.init_msgs.init.p1.protocol_version = nvsp_ver; - init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; + vmbus_xact_activate(xact); + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - /* Send the init request */ - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); - ret = vmbus_chan_send(sc->hn_prichan, + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); - if (ret != 0) - return (-1); - - sema_wait(&net_dev->channel_init_sema); + init, sizeof(*init), (uint64_t)(uintptr_t)&sndc); + if (error) { + if_printf(sc->hn_ifp, "send nvs init failed: %d\n", error); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); + return (error); + } - if (init_pkt->msgs.init_msgs.init_compl.status != nvsp_status_success) + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid init resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + return (EINVAL); + } + if (resp->nvs_type != HN_NVS_TYPE_INIT_RESP) { + if_printf(sc->hn_ifp, "not init resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); return (EINVAL); + } + + status = resp->nvs_status; + vmbus_xact_put(xact); + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "nvs init failed for ver 0x%x\n", + nvs_ver); + return (EINVAL); + } return (0); } @@ -512,33 +552,19 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ static int hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu) { - netvsc_dev *net_dev; - nvsp_msg *init_pkt; - int ret; - - net_dev = hv_nv_get_outbound_net_device(sc); - if (!net_dev) - return (-ENODEV); - - /* - * Set up configuration packet, write MTU - * Indicate we are capable of handling VLAN tags - */ - init_pkt = &net_dev->channel_init_packet; - memset(init_pkt, 0, sizeof(nvsp_msg)); - init_pkt->hdr.msg_type = nvsp_msg_2_type_send_ndis_config; - init_pkt->msgs.vers_2_msgs.send_ndis_config.mtu = mtu; - init_pkt-> - msgs.vers_2_msgs.send_ndis_config.capabilities.u1.u2.ieee8021q - = 1; - - /* Send the configuration packet */ - ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); - if (ret != 0) - return (-EINVAL); + struct hn_nvs_ndis_conf conf; + int error; - return (0); + memset(&conf, 0, sizeof(conf)); + conf.nvs_type = HN_NVS_TYPE_NDIS_CONF; + conf.nvs_mtu = mtu; + conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; + + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, + &conf, sizeof(conf), (uint64_t)(uintptr_t)&hn_send_ctx_none); + if (error) + if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); + return (error); } /* @@ -548,8 +574,6 @@ static int hv_nv_connect_to_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; - nvsp_msg *init_pkt; - uint32_t ndis_version; uint32_t protocol_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2, NVSP_PROTOCOL_VERSION_4, @@ -559,6 +583,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc int ret = 0; device_t dev = sc->hn_dev; struct ifnet *ifp = sc->hn_ifp; + struct hn_nvs_ndis_init ndis; net_dev = hv_nv_get_outbound_net_device(sc); @@ -591,37 +616,23 @@ hv_nv_connect_to_vsp(struct hn_softc *sc ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); /* - * Send the NDIS version + * Initialize NDIS. */ - init_pkt = &net_dev->channel_init_packet; - - memset(init_pkt, 0, sizeof(nvsp_msg)); - - if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_4) { - ndis_version = NDIS_VERSION_6_1; - } else { - ndis_version = NDIS_VERSION_6_30; - } - - init_pkt->hdr.msg_type = nvsp_msg_1_type_send_ndis_vers; - init_pkt->msgs.vers_1_msgs.send_ndis_vers.ndis_major_vers = - (ndis_version & 0xFFFF0000) >> 16; - init_pkt->msgs.vers_1_msgs.send_ndis_vers.ndis_minor_vers = - ndis_version & 0xFFFF; - /* Send the init request */ + memset(&ndis, 0, sizeof(ndis)); + ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; + ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; + if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_4) + ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; + else + ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); + &ndis, sizeof(ndis), (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { + if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); goto cleanup; } - /* - * TODO: BUGBUG - We have to wait for the above msg since the netvsp - * uses KMCL which acknowledges packet (completion packet) - * since our Vmbus always set the VMBUS_CHANPKT_FLAG_RC flag - */ - /* sema_wait(&NetVscChannel->channel_init_sema); */ /* Post the big receive buffer to NetVSP */ if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_2) @@ -742,19 +753,18 @@ hv_nv_on_device_remove(struct hn_softc * } void -hn_nvs_sent_wakeup(struct hn_send_ctx *sndc __unused, - struct netvsc_dev_ *net_dev, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg) -{ - /* Copy the response back */ - memcpy(&net_dev->channel_init_packet, msg, sizeof(nvsp_msg)); - sema_post(&net_dev->channel_init_sema); +hn_nvs_sent_xact(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + const struct nvsp_msg_ *msg, int dlen) +{ + + vmbus_xact_wakeup(sndc->hn_cbarg, msg, dlen); } static void hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg __unused) + const struct nvsp_msg_ *msg __unused, int dlen __unused) { /* EMPTY */ } @@ -788,7 +798,8 @@ hv_nv_on_send_completion(netvsc_dev *net struct hn_send_ctx *sndc; sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; - sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt)); + sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt), + VMBUS_CHANPKT_DATALEN(pkt)); /* * NOTE: * 'sndc' CAN NOT be accessed anymore, since it can be freed by Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 05:53:38 2016 (r307475) @@ -1060,7 +1060,6 @@ typedef struct netvsc_dev_ { uint32_t rx_buf_size; uint32_t rx_buf_gpadl_handle; uint32_t rx_section_count; - nvsp_1_rx_buf_section *rx_sections; /* Used for NetVSP initialization protocol */ struct sema channel_init_sema; @@ -1243,6 +1242,7 @@ typedef struct hn_softc { struct taskqueue *hn_tx_taskq; struct sysctl_oid *hn_tx_sysctl_tree; struct sysctl_oid *hn_rx_sysctl_tree; + struct vmbus_xact_ctx *hn_xact; } hn_softc_t; /* Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 05:53:38 2016 (r307475) @@ -115,6 +115,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "hv_net_vsc.h" #include "hv_rndis.h" @@ -124,6 +125,9 @@ __FBSDID("$FreeBSD$"); /* Short for Hyper-V network interface */ #define NETVSC_DEVNAME "hn" +#define HN_XACT_REQ_SIZE (2 * PAGE_SIZE) +#define HN_XACT_RESP_SIZE (2 * PAGE_SIZE) + /* * It looks like offset 0 of buf is reserved to hold the softc pointer. * The sc pointer evidently not needed, and is not presently populated. @@ -542,6 +546,11 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; + sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), + HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); + if (sc->hn_xact == NULL) + goto failed; + error = hv_rf_on_device_add(sc, &device_info, ring_cnt, &sc->hn_rx_ring[0]); if (error) @@ -643,6 +652,7 @@ netvsc_detach(device_t dev) if (sc->hn_tx_taskq != hn_tx_taskq) taskqueue_free(sc->hn_tx_taskq); + vmbus_xact_ctx_destroy(sc->hn_xact); return (0); } @@ -782,7 +792,8 @@ hn_txeof(struct hn_tx_ring *txr) static void hn_tx_done(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, - struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused) + struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused, + int dlen __unused) { struct hn_txdesc *txd = sndc->hn_cbarg; struct hn_tx_ring *txr; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 05:53:38 2016 (r307475) @@ -41,6 +41,10 @@ #define NDIS_VERSION_6_1 0x00060001 #define NDIS_VERSION_6_30 0x0006001e +#define NDIS_VERSION_MAJOR_6 6 +#define NDIS_VERSION_MINOR_1 1 +#define NDIS_VERSION_MINOR_30 30 + #define NDIS_VERSION (NDIS_VERSION_5_1) /* Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 05:39:45 2016 (r307474) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 05:53:38 2016 (r307475) @@ -46,9 +46,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include "hv_net_vsc.h" -#include "hv_rndis.h" -#include "hv_rndis_filter.h" +#include +#include +#include +#include +#include struct hv_rf_recvinfo { const ndis_8021q_info *vlan_info; @@ -91,10 +93,10 @@ hv_rf_send_offload_request(struct hn_sof static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg); + const struct nvsp_msg_ *msg, int dlen); static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg); + const struct nvsp_msg_ *msg, int dlen); /* * Set the Per-Packet-Info with the specified type @@ -1060,12 +1062,16 @@ hv_rf_on_device_add(struct hn_softc *sc, int ret; netvsc_dev *net_dev; rndis_device *rndis_dev; - nvsp_msg *init_pkt; rndis_offload_params offloads; struct rndis_recv_scale_cap rsscaps; uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = sc->hn_dev; + struct hn_nvs_subch_req *req; + const struct hn_nvs_subch_resp *resp; + size_t resp_len; + struct vmbus_xact *xact; + uint32_t status, nsubch; rndis_dev = hv_get_rndis_device(); if (rndis_dev == NULL) { @@ -1153,36 +1159,65 @@ hv_rf_on_device_add(struct hn_softc *sc, goto out; } - /* request host to create sub channels */ - init_pkt = &net_dev->channel_init_packet; - memset(init_pkt, 0, sizeof(nvsp_msg)); - - init_pkt->hdr.msg_type = nvsp_msg5_type_subchannel; - init_pkt->msgs.vers_5_msgs.subchannel_request.op = - NVSP_SUBCHANNE_ALLOCATE; - init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = - net_dev->num_channel - 1; + /* + * Ask NVS to allocate sub-channels. + */ + xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs subch req\n"); + ret = ENXIO; + goto out; + } + + req = vmbus_xact_req_data(xact); + req->nvs_type = HN_NVS_TYPE_SUBCH_REQ; + req->nvs_op = HN_NVS_SUBCH_OP_ALLOC; + req->nvs_nsubch = net_dev->num_channel - 1; + + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); + req, sizeof(*req), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { - device_printf(dev, "Fail to allocate subchannel\n"); + if_printf(sc->hn_ifp, "send nvs subch req failed: %d\n", ret); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); goto out; } - sema_wait(&net_dev->channel_init_sema); - - if (init_pkt->msgs.vers_5_msgs.subchn_complete.status != - nvsp_status_success) { - ret = ENODEV; - device_printf(dev, "sub channel complete error\n"); + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid subch resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + ret = EINVAL; + goto out; + } + if (resp->nvs_type != HN_NVS_TYPE_SUBCH_RESP) { + if_printf(sc->hn_ifp, "not subch resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); + ret = EINVAL; goto out; } - net_dev->num_channel = 1 + - init_pkt->msgs.vers_5_msgs.subchn_complete.num_subchannels; + status = resp->nvs_status; + nsubch = resp->nvs_nsubch; + vmbus_xact_put(xact); + + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "subch req failed: %x\n", status); + ret = EIO; + goto out; + } + if (nsubch > net_dev->num_channel - 1) { + if_printf(sc->hn_ifp, "%u subchans are allocated, requested %u\n", + nsubch, net_dev->num_channel - 1); + nsubch = net_dev->num_channel - 1; + } + net_dev->num_channel = nsubch + 1; ret = hv_rf_set_rss_param(rndis_dev, net_dev->num_channel); @@ -1239,7 +1274,8 @@ hv_rf_on_close(struct hn_softc *sc) static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, - struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused, + int dlen __unused) { if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) hn_chim_free(net_dev, sndc->hn_chim_idx); @@ -1247,7 +1283,8 @@ hn_rndis_sent_cb(struct hn_send_ctx *snd static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, - struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused, + int dlen __unused) { rndis_request *request = sndc->hn_cbarg; Copied and modified: stable/11/sys/dev/hyperv/netvsc/if_hnreg.h (from r303948, head/sys/dev/hyperv/netvsc/if_hnreg.h) ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnreg.h Thu Aug 11 06:14:54 2016 (r303948, copy source) +++ stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Mon Oct 17 05:53:38 2016 (r307475) @@ -32,10 +32,23 @@ #include #include +#define HN_NVS_RXBUF_SIG 0xcafe +#define HN_NVS_CHIM_SIG 0xface + #define HN_NVS_STATUS_OK 1 #define HN_NVS_TYPE_INIT 1 #define HN_NVS_TYPE_INIT_RESP 2 +#define HN_NVS_TYPE_NDIS_INIT 100 +#define HN_NVS_TYPE_RXBUF_CONN 101 +#define HN_NVS_TYPE_RXBUF_CONNRESP 102 +#define HN_NVS_TYPE_RXBUF_DISCONN 103 +#define HN_NVS_TYPE_CHIM_CONN 104 +#define HN_NVS_TYPE_CHIM_CONNRESP 105 +#define HN_NVS_TYPE_CHIM_DISCONN 106 +#define HN_NVS_TYPE_NDIS_CONF 125 +#define HN_NVS_TYPE_SUBCH_REQ 133 +#define HN_NVS_TYPE_SUBCH_RESP 133 /* same as SUBCH_REQ */ /* * Any size less than this one will _not_ work, e.g. hn_nvs_init @@ -59,4 +72,94 @@ struct hn_nvs_init_resp { uint32_t nvs_status; /* HN_NVS_STATUS_ */ } __packed; +/* No reponse */ +struct hn_nvs_ndis_conf { + uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_CONF */ + uint32_t nvs_mtu; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 06:09:38 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 214B4C12DF8; Mon, 17 Oct 2016 06:09:38 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B7B151308; Mon, 17 Oct 2016 06:09:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H69abM079118; Mon, 17 Oct 2016 06:09:36 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H69aUL079114; Mon, 17 Oct 2016 06:09:36 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170609.u9H69aUL079114@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 06:09:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307476 - in stable/11/sys/dev/hyperv: include netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 06:09:38 -0000 Author: sephe Date: Mon Oct 17 06:09:36 2016 New Revision: 307476 URL: https://svnweb.freebsd.org/changeset/base/307476 Log: MFC 304204-304206,304252-304256 304204 hyperv/hn: Factor out hn_nvs_send/hn_nvs_send_sglist Avoid unnecessary message type setting and centralize the send context to transaction id cast. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7500 304205 hyperv/hn: Simplify RNDIS NVS message sending. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7501 304206 hyperv/hn: Simplify RNDIS message checks on RX path. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7502 304252 hyperv/hn: Ignore the useless TX table. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7514 304253 hyperv/hn: Simplify RNDIS RX packets acknowledgement. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7515 304254 hyperv/hn: Remove reference to nvsp_msg Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7516 304255 hyperv/hn: Remove reference to nvsp_status Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7517 304256 hyperv/hn: Get rid of unused bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7518 Modified: stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnreg.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 05:53:38 2016 (r307475) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 06:09:36 2016 (r307476) @@ -83,6 +83,7 @@ struct vmbus_chanpkt_hdr { #define VMBUS_CHANPKT_TYPE_GPA 0x0009 #define VMBUS_CHANPKT_TYPE_COMP 0x000b +#define VMBUS_CHANPKT_FLAG_NONE 0 #define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */ #define VMBUS_CHANPKT_CONST_DATA(pkt) \ Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 05:53:38 2016 (r307475) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 06:09:36 2016 (r307476) @@ -72,7 +72,7 @@ static void hv_nv_on_receive(netvsc_dev const struct vmbus_chanpkt_hdr *pkt); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg, int); + const void *, int); static struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); @@ -118,7 +118,7 @@ hv_nv_get_next_send_section(netvsc_dev * unsigned long bitsmap_words = net_dev->bitsmap_words; unsigned long *bitsmap = net_dev->send_section_bitsmap; unsigned long idx; - int ret = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + int ret = HN_NVS_CHIM_IDX_INVALID; int i; for (i = 0; i < bitsmap_words; i++) { @@ -206,9 +206,8 @@ hv_nv_init_rx_buffer_with_net_vsp(struct hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); vmbus_xact_activate(xact); - error = vmbus_chan_send(sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - conn, sizeof(*conn), (uint64_t)(uintptr_t)&sndc); + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + conn, sizeof(*conn), &sndc); if (error != 0) { if_printf(sc->hn_ifp, "send nvs rxbuf conn failed: %d\n", error); @@ -313,9 +312,8 @@ hv_nv_init_send_buffer_with_net_vsp(stru hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); vmbus_xact_activate(xact); - error = vmbus_chan_send(sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - chim, sizeof(*chim), (uint64_t)(uintptr_t)&sndc); + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + chim, sizeof(*chim), &sndc); if (error) { if_printf(sc->hn_ifp, "send nvs chim conn failed: %d\n", error); @@ -393,9 +391,10 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ disconn.nvs_type = HN_NVS_TYPE_RXBUF_DISCONN; disconn.nvs_sig = HN_NVS_RXBUF_SIG; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), - (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + ret = hn_nvs_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), + &hn_send_ctx_none); if (ret != 0) { if_printf(net_dev->sc->hn_ifp, "send rxbuf disconn failed: %d\n", ret); @@ -445,9 +444,10 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne disconn.nvs_type = HN_NVS_TYPE_CHIM_DISCONN; disconn.nvs_sig = HN_NVS_CHIM_SIG; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), - (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + ret = hn_nvs_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), + &hn_send_ctx_none); if (ret != 0) { if_printf(net_dev->sc->hn_ifp, "send chim disconn failed: %d\n", ret); @@ -509,9 +509,8 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ vmbus_xact_activate(xact); hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - error = vmbus_chan_send(sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init, sizeof(*init), (uint64_t)(uintptr_t)&sndc); + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + init, sizeof(*init), &sndc); if (error) { if_printf(sc->hn_ifp, "send nvs init failed: %d\n", error); vmbus_xact_deactivate(xact); @@ -560,8 +559,9 @@ hv_nv_send_ndis_config(struct hn_softc * conf.nvs_mtu = mtu; conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; - error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - &conf, sizeof(conf), (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, + &conf, sizeof(conf), &hn_send_ctx_none); if (error) if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); return (error); @@ -627,8 +627,9 @@ hv_nv_connect_to_vsp(struct hn_softc *sc else ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; - ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - &ndis, sizeof(ndis), (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + ret = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, + &ndis, sizeof(ndis), &hn_send_ctx_none); if (ret != 0) { if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); goto cleanup; @@ -689,8 +690,6 @@ hv_nv_on_device_add(struct hn_softc *sc, /* Initialize the NetVSC channel extension */ - sema_init(&net_dev->channel_init_sema, 0, "netdev_sema"); - /* * Open the channel */ @@ -721,7 +720,6 @@ cleanup: * Free the packet buffers on the netvsc device packet queue. * Release other resources. */ - sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); return (NULL); @@ -746,7 +744,6 @@ hv_nv_on_device_remove(struct hn_softc * vmbus_chan_close(sc->hn_prichan); - sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); return (0); @@ -755,16 +752,16 @@ hv_nv_on_device_remove(struct hn_softc * void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg, int dlen) + const void *data, int dlen) { - vmbus_xact_wakeup(sndc->hn_cbarg, msg, dlen); + vmbus_xact_wakeup(sndc->hn_cbarg, data, dlen); } static void hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg __unused, int dlen __unused) + const void *data __unused, int dlen __unused) { /* EMPTY */ } @@ -813,33 +810,23 @@ hv_nv_on_send_completion(netvsc_dev *net * Returns 0 on success, non-zero on failure. */ int -hv_nv_on_send(struct vmbus_channel *chan, bool is_data_pkt, +hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) { - nvsp_msg send_msg; + struct hn_nvs_rndis rndis; int ret; - send_msg.hdr.msg_type = nvsp_msg_1_type_send_rndis_pkt; - if (is_data_pkt) { - /* 0 is RMC_DATA */ - send_msg.msgs.vers_1_msgs.send_rndis_pkt.chan_type = 0; - } else { - /* 1 is RMC_CONTROL */ - send_msg.msgs.vers_1_msgs.send_rndis_pkt.chan_type = 1; - } - - send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_idx = - sndc->hn_chim_idx; - send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_size = - sndc->hn_chim_sz; + rndis.nvs_type = HN_NVS_TYPE_RNDIS; + rndis.nvs_rndis_mtype = rndis_mtype; + rndis.nvs_chim_idx = sndc->hn_chim_idx; + rndis.nvs_chim_sz = sndc->hn_chim_sz; if (gpa_cnt) { - ret = vmbus_chan_send_sglist(chan, gpa, gpa_cnt, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); + ret = hn_nvs_send_sglist(chan, gpa, gpa_cnt, + &rndis, sizeof(rndis), sndc); } else { - ret = vmbus_chan_send(chan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); + ret = hn_nvs_send(chan, VMBUS_CHANPKT_FLAG_RC, + &rndis, sizeof(rndis), sndc); } return (ret); @@ -856,19 +843,18 @@ hv_nv_on_receive(netvsc_dev *net_dev, st struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { const struct vmbus_chanpkt_rxbuf *pkt; - const nvsp_msg *nvsp_msg_pkt; + const struct hn_nvs_hdr *nvs_hdr; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; int count = 0; int i = 0; - int status = nvsp_status_success; - - nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkthdr); + int status = HN_NVS_STATUS_OK; - /* Make sure this is a valid nvsp packet */ - if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg_1_type_send_rndis_pkt) { - if_printf(rxr->hn_ifp, "packet hdr type %u is invalid!\n", - nvsp_msg_pkt->hdr.msg_type); + /* Make sure that this is a RNDIS message. */ + nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); + if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { + if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", + nvs_hdr->nvs_type); return; } @@ -884,15 +870,16 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { - net_vsc_pkt->status = nvsp_status_success; + net_vsc_pkt->status = HN_NVS_STATUS_OK; net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs); net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; hv_rf_on_receive(net_dev, rxr, net_vsc_pkt); - if (net_vsc_pkt->status != nvsp_status_success) { - status = nvsp_status_failure; - } + + /* XXX pretty broken; whack it */ + if (net_vsc_pkt->status != HN_NVS_STATUS_OK) + status = HN_NVS_STATUS_FAILED; } /* @@ -912,20 +899,17 @@ static void hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, uint32_t status) { - nvsp_msg rx_comp_msg; + struct hn_nvs_rndis_ack ack; int retries = 0; int ret = 0; - rx_comp_msg.hdr.msg_type = nvsp_msg_1_type_send_rndis_pkt_complete; - - /* Pass in the status */ - rx_comp_msg.msgs.vers_1_msgs.send_rndis_pkt_complete.status = - status; + ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; + ack.nvs_status = status; retry_send_cmplt: /* Send the completion */ - ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, 0, - &rx_comp_msg, sizeof(nvsp_msg), tid); + ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, + VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); if (ret == 0) { /* success */ /* no-op */ @@ -940,44 +924,17 @@ retry_send_cmplt: } } -/* - * Net VSC receiving vRSS send table from VSP - */ static void -hv_nv_send_table(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) +hn_proc_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { - netvsc_dev *net_dev; - const nvsp_msg *nvsp_msg_pkt; - int i; - uint32_t count; - const uint32_t *table; - - net_dev = hv_nv_get_inbound_net_device(sc); - if (!net_dev) - return; - - nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); + const struct hn_nvs_hdr *hdr; - if (nvsp_msg_pkt->hdr.msg_type != - nvsp_msg5_type_send_indirection_table) { - printf("Netvsc: !Warning! receive msg type not " - "send_indirection_table. type = %d\n", - nvsp_msg_pkt->hdr.msg_type); + hdr = VMBUS_CHANPKT_CONST_DATA(pkt); + if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { + /* Useless; ignore */ return; } - - count = nvsp_msg_pkt->msgs.vers_5_msgs.send_table.count; - if (count != VRSS_SEND_TABLE_SIZE) { - printf("Netvsc: Received wrong send table size: %u\n", count); - return; - } - - table = (const uint32_t *) - ((const uint8_t *)&nvsp_msg_pkt->msgs.vers_5_msgs.send_table + - nvsp_msg_pkt->msgs.vers_5_msgs.send_table.offset); - - for (i = 0; i < count; i++) - net_dev->vrss_send_table[i] = table[i]; + if_printf(sc->hn_ifp, "got notify, nvs type %u\n", hdr->nvs_type); } /* @@ -1015,7 +972,7 @@ hv_nv_on_channel_callback(struct vmbus_c hv_nv_on_receive(net_dev, rxr, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: - hv_nv_send_table(sc, pkt); + hn_proc_notify(sc, pkt); break; default: if_printf(rxr->hn_ifp, Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 05:53:38 2016 (r307475) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 06:09:36 2016 (r307476) @@ -177,834 +177,6 @@ typedef struct rndis_recv_scale_param_ { uint32_t processor_masks_entry_size; } rndis_recv_scale_param; -typedef enum nvsp_msg_type_ { - nvsp_msg_type_none = 0, - - /* - * Init Messages - */ - nvsp_msg_type_init = 1, - nvsp_msg_type_init_complete = 2, - - nvsp_version_msg_start = 100, - - /* - * Version 1 Messages - */ - nvsp_msg_1_type_send_ndis_vers = nvsp_version_msg_start, - - nvsp_msg_1_type_send_rx_buf, - nvsp_msg_1_type_send_rx_buf_complete, - nvsp_msg_1_type_revoke_rx_buf, - - nvsp_msg_1_type_send_send_buf, - nvsp_msg_1_type_send_send_buf_complete, - nvsp_msg_1_type_revoke_send_buf, - - nvsp_msg_1_type_send_rndis_pkt, - nvsp_msg_1_type_send_rndis_pkt_complete, - - /* - * Version 2 Messages - */ - nvsp_msg_2_type_send_chimney_delegated_buf, - nvsp_msg_2_type_send_chimney_delegated_buf_complete, - nvsp_msg_2_type_revoke_chimney_delegated_buf, - - nvsp_msg_2_type_resume_chimney_rx_indication, - - nvsp_msg_2_type_terminate_chimney, - nvsp_msg_2_type_terminate_chimney_complete, - - nvsp_msg_2_type_indicate_chimney_event, - - nvsp_msg_2_type_send_chimney_packet, - nvsp_msg_2_type_send_chimney_packet_complete, - - nvsp_msg_2_type_post_chimney_rx_request, - nvsp_msg_2_type_post_chimney_rx_request_complete, - - nvsp_msg_2_type_alloc_rx_buf, - nvsp_msg_2_type_alloc_rx_buf_complete, - - nvsp_msg_2_type_free_rx_buf, - - nvsp_msg_2_send_vmq_rndis_pkt, - nvsp_msg_2_send_vmq_rndis_pkt_complete, - - nvsp_msg_2_type_send_ndis_config, - - nvsp_msg_2_type_alloc_chimney_handle, - nvsp_msg_2_type_alloc_chimney_handle_complete, - - nvsp_msg2_max = nvsp_msg_2_type_alloc_chimney_handle_complete, - - /* - * Version 4 Messages - */ - nvsp_msg4_type_send_vf_association, - nvsp_msg4_type_switch_data_path, - nvsp_msg4_type_uplink_connect_state_deprecated, - - nvsp_msg4_max = nvsp_msg4_type_uplink_connect_state_deprecated, - - /* - * Version 5 Messages - */ - nvsp_msg5_type_oid_query_ex, - nvsp_msg5_type_oid_query_ex_comp, - nvsp_msg5_type_subchannel, - nvsp_msg5_type_send_indirection_table, - - nvsp_msg5_max = nvsp_msg5_type_send_indirection_table, -} nvsp_msg_type; - -typedef enum nvsp_status_ { - nvsp_status_none = 0, - nvsp_status_success, - nvsp_status_failure, - /* Deprecated */ - nvsp_status_prot_vers_range_too_new, - /* Deprecated */ - nvsp_status_prot_vers_range_too_old, - nvsp_status_invalid_rndis_pkt, - nvsp_status_busy, - nvsp_status_max, -} nvsp_status; - -typedef struct nvsp_msg_hdr_ { - uint32_t msg_type; -} __packed nvsp_msg_hdr; - -/* - * Init Messages - */ - -/* - * This message is used by the VSC to initialize the channel - * after the channels has been opened. This message should - * never include anything other then versioning (i.e. this - * message will be the same for ever). - * - * Forever is a long time. The values have been redefined - * in Win7 to indicate major and minor protocol version - * number. - */ -typedef struct nvsp_msg_init_ { - union { - struct { - uint16_t minor_protocol_version; - uint16_t major_protocol_version; - } s; - /* Formerly min_protocol_version */ - uint32_t protocol_version; - } p1; - /* Formerly max_protocol_version */ - uint32_t protocol_version_2; -} __packed nvsp_msg_init; - -/* - * This message is used by the VSP to complete the initialization - * of the channel. This message should never include anything other - * then versioning (i.e. this message will be the same forever). - */ -typedef struct nvsp_msg_init_complete_ { - /* Deprecated */ - uint32_t negotiated_prot_vers; - uint32_t max_mdl_chain_len; - uint32_t status; -} __packed nvsp_msg_init_complete; - -typedef union nvsp_msg_init_uber_ { - nvsp_msg_init init; - nvsp_msg_init_complete init_compl; -} __packed nvsp_msg_init_uber; - -/* - * Version 1 Messages - */ - -/* - * This message is used by the VSC to send the NDIS version - * to the VSP. The VSP can use this information when handling - * OIDs sent by the VSC. - */ -typedef struct nvsp_1_msg_send_ndis_version_ { - uint32_t ndis_major_vers; - /* Deprecated */ - uint32_t ndis_minor_vers; -} __packed nvsp_1_msg_send_ndis_version; - -/* - * This message is used by the VSC to send a receive buffer - * to the VSP. The VSP can then use the receive buffer to - * send data to the VSC. - */ -typedef struct nvsp_1_msg_send_rx_buf_ { - uint32_t gpadl_handle; - uint16_t id; -} __packed nvsp_1_msg_send_rx_buf; - -typedef struct nvsp_1_rx_buf_section_ { - uint32_t offset; - uint32_t sub_allocation_size; - uint32_t num_sub_allocations; - uint32_t end_offset; -} __packed nvsp_1_rx_buf_section; - -/* - * This message is used by the VSP to acknowledge a receive - * buffer send by the VSC. This message must be sent by the - * VSP before the VSP uses the receive buffer. - */ -typedef struct nvsp_1_msg_send_rx_buf_complete_ { - uint32_t status; - uint32_t num_sections; - - /* - * The receive buffer is split into two parts, a large - * suballocation section and a small suballocation - * section. These sections are then suballocated by a - * certain size. - * - * For example, the following break up of the receive - * buffer has 6 large suballocations and 10 small - * suballocations. - * - * | Large Section | | Small Section | - * ------------------------------------------------------------ - * | | | | | | | | | | | | | | | | | | - * | | - * LargeOffset SmallOffset - */ - nvsp_1_rx_buf_section sections[1]; - -} __packed nvsp_1_msg_send_rx_buf_complete; - -/* - * This message is sent by the VSC to revoke the receive buffer. - * After the VSP completes this transaction, the VSP should never - * use the receive buffer again. - */ -typedef struct nvsp_1_msg_revoke_rx_buf_ { - uint16_t id; -} __packed nvsp_1_msg_revoke_rx_buf; - -/* - * This message is used by the VSC to send a send buffer - * to the VSP. The VSC can then use the send buffer to - * send data to the VSP. - */ -typedef struct nvsp_1_msg_send_send_buf_ { - uint32_t gpadl_handle; - uint16_t id; -} __packed nvsp_1_msg_send_send_buf; - -/* - * This message is used by the VSP to acknowledge a send - * buffer sent by the VSC. This message must be sent by the - * VSP before the VSP uses the sent buffer. - */ -typedef struct nvsp_1_msg_send_send_buf_complete_ { - uint32_t status; - - /* - * The VSC gets to choose the size of the send buffer and - * the VSP gets to choose the sections size of the buffer. - * This was done to enable dynamic reconfigurations when - * the cost of GPA-direct buffers decreases. - */ - uint32_t section_size; -} __packed nvsp_1_msg_send_send_buf_complete; - -/* - * This message is sent by the VSC to revoke the send buffer. - * After the VSP completes this transaction, the vsp should never - * use the send buffer again. - */ -typedef struct nvsp_1_msg_revoke_send_buf_ { - uint16_t id; -} __packed nvsp_1_msg_revoke_send_buf; - -/* - * This message is used by both the VSP and the VSC to send - * an RNDIS message to the opposite channel endpoint. - */ -typedef struct nvsp_1_msg_send_rndis_pkt_ { - /* - * This field is specified by RNIDS. They assume there's - * two different channels of communication. However, - * the Network VSP only has one. Therefore, the channel - * travels with the RNDIS packet. - */ - uint32_t chan_type; - - /* - * This field is used to send part or all of the data - * through a send buffer. This values specifies an - * index into the send buffer. If the index is - * 0xFFFFFFFF, then the send buffer is not being used - * and all of the data was sent through other VMBus - * mechanisms. - */ - uint32_t send_buf_section_idx; - uint32_t send_buf_section_size; -} __packed nvsp_1_msg_send_rndis_pkt; - -/* - * This message is used by both the VSP and the VSC to complete - * a RNDIS message to the opposite channel endpoint. At this - * point, the initiator of this message cannot use any resources - * associated with the original RNDIS packet. - */ -typedef struct nvsp_1_msg_send_rndis_pkt_complete_ { - uint32_t status; -} __packed nvsp_1_msg_send_rndis_pkt_complete; - - -/* - * Version 2 Messages - */ - -/* - * This message is used by the VSC to send the NDIS version - * to the VSP. The VSP can use this information when handling - * OIDs sent by the VSC. - */ -typedef struct nvsp_2_netvsc_capabilities_ { - union { - uint64_t as_uint64; - struct { - uint64_t vmq : 1; - uint64_t chimney : 1; - uint64_t sriov : 1; - uint64_t ieee8021q : 1; - uint64_t correlationid : 1; - uint64_t teaming : 1; - } u2; - } u1; -} __packed nvsp_2_netvsc_capabilities; - -typedef struct nvsp_2_msg_send_ndis_config_ { - uint32_t mtu; - uint32_t reserved; - nvsp_2_netvsc_capabilities capabilities; -} __packed nvsp_2_msg_send_ndis_config; - -/* - * NvspMessage2TypeSendChimneyDelegatedBuffer - */ -typedef struct nvsp_2_msg_send_chimney_buf_ -{ - /* - * On WIN7 beta, delegated_obj_max_size is defined as a uint32_t - * Since WIN7 RC, it was split into two uint16_t. To have the same - * struct layout, delegated_obj_max_size shall be the first field. - */ - uint16_t delegated_obj_max_size; - - /* - * The revision # of chimney protocol used between NVSC and NVSP. - * - * This revision is NOT related to the chimney revision between - * NDIS protocol and miniport drivers. - */ - uint16_t revision; - - uint32_t gpadl_handle; -} __packed nvsp_2_msg_send_chimney_buf; - - -/* Unsupported chimney revision 0 (only present in WIN7 beta) */ -#define NVSP_CHIMNEY_REVISION_0 0 - -/* WIN7 Beta Chimney QFE */ -#define NVSP_CHIMNEY_REVISION_1 1 - -/* The chimney revision since WIN7 RC */ -#define NVSP_CHIMNEY_REVISION_2 2 - - -/* - * NvspMessage2TypeSendChimneyDelegatedBufferComplete - */ -typedef struct nvsp_2_msg_send_chimney_buf_complete_ { - uint32_t status; - - /* - * Maximum number outstanding sends and pre-posted receives. - * - * NVSC should not post more than SendQuota/ReceiveQuota packets. - * Otherwise, it can block the non-chimney path for an indefinite - * amount of time. - * (since chimney sends/receives are affected by the remote peer). - * - * Note: NVSP enforces the quota restrictions on a per-VMBCHANNEL - * basis. It doesn't enforce the restriction separately for chimney - * send/receive. If NVSC doesn't voluntarily enforce "SendQuota", - * it may kill its own network connectivity. - */ - uint32_t send_quota; - uint32_t rx_quota; -} __packed nvsp_2_msg_send_chimney_buf_complete; - -/* - * NvspMessage2TypeRevokeChimneyDelegatedBuffer - */ -typedef struct nvsp_2_msg_revoke_chimney_buf_ { - uint32_t gpadl_handle; -} __packed nvsp_2_msg_revoke_chimney_buf; - - -#define NVSP_CHIMNEY_OBJECT_TYPE_NEIGHBOR 0 -#define NVSP_CHIMNEY_OBJECT_TYPE_PATH4 1 -#define NVSP_CHIMNEY_OBJECT_TYPE_PATH6 2 -#define NVSP_CHIMNEY_OBJECT_TYPE_TCP 3 - -/* - * NvspMessage2TypeAllocateChimneyHandle - */ -typedef struct nvsp_2_msg_alloc_chimney_handle_ { - uint64_t vsc_context; - uint32_t object_type; -} __packed nvsp_2_msg_alloc_chimney_handle; - -/* - * NvspMessage2TypeAllocateChimneyHandleComplete - */ -typedef struct nvsp_2_msg_alloc_chimney_handle_complete_ { - uint32_t vsp_handle; -} __packed nvsp_2_msg_alloc_chimney_handle_complete; - - -/* - * NvspMessage2TypeResumeChimneyRXIndication - */ -typedef struct nvsp_2_msg_resume_chimney_rx_indication { - /* - * Handle identifying the offloaded connection - */ - uint32_t vsp_tcp_handle; -} __packed nvsp_2_msg_resume_chimney_rx_indication; - - -#define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_FIRST_STAGE (0x01u) -#define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_RESERVED (~(0x01u)) - -/* - * NvspMessage2TypeTerminateChimney - */ -typedef struct nvsp_2_msg_terminate_chimney_ { - /* - * Handle identifying the offloaded object - */ - uint32_t vsp_handle; - - /* - * Terminate Offload Flags - * Bit 0: - * When set to 0, terminate the offload at the destination NIC - * Bit 1-31: Reserved, shall be zero - */ - uint32_t flags; - - union { - /* - * This field is valid only when bit 0 of flags is clear. - * It specifies the index into the premapped delegated - * object buffer. The buffer was sent through the - * NvspMessage2TypeSendChimneyDelegatedBuffer - * message at initialization time. - * - * NVSP will write the delegated state into the delegated - * buffer upon upload completion. - */ - uint32_t index; - - /* - * This field is valid only when bit 0 of flags is set. - * - * The seqence number of the most recently accepted RX - * indication when VSC sets its TCP context into - * "terminating" state. - * - * This allows NVSP to determines if there are any in-flight - * RX indications for which the acceptance state is still - * undefined. - */ - uint64_t last_accepted_rx_seq_no; - } f0; -} __packed nvsp_2_msg_terminate_chimney; - - -#define NVSP_TERMINATE_CHIMNEY_COMPLETE_FLAG_DATA_CORRUPTED 0x0000001u - -/* - * NvspMessage2TypeTerminateChimneyComplete - */ -typedef struct nvsp_2_msg_terminate_chimney_complete_ { - uint64_t vsc_context; - uint32_t flags; -} __packed nvsp_2_msg_terminate_chimney_complete; - -/* - * NvspMessage2TypeIndicateChimneyEvent - */ -typedef struct nvsp_2_msg_indicate_chimney_event_ { - /* - * When VscTcpContext is 0, event_type is an NDIS_STATUS event code - * Otherwise, EventType is an TCP connection event (defined in - * NdisTcpOffloadEventHandler chimney DDK document). - */ - uint32_t event_type; - - /* - * When VscTcpContext is 0, EventType is an NDIS_STATUS event code - * Otherwise, EventType is an TCP connection event specific information - * (defined in NdisTcpOffloadEventHandler chimney DDK document). - */ - uint32_t event_specific_info; - - /* - * If not 0, the event is per-TCP connection event. This field - * contains the VSC's TCP context. - * If 0, the event indication is global. - */ - uint64_t vsc_tcp_context; -} __packed nvsp_2_msg_indicate_chimney_event; - - -#define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu -#define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffffff - -/* - * NvspMessage2TypeSendChimneyPacket - */ -typedef struct nvsp_2_msg_send_chimney_pkt_ { - /* - * Identify the TCP connection for which this chimney send is - */ - uint32_t vsp_tcp_handle; - - /* - * This field is used to send part or all of the data - * through a send buffer. This values specifies an - * index into the send buffer. If the index is - * 0xFFFF, then the send buffer is not being used - * and all of the data was sent through other VMBus - * mechanisms. - */ - uint16_t send_buf_section_index; - uint16_t send_buf_section_size; - - /* - * OOB Data Index - * This an index to the OOB data buffer. If the index is 0xFFFFFFFF, - * then there is no OOB data. - * - * This field shall be always 0xFFFFFFFF for now. It is reserved for - * the future. - */ - uint16_t oob_data_index; - - /* - * DisconnectFlags = 0 - * Normal chimney send. See MiniportTcpOffloadSend for details. - * - * DisconnectFlags = TCP_DISCONNECT_GRACEFUL_CLOSE (0x01) - * Graceful disconnect. See MiniportTcpOffloadDisconnect for details. - * - * DisconnectFlags = TCP_DISCONNECT_ABORTIVE_CLOSE (0x02) - * Abortive disconnect. See MiniportTcpOffloadDisconnect for details. - */ - uint16_t disconnect_flags; - - uint32_t seq_no; -} __packed nvsp_2_msg_send_chimney_pkt; - -/* - * NvspMessage2TypeSendChimneyPacketComplete - */ -typedef struct nvsp_2_msg_send_chimney_pkt_complete_ { - /* - * The NDIS_STATUS for the chimney send - */ - uint32_t status; - - /* - * Number of bytes that have been sent to the peer (and ACKed by the peer). - */ - uint32_t bytes_transferred; -} __packed nvsp_2_msg_send_chimney_pkt_complete; - - -#define NVSP_1_CHIMNEY_RECV_FLAG_NO_PUSH 0x0001u -#define NVSP_1_CHIMNEY_RECV_INVALID_OOB_INDEX 0xffffu - -/* - * NvspMessage2TypePostChimneyRecvRequest - */ -typedef struct nvsp_2_msg_post_chimney_rx_request_ { - /* - * Identify the TCP connection which this chimney receive request - * is for. - */ - uint32_t vsp_tcp_handle; - - /* - * OOB Data Index - * This an index to the OOB data buffer. If the index is 0xFFFFFFFF, - * then there is no OOB data. - * - * This field shall be always 0xFFFFFFFF for now. It is reserved for - * the future. - */ - uint32_t oob_data_index; - - /* - * Bit 0 - * When it is set, this is a "no-push" receive. - * When it is clear, this is a "push" receive. - * - * Bit 1-15: Reserved and shall be zero - */ - uint16_t flags; - - /* - * For debugging and diagnoses purpose. - * The SeqNo is per TCP connection and starts from 0. - */ - uint32_t seq_no; -} __packed nvsp_2_msg_post_chimney_rx_request; - -/* - * NvspMessage2TypePostChimneyRecvRequestComplete - */ -typedef struct nvsp_2_msg_post_chimney_rx_request_complete_ { - /* - * The NDIS_STATUS for the chimney send - */ - uint32_t status; - - /* - * Number of bytes that have been sent to the peer (and ACKed by - * the peer). - */ - uint32_t bytes_xferred; -} __packed nvsp_2_msg_post_chimney_rx_request_complete; - -/* - * NvspMessage2TypeAllocateReceiveBuffer - */ -typedef struct nvsp_2_msg_alloc_rx_buf_ { - /* - * Allocation ID to match the allocation request and response - */ - uint32_t allocation_id; - - /* - * Length of the VM shared memory receive buffer that needs to - * be allocated - */ - uint32_t length; -} __packed nvsp_2_msg_alloc_rx_buf; - -/* - * NvspMessage2TypeAllocateReceiveBufferComplete - */ -typedef struct nvsp_2_msg_alloc_rx_buf_complete_ { - /* - * The NDIS_STATUS code for buffer allocation - */ - uint32_t status; - - /* - * Allocation ID from NVSP_2_MESSAGE_ALLOCATE_RECEIVE_BUFFER - */ - uint32_t allocation_id; - - /* - * GPADL handle for the allocated receive buffer - */ - uint32_t gpadl_handle; - - /* - * Receive buffer ID that is further used in *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 06:12:27 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FC60C15027; Mon, 17 Oct 2016 06:12:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4747F1765; Mon, 17 Oct 2016 06:12:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H6CQ5a082610; Mon, 17 Oct 2016 06:12:26 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H6CP9W082604; Mon, 17 Oct 2016 06:12:25 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170612.u9H6CP9W082604@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 06:12:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307477 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 06:12:27 -0000 Author: sephe Date: Mon Oct 17 06:12:25 2016 New Revision: 307477 URL: https://svnweb.freebsd.org/changeset/base/307477 Log: MFC 304270,304273 304270 hyperv/util: Don't reference hn_softc in KVP hn_softc is private data struct. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7519 304273 hyperv/util: Factor out helper for IC device_probe DEVMETHOD Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7530 Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/utilities/hv_util.c stable/11/sys/dev/hyperv/utilities/hv_util.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 06:09:36 2016 (r307476) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 06:12:25 2016 (r307477) @@ -41,10 +41,15 @@ #include "hv_util.h" #include "vmbus_if.h" -/* Heartbeat Service */ -static const struct hyperv_guid service_guid = { .hv_guid = - {0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, - 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }; +static const struct vmbus_ic_desc vmbus_heartbeat_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, + 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }, + .ic_desc = "Hyper-V Heartbeat" + }, + VMBUS_IC_DESC_END +}; /** * Process heartbeat message @@ -96,14 +101,8 @@ hv_heartbeat_cb(struct vmbus_channel *ch static int hv_heartbeat_probe(device_t dev) { - if (resource_disabled("hvheartbeat", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V Heartbeat Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_heartbeat_descs)); } static int Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 06:09:36 2016 (r307476) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 06:12:25 2016 (r307477) @@ -54,17 +54,13 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include -#include -#include -#include - #include -#include #include #include "hv_util.h" @@ -91,9 +87,15 @@ static int hv_kvp_log = 0; log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \ } while (0) -static const struct hyperv_guid service_guid = { .hv_guid = - {0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, - 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6} }; +static const struct vmbus_ic_desc vmbus_kvp_descs[] = { + { + .ic_guid = { .hv_guid = { + 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, + 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 } }, + .ic_desc = "Hyper-V KVP" + }, + VMBUS_IC_DESC_END +}; /* character device prototypes */ static d_open_t hv_kvp_dev_open; @@ -333,13 +335,11 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { /* XXX access other driver's softc? are you kidding? */ device_t dev = devs[devcnt]; - struct hn_softc *sc = device_get_softc(dev); struct vmbus_channel *chan; char buf[HYPERV_GUID_STRLEN]; /* * Trying to find GUID of Network Device - * TODO: need vmbus interface. */ chan = vmbus_get_channel(dev); hyperv_guid2str(vmbus_chan_guid_inst(chan), @@ -348,7 +348,7 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, HYPERV_GUID_STRLEN - 1) == 0) { strlcpy((char *)umsg->body.kvp_ip_val.adapter_id, - sc->hn_ifp->if_xname, MAX_ADAPTER_ID_SIZE); + device_get_nameunit(dev), MAX_ADAPTER_ID_SIZE); break; } } @@ -873,14 +873,8 @@ hv_kvp_dev_daemon_poll(struct cdev *dev, static int hv_kvp_probe(device_t dev) { - if (resource_disabled("hvkvp", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V KVP Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_kvp_descs)); } static int Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 06:09:36 2016 (r307476) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 06:12:25 2016 (r307477) @@ -46,9 +46,15 @@ #include "hv_util.h" #include "vmbus_if.h" -static const struct hyperv_guid service_guid = { .hv_guid = - {0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, - 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB} }; +static const struct vmbus_ic_desc vmbus_shutdown_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x31, 0x60, 0x0b, 0x0e, 0x13, 0x52, 0x34, 0x49, + 0x81, 0x8b, 0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb } }, + .ic_desc = "Hyper-V Shutdown" + }, + VMBUS_IC_DESC_END +}; /** * Shutdown @@ -118,14 +124,8 @@ hv_shutdown_cb(struct vmbus_channel *cha static int hv_shutdown_probe(device_t dev) { - if (resource_disabled("hvshutdown", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V Shutdown Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_shutdown_descs)); } static int Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 06:09:36 2016 (r307476) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 06:12:25 2016 (r307477) @@ -58,10 +58,15 @@ typedef struct { uint64_t data; } time_sync_data; - /* Time Synch Service */ -static const struct hyperv_guid service_guid = {.hv_guid = - {0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, - 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }; +static const struct vmbus_ic_desc vmbus_timesync_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, + 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }, + .ic_desc = "Hyper-V Timesync" + }, + VMBUS_IC_DESC_END +}; struct hv_ictimesync_data { uint64_t parenttime; @@ -174,14 +179,8 @@ hv_timesync_cb(struct vmbus_channel *cha static int hv_timesync_probe(device_t dev) { - if (resource_disabled("hvtimesync", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V Time Synch Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_timesync_descs)); } static int Modified: stable/11/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 06:09:36 2016 (r307476) +++ stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 06:12:25 2016 (r307477) @@ -42,7 +42,9 @@ #include #include #include -#include "hv_util.h" +#include + +#include "vmbus_if.h" #define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) @@ -75,6 +77,24 @@ hv_negotiate_version(struct hv_vmbus_icm } int +vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]) +{ + device_t bus = device_get_parent(dev); + const struct vmbus_ic_desc *d; + + if (resource_disabled(device_get_name(dev), 0)) + return (ENXIO); + + for (d = descs; d->ic_desc != NULL; ++d) { + if (VMBUS_PROBE_GUID(bus, dev, &d->ic_guid) == 0) { + device_set_desc(dev, d->ic_desc); + return (BUS_PROBE_DEFAULT); + } + } + return (ENXIO); +} + +int hv_util_attach(device_t dev, vmbus_chan_callback_t cb) { struct hv_util_sc *sc = device_get_softc(dev); Modified: stable/11/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 06:09:36 2016 (r307476) +++ stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 06:12:25 2016 (r307477) @@ -31,6 +31,7 @@ #ifndef _HVUTIL_H_ #define _HVUTIL_H_ +#include #include /** @@ -42,9 +43,17 @@ typedef struct hv_util_sc { int ic_buflen; } hv_util_sc; +struct vmbus_ic_desc { + const struct hyperv_guid ic_guid; + const char *ic_desc; +}; + +#define VMBUS_IC_DESC_END { .ic_desc = NULL } + void hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf); -int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); -int hv_util_detach(device_t dev); +int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); +int hv_util_detach(device_t dev); +int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); #endif From owner-svn-src-stable@freebsd.org Mon Oct 17 06:16:10 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3B20DC1514E; Mon, 17 Oct 2016 06:16:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F37E419F9; Mon, 17 Oct 2016 06:16:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H6G97w082808; Mon, 17 Oct 2016 06:16:09 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H6G8c6082801; Mon, 17 Oct 2016 06:16:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170616.u9H6G8c6082801@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 06:16:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307478 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 06:16:10 -0000 Author: sephe Date: Mon Oct 17 06:16:08 2016 New Revision: 307478 URL: https://svnweb.freebsd.org/changeset/base/307478 Log: MFC 304327,304329,304330 304327 hyperv/hn: Pass RX packet info to netvsc_recv. This paves to nuke netvsc_packet, which does not serves much purpose now. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7541 304329 hyperv/hn: Constify RNDIS messages on RX path. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7542 304330 hyperv/hn: Get rid of the useless netvsc_packet Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7544 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis.h stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 06:12:25 2016 (r307477) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 06:16:08 2016 (r307478) @@ -66,7 +66,7 @@ static int hv_nv_connect_to_vsp(struct static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); static void hv_nv_on_receive_completion(struct vmbus_channel *chan, - uint64_t tid, uint32_t status); + uint64_t tid); static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); @@ -844,11 +844,8 @@ hv_nv_on_receive(netvsc_dev *net_dev, st { const struct vmbus_chanpkt_rxbuf *pkt; const struct hn_nvs_hdr *nvs_hdr; - netvsc_packet vsc_pkt; - netvsc_packet *net_vsc_pkt = &vsc_pkt; int count = 0; int i = 0; - int status = HN_NVS_STATUS_OK; /* Make sure that this is a RNDIS message. */ nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); @@ -870,16 +867,9 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { - net_vsc_pkt->status = HN_NVS_STATUS_OK; - net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf + - pkt->cp_rxbuf[i].rb_ofs); - net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; - - hv_rf_on_receive(net_dev, rxr, net_vsc_pkt); - - /* XXX pretty broken; whack it */ - if (net_vsc_pkt->status != HN_NVS_STATUS_OK) - status = HN_NVS_STATUS_FAILED; + hv_rf_on_receive(net_dev, rxr, + (const uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs, + pkt->cp_rxbuf[i].rb_len); } /* @@ -887,7 +877,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * messages (not just data messages) will trigger a response * message back to the host. */ - hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid, status); + hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid); } /* @@ -896,15 +886,14 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * Send a receive completion packet to RNDIS device (ie NetVsp) */ static void -hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, - uint32_t status) +hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid) { struct hn_nvs_rndis_ack ack; int retries = 0; int ret = 0; ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; - ack.nvs_status = status; + ack.nvs_status = HN_NVS_STATUS_OK; retry_send_cmplt: /* Send the completion */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 06:12:25 2016 (r307477) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 06:16:08 2016 (r307478) @@ -274,13 +274,6 @@ typedef void (*pfn_on_send_rx_completion #define BITS_PER_LONG 32 #endif -typedef struct netvsc_packet_ { - uint16_t vlan_tci; - uint32_t status; - uint32_t tot_data_buf_len; - void *data; -} netvsc_packet; - typedef struct { uint8_t mac_addr[6]; /* Assumption unsigned long */ uint8_t link_state; Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 06:12:25 2016 (r307477) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 06:16:08 2016 (r307478) @@ -1277,10 +1277,8 @@ hn_lro_rx(struct lro_ctrl *lc, struct mb * Note: This is no longer used as a callback */ int -netvsc_recv(struct hn_rx_ring *rxr, netvsc_packet *packet, - const rndis_tcp_ip_csum_info *csum_info, - const struct rndis_hash_info *hash_info, - const struct rndis_hash_value *hash_value) +netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen, + const struct hn_recvinfo *info) { struct ifnet *ifp = rxr->hn_ifp; struct mbuf *m_new; @@ -1293,17 +1291,16 @@ netvsc_recv(struct hn_rx_ring *rxr, netv /* * Bail out if packet contains more data than configured MTU. */ - if (packet->tot_data_buf_len > (ifp->if_mtu + ETHER_HDR_LEN)) { + if (dlen > (ifp->if_mtu + ETHER_HDR_LEN)) { return (0); - } else if (packet->tot_data_buf_len <= MHLEN) { + } else if (dlen <= MHLEN) { m_new = m_gethdr(M_NOWAIT, MT_DATA); if (m_new == NULL) { if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return (0); } - memcpy(mtod(m_new, void *), packet->data, - packet->tot_data_buf_len); - m_new->m_pkthdr.len = m_new->m_len = packet->tot_data_buf_len; + memcpy(mtod(m_new, void *), data, dlen); + m_new->m_pkthdr.len = m_new->m_len = dlen; rxr->hn_small_pkts++; } else { /* @@ -1313,7 +1310,7 @@ netvsc_recv(struct hn_rx_ring *rxr, netv * if looped around to the Hyper-V TX channel, so avoid them. */ size = MCLBYTES; - if (packet->tot_data_buf_len > MCLBYTES) { + if (dlen > MCLBYTES) { /* 4096 */ size = MJUMPAGESIZE; } @@ -1324,7 +1321,7 @@ netvsc_recv(struct hn_rx_ring *rxr, netv return (0); } - hv_m_append(m_new, packet->tot_data_buf_len, packet->data); + hv_m_append(m_new, dlen, data); } m_new->m_pkthdr.rcvif = ifp; @@ -1332,28 +1329,28 @@ netvsc_recv(struct hn_rx_ring *rxr, netv do_csum = 0; /* receive side checksum offload */ - if (csum_info != NULL) { + if (info->csum_info != NULL) { /* IP csum offload */ - if (csum_info->receive.ip_csum_succeeded && do_csum) { + if (info->csum_info->receive.ip_csum_succeeded && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); rxr->hn_csum_ip++; } /* TCP/UDP csum offload */ - if ((csum_info->receive.tcp_csum_succeeded || - csum_info->receive.udp_csum_succeeded) && do_csum) { + if ((info->csum_info->receive.tcp_csum_succeeded || + info->csum_info->receive.udp_csum_succeeded) && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; - if (csum_info->receive.tcp_csum_succeeded) + if (info->csum_info->receive.tcp_csum_succeeded) rxr->hn_csum_tcp++; else rxr->hn_csum_udp++; } - if (csum_info->receive.ip_csum_succeeded && - csum_info->receive.tcp_csum_succeeded) + if (info->csum_info->receive.ip_csum_succeeded && + info->csum_info->receive.tcp_csum_succeeded) do_lro = 1; } else { const struct ether_header *eh; @@ -1409,19 +1406,18 @@ netvsc_recv(struct hn_rx_ring *rxr, netv } } skip: - if ((packet->vlan_tci != 0) && - (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0) { - m_new->m_pkthdr.ether_vtag = packet->vlan_tci; + if (info->vlan_info != NULL) { + m_new->m_pkthdr.ether_vtag = info->vlan_info->u1.s1.vlan_id; m_new->m_flags |= M_VLANTAG; } - if (hash_info != NULL && hash_value != NULL) { + if (info->hash_info != NULL && info->hash_value != NULL) { rxr->hn_rss_pkts++; - m_new->m_pkthdr.flowid = hash_value->hash_value; - if ((hash_info->hash_info & NDIS_HASH_FUNCTION_MASK) == + m_new->m_pkthdr.flowid = info->hash_value->hash_value; + if ((info->hash_info->hash_info & NDIS_HASH_FUNCTION_MASK) == NDIS_HASH_FUNCTION_TOEPLITZ) { uint32_t type = - (hash_info->hash_info & NDIS_HASH_TYPE_MASK); + (info->hash_info->hash_info & NDIS_HASH_TYPE_MASK); switch (type) { case NDIS_HASH_IPV4: @@ -1450,8 +1446,8 @@ skip: } } } else { - if (hash_value != NULL) { - m_new->m_pkthdr.flowid = hash_value->hash_value; + if (info->hash_value != NULL) { + m_new->m_pkthdr.flowid = info->hash_value->hash_value; } else { m_new->m_pkthdr.flowid = rxr->hn_rx_idx; hash_type = M_HASHTYPE_OPAQUE; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 06:12:25 2016 (r307477) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 06:16:08 2016 (r307478) @@ -1088,11 +1088,10 @@ typedef struct rndismp_rx_bufs_info_ { */ struct hn_rx_ring; struct hn_tx_ring; +struct hn_recvinfo; -int netvsc_recv(struct hn_rx_ring *rxr, - netvsc_packet *packet, const rndis_tcp_ip_csum_info *csum_info, - const struct rndis_hash_info *hash_info, - const struct rndis_hash_value *hash_value); +int netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen, + const struct hn_recvinfo *info); void netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); void* hv_set_rppi_data(rndis_msg *rndis_mesg, Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 06:12:25 2016 (r307477) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 06:16:08 2016 (r307478) @@ -52,13 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include -struct hv_rf_recvinfo { - const ndis_8021q_info *vlan_info; - const rndis_tcp_ip_csum_info *csum_info; - const struct rndis_hash_info *hash_info; - const struct rndis_hash_value *hash_value; -}; - #define HV_RF_RECVINFO_VLAN 0x1 #define HV_RF_RECVINFO_CSUM 0x2 #define HV_RF_RECVINFO_HASHINF 0x4 @@ -74,11 +67,12 @@ struct hv_rf_recvinfo { */ static int hv_rf_send_request(rndis_device *device, rndis_request *request, uint32_t message_type); -static void hv_rf_receive_response(rndis_device *device, rndis_msg *response); +static void hv_rf_receive_response(rndis_device *device, + const rndis_msg *response); static void hv_rf_receive_indicate_status(rndis_device *device, - rndis_msg *response); -static void hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, - netvsc_packet *pkt); + const rndis_msg *response); +static void hv_rf_receive_data(struct hn_rx_ring *rxr, + const void *data, int dlen); static int hv_rf_query_device(rndis_device *device, uint32_t oid, void *result, uint32_t *result_size); static inline int hv_rf_query_device_mac(rndis_device *device); @@ -302,7 +296,7 @@ sendit: * RNDIS filter receive response */ static void -hv_rf_receive_response(rndis_device *device, rndis_msg *response) +hv_rf_receive_response(rndis_device *device, const rndis_msg *response) { rndis_request *request = NULL; rndis_request *next_request; @@ -424,9 +418,9 @@ cleanup: * RNDIS filter receive indicate status */ static void -hv_rf_receive_indicate_status(rndis_device *device, rndis_msg *response) +hv_rf_receive_indicate_status(rndis_device *device, const rndis_msg *response) { - rndis_indicate_status *indicate = &response->msg.indicate_status; + const rndis_indicate_status *indicate = &response->msg.indicate_status; switch(indicate->status) { case RNDIS_STATUS_MEDIA_CONNECT: @@ -444,7 +438,7 @@ hv_rf_receive_indicate_status(rndis_devi } static int -hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hv_rf_recvinfo *info) +hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hn_recvinfo *info) { const rndis_per_packet_info *ppi; uint32_t mask, len; @@ -525,12 +519,12 @@ skip: * RNDIS filter receive data */ static void -hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, - netvsc_packet *pkt) +hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen) { - rndis_packet *rndis_pkt; + const rndis_msg *message = data; + const rndis_packet *rndis_pkt; uint32_t data_offset; - struct hv_rf_recvinfo info; + struct hn_recvinfo info; rndis_pkt = &message->msg.packet; @@ -542,30 +536,22 @@ hv_rf_receive_data(struct hn_rx_ring *rx /* Remove rndis header, then pass data packet up the stack */ data_offset = RNDIS_HEADER_SIZE + rndis_pkt->data_offset; - pkt->tot_data_buf_len -= data_offset; - if (pkt->tot_data_buf_len < rndis_pkt->data_length) { - pkt->status = HN_NVS_STATUS_FAILED; + dlen -= data_offset; + if (dlen < rndis_pkt->data_length) { if_printf(rxr->hn_ifp, "total length %u is less than data length %u\n", - pkt->tot_data_buf_len, rndis_pkt->data_length); + dlen, rndis_pkt->data_length); return; } - pkt->tot_data_buf_len = rndis_pkt->data_length; - pkt->data = (void *)((unsigned long)pkt->data + data_offset); + dlen = rndis_pkt->data_length; + data = (const uint8_t *)data + data_offset; if (hv_rf_find_recvinfo(rndis_pkt, &info)) { - pkt->status = HN_NVS_STATUS_FAILED; if_printf(rxr->hn_ifp, "recvinfo parsing failed\n"); return; } - - if (info.vlan_info != NULL) - pkt->vlan_tci = info.vlan_info->u1.s1.vlan_id; - else - pkt->vlan_tci = 0; - - netvsc_recv(rxr, pkt, info.csum_info, info.hash_info, info.hash_value); + netvsc_recv(rxr, data, dlen, &info); } /* @@ -573,30 +559,25 @@ hv_rf_receive_data(struct hn_rx_ring *rx */ int hv_rf_on_receive(netvsc_dev *net_dev, - struct hn_rx_ring *rxr, netvsc_packet *pkt) + struct hn_rx_ring *rxr, const void *data, int dlen) { rndis_device *rndis_dev; - rndis_msg *rndis_hdr; + const rndis_msg *rndis_hdr; /* Make sure the rndis device state is initialized */ - if (net_dev->extension == NULL) { - pkt->status = HN_NVS_STATUS_FAILED; + if (net_dev->extension == NULL) return (ENODEV); - } rndis_dev = (rndis_device *)net_dev->extension; - if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) { - pkt->status = HN_NVS_STATUS_FAILED; + if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) return (EINVAL); - } - - rndis_hdr = pkt->data; + rndis_hdr = data; switch (rndis_hdr->ndis_msg_type) { /* data message */ case REMOTE_NDIS_PACKET_MSG: - hv_rf_receive_data(rxr, rndis_hdr, pkt); + hv_rf_receive_data(rxr, data, dlen); break; /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 06:12:25 2016 (r307477) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 06:16:08 2016 (r307478) @@ -115,8 +115,8 @@ typedef struct rndis_device_ { struct hn_softc; struct hn_rx_ring; -int hv_rf_on_receive(netvsc_dev *net_dev, - struct hn_rx_ring *rxr, netvsc_packet *pkt); +int hv_rf_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, + const void *data, int dlen); void hv_rf_receive_rollup(netvsc_dev *net_dev); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan, Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 06:12:25 2016 (r307477) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 06:16:08 2016 (r307478) @@ -35,7 +35,6 @@ #include struct netvsc_dev_; -struct nvsp_msg_; struct vmbus_channel; struct hn_send_ctx; @@ -51,6 +50,18 @@ struct hn_send_ctx { int hn_chim_sz; }; +struct rndis_hash_info; +struct rndix_hash_value; +struct ndis_8021q_info_; +struct rndis_tcp_ip_csum_info_; + +struct hn_recvinfo { + const struct ndis_8021q_info_ *vlan_info; + const struct rndis_tcp_ip_csum_info_ *csum_info; + const struct rndis_hash_info *hash_info; + const struct rndis_hash_value *hash_value; +}; + #define HN_SEND_CTX_INITIALIZER(cb, cbarg) \ { \ .hn_cb = cb, \ From owner-svn-src-stable@freebsd.org Mon Oct 17 06:18:11 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF890C152B9; Mon, 17 Oct 2016 06:18:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B0F861DAF; Mon, 17 Oct 2016 06:18:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H6IAW6083028; Mon, 17 Oct 2016 06:18:10 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H6IAid083027; Mon, 17 Oct 2016 06:18:10 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170618.u9H6IAid083027@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 06:18:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307479 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 06:18:12 -0000 Author: sephe Date: Mon Oct 17 06:18:10 2016 New Revision: 307479 URL: https://svnweb.freebsd.org/changeset/base/307479 Log: MFC 304331 hyperv/kvp: Remove unnecessary function parameter. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7550 Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 06:16:08 2016 (r307478) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 06:18:10 2016 (r307479) @@ -217,10 +217,9 @@ hv_kvp_transaction_init(hv_kvp_sc *sc, u * hv_kvp - version neogtiation function */ static void -hv_kvp_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, - struct hv_vmbus_icmsg_negotiate *negop, - uint8_t *buf) +hv_kvp_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf) { + struct hv_vmbus_icmsg_negotiate *negop; int icframe_vercnt; int icmsg_vercnt; @@ -641,7 +640,7 @@ hv_kvp_process_request(void *context, in hv_kvp_transaction_init(sc, recvlen, requestid, kvp_buf); if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_kvp_negotiate_version(icmsghdrp, NULL, kvp_buf); + hv_kvp_negotiate_version(icmsghdrp, kvp_buf); hv_kvp_respond_host(sc, ret); /* From owner-svn-src-stable@freebsd.org Mon Oct 17 06:47:36 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63A32C15A90; Mon, 17 Oct 2016 06:47:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2F82E1BC8; Mon, 17 Oct 2016 06:47:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H6lZds094098; Mon, 17 Oct 2016 06:47:35 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H6lZti094094; Mon, 17 Oct 2016 06:47:35 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170647.u9H6lZti094094@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 06:47:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307480 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 06:47:36 -0000 Author: sephe Date: Mon Oct 17 06:47:34 2016 New Revision: 307480 URL: https://svnweb.freebsd.org/changeset/base/307480 Log: MFC 304441,304444,304446,304447,304591,304593-304595 304441 hyperv/hn: Move NVS version to softc Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7553 304444 hyperv/hn: Remove assign-only struct field Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7554 304446 hyperv/hn: Remove the useless num_channel Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7555 304447 hyperv/hn: Move RXBUF to hn_softc And don't recreate RXBUF for each primary channel open, it is now created in device_attach DEVMETHOD and destroyed in device_detach DEVMETHOD. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7556 304591 hyperv/hn: Move chimney sending buffer to hn_softc And don't recreate chimney sending buffer for each primary channel open, it is now created in device_attach DEVMETHOD and destroyed in device_detach DEVMETHOD. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7574 304593 hyperv/hn: Get rid of netvsc_dev Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7575 304594 hyperv/hn: Factor out function to execute NVS transactions. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7577 304595 hyperv/hn: Factor out function to simplify NVS request sending Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7578 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 06:18:10 2016 (r307479) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 06:47:34 2016 (r307480) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -59,85 +60,78 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper static void hv_nv_on_channel_callback(struct vmbus_channel *chan, void *xrxr); static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); -static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); -static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); +static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *, int); +static int hv_nv_destroy_send_buffer(struct hn_softc *sc); +static int hv_nv_destroy_rx_buffer(struct hn_softc *sc); static int hv_nv_connect_to_vsp(struct hn_softc *sc); -static void hv_nv_on_send_completion(netvsc_dev *net_dev, +static void hv_nv_on_send_completion(struct hn_softc *sc, struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); static void hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid); -static void hv_nv_on_receive(netvsc_dev *net_dev, +static void hv_nv_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, - struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + struct hn_softc *, struct vmbus_channel *chan, const void *, int); +static void hn_nvs_sent_xact(struct hn_send_ctx *, struct hn_softc *sc, + struct vmbus_channel *, const void *, int); static struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); -/* - * - */ -static inline netvsc_dev * -hv_nv_alloc_net_device(struct hn_softc *sc) +uint32_t +hn_chim_alloc(struct hn_softc *sc) { - netvsc_dev *net_dev; + int i, bmap_cnt = sc->hn_chim_bmap_cnt; + u_long *bmap = sc->hn_chim_bmap; + uint32_t ret = HN_NVS_CHIM_IDX_INVALID; - net_dev = malloc(sizeof(netvsc_dev), M_NETVSC, M_WAITOK | M_ZERO); + for (i = 0; i < bmap_cnt; ++i) { + int idx; - net_dev->sc = sc; - net_dev->destroy = FALSE; - sc->net_dev = net_dev; + idx = ffsl(~bmap[i]); + if (idx == 0) + continue; - return (net_dev); -} + --idx; /* ffsl is 1-based */ + KASSERT(i * LONG_BIT + idx < sc->hn_chim_cnt, + ("invalid i %d and idx %d", i, idx)); -/* - * XXX unnecessary; nuke it. - */ -static inline netvsc_dev * -hv_nv_get_outbound_net_device(struct hn_softc *sc) -{ - return sc->net_dev; -} + if (atomic_testandset_long(&bmap[i], idx)) + continue; -/* - * XXX unnecessary; nuke it. - */ -static inline netvsc_dev * -hv_nv_get_inbound_net_device(struct hn_softc *sc) -{ - return sc->net_dev; + ret = i * LONG_BIT + idx; + break; + } + return (ret); } -int -hv_nv_get_next_send_section(netvsc_dev *net_dev) +const void * +hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, + void *req, int reqlen, size_t *resp_len) { - unsigned long bitsmap_words = net_dev->bitsmap_words; - unsigned long *bitsmap = net_dev->send_section_bitsmap; - unsigned long idx; - int ret = HN_NVS_CHIM_IDX_INVALID; - int i; - - for (i = 0; i < bitsmap_words; i++) { - idx = ffsl(~bitsmap[i]); - if (0 == idx) - continue; - - idx--; - KASSERT(i * BITS_PER_LONG + idx < net_dev->send_section_count, - ("invalid i %d and idx %lu", i, idx)); + struct hn_send_ctx sndc; + int error; - if (atomic_testandset_long(&bitsmap[i], idx)) - continue; + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - ret = i * BITS_PER_LONG + idx; - break; + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + req, reqlen, &sndc); + if (error) { + vmbus_xact_deactivate(xact); + return NULL; } + return (vmbus_xact_wait(xact, resp_len)); +} - return (ret); +static __inline int +hn_nvs_req_send(struct hn_softc *sc, void *req, int reqlen) +{ + + return (hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, + req, reqlen, &hn_send_ctx_none)); } /* @@ -147,29 +141,17 @@ hv_nv_get_next_send_section(netvsc_dev * * Hyper-V extensible switch and the synthetic data path. */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) +hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc, int rxbuf_size) { - struct vmbus_xact *xact; + struct vmbus_xact *xact = NULL; struct hn_nvs_rxbuf_conn *conn; const struct hn_nvs_rxbuf_connresp *resp; size_t resp_len; - struct hn_send_ctx sndc; - netvsc_dev *net_dev; uint32_t status; int error; - net_dev = hv_nv_get_outbound_net_device(sc); - if (!net_dev) { - return (ENODEV); - } - - net_dev->rx_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), - PAGE_SIZE, 0, net_dev->rx_buf_size, &net_dev->rxbuf_dma, - BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (net_dev->rx_buf == NULL) { - device_printf(sc->hn_dev, "allocate rxbuf failed\n"); - return (ENOMEM); - } + KASSERT(rxbuf_size <= NETVSC_RECEIVE_BUFFER_SIZE, + ("invalid rxbuf size %d", rxbuf_size)); /* * Connect the RXBUF GPADL to the primary channel. @@ -179,8 +161,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct * just share this RXBUF. */ error = vmbus_chan_gpadl_connect(sc->hn_prichan, - net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size, - &net_dev->rx_buf_gpadl_handle); + sc->hn_rxbuf_dma.hv_paddr, rxbuf_size, &sc->hn_rxbuf_gpadl); if (error) { if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n", error); @@ -197,55 +178,47 @@ hv_nv_init_rx_buffer_with_net_vsp(struct error = ENXIO; goto cleanup; } - conn = vmbus_xact_req_data(xact); conn->nvs_type = HN_NVS_TYPE_RXBUF_CONN; - conn->nvs_gpadl = net_dev->rx_buf_gpadl_handle; + conn->nvs_gpadl = sc->hn_rxbuf_gpadl; conn->nvs_sig = HN_NVS_RXBUF_SIG; - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - vmbus_xact_activate(xact); - - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, - conn, sizeof(*conn), &sndc); - if (error != 0) { - if_printf(sc->hn_ifp, "send nvs rxbuf conn failed: %d\n", - error); - vmbus_xact_deactivate(xact); - vmbus_xact_put(xact); + resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec rxbuf conn failed\n"); + error = EIO; goto cleanup; } - - resp = vmbus_xact_wait(xact, &resp_len); if (resp_len < sizeof(*resp)) { if_printf(sc->hn_ifp, "invalid rxbuf conn resp length %zu\n", resp_len); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } if (resp->nvs_type != HN_NVS_TYPE_RXBUF_CONNRESP) { if_printf(sc->hn_ifp, "not rxbuf conn resp, type %u\n", resp->nvs_type); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } status = resp->nvs_status; vmbus_xact_put(xact); + xact = NULL; if (status != HN_NVS_STATUS_OK) { if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status); error = EIO; goto cleanup; } - net_dev->rx_section_count = 1; + sc->hn_flags |= HN_FLAG_RXBUF_CONNECTED; return (0); cleanup: - hv_nv_destroy_rx_buffer(net_dev); + if (xact != NULL) + vmbus_xact_put(xact); + hv_nv_destroy_rx_buffer(sc); return (error); } @@ -255,28 +228,13 @@ cleanup: static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { - struct hn_send_ctx sndc; - struct vmbus_xact *xact; + struct vmbus_xact *xact = NULL; struct hn_nvs_chim_conn *chim; const struct hn_nvs_chim_connresp *resp; size_t resp_len; uint32_t status, sectsz; - netvsc_dev *net_dev; int error; - net_dev = hv_nv_get_outbound_net_device(sc); - if (!net_dev) { - return (ENODEV); - } - - net_dev->send_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), - PAGE_SIZE, 0, net_dev->send_buf_size, &net_dev->txbuf_dma, - BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (net_dev->send_buf == NULL) { - device_printf(sc->hn_dev, "allocate chimney txbuf failed\n"); - return (ENOMEM); - } - /* * Connect chimney sending buffer GPADL to the primary channel. * @@ -285,8 +243,8 @@ hv_nv_init_send_buffer_with_net_vsp(stru * Sub-channels just share this chimney sending buffer. */ error = vmbus_chan_gpadl_connect(sc->hn_prichan, - net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size, - &net_dev->send_buf_gpadl_handle); + sc->hn_chim_dma.hv_paddr, NETVSC_SEND_BUFFER_SIZE, + &sc->hn_chim_gpadl); if (error) { if_printf(sc->hn_ifp, "chimney sending buffer gpadl " "connect failed: %d\n", error); @@ -303,37 +261,26 @@ hv_nv_init_send_buffer_with_net_vsp(stru error = ENXIO; goto cleanup; } - chim = vmbus_xact_req_data(xact); chim->nvs_type = HN_NVS_TYPE_CHIM_CONN; - chim->nvs_gpadl = net_dev->send_buf_gpadl_handle; + chim->nvs_gpadl = sc->hn_chim_gpadl; chim->nvs_sig = HN_NVS_CHIM_SIG; - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - vmbus_xact_activate(xact); - - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, - chim, sizeof(*chim), &sndc); - if (error) { - if_printf(sc->hn_ifp, "send nvs chim conn failed: %d\n", - error); - vmbus_xact_deactivate(xact); - vmbus_xact_put(xact); + resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec chim conn failed\n"); + error = EIO; goto cleanup; } - - resp = vmbus_xact_wait(xact, &resp_len); if (resp_len < sizeof(*resp)) { if_printf(sc->hn_ifp, "invalid chim conn resp length %zu\n", resp_len); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } if (resp->nvs_type != HN_NVS_TYPE_CHIM_CONNRESP) { if_printf(sc->hn_ifp, "not chim conn resp, type %u\n", resp->nvs_type); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } @@ -341,6 +288,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru status = resp->nvs_status; sectsz = resp->nvs_sectsz; vmbus_xact_put(xact); + xact = NULL; if (status != HN_NVS_STATUS_OK) { if_printf(sc->hn_ifp, "chim conn failed: %x\n", status); @@ -353,23 +301,33 @@ hv_nv_init_send_buffer_with_net_vsp(stru return 0; } - net_dev->send_section_size = sectsz; - net_dev->send_section_count = - net_dev->send_buf_size / net_dev->send_section_size; - net_dev->bitsmap_words = howmany(net_dev->send_section_count, - BITS_PER_LONG); - net_dev->send_section_bitsmap = - malloc(net_dev->bitsmap_words * sizeof(long), M_NETVSC, - M_WAITOK | M_ZERO); + sc->hn_chim_szmax = sectsz; + sc->hn_chim_cnt = NETVSC_SEND_BUFFER_SIZE / sc->hn_chim_szmax; + if (NETVSC_SEND_BUFFER_SIZE % sc->hn_chim_szmax != 0) { + if_printf(sc->hn_ifp, "chimney sending sections are " + "not properly aligned\n"); + } + if (sc->hn_chim_cnt % LONG_BIT != 0) { + if_printf(sc->hn_ifp, "discard %d chimney sending sections\n", + sc->hn_chim_cnt % LONG_BIT); + } + + sc->hn_chim_bmap_cnt = sc->hn_chim_cnt / LONG_BIT; + sc->hn_chim_bmap = malloc(sc->hn_chim_bmap_cnt * sizeof(u_long), + M_NETVSC, M_WAITOK | M_ZERO); + /* Done! */ + sc->hn_flags |= HN_FLAG_CHIM_CONNECTED; if (bootverbose) { - if_printf(sc->hn_ifp, "chimney sending buffer %u/%u\n", - net_dev->send_section_size, net_dev->send_section_count); + if_printf(sc->hn_ifp, "chimney sending buffer %d/%d\n", + sc->hn_chim_szmax, sc->hn_chim_cnt); } return 0; cleanup: - hv_nv_destroy_send_buffer(net_dev); + if (xact != NULL) + vmbus_xact_put(xact); + hv_nv_destroy_send_buffer(sc); return (error); } @@ -377,11 +335,11 @@ cleanup: * Net VSC destroy receive buffer */ static int -hv_nv_destroy_rx_buffer(netvsc_dev *net_dev) +hv_nv_destroy_rx_buffer(struct hn_softc *sc) { int ret = 0; - if (net_dev->rx_section_count) { + if (sc->hn_flags & HN_FLAG_RXBUF_CONNECTED) { struct hn_nvs_rxbuf_disconn disconn; /* @@ -392,37 +350,28 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ disconn.nvs_sig = HN_NVS_RXBUF_SIG; /* NOTE: No response. */ - ret = hn_nvs_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), - &hn_send_ctx_none); + ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); if (ret != 0) { - if_printf(net_dev->sc->hn_ifp, + if_printf(sc->hn_ifp, "send rxbuf disconn failed: %d\n", ret); return (ret); } - net_dev->rx_section_count = 0; + sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED; } - /* Tear down the gpadl on the vsp end */ - if (net_dev->rx_buf_gpadl_handle) { - ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, - net_dev->rx_buf_gpadl_handle); + if (sc->hn_rxbuf_gpadl != 0) { /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect RXBUF from primary channel. */ + ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + sc->hn_rxbuf_gpadl); if (ret != 0) { + if_printf(sc->hn_ifp, + "rxbuf disconn failed: %d\n", ret); return (ret); } - net_dev->rx_buf_gpadl_handle = 0; - } - - if (net_dev->rx_buf) { - /* Free up the receive buffer */ - hyperv_dmamem_free(&net_dev->rxbuf_dma, net_dev->rx_buf); - net_dev->rx_buf = NULL; + sc->hn_rxbuf_gpadl = 0; } - return (ret); } @@ -430,11 +379,11 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ * Net VSC destroy send buffer */ static int -hv_nv_destroy_send_buffer(netvsc_dev *net_dev) +hv_nv_destroy_send_buffer(struct hn_softc *sc) { int ret = 0; - if (net_dev->send_section_size) { + if (sc->hn_flags & HN_FLAG_CHIM_CONNECTED) { struct hn_nvs_chim_disconn disconn; /* @@ -445,80 +394,62 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne disconn.nvs_sig = HN_NVS_CHIM_SIG; /* NOTE: No response. */ - ret = hn_nvs_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), - &hn_send_ctx_none); + ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); if (ret != 0) { - if_printf(net_dev->sc->hn_ifp, + if_printf(sc->hn_ifp, "send chim disconn failed: %d\n", ret); return (ret); } + sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED; } - /* Tear down the gpadl on the vsp end */ - if (net_dev->send_buf_gpadl_handle) { - ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, - net_dev->send_buf_gpadl_handle); - + if (sc->hn_chim_gpadl != 0) { /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect chimney sending buffer from primary channel. */ + ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + sc->hn_chim_gpadl); if (ret != 0) { + if_printf(sc->hn_ifp, + "chim disconn failed: %d\n", ret); return (ret); } - net_dev->send_buf_gpadl_handle = 0; - } - - if (net_dev->send_buf) { - /* Free up the receive buffer */ - hyperv_dmamem_free(&net_dev->txbuf_dma, net_dev->send_buf); - net_dev->send_buf = NULL; + sc->hn_chim_gpadl = 0; } - if (net_dev->send_section_bitsmap) { - free(net_dev->send_section_bitsmap, M_NETVSC); + if (sc->hn_chim_bmap != NULL) { + free(sc->hn_chim_bmap, M_NETVSC); + sc->hn_chim_bmap = NULL; } return (ret); } static int -hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, - uint32_t nvs_ver) +hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, uint32_t nvs_ver) { - struct hn_send_ctx sndc; struct vmbus_xact *xact; struct hn_nvs_init *init; const struct hn_nvs_init_resp *resp; size_t resp_len; uint32_t status; - int error; xact = vmbus_xact_get(sc->hn_xact, sizeof(*init)); if (xact == NULL) { if_printf(sc->hn_ifp, "no xact for nvs init\n"); return (ENXIO); } - init = vmbus_xact_req_data(xact); init->nvs_type = HN_NVS_TYPE_INIT; init->nvs_ver_min = nvs_ver; init->nvs_ver_max = nvs_ver; - vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, - init, sizeof(*init), &sndc); - if (error) { - if_printf(sc->hn_ifp, "send nvs init failed: %d\n", error); - vmbus_xact_deactivate(xact); + resp = hn_nvs_xact_execute(sc, xact, init, sizeof(*init), &resp_len); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec init failed\n"); vmbus_xact_put(xact); - return (error); + return (EIO); } - - resp = vmbus_xact_wait(xact, &resp_len); if (resp_len < sizeof(*resp)) { if_printf(sc->hn_ifp, "invalid init resp length %zu\n", resp_len); @@ -560,8 +491,7 @@ hv_nv_send_ndis_config(struct hn_softc * conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; /* NOTE: No response. */ - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, - &conf, sizeof(conf), &hn_send_ctx_none); + error = hn_nvs_req_send(sc, &conf, sizeof(conf)); if (error) if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); return (error); @@ -573,7 +503,6 @@ hv_nv_send_ndis_config(struct hn_softc * static int hv_nv_connect_to_vsp(struct hn_softc *sc) { - netvsc_dev *net_dev; uint32_t protocol_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2, NVSP_PROTOCOL_VERSION_4, @@ -584,19 +513,18 @@ hv_nv_connect_to_vsp(struct hn_softc *sc device_t dev = sc->hn_dev; struct ifnet *ifp = sc->hn_ifp; struct hn_nvs_ndis_init ndis; - - net_dev = hv_nv_get_outbound_net_device(sc); + int rxbuf_size; /* * Negotiate the NVSP version. Try the latest NVSP first. */ for (i = protocol_number - 1; i >= 0; i--) { - if (hv_nv_negotiate_nvsp_protocol(sc, net_dev, - protocol_list[i]) == 0) { - net_dev->nvsp_version = protocol_list[i]; - if (bootverbose) - device_printf(dev, "Netvsc: got version 0x%x\n", - net_dev->nvsp_version); + if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { + sc->hn_nvs_ver = protocol_list[i]; + if (bootverbose) { + device_printf(dev, "NVS version 0x%x\n", + sc->hn_nvs_ver); + } break; } } @@ -612,7 +540,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc * Set the MTU if supported by this NVSP protocol version * This needs to be right after the NVSP init message per Haiyang */ - if (net_dev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) + if (sc->hn_nvs_ver >= NVSP_PROTOCOL_VERSION_2) ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); /* @@ -622,27 +550,25 @@ hv_nv_connect_to_vsp(struct hn_softc *sc memset(&ndis, 0, sizeof(ndis)); ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; - if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_4) + if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; else ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; /* NOTE: No response. */ - ret = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, - &ndis, sizeof(ndis), &hn_send_ctx_none); + ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); if (ret != 0) { if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); goto cleanup; } /* Post the big receive buffer to NetVSP */ - if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_2) - net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; + if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_2) + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; else - net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; - net_dev->send_buf_size = NETVSC_SEND_BUFFER_SIZE; + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE; - ret = hv_nv_init_rx_buffer_with_net_vsp(sc); + ret = hv_nv_init_rx_buffer_with_net_vsp(sc, rxbuf_size); if (ret == 0) ret = hv_nv_init_send_buffer_with_net_vsp(sc); @@ -654,10 +580,10 @@ cleanup: * Net VSC disconnect from VSP */ static void -hv_nv_disconnect_from_vsp(netvsc_dev *net_dev) +hv_nv_disconnect_from_vsp(struct hn_softc *sc) { - hv_nv_destroy_rx_buffer(net_dev); - hv_nv_destroy_send_buffer(net_dev); + hv_nv_destroy_rx_buffer(sc); + hv_nv_destroy_send_buffer(sc); } void @@ -676,20 +602,12 @@ hv_nv_subchan_attach(struct vmbus_channe * * Callback when the device belonging to this driver is added */ -netvsc_dev * -hv_nv_on_device_add(struct hn_softc *sc, void *additional_info, - struct hn_rx_ring *rxr) +int +hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr) { struct vmbus_channel *chan = sc->hn_prichan; - netvsc_dev *net_dev; int ret = 0; - net_dev = hv_nv_alloc_net_device(sc); - if (net_dev == NULL) - return NULL; - - /* Initialize the NetVSC channel extension */ - /* * Open the channel */ @@ -709,20 +627,13 @@ hv_nv_on_device_add(struct hn_softc *sc, if (ret != 0) goto close; - return (net_dev); + return (0); close: /* Now, we can close the channel safely */ vmbus_chan_close(chan); - cleanup: - /* - * Free the packet buffers on the netvsc device packet queue. - * Release other resources. - */ - free(net_dev, M_NETVSC); - - return (NULL); + return (ret); } /* @@ -731,27 +642,19 @@ cleanup: int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) { - netvsc_dev *net_dev = sc->net_dev;; - /* Stop outbound traffic ie sends and receives completions */ - net_dev->destroy = TRUE; - - hv_nv_disconnect_from_vsp(net_dev); - - /* At this point, no one should be accessing net_dev except in here */ + hv_nv_disconnect_from_vsp(sc); /* Now, we can close the channel safely */ vmbus_chan_close(sc->hn_prichan); - free(net_dev, M_NETVSC); - return (0); } -void +static void hn_nvs_sent_xact(struct hn_send_ctx *sndc, - struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data, int dlen) { @@ -760,42 +663,42 @@ hn_nvs_sent_xact(struct hn_send_ctx *snd static void hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, - struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data __unused, int dlen __unused) { /* EMPTY */ } void -hn_chim_free(struct netvsc_dev_ *net_dev, uint32_t chim_idx) +hn_chim_free(struct hn_softc *sc, uint32_t chim_idx) { u_long mask; uint32_t idx; - idx = chim_idx / BITS_PER_LONG; - KASSERT(idx < net_dev->bitsmap_words, + idx = chim_idx / LONG_BIT; + KASSERT(idx < sc->hn_chim_bmap_cnt, ("invalid chimney index 0x%x", chim_idx)); - mask = 1UL << (chim_idx % BITS_PER_LONG); - KASSERT(net_dev->send_section_bitsmap[idx] & mask, + mask = 1UL << (chim_idx % LONG_BIT); + KASSERT(sc->hn_chim_bmap[idx] & mask, ("index bitmap 0x%lx, chimney index %u, " "bitmap idx %d, bitmask 0x%lx", - net_dev->send_section_bitsmap[idx], chim_idx, idx, mask)); + sc->hn_chim_bmap[idx], chim_idx, idx, mask)); - atomic_clear_long(&net_dev->send_section_bitsmap[idx], mask); + atomic_clear_long(&sc->hn_chim_bmap[idx], mask); } /* * Net VSC on send completion */ static void -hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *chan, +hv_nv_on_send_completion(struct hn_softc *sc, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt) { struct hn_send_ctx *sndc; sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; - sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt), + sndc->hn_cb(sndc, sc, chan, VMBUS_CHANPKT_CONST_DATA(pkt), VMBUS_CHANPKT_DATALEN(pkt)); /* * NOTE: @@ -839,7 +742,7 @@ hv_nv_on_send(struct vmbus_channel *chan * with virtual addresses. */ static void -hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, +hv_nv_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { const struct vmbus_chanpkt_rxbuf *pkt; @@ -867,8 +770,8 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { - hv_rf_on_receive(net_dev, rxr, - (const uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs, + hv_rf_on_receive(sc, rxr, + rxr->hn_rxbuf + pkt->cp_rxbuf[i].rb_ofs, pkt->cp_rxbuf[i].rb_len); } @@ -934,14 +837,9 @@ hv_nv_on_channel_callback(struct vmbus_c { struct hn_rx_ring *rxr = xrxr; struct hn_softc *sc = rxr->hn_ifp->if_softc; - netvsc_dev *net_dev; void *buffer; int bufferlen = NETVSC_PACKET_SIZE; - net_dev = hv_nv_get_inbound_net_device(sc); - if (net_dev == NULL) - return; - buffer = rxr->hn_rdbuf; do { struct vmbus_chanpkt_hdr *pkt = buffer; @@ -954,11 +852,10 @@ hv_nv_on_channel_callback(struct vmbus_c if (bytes_rxed > 0) { switch (pkt->cph_type) { case VMBUS_CHANPKT_TYPE_COMP: - hv_nv_on_send_completion(net_dev, chan, - pkt); + hv_nv_on_send_completion(sc, chan, pkt); break; case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(net_dev, rxr, chan, pkt); + hv_nv_on_receive(sc, rxr, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: hn_proc_notify(sc, pkt); Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 06:18:10 2016 (r307479) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 06:47:34 2016 (r307480) @@ -212,40 +212,6 @@ typedef struct rndis_recv_scale_param_ { * Data types */ -/* - * Per netvsc channel-specific - */ -typedef struct netvsc_dev_ { - struct hn_softc *sc; - - /* Send buffer allocated by us but manages by NetVSP */ - void *send_buf; - uint32_t send_buf_size; - uint32_t send_buf_gpadl_handle; - uint32_t send_section_size; - uint32_t send_section_count; - unsigned long bitsmap_words; - unsigned long *send_section_bitsmap; - - /* Receive buffer allocated by us but managed by NetVSP */ - void *rx_buf; - uint32_t rx_buf_size; - uint32_t rx_buf_gpadl_handle; - uint32_t rx_section_count; - - /* Holds rndis device info */ - void *extension; - - uint8_t destroy; - /* Negotiated NVSP version */ - uint32_t nvsp_version; - - uint32_t num_channel; - - struct hyperv_dma rxbuf_dma; - struct hyperv_dma txbuf_dma; -} netvsc_dev; - struct vmbus_channel; typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); @@ -268,12 +234,6 @@ typedef void (*pfn_on_send_rx_completion #define TRANSPORT_TYPE_IPV6_TCP ((TYPE_IPV6 << 16) | TYPE_TCP) #define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP) -#ifdef __LP64__ -#define BITS_PER_LONG 64 -#else -#define BITS_PER_LONG 32 -#endif - typedef struct { uint8_t mac_addr[6]; /* Assumption unsigned long */ uint8_t link_state; @@ -292,6 +252,7 @@ struct hn_rx_ring { struct ifnet *hn_ifp; struct hn_tx_ring *hn_txr; void *hn_rdbuf; + uint8_t *hn_rxbuf; /* shadow sc->hn_rxbuf */ int hn_rx_idx; /* Trust csum verification on host side */ @@ -345,7 +306,7 @@ struct hn_tx_ring { struct vmbus_channel *hn_chan; int hn_direct_tx_size; - int hn_tx_chimney_size; + int hn_chim_size; bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; @@ -383,7 +344,7 @@ typedef struct hn_softc { int hn_initdone; /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; - netvsc_dev *net_dev; + struct rndis_device_ *rndis_dev; struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; @@ -394,14 +355,31 @@ typedef struct hn_softc { int hn_tx_ring_inuse; struct hn_tx_ring *hn_tx_ring; + uint8_t *hn_chim; + u_long *hn_chim_bmap; + int hn_chim_bmap_cnt; + int hn_chim_cnt; + int hn_chim_szmax; + int hn_cpu; - int hn_tx_chimney_max; struct taskqueue *hn_tx_taskq; struct sysctl_oid *hn_tx_sysctl_tree; struct sysctl_oid *hn_rx_sysctl_tree; struct vmbus_xact_ctx *hn_xact; + uint32_t hn_nvs_ver; + + uint32_t hn_flags; + void *hn_rxbuf; + uint32_t hn_rxbuf_gpadl; + struct hyperv_dma hn_rxbuf_dma; + + uint32_t hn_chim_gpadl; + struct hyperv_dma hn_chim_dma; } hn_softc_t; +#define HN_FLAG_RXBUF_CONNECTED 0x0001 +#define HN_FLAG_CHIM_CONNECTED 0x0002 + /* * Externs */ @@ -409,13 +387,11 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, - void *additional_info, struct hn_rx_ring *rxr); +int hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr); int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); -int hv_nv_get_next_send_section(netvsc_dev *net_dev); void hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 06:18:10 2016 (r307479) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 06:47:34 2016 (r307480) @@ -328,7 +328,7 @@ static int hn_lro_lenlim_sysctl(SYSCTL_H static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS); #endif static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); @@ -342,9 +342,9 @@ static void hn_start_taskfunc(void *, in static void hn_start_txeof_taskfunc(void *, int); static void hn_stop_tx_tasks(struct hn_softc *); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); -static void hn_create_rx_data(struct hn_softc *sc, int); +static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); -static void hn_set_tx_chimney_size(struct hn_softc *, int); +static void hn_set_chim_size(struct hn_softc *, int); static void hn_channel_attach(struct hn_softc *, struct vmbus_channel *); static void hn_subchan_attach(struct hn_softc *, struct vmbus_channel *); static void hn_subchan_setup(struct hn_softc *); @@ -504,7 +504,9 @@ netvsc_attach(device_t dev) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 06:56:59 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D200C15C8B; Mon, 17 Oct 2016 06:56:59 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6B80F106D; Mon, 17 Oct 2016 06:56:59 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H6uweO097774; Mon, 17 Oct 2016 06:56:58 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H6uwag097771; Mon, 17 Oct 2016 06:56:58 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170656.u9H6uwag097771@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 06:56:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307481 - in stable/11/sys: dev/usb/net net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 06:56:59 -0000 Author: sephe Date: Mon Oct 17 06:56:58 2016 New Revision: 307481 URL: https://svnweb.freebsd.org/changeset/base/307481 Log: MFC 304654,304722,304723 304654 net: Split RNDIS protocol structs/macros out of dev/usb/net/if_urndisreg.h So that Hyper-V can leverage them instead of rolling its own definition. Discussed with: hps Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7592 304722 net/rndis: Add canonical RNDIS major/minor version as of today. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7593 304723 net/rndis: Fix RNDIS_STATUS_PENDING definition. While I'm here, sort the RNDIS status in ascending order. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7594 Added: stable/11/sys/net/rndis.h - copied, changed from r304654, head/sys/net/rndis.h Modified: stable/11/sys/dev/usb/net/if_urndis.c stable/11/sys/dev/usb/net/if_urndisreg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/net/if_urndis.c ============================================================================== --- stable/11/sys/dev/usb/net/if_urndis.c Mon Oct 17 06:47:34 2016 (r307480) +++ stable/11/sys/dev/usb/net/if_urndis.c Mon Oct 17 06:56:58 2016 (r307481) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -79,17 +80,17 @@ static uether_fn_t urndis_setmulti; static uether_fn_t urndis_setpromisc; static uint32_t urndis_ctrl_query(struct urndis_softc *sc, uint32_t oid, - struct urndis_query_req *msg, uint16_t len, + struct rndis_query_req *msg, uint16_t len, const void **rbuf, uint16_t *rbufsz); static uint32_t urndis_ctrl_set(struct urndis_softc *sc, uint32_t oid, - struct urndis_set_req *msg, uint16_t len); + struct rndis_set_req *msg, uint16_t len); static uint32_t urndis_ctrl_handle_init(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr); + const struct rndis_comp_hdr *hdr); static uint32_t urndis_ctrl_handle_query(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr, const void **buf, + const struct rndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz); static uint32_t urndis_ctrl_handle_reset(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr); + const struct rndis_comp_hdr *hdr); static uint32_t urndis_ctrl_init(struct urndis_softc *sc); static uint32_t urndis_ctrl_halt(struct urndis_softc *sc); @@ -212,8 +213,8 @@ urndis_attach(device_t dev) { static struct { union { - struct urndis_query_req query; - struct urndis_set_req set; + struct rndis_query_req query; + struct rndis_set_req set; } hdr; union { uint8_t eaddr[ETHER_ADDR_LEN]; @@ -453,10 +454,10 @@ urndis_ctrl_send(struct urndis_softc *sc return (err); } -static struct urndis_comp_hdr * +static struct rndis_comp_hdr * urndis_ctrl_recv(struct urndis_softc *sc) { - struct urndis_comp_hdr *hdr; + struct rndis_comp_hdr *hdr; usb_error_t err; err = urndis_ctrl_msg(sc, UT_READ_CLASS_INTERFACE, @@ -466,7 +467,7 @@ urndis_ctrl_recv(struct urndis_softc *sc if (err != USB_ERR_NORMAL_COMPLETION) return (NULL); - hdr = (struct urndis_comp_hdr *)sc->sc_response_buf; + hdr = (struct rndis_comp_hdr *)sc->sc_response_buf; DPRINTF("type 0x%x len %u\n", le32toh(hdr->rm_type), le32toh(hdr->rm_len)); @@ -480,7 +481,7 @@ urndis_ctrl_recv(struct urndis_softc *sc } static uint32_t -urndis_ctrl_handle(struct urndis_softc *sc, struct urndis_comp_hdr *hdr, +urndis_ctrl_handle(struct urndis_softc *sc, struct rndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz) { uint32_t rval; @@ -521,11 +522,11 @@ urndis_ctrl_handle(struct urndis_softc * static uint32_t urndis_ctrl_handle_init(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr) + const struct rndis_comp_hdr *hdr) { - const struct urndis_init_comp *msg; + const struct rndis_init_comp *msg; - msg = (const struct urndis_init_comp *)hdr; + msg = (const struct rndis_init_comp *)hdr; DPRINTF("len %u rid %u status 0x%x " "ver_major %u ver_minor %u devflags 0x%x medium 0x%x pktmaxcnt %u " @@ -564,12 +565,12 @@ urndis_ctrl_handle_init(struct urndis_so static uint32_t urndis_ctrl_handle_query(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz) + const struct rndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz) { - const struct urndis_query_comp *msg; + const struct rndis_query_comp *msg; uint64_t limit; - msg = (const struct urndis_query_comp *)hdr; + msg = (const struct rndis_query_comp *)hdr; DPRINTF("len %u rid %u status 0x%x " "buflen %u bufoff %u\n", @@ -609,12 +610,12 @@ urndis_ctrl_handle_query(struct urndis_s static uint32_t urndis_ctrl_handle_reset(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr) + const struct rndis_comp_hdr *hdr) { - const struct urndis_reset_comp *msg; + const struct rndis_reset_comp *msg; uint32_t rval; - msg = (const struct urndis_reset_comp *)hdr; + msg = (const struct rndis_reset_comp *)hdr; rval = le32toh(msg->rm_status); @@ -630,7 +631,7 @@ urndis_ctrl_handle_reset(struct urndis_s } if (msg->rm_adrreset != 0) { struct { - struct urndis_set_req hdr; + struct rndis_set_req hdr; uint32_t filter; } msg_filter; @@ -650,14 +651,14 @@ urndis_ctrl_handle_reset(struct urndis_s static uint32_t urndis_ctrl_init(struct urndis_softc *sc) { - struct urndis_init_req msg; - struct urndis_comp_hdr *hdr; + struct rndis_init_req msg; + struct rndis_comp_hdr *hdr; uint32_t rval; msg.rm_type = htole32(REMOTE_NDIS_INITIALIZE_MSG); msg.rm_len = htole32(sizeof(msg)); msg.rm_rid = 0; - msg.rm_ver_major = htole32(1); + msg.rm_ver_major = htole32(RNDIS_VERSION_MAJOR); msg.rm_ver_minor = htole32(1); msg.rm_max_xfersz = htole32(RNDIS_RX_MAXLEN); @@ -688,7 +689,7 @@ urndis_ctrl_init(struct urndis_softc *sc static uint32_t urndis_ctrl_halt(struct urndis_softc *sc) { - struct urndis_halt_req msg; + struct rndis_halt_req msg; uint32_t rval; msg.rm_type = htole32(REMOTE_NDIS_HALT_MSG); @@ -714,10 +715,10 @@ urndis_ctrl_halt(struct urndis_softc *sc */ static uint32_t urndis_ctrl_query(struct urndis_softc *sc, uint32_t oid, - struct urndis_query_req *msg, uint16_t len, const void **rbuf, + struct rndis_query_req *msg, uint16_t len, const void **rbuf, uint16_t *rbufsz) { - struct urndis_comp_hdr *hdr; + struct rndis_comp_hdr *hdr; uint32_t datalen, rval; msg->rm_type = htole32(REMOTE_NDIS_QUERY_MSG); @@ -761,9 +762,9 @@ urndis_ctrl_query(struct urndis_softc *s static uint32_t urndis_ctrl_set(struct urndis_softc *sc, uint32_t oid, - struct urndis_set_req *msg, uint16_t len) + struct rndis_set_req *msg, uint16_t len) { - struct urndis_comp_hdr *hdr; + struct rndis_comp_hdr *hdr; uint32_t datalen, rval; msg->rm_type = htole32(REMOTE_NDIS_SET_MSG); @@ -813,7 +814,7 @@ urndis_bulk_read_callback(struct usb_xfe struct urndis_softc *sc = usbd_xfer_softc(xfer); struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, 0); struct ifnet *ifp = uether_getifp(&sc->sc_ue); - struct urndis_packet_msg msg; + struct rndis_packet_msg msg; struct mbuf *m; int actlen; int aframes; @@ -873,11 +874,11 @@ urndis_bulk_read_callback(struct usb_xfe "datalen %u\n", msg.rm_datalen, actlen); goto tr_setup; } else if ((msg.rm_dataoffset + msg.rm_datalen + - (uint32_t)__offsetof(struct urndis_packet_msg, + (uint32_t)__offsetof(struct rndis_packet_msg, rm_dataoffset)) > (uint32_t)actlen) { DPRINTF("invalid dataoffset %u larger than %u\n", msg.rm_dataoffset + msg.rm_datalen + - (uint32_t)__offsetof(struct urndis_packet_msg, + (uint32_t)__offsetof(struct rndis_packet_msg, rm_dataoffset), actlen); goto tr_setup; } else if (msg.rm_datalen < (uint32_t)sizeof(struct ether_header)) { @@ -903,7 +904,7 @@ urndis_bulk_read_callback(struct usb_xfe m_adj(m, ETHER_ALIGN); usbd_copy_out(pc, offset + msg.rm_dataoffset + - __offsetof(struct urndis_packet_msg, + __offsetof(struct rndis_packet_msg, rm_dataoffset), m->m_data, msg.rm_datalen); /* enqueue */ @@ -939,7 +940,7 @@ tr_setup: static void urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) { - struct urndis_packet_msg msg; + struct rndis_packet_msg msg; struct urndis_softc *sc = usbd_xfer_softc(xfer); struct ifnet *ifp = uether_getifp(&sc->sc_ue); struct mbuf *m; Modified: stable/11/sys/dev/usb/net/if_urndisreg.h ============================================================================== --- stable/11/sys/dev/usb/net/if_urndisreg.h Mon Oct 17 06:47:34 2016 (r307480) +++ stable/11/sys/dev/usb/net/if_urndisreg.h Mon Oct 17 06:56:58 2016 (r307481) @@ -55,242 +55,4 @@ struct urndis_softc { #define URNDIS_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) #define URNDIS_LOCK_ASSERT(sc, what) mtx_assert(&(sc)->sc_mtx, (what)) -#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L -#define RNDIS_STATUS_FAILURE 0xC0000001L -#define RNDIS_STATUS_INVALID_DATA 0xC0010015L -#define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL -#define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL -#define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL -#define RNDIS_STATUS_PENDING STATUS_PENDING /* XXX */ -#define RNDIS_STATUS_RESOURCES 0xC000009AL -#define RNDIS_STATUS_SUCCESS 0x00000000L - -#define OID_GEN_SUPPORTED_LIST 0x00010101 -#define OID_GEN_HARDWARE_STATUS 0x00010102 -#define OID_GEN_MEDIA_SUPPORTED 0x00010103 -#define OID_GEN_MEDIA_IN_USE 0x00010104 -#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 -#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 -#define OID_GEN_LINK_SPEED 0x00010107 -#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 -#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 -#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A -#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B -#define OID_GEN_VENDOR_ID 0x0001010C -#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D -#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E -#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F -#define OID_GEN_DRIVER_VERSION 0x00010110 -#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 -#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 -#define OID_GEN_MAC_OPTIONS 0x00010113 -#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 -#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 -#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 -#define OID_GEN_SUPPORTED_GUIDS 0x00010117 -#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 -#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 -#define OID_GEN_MACHINE_NAME 0x0001021A -#define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B -#define OID_GEN_VLAN_ID 0x0001021C - -#define OID_802_3_PERMANENT_ADDRESS 0x01010101 -#define OID_802_3_CURRENT_ADDRESS 0x01010102 -#define OID_802_3_MULTICAST_LIST 0x01010103 -#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 -#define OID_802_3_MAC_OPTIONS 0x01010105 -#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 -#define OID_802_3_XMIT_ONE_COLLISION 0x01020102 -#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 -#define OID_802_3_XMIT_DEFERRED 0x01020201 -#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 -#define OID_802_3_RCV_OVERRUN 0x01020203 -#define OID_802_3_XMIT_UNDERRUN 0x01020204 -#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 -#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 -#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 - -#define RNDIS_MEDIUM_802_3 0x00000000 - -/* Device flags */ -#define RNDIS_DF_CONNECTIONLESS 0x00000001 -#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 - -/* - * RNDIS data message - */ -#define REMOTE_NDIS_PACKET_MSG 0x00000001 - -struct urndis_packet_msg { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_dataoffset; - uint32_t rm_datalen; - uint32_t rm_oobdataoffset; - uint32_t rm_oobdatalen; - uint32_t rm_oobdataelements; - uint32_t rm_pktinfooffset; - uint32_t rm_pktinfolen; - uint32_t rm_vchandle; - uint32_t rm_reserved; -}; - -/* - * RNDIS control messages - */ -struct urndis_comp_hdr { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; -}; - -/* Initialize the device. */ -#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 -#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002 - -struct urndis_init_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_ver_major; - uint32_t rm_ver_minor; - uint32_t rm_max_xfersz; -}; - -struct urndis_init_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; - uint32_t rm_ver_major; - uint32_t rm_ver_minor; - uint32_t rm_devflags; - uint32_t rm_medium; - uint32_t rm_pktmaxcnt; - uint32_t rm_pktmaxsz; - uint32_t rm_align; - uint32_t rm_aflistoffset; - uint32_t rm_aflistsz; -}; - -/* Halt the device. No response sent. */ -#define REMOTE_NDIS_HALT_MSG 0x00000003 - -struct urndis_halt_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; -}; - -/* Send a query object. */ -#define REMOTE_NDIS_QUERY_MSG 0x00000004 -#define REMOTE_NDIS_QUERY_CMPLT 0x80000004 - -struct urndis_query_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_oid; - uint32_t rm_infobuflen; - uint32_t rm_infobufoffset; - uint32_t rm_devicevchdl; -}; - -struct urndis_query_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; - uint32_t rm_infobuflen; - uint32_t rm_infobufoffset; -}; - -/* Send a set object request. */ -#define REMOTE_NDIS_SET_MSG 0x00000005 -#define REMOTE_NDIS_SET_CMPLT 0x80000005 - -struct urndis_set_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_oid; - uint32_t rm_infobuflen; - uint32_t rm_infobufoffset; - uint32_t rm_devicevchdl; -}; - -struct urndis_set_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; -}; - -#define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 -#define REMOTE_NDIS_SET_PARAM_STRING 0x00000002 - -struct urndis_set_parameter { - uint32_t rm_nameoffset; - uint32_t rm_namelen; - uint32_t rm_type; - uint32_t rm_valueoffset; - uint32_t rm_valuelen; -}; - -/* Perform a soft reset on the device. */ -#define REMOTE_NDIS_RESET_MSG 0x00000006 -#define REMOTE_NDIS_RESET_CMPLT 0x80000006 - -struct urndis_reset_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; -}; - -struct urndis_reset_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_status; - uint32_t rm_adrreset; -}; - -/* 802.3 link-state or undefined message error. */ -#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 - -/* Keepalive messsage. May be sent by device. */ -#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 -#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 - -struct urndis_keepalive_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; -}; - -struct urndis_keepalive_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; -}; - -/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ -#define RNDIS_PACKET_TYPE_DIRECTED 0x00000001 -#define RNDIS_PACKET_TYPE_MULTICAST 0x00000002 -#define RNDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 -#define RNDIS_PACKET_TYPE_BROADCAST 0x00000008 -#define RNDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 -#define RNDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 -#define RNDIS_PACKET_TYPE_SMT 0x00000040 -#define RNDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 -#define RNDIS_PACKET_TYPE_GROUP 0x00001000 -#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000 -#define RNDIS_PACKET_TYPE_FUNCTIONAL 0x00004000 -#define RNDIS_PACKET_TYPE_MAC_FRAME 0x00008000 - -/* RNDIS offsets */ -#define RNDIS_HEADER_OFFSET 8 /* bytes */ -#define RNDIS_DATA_OFFSET ((uint32_t)(sizeof(struct urndis_packet_msg) - RNDIS_HEADER_OFFSET)) - #endif /* _IF_URNDISREG_H_ */ Copied and modified: stable/11/sys/net/rndis.h (from r304654, head/sys/net/rndis.h) ============================================================================== --- head/sys/net/rndis.h Tue Aug 23 02:54:06 2016 (r304654, copy source) +++ stable/11/sys/net/rndis.h Mon Oct 17 06:56:58 2016 (r307481) @@ -23,15 +23,19 @@ #ifndef _NET_RNDIS_H_ #define _NET_RNDIS_H_ -#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L -#define RNDIS_STATUS_FAILURE 0xC0000001L -#define RNDIS_STATUS_INVALID_DATA 0xC0010015L +/* Canonical major/minor version as of 22th Aug. 2016. */ +#define RNDIS_VERSION_MAJOR 0x00000001 +#define RNDIS_VERSION_MINOR 0x00000000 + +#define RNDIS_STATUS_SUCCESS 0x00000000L +#define RNDIS_STATUS_PENDING 0x00000103L #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL +#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L +#define RNDIS_STATUS_FAILURE 0xC0000001L #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL -#define RNDIS_STATUS_PENDING STATUS_PENDING /* XXX */ #define RNDIS_STATUS_RESOURCES 0xC000009AL -#define RNDIS_STATUS_SUCCESS 0x00000000L +#define RNDIS_STATUS_INVALID_DATA 0xC0010015L #define OID_GEN_SUPPORTED_LIST 0x00010101 #define OID_GEN_HARDWARE_STATUS 0x00010102 From owner-svn-src-stable@freebsd.org Mon Oct 17 07:02:18 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5AE74C15F0F; Mon, 17 Oct 2016 07:02:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 328EF159E; Mon, 17 Oct 2016 07:02:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H72HS3001628; Mon, 17 Oct 2016 07:02:17 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H72HP7001627; Mon, 17 Oct 2016 07:02:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170702.u9H72HP7001627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:02:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307482 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:02:18 -0000 Author: sephe Date: Mon Oct 17 07:02:17 2016 New Revision: 307482 URL: https://svnweb.freebsd.org/changeset/base/307482 Log: MFC 304724,304728 304724 hyperv/hn: Remove the redundant rid setting for RNDIS HALT. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7595 304728 hyperv/hn: Log a warning for RESET_CMPLT. RESET is not used by the hn(4) at all, and RESET_CMPLT does not even have a rid to match with the pending requests. So, let's put it onto an independent switch branch and log a warning about it. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7602 Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 06:56:58 2016 (r307481) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:02:17 2016 (r307482) @@ -324,16 +324,9 @@ hv_rf_receive_response(rndis_device *dev memcpy(&request->response_msg, response, response->msg_len); } else { - if (response->ndis_msg_type == REMOTE_NDIS_RESET_CMPLT) { - /* Does not have a request id field */ - request->response_msg.msg.reset_complete.status = - STATUS_BUFFER_OVERFLOW; - } else { - request->response_msg.msg.init_complete.status = - STATUS_BUFFER_OVERFLOW; - } + request->response_msg.msg.init_complete.status = + STATUS_BUFFER_OVERFLOW; } - sema_post(&request->wait_sema); } } @@ -566,29 +559,40 @@ hv_rf_on_receive(struct hn_softc *sc, st rndis_hdr = data; switch (rndis_hdr->ndis_msg_type) { - /* data message */ case REMOTE_NDIS_PACKET_MSG: hv_rf_receive_data(rxr, data, dlen); break; + /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_SET_CMPLT: - case REMOTE_NDIS_RESET_CMPLT: case REMOTE_NDIS_KEEPALIVE_CMPLT: hv_rf_receive_response(rndis_dev, rndis_hdr); break; + /* notification message */ case REMOTE_NDIS_INDICATE_STATUS_MSG: hv_rf_receive_indicate_status(rndis_dev, rndis_hdr); break; + + case REMOTE_NDIS_RESET_CMPLT: + /* + * Reset completed, no rid. + * + * NOTE: + * RESET is not issued by hn(4), so this message should + * _not_ be observed. + */ + if_printf(sc->hn_ifp, "RESET CMPLT received\n"); + break; + default: - printf("hv_rf_on_receive(): Unknown msg_type 0x%x\n", + if_printf(sc->hn_ifp, "unknown RNDIS message 0x%x\n", rndis_hdr->ndis_msg_type); break; } - return (0); } @@ -928,7 +932,6 @@ static int hv_rf_halt_device(rndis_device *device) { rndis_request *request; - rndis_halt_request *halt; int i, ret; /* Attempt to do a rndis device halt */ @@ -941,12 +944,6 @@ hv_rf_halt_device(rndis_device *device) /* initialize "poor man's semaphore" */ request->halt_complete_flag = 0; - /* Set up the rndis set */ - halt = &request->request_msg.msg.halt_request; - halt->request_id = atomic_fetchadd_int(&device->new_request_id, 1); - /* Increment to get the new value (call above returns old value) */ - halt->request_id += 1; - ret = hv_rf_send_request(device, request, REMOTE_NDIS_HALT_MSG); if (ret != 0) { return (-1); From owner-svn-src-stable@freebsd.org Mon Oct 17 07:06:16 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 14262C130F7; Mon, 17 Oct 2016 07:06:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CAE651786; Mon, 17 Oct 2016 07:06:15 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H76Esi001809; Mon, 17 Oct 2016 07:06:14 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H76E0Z001803; Mon, 17 Oct 2016 07:06:14 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170706.u9H76E0Z001803@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:06:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307483 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:06:16 -0000 Author: sephe Date: Mon Oct 17 07:06:14 2016 New Revision: 307483 URL: https://svnweb.freebsd.org/changeset/base/307483 Log: MFC 304730 hyperv/ic: Redefine IC version negotiate message. And stringent input IC version negotiate message checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7614 Added: stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h - copied unchanged from r304730, head/sys/dev/hyperv/utilities/vmbus_icreg.h Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/utilities/hv_util.c stable/11/sys/dev/hyperv/utilities/hv_util.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 07:02:17 2016 (r307482) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 07:06:14 2016 (r307483) @@ -80,7 +80,11 @@ hv_heartbeat_cb(struct vmbus_channel *ch &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, buf); + int error; + + error = vmbus_ic_negomsg(softc, buf, recvlen); + if (error) + return; } else { heartbeat_msg = (struct hv_vmbus_heartbeat_msg_data *) Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 07:02:17 2016 (r307482) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 07:06:14 2016 (r307483) @@ -85,7 +85,11 @@ hv_shutdown_cb(struct vmbus_channel *cha &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, buf); + int error; + + error = vmbus_ic_negomsg(softc, buf, recv_len); + if (error) + return; } else { shutdown_msg = (struct hv_vmbus_shutdown_msg_data *) Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 07:02:17 2016 (r307482) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 07:06:14 2016 (r307483) @@ -160,7 +160,11 @@ hv_timesync_cb(struct vmbus_channel *cha sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, time_buf); + int error; + + error = vmbus_ic_negomsg(&softc->util_sc, time_buf, recvlen); + if (error) + return; } else { timedatap = (struct hv_ictimesync_data *) &time_buf[ sizeof(struct hv_vmbus_pipe_hdr) + Modified: stable/11/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 07:02:17 2016 (r307482) +++ stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 07:06:14 2016 (r307483) @@ -36,44 +36,62 @@ #include #include #include +#include #include -#include #include #include -#include #include +#include #include "vmbus_if.h" #define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) -void -hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf) +CTASSERT(sizeof(struct vmbus_icmsg_negotiate) < VMBUS_IC_BRSIZE); + +int +vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int dlen) { - struct hv_vmbus_icmsg_negotiate *negop; + struct vmbus_icmsg_negotiate *nego; + int cnt, major; - icmsghdrp->icmsgsize = 0x10; + /* + * Preliminary message size verification + */ + if (dlen < sizeof(*nego)) { + device_printf(sc->ic_dev, "truncated ic negotiate, len %d\n", + dlen); + return EINVAL; + } + nego = data; - negop = (struct hv_vmbus_icmsg_negotiate *)&buf[ - sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - - if (negop->icframe_vercnt >= 2 && - negop->icversion_data[1].major == 3) { - negop->icversion_data[0].major = 3; - negop->icversion_data[0].minor = 0; - negop->icversion_data[1].major = 3; - negop->icversion_data[1].minor = 0; - } else { - negop->icversion_data[0].major = 1; - negop->icversion_data[0].minor = 0; - negop->icversion_data[1].major = 1; - negop->icversion_data[1].minor = 0; + cnt = nego->ic_fwver_cnt + nego->ic_msgver_cnt; + if (dlen < __offsetof(struct vmbus_icmsg_negotiate, ic_ver[cnt])) { + device_printf(sc->ic_dev, "ic negotiate does not contain " + "versions %d\n", dlen); + return EINVAL; } - negop->icframe_vercnt = 1; - negop->icmsg_vercnt = 1; + /* Select major version; XXX looks wrong. */ + if (nego->ic_fwver_cnt >= 2 && VMBUS_ICVER_MAJOR(nego->ic_ver[1]) == 3) + major = 3; + else + major = 1; + + /* One framework version */ + nego->ic_fwver_cnt = 1; + nego->ic_ver[0] = VMBUS_IC_VERSION(major, 0); + + /* One message version */ + nego->ic_msgver_cnt = 1; + nego->ic_ver[1] = VMBUS_IC_VERSION(major, 0); + + /* Data contains two versions */ + nego->ic_hdr.ic_dsize = __offsetof(struct vmbus_icmsg_negotiate, + ic_ver[2]) - sizeof(struct vmbus_icmsg_hdr); + + return 0; } int @@ -101,6 +119,7 @@ hv_util_attach(device_t dev, vmbus_chan_ struct vmbus_channel *chan = vmbus_get_channel(dev); int error; + sc->ic_dev = dev; sc->ic_buflen = VMBUS_IC_BRSIZE; sc->receive_buffer = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, M_WAITOK | M_ZERO); Modified: stable/11/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 07:02:17 2016 (r307482) +++ stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 07:06:14 2016 (r307483) @@ -39,6 +39,7 @@ * */ typedef struct hv_util_sc { + device_t ic_dev; uint8_t *receive_buffer; int ic_buflen; } hv_util_sc; @@ -50,10 +51,9 @@ struct vmbus_ic_desc { #define VMBUS_IC_DESC_END { .ic_desc = NULL } -void hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf); - int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); int hv_util_detach(device_t dev); int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); +int vmbus_ic_negomsg(struct hv_util_sc *, void *data, int dlen); #endif Copied: stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h (from r304730, head/sys/dev/hyperv/utilities/vmbus_icreg.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h Mon Oct 17 07:06:14 2016 (r307483, copy of r304730, head/sys/dev/hyperv/utilities/vmbus_icreg.h) @@ -0,0 +1,84 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _VMBUS_ICREG_H_ +#define _VMBUS_ICREG_H_ + +#define VMBUS_ICMSG_TYPE_NEGOTIATE 0 +#define VMBUS_ICMSG_TYPE_HEARTBEAT 1 +#define VMBUS_ICMSG_TYPE_KVP 2 +#define VMBUS_ICMSG_TYPE_SHUTDOWN 3 +#define VMBUS_ICMSG_TYPE_TIMESYNC 4 +#define VMBUS_ICMSG_TYPE_VSS 5 + +#define VMBUS_ICMSG_STATUS_OK 0x00000000 +#define VMBUS_ICMSG_STATUS_FAIL 0x80004005 + +#define VMBUS_IC_VERSION(major, minor) ((major) | (((uint32_t)(minor)) << 16)) +#define VMBUS_ICVER_MAJOR(ver) ((ver) & 0xffff) +#define VMBUS_ICVER_MINOR(ver) (((ver) & 0xffff0000) >> 16) + +struct vmbus_pipe_hdr { + uint32_t ph_flags; + uint32_t ph_msgsz; +} __packed; + +struct vmbus_icmsg_hdr { + struct vmbus_pipe_hdr ic_pipe; + uint32_t ic_fwver; /* framework version */ + uint16_t ic_type; + uint32_t ic_msgver; /* message version */ + uint16_t ic_dsize; /* data size */ + uint32_t ic_status; /* VMBUS_ICMSG_STATUS_ */ + uint8_t ic_xactid; + uint8_t ic_flags; /* VMBUS_ICMSG_FLAG_ */ + uint8_t ic_rsvd[2]; +} __packed; + +#define VMBUS_ICMSG_FLAG_XACT 0x0001 +#define VMBUS_ICMSG_FLAG_REQ 0x0002 +#define VMBUS_ICMSG_FLAG_RESP 0x0004 + +/* VMBUS_ICMSG_TYPE_NEGOTIATE */ +struct vmbus_icmsg_negotiate { + struct vmbus_icmsg_hdr ic_hdr; + uint16_t ic_fwver_cnt; + uint16_t ic_msgver_cnt; + uint32_t ic_rsvd; + /* + * This version array contains two set of supported + * versions: + * - The first set consists of #ic_fwver_cnt supported framework + * versions. + * - The second set consists of #ic_msgver_cnt supported message + * versions. + */ + uint32_t ic_ver[]; +} __packed; + +#endif /* !_VMBUS_ICREG_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 07:10:59 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC388C13266; Mon, 17 Oct 2016 07:10:59 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7C201A25; Mon, 17 Oct 2016 07:10:59 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7Awhl004734; Mon, 17 Oct 2016 07:10:58 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7AwWl004726; Mon, 17 Oct 2016 07:10:58 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170710.u9H7AwWl004726@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:10:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307484 - in stable/11/sys: dev/hyperv/netvsc net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:11:00 -0000 Author: sephe Date: Mon Oct 17 07:10:58 2016 New Revision: 307484 URL: https://svnweb.freebsd.org/changeset/base/307484 Log: MFC 304783-304785 304783 hyperv/hn: Use definition in net/rndis.h for message type and status code. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7620 304784 hyperv/hn: Add compat code for RNDIS reorganization phase. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7621 304785 hyperv/hn: Use vmbus xact for RNDIS initialize. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7624 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis.h stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:06:14 2016 (r307483) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:10:58 2016 (r307484) @@ -77,7 +77,7 @@ static void hn_nvs_sent_none(struct hn_s static void hn_nvs_sent_xact(struct hn_send_ctx *, struct hn_softc *sc, struct vmbus_channel *, const void *, int); -static struct hn_send_ctx hn_send_ctx_none = +struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); uint32_t Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:06:14 2016 (r307483) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:10:58 2016 (r307484) @@ -239,6 +239,11 @@ typedef struct { uint8_t link_state; } netvsc_device_info; +#define HN_XACT_REQ_PGCNT 2 +#define HN_XACT_RESP_PGCNT 2 +#define HN_XACT_REQ_SIZE (HN_XACT_REQ_PGCNT * PAGE_SIZE) +#define HN_XACT_RESP_SIZE (HN_XACT_RESP_PGCNT * PAGE_SIZE) + #ifndef HN_USE_TXDESC_BUFRING struct hn_txdesc; SLIST_HEAD(hn_txdesc_list, hn_txdesc); @@ -375,6 +380,8 @@ typedef struct hn_softc { uint32_t hn_chim_gpadl; struct hyperv_dma hn_chim_dma; + + uint32_t hn_rndis_rid; } hn_softc_t; #define HN_FLAG_RXBUF_CONNECTED 0x0001 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:06:14 2016 (r307483) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:10:58 2016 (r307484) @@ -125,9 +125,6 @@ __FBSDID("$FreeBSD$"); /* Short for Hyper-V network interface */ #define NETVSC_DEVNAME "hn" -#define HN_XACT_REQ_SIZE (2 * PAGE_SIZE) -#define HN_XACT_RESP_SIZE (2 * PAGE_SIZE) - /* * It looks like offset 0 of buf is reserved to hold the softc pointer. * The sc pointer evidently not needed, and is not presently populated. Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:06:14 2016 (r307483) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:10:58 2016 (r307484) @@ -31,6 +31,7 @@ #ifndef __HV_RNDIS_H__ #define __HV_RNDIS_H__ +#include /* * NDIS protocol version numbers @@ -48,95 +49,6 @@ #define NDIS_VERSION (NDIS_VERSION_5_1) /* - * Status codes - */ - -#define STATUS_SUCCESS (0x00000000L) -#define STATUS_UNSUCCESSFUL (0xC0000001L) -#define STATUS_PENDING (0x00000103L) -#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL) -#define STATUS_BUFFER_OVERFLOW (0x80000005L) -#define STATUS_NOT_SUPPORTED (0xC00000BBL) - -#define RNDIS_STATUS_SUCCESS (STATUS_SUCCESS) -#define RNDIS_STATUS_PENDING (STATUS_PENDING) -#define RNDIS_STATUS_NOT_RECOGNIZED (0x00010001L) -#define RNDIS_STATUS_NOT_COPIED (0x00010002L) -#define RNDIS_STATUS_NOT_ACCEPTED (0x00010003L) -#define RNDIS_STATUS_CALL_ACTIVE (0x00010007L) - -#define RNDIS_STATUS_ONLINE (0x40010003L) -#define RNDIS_STATUS_RESET_START (0x40010004L) -#define RNDIS_STATUS_RESET_END (0x40010005L) -#define RNDIS_STATUS_RING_STATUS (0x40010006L) -#define RNDIS_STATUS_CLOSED (0x40010007L) -#define RNDIS_STATUS_WAN_LINE_UP (0x40010008L) -#define RNDIS_STATUS_WAN_LINE_DOWN (0x40010009L) -#define RNDIS_STATUS_WAN_FRAGMENT (0x4001000AL) -#define RNDIS_STATUS_MEDIA_CONNECT (0x4001000BL) -#define RNDIS_STATUS_MEDIA_DISCONNECT (0x4001000CL) -#define RNDIS_STATUS_HARDWARE_LINE_UP (0x4001000DL) -#define RNDIS_STATUS_HARDWARE_LINE_DOWN (0x4001000EL) -#define RNDIS_STATUS_INTERFACE_UP (0x4001000FL) -#define RNDIS_STATUS_INTERFACE_DOWN (0x40010010L) -#define RNDIS_STATUS_MEDIA_BUSY (0x40010011L) -#define RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION (0x40010012L) -#define RNDIS_STATUS_WW_INDICATION RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION -#define RNDIS_STATUS_LINK_SPEED_CHANGE (0x40010013L) - -#define RNDIS_STATUS_NOT_RESETTABLE (0x80010001L) -#define RNDIS_STATUS_SOFT_ERRORS (0x80010003L) -#define RNDIS_STATUS_HARD_ERRORS (0x80010004L) -#define RNDIS_STATUS_BUFFER_OVERFLOW (STATUS_BUFFER_OVERFLOW) - -#define RNDIS_STATUS_FAILURE (STATUS_UNSUCCESSFUL) -#define RNDIS_STATUS_RESOURCES (STATUS_INSUFFICIENT_RESOURCES) -#define RNDIS_STATUS_CLOSING (0xC0010002L) -#define RNDIS_STATUS_BAD_VERSION (0xC0010004L) -#define RNDIS_STATUS_BAD_CHARACTERISTICS (0xC0010005L) -#define RNDIS_STATUS_ADAPTER_NOT_FOUND (0xC0010006L) -#define RNDIS_STATUS_OPEN_FAILED (0xC0010007L) -#define RNDIS_STATUS_DEVICE_FAILED (0xC0010008L) -#define RNDIS_STATUS_MULTICAST_FULL (0xC0010009L) -#define RNDIS_STATUS_MULTICAST_EXISTS (0xC001000AL) -#define RNDIS_STATUS_MULTICAST_NOT_FOUND (0xC001000BL) -#define RNDIS_STATUS_REQUEST_ABORTED (0xC001000CL) -#define RNDIS_STATUS_RESET_IN_PROGRESS (0xC001000DL) -#define RNDIS_STATUS_CLOSING_INDICATING (0xC001000EL) -#define RNDIS_STATUS_NOT_SUPPORTED (STATUS_NOT_SUPPORTED) -#define RNDIS_STATUS_INVALID_PACKET (0xC001000FL) -#define RNDIS_STATUS_OPEN_LIST_FULL (0xC0010010L) -#define RNDIS_STATUS_ADAPTER_NOT_READY (0xC0010011L) -#define RNDIS_STATUS_ADAPTER_NOT_OPEN (0xC0010012L) -#define RNDIS_STATUS_NOT_INDICATING (0xC0010013L) -#define RNDIS_STATUS_INVALID_LENGTH (0xC0010014L) -#define RNDIS_STATUS_INVALID_DATA (0xC0010015L) -#define RNDIS_STATUS_BUFFER_TOO_SHORT (0xC0010016L) -#define RNDIS_STATUS_INVALID_OID (0xC0010017L) -#define RNDIS_STATUS_ADAPTER_REMOVED (0xC0010018L) -#define RNDIS_STATUS_UNSUPPORTED_MEDIA (0xC0010019L) -#define RNDIS_STATUS_GROUP_ADDRESS_IN_USE (0xC001001AL) -#define RNDIS_STATUS_FILE_NOT_FOUND (0xC001001BL) -#define RNDIS_STATUS_ERROR_READING_FILE (0xC001001CL) -#define RNDIS_STATUS_ALREADY_MAPPED (0xC001001DL) -#define RNDIS_STATUS_RESOURCE_CONFLICT (0xC001001EL) -#define RNDIS_STATUS_NO_CABLE (0xC001001FL) - -#define RNDIS_STATUS_INVALID_SAP (0xC0010020L) -#define RNDIS_STATUS_SAP_IN_USE (0xC0010021L) -#define RNDIS_STATUS_INVALID_ADDRESS (0xC0010022L) -#define RNDIS_STATUS_VC_NOT_ACTIVATED (0xC0010023L) -#define RNDIS_STATUS_DEST_OUT_OF_ORDER (0xC0010024L) -#define RNDIS_STATUS_VC_NOT_AVAILABLE (0xC0010025L) -#define RNDIS_STATUS_CELLRATE_NOT_AVAILABLE (0xC0010026L) -#define RNDIS_STATUS_INCOMPATABLE_QOS (0xC0010027L) -#define RNDIS_STATUS_AAL_PARAMS_UNSUPPORTED (0xC0010028L) -#define RNDIS_STATUS_NO_ROUTE_TO_DESTINATION (0xC0010029L) - -#define RNDIS_STATUS_TOKEN_RING_OPEN_ERROR (0xC0011000L) - - -/* * Object Identifiers used by NdisRequest Query/Set Information */ @@ -289,82 +201,6 @@ */ #define OID_RNDISMP_GET_RECEIVE_BUFFERS 0xFFA0C90D // Query only - -/* - * Remote NDIS message types - */ -#define REMOTE_NDIS_PACKET_MSG 0x00000001 -#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 -#define REMOTE_NDIS_HALT_MSG 0x00000003 -#define REMOTE_NDIS_QUERY_MSG 0x00000004 -#define REMOTE_NDIS_SET_MSG 0x00000005 -#define REMOTE_NDIS_RESET_MSG 0x00000006 -#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 -#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 - -#define REMOTE_CONDIS_MP_CREATE_VC_MSG 0x00008001 -#define REMOTE_CONDIS_MP_DELETE_VC_MSG 0x00008002 -#define REMOTE_CONDIS_MP_ACTIVATE_VC_MSG 0x00008005 -#define REMOTE_CONDIS_MP_DEACTIVATE_VC_MSG 0x00008006 -#define REMOTE_CONDIS_INDICATE_STATUS_MSG 0x00008007 - -/* - * Remote NDIS message completion types - */ -#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002 -#define REMOTE_NDIS_QUERY_CMPLT 0x80000004 -#define REMOTE_NDIS_SET_CMPLT 0x80000005 -#define REMOTE_NDIS_RESET_CMPLT 0x80000006 -#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 - -#define REMOTE_CONDIS_MP_CREATE_VC_CMPLT 0x80008001 -#define REMOTE_CONDIS_MP_DELETE_VC_CMPLT 0x80008002 -#define REMOTE_CONDIS_MP_ACTIVATE_VC_CMPLT 0x80008005 -#define REMOTE_CONDIS_MP_DEACTIVATE_VC_CMPLT 0x80008006 - -/* - * Reserved message type for private communication between lower-layer - * host driver and remote device, if necessary. - */ -#define REMOTE_NDIS_BUS_MSG 0xff000001 - -/* - * Defines for DeviceFlags in rndis_initialize_complete - */ -#define RNDIS_DF_CONNECTIONLESS 0x00000001 -#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 -#define RNDIS_DF_RAW_DATA 0x00000004 - -/* - * Remote NDIS medium types. - */ -#define RNDIS_MEDIUM_802_3 0x00000000 -#define RNDIS_MEDIUM_802_5 0x00000001 -#define RNDIS_MEDIUM_FDDI 0x00000002 -#define RNDIS_MEDIUM_WAN 0x00000003 -#define RNDIS_MEDIUM_LOCAL_TALK 0x00000004 -#define RNDIS_MEDIUM_ARCNET_RAW 0x00000006 -#define RNDIS_MEDIUM_ARCNET_878_2 0x00000007 -#define RNDIS_MEDIUM_ATM 0x00000008 -#define RNDIS_MEDIUM_WIRELESS_WAN 0x00000009 -#define RNDIS_MEDIUM_IRDA 0x0000000a -#define RNDIS_MEDIUM_CO_WAN 0x0000000b -/* Not a real medium, defined as an upper bound */ -#define RNDIS_MEDIUM_MAX 0x0000000d - -/* - * Remote NDIS medium connection states. - */ -#define RNDIS_MEDIA_STATE_CONNECTED 0x00000000 -#define RNDIS_MEDIA_STATE_DISCONNECTED 0x00000001 - -/* - * Remote NDIS version numbers - */ -#define RNDIS_MAJOR_VERSION 0x00000001 -#define RNDIS_MINOR_VERSION 0x00000000 - - /* * Remote NDIS offload parameters */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:06:14 2016 (r307483) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:10:58 2016 (r307484) @@ -62,6 +62,11 @@ __FBSDID("$FreeBSD$"); HV_RF_RECVINFO_HASHINF | \ HV_RF_RECVINFO_HASHVAL) +#define HN_RNDIS_RID_COMPAT_MASK 0xffff +#define HN_RNDIS_RID_COMPAT_MAX HN_RNDIS_RID_COMPAT_MASK + +#define HN_RNDIS_XFER_SIZE 2048 + /* * Forward declarations */ @@ -92,6 +97,20 @@ static void hn_rndis_sent_cb(struct hn_s struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); +static __inline uint32_t +hn_rndis_rid(struct hn_softc *sc) +{ + uint32_t rid; + +again: + rid = atomic_fetchadd_int(&sc->hn_rndis_rid, 1); + if (rid == 0) + goto again; + + /* Use upper 16 bits for non-compat RNDIS messages. */ + return ((rid & 0xffff) << 16); +} + /* * Set the Per-Packet-Info with the specified type */ @@ -202,9 +221,8 @@ hv_rndis_request(rndis_device *device, u * as a template. */ set = &rndis_mesg->msg.set_request; - set->request_id = atomic_fetchadd_int(&device->new_request_id, 1); - /* Increment to get the new value (call above returns old value) */ - set->request_id += 1; + set->request_id = atomic_fetchadd_int(&device->new_request_id, 1) & + HN_RNDIS_RID_COMPAT_MASK; /* Add to the request list */ mtx_lock(&device->req_lock); @@ -325,7 +343,7 @@ hv_rf_receive_response(rndis_device *dev response->msg_len); } else { request->response_msg.msg.init_complete.status = - STATUS_BUFFER_OVERFLOW; + RNDIS_STATUS_BUFFER_OVERFLOW; } sema_post(&request->wait_sema); } @@ -389,7 +407,7 @@ hv_rf_send_offload_request(struct hn_sof device_printf(dev, "hv send offload request succeeded\n"); ret = 0; } else { - if (set_complete->status == STATUS_NOT_SUPPORTED) { + if (set_complete->status == RNDIS_STATUS_NOT_SUPPORTED) { device_printf(dev, "HV Not support offload\n"); ret = 0; } else { @@ -552,6 +570,7 @@ hv_rf_on_receive(struct hn_softc *sc, st { rndis_device *rndis_dev; const rndis_msg *rndis_hdr; + const struct rndis_comp_hdr *comp; rndis_dev = sc->rndis_dev; if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) @@ -569,7 +588,13 @@ hv_rf_on_receive(struct hn_softc *sc, st case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_SET_CMPLT: case REMOTE_NDIS_KEEPALIVE_CMPLT: - hv_rf_receive_response(rndis_dev, rndis_hdr); + comp = data; + if (comp->rm_rid <= HN_RNDIS_RID_COMPAT_MAX) { + /* Transition time compat code */ + hv_rf_receive_response(rndis_dev, rndis_hdr); + } else { + vmbus_xact_ctx_wakeup(sc->hn_xact, data, dlen); + } break; /* notification message */ @@ -865,62 +890,139 @@ exit: return (ret); } -/* - * RNDIS filter init device - */ -static int -hv_rf_init_device(rndis_device *device) -{ - rndis_request *request; - rndis_initialize_request *init; - rndis_initialize_complete *init_complete; - uint32_t status; - int ret; +static const void * +hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, + size_t reqlen, size_t min_complen, uint32_t comp_type) +{ + struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; + const struct rndis_comp_hdr *comp; + bus_addr_t paddr; + size_t comp_len; + int gpa_cnt, error; + + KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); + KASSERT(reqlen <= HN_XACT_REQ_SIZE && reqlen > 0, + ("invalid request length %zu", reqlen)); + KASSERT(min_complen >= sizeof(*comp), + ("invalid minimum complete len %zu", min_complen)); - request = hv_rndis_request(device, REMOTE_NDIS_INITIALIZE_MSG, - RNDIS_MESSAGE_SIZE(rndis_initialize_request)); - if (!request) { - ret = -1; - goto cleanup; + /* + * Setup the SG list. + */ + paddr = vmbus_xact_req_paddr(xact); + KASSERT((paddr & PAGE_MASK) == 0, + ("vmbus xact request is not page aligned 0x%jx", (uintmax_t)paddr)); + for (gpa_cnt = 0; gpa_cnt < HN_XACT_REQ_PGCNT; ++gpa_cnt) { + int len = PAGE_SIZE; + + if (reqlen == 0) + break; + if (reqlen < len) + len = reqlen; + + gpa[gpa_cnt].gpa_page = atop(paddr) + gpa_cnt; + gpa[gpa_cnt].gpa_len = len; + gpa[gpa_cnt].gpa_ofs = 0; + + reqlen -= len; } + KASSERT(reqlen == 0, ("still have %zu request data left", reqlen)); - /* Set up the rndis set */ - init = &request->request_msg.msg.init_request; - init->major_version = RNDIS_MAJOR_VERSION; - init->minor_version = RNDIS_MINOR_VERSION; /* - * Per the RNDIS document, this should be set to the max MTU - * plus the header size. However, 2048 works fine, so leaving - * it as is. + * Send this RNDIS control message and wait for its completion + * message. */ - init->max_xfer_size = 2048; - - device->state = RNDIS_DEV_INITIALIZING; + vmbus_xact_activate(xact); + error = hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, + &hn_send_ctx_none, gpa, gpa_cnt); + if (error) { + vmbus_xact_deactivate(xact); + if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); + return (NULL); + } + comp = vmbus_xact_wait(xact, &comp_len); - ret = hv_rf_send_request(device, request, REMOTE_NDIS_INITIALIZE_MSG); - if (ret != 0) { - device->state = RNDIS_DEV_UNINITIALIZED; - goto cleanup; + /* + * Check this RNDIS complete message. + */ + if (comp_len < min_complen) { + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu\n", comp_len); + return (NULL); + } + if (comp->rm_len < min_complen) { + if_printf(sc->hn_ifp, "invalid RNDIS comp msglen %u\n", + comp->rm_len); + return (NULL); + } + if (comp->rm_type != comp_type) { + if_printf(sc->hn_ifp, "unexpected RNDIS comp 0x%08x, " + "expect 0x%08x\n", comp->rm_type, comp_type); + return (NULL); + } + if (comp->rm_rid != rid) { + if_printf(sc->hn_ifp, "RNDIS comp rid mismatch %u, " + "expect %u\n", comp->rm_rid, rid); + return (NULL); } + /* All pass! */ + return (comp); +} - sema_wait(&request->wait_sema); +/* + * RNDIS filter init device + */ +static int +hv_rf_init_device(rndis_device *device) +{ + struct hn_softc *sc = device->sc; + struct rndis_init_req *req; + const struct rndis_init_comp *comp; + struct vmbus_xact *xact; + uint32_t rid; + int error; - init_complete = &request->response_msg.msg.init_complete; - status = init_complete->status; - if (status == RNDIS_STATUS_SUCCESS) { - device->state = RNDIS_DEV_INITIALIZED; - ret = 0; - } else { - device->state = RNDIS_DEV_UNINITIALIZED; - ret = -1; - } + /* XXX */ + device->state = RNDIS_DEV_INITIALIZED; -cleanup: - if (request) { - hv_put_rndis_request(device, request); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS init\n"); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_INITIALIZE_MSG; + req->rm_len = sizeof(*req); + req->rm_rid = rid; + req->rm_ver_major = RNDIS_VERSION_MAJOR; + req->rm_ver_minor = RNDIS_VERSION_MINOR; + req->rm_max_xfersz = HN_RNDIS_XFER_SIZE; + + comp = hn_rndis_xact_execute(sc, xact, rid, sizeof(*req), + RNDIS_INIT_COMP_SIZE_MIN, REMOTE_NDIS_INITIALIZE_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS init failed\n"); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS init failed: status 0x%08x\n", + comp->rm_status); + error = EIO; + goto done; + } + if (bootverbose) { + if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u\n", + comp->rm_ver_major, comp->rm_ver_minor, + comp->rm_pktmaxsz, comp->rm_pktmaxcnt); } + error = 0; - return (ret); +done: + if (xact != NULL) + vmbus_xact_put(xact); + return (error); } #define HALT_COMPLETION_WAIT_COUNT 25 Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:06:14 2016 (r307483) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:10:58 2016 (r307484) @@ -115,4 +115,6 @@ const void *hn_nvs_xact_execute(struct h uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); +extern struct hn_send_ctx hn_send_ctx_none; + #endif /* !_IF_HNVAR_H_ */ Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Mon Oct 17 07:06:14 2016 (r307483) +++ stable/11/sys/net/rndis.h Mon Oct 17 07:10:58 2016 (r307484) @@ -146,6 +146,9 @@ struct rndis_init_comp { uint32_t rm_aflistsz; }; +#define RNDIS_INIT_COMP_SIZE_MIN \ + __offsetof(struct rndis_init_comp, rm_aflistsz) + /* Halt the device. No response sent. */ #define REMOTE_NDIS_HALT_MSG 0x00000003 From owner-svn-src-stable@freebsd.org Mon Oct 17 07:13:50 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8EEAAC1340C; Mon, 17 Oct 2016 07:13:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 66B661CF1; Mon, 17 Oct 2016 07:13:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7Dnbw005717; Mon, 17 Oct 2016 07:13:49 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7Dmvh005711; Mon, 17 Oct 2016 07:13:48 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170713.u9H7Dmvh005711@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:13:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307485 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:13:50 -0000 Author: sephe Date: Mon Oct 17 07:13:48 2016 New Revision: 307485 URL: https://svnweb.freebsd.org/changeset/base/307485 Log: MFC 304786,304788 304786 hyperv/ic: Cleanup heartbeat channel callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7626 304788 hyperv/ic: Update total message size if negotiate message size grows. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7627 Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/utilities/hv_util.c stable/11/sys/dev/hyperv/utilities/hv_util.h stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 07:10:58 2016 (r307484) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 07:13:48 2016 (r307485) @@ -22,23 +22,22 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #include -#include #include -#include +#include #include -#include -#include #include #include #include -#include -#include "hv_util.h" +#include +#include + #include "vmbus_if.h" static const struct vmbus_ic_desc vmbus_heartbeat_descs[] = { @@ -51,55 +50,64 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; -/** - * Process heartbeat message - */ static void -hv_heartbeat_cb(struct vmbus_channel *channel, void *context) +vmbus_heartbeat_cb(struct vmbus_channel *chan, void *xsc) { - uint8_t* buf; - int recvlen; - uint64_t requestid; - int ret; - - struct hv_vmbus_heartbeat_msg_data* heartbeat_msg; - struct hv_vmbus_icmsg_hdr* icmsghdrp; - hv_util_sc *softc; - - softc = (hv_util_sc*)context; - buf = softc->receive_buffer; - - recvlen = softc->ic_buflen; - ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid); - KASSERT(ret != ENOBUFS, ("hvheartbeat recvbuf is not large enough")); - /* XXX check recvlen to make sure that it contains enough data */ - - if ((ret == 0) && recvlen > 0) { - - icmsghdrp = (struct hv_vmbus_icmsg_hdr *) - &buf[sizeof(struct hv_vmbus_pipe_hdr)]; - - if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - int error; + struct hv_util_sc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + int dlen, error; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->receive_buffer; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; + + if (dlen < sizeof(struct vmbus_icmsg_hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; - error = vmbus_ic_negomsg(softc, buf, recvlen); + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen); if (error) return; - } else { - heartbeat_msg = - (struct hv_vmbus_heartbeat_msg_data *) - &buf[sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - - heartbeat_msg->seq_num += 1; - } + break; - icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | - HV_ICMSGHDRFLAG_RESPONSE; - - vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, - buf, recvlen, requestid); + case VMBUS_ICMSG_TYPE_HEARTBEAT: + /* Only ic_seq is a must */ + if (dlen < VMBUS_ICMSG_HEARTBEAT_SIZE_MIN) { + device_printf(sc->ic_dev, "invalid heartbeat len %d\n", + dlen); + return; + } + ((struct vmbus_icmsg_heartbeat *)data)->ic_seq++; + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; } + + /* + * Send response by echoing the updated request back. + */ + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); } static int @@ -112,7 +120,8 @@ hv_heartbeat_probe(device_t dev) static int hv_heartbeat_attach(device_t dev) { - return hv_util_attach(dev, hv_heartbeat_cb); + + return (hv_util_attach(dev, vmbus_heartbeat_cb)); } static device_method_t heartbeat_methods[] = { Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 07:10:58 2016 (r307484) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 07:13:48 2016 (r307485) @@ -87,7 +87,7 @@ hv_shutdown_cb(struct vmbus_channel *cha if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { int error; - error = vmbus_ic_negomsg(softc, buf, recv_len); + error = vmbus_ic_negomsg(softc, buf, &recv_len); if (error) return; } else { Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 07:10:58 2016 (r307484) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 07:13:48 2016 (r307485) @@ -162,7 +162,7 @@ hv_timesync_cb(struct vmbus_channel *cha if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { int error; - error = vmbus_ic_negomsg(&softc->util_sc, time_buf, recvlen); + error = vmbus_ic_negomsg(&softc->util_sc, time_buf, &recvlen); if (error) return; } else { Modified: stable/11/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 07:10:58 2016 (r307484) +++ stable/11/sys/dev/hyperv/utilities/hv_util.c Mon Oct 17 07:13:48 2016 (r307485) @@ -48,13 +48,16 @@ #define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) -CTASSERT(sizeof(struct vmbus_icmsg_negotiate) < VMBUS_IC_BRSIZE); +#define VMBUS_IC_VERCNT 2 +#define VMBUS_IC_NEGOSZ \ + __offsetof(struct vmbus_icmsg_negotiate, ic_ver[VMBUS_IC_VERCNT]) +CTASSERT(VMBUS_IC_NEGOSZ < VMBUS_IC_BRSIZE); int -vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int dlen) +vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen0) { struct vmbus_icmsg_negotiate *nego; - int cnt, major; + int cnt, major, dlen = *dlen0; /* * Preliminary message size verification @@ -87,9 +90,13 @@ vmbus_ic_negomsg(struct hv_util_sc *sc, nego->ic_msgver_cnt = 1; nego->ic_ver[1] = VMBUS_IC_VERSION(major, 0); - /* Data contains two versions */ - nego->ic_hdr.ic_dsize = __offsetof(struct vmbus_icmsg_negotiate, - ic_ver[2]) - sizeof(struct vmbus_icmsg_hdr); + /* Update data size */ + nego->ic_hdr.ic_dsize = VMBUS_IC_NEGOSZ - + sizeof(struct vmbus_icmsg_hdr); + + /* Update total size, if necessary */ + if (dlen < VMBUS_IC_NEGOSZ) + *dlen0 = VMBUS_IC_NEGOSZ; return 0; } Modified: stable/11/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 07:10:58 2016 (r307484) +++ stable/11/sys/dev/hyperv/utilities/hv_util.h Mon Oct 17 07:13:48 2016 (r307485) @@ -54,6 +54,6 @@ struct vmbus_ic_desc { int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); int hv_util_detach(device_t dev); int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); -int vmbus_ic_negomsg(struct hv_util_sc *, void *data, int dlen); +int vmbus_ic_negomsg(struct hv_util_sc *, void *data, int *dlen); #endif Modified: stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h ============================================================================== --- stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h Mon Oct 17 07:10:58 2016 (r307484) +++ stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h Mon Oct 17 07:13:48 2016 (r307485) @@ -81,4 +81,14 @@ struct vmbus_icmsg_negotiate { uint32_t ic_ver[]; } __packed; +/* VMBUS_ICMSG_TYPE_HEARTBEAT */ +struct vmbus_icmsg_heartbeat { + struct vmbus_icmsg_hdr ic_hdr; + uint64_t ic_seq; + uint32_t ic_rsvd[8]; +} __packed; + +#define VMBUS_ICMSG_HEARTBEAT_SIZE_MIN \ + __offsetof(struct vmbus_icmsg_heartbeat, ic_rsvd[0]) + #endif /* !_VMBUS_ICREG_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 07:16:06 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 49B14C13540; Mon, 17 Oct 2016 07:16:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 116591E99; Mon, 17 Oct 2016 07:16:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7G5TY005859; Mon, 17 Oct 2016 07:16:05 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7G4Wt005854; Mon, 17 Oct 2016 07:16:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170716.u9H7G4Wt005854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:16:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307486 - in stable/11/sys/dev/hyperv: include storvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:16:06 -0000 Author: sephe Date: Mon Oct 17 07:16:04 2016 New Revision: 307486 URL: https://svnweb.freebsd.org/changeset/base/307486 Log: MFC 304790,304791 304790 hyperv/vmbus: Add function to calculate max # of elements in a bufring. Sponsored by: Microsoft 304791 hyperv/storvsc: Increase queue depth and rework channel selection. - Increasing queue depth gives ~100% performance improvement for randwrite fio test in Azure. - New channel selection, which takes LUN id and the current cpuid into consideration, gives additional ~20% performance improvement for ranwrite fio test in Azure. Submitted by: Hongzhang Jiang Modified by: sephe Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7622 Modified: stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 07:13:48 2016 (r307485) +++ stable/11/sys/dev/hyperv/include/vmbus.h Mon Oct 17 07:16:04 2016 (r307486) @@ -161,5 +161,7 @@ uint32_t vmbus_chan_subidx(const struct bool vmbus_chan_is_primary(const struct vmbus_channel *chan); const struct hyperv_guid * vmbus_chan_guid_inst(const struct vmbus_channel *chan); +int vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, + int dlen_max); #endif /* !_VMBUS_H_ */ Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 07:13:48 2016 (r307485) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Oct 17 07:16:04 2016 (r307486) @@ -75,11 +75,9 @@ __FBSDID("$FreeBSD$"); #include #include - #include "hv_vstorage.h" #include "vmbus_if.h" -#define STORVSC_RINGBUFFER_SIZE (20*PAGE_SIZE) #define STORVSC_MAX_LUNS_PER_TARGET (64) #define STORVSC_MAX_IO_REQUESTS (STORVSC_MAX_LUNS_PER_TARGET * 2) #define BLKVSC_MAX_IDE_DISKS_PER_TARGET (1) @@ -121,8 +119,6 @@ struct hv_sgl_page_pool{ boolean_t is_init; } g_hv_sgl_page_pool; -#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * STORVSC_DATA_SEGCNT_MAX - enum storvsc_request_type { WRITE_TYPE, READ_TYPE, @@ -130,17 +126,35 @@ enum storvsc_request_type { }; SYSCTL_NODE(_hw, OID_AUTO, storvsc, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, - "Hyper-V storage interface"); + "Hyper-V storage interface"); + +static u_int hv_storvsc_use_win8ext_flags = 1; +SYSCTL_UINT(_hw_storvsc, OID_AUTO, use_win8ext_flags, CTLFLAG_RW, + &hv_storvsc_use_win8ext_flags, 0, + "Use win8 extension flags or not"); static u_int hv_storvsc_use_pim_unmapped = 1; -SYSCTL_INT(_hw_storvsc, OID_AUTO, use_pim_unmapped, CTLFLAG_RDTUN, - &hv_storvsc_use_pim_unmapped, 0, - "Optimize storvsc by using unmapped I/O"); +SYSCTL_UINT(_hw_storvsc, OID_AUTO, use_pim_unmapped, CTLFLAG_RDTUN, + &hv_storvsc_use_pim_unmapped, 0, + "Optimize storvsc by using unmapped I/O"); + +static u_int hv_storvsc_ringbuffer_size = (64 * PAGE_SIZE); +SYSCTL_UINT(_hw_storvsc, OID_AUTO, ringbuffer_size, CTLFLAG_RDTUN, + &hv_storvsc_ringbuffer_size, 0, "Hyper-V storage ringbuffer size"); + +static u_int hv_storvsc_max_io = 512; +SYSCTL_UINT(_hw_storvsc, OID_AUTO, max_io, CTLFLAG_RDTUN, + &hv_storvsc_max_io, 0, "Hyper-V storage max io limit"); + +#define STORVSC_MAX_IO \ + vmbus_chan_prplist_nelem(hv_storvsc_ringbuffer_size, \ + STORVSC_DATA_SEGCNT_MAX, VSTOR_PKT_SIZE) struct hv_storvsc_sysctl { u_long data_bio_cnt; u_long data_vaddr_cnt; u_long data_sg_cnt; + u_long chan_send_cnt[MAXCPU]; }; struct storvsc_gpa_range { @@ -184,10 +198,18 @@ struct storvsc_softc { device_t hs_dev; bus_dma_tag_t storvsc_req_dtag; struct hv_storvsc_sysctl sysctl_data; - - struct vmbus_channel *hs_cpu2chan[MAXCPU]; + uint32_t hs_nchan; + struct vmbus_channel *hs_sel_chan[MAXCPU]; }; +/* + * The size of the vmscsi_request has changed in win8. The + * additional size is for the newly added elements in the + * structure. These elements are valid only when we are talking + * to a win8 host. + * Track the correct size we need to apply. + */ +static int vmscsi_size_delta = sizeof(struct vmscsi_win8_extension); /** * HyperV storvsc timeout testing cases: @@ -211,7 +233,7 @@ struct storvsc_driver_props { char *drv_name; char *drv_desc; uint8_t drv_max_luns_per_target; - uint8_t drv_max_ios_per_target; + uint32_t drv_max_ios_per_target; uint32_t drv_ringbuffer_size; }; @@ -240,10 +262,10 @@ static const struct hyperv_guid gBlkVscD static struct storvsc_driver_props g_drv_props_table[] = { {"blkvsc", "Hyper-V IDE Storage Interface", BLKVSC_MAX_IDE_DISKS_PER_TARGET, BLKVSC_MAX_IO_REQUESTS, - STORVSC_RINGBUFFER_SIZE}, + 20*PAGE_SIZE}, {"storvsc", "Hyper-V SCSI Storage Interface", STORVSC_MAX_LUNS_PER_TARGET, STORVSC_MAX_IO_REQUESTS, - STORVSC_RINGBUFFER_SIZE} + 20*PAGE_SIZE} }; /* @@ -253,14 +275,6 @@ static struct storvsc_driver_props g_drv static int sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE; /* - * The size of the vmscsi_request has changed in win8. The - * additional size is for the newly added elements in the - * structure. These elements are valid only when we are talking - * to a win8 host. - * Track the correct size we need to apply. - */ -static int vmscsi_size_delta; -/* * The storage protocol version is determined during the * initial exchange with the host. It will indicate which * storage functionality is available in the host. @@ -413,6 +427,9 @@ storvsc_send_multichannel_request(struct return; } + /* Update channel count */ + sc->hs_nchan = request_channels_cnt + 1; + /* Wait for sub-channels setup to complete. */ subchan = vmbus_subchan_get(sc->hs_chan, request_channels_cnt); @@ -585,7 +602,6 @@ hv_storvsc_channel_init(struct storvsc_s */ if (support_multichannel) storvsc_send_multichannel_request(sc, max_chans); - cleanup: sema_destroy(&request->synch_sema); return (ret); @@ -624,7 +640,6 @@ hv_storvsc_connect_vsp(struct storvsc_so } ret = hv_storvsc_channel_init(sc); - return (ret); } @@ -686,7 +701,7 @@ hv_storvsc_io_request(struct storvsc_sof { struct vstor_packet *vstor_packet = &request->vstor_packet; struct vmbus_channel* outgoing_channel = NULL; - int ret = 0; + int ret = 0, ch_sel; vstor_packet->flags |= REQUEST_COMPLETION_FLAG; @@ -700,7 +715,8 @@ hv_storvsc_io_request(struct storvsc_sof vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB; - outgoing_channel = sc->hs_cpu2chan[curcpu]; + ch_sel = (vstor_packet->u.vm_srb.lun + curcpu) % sc->hs_nchan; + outgoing_channel = sc->hs_sel_chan[ch_sel]; mtx_unlock(&request->softc->hs_lock); if (request->prp_list.gpa_range.gpa_len) { @@ -712,6 +728,10 @@ hv_storvsc_io_request(struct storvsc_sof VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } + /* statistic for successful request sending on each channel */ + if (!ret) { + sc->sysctl_data.chan_send_cnt[ch_sel]++; + } mtx_lock(&request->softc->hs_lock); if (ret != 0) { @@ -907,17 +927,20 @@ storvsc_probe(device_t dev) } static void -storvsc_create_cpu2chan(struct storvsc_softc *sc) +storvsc_create_chan_sel(struct storvsc_softc *sc) { - int cpu; + struct vmbus_channel **subch; + int i, nsubch; - CPU_FOREACH(cpu) { - sc->hs_cpu2chan[cpu] = vmbus_chan_cpu2chan(sc->hs_chan, cpu); - if (bootverbose) { - device_printf(sc->hs_dev, "cpu%d -> chan%u\n", - cpu, vmbus_chan_id(sc->hs_cpu2chan[cpu])); - } - } + sc->hs_sel_chan[0] = sc->hs_chan; + nsubch = sc->hs_nchan - 1; + if (nsubch == 0) + return; + + subch = vmbus_subchan_get(sc->hs_chan, nsubch); + for (i = 0; i < nsubch; i++) + sc->hs_sel_chan[i + 1] = subch[i]; + vmbus_subchan_rel(subch, nsubch); } static int @@ -977,7 +1000,10 @@ storvsc_sysctl(device_t dev) { struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; + struct sysctl_oid *ch_tree, *chid_tree; struct storvsc_softc *sc; + char name[16]; + int i; sc = device_get_softc(dev); ctx = device_get_sysctl_ctx(dev); @@ -989,6 +1015,28 @@ storvsc_sysctl(device_t dev) &sc->sysctl_data.data_vaddr_cnt, "# of vaddr data block"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_sg_cnt", CTLFLAG_RW, &sc->sysctl_data.data_sg_cnt, "# of sg data block"); + + /* dev.storvsc.UNIT.channel */ + ch_tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "channel", + CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + for (i = 0; i < sc->hs_nchan; i++) { + uint32_t ch_id; + + ch_id = vmbus_chan_id(sc->hs_sel_chan[i]); + snprintf(name, sizeof(name), "%d", ch_id); + /* dev.storvsc.UNIT.channel.CHID */ + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + /* dev.storvsc.UNIT.channel.CHID.send_req */ + SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "send_req", CTLFLAG_RD, &sc->sysctl_data.chan_send_cnt[i], + "# of request sending from this channel"); + } } /** @@ -1019,6 +1067,7 @@ storvsc_attach(device_t dev) root_mount_token = root_mount_hold("storvsc"); sc = device_get_softc(dev); + sc->hs_nchan = 1; sc->hs_chan = vmbus_get_channel(dev); stor_type = storvsc_get_storage_type(dev); @@ -1030,7 +1079,14 @@ storvsc_attach(device_t dev) /* fill in driver specific properties */ sc->hs_drv_props = &g_drv_props_table[stor_type]; - + sc->hs_drv_props->drv_ringbuffer_size = hv_storvsc_ringbuffer_size; + sc->hs_drv_props->drv_max_ios_per_target = + MIN(STORVSC_MAX_IO, hv_storvsc_max_io); + if (bootverbose) { + printf("storvsc ringbuffer size: %d, max_io: %d\n", + sc->hs_drv_props->drv_ringbuffer_size, + sc->hs_drv_props->drv_max_ios_per_target); + } /* fill in device specific properties */ sc->hs_unit = device_get_unit(dev); sc->hs_dev = dev; @@ -1052,7 +1108,7 @@ storvsc_attach(device_t dev) * STORVSC_DATA_SEGCNT_MAX segments, each * segment has one page buffer */ - for (i = 0; i < STORVSC_MAX_IO_REQUESTS; i++) { + for (i = 0; i < sc->hs_drv_props->drv_max_ios_per_target; i++) { sgl_node = malloc(sizeof(struct hv_sgl_node), M_DEVBUF, M_WAITOK|M_ZERO); @@ -1083,7 +1139,7 @@ storvsc_attach(device_t dev) } /* Construct cpu to channel mapping */ - storvsc_create_cpu2chan(sc); + storvsc_create_chan_sel(sc); /* * Create the device queue. @@ -1840,19 +1896,37 @@ create_storvsc_request(union ccb *ccb, s csio->cdb_len); } + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.time_out_value = 60; + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_DISABLE_SYNCH_TRANSFER; + } switch (ccb->ccb_h.flags & CAM_DIR_MASK) { case CAM_DIR_OUT: - reqp->vstor_packet.u.vm_srb.data_in = WRITE_TYPE; + reqp->vstor_packet.u.vm_srb.data_in = WRITE_TYPE; + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_DATA_OUT; + } break; case CAM_DIR_IN: reqp->vstor_packet.u.vm_srb.data_in = READ_TYPE; + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_DATA_IN; + } break; case CAM_DIR_NONE: reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE; + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_NO_DATA_TRANSFER; + } break; default: - reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE; - break; + printf("Error: unexpected data direction: 0x%x\n", + ccb->ccb_h.flags & CAM_DIR_MASK); + return (EINVAL); } reqp->sense_data = &csio->sense_data; Modified: stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h Mon Oct 17 07:13:48 2016 (r307485) +++ stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h Mon Oct 17 07:16:04 2016 (r307486) @@ -253,6 +253,22 @@ struct vstor_packet { #define SRB_STATUS_AUTOSENSE_VALID 0x80 #define SRB_STATUS_INVALID_LUN 0X20 +/* + * SRB Flag Bits + */ + +#define SRB_FLAGS_QUEUE_ACTION_ENABLE 0x00000002 +#define SRB_FLAGS_DISABLE_DISCONNECT 0x00000004 +#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER 0x00000008 +#define SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x00000010 +#define SRB_FLAGS_DISABLE_AUTOSENSE 0x00000020 +#define SRB_FLAGS_DATA_IN 0x00000040 +#define SRB_FLAGS_DATA_OUT 0x00000080 +#define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000 +#define SRB_FLAGS_UNSPECIFIED_DIRECTION (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT) +#define SRB_FLAGS_NO_QUEUE_FREEZE 0x00000100 +#define SRB_FLAGS_ADAPTER_CACHE_ENABLE 0x00000200 +#define SRB_FLAGS_FREE_SENSE_BUFFER 0x00000400 /** * Packet flags */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Oct 17 07:13:48 2016 (r307485) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Oct 17 07:16:04 2016 (r307486) @@ -74,6 +74,7 @@ struct sysctl_oid; static __inline int vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr) { + /* * - 64 bits for the trailing start index (- sizeof(uint64_t)). * - The rindex and windex can't be same (- 1). See @@ -82,6 +83,17 @@ vmbus_txbr_maxpktsz(const struct vmbus_t return (tbr->txbr_dsize - sizeof(uint64_t) - 1); } +static __inline int +vmbus_br_nelem(int br_size, int elem_size) +{ + + /* Strip bufring header */ + br_size -= sizeof(struct vmbus_bufring); + /* Add per-element trailing index */ + elem_size += sizeof(uint64_t); + return (br_size / elem_size); +} + void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, struct vmbus_br *br, const char *name); Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 07:13:48 2016 (r307485) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 07:16:04 2016 (r307486) @@ -1411,3 +1411,16 @@ vmbus_chan_guid_inst(const struct vmbus_ { return &chan->ch_guid_inst; } + +int +vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, int dlen_max) +{ + int elem_size; + + elem_size = __offsetof(struct vmbus_chanpkt_prplist, + cp_range[0].gpa_page[prpcnt_max]); + elem_size += dlen_max; + elem_size = VMBUS_CHANPKT_TOTLEN(elem_size); + + return (vmbus_br_nelem(br_size, elem_size)); +} From owner-svn-src-stable@freebsd.org Mon Oct 17 07:20:03 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 13D18C138E9; Mon, 17 Oct 2016 07:20:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA0D011C4; Mon, 17 Oct 2016 07:20:02 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7K2vq006091; Mon, 17 Oct 2016 07:20:02 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7K1Lm006083; Mon, 17 Oct 2016 07:20:01 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170720.u9H7K1Lm006083@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:20:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307487 - in stable/11/sys: dev/hyperv/netvsc net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:20:03 -0000 Author: sephe Date: Mon Oct 17 07:20:01 2016 New Revision: 307487 URL: https://svnweb.freebsd.org/changeset/base/307487 Log: MFC 304832-304834,304972 304832 hyperv/hn: Use vmbus xact for RNDIS query. And switch MAC address query to use new RNDIS query function. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7639 304833 hyperv/hn: Save the adopted NDIS version for RNDIS to use later. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7640 304834 hyperv/hn: Use vmbus xact for RNDIS set. And use new RNDIS set to configure NDIS offloading parameters. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7641 304972 hyperv/hn: Add definition for NDIS media state. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7652 Added: stable/11/sys/dev/hyperv/netvsc/ndis.h - copied, changed from r304834, head/sys/dev/hyperv/netvsc/ndis.h Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis.h stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:16:04 2016 (r307486) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:20:01 2016 (r307487) @@ -521,9 +521,15 @@ hv_nv_connect_to_vsp(struct hn_softc *sc for (i = protocol_number - 1; i >= 0; i--) { if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { sc->hn_nvs_ver = protocol_list[i]; + sc->hn_ndis_ver = NDIS_VERSION_6_30; + if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) + sc->hn_ndis_ver = NDIS_VERSION_6_1; if (bootverbose) { - device_printf(dev, "NVS version 0x%x\n", - sc->hn_nvs_ver); + if_printf(sc->hn_ifp, "NVS version 0x%x, " + "NDIS version %u.%u\n", + sc->hn_nvs_ver, + NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } break; } @@ -549,11 +555,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc memset(&ndis, 0, sizeof(ndis)); ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; - ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; - else - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; + ndis.nvs_ndis_major = NDIS_VERSION_MAJOR(sc->hn_ndis_ver); + ndis.nvs_ndis_minor = NDIS_VERSION_MINOR(sc->hn_ndis_ver); /* NOTE: No response. */ ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:16:04 2016 (r307486) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:20:01 2016 (r307487) @@ -382,6 +382,7 @@ typedef struct hn_softc { struct hyperv_dma hn_chim_dma; uint32_t hn_rndis_rid; + uint32_t hn_ndis_ver; } hn_softc_t; #define HN_FLAG_RXBUF_CONNECTED 0x0001 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:16:04 2016 (r307486) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:20:01 2016 (r307487) @@ -117,9 +117,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include "hv_net_vsc.h" -#include "hv_rndis.h" -#include "hv_rndis_filter.h" +#include +#include +#include +#include + #include "vmbus_if.h" /* Short for Hyper-V network interface */ @@ -330,6 +332,7 @@ static int hn_rx_stat_ulong_sysctl(SYSCT static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); @@ -427,6 +430,8 @@ netvsc_probe(device_t dev) static int netvsc_attach(device_t dev) { + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; netvsc_device_info device_info; hn_softc_t *sc; int unit = device_get_unit(dev); @@ -581,7 +586,7 @@ netvsc_attach(device_t dev) } #endif - if (device_info.link_state == 0) { + if (device_info.link_state == NDIS_MEDIA_STATE_CONNECTED) { sc->hn_carrier = 1; } @@ -608,9 +613,13 @@ netvsc_attach(device_t dev) hn_tx_chimney_size < sc->hn_chim_szmax) hn_set_chim_size(sc, hn_tx_chimney_size); - SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, - "nvs_version", CTLFLAG_RD, &sc->hn_nvs_ver, 0, "NVS version"); + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, + &sc->hn_nvs_ver, 0, "NVS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_ndis_version_sysctl, "A", "NDIS version"); return (0); failed: @@ -2094,6 +2103,18 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG } static int +hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +static int hn_check_iplen(const struct mbuf *m, int hoff) { const struct ip *ip; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:16:04 2016 (r307486) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:20:01 2016 (r307487) @@ -42,11 +42,8 @@ #define NDIS_VERSION_6_1 0x00060001 #define NDIS_VERSION_6_30 0x0006001e -#define NDIS_VERSION_MAJOR_6 6 -#define NDIS_VERSION_MINOR_1 1 -#define NDIS_VERSION_MINOR_30 30 - -#define NDIS_VERSION (NDIS_VERSION_5_1) +#define NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) +#define NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) /* * Object Identifiers used by NdisRequest Query/Set Information Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:16:04 2016 (r307486) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:20:01 2016 (r307487) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define HV_RF_RECVINFO_VLAN 0x1 #define HV_RF_RECVINFO_CSUM 0x2 @@ -96,6 +97,11 @@ static void hn_rndis_sent_halt(struct hn static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); +static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0); +static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, + size_t dlen); +static int hn_rndis_conf_offload(struct hn_softc *sc); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -695,13 +701,23 @@ cleanup: /* * RNDIS filter query device MAC address */ -static inline int +static int hv_rf_query_device_mac(rndis_device *device) { - uint32_t size = ETHER_ADDR_LEN; + struct hn_softc *sc = device->sc; + size_t hwaddr_len; + int error; - return (hv_rf_query_device(device, - RNDIS_OID_802_3_PERMANENT_ADDRESS, device->hw_mac_addr, &size)); + hwaddr_len = ETHER_ADDR_LEN; + error = hn_rndis_query(sc, OID_802_3_PERMANENT_ADDRESS, NULL, 0, + device->hw_mac_addr, &hwaddr_len); + if (error) + return error; + if (hwaddr_len != ETHER_ADDR_LEN) { + if_printf(sc->hn_ifp, "invalid hwaddr len %zu\n", hwaddr_len); + return EINVAL; + } + return 0; } /* @@ -892,12 +908,12 @@ exit: static const void * hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, - size_t reqlen, size_t min_complen, uint32_t comp_type) + size_t reqlen, size_t *comp_len0, uint32_t comp_type) { struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; const struct rndis_comp_hdr *comp; bus_addr_t paddr; - size_t comp_len; + size_t comp_len, min_complen = *comp_len0; int gpa_cnt, error; KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); @@ -946,7 +962,14 @@ hn_rndis_xact_execute(struct hn_softc *s * Check this RNDIS complete message. */ if (comp_len < min_complen) { - if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu\n", comp_len); + if (comp_len >= sizeof(*comp)) { + /* rm_status field is valid */ + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu, " + "status 0x%08x\n", comp_len, comp->rm_status); + } else { + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu\n", + comp_len); + } return (NULL); } if (comp->rm_len < min_complen) { @@ -965,9 +988,190 @@ hn_rndis_xact_execute(struct hn_softc *s return (NULL); } /* All pass! */ + *comp_len0 = comp_len; return (comp); } +static int +hn_rndis_query(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0) +{ + struct rndis_query_req *req; + const struct rndis_query_comp *comp; + struct vmbus_xact *xact; + size_t reqlen, odlen = *odlen0, comp_len; + int error, ofs; + uint32_t rid; + + reqlen = sizeof(*req) + idlen; + xact = vmbus_xact_get(sc->hn_xact, reqlen); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS query 0x%08x\n", oid); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_QUERY_MSG; + req->rm_len = reqlen; + req->rm_rid = rid; + req->rm_oid = oid; + /* + * XXX + * This is _not_ RNDIS Spec conforming: + * "This MUST be set to 0 when there is no input data + * associated with the OID." + * + * If this field was set to 0 according to the RNDIS Spec, + * Hyper-V would set non-SUCCESS status in the query + * completion. + */ + req->rm_infobufoffset = RNDIS_QUERY_REQ_INFOBUFOFFSET; + + if (idlen > 0) { + req->rm_infobuflen = idlen; + /* Input data immediately follows RNDIS query. */ + memcpy(req + 1, idata, idlen); + } + + comp_len = sizeof(*comp) + odlen; + comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, + REMOTE_NDIS_QUERY_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS query 0x%08x failed\n", oid); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS query 0x%08x failed: " + "status 0x%08x\n", oid, comp->rm_status); + error = EIO; + goto done; + } + if (comp->rm_infobuflen == 0 || comp->rm_infobufoffset == 0) { + /* No output data! */ + if_printf(sc->hn_ifp, "RNDIS query 0x%08x, no data\n", oid); + *odlen0 = 0; + error = 0; + goto done; + } + + /* + * Check output data length and offset. + */ + /* ofs is the offset from the beginning of comp. */ + ofs = RNDIS_QUERY_COMP_INFOBUFABS(comp->rm_infobufoffset); + if (ofs < sizeof(*comp) || ofs + comp->rm_infobuflen > comp_len) { + if_printf(sc->hn_ifp, "RNDIS query invalid comp ib off/len, " + "%u/%u\n", comp->rm_infobufoffset, comp->rm_infobuflen); + error = EINVAL; + goto done; + } + + /* + * Save output data. + */ + if (comp->rm_infobuflen < odlen) + odlen = comp->rm_infobuflen; + memcpy(odata, ((const uint8_t *)comp) + ofs, odlen); + *odlen0 = odlen; + + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} + +static int +hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen) +{ + struct rndis_set_req *req; + const struct rndis_set_comp *comp; + struct vmbus_xact *xact; + size_t reqlen, comp_len; + uint32_t rid; + int error; + + KASSERT(dlen > 0, ("invalid dlen %zu", dlen)); + + reqlen = sizeof(*req) + dlen; + xact = vmbus_xact_get(sc->hn_xact, reqlen); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS set 0x%08x\n", oid); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_SET_MSG; + req->rm_len = reqlen; + req->rm_rid = rid; + req->rm_oid = oid; + req->rm_infobuflen = dlen; + req->rm_infobufoffset = RNDIS_SET_REQ_INFOBUFOFFSET; + /* Data immediately follows RNDIS set. */ + memcpy(req + 1, data, dlen); + + comp_len = sizeof(*comp); + comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, + REMOTE_NDIS_SET_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS set 0x%08x failed\n", oid); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS set 0x%08x failed: " + "status 0x%08x\n", oid, comp->rm_status); + error = EIO; + goto done; + } + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} + +static int +hn_rndis_conf_offload(struct hn_softc *sc) +{ + struct ndis_offload_params params; + size_t paramsz; + int error; + + /* NOTE: 0 means "no change" */ + memset(¶ms, 0, sizeof(params)); + + params.ndis_hdr.ndis_type = NDIS_OBJTYPE_DEFAULT; + if (sc->hn_ndis_ver < NDIS_VERSION_6_30) { + params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_2; + paramsz = NDIS_OFFLOAD_PARAMS_SIZE_6_1; + } else { + params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_3; + paramsz = NDIS_OFFLOAD_PARAMS_SIZE; + } + params.ndis_hdr.ndis_size = paramsz; + + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; + if (sc->hn_ndis_ver >= NDIS_VERSION_6_30) { + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; + } + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; + /* XXX ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON */ + + error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); + if (error) { + if_printf(sc->hn_ifp, "offload config failed: %d\n", error); + } else { + if (bootverbose) + if_printf(sc->hn_ifp, "offload config done\n"); + } + return (error); +} + /* * RNDIS filter init device */ @@ -978,6 +1182,7 @@ hv_rf_init_device(rndis_device *device) struct rndis_init_req *req; const struct rndis_init_comp *comp; struct vmbus_xact *xact; + size_t comp_len; uint32_t rid; int error; @@ -998,8 +1203,9 @@ hv_rf_init_device(rndis_device *device) req->rm_ver_minor = RNDIS_VERSION_MINOR; req->rm_max_xfersz = HN_RNDIS_XFER_SIZE; - comp = hn_rndis_xact_execute(sc, xact, rid, sizeof(*req), - RNDIS_INIT_COMP_SIZE_MIN, REMOTE_NDIS_INITIALIZE_CMPLT); + comp_len = RNDIS_INIT_COMP_SIZE_MIN; + comp = hn_rndis_xact_execute(sc, xact, rid, sizeof(*req), &comp_len, + REMOTE_NDIS_INITIALIZE_CMPLT); if (comp == NULL) { if_printf(sc->hn_ifp, "exec RNDIS init failed\n"); error = EIO; @@ -1131,7 +1337,6 @@ hv_rf_on_device_add(struct hn_softc *sc, { int ret; rndis_device *rndis_dev; - rndis_offload_params offloads; struct rndis_recv_scale_cap rsscaps; uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; @@ -1181,21 +1386,8 @@ hv_rf_on_device_add(struct hn_softc *sc, /* TODO: shut down rndis device and the channel */ } - /* config csum offload and send request to host */ - memset(&offloads, 0, sizeof(offloads)); - offloads.ipv4_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.tcp_ipv4_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.udp_ipv4_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.tcp_ipv6_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.udp_ipv6_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.lso_v2_ipv4 = RNDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED; - - ret = hv_rf_send_offload_request(sc, &offloads); - if (ret != 0) { - /* TODO: shut down rndis device and the channel */ - device_printf(dev, - "hv_rf_send_offload_request failed, ret=%d\n", ret); - } + /* Configure NDIS offload settings */ + hn_rndis_conf_offload(sc); memcpy(dev_info->mac_addr, rndis_dev->hw_mac_addr, ETHER_ADDR_LEN); Copied and modified: stable/11/sys/dev/hyperv/netvsc/ndis.h (from r304834, head/sys/dev/hyperv/netvsc/ndis.h) ============================================================================== --- head/sys/dev/hyperv/netvsc/ndis.h Fri Aug 26 05:18:27 2016 (r304834, copy source) +++ stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 07:20:01 2016 (r307487) @@ -29,6 +29,9 @@ #ifndef _NET_NDIS_H_ #define _NET_NDIS_H_ +#define NDIS_MEDIA_STATE_CONNECTED 0 +#define NDIS_MEDIA_STATE_DISCONNECTED 1 + #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C #define NDIS_OBJTYPE_DEFAULT 0x80 Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Mon Oct 17 07:16:04 2016 (r307486) +++ stable/11/sys/net/rndis.h Mon Oct 17 07:20:01 2016 (r307487) @@ -172,6 +172,10 @@ struct rndis_query_req { uint32_t rm_devicevchdl; }; +#define RNDIS_QUERY_REQ_INFOBUFOFFSET \ + (sizeof(struct rndis_query_req) - \ + __offsetof(struct rndis_query_req, rm_rid)) + struct rndis_query_comp { uint32_t rm_type; uint32_t rm_len; @@ -181,6 +185,9 @@ struct rndis_query_comp { uint32_t rm_infobufoffset; }; +#define RNDIS_QUERY_COMP_INFOBUFABS(ofs) \ + ((ofs) + __offsetof(struct rndis_query_req, rm_rid)) + /* Send a set object request. */ #define REMOTE_NDIS_SET_MSG 0x00000005 #define REMOTE_NDIS_SET_CMPLT 0x80000005 @@ -195,6 +202,10 @@ struct rndis_set_req { uint32_t rm_devicevchdl; }; +#define RNDIS_SET_REQ_INFOBUFOFFSET \ + (sizeof(struct rndis_set_req) - \ + __offsetof(struct rndis_set_req, rm_rid)) + struct rndis_set_comp { uint32_t rm_type; uint32_t rm_len; From owner-svn-src-stable@freebsd.org Mon Oct 17 07:27:18 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9ACA9C13E2C; Mon, 17 Oct 2016 07:27:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 625FA1867; Mon, 17 Oct 2016 07:27:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7RHS6009869; Mon, 17 Oct 2016 07:27:17 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7RHYl009863; Mon, 17 Oct 2016 07:27:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170727.u9H7RHYl009863@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:27:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307490 - in stable/11/sys: dev/hyperv/netvsc dev/usb/net net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:27:18 -0000 Author: sephe Date: Mon Oct 17 07:27:16 2016 New Revision: 307490 URL: https://svnweb.freebsd.org/changeset/base/307490 Log: MFC 304973,304975,304976,304979,305044-305048 304973 hyperv/hn: Switch to new RNDIS query for link status extraction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7654 304975 hyperv/hn: Switch to new RNDIS query for RSS capabilities extraction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7656 304976 hyperv/hn: Fix # of channels setting, if RSS is not available. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7657 304979 hyperv/hn: Switch to new RNDIS set for RSS parameters. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7658 305044 hyperv/hn: Move OIDs to net/rndis.h; they are standard NDIS OIDs. Actually all OIDs defined in net/rndis.h are standard NDIS OIDs. While I'm here, use the verbose macro name as in NDIS spec. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7679 305045 hyperv/hn: Indentation and field comment fixup for ndis.h. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7680 305046 net/rndis: Packet types are defined by NDIS; not RNDIS specific. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7681 305047 hyperv/hn: Switch to new RNDIS set for RX filters. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7683 305048 hyperv/hn: Remove unused function Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7684 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_rndis.h stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/ndis.h stable/11/sys/dev/usb/net/if_urndis.c stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:25:46 2016 (r307489) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:27:16 2016 (r307490) @@ -62,6 +62,8 @@ #include #include +#include + #define HN_USE_TXDESC_BUFRING MALLOC_DECLARE(M_NETVSC); @@ -383,6 +385,8 @@ typedef struct hn_softc { uint32_t hn_rndis_rid; uint32_t hn_ndis_ver; + + struct ndis_rssprm_toeplitz hn_rss; } hn_softc_t; #define HN_FLAG_RXBUF_CONNECTED 0x0001 Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:25:46 2016 (r307489) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:27:16 2016 (r307490) @@ -536,20 +536,6 @@ struct rndis_hash_info { uint32_t hash_info; } __packed; -#define NDIS_HASH_FUNCTION_MASK 0x000000FF /* see hash function */ -#define NDIS_HASH_TYPE_MASK 0x00FFFF00 /* see hash type */ - -/* hash function */ -#define NDIS_HASH_FUNCTION_TOEPLITZ 0x00000001 - -/* hash type */ -#define NDIS_HASH_IPV4 0x00000100 -#define NDIS_HASH_TCP_IPV4 0x00000200 -#define NDIS_HASH_IPV6 0x00000400 -#define NDIS_HASH_IPV6_EX 0x00000800 -#define NDIS_HASH_TCP_IPV6 0x00001000 -#define NDIS_HASH_TCP_IPV6_EX 0x00002000 - typedef struct rndis_tcp_tso_info_ { union { struct { @@ -903,19 +889,6 @@ typedef struct rndismp_rx_bufs_info_ { #define RNDIS_HEADER_SIZE (sizeof(rndis_msg) - sizeof(rndis_msg_container)) -#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 -#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 -#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 -#define NDIS_PACKET_TYPE_BROADCAST 0x00000008 -#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 -#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 -#define NDIS_PACKET_TYPE_SMT 0x00000040 -#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 -#define NDIS_PACKET_TYPE_GROUP 0x00000100 -#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200 -#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400 -#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800 - /* * Externs */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:25:46 2016 (r307489) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:27:16 2016 (r307490) @@ -79,17 +79,9 @@ static void hv_rf_receive_indicate_statu const rndis_msg *response); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); -static int hv_rf_query_device(rndis_device *device, uint32_t oid, - void *result, uint32_t *result_size); static inline int hv_rf_query_device_mac(rndis_device *device); static inline int hv_rf_query_device_link_status(rndis_device *device); -static int hv_rf_set_packet_filter(rndis_device *device, uint32_t new_filter); static int hv_rf_init_device(rndis_device *device); -static int hv_rf_open_device(rndis_device *device); -static int hv_rf_close_device(rndis_device *device); -int -hv_rf_send_offload_request(struct hn_softc *sc, - rndis_offload_params *offloads); static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, @@ -102,6 +94,8 @@ static int hn_rndis_query(struct hn_soft static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); static int hn_rndis_conf_offload(struct hn_softc *sc); +static int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt); +static int hn_rndis_conf_rss(struct hn_softc *sc, int nchan); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -355,78 +349,6 @@ hv_rf_receive_response(rndis_device *dev } } -int -hv_rf_send_offload_request(struct hn_softc *sc, - rndis_offload_params *offloads) -{ - rndis_request *request; - rndis_set_request *set; - rndis_offload_params *offload_req; - rndis_set_complete *set_complete; - rndis_device *rndis_dev = sc->rndis_dev; - device_t dev = sc->hn_dev; - uint32_t extlen = sizeof(rndis_offload_params); - int ret; - - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) { - extlen = VERSION_4_OFFLOAD_SIZE; - /* On NVSP_PROTOCOL_VERSION_4 and below, we do not support - * UDP checksum offload. - */ - offloads->udp_ipv4_csum = 0; - offloads->udp_ipv6_csum = 0; - } - - request = hv_rndis_request(rndis_dev, REMOTE_NDIS_SET_MSG, - RNDIS_MESSAGE_SIZE(rndis_set_request) + extlen); - if (!request) - return (ENOMEM); - - set = &request->request_msg.msg.set_request; - set->oid = RNDIS_OID_TCP_OFFLOAD_PARAMETERS; - set->info_buffer_length = extlen; - set->info_buffer_offset = sizeof(rndis_set_request); - set->device_vc_handle = 0; - - offload_req = (rndis_offload_params *)((unsigned long)set + - set->info_buffer_offset); - *offload_req = *offloads; - offload_req->header.type = RNDIS_OBJECT_TYPE_DEFAULT; - offload_req->header.revision = RNDIS_OFFLOAD_PARAMETERS_REVISION_3; - offload_req->header.size = extlen; - - ret = hv_rf_send_request(rndis_dev, request, REMOTE_NDIS_SET_MSG); - if (ret != 0) { - device_printf(dev, "hv send offload request failed, ret=%d!\n", - ret); - goto cleanup; - } - - ret = sema_timedwait(&request->wait_sema, 5 * hz); - if (ret != 0) { - device_printf(dev, "hv send offload request timeout\n"); - goto cleanup; - } - - set_complete = &request->response_msg.msg.set_complete; - if (set_complete->status == RNDIS_STATUS_SUCCESS) { - device_printf(dev, "hv send offload request succeeded\n"); - ret = 0; - } else { - if (set_complete->status == RNDIS_STATUS_NOT_SUPPORTED) { - device_printf(dev, "HV Not support offload\n"); - ret = 0; - } else { - ret = set_complete->status; - } - } - -cleanup: - hv_put_rndis_request(rndis_dev, request); - - return (ret); -} - /* * RNDIS filter receive indicate status */ @@ -628,77 +550,6 @@ hv_rf_on_receive(struct hn_softc *sc, st } /* - * RNDIS filter query device - */ -static int -hv_rf_query_device(rndis_device *device, uint32_t oid, void *result, - uint32_t *result_size) -{ - rndis_request *request; - uint32_t in_result_size = *result_size; - rndis_query_request *query; - rndis_query_complete *query_complete; - int ret = 0; - - *result_size = 0; - request = hv_rndis_request(device, REMOTE_NDIS_QUERY_MSG, - RNDIS_MESSAGE_SIZE(rndis_query_request)); - if (request == NULL) { - ret = -1; - goto cleanup; - } - - /* Set up the rndis query */ - query = &request->request_msg.msg.query_request; - query->oid = oid; - query->info_buffer_offset = sizeof(rndis_query_request); - query->info_buffer_length = 0; - query->device_vc_handle = 0; - - if (oid == RNDIS_OID_GEN_RSS_CAPABILITIES) { - struct rndis_recv_scale_cap *cap; - - request->request_msg.msg_len += - sizeof(struct rndis_recv_scale_cap); - query->info_buffer_length = sizeof(struct rndis_recv_scale_cap); - cap = (struct rndis_recv_scale_cap *)((unsigned long)query + - query->info_buffer_offset); - cap->hdr.type = RNDIS_OBJECT_TYPE_RSS_CAPABILITIES; - cap->hdr.rev = RNDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2; - cap->hdr.size = sizeof(struct rndis_recv_scale_cap); - } - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_QUERY_MSG); - if (ret != 0) { - /* Fixme: printf added */ - printf("RNDISFILTER request failed to Send!\n"); - goto cleanup; - } - - sema_wait(&request->wait_sema); - - /* Copy the response back */ - query_complete = &request->response_msg.msg.query_complete; - - if (query_complete->info_buffer_length > in_result_size) { - ret = EINVAL; - goto cleanup; - } - - memcpy(result, (void *)((unsigned long)query_complete + - query_complete->info_buffer_offset), - query_complete->info_buffer_length); - - *result_size = query_complete->info_buffer_length; - -cleanup: - if (request != NULL) - hv_put_rndis_request(device, request); - - return (ret); -} - -/* * RNDIS filter query device MAC address */ static int @@ -712,12 +563,12 @@ hv_rf_query_device_mac(rndis_device *dev error = hn_rndis_query(sc, OID_802_3_PERMANENT_ADDRESS, NULL, 0, device->hw_mac_addr, &hwaddr_len); if (error) - return error; + return (error); if (hwaddr_len != ETHER_ADDR_LEN) { if_printf(sc->hn_ifp, "invalid hwaddr len %zu\n", hwaddr_len); - return EINVAL; + return (EINVAL); } - return 0; + return (0); } /* @@ -726,13 +577,23 @@ hv_rf_query_device_mac(rndis_device *dev static inline int hv_rf_query_device_link_status(rndis_device *device) { - uint32_t size = sizeof(uint32_t); + struct hn_softc *sc = device->sc; + size_t size; + int error; - return (hv_rf_query_device(device, - RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, &device->link_status, &size)); + size = sizeof(uint32_t); + error = hn_rndis_query(sc, OID_GEN_MEDIA_CONNECT_STATUS, NULL, 0, + &device->link_status, &size); + if (error) + return (error); + if (size != sizeof(uint32_t)) { + if_printf(sc->hn_ifp, "invalid link status len %zu\n", size); + return (EINVAL); + } + return (0); } -static uint8_t netvsc_hash_key[HASH_KEYLEN] = { +static uint8_t netvsc_hash_key[NDIS_HASH_KEYSIZE_TOEPLITZ] = { 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, @@ -740,172 +601,6 @@ static uint8_t netvsc_hash_key[HASH_KEYL 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa }; -/* - * RNDIS set vRSS parameters - */ -static int -hv_rf_set_rss_param(rndis_device *device, int num_queue) -{ - rndis_request *request; - rndis_set_request *set; - rndis_set_complete *set_complete; - rndis_recv_scale_param *rssp; - uint32_t extlen = sizeof(rndis_recv_scale_param) + - (4 * ITAB_NUM) + HASH_KEYLEN; - uint32_t *itab, status; - uint8_t *keyp; - int i, ret; - - - request = hv_rndis_request(device, REMOTE_NDIS_SET_MSG, - RNDIS_MESSAGE_SIZE(rndis_set_request) + extlen); - if (request == NULL) { - if (bootverbose) - printf("Netvsc: No memory to set vRSS parameters.\n"); - ret = -1; - goto cleanup; - } - - set = &request->request_msg.msg.set_request; - set->oid = RNDIS_OID_GEN_RSS_PARAMETERS; - set->info_buffer_length = extlen; - set->info_buffer_offset = sizeof(rndis_set_request); - set->device_vc_handle = 0; - - /* Fill out the rssp parameter structure */ - rssp = (rndis_recv_scale_param *)(set + 1); - rssp->hdr.type = RNDIS_OBJECT_TYPE_RSS_PARAMETERS; - rssp->hdr.rev = RNDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2; - rssp->hdr.size = sizeof(rndis_recv_scale_param); - rssp->flag = 0; - rssp->hashinfo = RNDIS_HASH_FUNC_TOEPLITZ | RNDIS_HASH_IPV4 | - RNDIS_HASH_TCP_IPV4 | RNDIS_HASH_IPV6 | RNDIS_HASH_TCP_IPV6; - rssp->indirect_tabsize = 4 * ITAB_NUM; - rssp->indirect_taboffset = sizeof(rndis_recv_scale_param); - rssp->hashkey_size = HASH_KEYLEN; - rssp->hashkey_offset = rssp->indirect_taboffset + - rssp->indirect_tabsize; - - /* Set indirection table entries */ - itab = (uint32_t *)(rssp + 1); - for (i = 0; i < ITAB_NUM; i++) - itab[i] = i % num_queue; - - /* Set hash key values */ - keyp = (uint8_t *)((unsigned long)rssp + rssp->hashkey_offset); - for (i = 0; i < HASH_KEYLEN; i++) - keyp[i] = netvsc_hash_key[i]; - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_SET_MSG); - if (ret != 0) { - goto cleanup; - } - - /* - * Wait for the response from the host. Another thread will signal - * us when the response has arrived. In the failure case, - * sema_timedwait() returns a non-zero status after waiting 5 seconds. - */ - ret = sema_timedwait(&request->wait_sema, 5 * hz); - if (ret == 0) { - /* Response received, check status */ - set_complete = &request->response_msg.msg.set_complete; - status = set_complete->status; - if (status != RNDIS_STATUS_SUCCESS) { - /* Bad response status, return error */ - if (bootverbose) - printf("Netvsc: Failed to set vRSS " - "parameters.\n"); - ret = -2; - } else { - if (bootverbose) - printf("Netvsc: Successfully set vRSS " - "parameters.\n"); - } - } else { - /* - * We cannot deallocate the request since we may still - * receive a send completion for it. - */ - printf("Netvsc: vRSS set timeout, id = %u, ret = %d\n", - request->request_msg.msg.init_request.request_id, ret); - goto exit; - } - -cleanup: - if (request != NULL) { - hv_put_rndis_request(device, request); - } -exit: - return (ret); -} - -/* - * RNDIS filter set packet filter - * Sends an rndis request with the new filter, then waits for a response - * from the host. - * Returns zero on success, non-zero on failure. - */ -static int -hv_rf_set_packet_filter(rndis_device *device, uint32_t new_filter) -{ - rndis_request *request; - rndis_set_request *set; - rndis_set_complete *set_complete; - uint32_t status; - int ret; - - request = hv_rndis_request(device, REMOTE_NDIS_SET_MSG, - RNDIS_MESSAGE_SIZE(rndis_set_request) + sizeof(uint32_t)); - if (request == NULL) { - ret = -1; - goto cleanup; - } - - /* Set up the rndis set */ - set = &request->request_msg.msg.set_request; - set->oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER; - set->info_buffer_length = sizeof(uint32_t); - set->info_buffer_offset = sizeof(rndis_set_request); - - memcpy((void *)((unsigned long)set + sizeof(rndis_set_request)), - &new_filter, sizeof(uint32_t)); - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_SET_MSG); - if (ret != 0) { - goto cleanup; - } - - /* - * Wait for the response from the host. Another thread will signal - * us when the response has arrived. In the failure case, - * sema_timedwait() returns a non-zero status after waiting 5 seconds. - */ - ret = sema_timedwait(&request->wait_sema, 5 * hz); - if (ret == 0) { - /* Response received, check status */ - set_complete = &request->response_msg.msg.set_complete; - status = set_complete->status; - if (status != RNDIS_STATUS_SUCCESS) { - /* Bad response status, return error */ - ret = -2; - } - } else { - /* - * We cannot deallocate the request since we may still - * receive a send completion for it. - */ - goto exit; - } - -cleanup: - if (request != NULL) { - hv_put_rndis_request(device, request); - } -exit: - return (ret); -} - static const void * hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, size_t reqlen, size_t *comp_len0, uint32_t comp_type) @@ -1083,6 +778,51 @@ done: } static int +hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt) +{ + struct ndis_rss_caps in, caps; + size_t caps_len; + int error; + + /* + * Only NDIS 6.30+ is supported. + */ + KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); + *rxr_cnt = 0; + + memset(&in, 0, sizeof(in)); + in.ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_CAPS; + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + + caps_len = NDIS_RSS_CAPS_SIZE; + error = hn_rndis_query(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, + &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len); + if (error) + return (error); + if (caps_len < NDIS_RSS_CAPS_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS RSS caps len %zu", + caps_len); + return (EINVAL); + } + + if (caps.ndis_nrxr == 0) { + if_printf(sc->hn_ifp, "0 RX rings!?\n"); + return (EINVAL); + } + *rxr_cnt = caps.ndis_nrxr; + + if (caps_len == NDIS_RSS_CAPS_SIZE) { + if (bootverbose) { + if_printf(sc->hn_ifp, "RSS indirect table size %u\n", + caps.ndis_nind); + } + } + return (0); +} + +static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen) { struct rndis_set_req *req; @@ -1172,6 +912,72 @@ hn_rndis_conf_offload(struct hn_softc *s return (error); } +static int +hn_rndis_conf_rss(struct hn_softc *sc, int nchan) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + struct ndis_rss_params *prm = &rss->rss_params; + int i, error; + + /* + * Only NDIS 6.30+ is supported. + */ + KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); + + memset(rss, 0, sizeof(*rss)); + prm->ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_PARAMS; + prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; + prm->ndis_hdr.ndis_size = sizeof(*rss); + prm->ndis_hash = NDIS_HASH_FUNCTION_TOEPLITZ | + NDIS_HASH_IPV4 | NDIS_HASH_TCP_IPV4 | + NDIS_HASH_IPV6 | NDIS_HASH_TCP_IPV6; + /* TODO: Take ndis_rss_caps.ndis_nind into account */ + prm->ndis_indsize = sizeof(rss->rss_ind); + prm->ndis_indoffset = + __offsetof(struct ndis_rssprm_toeplitz, rss_ind[0]); + prm->ndis_keysize = sizeof(rss->rss_key); + prm->ndis_keyoffset = + __offsetof(struct ndis_rssprm_toeplitz, rss_key[0]); + + /* Setup RSS key */ + memcpy(rss->rss_key, netvsc_hash_key, sizeof(rss->rss_key)); + + /* Setup RSS indirect table */ + /* TODO: Take ndis_rss_caps.ndis_nind into account */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) + rss->rss_ind[i] = i % nchan; + + error = hn_rndis_set(sc, OID_GEN_RECEIVE_SCALE_PARAMETERS, + rss, sizeof(*rss)); + if (error) { + if_printf(sc->hn_ifp, "RSS config failed: %d\n", error); + } else { + if (bootverbose) + if_printf(sc->hn_ifp, "RSS config done\n"); + } + return (error); +} + +static int +hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter) +{ + int error; + + error = hn_rndis_set(sc, OID_GEN_CURRENT_PACKET_FILTER, + &filter, sizeof(filter)); + if (error) { + if_printf(sc->hn_ifp, "set RX filter 0x%08x failed: %d\n", + filter, error); + } else { + if (bootverbose) { + if_printf(sc->hn_ifp, "set RX filter 0x%08x done\n", + filter); + } + } + return (error); +} + /* * RNDIS filter init device */ @@ -1280,55 +1086,6 @@ hv_rf_halt_device(rndis_device *device) } /* - * RNDIS filter open device - */ -static int -hv_rf_open_device(rndis_device *device) -{ - int ret; - - if (device->state != RNDIS_DEV_INITIALIZED) { - return (0); - } - - if (hv_promisc_mode != 1) { - ret = hv_rf_set_packet_filter(device, - NDIS_PACKET_TYPE_BROADCAST | - NDIS_PACKET_TYPE_ALL_MULTICAST | - NDIS_PACKET_TYPE_DIRECTED); - } else { - ret = hv_rf_set_packet_filter(device, - NDIS_PACKET_TYPE_PROMISCUOUS); - } - - if (ret == 0) { - device->state = RNDIS_DEV_DATAINITIALIZED; - } - - return (ret); -} - -/* - * RNDIS filter close device - */ -static int -hv_rf_close_device(rndis_device *device) -{ - int ret; - - if (device->state != RNDIS_DEV_DATAINITIALIZED) { - return (0); - } - - ret = hv_rf_set_packet_filter(device, 0); - if (ret == 0) { - device->state = RNDIS_DEV_INITIALIZED; - } - - return (ret); -} - -/* * RNDIS filter on device add */ int @@ -1337,8 +1094,6 @@ hv_rf_on_device_add(struct hn_softc *sc, { int ret; rndis_device *rndis_dev; - struct rndis_recv_scale_cap rsscaps; - uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = sc->hn_dev; struct hn_nvs_subch_req *req; @@ -1347,6 +1102,7 @@ hv_rf_on_device_add(struct hn_softc *sc, struct vmbus_xact *xact = NULL; uint32_t status, nsubch; int nchan = *nchan0; + int rxr_cnt; rndis_dev = hv_get_rndis_device(); if (rndis_dev == NULL) { @@ -1395,22 +1151,29 @@ hv_rf_on_device_add(struct hn_softc *sc, dev_info->link_state = rndis_dev->link_status; - if (sc->hn_nvs_ver < NVSP_PROTOCOL_VERSION_5 || nchan == 1) + if (sc->hn_ndis_ver < NDIS_VERSION_6_30 || nchan == 1) { + /* + * Either RSS is not supported, or multiple RX/TX rings + * are not requested. + */ + *nchan0 = 1; return (0); + } - memset(&rsscaps, 0, rsscaps_size); - ret = hv_rf_query_device(rndis_dev, - RNDIS_OID_GEN_RSS_CAPABILITIES, - &rsscaps, &rsscaps_size); - if ((ret != 0) || (rsscaps.num_recv_que < 2)) { - device_printf(dev, "hv_rf_query_device failed or " - "rsscaps.num_recv_que < 2 \n"); - goto out; + /* + * Get RSS capabilities, e.g. # of RX rings, and # of indirect + * table entries. + */ + ret = hn_rndis_get_rsscaps(sc, &rxr_cnt); + if (ret) { + /* No RSS; this is benign. */ + *nchan0 = 1; + return (0); } - device_printf(dev, "channel, offered %u, requested %d\n", - rsscaps.num_recv_que, nchan); - if (nchan > rsscaps.num_recv_que) - nchan = rsscaps.num_recv_que; + if (nchan > rxr_cnt) + nchan = rxr_cnt; + if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", + rxr_cnt, nchan); if (nchan == 1) { device_printf(dev, "only 1 channel is supported, no vRSS\n"); @@ -1467,8 +1230,11 @@ hv_rf_on_device_add(struct hn_softc *sc, } nchan = nsubch + 1; - ret = hv_rf_set_rss_param(rndis_dev, nchan); - *nchan0 = nchan; + ret = hn_rndis_conf_rss(sc, nchan); + if (ret != 0) + *nchan0 = 1; + else + *nchan0 = nchan; out: if (xact != NULL) vmbus_xact_put(xact); @@ -1502,8 +1268,17 @@ hv_rf_on_device_remove(struct hn_softc * int hv_rf_on_open(struct hn_softc *sc) { + uint32_t filter; - return (hv_rf_open_device(sc->rndis_dev)); + /* XXX */ + if (hv_promisc_mode != 1) { + filter = NDIS_PACKET_TYPE_BROADCAST | + NDIS_PACKET_TYPE_ALL_MULTICAST | + NDIS_PACKET_TYPE_DIRECTED; + } else { + filter = NDIS_PACKET_TYPE_PROMISCUOUS; + } + return (hn_rndis_set_rxfilter(sc, filter)); } /* @@ -1513,7 +1288,7 @@ int hv_rf_on_close(struct hn_softc *sc) { - return (hv_rf_close_device(sc->rndis_dev)); + return (hn_rndis_set_rxfilter(sc, 0)); } static void Modified: stable/11/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 07:25:46 2016 (r307489) +++ stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 07:27:16 2016 (r307490) @@ -29,93 +29,178 @@ #ifndef _NET_NDIS_H_ #define _NET_NDIS_H_ -#define NDIS_MEDIA_STATE_CONNECTED 0 -#define NDIS_MEDIA_STATE_DISCONNECTED 1 +#define NDIS_MEDIA_STATE_CONNECTED 0 +#define NDIS_MEDIA_STATE_DISCONNECTED 1 -#define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C +#define NDIS_OFFLOAD_SET_NOCHG 0 +#define NDIS_OFFLOAD_SET_ON 1 +#define NDIS_OFFLOAD_SET_OFF 2 -#define NDIS_OBJTYPE_DEFAULT 0x80 +/* a.k.a GRE MAC */ +#define NDIS_ENCAP_TYPE_NVGRE 0x00000001 -/* common_set */ -#define NDIS_OFFLOAD_SET_NOCHG 0 -#define NDIS_OFFLOAD_SET_ON 1 -#define NDIS_OFFLOAD_SET_OFF 2 +#define NDIS_HASH_FUNCTION_MASK 0x000000FF /* see hash function */ +#define NDIS_HASH_TYPE_MASK 0x00FFFF00 /* see hash type */ -/* a.k.a GRE MAC */ -#define NDIS_ENCAP_TYPE_NVGRE 0x00000001 +/* hash function */ +#define NDIS_HASH_FUNCTION_TOEPLITZ 0x00000001 + +/* hash type */ +#define NDIS_HASH_IPV4 0x00000100 +#define NDIS_HASH_TCP_IPV4 0x00000200 +#define NDIS_HASH_IPV6 0x00000400 +#define NDIS_HASH_IPV6_EX 0x00000800 +#define NDIS_HASH_TCP_IPV6 0x00001000 +#define NDIS_HASH_TCP_IPV6_EX 0x00002000 + +#define NDIS_HASH_KEYSIZE_TOEPLITZ 40 +#define NDIS_HASH_INDCNT 128 + +#define NDIS_OBJTYPE_DEFAULT 0x80 +#define NDIS_OBJTYPE_RSS_CAPS 0x88 +#define NDIS_OBJTYPE_RSS_PARAMS 0x89 struct ndis_object_hdr { - uint8_t ndis_type; /* NDIS_OBJTYPE_ */ - uint8_t ndis_rev; /* type specific */ - uint16_t ndis_size; /* incl. this hdr */ + uint8_t ndis_type; /* NDIS_OBJTYPE_ */ + uint8_t ndis_rev; /* type specific */ + uint16_t ndis_size; /* incl. this hdr */ }; -/* OID_TCP_OFFLOAD_PARAMETERS */ +/* + * OID_TCP_OFFLOAD_PARAMETERS + * ndis_type: NDIS_OBJTYPE_DEFAULT + */ struct ndis_offload_params { struct ndis_object_hdr ndis_hdr; - uint8_t ndis_ip4csum; /* param_set */ - uint8_t ndis_tcp4csum; /* param_set */ - uint8_t ndis_udp4csum; /* param_set */ - uint8_t ndis_tcp6csum; /* param_set */ - uint8_t ndis_udp6csum; /* param_set */ - uint8_t ndis_lsov1; /* lsov1_set */ - uint8_t ndis_ipsecv1; /* ipsecv1_set */ - uint8_t ndis_lsov2_ip4; /* lsov2_set */ - uint8_t ndis_lsov2_ip6; /* lsov2_set */ - uint8_t ndis_tcp4conn; /* PARAM_NOCHG */ - uint8_t ndis_tcp6conn; /* PARAM_NOCHG */ - uint32_t ndis_flags; /* 0 */ + uint8_t ndis_ip4csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_tcp4csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_udp4csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_tcp6csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_udp6csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_lsov1; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_ipsecv1; /* NDIS_OFFLOAD_IPSECV1_ */ + uint8_t ndis_lsov2_ip4; /* NDIS_OFFLOAD_LSOV2_ */ + uint8_t ndis_lsov2_ip6; /* NDIS_OFFLOAD_LSOV2_ */ + uint8_t ndis_tcp4conn; /* 0 */ + uint8_t ndis_tcp6conn; /* 0 */ + uint32_t ndis_flags; /* 0 */ /* NDIS >= 6.1 */ - uint8_t ndis_ipsecv2; /* ipsecv2_set */ - uint8_t ndis_ipsecv2_ip4; /* ipsecv2_set */ + uint8_t ndis_ipsecv2; /* NDIS_OFFLOAD_IPSECV2_ */ + uint8_t ndis_ipsecv2_ip4;/* NDIS_OFFLOAD_IPSECV2_ */ /* NDIS >= 6.30 */ - uint8_t ndis_rsc_ip4; /* rsc_set */ - uint8_t ndis_rsc_ip6; /* rsc_set */ - uint8_t ndis_encap; /* common_set */ - uint8_t ndis_encap_types; /* NDIS_ENCAP_TYPE_ */ + uint8_t ndis_rsc_ip4; /* NDIS_OFFLOAD_RSC_ */ + uint8_t ndis_rsc_ip6; /* NDIS_OFFLOAD_RSC_ */ + uint8_t ndis_encap; /* NDIS_OFFLOAD_SET_ */ + uint8_t ndis_encap_types;/* NDIS_ENCAP_TYPE_ */ }; -#define NDIS_OFFLOAD_PARAMS_SIZE sizeof(struct ndis_offload_params) -#define NDIS_OFFLOAD_PARAMS_SIZE_6_1 \ +#define NDIS_OFFLOAD_PARAMS_SIZE sizeof(struct ndis_offload_params) +#define NDIS_OFFLOAD_PARAMS_SIZE_6_1 \ __offsetof(struct ndis_offload_params, ndis_rsc_ip4) -#define NDIS_OFFLOAD_PARAMS_REV_2 2 /* NDIS 6.1 */ -#define NDIS_OFFLOAD_PARAMS_REV_3 3 /* NDIS 6.30 */ +#define NDIS_OFFLOAD_PARAMS_REV_2 2 /* NDIS 6.1 */ +#define NDIS_OFFLOAD_PARAMS_REV_3 3 /* NDIS 6.30 */ -/* param_set */ -#define NDIS_OFFLOAD_PARAM_NOCHG 0 /* common to all sets */ -#define NDIS_OFFLOAD_PARAM_OFF 1 -#define NDIS_OFFLOAD_PARAM_TX 2 -#define NDIS_OFFLOAD_PARAM_RX 3 -#define NDIS_OFFLOAD_PARAM_TXRX 4 +#define NDIS_OFFLOAD_PARAM_NOCHG 0 /* common */ +#define NDIS_OFFLOAD_PARAM_OFF 1 +#define NDIS_OFFLOAD_PARAM_TX 2 +#define NDIS_OFFLOAD_PARAM_RX 3 +#define NDIS_OFFLOAD_PARAM_TXRX 4 -/* lsov1_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_LSOV1_OFF 1 -#define NDIS_OFFLOAD_LSOV1_ON 2 +#define NDIS_OFFLOAD_LSOV1_OFF 1 +#define NDIS_OFFLOAD_LSOV1_ON 2 -/* ipsecv1_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_IPSECV1_OFF 1 -#define NDIS_OFFLOAD_IPSECV1_AH 2 -#define NDIS_OFFLOAD_IPSECV1_ESP 3 -#define NDIS_OFFLOAD_IPSECV1_AH_ESP 4 +#define NDIS_OFFLOAD_IPSECV1_OFF 1 +#define NDIS_OFFLOAD_IPSECV1_AH 2 +#define NDIS_OFFLOAD_IPSECV1_ESP 3 +#define NDIS_OFFLOAD_IPSECV1_AH_ESP 4 -/* lsov2_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_LSOV2_OFF 1 -#define NDIS_OFFLOAD_LSOV2_ON 2 +#define NDIS_OFFLOAD_LSOV2_OFF 1 +#define NDIS_OFFLOAD_LSOV2_ON 2 -/* ipsecv2_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_IPSECV2_OFF 1 -#define NDIS_OFFLOAD_IPSECV2_AH 2 -#define NDIS_OFFLOAD_IPSECV2_ESP 3 -#define NDIS_OFFLOAD_IPSECV2_AH_ESP 4 +#define NDIS_OFFLOAD_IPSECV2_OFF 1 +#define NDIS_OFFLOAD_IPSECV2_AH 2 +#define NDIS_OFFLOAD_IPSECV2_ESP 3 +#define NDIS_OFFLOAD_IPSECV2_AH_ESP 4 -/* rsc_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_RSC_OFF 1 -#define NDIS_OFFLOAD_RSC_ON 2 +#define NDIS_OFFLOAD_RSC_OFF 1 +#define NDIS_OFFLOAD_RSC_ON 2 + +/* + * OID_GEN_RECEIVE_SCALE_CAPABILITIES + * ndis_type: NDIS_OBJTYPE_RSS_CAPS + */ +struct ndis_rss_caps { + struct ndis_object_hdr ndis_hdr; + uint32_t ndis_flags; /* NDIS_RSS_CAP_ */ + uint32_t ndis_nmsi; /* # of MSIs */ + uint32_t ndis_nrxr; /* # of RX rings */ + /* NDIS >= 6.30 */ + uint16_t ndis_nind; /* # of indtbl ent. */ + uint16_t ndis_pad; +}; + +#define NDIS_RSS_CAPS_SIZE \ + __offsetof(struct ndis_rss_caps, ndis_pad) +#define NDIS_RSS_CAPS_SIZE_6_0 \ + __offsetof(struct ndis_rss_caps, ndis_nind) + +#define NDIS_RSS_CAPS_REV_1 1 /* NDIS 6.{0,1,20} */ +#define NDIS_RSS_CAPS_REV_2 2 /* NDIS 6.30 */ + +#define NDIS_RSS_CAP_MSI 0x01000000 +#define NDIS_RSS_CAP_CLASSIFY_ISR 0x02000000 +#define NDIS_RSS_CAP_CLASSIFY_DPC 0x04000000 +#define NDIS_RSS_CAP_MSIX 0x08000000 +#define NDIS_RSS_CAP_IPV4 0x00000100 +#define NDIS_RSS_CAP_IPV6 0x00000200 +#define NDIS_RSS_CAP_IPV6_EX 0x00000400 +#define NDIS_RSS_CAP_HASH_TOEPLITZ 0x00000001 + +/* + * OID_GEN_RECEIVE_SCALE_PARAMETERS + * ndis_type: NDIS_OBJTYPE_RSS_PARAMS + */ +struct ndis_rss_params { + struct ndis_object_hdr ndis_hdr; + uint16_t ndis_flags; /* NDIS_RSS_FLAG_ */ + uint16_t ndis_bcpu; /* base cpu 0 */ + uint32_t ndis_hash; /* NDIS_HASH_ */ + uint16_t ndis_indsize; /* indirect table */ + uint32_t ndis_indoffset; + uint16_t ndis_keysize; /* hash key */ + uint32_t ndis_keyoffset; + /* NDIS >= 6.20 */ + uint32_t ndis_cpumaskoffset; + uint32_t ndis_cpumaskcnt; + uint32_t ndis_cpumaskentsz; +}; + +#define NDIS_RSS_PARAMS_SIZE sizeof(struct ndis_rss_params) +#define NDIS_RSS_PARAMS_SIZE_6_0 \ + __offsetof(struct ndis_rss_params, ndis_cpumaskoffset) + +#define NDIS_RSS_PARAMS_REV_1 1 /* NDIS 6.0 */ +#define NDIS_RSS_PARAMS_REV_2 2 /* NDIS 6.20 */ + +#define NDIS_RSS_FLAG_BCPU_UNCHG 0x0001 +#define NDIS_RSS_FLAG_HASH_UNCHG 0x0002 +#define NDIS_RSS_FLAG_IND_UNCHG 0x0004 +#define NDIS_RSS_FLAG_KEY_UNCHG 0x0008 +#define NDIS_RSS_FLAG_DISABLE 0x0010 + +/* non-standard convenient struct */ +struct ndis_rssprm_toeplitz { + struct ndis_rss_params rss_params; + /* Toeplitz hash key */ + uint8_t rss_key[NDIS_HASH_KEYSIZE_TOEPLITZ]; + /* Indirect table */ + uint32_t rss_ind[NDIS_HASH_INDCNT]; +}; #endif /* !_NET_NDIS_H_ */ Modified: stable/11/sys/dev/usb/net/if_urndis.c ============================================================================== --- stable/11/sys/dev/usb/net/if_urndis.c Mon Oct 17 07:25:46 2016 (r307489) +++ stable/11/sys/dev/usb/net/if_urndis.c Mon Oct 17 07:27:16 2016 (r307490) @@ -292,8 +292,8 @@ urndis_attach(device_t dev) memcpy(&sc->sc_ue.ue_eaddr, buf, ETHER_ADDR_LEN); /* Initialize packet filter */ - sc->sc_filter = RNDIS_PACKET_TYPE_BROADCAST | - RNDIS_PACKET_TYPE_ALL_MULTICAST; + sc->sc_filter = NDIS_PACKET_TYPE_BROADCAST | *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 07:29:12 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 237BFC13E9E; Mon, 17 Oct 2016 07:29:12 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1D7B19DE; Mon, 17 Oct 2016 07:29:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7TB48010010; Mon, 17 Oct 2016 07:29:11 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7TAuC010007; Mon, 17 Oct 2016 07:29:10 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170729.u9H7TAuC010007@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:29:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307491 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:29:12 -0000 Author: sephe Date: Mon Oct 17 07:29:10 2016 New Revision: 307491 URL: https://svnweb.freebsd.org/changeset/base/307491 Log: MFC 305049,305050 305049 hyperv/hn: Factor out func to exec RNDIS transaction w/o checking result It will be used by RNDIS HALT and RESET. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7685 305050 hyperv/hn: Switch to new RNDIS transaction execution for halt. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7686 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:27:16 2016 (r307490) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:29:10 2016 (r307491) @@ -74,8 +74,6 @@ static void hv_nv_on_receive(struct hn_s static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct hn_softc *, struct vmbus_channel *chan, const void *, int); -static void hn_nvs_sent_xact(struct hn_send_ctx *, struct hn_softc *sc, - struct vmbus_channel *, const void *, int); struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); @@ -655,7 +653,7 @@ hv_nv_on_device_remove(struct hn_softc * return (0); } -static void +void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data, int dlen) Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:27:16 2016 (r307490) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:29:10 2016 (r307491) @@ -71,8 +71,6 @@ __FBSDID("$FreeBSD$"); /* * Forward declarations */ -static int hv_rf_send_request(rndis_device *device, rndis_request *request, - uint32_t message_type); static void hv_rf_receive_response(rndis_device *device, const rndis_msg *response); static void hv_rf_receive_indicate_status(rndis_device *device, @@ -83,12 +81,6 @@ static inline int hv_rf_query_device_mac static inline int hv_rf_query_device_link_status(rndis_device *device); static int hv_rf_init_device(rndis_device *device); -static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, - struct hn_softc *sc, struct vmbus_channel *chan, - const void *data, int dlen); -static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, - struct hn_softc *sc, struct vmbus_channel *chan, - const void *data, int dlen); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, @@ -197,120 +189,6 @@ hv_put_rndis_device(rndis_device *device } /* - * - */ -static inline rndis_request * -hv_rndis_request(rndis_device *device, uint32_t message_type, - uint32_t message_length) -{ - rndis_request *request; - rndis_msg *rndis_mesg; - rndis_set_request *set; - - request = malloc(sizeof(rndis_request), M_NETVSC, M_WAITOK | M_ZERO); - - sema_init(&request->wait_sema, 0, "rndis sema"); - - rndis_mesg = &request->request_msg; - rndis_mesg->ndis_msg_type = message_type; - rndis_mesg->msg_len = message_length; - - /* - * Set the request id. This field is always after the rndis header - * for request/response packet types so we just use the set_request - * as a template. - */ - set = &rndis_mesg->msg.set_request; - set->request_id = atomic_fetchadd_int(&device->new_request_id, 1) & - HN_RNDIS_RID_COMPAT_MASK; - - /* Add to the request list */ - mtx_lock(&device->req_lock); - STAILQ_INSERT_TAIL(&device->myrequest_list, request, mylist_entry); - mtx_unlock(&device->req_lock); - - return (request); -} - -/* - * - */ -static inline void -hv_put_rndis_request(rndis_device *device, rndis_request *request) -{ - mtx_lock(&device->req_lock); - /* Fixme: Has O(n) performance */ - /* - * XXXKYS: Use Doubly linked lists. - */ - STAILQ_REMOVE(&device->myrequest_list, request, rndis_request_, - mylist_entry); - mtx_unlock(&device->req_lock); - - sema_destroy(&request->wait_sema); - free(request, M_NETVSC); -} - -/* - * - */ -static int -hv_rf_send_request(rndis_device *device, rndis_request *request, - uint32_t message_type) -{ - struct hn_softc *sc = device->sc; - uint32_t send_buf_section_idx, tot_data_buf_len; - struct vmbus_gpa gpa[2]; - int gpa_cnt, send_buf_section_size; - hn_sent_callback_t cb; - - /* Set up the packet to send it */ - tot_data_buf_len = request->request_msg.msg_len; - - gpa_cnt = 1; - gpa[0].gpa_page = hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; - gpa[0].gpa_len = request->request_msg.msg_len; - gpa[0].gpa_ofs = (unsigned long)&request->request_msg & (PAGE_SIZE - 1); - - if (gpa[0].gpa_ofs + gpa[0].gpa_len > PAGE_SIZE) { - gpa_cnt = 2; - gpa[0].gpa_len = PAGE_SIZE - gpa[0].gpa_ofs; - gpa[1].gpa_page = - hv_get_phys_addr((char*)&request->request_msg + - gpa[0].gpa_len) >> PAGE_SHIFT; - gpa[1].gpa_ofs = 0; - gpa[1].gpa_len = request->request_msg.msg_len - gpa[0].gpa_len; - } - - if (message_type != REMOTE_NDIS_HALT_MSG) - cb = hn_rndis_sent_cb; - else - cb = hn_rndis_sent_halt; - - if (tot_data_buf_len < sc->hn_chim_szmax) { - send_buf_section_idx = hn_chim_alloc(sc); - if (send_buf_section_idx != HN_NVS_CHIM_IDX_INVALID) { - uint8_t *dest = sc->hn_chim + - (send_buf_section_idx * sc->hn_chim_szmax); - - memcpy(dest, &request->request_msg, request->request_msg.msg_len); - send_buf_section_size = tot_data_buf_len; - gpa_cnt = 0; - goto sendit; - } - /* Failed to allocate chimney send buffer; move on */ - } - send_buf_section_idx = HN_NVS_CHIM_IDX_INVALID; - send_buf_section_size = 0; - -sendit: - hn_send_ctx_init(&request->send_ctx, cb, request, - send_buf_section_idx, send_buf_section_size); - return hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, - &request->send_ctx, gpa, gpa_cnt); -} - -/* * RNDIS filter receive response */ static void @@ -602,20 +480,15 @@ static uint8_t netvsc_hash_key[NDIS_HASH }; static const void * -hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, - size_t reqlen, size_t *comp_len0, uint32_t comp_type) +hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, + struct hn_send_ctx *sndc, size_t *comp_len) { struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; - const struct rndis_comp_hdr *comp; - bus_addr_t paddr; - size_t comp_len, min_complen = *comp_len0; int gpa_cnt, error; + bus_addr_t paddr; - KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); KASSERT(reqlen <= HN_XACT_REQ_SIZE && reqlen > 0, ("invalid request length %zu", reqlen)); - KASSERT(min_complen >= sizeof(*comp), - ("invalid minimum complete len %zu", min_complen)); /* * Setup the SG list. @@ -644,14 +517,34 @@ hn_rndis_xact_execute(struct hn_softc *s * message. */ vmbus_xact_activate(xact); - error = hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, - &hn_send_ctx_none, gpa, gpa_cnt); + error = hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, sndc, + gpa, gpa_cnt); if (error) { vmbus_xact_deactivate(xact); if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); return (NULL); } - comp = vmbus_xact_wait(xact, &comp_len); + return (vmbus_xact_wait(xact, comp_len)); +} + +static const void * +hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, + size_t reqlen, size_t *comp_len0, uint32_t comp_type) +{ + const struct rndis_comp_hdr *comp; + size_t comp_len, min_complen = *comp_len0; + + KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); + KASSERT(min_complen >= sizeof(*comp), + ("invalid minimum complete len %zu", min_complen)); + + /* + * Execute the xact setup by the caller. + */ + comp = hn_rndis_xact_exec1(sc, xact, reqlen, &hn_send_ctx_none, + &comp_len); + if (comp == NULL) + return (NULL); /* * Check this RNDIS complete message. @@ -1037,51 +930,34 @@ done: return (error); } -#define HALT_COMPLETION_WAIT_COUNT 25 - /* * RNDIS filter halt device */ static int -hv_rf_halt_device(rndis_device *device) +hv_rf_halt_device(struct hn_softc *sc) { - rndis_request *request; - int i, ret; - - /* Attempt to do a rndis device halt */ - request = hv_rndis_request(device, REMOTE_NDIS_HALT_MSG, - RNDIS_MESSAGE_SIZE(rndis_halt_request)); - if (request == NULL) { - return (-1); - } - - /* initialize "poor man's semaphore" */ - request->halt_complete_flag = 0; - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_HALT_MSG); - if (ret != 0) { - return (-1); - } + struct vmbus_xact *xact; + struct rndis_halt_req *halt; + struct hn_send_ctx sndc; + size_t comp_len; - /* - * Wait for halt response from halt callback. We must wait for - * the transaction response before freeing the request and other - * resources. - */ - for (i=HALT_COMPLETION_WAIT_COUNT; i > 0; i--) { - if (request->halt_complete_flag != 0) { - break; - } - DELAY(400); - } - if (i == 0) { - return (-1); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*halt)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS halt\n"); + return (ENXIO); } + halt = vmbus_xact_req_data(xact); + halt->rm_type = REMOTE_NDIS_HALT_MSG; + halt->rm_len = sizeof(*halt); + halt->rm_rid = hn_rndis_rid(sc); + + /* No RNDIS completion; rely on NVS message send completion */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + hn_rndis_xact_exec1(sc, xact, sizeof(*halt), &sndc, &comp_len); - device->state = RNDIS_DEV_UNINITIALIZED; - - hv_put_rndis_request(device, request); - + vmbus_xact_put(xact); + if (bootverbose) + if_printf(sc->hn_ifp, "RNDIS halt done\n"); return (0); } @@ -1251,7 +1127,7 @@ hv_rf_on_device_remove(struct hn_softc * int ret; /* Halt and release the rndis device */ - ret = hv_rf_halt_device(rndis_dev); + ret = hv_rf_halt_device(sc); sc->rndis_dev = NULL; hv_put_rndis_device(rndis_dev); @@ -1291,33 +1167,6 @@ hv_rf_on_close(struct hn_softc *sc) return (hn_rndis_set_rxfilter(sc, 0)); } -static void -hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct hn_softc *sc, - struct vmbus_channel *chan __unused, const void *data __unused, - int dlen __unused) -{ - if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) - hn_chim_free(sc, sndc->hn_chim_idx); -} - -static void -hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct hn_softc *sc, - struct vmbus_channel *chan __unused, const void *data __unused, - int dlen __unused) -{ - rndis_request *request = sndc->hn_cbarg; - - if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) - hn_chim_free(sc, sndc->hn_chim_idx); - - /* - * Notify hv_rf_halt_device() about halt completion. - * The halt code must wait for completion before freeing - * the transaction resources. - */ - request->halt_complete_flag = 1; -} - void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:27:16 2016 (r307490) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:29:10 2016 (r307491) @@ -112,6 +112,8 @@ struct vmbus_xact; const void *hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, size_t *resp_len); +void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc, + struct vmbus_channel *chan, const void *data, int dlen); uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); From owner-svn-src-stable@freebsd.org Mon Oct 17 07:32:51 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FAB1C15018; Mon, 17 Oct 2016 07:32:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB3E21D8E; Mon, 17 Oct 2016 07:32:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7Woup013519; Mon, 17 Oct 2016 07:32:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7WnnC013513; Mon, 17 Oct 2016 07:32:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170732.u9H7WnnC013513@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:32:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307492 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:32:51 -0000 Author: sephe Date: Mon Oct 17 07:32:49 2016 New Revision: 307492 URL: https://svnweb.freebsd.org/changeset/base/307492 Log: MFC 305052-305054,305110 305052 hyperv/hn: Remove the useless rndis_device and related bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7687 305053 hyperv/hn: Log packet message alignment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7689 305054 hyperv/hn: Remove unnecessary NULL check. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7690 305110 hyperv/hn: Consolidate NVS transaction execution. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7704 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:29:10 2016 (r307491) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 07:32:49 2016 (r307492) @@ -107,21 +107,45 @@ hn_chim_alloc(struct hn_softc *sc) const void * hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, - void *req, int reqlen, size_t *resp_len) + void *req, int reqlen, size_t *resplen0, uint32_t type) { struct hn_send_ctx sndc; + size_t resplen, min_resplen = *resplen0; + const struct hn_nvs_hdr *hdr; int error; + KASSERT(min_resplen >= sizeof(*hdr), + ("invalid minimum response len %zu", min_resplen)); + + /* + * Execute the xact setup by the caller. + */ hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - vmbus_xact_activate(xact); + vmbus_xact_activate(xact); error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, req, reqlen, &sndc); if (error) { vmbus_xact_deactivate(xact); - return NULL; + return (NULL); } - return (vmbus_xact_wait(xact, resp_len)); + hdr = vmbus_xact_wait(xact, &resplen); + + /* + * Check this NVS response message. + */ + if (resplen < min_resplen) { + if_printf(sc->hn_ifp, "invalid NVS resp len %zu\n", resplen); + return (NULL); + } + if (hdr->nvs_type != type) { + if_printf(sc->hn_ifp, "unexpected NVS resp 0x%08x, " + "expect 0x%08x\n", hdr->nvs_type, type); + return (NULL); + } + /* All pass! */ + *resplen0 = resplen; + return (hdr); } static __inline int @@ -181,24 +205,14 @@ hv_nv_init_rx_buffer_with_net_vsp(struct conn->nvs_gpadl = sc->hn_rxbuf_gpadl; conn->nvs_sig = HN_NVS_RXBUF_SIG; - resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len, + HN_NVS_TYPE_RXBUF_CONNRESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec rxbuf conn failed\n"); error = EIO; goto cleanup; } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid rxbuf conn resp length %zu\n", - resp_len); - error = EINVAL; - goto cleanup; - } - if (resp->nvs_type != HN_NVS_TYPE_RXBUF_CONNRESP) { - if_printf(sc->hn_ifp, "not rxbuf conn resp, type %u\n", - resp->nvs_type); - error = EINVAL; - goto cleanup; - } status = resp->nvs_status; vmbus_xact_put(xact); @@ -264,24 +278,14 @@ hv_nv_init_send_buffer_with_net_vsp(stru chim->nvs_gpadl = sc->hn_chim_gpadl; chim->nvs_sig = HN_NVS_CHIM_SIG; - resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len, + HN_NVS_TYPE_CHIM_CONNRESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec chim conn failed\n"); error = EIO; goto cleanup; } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid chim conn resp length %zu\n", - resp_len); - error = EINVAL; - goto cleanup; - } - if (resp->nvs_type != HN_NVS_TYPE_CHIM_CONNRESP) { - if_printf(sc->hn_ifp, "not chim conn resp, type %u\n", - resp->nvs_type); - error = EINVAL; - goto cleanup; - } status = resp->nvs_status; sectsz = resp->nvs_sectsz; @@ -442,24 +446,14 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ init->nvs_ver_min = nvs_ver; init->nvs_ver_max = nvs_ver; - resp = hn_nvs_xact_execute(sc, xact, init, sizeof(*init), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, init, sizeof(*init), &resp_len, + HN_NVS_TYPE_INIT_RESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec init failed\n"); vmbus_xact_put(xact); return (EIO); } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid init resp length %zu\n", - resp_len); - vmbus_xact_put(xact); - return (EINVAL); - } - if (resp->nvs_type != HN_NVS_TYPE_INIT_RESP) { - if_printf(sc->hn_ifp, "not init resp, type %u\n", - resp->nvs_type); - vmbus_xact_put(xact); - return (EINVAL); - } status = resp->nvs_status; vmbus_xact_put(xact); @@ -641,7 +635,7 @@ cleanup: * Net VSC on device remove */ int -hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) +hv_nv_on_device_remove(struct hn_softc *sc) { hv_nv_disconnect_from_vsp(sc); Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:29:10 2016 (r307491) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 07:32:49 2016 (r307492) @@ -237,8 +237,8 @@ typedef void (*pfn_on_send_rx_completion #define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP) typedef struct { - uint8_t mac_addr[6]; /* Assumption unsigned long */ - uint8_t link_state; + uint8_t mac_addr[ETHER_ADDR_LEN]; + uint32_t link_state; } netvsc_device_info; #define HN_XACT_REQ_PGCNT 2 @@ -351,7 +351,6 @@ typedef struct hn_softc { int hn_initdone; /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; - struct rndis_device_ *rndis_dev; struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; @@ -400,8 +399,7 @@ struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); int hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr); -int hv_nv_on_device_remove(struct hn_softc *sc, - boolean_t destroy_channel); +int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); void hv_nv_subchan_attach(struct vmbus_channel *chan, Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:29:10 2016 (r307491) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:32:49 2016 (r307492) @@ -154,8 +154,8 @@ __FBSDID("$FreeBSD$"); #define HN_TX_DATA_BOUNDARY PAGE_SIZE #define HN_TX_DATA_MAXSIZE IP_MAXPACKET #define HN_TX_DATA_SEGSIZE PAGE_SIZE -#define HN_TX_DATA_SEGCNT_MAX \ - (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) +/* -1 for RNDIS packet message */ +#define HN_TX_DATA_SEGCNT_MAX (NETVSC_PACKET_MAXPAGE - 1) #define HN_DIRECT_TX_SIZE_DEF 128 @@ -651,7 +651,7 @@ netvsc_detach(device_t dev) * the netdevice. */ - hv_rf_on_device_remove(sc, HV_RF_NV_DESTROY_CHANNEL); + hv_rf_on_device_remove(sc); hn_stop_tx_tasks(sc); @@ -1029,7 +1029,8 @@ hn_encap(struct hn_tx_ring *txr, struct } *m_head0 = m_head; - txr->hn_gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; + /* +1 RNDIS packet message */ + txr->hn_gpa_cnt = nsegs + 1; /* send packet with page buffer */ txr->hn_gpa[0].gpa_page = atop(txd->rndis_msg_paddr); @@ -1037,12 +1038,11 @@ hn_encap(struct hn_tx_ring *txr, struct txr->hn_gpa[0].gpa_len = rndis_msg_size; /* - * Fill the page buffers with mbuf info starting at index - * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. + * Fill the page buffers with mbuf info after the page + * buffer for RNDIS packet message. */ for (i = 0; i < nsegs; ++i) { - struct vmbus_gpa *gpa = &txr->hn_gpa[ - i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; + struct vmbus_gpa *gpa = &txr->hn_gpa[i + 1]; gpa->gpa_page = atop(segs[i].ds_addr); gpa->gpa_ofs = segs[i].ds_addr & PAGE_MASK; @@ -1576,7 +1576,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, * MTU to take effect. This includes tearing down, but not * deleting the channel, then bringing it back up. */ - error = hv_rf_on_device_remove(sc, HV_RF_NV_RETAIN_CHANNEL); + error = hv_rf_on_device_remove(sc); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:29:10 2016 (r307491) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:32:49 2016 (r307492) @@ -71,15 +71,14 @@ __FBSDID("$FreeBSD$"); /* * Forward declarations */ -static void hv_rf_receive_response(rndis_device *device, - const rndis_msg *response); -static void hv_rf_receive_indicate_status(rndis_device *device, +static void hv_rf_receive_indicate_status(struct hn_softc *sc, const rndis_msg *response); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); -static inline int hv_rf_query_device_mac(rndis_device *device); -static inline int hv_rf_query_device_link_status(rndis_device *device); -static int hv_rf_init_device(rndis_device *device); +static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); +static int hv_rf_query_device_link_status(struct hn_softc *sc, + uint32_t *link_status); +static int hv_rf_init_device(struct hn_softc *sc); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); @@ -157,94 +156,24 @@ hv_get_ppi_data(rndis_packet *rpkt, uint return (NULL); } - -/* - * Allow module_param to work and override to switch to promiscuous mode. - */ -static inline rndis_device * -hv_get_rndis_device(void) -{ - rndis_device *device; - - device = malloc(sizeof(rndis_device), M_NETVSC, M_WAITOK | M_ZERO); - - mtx_init(&device->req_lock, "HV-FRL", NULL, MTX_DEF); - - /* Same effect as STAILQ_HEAD_INITIALIZER() static initializer */ - STAILQ_INIT(&device->myrequest_list); - - device->state = RNDIS_DEV_UNINITIALIZED; - - return (device); -} - -/* - * - */ -static inline void -hv_put_rndis_device(rndis_device *device) -{ - mtx_destroy(&device->req_lock); - free(device, M_NETVSC); -} - -/* - * RNDIS filter receive response - */ -static void -hv_rf_receive_response(rndis_device *device, const rndis_msg *response) -{ - rndis_request *request = NULL; - rndis_request *next_request; - boolean_t found = FALSE; - - mtx_lock(&device->req_lock); - request = STAILQ_FIRST(&device->myrequest_list); - while (request != NULL) { - /* - * All request/response message contains request_id as the - * first field - */ - if (request->request_msg.msg.init_request.request_id == - response->msg.init_complete.request_id) { - found = TRUE; - break; - } - next_request = STAILQ_NEXT(request, mylist_entry); - request = next_request; - } - mtx_unlock(&device->req_lock); - - if (found) { - if (response->msg_len <= sizeof(rndis_msg)) { - memcpy(&request->response_msg, response, - response->msg_len); - } else { - request->response_msg.msg.init_complete.status = - RNDIS_STATUS_BUFFER_OVERFLOW; - } - sema_post(&request->wait_sema); - } -} - /* * RNDIS filter receive indicate status */ static void -hv_rf_receive_indicate_status(rndis_device *device, const rndis_msg *response) +hv_rf_receive_indicate_status(struct hn_softc *sc, const rndis_msg *response) { const rndis_indicate_status *indicate = &response->msg.indicate_status; switch(indicate->status) { case RNDIS_STATUS_MEDIA_CONNECT: - netvsc_linkstatus_callback(device->sc, 1); + netvsc_linkstatus_callback(sc, 1); break; case RNDIS_STATUS_MEDIA_DISCONNECT: - netvsc_linkstatus_callback(device->sc, 0); + netvsc_linkstatus_callback(sc, 0); break; default: /* TODO: */ - device_printf(device->sc->hn_dev, + if_printf(sc->hn_ifp, "unknown status %d received\n", indicate->status); break; } @@ -374,14 +303,9 @@ int hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen) { - rndis_device *rndis_dev; const rndis_msg *rndis_hdr; const struct rndis_comp_hdr *comp; - rndis_dev = sc->rndis_dev; - if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) - return (EINVAL); - rndis_hdr = data; switch (rndis_hdr->ndis_msg_type) { /* data message */ @@ -395,17 +319,14 @@ hv_rf_on_receive(struct hn_softc *sc, st case REMOTE_NDIS_SET_CMPLT: case REMOTE_NDIS_KEEPALIVE_CMPLT: comp = data; - if (comp->rm_rid <= HN_RNDIS_RID_COMPAT_MAX) { - /* Transition time compat code */ - hv_rf_receive_response(rndis_dev, rndis_hdr); - } else { - vmbus_xact_ctx_wakeup(sc->hn_xact, data, dlen); - } + KASSERT(comp->rm_rid > HN_RNDIS_RID_COMPAT_MAX, + ("invalid rid 0x%08x\n", comp->rm_rid)); + vmbus_xact_ctx_wakeup(sc->hn_xact, comp, dlen); break; /* notification message */ case REMOTE_NDIS_INDICATE_STATUS_MSG: - hv_rf_receive_indicate_status(rndis_dev, rndis_hdr); + hv_rf_receive_indicate_status(sc, rndis_hdr); break; case REMOTE_NDIS_RESET_CMPLT: @@ -431,19 +352,18 @@ hv_rf_on_receive(struct hn_softc *sc, st * RNDIS filter query device MAC address */ static int -hv_rf_query_device_mac(rndis_device *device) +hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr) { - struct hn_softc *sc = device->sc; - size_t hwaddr_len; + size_t eaddr_len; int error; - hwaddr_len = ETHER_ADDR_LEN; + eaddr_len = ETHER_ADDR_LEN; error = hn_rndis_query(sc, OID_802_3_PERMANENT_ADDRESS, NULL, 0, - device->hw_mac_addr, &hwaddr_len); + eaddr, &eaddr_len); if (error) return (error); - if (hwaddr_len != ETHER_ADDR_LEN) { - if_printf(sc->hn_ifp, "invalid hwaddr len %zu\n", hwaddr_len); + if (eaddr_len != ETHER_ADDR_LEN) { + if_printf(sc->hn_ifp, "invalid eaddr len %zu\n", eaddr_len); return (EINVAL); } return (0); @@ -452,16 +372,15 @@ hv_rf_query_device_mac(rndis_device *dev /* * RNDIS filter query device link status */ -static inline int -hv_rf_query_device_link_status(rndis_device *device) +static int +hv_rf_query_device_link_status(struct hn_softc *sc, uint32_t *link_status) { - struct hn_softc *sc = device->sc; size_t size; int error; - size = sizeof(uint32_t); + size = sizeof(*link_status); error = hn_rndis_query(sc, OID_GEN_MEDIA_CONNECT_STATUS, NULL, 0, - &device->link_status, &size); + link_status, &size); if (error) return (error); if (size != sizeof(uint32_t)) { @@ -875,9 +794,8 @@ hn_rndis_set_rxfilter(struct hn_softc *s * RNDIS filter init device */ static int -hv_rf_init_device(rndis_device *device) +hv_rf_init_device(struct hn_softc *sc) { - struct hn_softc *sc = device->sc; struct rndis_init_req *req; const struct rndis_init_comp *comp; struct vmbus_xact *xact; @@ -885,9 +803,6 @@ hv_rf_init_device(rndis_device *device) uint32_t rid; int error; - /* XXX */ - device->state = RNDIS_DEV_INITIALIZED; - xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); if (xact == NULL) { if_printf(sc->hn_ifp, "no xact for RNDIS init\n"); @@ -918,15 +833,14 @@ hv_rf_init_device(rndis_device *device) goto done; } if (bootverbose) { - if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u\n", - comp->rm_ver_major, comp->rm_ver_minor, - comp->rm_pktmaxsz, comp->rm_pktmaxcnt); + if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u, " + "align %u\n", comp->rm_ver_major, comp->rm_ver_minor, + comp->rm_pktmaxsz, comp->rm_pktmaxcnt, + 1U << comp->rm_align); } error = 0; - done: - if (xact != NULL) - vmbus_xact_put(xact); + vmbus_xact_put(xact); return (error); } @@ -969,7 +883,6 @@ hv_rf_on_device_add(struct hn_softc *sc, int *nchan0, struct hn_rx_ring *rxr) { int ret; - rndis_device *rndis_dev; netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = sc->hn_dev; struct hn_nvs_subch_req *req; @@ -980,13 +893,6 @@ hv_rf_on_device_add(struct hn_softc *sc, int nchan = *nchan0; int rxr_cnt; - rndis_dev = hv_get_rndis_device(); - if (rndis_dev == NULL) { - return (ENOMEM); - } - sc->rndis_dev = rndis_dev; - rndis_dev->sc = sc; - /* * Let the inner driver handle this first to create the netvsc channel * NOTE! Once the channel is created, we may get a receive callback @@ -994,17 +900,15 @@ hv_rf_on_device_add(struct hn_softc *sc, * Note: Earlier code used a function pointer here. */ ret = hv_nv_on_device_add(sc, rxr); - if (ret != 0) { - hv_put_rndis_device(rndis_dev); + if (ret != 0) return (ret); - } /* * Initialize the rndis device */ /* Send the rndis initialization message */ - ret = hv_rf_init_device(rndis_dev); + ret = hv_rf_init_device(sc); if (ret != 0) { /* * TODO: If rndis init failed, we will need to shut down @@ -1013,19 +917,15 @@ hv_rf_on_device_add(struct hn_softc *sc, } /* Get the mac address */ - ret = hv_rf_query_device_mac(rndis_dev); + ret = hv_rf_query_device_mac(sc, dev_info->mac_addr); if (ret != 0) { /* TODO: shut down rndis device and the channel */ } /* Configure NDIS offload settings */ hn_rndis_conf_offload(sc); - - memcpy(dev_info->mac_addr, rndis_dev->hw_mac_addr, ETHER_ADDR_LEN); - hv_rf_query_device_link_status(rndis_dev); - - dev_info->link_state = rndis_dev->link_status; + hv_rf_query_device_link_status(sc, &dev_info->link_state); if (sc->hn_ndis_ver < NDIS_VERSION_6_30 || nchan == 1) { /* @@ -1070,24 +970,14 @@ hv_rf_on_device_add(struct hn_softc *sc, req->nvs_op = HN_NVS_SUBCH_OP_ALLOC; req->nvs_nsubch = nchan - 1; - resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len, + HN_NVS_TYPE_SUBCH_RESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec subch failed\n"); ret = EIO; goto out; } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid subch resp length %zu\n", - resp_len); - ret = EINVAL; - goto out; - } - if (resp->nvs_type != HN_NVS_TYPE_SUBCH_RESP) { - if_printf(sc->hn_ifp, "not subch resp, type %u\n", - resp->nvs_type); - ret = EINVAL; - goto out; - } status = resp->nvs_status; nsubch = resp->nvs_nsubch; @@ -1121,19 +1011,15 @@ out: * RNDIS filter on device remove */ int -hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) +hv_rf_on_device_remove(struct hn_softc *sc) { - rndis_device *rndis_dev = sc->rndis_dev; int ret; /* Halt and release the rndis device */ ret = hv_rf_halt_device(sc); - sc->rndis_dev = NULL; - hv_put_rndis_device(rndis_dev); - /* Pass control to inner driver to remove the device */ - ret |= hv_nv_on_device_remove(sc, destroy_channel); + ret |= hv_nv_on_device_remove(sc); return (ret); } Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 07:29:10 2016 (r307491) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 07:32:49 2016 (r307492) @@ -36,80 +36,6 @@ #include /* - * Defines - */ - -/* Destroy or preserve channel on filter/netvsc teardown */ -#define HV_RF_NV_DESTROY_CHANNEL TRUE -#define HV_RF_NV_RETAIN_CHANNEL FALSE - -/* - * Number of page buffers to reserve for the RNDIS filter packet in the - * transmitted message. - */ -#define HV_RF_NUM_TX_RESERVED_PAGE_BUFS 1 - - -/* - * Data types - */ - -typedef enum { - RNDIS_DEV_UNINITIALIZED = 0, - RNDIS_DEV_INITIALIZING, - RNDIS_DEV_INITIALIZED, - RNDIS_DEV_DATAINITIALIZED, -} rndis_device_state; - -typedef struct rndis_request_ { - STAILQ_ENTRY(rndis_request_) mylist_entry; - struct sema wait_sema; - - /* - * The max response size is sizeof(rndis_msg) + PAGE_SIZE. - * - * XXX - * This is ugly and should be cleaned up once we busdma-fy - * RNDIS request bits. - */ - rndis_msg response_msg; - uint8_t buf_resp[PAGE_SIZE]; - - /* Simplify allocation by having a netvsc packet inline */ - struct hn_send_ctx send_ctx; - - /* - * The max request size is sizeof(rndis_msg) + PAGE_SIZE. - * - * NOTE: - * This is required for the large request like RSS settings. - * - * XXX - * This is ugly and should be cleaned up once we busdma-fy - * RNDIS request bits. - */ - rndis_msg request_msg; - uint8_t buf_req[PAGE_SIZE]; - - /* Fixme: Poor man's semaphore. */ - uint32_t halt_complete_flag; -} rndis_request; - -typedef struct rndis_device_ { - struct hn_softc *sc; - - rndis_device_state state; - uint32_t link_status; - uint32_t new_request_id; - - struct mtx req_lock; - - STAILQ_HEAD(RQ, rndis_request_) myrequest_list; - - uint8_t hw_mac_addr[ETHER_ADDR_LEN]; -} rndis_device; - -/* * Externs */ struct hn_rx_ring; @@ -119,7 +45,7 @@ int hv_rf_on_receive(struct hn_softc *sc void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan, struct hn_rx_ring *rxr); -int hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); +int hv_rf_on_device_remove(struct hn_softc *sc); int hv_rf_on_open(struct hn_softc *sc); int hv_rf_on_close(struct hn_softc *sc); Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:29:10 2016 (r307491) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:32:49 2016 (r307492) @@ -111,7 +111,7 @@ struct vmbus_xact; const void *hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, - size_t *resp_len); + size_t *resp_len, uint32_t type); void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); uint32_t hn_chim_alloc(struct hn_softc *sc); From owner-svn-src-stable@freebsd.org Mon Oct 17 07:35:32 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ABBB9C15119; Mon, 17 Oct 2016 07:35:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6B1A61F53; Mon, 17 Oct 2016 07:35:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7ZVfO013689; Mon, 17 Oct 2016 07:35:31 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7ZVZW013688; Mon, 17 Oct 2016 07:35:31 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170735.u9H7ZVZW013688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:35:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307493 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:35:32 -0000 Author: sephe Date: Mon Oct 17 07:35:31 2016 New Revision: 307493 URL: https://svnweb.freebsd.org/changeset/base/307493 Log: MFC 305111 hyperv/timesync: Rework time adjustment policy - By default, adjust time upon SYNC request. It can be disabled through hw.hvtimesync.ignore_sync_req. SYNC request will be sent by hypervisor the host is resumed, rebooted, etc. - By default, adjust time upon SAMPLE request, if there is 100ms difference between VM time and hypervisor time. This can be disabled through hw.hvtimesync.sample_drift. And nuke the unnecessary task, since channel callback is running in a Hyper-V taskqueue nowadays. Submitted by: YanZhe Chen Discussed with: Dexuan Cui , Hongjiang Zhang , sephe Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7707 Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 07:32:49 2016 (r307492) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 07:35:31 2016 (r307493) @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -52,11 +52,7 @@ #define HV_ICTIMESYNCFLAG_SYNC 1 #define HV_ICTIMESYNCFLAG_SAMPLE 2 #define HV_NANO_SEC_PER_SEC 1000000000 - -/* Time Sync data */ -typedef struct { - uint64_t data; -} time_sync_data; +#define HV_NANO_SEC_PER_MILLI_SEC 1000000 static const struct vmbus_ic_desc vmbus_timesync_descs[] = { { @@ -75,22 +71,43 @@ struct hv_ictimesync_data { uint8_t flags; } __packed; -typedef struct hv_timesync_sc { - hv_util_sc util_sc; - struct task task; - time_sync_data time_msg; -} hv_timesync_sc; +/* + * Globals + */ +SYSCTL_NODE(_hw, OID_AUTO, hvtimesync, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, + "Hyper-V timesync interface"); + +/* Ignore the sync request when set to 1. */ +static int ignore_sync_req = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, ignore_sync_req, CTLFLAG_RWTUN, + &ignore_sync_req, 0, + "Ignore the sync request when set to 1."); + +/* + * Trigger sample sync when drift exceeds threshold (ms). + * Ignore the sample request when set to 0. + */ +static int sample_drift = 100; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_drift, CTLFLAG_RWTUN, + &sample_drift, 0, + "Threshold that makes sample request trigger the sync."); /** - * Set host time based on time sync message from host + * @brief Synchronize time with host after reboot, restore, etc. + * + * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM. + * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time + * message after the timesync channel is opened. Since the hv_utils module is + * loaded after hv_vmbus, the first message is usually missed. The other + * thing is, systime is automatically set to emulated hardware clock which may + * not be UTC time or in the same time zone. So, to override these effects, we + * use the first 50 time samples for initial system time setting. */ -static void -hv_set_host_time(void *context, int pending) +static inline +void hv_adj_guesttime(hv_util_sc *sc, uint64_t hosttime, uint8_t flags) { - hv_timesync_sc *softc = (hv_timesync_sc*)context; - uint64_t hosttime = softc->time_msg.data; struct timespec guest_ts, host_ts; - uint64_t host_tns; + uint64_t host_tns, guest_tns; int64_t diff; int error; @@ -99,37 +116,35 @@ hv_set_host_time(void *context, int pend host_ts.tv_nsec = (long)(host_tns%HV_NANO_SEC_PER_SEC); nanotime(&guest_ts); + guest_tns = guest_ts.tv_sec * HV_NANO_SEC_PER_SEC + guest_ts.tv_nsec; - diff = (int64_t)host_ts.tv_sec - (int64_t)guest_ts.tv_sec; + if ((flags & HV_ICTIMESYNCFLAG_SYNC) != 0 && ignore_sync_req == 0) { + if (bootverbose) { + device_printf(sc->ic_dev, "handle sync request " + "{host: %ju, guest: %ju}\n", + (uintmax_t)host_tns, (uintmax_t)guest_tns); + } - /* - * If host differs by 5 seconds then make the guest catch up - */ - if (diff > 5 || diff < -5) { error = kern_clock_settime(curthread, CLOCK_REALTIME, &host_ts); + return; } -} -/** - * @brief Synchronize time with host after reboot, restore, etc. - * - * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM. - * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time - * message after the timesync channel is opened. Since the hv_utils module is - * loaded after hv_vmbus, the first message is usually missed. The other - * thing is, systime is automatically set to emulated hardware clock which may - * not be UTC time or in the same time zone. So, to override these effects, we - * use the first 50 time samples for initial system time setting. - */ -static inline -void hv_adj_guesttime(hv_timesync_sc *sc, uint64_t hosttime, uint8_t flags) -{ - sc->time_msg.data = hosttime; - - if (((flags & HV_ICTIMESYNCFLAG_SYNC) != 0) || - ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0)) { - taskqueue_enqueue(taskqueue_thread, &sc->task); + if ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0 && sample_drift != 0) { + if (bootverbose) { + device_printf(sc->ic_dev, "handle sample request " + "{host: %ju, guest: %ju}\n", + (uintmax_t)host_tns, (uintmax_t)guest_tns); + } + + diff = (int64_t)(host_tns - guest_tns) / HV_NANO_SEC_PER_MILLI_SEC; + if (diff > sample_drift || diff < -sample_drift) { + error = kern_clock_settime(curthread, CLOCK_REALTIME, + &host_ts); + if (bootverbose) + device_printf(sc->ic_dev, "trigger sample sync"); + } + return; } } @@ -145,12 +160,12 @@ hv_timesync_cb(struct vmbus_channel *cha int ret; uint8_t* time_buf; struct hv_ictimesync_data* timedatap; - hv_timesync_sc *softc; + hv_util_sc *softc; - softc = (hv_timesync_sc*)context; - time_buf = softc->util_sc.receive_buffer; + softc = (hv_util_sc*)context; + time_buf = softc->receive_buffer; - recvlen = softc->util_sc.ic_buflen; + recvlen = softc->ic_buflen; ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -162,7 +177,7 @@ hv_timesync_cb(struct vmbus_channel *cha if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { int error; - error = vmbus_ic_negomsg(&softc->util_sc, time_buf, &recvlen); + error = vmbus_ic_negomsg(softc, time_buf, &recvlen); if (error) return; } else { @@ -190,18 +205,12 @@ hv_timesync_probe(device_t dev) static int hv_timesync_attach(device_t dev) { - hv_timesync_sc *softc = device_get_softc(dev); - - TASK_INIT(&softc->task, 1, hv_set_host_time, softc); return hv_util_attach(dev, hv_timesync_cb); } static int hv_timesync_detach(device_t dev) { - hv_timesync_sc *softc = device_get_softc(dev); - - taskqueue_drain(taskqueue_thread, &softc->task); return hv_util_detach(dev); } @@ -213,7 +222,7 @@ static device_method_t timesync_methods[ { 0, 0 } }; -static driver_t timesync_driver = { "hvtimesync", timesync_methods, sizeof(hv_timesync_sc)}; +static driver_t timesync_driver = { "hvtimesync", timesync_methods, sizeof(hv_util_sc)}; static devclass_t timesync_devclass; From owner-svn-src-stable@freebsd.org Mon Oct 17 07:38:23 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C410C1523C; Mon, 17 Oct 2016 07:38:23 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DEF1910DC; Mon, 17 Oct 2016 07:38:22 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7cMTg013844; Mon, 17 Oct 2016 07:38:22 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7cLbt013841; Mon, 17 Oct 2016 07:38:21 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170738.u9H7cLbt013841@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:38:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307494 - in stable/11/sys: dev/hyperv/netvsc net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:38:23 -0000 Author: sephe Date: Mon Oct 17 07:38:21 2016 New Revision: 307494 URL: https://svnweb.freebsd.org/changeset/base/307494 Log: MFC 305173,305174 305173 net/rndis: Add comment for rndis_set_parameter Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7705 305174 hyperv/hn: Remove unused function Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7706 Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:35:31 2016 (r307493) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Mon Oct 17 07:38:21 2016 (r307494) @@ -904,7 +904,5 @@ void* hv_set_rppi_data(rndis_msg *rndis_ uint32_t rppi_size, int pkt_type); -void* hv_get_ppi_data(rndis_packet *rpkt, uint32_t type); - #endif /* __HV_RNDIS_H__ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:35:31 2016 (r307493) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:38:21 2016 (r307494) @@ -128,35 +128,6 @@ hv_set_rppi_data(rndis_msg *rndis_mesg, } /* - * Get the Per-Packet-Info with the specified type - * return NULL if not found. - */ -void * -hv_get_ppi_data(rndis_packet *rpkt, uint32_t type) -{ - rndis_per_packet_info *ppi; - int len; - - if (rpkt->per_pkt_info_offset == 0) - return (NULL); - - ppi = (rndis_per_packet_info *)((unsigned long)rpkt + - rpkt->per_pkt_info_offset); - len = rpkt->per_pkt_info_length; - - while (len > 0) { - if (ppi->type == type) - return (void *)((unsigned long)ppi + - ppi->per_packet_info_offset); - - len -= ppi->size; - ppi = (rndis_per_packet_info *)((unsigned long)ppi + ppi->size); - } - - return (NULL); -} - -/* * RNDIS filter receive indicate status */ static void Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Mon Oct 17 07:35:31 2016 (r307493) +++ stable/11/sys/net/rndis.h Mon Oct 17 07:38:21 2016 (r307494) @@ -217,6 +217,9 @@ struct rndis_set_comp { uint32_t rm_status; }; +/* + * Parameter used by OID_GEN_RNDIS_CONFIG_PARAMETER. + */ #define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 #define REMOTE_NDIS_SET_PARAM_STRING 0x00000002 From owner-svn-src-stable@freebsd.org Mon Oct 17 07:46:15 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E90FC15427; Mon, 17 Oct 2016 07:46:15 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 520FD15CF; Mon, 17 Oct 2016 07:46:15 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H7kEkZ017726; Mon, 17 Oct 2016 07:46:14 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H7kDji017720; Mon, 17 Oct 2016 07:46:13 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170746.u9H7kDji017720@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 07:46:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307495 - in stable/11/sys: dev/hyperv/netvsc net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 07:46:15 -0000 Author: sephe Date: Mon Oct 17 07:46:13 2016 New Revision: 307495 URL: https://svnweb.freebsd.org/changeset/base/307495 Log: MFC 305175,305176,305179,305182,305268,305270,305276 305175 net/rndis: Define per-packet-info for RNDIS packet message Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7708 305176 hyperv/hn: Stringent per-packet-info verification. While I'm here, minor style changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7709 305179 hyperv/hn: Fix VLAN tag construction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7716 305182 net/rndis: Define types for RNDIS pktinfo rm_type field. They are defined by NDIS spec, so the NDIS prefix. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7717 305268 hyperv/hn: Rework RXCSUM related bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7735 305270 hyperv/hn: Simplify RX hash related bits. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7736 305276 hyperv/hn: Use the per-packet-info types defined by net/rndis.h Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7737 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnreg.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/dev/hyperv/netvsc/ndis.h stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:38:21 2016 (r307494) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 07:46:13 2016 (r307495) @@ -1289,7 +1289,7 @@ netvsc_recv(struct hn_rx_ring *rxr, cons struct ifnet *ifp = rxr->hn_ifp; struct mbuf *m_new; int size, do_lro = 0, do_csum = 1; - int hash_type = M_HASHTYPE_OPAQUE_HASH; + int hash_type; if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) return (0); @@ -1335,28 +1335,29 @@ netvsc_recv(struct hn_rx_ring *rxr, cons do_csum = 0; /* receive side checksum offload */ - if (info->csum_info != NULL) { + if (info->csum_info != HN_NDIS_RXCSUM_INFO_INVALID) { /* IP csum offload */ - if (info->csum_info->receive.ip_csum_succeeded && do_csum) { + if ((info->csum_info & NDIS_RXCSUM_INFO_IPCS_OK) && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); rxr->hn_csum_ip++; } /* TCP/UDP csum offload */ - if ((info->csum_info->receive.tcp_csum_succeeded || - info->csum_info->receive.udp_csum_succeeded) && do_csum) { + if ((info->csum_info & (NDIS_RXCSUM_INFO_UDPCS_OK | + NDIS_RXCSUM_INFO_TCPCS_OK)) && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; - if (info->csum_info->receive.tcp_csum_succeeded) + if (info->csum_info & NDIS_RXCSUM_INFO_TCPCS_OK) rxr->hn_csum_tcp++; else rxr->hn_csum_udp++; } - if (info->csum_info->receive.ip_csum_succeeded && - info->csum_info->receive.tcp_csum_succeeded) + if ((info->csum_info & + (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) == + (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) do_lro = 1; } else { const struct ether_header *eh; @@ -1412,18 +1413,21 @@ netvsc_recv(struct hn_rx_ring *rxr, cons } } skip: - if (info->vlan_info != NULL) { - m_new->m_pkthdr.ether_vtag = info->vlan_info->u1.s1.vlan_id; + if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) { + m_new->m_pkthdr.ether_vtag = EVL_MAKETAG( + NDIS_VLAN_INFO_ID(info->vlan_info), + NDIS_VLAN_INFO_PRI(info->vlan_info), + NDIS_VLAN_INFO_CFI(info->vlan_info)); m_new->m_flags |= M_VLANTAG; } - if (info->hash_info != NULL && info->hash_value != NULL) { + if (info->hash_info != HN_NDIS_HASH_INFO_INVALID) { rxr->hn_rss_pkts++; - m_new->m_pkthdr.flowid = info->hash_value->hash_value; - if ((info->hash_info->hash_info & NDIS_HASH_FUNCTION_MASK) == + m_new->m_pkthdr.flowid = info->hash_value; + hash_type = M_HASHTYPE_OPAQUE_HASH; + if ((info->hash_info & NDIS_HASH_FUNCTION_MASK) == NDIS_HASH_FUNCTION_TOEPLITZ) { - uint32_t type = - (info->hash_info->hash_info & NDIS_HASH_TYPE_MASK); + uint32_t type = (info->hash_info & NDIS_HASH_TYPE_MASK); switch (type) { case NDIS_HASH_IPV4: @@ -1452,12 +1456,8 @@ skip: } } } else { - if (info->hash_value != NULL) { - m_new->m_pkthdr.flowid = info->hash_value->hash_value; - } else { - m_new->m_pkthdr.flowid = rxr->hn_rx_idx; - hash_type = M_HASHTYPE_OPAQUE; - } + m_new->m_pkthdr.flowid = rxr->hn_rx_idx; + hash_type = M_HASHTYPE_OPAQUE; } M_HASHTYPE_SET(m_new, hash_type); Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:38:21 2016 (r307494) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 07:46:13 2016 (r307495) @@ -153,79 +153,92 @@ hv_rf_receive_indicate_status(struct hn_ static int hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hn_recvinfo *info) { - const rndis_per_packet_info *ppi; - uint32_t mask, len; + const struct rndis_pktinfo *pi; + uint32_t mask = 0, len; - info->vlan_info = NULL; - info->csum_info = NULL; - info->hash_info = NULL; - info->hash_value = NULL; + info->vlan_info = HN_NDIS_VLAN_INFO_INVALID; + info->csum_info = HN_NDIS_RXCSUM_INFO_INVALID; + info->hash_info = HN_NDIS_HASH_INFO_INVALID; if (rpkt->per_pkt_info_offset == 0) - return 0; + return (0); + if (__predict_false(rpkt->per_pkt_info_offset & + (RNDIS_PKTINFO_ALIGN - 1))) + return (EINVAL); + if (__predict_false(rpkt->per_pkt_info_offset < + RNDIS_PACKET_MSG_OFFSET_MIN)) + return (EINVAL); - ppi = (const rndis_per_packet_info *) + pi = (const struct rndis_pktinfo *) ((const uint8_t *)rpkt + rpkt->per_pkt_info_offset); len = rpkt->per_pkt_info_length; - mask = 0; while (len != 0) { - const void *ppi_dptr; - uint32_t ppi_dlen; + const void *data; + uint32_t dlen; - if (__predict_false(ppi->size < ppi->per_packet_info_offset)) - return EINVAL; - ppi_dlen = ppi->size - ppi->per_packet_info_offset; - ppi_dptr = (const uint8_t *)ppi + ppi->per_packet_info_offset; - - switch (ppi->type) { - case ieee_8021q_info: - if (__predict_false(ppi_dlen < sizeof(ndis_8021q_info))) - return EINVAL; - info->vlan_info = ppi_dptr; + if (__predict_false(len < sizeof(*pi))) + return (EINVAL); + if (__predict_false(len < pi->rm_size)) + return (EINVAL); + len -= pi->rm_size; + + if (__predict_false(pi->rm_size & (RNDIS_PKTINFO_ALIGN - 1))) + return (EINVAL); + if (__predict_false(pi->rm_size < pi->rm_pktinfooffset)) + return (EINVAL); + dlen = pi->rm_size - pi->rm_pktinfooffset; + data = pi->rm_data; + + switch (pi->rm_type) { + case NDIS_PKTINFO_TYPE_VLAN: + if (__predict_false(dlen < NDIS_VLAN_INFO_SIZE)) + return (EINVAL); + info->vlan_info = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_VLAN; break; - case tcpip_chksum_info: - if (__predict_false(ppi_dlen < - sizeof(rndis_tcp_ip_csum_info))) - return EINVAL; - info->csum_info = ppi_dptr; + case NDIS_PKTINFO_TYPE_CSUM: + if (__predict_false(dlen < NDIS_RXCSUM_INFO_SIZE)) + return (EINVAL); + info->csum_info = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_CSUM; break; - case nbl_hash_value: - if (__predict_false(ppi_dlen < - sizeof(struct rndis_hash_value))) - return EINVAL; - info->hash_value = ppi_dptr; + case HN_NDIS_PKTINFO_TYPE_HASHVAL: + if (__predict_false(dlen < HN_NDIS_HASH_VALUE_SIZE)) + return (EINVAL); + info->hash_value = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_HASHVAL; break; - case nbl_hash_info: - if (__predict_false(ppi_dlen < - sizeof(struct rndis_hash_info))) - return EINVAL; - info->hash_info = ppi_dptr; + case HN_NDIS_PKTINFO_TYPE_HASHINF: + if (__predict_false(dlen < HN_NDIS_HASH_INFO_SIZE)) + return (EINVAL); + info->hash_info = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_HASHINF; break; default: - goto skip; + goto next; } if (mask == HV_RF_RECVINFO_ALL) { /* All found; done */ break; } -skip: - if (__predict_false(len < ppi->size)) - return EINVAL; - len -= ppi->size; - ppi = (const rndis_per_packet_info *) - ((const uint8_t *)ppi + ppi->size); +next: + pi = (const struct rndis_pktinfo *) + ((const uint8_t *)pi + pi->rm_size); } - return 0; + + /* + * Final fixup. + * - If there is no hash value, invalidate the hash info. + */ + if ((mask & HV_RF_RECVINFO_HASHVAL) == 0) + info->hash_info = HN_NDIS_HASH_INFO_INVALID; + return (0); } /* Modified: stable/11/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Mon Oct 17 07:38:21 2016 (r307494) +++ stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Mon Oct 17 07:46:13 2016 (r307495) @@ -208,4 +208,17 @@ struct hn_nvs_rndis_ack { } __packed; CTASSERT(sizeof(struct hn_nvs_rndis_ack) >= HN_NVS_REQSIZE_MIN); +/* + * RNDIS extension + */ + +/* Per-packet hash info */ +#define HN_NDIS_HASH_INFO_SIZE sizeof(uint32_t) +#define HN_NDIS_PKTINFO_TYPE_HASHINF NDIS_PKTINFO_TYPE_ORIG_NBLIST +/* NDIS_HASH_ */ + +/* Per-packet hash value */ +#define HN_NDIS_HASH_VALUE_SIZE sizeof(uint32_t) +#define HN_NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID + #endif /* !_IF_HNREG_H_ */ Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:38:21 2016 (r307494) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 07:46:13 2016 (r307495) @@ -55,11 +55,15 @@ struct rndix_hash_value; struct ndis_8021q_info_; struct rndis_tcp_ip_csum_info_; +#define HN_NDIS_VLAN_INFO_INVALID 0xffffffff +#define HN_NDIS_RXCSUM_INFO_INVALID 0 +#define HN_NDIS_HASH_INFO_INVALID 0 + struct hn_recvinfo { - const struct ndis_8021q_info_ *vlan_info; - const struct rndis_tcp_ip_csum_info_ *csum_info; - const struct rndis_hash_info *hash_info; - const struct rndis_hash_value *hash_value; + uint32_t vlan_info; + uint32_t csum_info; + uint32_t hash_info; + uint32_t hash_value; }; #define HN_SEND_CTX_INITIALIZER(cb, cbarg) \ Modified: stable/11/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 07:38:21 2016 (r307494) +++ stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 07:46:13 2016 (r307495) @@ -203,4 +203,32 @@ struct ndis_rssprm_toeplitz { uint32_t rss_ind[NDIS_HASH_INDCNT]; }; +/* + * Per-packet-info + */ + +/* VLAN */ +#define NDIS_VLAN_INFO_SIZE sizeof(uint32_t) +#define NDIS_VLAN_INFO_PRI_MASK 0x0007 +#define NDIS_VLAN_INFO_CFI_MASK 0x0008 +#define NDIS_VLAN_INFO_ID_MASK 0xfff0 +#define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \ + (((pri) & NVIS_VLAN_INFO_PRI_MASK) | \ + (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4)) +#define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4) +#define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3) +#define NDIS_VLAN_INFO_PRI(inf) ((inf) & NDIS_VLAN_INFO_PRI_MASK) + +/* Reception checksum */ +#define NDIS_RXCSUM_INFO_SIZE sizeof(uint32_t) +#define NDIS_RXCSUM_INFO_TCPCS_FAILED 0x0001 +#define NDIS_RXCSUM_INFO_UDPCS_FAILED 0x0002 +#define NDIS_RXCSUM_INFO_IPCS_FAILED 0x0004 +#define NDIS_RXCSUM_INFO_TCPCS_OK 0x0008 +#define NDIS_RXCSUM_INFO_UDPCS_OK 0x0010 +#define NDIS_RXCSUM_INFO_IPCS_OK 0x0020 +#define NDIS_RXCSUM_INFO_LOOPBACK 0x0040 +#define NDIS_RXCSUM_INFO_TCPCS_INVAL 0x0080 +#define NDIS_RXCSUM_INFO_IPCS_INVAL 0x0100 + #endif /* !_NET_NDIS_H_ */ Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Mon Oct 17 07:38:21 2016 (r307494) +++ stable/11/sys/net/rndis.h Mon Oct 17 07:46:13 2016 (r307495) @@ -112,6 +112,39 @@ struct rndis_packet_msg { }; /* + * Minimum value for rm_dataoffset, rm_oobdataoffset, and + * rm_pktinfooffset. + */ +#define RNDIS_PACKET_MSG_OFFSET_MIN \ + (sizeof(struct rndis_packet_msg) - \ + __offsetof(struct rndis_packet_msg, rm_dataoffset)) + +/* Per-packet-info for RNDIS data message */ +struct rndis_pktinfo { + uint32_t rm_size; + uint32_t rm_type; /* NDIS_PKTINFO_TYPE_ */ + uint32_t rm_pktinfooffset; + uint8_t rm_data[]; +}; + +#define RNDIS_PKTINFO_OFFSET \ + __offsetof(struct rndis_pktinfo, rm_data[0]) +#define RNDIS_PKTINFO_ALIGN 4 + +#define NDIS_PKTINFO_TYPE_CSUM 0 +#define NDIS_PKTINFO_TYPE_IPSEC 1 +#define NDIS_PKTINFO_TYPE_LSO 2 +#define NDIS_PKTINFO_TYPE_CLASSIFY 3 +/* reserved 4 */ +#define NDIS_PKTINFO_TYPE_SGLIST 5 +#define NDIS_PKTINFO_TYPE_VLAN 6 +#define NDIS_PKTINFO_TYPE_ORIG 7 +#define NDIS_PKTINFO_TYPE_PKT_CANCELID 8 +#define NDIS_PKTINFO_TYPE_ORIG_NBLIST 9 +#define NDIS_PKTINFO_TYPE_CACHE_NBLIST 10 +#define NDIS_PKTINFO_TYPE_PKT_PAD 11 + +/* * RNDIS control messages */ struct rndis_comp_hdr { From owner-svn-src-stable@freebsd.org Mon Oct 17 08:03:16 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B74D4C15A36; Mon, 17 Oct 2016 08:03:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88D2B1E58; Mon, 17 Oct 2016 08:03:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H83Fc3024975; Mon, 17 Oct 2016 08:03:15 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H83FkP024974; Mon, 17 Oct 2016 08:03:15 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170803.u9H83FkP024974@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:03:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307496 - stable/11/sys/net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:03:16 -0000 Author: sephe Date: Mon Oct 17 08:03:15 2016 New Revision: 307496 URL: https://svnweb.freebsd.org/changeset/base/307496 Log: MFC 305277,305278 305277 net/rndis: Add comment for rndis_comp_hdr Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7738 305278 net/rndis: Define common message header for RNDIS messages. And avoid RNDIS_HEADER_OFFSET hardcoding. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7739 Modified: stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Mon Oct 17 07:46:13 2016 (r307495) +++ stable/11/sys/net/rndis.h Mon Oct 17 08:03:15 2016 (r307496) @@ -93,6 +93,14 @@ #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 /* + * Common RNDIS message header. + */ +struct rndis_msghdr { + uint32_t rm_type; + uint32_t rm_len; +}; + +/* * RNDIS data message */ #define REMOTE_NDIS_PACKET_MSG 0x00000001 @@ -147,6 +155,12 @@ struct rndis_pktinfo { /* * RNDIS control messages */ + +/* + * Common header for RNDIS completion messages. + * + * NOTE: It does not apply to REMOTE_NDIS_RESET_CMPLT. + */ struct rndis_comp_hdr { uint32_t rm_type; uint32_t rm_len; @@ -316,7 +330,7 @@ struct rndis_keepalive_comp { #define NDIS_PACKET_TYPE_MAC_FRAME 0x00008000 /* RNDIS offsets */ -#define RNDIS_HEADER_OFFSET 8 /* bytes */ +#define RNDIS_HEADER_OFFSET ((uint32_t)sizeof(struct rndis_msghdr)) #define RNDIS_DATA_OFFSET \ ((uint32_t)(sizeof(struct rndis_packet_msg) - RNDIS_HEADER_OFFSET)) From owner-svn-src-stable@freebsd.org Mon Oct 17 08:06:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43B7DC15AFD; Mon, 17 Oct 2016 08:06:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 12CCA100B; Mon, 17 Oct 2016 08:06:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H86K0t025149; Mon, 17 Oct 2016 08:06:20 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H86Jet025145; Mon, 17 Oct 2016 08:06:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170806.u9H86Jet025145@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:06:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307497 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:06:21 -0000 Author: sephe Date: Mon Oct 17 08:06:19 2016 New Revision: 307497 URL: https://svnweb.freebsd.org/changeset/base/307497 Log: MFC 305279-305281 305279 hyperv/ic: Minor style fix. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7743 305280 hyperv/ic: Cleanup shutdown channel callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7744 305281 hyperv/ic: Cleanup timesync channel callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7745 Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 08:03:15 2016 (r307496) +++ stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Oct 17 08:06:19 2016 (r307497) @@ -69,7 +69,7 @@ vmbus_heartbeat_cb(struct vmbus_channel if (error) return; - if (dlen < sizeof(struct vmbus_icmsg_hdr)) { + if (dlen < sizeof(*hdr)) { device_printf(sc->ic_dev, "invalid data len %d\n", dlen); return; } Modified: stable/11/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 08:03:15 2016 (r307496) +++ stable/11/sys/dev/hyperv/utilities/hv_shutdown.c Mon Oct 17 08:06:19 2016 (r307497) @@ -22,28 +22,23 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ -/* - * A common driver for all hyper-V util services. - */ +#include +__FBSDID("$FreeBSD$"); #include -#include #include -#include +#include #include #include -#include -#include #include #include #include -#include -#include "hv_util.h" +#include +#include + #include "vmbus_if.h" static const struct vmbus_ic_desc vmbus_shutdown_descs[] = { @@ -56,73 +51,78 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; -/** - * Shutdown - */ static void -hv_shutdown_cb(struct vmbus_channel *channel, void *context) +vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) { - uint8_t* buf; - uint8_t execute_shutdown = 0; - hv_vmbus_icmsg_hdr* icmsghdrp; - uint32_t recv_len; - uint64_t request_id; - int ret; - hv_vmbus_shutdown_msg_data* shutdown_msg; - hv_util_sc *softc; - - softc = (hv_util_sc*)context; - buf = softc->receive_buffer; - - recv_len = softc->ic_buflen; - ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id); - KASSERT(ret != ENOBUFS, ("hvshutdown recvbuf is not large enough")); - /* XXX check recv_len to make sure that it contains enough data */ - - if ((ret == 0) && recv_len > 0) { - - icmsghdrp = (struct hv_vmbus_icmsg_hdr *) - &buf[sizeof(struct hv_vmbus_pipe_hdr)]; - - if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - int error; + struct hv_util_sc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + struct vmbus_icmsg_shutdown *msg; + int dlen, error, do_shutdown = 0; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->receive_buffer; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; + + if (dlen < sizeof(*hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; - error = vmbus_ic_negomsg(softc, buf, &recv_len); + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen); if (error) return; - } else { - shutdown_msg = - (struct hv_vmbus_shutdown_msg_data *) - &buf[sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - - switch (shutdown_msg->flags) { - case 0: - case 1: - icmsghdrp->status = HV_S_OK; - execute_shutdown = 1; - if(bootverbose) - printf("Shutdown request received -" - " graceful shutdown initiated\n"); - break; - default: - icmsghdrp->status = HV_E_FAIL; - execute_shutdown = 0; - printf("Shutdown request received -" - " Invalid request\n"); - break; - } - } + break; - icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | - HV_ICMSGHDRFLAG_RESPONSE; + case VMBUS_ICMSG_TYPE_SHUTDOWN: + if (dlen < VMBUS_ICMSG_SHUTDOWN_SIZE_MIN) { + device_printf(sc->ic_dev, "invalid shutdown len %d\n", + dlen); + return; + } + msg = data; - vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, - buf, recv_len, request_id); + /* XXX ic_flags definition? */ + if (msg->ic_haltflags == 0 || msg->ic_haltflags == 1) { + device_printf(sc->ic_dev, "shutdown requested\n"); + hdr->ic_status = VMBUS_ICMSG_STATUS_OK; + do_shutdown = 1; + } else { + device_printf(sc->ic_dev, "unknown shutdown flags " + "0x%08x\n", msg->ic_haltflags); + hdr->ic_status = VMBUS_ICMSG_STATUS_FAIL; + } + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; } - if (execute_shutdown) - shutdown_nice(RB_POWEROFF); + /* + * Send response by echoing the updated request back. + */ + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); + + if (do_shutdown) + shutdown_nice(RB_POWEROFF); } static int @@ -135,7 +135,8 @@ hv_shutdown_probe(device_t dev) static int hv_shutdown_attach(device_t dev) { - return hv_util_attach(dev, hv_shutdown_cb); + + return (hv_util_attach(dev, vmbus_shutdown_cb)); } static device_method_t shutdown_methods[] = { Modified: stable/11/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 08:03:15 2016 (r307496) +++ stable/11/sys/dev/hyperv/utilities/hv_timesync.c Mon Oct 17 08:06:19 2016 (r307497) @@ -22,37 +22,25 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ -/* - * A common driver for all hyper-V util services. - */ +#include +__FBSDID("$FreeBSD$"); #include -#include #include -#include +#include #include -#include -#include #include -#include #include +#include #include #include -#include -#include "hv_util.h" -#include "vmbus_if.h" +#include +#include -#define HV_WLTIMEDELTA 116444736000000000L /* in 100ns unit */ -#define HV_ICTIMESYNCFLAG_PROBE 0 -#define HV_ICTIMESYNCFLAG_SYNC 1 -#define HV_ICTIMESYNCFLAG_SAMPLE 2 -#define HV_NANO_SEC_PER_SEC 1000000000 -#define HV_NANO_SEC_PER_MILLI_SEC 1000000 +#include "vmbus_if.h" static const struct vmbus_ic_desc vmbus_timesync_descs[] = { { @@ -64,135 +52,144 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; -struct hv_ictimesync_data { - uint64_t parenttime; - uint64_t childtime; - uint64_t roundtriptime; - uint8_t flags; -} __packed; - -/* - * Globals - */ SYSCTL_NODE(_hw, OID_AUTO, hvtimesync, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, "Hyper-V timesync interface"); -/* Ignore the sync request when set to 1. */ -static int ignore_sync_req = 0; -SYSCTL_INT(_hw_hvtimesync, OID_AUTO, ignore_sync_req, CTLFLAG_RWTUN, - &ignore_sync_req, 0, - "Ignore the sync request when set to 1."); +static int vmbus_ts_ignore_sync = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, ignore_sync, CTLFLAG_RWTUN, + &vmbus_ts_ignore_sync, 0, "Ignore the sync request."); /* * Trigger sample sync when drift exceeds threshold (ms). * Ignore the sample request when set to 0. */ -static int sample_drift = 100; -SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_drift, CTLFLAG_RWTUN, - &sample_drift, 0, - "Threshold that makes sample request trigger the sync."); - -/** - * @brief Synchronize time with host after reboot, restore, etc. - * - * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM. - * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time - * message after the timesync channel is opened. Since the hv_utils module is - * loaded after hv_vmbus, the first message is usually missed. The other - * thing is, systime is automatically set to emulated hardware clock which may - * not be UTC time or in the same time zone. So, to override these effects, we - * use the first 50 time samples for initial system time setting. - */ -static inline -void hv_adj_guesttime(hv_util_sc *sc, uint64_t hosttime, uint8_t flags) +static int vmbus_ts_sample_thresh = 100; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_thresh, CTLFLAG_RWTUN, + &vmbus_ts_sample_thresh, 0, + "Threshold that makes sample request trigger the sync (unit: ms)."); + +static int vmbus_ts_sample_verbose = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_verbose, CTLFLAG_RWTUN, + &vmbus_ts_sample_verbose, 0, "Increase sample request verbosity."); + +static void +vmbus_timesync(struct hv_util_sc *sc, uint64_t hvtime, uint8_t tsflags) { - struct timespec guest_ts, host_ts; - uint64_t host_tns, guest_tns; - int64_t diff; - int error; - - host_tns = (hosttime - HV_WLTIMEDELTA) * 100; - host_ts.tv_sec = (time_t)(host_tns/HV_NANO_SEC_PER_SEC); - host_ts.tv_nsec = (long)(host_tns%HV_NANO_SEC_PER_SEC); + struct timespec vm_ts; + uint64_t hv_ns, vm_ns; - nanotime(&guest_ts); - guest_tns = guest_ts.tv_sec * HV_NANO_SEC_PER_SEC + guest_ts.tv_nsec; + hv_ns = (hvtime - VMBUS_ICMSG_TS_BASE) * VMBUS_ICMSG_TS_FACTOR; + nanotime(&vm_ts); + vm_ns = (vm_ts.tv_sec * NANOSEC) + vm_ts.tv_nsec; + + if ((tsflags & VMBUS_ICMSG_TS_FLAG_SYNC) && !vmbus_ts_ignore_sync) { + struct timespec hv_ts; - if ((flags & HV_ICTIMESYNCFLAG_SYNC) != 0 && ignore_sync_req == 0) { if (bootverbose) { - device_printf(sc->ic_dev, "handle sync request " - "{host: %ju, guest: %ju}\n", - (uintmax_t)host_tns, (uintmax_t)guest_tns); + device_printf(sc->ic_dev, "apply sync request, " + "hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); } - - error = kern_clock_settime(curthread, CLOCK_REALTIME, - &host_ts); + hv_ts.tv_sec = hv_ns / NANOSEC; + hv_ts.tv_nsec = hv_ns % NANOSEC; + kern_clock_settime(curthread, CLOCK_REALTIME, &hv_ts); + /* Done! */ return; } - if ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0 && sample_drift != 0) { - if (bootverbose) { - device_printf(sc->ic_dev, "handle sample request " - "{host: %ju, guest: %ju}\n", - (uintmax_t)host_tns, (uintmax_t)guest_tns); + if ((tsflags & VMBUS_ICMSG_TS_FLAG_SAMPLE) && + vmbus_ts_sample_thresh > 0) { + int64_t diff; + + if (vmbus_ts_sample_verbose) { + device_printf(sc->ic_dev, "sample request, " + "hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); } - diff = (int64_t)(host_tns - guest_tns) / HV_NANO_SEC_PER_MILLI_SEC; - if (diff > sample_drift || diff < -sample_drift) { - error = kern_clock_settime(curthread, CLOCK_REALTIME, - &host_ts); - if (bootverbose) - device_printf(sc->ic_dev, "trigger sample sync"); + if (hv_ns > vm_ns) + diff = hv_ns - vm_ns; + else + diff = vm_ns - hv_ns; + /* nanosec -> millisec */ + diff /= 1000000; + + if (diff > vmbus_ts_sample_thresh) { + struct timespec hv_ts; + + if (bootverbose) { + device_printf(sc->ic_dev, + "apply sample request, hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); + } + hv_ts.tv_sec = hv_ns / NANOSEC; + hv_ts.tv_nsec = hv_ns % NANOSEC; + kern_clock_settime(curthread, CLOCK_REALTIME, &hv_ts); } + /* Done */ return; } } -/** - * Time Sync Channel message handler - */ static void -hv_timesync_cb(struct vmbus_channel *channel, void *context) +vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) { - hv_vmbus_icmsg_hdr* icmsghdrp; - uint32_t recvlen; - uint64_t requestId; - int ret; - uint8_t* time_buf; - struct hv_ictimesync_data* timedatap; - hv_util_sc *softc; - - softc = (hv_util_sc*)context; - time_buf = softc->receive_buffer; - - recvlen = softc->ic_buflen; - ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); - KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); - /* XXX check recvlen to make sure that it contains enough data */ - - if ((ret == 0) && recvlen > 0) { - icmsghdrp = (struct hv_vmbus_icmsg_hdr *) &time_buf[ - sizeof(struct hv_vmbus_pipe_hdr)]; + struct hv_util_sc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + const struct vmbus_icmsg_timesync *msg; + int dlen, error; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->receive_buffer; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; - if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - int error; + if (dlen < sizeof(*hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; - error = vmbus_ic_negomsg(softc, time_buf, &recvlen); + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen); if (error) return; - } else { - timedatap = (struct hv_ictimesync_data *) &time_buf[ - sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - hv_adj_guesttime(softc, timedatap->parenttime, timedatap->flags); - } + break; - icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION - | HV_ICMSGHDRFLAG_RESPONSE; - - vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, - time_buf, recvlen, requestId); + case VMBUS_ICMSG_TYPE_TIMESYNC: + if (dlen < sizeof(*msg)) { + device_printf(sc->ic_dev, "invalid timesync len %d\n", + dlen); + return; + } + msg = data; + vmbus_timesync(sc, msg->ic_hvtime, msg->ic_tsflags); + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; } + + /* + * Send response by echoing the updated request back. + */ + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); } static int @@ -205,20 +202,15 @@ hv_timesync_probe(device_t dev) static int hv_timesync_attach(device_t dev) { - return hv_util_attach(dev, hv_timesync_cb); -} -static int -hv_timesync_detach(device_t dev) -{ - return hv_util_detach(dev); + return (hv_util_attach(dev, vmbus_timesync_cb)); } static device_method_t timesync_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_timesync_probe), DEVMETHOD(device_attach, hv_timesync_attach), - DEVMETHOD(device_detach, hv_timesync_detach), + DEVMETHOD(device_detach, hv_util_detach), { 0, 0 } }; Modified: stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h ============================================================================== --- stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h Mon Oct 17 08:03:15 2016 (r307496) +++ stable/11/sys/dev/hyperv/utilities/vmbus_icreg.h Mon Oct 17 08:06:19 2016 (r307497) @@ -91,4 +91,35 @@ struct vmbus_icmsg_heartbeat { #define VMBUS_ICMSG_HEARTBEAT_SIZE_MIN \ __offsetof(struct vmbus_icmsg_heartbeat, ic_rsvd[0]) +/* VMBUS_ICMSG_TYPE_SHUTDOWN */ +struct vmbus_icmsg_shutdown { + struct vmbus_icmsg_hdr ic_hdr; + uint32_t ic_code; + uint32_t ic_timeo; + uint32_t ic_haltflags; + uint8_t ic_msg[2048]; +} __packed; + +#define VMBUS_ICMSG_SHUTDOWN_SIZE_MIN \ + __offsetof(struct vmbus_icmsg_shutdown, ic_msg[0]) + +/* VMBUS_ICMSG_TYPE_TIMESYNC */ +struct vmbus_icmsg_timesync { + struct vmbus_icmsg_hdr ic_hdr; + uint64_t ic_hvtime; + uint64_t ic_vmtime; + uint64_t ic_rtt; + uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ +} __packed; + +#define VMBUS_ICMSG_TS_FLAG_SYNC 0x01 +#define VMBUS_ICMSG_TS_FLAG_SAMPLE 0x02 + +/* XXX consolidate w/ hyperv */ +#define VMBUS_ICMSG_TS_BASE 116444736000000000ULL +#define VMBUS_ICMSG_TS_FACTOR 100ULL +#ifndef NANOSEC +#define NANOSEC 1000000000ULL +#endif + #endif /* !_VMBUS_ICREG_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 08:10:25 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAF50C15BB4; Mon, 17 Oct 2016 08:10:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A6B6711CC; Mon, 17 Oct 2016 08:10:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8AOC7025390; Mon, 17 Oct 2016 08:10:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8AOHm025384; Mon, 17 Oct 2016 08:10:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170810.u9H8AOHm025384@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:10:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307498 - in stable/11/sys: dev/hyperv/netvsc dev/hyperv/vmbus net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:10:26 -0000 Author: sephe Date: Mon Oct 17 08:10:24 2016 New Revision: 307498 URL: https://svnweb.freebsd.org/changeset/base/307498 Log: MFC 305405,305407,305408,305410,305411,305453 305405 hyperv/vmbus: Stringent header length and total length check. While I'm here, minor style changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7752 305407 hyperv/hn: Stringent NVS notification length check. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7753 305408 hyperv/hn: Stringent NVS RNDIS packets length checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7755 305410 net/rndis: Define RNDIS status message, which could be sent by device. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7757 305411 hyperv/hn: Stringent RNDIS control message length check. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7758 305453 hyperv/hn: Stringent RNDIS packet message length/offset check. While I'm here, use definition in net/rndis.h Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7782 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:06:19 2016 (r307497) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:10:24 2016 (r307498) @@ -742,32 +742,53 @@ hv_nv_on_receive(struct hn_softc *sc, st { const struct vmbus_chanpkt_rxbuf *pkt; const struct hn_nvs_hdr *nvs_hdr; - int count = 0; - int i = 0; + int count, i, hlen; - /* Make sure that this is a RNDIS message. */ + if (__predict_false(VMBUS_CHANPKT_DATALEN(pkthdr) < sizeof(*nvs_hdr))) { + if_printf(rxr->hn_ifp, "invalid nvs RNDIS\n"); + return; + } nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); + + /* Make sure that this is a RNDIS message. */ if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", nvs_hdr->nvs_type); return; } - + + hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); + if (__predict_false(hlen < sizeof(*pkt))) { + if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); + return; + } pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { - if_printf(rxr->hn_ifp, "rxbuf_id %d is invalid!\n", + if (__predict_false(pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID)) { + if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", pkt->cp_rxbuf_id); return; } count = pkt->cp_rxbuf_cnt; + if (__predict_false(hlen < + __offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { + if_printf(rxr->hn_ifp, "invalid rxbuf_cnt %d\n", count); + return; + } /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ - for (i = 0; i < count; i++) { - hv_rf_on_receive(sc, rxr, - rxr->hn_rxbuf + pkt->cp_rxbuf[i].rb_ofs, - pkt->cp_rxbuf[i].rb_len); + for (i = 0; i < count; ++i) { + int ofs, len; + + ofs = pkt->cp_rxbuf[i].rb_ofs; + len = pkt->cp_rxbuf[i].rb_len; + if (__predict_false(ofs + len > NETVSC_RECEIVE_BUFFER_SIZE)) { + if_printf(rxr->hn_ifp, "%dth RNDIS msg overflow rxbuf, " + "ofs %d, len %d\n", i, ofs, len); + continue; + } + hv_rf_on_receive(sc, rxr, rxr->hn_rxbuf + ofs, len); } /* @@ -816,7 +837,12 @@ hn_proc_notify(struct hn_softc *sc, cons { const struct hn_nvs_hdr *hdr; + if (VMBUS_CHANPKT_DATALEN(pkt) < sizeof(*hdr)) { + if_printf(sc->hn_ifp, "invalid nvs notify\n"); + return; + } hdr = VMBUS_CHANPKT_CONST_DATA(pkt); + if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { /* Useless; ignore */ return; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:06:19 2016 (r307497) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:10:24 2016 (r307498) @@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$"); * Forward declarations */ static void hv_rf_receive_indicate_status(struct hn_softc *sc, - const rndis_msg *response); + const void *data, int dlen); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); @@ -131,59 +131,50 @@ hv_set_rppi_data(rndis_msg *rndis_mesg, * RNDIS filter receive indicate status */ static void -hv_rf_receive_indicate_status(struct hn_softc *sc, const rndis_msg *response) +hv_rf_receive_indicate_status(struct hn_softc *sc, const void *data, int dlen) { - const rndis_indicate_status *indicate = &response->msg.indicate_status; - - switch(indicate->status) { + const struct rndis_status_msg *msg; + + if (dlen < sizeof(*msg)) { + if_printf(sc->hn_ifp, "invalid RNDIS status\n"); + return; + } + msg = data; + + switch (msg->rm_status) { case RNDIS_STATUS_MEDIA_CONNECT: netvsc_linkstatus_callback(sc, 1); break; + case RNDIS_STATUS_MEDIA_DISCONNECT: netvsc_linkstatus_callback(sc, 0); break; + default: /* TODO: */ - if_printf(sc->hn_ifp, - "unknown status %d received\n", indicate->status); + if_printf(sc->hn_ifp, "unknown RNDIS status 0x%08x\n", + msg->rm_status); break; } } static int -hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hn_recvinfo *info) +hn_rndis_rxinfo(const void *info_data, int info_dlen, struct hn_recvinfo *info) { - const struct rndis_pktinfo *pi; - uint32_t mask = 0, len; - - info->vlan_info = HN_NDIS_VLAN_INFO_INVALID; - info->csum_info = HN_NDIS_RXCSUM_INFO_INVALID; - info->hash_info = HN_NDIS_HASH_INFO_INVALID; - - if (rpkt->per_pkt_info_offset == 0) - return (0); - if (__predict_false(rpkt->per_pkt_info_offset & - (RNDIS_PKTINFO_ALIGN - 1))) - return (EINVAL); - if (__predict_false(rpkt->per_pkt_info_offset < - RNDIS_PACKET_MSG_OFFSET_MIN)) - return (EINVAL); + const struct rndis_pktinfo *pi = info_data; + uint32_t mask = 0; - pi = (const struct rndis_pktinfo *) - ((const uint8_t *)rpkt + rpkt->per_pkt_info_offset); - len = rpkt->per_pkt_info_length; - - while (len != 0) { + while (info_dlen != 0) { const void *data; uint32_t dlen; - if (__predict_false(len < sizeof(*pi))) + if (__predict_false(info_dlen < sizeof(*pi))) return (EINVAL); - if (__predict_false(len < pi->rm_size)) + if (__predict_false(info_dlen < pi->rm_size)) return (EINVAL); - len -= pi->rm_size; + info_dlen -= pi->rm_size; - if (__predict_false(pi->rm_size & (RNDIS_PKTINFO_ALIGN - 1))) + if (__predict_false(pi->rm_size & RNDIS_PKTINFO_SIZE_ALIGNMASK)) return (EINVAL); if (__predict_false(pi->rm_size < pi->rm_pktinfooffset)) return (EINVAL); @@ -241,76 +232,223 @@ next: return (0); } +static __inline bool +hn_rndis_check_overlap(int off, int len, int check_off, int check_len) +{ + + if (off < check_off) { + if (__predict_true(off + len <= check_off)) + return (false); + } else if (off > check_off) { + if (__predict_true(check_off + check_len <= off)) + return (false); + } + return (true); +} + /* * RNDIS filter receive data */ static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen) { - const rndis_msg *message = data; - const rndis_packet *rndis_pkt; - uint32_t data_offset; + const struct rndis_packet_msg *pkt; struct hn_recvinfo info; - - rndis_pkt = &message->msg.packet; + int data_off, pktinfo_off, data_len, pktinfo_len; /* - * Fixme: Handle multiple rndis pkt msgs that may be enclosed in this - * netvsc packet (ie tot_data_buf_len != message_length) + * Check length. */ + if (__predict_false(dlen < sizeof(*pkt))) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg\n"); + return; + } + pkt = data; - /* Remove rndis header, then pass data packet up the stack */ - data_offset = RNDIS_HEADER_SIZE + rndis_pkt->data_offset; + if (__predict_false(dlen < pkt->rm_len)) { + if_printf(rxr->hn_ifp, "truncated RNDIS packet msg, " + "dlen %d, msglen %u\n", dlen, pkt->rm_len); + return; + } + if (__predict_false(pkt->rm_len < + pkt->rm_datalen + pkt->rm_oobdatalen + pkt->rm_pktinfolen)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msglen, " + "msglen %u, data %u, oob %u, pktinfo %u\n", + pkt->rm_len, pkt->rm_datalen, pkt->rm_oobdatalen, + pkt->rm_pktinfolen); + return; + } + if (__predict_false(pkt->rm_datalen == 0)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, no data\n"); + return; + } - dlen -= data_offset; - if (dlen < rndis_pkt->data_length) { - if_printf(rxr->hn_ifp, - "total length %u is less than data length %u\n", - dlen, rndis_pkt->data_length); + /* + * Check offests. + */ +#define IS_OFFSET_INVALID(ofs) \ + ((ofs) < RNDIS_PACKET_MSG_OFFSET_MIN || \ + ((ofs) & RNDIS_PACKET_MSG_OFFSET_ALIGNMASK)) + + /* XXX Hyper-V does not meet data offset alignment requirement */ + if (__predict_false(pkt->rm_dataoffset < RNDIS_PACKET_MSG_OFFSET_MIN)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "data offset %u\n", pkt->rm_dataoffset); + return; + } + if (__predict_false(pkt->rm_oobdataoffset > 0 && + IS_OFFSET_INVALID(pkt->rm_oobdataoffset))) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob offset %u\n", pkt->rm_oobdataoffset); + return; + } + if (__predict_true(pkt->rm_pktinfooffset > 0) && + __predict_false(IS_OFFSET_INVALID(pkt->rm_pktinfooffset))) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "pktinfo offset %u\n", pkt->rm_pktinfooffset); return; } - dlen = rndis_pkt->data_length; - data = (const uint8_t *)data + data_offset; +#undef IS_OFFSET_INVALID - if (hv_rf_find_recvinfo(rndis_pkt, &info)) { - if_printf(rxr->hn_ifp, "recvinfo parsing failed\n"); + data_off = RNDIS_PACKET_MSG_OFFSET_ABS(pkt->rm_dataoffset); + data_len = pkt->rm_datalen; + pktinfo_off = RNDIS_PACKET_MSG_OFFSET_ABS(pkt->rm_pktinfooffset); + pktinfo_len = pkt->rm_pktinfolen; + + /* + * Check OOB coverage. + */ + if (__predict_false(pkt->rm_oobdatalen != 0)) { + int oob_off, oob_len; + + if_printf(rxr->hn_ifp, "got oobdata\n"); + oob_off = RNDIS_PACKET_MSG_OFFSET_ABS(pkt->rm_oobdataoffset); + oob_len = pkt->rm_oobdatalen; + + if (__predict_false(oob_off + oob_len > pkt->rm_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob overflow, msglen %u, oob abs %d len %d\n", + pkt->rm_len, oob_off, oob_len); + return; + } + + /* + * Check against data. + */ + if (hn_rndis_check_overlap(oob_off, oob_len, + data_off, data_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob overlaps data, oob abs %d len %d, " + "data abs %d len %d\n", + oob_off, oob_len, data_off, data_len); + return; + } + + /* + * Check against pktinfo. + */ + if (pktinfo_len != 0 && + hn_rndis_check_overlap(oob_off, oob_len, + pktinfo_off, pktinfo_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob overlaps pktinfo, oob abs %d len %d, " + "pktinfo abs %d len %d\n", + oob_off, oob_len, pktinfo_off, pktinfo_len); + return; + } + } + + /* + * Check per-packet-info coverage and find useful per-packet-info. + */ + info.vlan_info = HN_NDIS_VLAN_INFO_INVALID; + info.csum_info = HN_NDIS_RXCSUM_INFO_INVALID; + info.hash_info = HN_NDIS_HASH_INFO_INVALID; + if (__predict_true(pktinfo_len != 0)) { + bool overlap; + int error; + + if (__predict_false(pktinfo_off + pktinfo_len > pkt->rm_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "pktinfo overflow, msglen %u, " + "pktinfo abs %d len %d\n", + pkt->rm_len, pktinfo_off, pktinfo_len); + return; + } + + /* + * Check packet info coverage. + */ + overlap = hn_rndis_check_overlap(pktinfo_off, pktinfo_len, + data_off, data_len); + if (__predict_false(overlap)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "pktinfo overlap data, pktinfo abs %d len %d, " + "data abs %d len %d\n", + pktinfo_off, pktinfo_len, data_off, data_len); + return; + } + + /* + * Find useful per-packet-info. + */ + error = hn_rndis_rxinfo(((const uint8_t *)pkt) + pktinfo_off, + pktinfo_len, &info); + if (__predict_false(error)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg " + "pktinfo\n"); + return; + } + } + + if (__predict_false(data_off + data_len > pkt->rm_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "data overflow, msglen %u, data abs %d len %d\n", + pkt->rm_len, data_off, data_len); return; } - netvsc_recv(rxr, data, dlen, &info); + netvsc_recv(rxr, ((const uint8_t *)pkt) + data_off, data_len, &info); } /* * RNDIS filter on receive */ -int +void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen) { - const rndis_msg *rndis_hdr; const struct rndis_comp_hdr *comp; + const struct rndis_msghdr *hdr; + + if (__predict_false(dlen < sizeof(*hdr))) { + if_printf(rxr->hn_ifp, "invalid RNDIS msg\n"); + return; + } + hdr = data; - rndis_hdr = data; - switch (rndis_hdr->ndis_msg_type) { - /* data message */ + switch (hdr->rm_type) { case REMOTE_NDIS_PACKET_MSG: hv_rf_receive_data(rxr, data, dlen); break; - /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_SET_CMPLT: - case REMOTE_NDIS_KEEPALIVE_CMPLT: + case REMOTE_NDIS_KEEPALIVE_CMPLT: /* unused */ + if (dlen < sizeof(*comp)) { + if_printf(rxr->hn_ifp, "invalid RNDIS cmplt\n"); + return; + } comp = data; + KASSERT(comp->rm_rid > HN_RNDIS_RID_COMPAT_MAX, - ("invalid rid 0x%08x\n", comp->rm_rid)); + ("invalid RNDIS rid 0x%08x\n", comp->rm_rid)); vmbus_xact_ctx_wakeup(sc->hn_xact, comp, dlen); break; - /* notification message */ case REMOTE_NDIS_INDICATE_STATUS_MSG: - hv_rf_receive_indicate_status(sc, rndis_hdr); + hv_rf_receive_indicate_status(sc, data, dlen); break; case REMOTE_NDIS_RESET_CMPLT: @@ -321,15 +459,14 @@ hv_rf_on_receive(struct hn_softc *sc, st * RESET is not issued by hn(4), so this message should * _not_ be observed. */ - if_printf(sc->hn_ifp, "RESET CMPLT received\n"); + if_printf(rxr->hn_ifp, "RESET cmplt received\n"); break; default: - if_printf(sc->hn_ifp, "unknown RNDIS message 0x%x\n", - rndis_hdr->ndis_msg_type); + if_printf(rxr->hn_ifp, "unknown RNDIS msg 0x%x\n", + hdr->rm_type); break; } - return (0); } /* @@ -551,7 +688,7 @@ hn_rndis_query(struct hn_softc *sc, uint * Check output data length and offset. */ /* ofs is the offset from the beginning of comp. */ - ofs = RNDIS_QUERY_COMP_INFOBUFABS(comp->rm_infobufoffset); + ofs = RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(comp->rm_infobufoffset); if (ofs < sizeof(*comp) || ofs + comp->rm_infobuflen > comp_len) { if_printf(sc->hn_ifp, "RNDIS query invalid comp ib off/len, " "%u/%u\n", comp->rm_infobufoffset, comp->rm_infobuflen); Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 08:06:19 2016 (r307497) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 08:10:24 2016 (r307498) @@ -40,7 +40,7 @@ */ struct hn_rx_ring; -int hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, +void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan, Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 08:06:19 2016 (r307497) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 08:10:24 2016 (r307498) @@ -721,7 +721,20 @@ vmbus_chan_recv(struct vmbus_channel *ch error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) - return error; + return (error); + + if (__predict_false(pkt.cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { + device_printf(chan->ch_dev, "invalid hlen %u\n", + pkt.cph_hlen); + /* XXX this channel is dead actually. */ + return (EIO); + } + if (__predict_false(pkt.cph_hlen > pkt.cph_tlen)) { + device_printf(chan->ch_dev, "invalid hlen %u and tlen %u\n", + pkt.cph_hlen, pkt.cph_tlen); + /* XXX this channel is dead actually. */ + return (EIO); + } hlen = VMBUS_CHANPKT_GETLEN(pkt.cph_hlen); dlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen) - hlen; @@ -729,7 +742,7 @@ vmbus_chan_recv(struct vmbus_channel *ch if (*dlen0 < dlen) { /* Return the size of this packet's data. */ *dlen0 = dlen; - return ENOBUFS; + return (ENOBUFS); } *xactid = pkt.cph_xactid; @@ -739,7 +752,7 @@ vmbus_chan_recv(struct vmbus_channel *ch error = vmbus_rxbr_read(&chan->ch_rxbr, data, dlen, hlen); KASSERT(!error, ("vmbus_rxbr_read failed")); - return 0; + return (0); } int @@ -751,13 +764,26 @@ vmbus_chan_recv_pkt(struct vmbus_channel error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) - return error; + return (error); + + if (__predict_false(pkt.cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { + device_printf(chan->ch_dev, "invalid hlen %u\n", + pkt.cph_hlen); + /* XXX this channel is dead actually. */ + return (EIO); + } + if (__predict_false(pkt.cph_hlen > pkt.cph_tlen)) { + device_printf(chan->ch_dev, "invalid hlen %u and tlen %u\n", + pkt.cph_hlen, pkt.cph_tlen); + /* XXX this channel is dead actually. */ + return (EIO); + } pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); if (*pktlen0 < pktlen) { /* Return the size of this packet. */ *pktlen0 = pktlen; - return ENOBUFS; + return (ENOBUFS); } *pktlen0 = pktlen; @@ -765,7 +791,7 @@ vmbus_chan_recv_pkt(struct vmbus_channel error = vmbus_rxbr_read(&chan->ch_rxbr, pkt0, pktlen, 0); KASSERT(!error, ("vmbus_rxbr_read failed")); - return 0; + return (0); } static void Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 08:06:19 2016 (r307497) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Oct 17 08:10:24 2016 (r307498) @@ -153,6 +153,9 @@ do { \ #define VMBUS_CHANPKT_TOTLEN(tlen) \ roundup2((tlen), VMBUS_CHANPKT_SIZE_ALIGN) +#define VMBUS_CHANPKT_HLEN_MIN \ + (sizeof(struct vmbus_chanpkt_hdr) >> VMBUS_CHANPKT_SIZE_SHIFT) + struct vmbus_chanpkt { struct vmbus_chanpkt_hdr cp_hdr; } __packed; Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Mon Oct 17 08:06:19 2016 (r307497) +++ stable/11/sys/net/rndis.h Mon Oct 17 08:10:24 2016 (r307498) @@ -127,6 +127,14 @@ struct rndis_packet_msg { (sizeof(struct rndis_packet_msg) - \ __offsetof(struct rndis_packet_msg, rm_dataoffset)) +/* Offset from the beginning of rndis_packet_msg. */ +#define RNDIS_PACKET_MSG_OFFSET_ABS(ofs) \ + ((ofs) + __offsetof(struct rndis_packet_msg, rm_dataoffset)) + +#define RNDIS_PACKET_MSG_OFFSET_ALIGN 4 +#define RNDIS_PACKET_MSG_OFFSET_ALIGNMASK \ + (RNDIS_PACKET_MSG_OFFSET_ALIGN - 1) + /* Per-packet-info for RNDIS data message */ struct rndis_pktinfo { uint32_t rm_size; @@ -137,7 +145,8 @@ struct rndis_pktinfo { #define RNDIS_PKTINFO_OFFSET \ __offsetof(struct rndis_pktinfo, rm_data[0]) -#define RNDIS_PKTINFO_ALIGN 4 +#define RNDIS_PKTINFO_SIZE_ALIGN 4 +#define RNDIS_PKTINFO_SIZE_ALIGNMASK (RNDIS_PKTINFO_SIZE_ALIGN - 1) #define NDIS_PKTINFO_TYPE_CSUM 0 #define NDIS_PKTINFO_TYPE_IPSEC 1 @@ -236,7 +245,8 @@ struct rndis_query_comp { uint32_t rm_infobufoffset; }; -#define RNDIS_QUERY_COMP_INFOBUFABS(ofs) \ +/* infobuf offset from the beginning of rndis_query_comp. */ +#define RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(ofs) \ ((ofs) + __offsetof(struct rndis_query_req, rm_rid)) /* Send a set object request. */ @@ -295,9 +305,28 @@ struct rndis_reset_comp { uint32_t rm_adrreset; }; -/* 802.3 link-state or undefined message error. */ +/* 802.3 link-state or undefined message error. Sent by device. */ #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 +struct rndis_status_msg { + uint32_t rm_type; + uint32_t rm_len; + uint32_t rm_status; + uint32_t rm_stbuflen; + uint32_t rm_stbufoffset; + /* rndis_diag_info */ +}; + +/* + * Immediately after rndis_status_msg.rm_stbufoffset, if a control + * message is malformatted, or a packet message contains inappropriate + * content. + */ +struct rndis_diag_info { + uint32_t rm_diagstatus; + uint32_t rm_erroffset; +}; + /* Keepalive messsage. May be sent by device. */ #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 From owner-svn-src-stable@freebsd.org Mon Oct 17 08:16:28 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB1A2C15D70; Mon, 17 Oct 2016 08:16:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8EF4417BE; Mon, 17 Oct 2016 08:16:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8GRuF029225; Mon, 17 Oct 2016 08:16:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8GRK8029218; Mon, 17 Oct 2016 08:16:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170816.u9H8GRK8029218@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:16:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307500 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:16:28 -0000 Author: sephe Date: Mon Oct 17 08:16:26 2016 New Revision: 307500 URL: https://svnweb.freebsd.org/changeset/base/307500 Log: MFC 305454,305455,305521,305524-305526 305454 hyperv/hn: Fix VLAN tag setup for outgoing VLAN packets. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7785 305455 hyperv/hn: Avoid bit fields for LSOv2 setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7786 305521 hyperv/hn: Avoid bit fields for TXCSUM setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7792 305524 hyperv/hn: Cleanup RNDIS packet message encapsulation. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7793 305525 hyperv/hn: Simplify per-packet-info construction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7794 305526 hyperv/hn: Nuke unused bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7795 Deleted: stable/11/sys/dev/hyperv/netvsc/hv_rndis.h Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnreg.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/dev/hyperv/netvsc/ndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:14:23 2016 (r307499) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:16:26 2016 (r307500) @@ -48,9 +48,9 @@ #include #include #include -#include #include #include +#include MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); @@ -513,15 +513,15 @@ hv_nv_connect_to_vsp(struct hn_softc *sc for (i = protocol_number - 1; i >= 0; i--) { if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { sc->hn_nvs_ver = protocol_list[i]; - sc->hn_ndis_ver = NDIS_VERSION_6_30; + sc->hn_ndis_ver = HN_NDIS_VERSION_6_30; if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) - sc->hn_ndis_ver = NDIS_VERSION_6_1; + sc->hn_ndis_ver = HN_NDIS_VERSION_6_1; if (bootverbose) { if_printf(sc->hn_ifp, "NVS version 0x%x, " "NDIS version %u.%u\n", sc->hn_nvs_ver, - NDIS_VERSION_MAJOR(sc->hn_ndis_ver), - NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } break; } @@ -547,8 +547,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc memset(&ndis, 0, sizeof(ndis)); ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; - ndis.nvs_ndis_major = NDIS_VERSION_MAJOR(sc->hn_ndis_ver); - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR(sc->hn_ndis_ver); + ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver); + ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver); /* NOTE: No response. */ ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); @@ -764,7 +764,7 @@ hv_nv_on_receive(struct hn_softc *sc, st } pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - if (__predict_false(pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID)) { + if (__predict_false(pkt->cp_rxbuf_id != HN_NVS_RXBUF_SIG)) { if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", pkt->cp_rxbuf_id); return; Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:14:23 2016 (r307499) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:16:26 2016 (r307500) @@ -74,110 +74,6 @@ MALLOC_DECLARE(M_NETVSC); #define NVSP_PROTOCOL_VERSION_2 0x30002 #define NVSP_PROTOCOL_VERSION_4 0x40000 #define NVSP_PROTOCOL_VERSION_5 0x50000 -#define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1) -#define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2) - -#define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2 - -#define VERSION_4_OFFLOAD_SIZE 22 - -#define NVSP_OPERATIONAL_STATUS_OK (0x00000000) -#define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001) -#define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002) -#define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003) -#define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004) - -/* - * Maximun number of transfer pages (packets) the VSP will use on a receive - */ -#define NVSP_MAX_PACKETS_PER_RECEIVE 375 - -/* vRSS stuff */ -#define RNDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88 -#define RNDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89 - -#define RNDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2 -#define RNDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2 - -struct rndis_obj_header { - uint8_t type; - uint8_t rev; - uint16_t size; -} __packed; - -/* rndis_recv_scale_cap/cap_flag */ -#define RNDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x01000000 -#define RNDIS_RSS_CAPS_CLASSIFICATION_AT_ISR 0x02000000 -#define RNDIS_RSS_CAPS_CLASSIFICATION_AT_DPC 0x04000000 -#define RNDIS_RSS_CAPS_USING_MSI_X 0x08000000 -#define RNDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS 0x10000000 -#define RNDIS_RSS_CAPS_SUPPORTS_MSI_X 0x20000000 -#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4 0x00000100 -#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6 0x00000200 -#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX 0x00000400 - -/* RNDIS_RECEIVE_SCALE_CAPABILITIES */ -struct rndis_recv_scale_cap { - struct rndis_obj_header hdr; - uint32_t cap_flag; - uint32_t num_int_msg; - uint32_t num_recv_que; - uint16_t num_indirect_tabent; -} __packed; - -/* rndis_recv_scale_param flags */ -#define RNDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001 -#define RNDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED 0x0002 -#define RNDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED 0x0004 -#define RNDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008 -#define RNDIS_RSS_PARAM_FLAG_DISABLE_RSS 0x0010 - -/* Hash info bits */ -#define RNDIS_HASH_FUNC_TOEPLITZ 0x00000001 -#define RNDIS_HASH_IPV4 0x00000100 -#define RNDIS_HASH_TCP_IPV4 0x00000200 -#define RNDIS_HASH_IPV6 0x00000400 -#define RNDIS_HASH_IPV6_EX 0x00000800 -#define RNDIS_HASH_TCP_IPV6 0x00001000 -#define RNDIS_HASH_TCP_IPV6_EX 0x00002000 - -#define RNDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4) -#define RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 40 - -#define ITAB_NUM 128 -#define HASH_KEYLEN RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 - -/* RNDIS_RECEIVE_SCALE_PARAMETERS */ -typedef struct rndis_recv_scale_param_ { - struct rndis_obj_header hdr; - - /* Qualifies the rest of the information */ - uint16_t flag; - - /* The base CPU number to do receive processing. not used */ - uint16_t base_cpu_number; - - /* This describes the hash function and type being enabled */ - uint32_t hashinfo; - - /* The size of indirection table array */ - uint16_t indirect_tabsize; - - /* The offset of the indirection table from the beginning of this - * structure - */ - uint32_t indirect_taboffset; - - /* The size of the hash secret key */ - uint16_t hashkey_size; - - /* The offset of the secret key from the beginning of this structure */ - uint32_t hashkey_offset; - - uint32_t processor_masks_offset; - uint32_t num_processor_masks; - uint32_t processor_masks_entry_size; -} rndis_recv_scale_param; /* * The following arguably belongs in a separate header file @@ -188,18 +84,10 @@ typedef struct rndis_recv_scale_param_ { */ #define NETVSC_SEND_BUFFER_SIZE (1024*1024*15) /* 15M */ -#define NETVSC_SEND_BUFFER_ID 0xface #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15) /* 15MB */ #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */ -#define NETVSC_RECEIVE_BUFFER_ID 0xcafe - -#define NETVSC_RECEIVE_SG_COUNT 1 - -/* Preallocated receive packets */ -#define NETVSC_RECEIVE_PACKETLIST_COUNT 256 - /* * Maximum MTU we permit to be configured for a netvsc interface. * When the code was developed, a max MTU of 12232 was tested and @@ -208,7 +96,6 @@ typedef struct rndis_recv_scale_param_ { #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024) #define NETVSC_PACKET_SIZE PAGE_SIZE -#define VRSS_SEND_TABLE_SIZE 16 /* * Data types @@ -216,26 +103,9 @@ typedef struct rndis_recv_scale_param_ { struct vmbus_channel; -typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); - #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) #define NETVSC_PACKET_MAXPAGE 32 -#define NETVSC_VLAN_PRIO_MASK 0xe000 -#define NETVSC_VLAN_PRIO_SHIFT 13 -#define NETVSC_VLAN_VID_MASK 0x0fff - -#define TYPE_IPV4 2 -#define TYPE_IPV6 4 -#define TYPE_TCP 2 -#define TYPE_UDP 4 - -#define TRANSPORT_TYPE_NOT_IP 0 -#define TRANSPORT_TYPE_IPV4_TCP ((TYPE_IPV4 << 16) | TYPE_TCP) -#define TRANSPORT_TYPE_IPV4_UDP ((TYPE_IPV4 << 16) | TYPE_UDP) -#define TRANSPORT_TYPE_IPV6_TCP ((TYPE_IPV6 << 16) | TYPE_TCP) -#define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP) - typedef struct { uint8_t mac_addr[ETHER_ADDR_LEN]; uint32_t link_state; Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:14:23 2016 (r307499) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:16:26 2016 (r307500) @@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$"); #include #include #include - +#include #include #include @@ -118,7 +118,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -142,14 +141,14 @@ __FBSDID("$FreeBSD$"); #define HN_RING_CNT_DEF_MAX 8 -#define HN_RNDIS_MSG_LEN \ - (sizeof(rndis_msg) + \ - RNDIS_HASHVAL_PPI_SIZE + \ - RNDIS_VLAN_PPI_SIZE + \ - RNDIS_TSO_PPI_SIZE + \ - RNDIS_CSUM_PPI_SIZE) -#define HN_RNDIS_MSG_BOUNDARY PAGE_SIZE -#define HN_RNDIS_MSG_ALIGN CACHE_LINE_SIZE +#define HN_RNDIS_PKT_LEN \ + (sizeof(struct rndis_packet_msg) + \ + HN_RNDIS_PKTINFO_SIZE(HN_NDIS_HASH_VALUE_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_VLAN_INFO_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_LSO2_INFO_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_TXCSUM_INFO_SIZE)) +#define HN_RNDIS_PKT_BOUNDARY PAGE_SIZE +#define HN_RNDIS_PKT_ALIGN CACHE_LINE_SIZE #define HN_TX_DATA_BOUNDARY PAGE_SIZE #define HN_TX_DATA_MAXSIZE IP_MAXPACKET @@ -173,9 +172,9 @@ struct hn_txdesc { bus_dmamap_t data_dmap; - bus_addr_t rndis_msg_paddr; - rndis_msg *rndis_msg; - bus_dmamap_t rndis_msg_dmap; + bus_addr_t rndis_pkt_paddr; + struct rndis_packet_msg *rndis_pkt; + bus_dmamap_t rndis_pkt_dmap; }; #define HN_TXD_FLAG_ONLIST 0x1 @@ -827,7 +826,7 @@ hn_tx_done(struct hn_send_ctx *sndc, str } void -netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) +hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { #if defined(INET) || defined(INET6) tcp_lro_flush_all(&rxr->hn_lro); @@ -845,6 +844,15 @@ netvsc_channel_rollup(struct hn_rx_ring hn_txeof(txr); } +static __inline uint32_t +hn_rndis_pktmsg_offset(uint32_t ofs) +{ + + KASSERT(ofs >= sizeof(struct rndis_packet_msg), + ("invalid RNDIS packet msg offset %u", ofs)); + return (ofs - __offsetof(struct rndis_packet_msg, rm_dataoffset)); +} + /* * NOTE: * If this function fails, then both txd and m_head0 will be freed. @@ -855,14 +863,10 @@ hn_encap(struct hn_tx_ring *txr, struct bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i; struct mbuf *m_head = *m_head0; - rndis_msg *rndis_mesg; - rndis_packet *rndis_pkt; - rndis_per_packet_info *rppi; - struct rndis_hash_value *hash_value; - uint32_t rndis_msg_size, tot_data_buf_len, send_buf_section_idx; - int send_buf_section_size; - - tot_data_buf_len = m_head->m_pkthdr.len; + struct rndis_packet_msg *pkt; + uint32_t send_buf_section_idx; + int send_buf_section_size, pktlen; + uint32_t *pi_data; /* * extension points to the area reserved for the @@ -870,45 +874,34 @@ hn_encap(struct hn_tx_ring *txr, struct * the netvsc_packet (and rppi struct, if present; * length is updated later). */ - rndis_mesg = txd->rndis_msg; - /* XXX not necessary */ - memset(rndis_mesg, 0, HN_RNDIS_MSG_LEN); - rndis_mesg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; - - rndis_pkt = &rndis_mesg->msg.packet; - rndis_pkt->data_offset = sizeof(rndis_packet); - rndis_pkt->data_length = tot_data_buf_len; - rndis_pkt->per_pkt_info_offset = sizeof(rndis_packet); - - rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet); + pkt = txd->rndis_pkt; + pkt->rm_type = REMOTE_NDIS_PACKET_MSG; + pkt->rm_len = sizeof(*pkt) + m_head->m_pkthdr.len; + pkt->rm_dataoffset = sizeof(*pkt); + pkt->rm_datalen = m_head->m_pkthdr.len; + pkt->rm_pktinfooffset = sizeof(*pkt); + pkt->rm_pktinfolen = 0; /* * Set the hash value for this packet, so that the host could * dispatch the TX done event for this packet back to this TX * ring's channel. */ - rndis_msg_size += RNDIS_HASHVAL_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_HASHVAL_PPI_SIZE, - nbl_hash_value); - hash_value = (struct rndis_hash_value *)((uint8_t *)rppi + - rppi->per_packet_info_offset); - hash_value->hash_value = txr->hn_tx_idx; + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL); + *pi_data = txr->hn_tx_idx; if (m_head->m_flags & M_VLANTAG) { - ndis_8021q_info *rppi_vlan_info; - - rndis_msg_size += RNDIS_VLAN_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_VLAN_PPI_SIZE, - ieee_8021q_info); - - rppi_vlan_info = (ndis_8021q_info *)((uint8_t *)rppi + - rppi->per_packet_info_offset); - rppi_vlan_info->u1.s1.vlan_id = - m_head->m_pkthdr.ether_vtag & 0xfff; + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + NDIS_VLAN_INFO_SIZE, NDIS_PKTINFO_TYPE_VLAN); + *pi_data = NDIS_VLAN_INFO_MAKE( + EVL_VLANOFTAG(m_head->m_pkthdr.ether_vtag), + EVL_PRIOFTAG(m_head->m_pkthdr.ether_vtag), + EVL_CFIOFTAG(m_head->m_pkthdr.ether_vtag)); } if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { - rndis_tcp_tso_info *tso_info; +#if defined(INET6) || defined(INET) struct ether_vlan_header *eh; int ether_len; @@ -921,15 +914,8 @@ hn_encap(struct hn_tx_ring *txr, struct else ether_len = ETHER_HDR_LEN; - rndis_msg_size += RNDIS_TSO_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_TSO_PPI_SIZE, - tcp_large_send_info); - - tso_info = (rndis_tcp_tso_info *)((uint8_t *)rppi + - rppi->per_packet_info_offset); - tso_info->lso_v2_xmit.type = - RNDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE; - + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + NDIS_LSO2_INFO_SIZE, NDIS_PKTINFO_TYPE_LSO); #ifdef INET if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { struct ip *ip = @@ -938,13 +924,12 @@ hn_encap(struct hn_tx_ring *txr, struct struct tcphdr *th = (struct tcphdr *)((caddr_t)ip + iph_len); - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV4; ip->ip_len = 0; ip->ip_sum = 0; - th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(IPPROTO_TCP)); + *pi_data = NDIS_LSO2_INFO_MAKEIPV4(0, + m_head->m_pkthdr.tso_segsz); } #endif #if defined(INET6) && defined(INET) @@ -956,53 +941,47 @@ hn_encap(struct hn_tx_ring *txr, struct (m_head->m_data + ether_len); struct tcphdr *th = (struct tcphdr *)(ip6 + 1); - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV6; ip6->ip6_plen = 0; th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); + *pi_data = NDIS_LSO2_INFO_MAKEIPV6(0, + m_head->m_pkthdr.tso_segsz); } #endif - tso_info->lso_v2_xmit.tcp_header_offset = 0; - tso_info->lso_v2_xmit.mss = m_head->m_pkthdr.tso_segsz; +#endif /* INET6 || INET */ } else if (m_head->m_pkthdr.csum_flags & txr->hn_csum_assist) { - rndis_tcp_ip_csum_info *csum_info; - - rndis_msg_size += RNDIS_CSUM_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_CSUM_PPI_SIZE, - tcpip_chksum_info); - csum_info = (rndis_tcp_ip_csum_info *)((uint8_t *)rppi + - rppi->per_packet_info_offset); + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + NDIS_TXCSUM_INFO_SIZE, NDIS_PKTINFO_TYPE_CSUM); + *pi_data = NDIS_TXCSUM_INFO_IPV4; - csum_info->xmit.is_ipv4 = 1; if (m_head->m_pkthdr.csum_flags & CSUM_IP) - csum_info->xmit.ip_header_csum = 1; + *pi_data |= NDIS_TXCSUM_INFO_IPCS; - if (m_head->m_pkthdr.csum_flags & CSUM_TCP) { - csum_info->xmit.tcp_csum = 1; - csum_info->xmit.tcp_header_offset = 0; - } else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) { - csum_info->xmit.udp_csum = 1; - } + if (m_head->m_pkthdr.csum_flags & CSUM_TCP) + *pi_data |= NDIS_TXCSUM_INFO_TCPCS; + else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) + *pi_data |= NDIS_TXCSUM_INFO_UDPCS; } - rndis_mesg->msg_len = tot_data_buf_len + rndis_msg_size; - tot_data_buf_len = rndis_mesg->msg_len; + pktlen = pkt->rm_pktinfooffset + pkt->rm_pktinfolen; + /* Convert RNDIS packet message offsets */ + pkt->rm_dataoffset = hn_rndis_pktmsg_offset(pkt->rm_dataoffset); + pkt->rm_pktinfooffset = hn_rndis_pktmsg_offset(pkt->rm_pktinfooffset); /* * Chimney send, if the packet could fit into one chimney buffer. */ - if (tot_data_buf_len < txr->hn_chim_size) { + if (pkt->rm_len < txr->hn_chim_size) { txr->hn_tx_chimney_tried++; send_buf_section_idx = hn_chim_alloc(txr->hn_sc); if (send_buf_section_idx != HN_NVS_CHIM_IDX_INVALID) { uint8_t *dest = txr->hn_sc->hn_chim + (send_buf_section_idx * txr->hn_sc->hn_chim_szmax); - memcpy(dest, rndis_mesg, rndis_msg_size); - dest += rndis_msg_size; + memcpy(dest, pkt, pktlen); + dest += pktlen; m_copydata(m_head, 0, m_head->m_pkthdr.len, dest); - send_buf_section_size = tot_data_buf_len; + send_buf_section_size = pkt->rm_len; txr->hn_gpa_cnt = 0; txr->hn_tx_chimney++; goto done; @@ -1033,9 +1012,9 @@ hn_encap(struct hn_tx_ring *txr, struct txr->hn_gpa_cnt = nsegs + 1; /* send packet with page buffer */ - txr->hn_gpa[0].gpa_page = atop(txd->rndis_msg_paddr); - txr->hn_gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; - txr->hn_gpa[0].gpa_len = rndis_msg_size; + txr->hn_gpa[0].gpa_page = atop(txd->rndis_pkt_paddr); + txr->hn_gpa[0].gpa_ofs = txd->rndis_pkt_paddr & PAGE_MASK; + txr->hn_gpa[0].gpa_len = pktlen; /* * Fill the page buffers with mbuf info after the page @@ -1283,7 +1262,7 @@ hn_lro_rx(struct lro_ctrl *lc, struct mb * Note: This is no longer used as a callback */ int -netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen, +hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_recvinfo *info) { struct ifnet *ifp = rxr->hn_ifp; @@ -2109,8 +2088,8 @@ hn_ndis_version_sysctl(SYSCTL_HANDLER_AR char verstr[16]; snprintf(verstr, sizeof(verstr), "%u.%u", - NDIS_VERSION_MAJOR(sc->hn_ndis_ver), - NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); } @@ -2460,16 +2439,16 @@ hn_create_tx_ring(struct hn_softc *sc, i parent_dtag = bus_get_dma_tag(dev); - /* DMA tag for RNDIS messages. */ + /* DMA tag for RNDIS packet messages. */ error = bus_dma_tag_create(parent_dtag, /* parent */ - HN_RNDIS_MSG_ALIGN, /* alignment */ - HN_RNDIS_MSG_BOUNDARY, /* boundary */ + HN_RNDIS_PKT_ALIGN, /* alignment */ + HN_RNDIS_PKT_BOUNDARY, /* boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ - HN_RNDIS_MSG_LEN, /* maxsize */ + HN_RNDIS_PKT_LEN, /* maxsize */ 1, /* nsegments */ - HN_RNDIS_MSG_LEN, /* maxsegsize */ + HN_RNDIS_PKT_LEN, /* maxsegsize */ 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockfuncarg */ @@ -2504,28 +2483,28 @@ hn_create_tx_ring(struct hn_softc *sc, i txd->txr = txr; /* - * Allocate and load RNDIS messages. + * Allocate and load RNDIS packet message. */ error = bus_dmamem_alloc(txr->hn_tx_rndis_dtag, - (void **)&txd->rndis_msg, - BUS_DMA_WAITOK | BUS_DMA_COHERENT, - &txd->rndis_msg_dmap); + (void **)&txd->rndis_pkt, + BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, + &txd->rndis_pkt_dmap); if (error) { device_printf(dev, - "failed to allocate rndis_msg, %d\n", i); + "failed to allocate rndis_packet_msg, %d\n", i); return error; } error = bus_dmamap_load(txr->hn_tx_rndis_dtag, - txd->rndis_msg_dmap, - txd->rndis_msg, HN_RNDIS_MSG_LEN, - hyperv_dma_map_paddr, &txd->rndis_msg_paddr, + txd->rndis_pkt_dmap, + txd->rndis_pkt, HN_RNDIS_PKT_LEN, + hyperv_dma_map_paddr, &txd->rndis_pkt_paddr, BUS_DMA_NOWAIT); if (error) { device_printf(dev, - "failed to load rndis_msg, %d\n", i); + "failed to load rndis_packet_msg, %d\n", i); bus_dmamem_free(txr->hn_tx_rndis_dtag, - txd->rndis_msg, txd->rndis_msg_dmap); + txd->rndis_pkt, txd->rndis_pkt_dmap); return error; } @@ -2536,9 +2515,9 @@ hn_create_tx_ring(struct hn_softc *sc, i device_printf(dev, "failed to allocate tx data dmamap\n"); bus_dmamap_unload(txr->hn_tx_rndis_dtag, - txd->rndis_msg_dmap); + txd->rndis_pkt_dmap); bus_dmamem_free(txr->hn_tx_rndis_dtag, - txd->rndis_msg, txd->rndis_msg_dmap); + txd->rndis_pkt, txd->rndis_pkt_dmap); return error; } @@ -2596,9 +2575,9 @@ hn_txdesc_dmamap_destroy(struct hn_txdes KASSERT(txd->m == NULL, ("still has mbuf installed")); KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("still dma mapped")); - bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_msg_dmap); - bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_msg, - txd->rndis_msg_dmap); + bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_pkt_dmap); + bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_pkt, + txd->rndis_pkt_dmap); bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap); } Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:14:23 2016 (r307499) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:16:26 2016 (r307500) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -48,7 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -102,29 +102,40 @@ again: return ((rid & 0xffff) << 16); } -/* - * Set the Per-Packet-Info with the specified type - */ void * -hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, - int pkt_type) +hn_rndis_pktinfo_append(struct rndis_packet_msg *pkt, size_t pktsize, + size_t pi_dlen, uint32_t pi_type) { - rndis_packet *rndis_pkt; - rndis_per_packet_info *rppi; + const size_t pi_size = HN_RNDIS_PKTINFO_SIZE(pi_dlen); + struct rndis_pktinfo *pi; - rndis_pkt = &rndis_mesg->msg.packet; - rndis_pkt->data_offset += rppi_size; + KASSERT((pi_size & RNDIS_PACKET_MSG_OFFSET_ALIGNMASK) == 0, + ("unaligned pktinfo size %zu, pktinfo dlen %zu", pi_size, pi_dlen)); - rppi = (rndis_per_packet_info *)((char *)rndis_pkt + - rndis_pkt->per_pkt_info_offset + rndis_pkt->per_pkt_info_length); + /* + * Per-packet-info does not move; it only grows. + * + * NOTE: + * rm_pktinfooffset in this phase counts from the beginning + * of rndis_packet_msg. + */ + KASSERT(pkt->rm_pktinfooffset + pkt->rm_pktinfolen + pi_size <= pktsize, + ("%u pktinfo overflows RNDIS packet msg", pi_type)); + pi = (struct rndis_pktinfo *)((uint8_t *)pkt + pkt->rm_pktinfooffset + + pkt->rm_pktinfolen); + pkt->rm_pktinfolen += pi_size; + + pi->rm_size = pi_size; + pi->rm_type = pi_type; + pi->rm_pktinfooffset = RNDIS_PKTINFO_OFFSET; - rppi->size = rppi_size; - rppi->type = pkt_type; - rppi->per_packet_info_offset = sizeof(rndis_per_packet_info); + /* Data immediately follow per-packet-info. */ + pkt->rm_dataoffset += pi_size; - rndis_pkt->per_pkt_info_length += rppi_size; + /* Update RNDIS packet msg length */ + pkt->rm_len += pi_size; - return (rppi); + return (pi->rm_data); } /* @@ -408,7 +419,7 @@ hv_rf_receive_data(struct hn_rx_ring *rx pkt->rm_len, data_off, data_len); return; } - netvsc_recv(rxr, ((const uint8_t *)pkt) + data_off, data_len, &info); + hn_rxpkt(rxr, ((const uint8_t *)pkt) + data_off, data_len, &info); } /* @@ -720,7 +731,7 @@ hn_rndis_get_rsscaps(struct hn_softc *sc /* * Only NDIS 6.30+ is supported. */ - KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); *rxr_cnt = 0; @@ -816,7 +827,7 @@ hn_rndis_conf_offload(struct hn_softc *s memset(¶ms, 0, sizeof(params)); params.ndis_hdr.ndis_type = NDIS_OBJTYPE_DEFAULT; - if (sc->hn_ndis_ver < NDIS_VERSION_6_30) { + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30) { params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_2; paramsz = NDIS_OFFLOAD_PARAMS_SIZE_6_1; } else { @@ -828,7 +839,7 @@ hn_rndis_conf_offload(struct hn_softc *s params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; - if (sc->hn_ndis_ver >= NDIS_VERSION_6_30) { + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; } @@ -855,7 +866,7 @@ hn_rndis_conf_rss(struct hn_softc *sc, i /* * Only NDIS 6.30+ is supported. */ - KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); memset(rss, 0, sizeof(*rss)); @@ -1048,7 +1059,7 @@ hv_rf_on_device_add(struct hn_softc *sc, hv_rf_query_device_link_status(sc, &dev_info->link_state); - if (sc->hn_ndis_ver < NDIS_VERSION_6_30 || nchan == 1) { + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30 || nchan == 1) { /* * Either RSS is not supported, or multiple RX/TX rings * are not requested. @@ -1178,5 +1189,5 @@ void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { - netvsc_channel_rollup(rxr, txr); + hn_chan_rollup(rxr, txr); } Modified: stable/11/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Mon Oct 17 08:14:23 2016 (r307499) +++ stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Mon Oct 17 08:16:26 2016 (r307500) @@ -32,6 +32,14 @@ #include #include +/* + * NDIS protocol version numbers + */ +#define HN_NDIS_VERSION_6_1 0x00060001 +#define HN_NDIS_VERSION_6_30 0x0006001e +#define HN_NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) +#define HN_NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) + #define HN_NVS_RXBUF_SIG 0xcafe #define HN_NVS_CHIM_SIG 0xface @@ -221,4 +229,8 @@ CTASSERT(sizeof(struct hn_nvs_rndis_ack) #define HN_NDIS_HASH_VALUE_SIZE sizeof(uint32_t) #define HN_NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID +/* Per-packet-info size */ +#define HN_RNDIS_PKTINFO_SIZE(dlen) \ + __offsetof(struct rndis_pktinfo, rm_data[dlen]) + #endif /* !_IF_HNREG_H_ */ Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 08:14:23 2016 (r307499) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 08:16:26 2016 (r307500) @@ -112,6 +112,7 @@ hn_nvs_send_sglist(struct vmbus_channel } struct vmbus_xact; +struct rndis_packet_msg; const void *hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, @@ -121,6 +122,13 @@ void hn_nvs_sent_xact(struct hn_send_ct uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); +void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, + size_t pktsize, size_t pi_dlen, uint32_t pi_type); + +int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, + const struct hn_recvinfo *info); +void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); + extern struct hn_send_ctx hn_send_ctx_none; #endif /* !_IF_HNVAR_H_ */ Modified: stable/11/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 08:14:23 2016 (r307499) +++ stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 08:16:26 2016 (r307500) @@ -213,7 +213,7 @@ struct ndis_rssprm_toeplitz { #define NDIS_VLAN_INFO_CFI_MASK 0x0008 #define NDIS_VLAN_INFO_ID_MASK 0xfff0 #define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \ - (((pri) & NVIS_VLAN_INFO_PRI_MASK) | \ + (((pri) & NDIS_VLAN_INFO_PRI_MASK) | \ (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4)) #define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4) #define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3) @@ -231,4 +231,31 @@ struct ndis_rssprm_toeplitz { #define NDIS_RXCSUM_INFO_TCPCS_INVAL 0x0080 #define NDIS_RXCSUM_INFO_IPCS_INVAL 0x0100 +/* LSOv2 */ +#define NDIS_LSO2_INFO_SIZE sizeof(uint32_t) +#define NDIS_LSO2_INFO_MSS_MASK 0x000fffff +#define NDIS_LSO2_INFO_THOFF_MASK 0x3ff00000 +#define NDIS_LSO2_INFO_ISLSO2 0x40000000 +#define NDIS_LSO2_INFO_ISIPV6 0x80000000 + +#define NDIS_LSO2_INFO_MAKE(thoff, mss) \ + ((((uint32_t)(mss)) & NDIS_LSO2_INFO_MSS_MASK) | \ + ((((uint32_t)(thoff)) & 0x3ff) << 20) | \ + NDIS_LSO2_INFO_ISLSO2) + +#define NDIS_LSO2_INFO_MAKEIPV4(thoff, mss) \ + NDIS_LSO2_INFO_MAKE((thoff), (mss)) + +#define NDIS_LSO2_INFO_MAKEIPV6(thoff, mss) \ + (NDIS_LSO2_INFO_MAKE((thoff), (mss)) | NDIS_LSO2_INFO_ISIPV6) + +/* Transmission checksum */ +#define NDIS_TXCSUM_INFO_SIZE sizeof(uint32_t) +#define NDIS_TXCSUM_INFO_IPV4 0x00000001 +#define NDIS_TXCSUM_INFO_IPV6 0x00000002 +#define NDIS_TXCSUM_INFO_TCPCS 0x00000004 +#define NDIS_TXCSUM_INFO_UDPCS 0x00000008 +#define NDIS_TXCSUM_INFO_IPCS 0x00000010 +#define NDIS_TXCSUM_INFO_THOFF 0x03ff0000 + #endif /* !_NET_NDIS_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 08:20:19 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24951C15E9E; Mon, 17 Oct 2016 08:20:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C9E8B1B7A; Mon, 17 Oct 2016 08:20:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8KI10029510; Mon, 17 Oct 2016 08:20:18 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8KHol029504; Mon, 17 Oct 2016 08:20:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170820.u9H8KHol029504@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:20:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307502 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:20:19 -0000 Author: sephe Date: Mon Oct 17 08:20:17 2016 New Revision: 307502 URL: https://svnweb.freebsd.org/changeset/base/307502 Log: MFC 305578-305581 305578 hyperv/hn: Pull vmbus channel open up. While I'm here, pull up the channel callback related code too. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7805 305579 hyperv/hn: Push RXBUF size adjustment down. It is not used in other places. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7806 305580 hyperv/hn: Factor out function to do NVS initialization. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7807 305581 hyperv/hn: Pass MTU around. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7808 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:17:06 2016 (r307501) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:20:17 2016 (r307502) @@ -57,20 +57,11 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper /* * Forward declarations */ -static void hv_nv_on_channel_callback(struct vmbus_channel *chan, - void *xrxr); static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *, int); +static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); static int hv_nv_destroy_send_buffer(struct hn_softc *sc); static int hv_nv_destroy_rx_buffer(struct hn_softc *sc); -static int hv_nv_connect_to_vsp(struct hn_softc *sc); -static void hv_nv_on_send_completion(struct hn_softc *sc, - struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); -static void hv_nv_on_receive_completion(struct vmbus_channel *chan, - uint64_t tid); -static void hv_nv_on_receive(struct hn_softc *sc, - struct hn_rx_ring *rxr, struct vmbus_channel *chan, - const struct vmbus_chanpkt_hdr *pkt); +static int hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct hn_softc *, struct vmbus_channel *chan, const void *, int); @@ -78,6 +69,13 @@ static void hn_nvs_sent_none(struct hn_s struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); +static const uint32_t hn_nvs_version[] = { + HN_NVS_VERSION_5, + HN_NVS_VERSION_4, + HN_NVS_VERSION_2, + HN_NVS_VERSION_1 +}; + uint32_t hn_chim_alloc(struct hn_softc *sc) { @@ -163,17 +161,22 @@ hn_nvs_req_send(struct hn_softc *sc, voi * Hyper-V extensible switch and the synthetic data path. */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc, int rxbuf_size) +hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { struct vmbus_xact *xact = NULL; struct hn_nvs_rxbuf_conn *conn; const struct hn_nvs_rxbuf_connresp *resp; size_t resp_len; uint32_t status; - int error; + int error, rxbuf_size; - KASSERT(rxbuf_size <= NETVSC_RECEIVE_BUFFER_SIZE, - ("invalid rxbuf size %d", rxbuf_size)); + /* + * Limit RXBUF size for old NVS. + */ + if (sc->hn_nvs_ver <= HN_NVS_VERSION_2) + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; + else + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE; /* * Connect the RXBUF GPADL to the primary channel. @@ -428,7 +431,7 @@ hv_nv_destroy_send_buffer(struct hn_soft } static int -hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, uint32_t nvs_ver) +hn_nvs_doinit(struct hn_softc *sc, uint32_t nvs_ver) { struct vmbus_xact *xact; struct hn_nvs_init *init; @@ -489,57 +492,55 @@ hv_nv_send_ndis_config(struct hn_softc * return (error); } -/* - * Net VSC connect to VSP - */ static int -hv_nv_connect_to_vsp(struct hn_softc *sc) +hn_nvs_init(struct hn_softc *sc) { - uint32_t protocol_list[] = { NVSP_PROTOCOL_VERSION_1, - NVSP_PROTOCOL_VERSION_2, - NVSP_PROTOCOL_VERSION_4, - NVSP_PROTOCOL_VERSION_5 }; int i; - int protocol_number = nitems(protocol_list); - int ret = 0; - device_t dev = sc->hn_dev; - struct ifnet *ifp = sc->hn_ifp; - struct hn_nvs_ndis_init ndis; - int rxbuf_size; - /* - * Negotiate the NVSP version. Try the latest NVSP first. - */ - for (i = protocol_number - 1; i >= 0; i--) { - if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { - sc->hn_nvs_ver = protocol_list[i]; + for (i = 0; i < nitems(hn_nvs_version); ++i) { + int error; + + error = hn_nvs_doinit(sc, hn_nvs_version[i]); + if (!error) { + sc->hn_nvs_ver = hn_nvs_version[i]; + + /* Set NDIS version according to NVS version. */ sc->hn_ndis_ver = HN_NDIS_VERSION_6_30; - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) + if (sc->hn_nvs_ver <= HN_NVS_VERSION_4) sc->hn_ndis_ver = HN_NDIS_VERSION_6_1; + if (bootverbose) { if_printf(sc->hn_ifp, "NVS version 0x%x, " - "NDIS version %u.%u\n", - sc->hn_nvs_ver, + "NDIS version %u.%u\n", sc->hn_nvs_ver, HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } - break; + return (0); } } + if_printf(sc->hn_ifp, "no NVS available\n"); + return (ENXIO); +} - if (i < 0) { - if (bootverbose) - device_printf(dev, "failed to negotiate a valid " - "protocol.\n"); - return (EPROTO); - } +/* + * Net VSC connect to VSP + */ +static int +hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu) +{ + int ret = 0; + struct hn_nvs_ndis_init ndis; + + ret = hn_nvs_init(sc); + if (ret != 0) + return (ret); /* * Set the MTU if supported by this NVSP protocol version * This needs to be right after the NVSP init message per Haiyang */ - if (sc->hn_nvs_ver >= NVSP_PROTOCOL_VERSION_2) - ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); + if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) + ret = hv_nv_send_ndis_config(sc, mtu); /* * Initialize NDIS. @@ -557,13 +558,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc goto cleanup; } - /* Post the big receive buffer to NetVSP */ - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_2) - rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; - else - rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE; - - ret = hv_nv_init_rx_buffer_with_net_vsp(sc, rxbuf_size); + ret = hv_nv_init_rx_buffer_with_net_vsp(sc); if (ret == 0) ret = hv_nv_init_send_buffer_with_net_vsp(sc); @@ -581,54 +576,19 @@ hv_nv_disconnect_from_vsp(struct hn_soft hv_nv_destroy_send_buffer(sc); } -void -hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr) -{ - KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), - ("chan%u subidx %u, rxr%d mismatch", - vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); - vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, - NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, - hv_nv_on_channel_callback, rxr); -} - /* * Net VSC on device add * * Callback when the device belonging to this driver is added */ int -hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr) +hv_nv_on_device_add(struct hn_softc *sc, int mtu) { - struct vmbus_channel *chan = sc->hn_prichan; - int ret = 0; - - /* - * Open the channel - */ - KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), - ("chan%u subidx %u, rxr%d mismatch", - vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); - ret = vmbus_chan_open(chan, - NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, - NULL, 0, hv_nv_on_channel_callback, rxr); - if (ret != 0) - goto cleanup; /* * Connect with the NetVsp */ - ret = hv_nv_connect_to_vsp(sc); - if (ret != 0) - goto close; - - return (0); - -close: - /* Now, we can close the channel safely */ - vmbus_chan_close(chan); -cleanup: - return (ret); + return (hv_nv_connect_to_vsp(sc, mtu)); } /* @@ -684,25 +644,6 @@ hn_chim_free(struct hn_softc *sc, uint32 } /* - * Net VSC on send completion - */ -static void -hv_nv_on_send_completion(struct hn_softc *sc, struct vmbus_channel *chan, - const struct vmbus_chanpkt_hdr *pkt) -{ - struct hn_send_ctx *sndc; - - sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; - sndc->hn_cb(sndc, sc, chan, VMBUS_CHANPKT_CONST_DATA(pkt), - VMBUS_CHANPKT_DATALEN(pkt)); - /* - * NOTE: - * 'sndc' CAN NOT be accessed anymore, since it can be freed by - * its callback. - */ -} - -/* * Net VSC on send * Sends a packet on the specified Hyper-V device. * Returns 0 on success, non-zero on failure. @@ -729,190 +670,3 @@ hv_nv_on_send(struct vmbus_channel *chan return (ret); } - -/* - * Net VSC on receive - * - * In the FreeBSD Hyper-V virtual world, this function deals exclusively - * with virtual addresses. - */ -static void -hv_nv_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, - struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) -{ - const struct vmbus_chanpkt_rxbuf *pkt; - const struct hn_nvs_hdr *nvs_hdr; - int count, i, hlen; - - if (__predict_false(VMBUS_CHANPKT_DATALEN(pkthdr) < sizeof(*nvs_hdr))) { - if_printf(rxr->hn_ifp, "invalid nvs RNDIS\n"); - return; - } - nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); - - /* Make sure that this is a RNDIS message. */ - if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { - if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", - nvs_hdr->nvs_type); - return; - } - - hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); - if (__predict_false(hlen < sizeof(*pkt))) { - if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); - return; - } - pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - - if (__predict_false(pkt->cp_rxbuf_id != HN_NVS_RXBUF_SIG)) { - if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", - pkt->cp_rxbuf_id); - return; - } - - count = pkt->cp_rxbuf_cnt; - if (__predict_false(hlen < - __offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { - if_printf(rxr->hn_ifp, "invalid rxbuf_cnt %d\n", count); - return; - } - - /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ - for (i = 0; i < count; ++i) { - int ofs, len; - - ofs = pkt->cp_rxbuf[i].rb_ofs; - len = pkt->cp_rxbuf[i].rb_len; - if (__predict_false(ofs + len > NETVSC_RECEIVE_BUFFER_SIZE)) { - if_printf(rxr->hn_ifp, "%dth RNDIS msg overflow rxbuf, " - "ofs %d, len %d\n", i, ofs, len); - continue; - } - hv_rf_on_receive(sc, rxr, rxr->hn_rxbuf + ofs, len); - } - - /* - * Moved completion call back here so that all received - * messages (not just data messages) will trigger a response - * message back to the host. - */ - hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid); -} - -/* - * Net VSC on receive completion - * - * Send a receive completion packet to RNDIS device (ie NetVsp) - */ -static void -hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid) -{ - struct hn_nvs_rndis_ack ack; - int retries = 0; - int ret = 0; - - ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; - ack.nvs_status = HN_NVS_STATUS_OK; - -retry_send_cmplt: - /* Send the completion */ - ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, - VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); - if (ret == 0) { - /* success */ - /* no-op */ - } else if (ret == EAGAIN) { - /* no more room... wait a bit and attempt to retry 3 times */ - retries++; - - if (retries < 4) { - DELAY(100); - goto retry_send_cmplt; - } - } -} - -static void -hn_proc_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) -{ - const struct hn_nvs_hdr *hdr; - - if (VMBUS_CHANPKT_DATALEN(pkt) < sizeof(*hdr)) { - if_printf(sc->hn_ifp, "invalid nvs notify\n"); - return; - } - hdr = VMBUS_CHANPKT_CONST_DATA(pkt); - - if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { - /* Useless; ignore */ - return; - } - if_printf(sc->hn_ifp, "got notify, nvs type %u\n", hdr->nvs_type); -} - -/* - * Net VSC on channel callback - */ -static void -hv_nv_on_channel_callback(struct vmbus_channel *chan, void *xrxr) -{ - struct hn_rx_ring *rxr = xrxr; - struct hn_softc *sc = rxr->hn_ifp->if_softc; - void *buffer; - int bufferlen = NETVSC_PACKET_SIZE; - - buffer = rxr->hn_rdbuf; - do { - struct vmbus_chanpkt_hdr *pkt = buffer; - uint32_t bytes_rxed; - int ret; - - bytes_rxed = bufferlen; - ret = vmbus_chan_recv_pkt(chan, pkt, &bytes_rxed); - if (ret == 0) { - if (bytes_rxed > 0) { - switch (pkt->cph_type) { - case VMBUS_CHANPKT_TYPE_COMP: - hv_nv_on_send_completion(sc, chan, pkt); - break; - case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(sc, rxr, chan, pkt); - break; - case VMBUS_CHANPKT_TYPE_INBAND: - hn_proc_notify(sc, pkt); - break; - default: - if_printf(rxr->hn_ifp, - "unknown chan pkt %u\n", - pkt->cph_type); - break; - } - } - } else if (ret == ENOBUFS) { - /* Handle large packet */ - if (bufferlen > NETVSC_PACKET_SIZE) { - free(buffer, M_NETVSC); - buffer = NULL; - } - - /* alloc new buffer */ - buffer = malloc(bytes_rxed, M_NETVSC, M_NOWAIT); - if (buffer == NULL) { - if_printf(rxr->hn_ifp, - "hv_cb malloc buffer failed, len=%u\n", - bytes_rxed); - bufferlen = 0; - break; - } - bufferlen = bytes_rxed; - } else { - /* No more packets */ - break; - } - } while (1); - - if (bufferlen > NETVSC_PACKET_SIZE) - free(buffer, M_NETVSC); - - hv_rf_channel_rollup(rxr, rxr->hn_txr); -} Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:17:06 2016 (r307501) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:20:17 2016 (r307502) @@ -68,13 +68,6 @@ MALLOC_DECLARE(M_NETVSC); -#define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF) - -#define NVSP_PROTOCOL_VERSION_1 2 -#define NVSP_PROTOCOL_VERSION_2 0x30002 -#define NVSP_PROTOCOL_VERSION_4 0x40000 -#define NVSP_PROTOCOL_VERSION_5 0x50000 - /* * The following arguably belongs in a separate header file */ @@ -268,12 +261,10 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -int hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr); +int hv_nv_on_device_add(struct hn_softc *sc, int mtu); int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); -void hv_nv_subchan_attach(struct vmbus_channel *chan, - struct hn_rx_ring *rxr); #endif /* __HV_NET_VSC_H__ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:17:06 2016 (r307501) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:20:17 2016 (r307502) @@ -344,9 +344,18 @@ static int hn_encap(struct hn_tx_ring *, static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_chim_size(struct hn_softc *, int); -static void hn_channel_attach(struct hn_softc *, struct vmbus_channel *); -static void hn_subchan_attach(struct hn_softc *, struct vmbus_channel *); -static void hn_subchan_setup(struct hn_softc *); +static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); +static int hn_attach_subchans(struct hn_softc *); +static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr); + +static void hn_nvs_handle_notify(struct hn_softc *sc, + const struct vmbus_chanpkt_hdr *pkt); +static void hn_nvs_handle_comp(struct hn_softc *sc, struct vmbus_channel *chan, + const struct vmbus_chanpkt_hdr *pkt); +static void hn_nvs_handle_rxbuf(struct hn_softc *sc, struct hn_rx_ring *rxr, + struct vmbus_channel *chan, + const struct vmbus_chanpkt_hdr *pkthdr); +static void hn_nvs_ack_rxbuf(struct vmbus_channel *chan, uint64_t tid); static int hn_transmit(struct ifnet *, struct mbuf *); static void hn_xmit_qflush(struct ifnet *); @@ -512,12 +521,13 @@ netvsc_attach(device_t dev) /* * Associate the first TX/RX ring w/ the primary channel. */ - hn_channel_attach(sc, sc->hn_prichan); + error = hn_chan_attach(sc, sc->hn_prichan); + if (error) + goto failed; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; ifp->if_init = hn_ifinit; - /* needed by hv_rf_on_device_add() code */ ifp->if_mtu = ETHERMTU; if (hn_use_if_start) { int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); @@ -554,8 +564,7 @@ netvsc_attach(device_t dev) if (sc->hn_xact == NULL) goto failed; - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, - &sc->hn_rx_ring[0]); + error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, ETHERMTU); if (error) goto failed; KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_inuse, @@ -572,8 +581,11 @@ netvsc_attach(device_t dev) device_printf(dev, "%d TX ring, %d RX ring\n", sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); - if (sc->hn_rx_ring_inuse > 1) - hn_subchan_setup(sc); + if (sc->hn_rx_ring_inuse > 1) { + error = hn_attach_subchans(sc); + if (error) + goto failed; + } #if __FreeBSD_version >= 1100099 if (sc->hn_rx_ring_inuse > 1) { @@ -1566,9 +1578,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, /* Wait for subchannels to be destroyed */ vmbus_subchan_drain(sc->hn_prichan); + sc->hn_rx_ring[0].hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; + sc->hn_tx_ring[0].hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; + hn_chan_attach(sc, sc->hn_prichan); /* XXX check error */ + ring_cnt = sc->hn_rx_ring_inuse; error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, - &sc->hn_rx_ring[0]); + ifr->ifr_mtu); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -1594,7 +1610,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, sc->hn_tx_ring[r].hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; } - hn_subchan_setup(sc); + hn_attach_subchans(sc); /* XXX check error */ } if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) @@ -2948,14 +2964,18 @@ hn_xmit_txeof_taskfunc(void *xtxr, int p mtx_unlock(&txr->hn_tx_lock); } -static void -hn_channel_attach(struct hn_softc *sc, struct vmbus_channel *chan) +static int +hn_chan_attach(struct hn_softc *sc, struct vmbus_channel *chan) { struct hn_rx_ring *rxr; - int idx; + struct hn_tx_ring *txr = NULL; + int idx, error; idx = vmbus_chan_subidx(chan); + /* + * Link this channel to RX/TX ring. + */ KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, ("invalid channel index %d, should > 0 && < %d", idx, sc->hn_rx_ring_inuse)); @@ -2965,60 +2985,260 @@ hn_channel_attach(struct hn_softc *sc, s rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED; if (bootverbose) { - if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", + if_printf(sc->hn_ifp, "link RX ring %d to chan%u\n", idx, vmbus_chan_id(chan)); } if (idx < sc->hn_tx_ring_inuse) { - struct hn_tx_ring *txr = &sc->hn_tx_ring[idx]; - + txr = &sc->hn_tx_ring[idx]; KASSERT((txr->hn_tx_flags & HN_TX_FLAG_ATTACHED) == 0, ("TX ring %d already attached", idx)); txr->hn_tx_flags |= HN_TX_FLAG_ATTACHED; txr->hn_chan = chan; if (bootverbose) { - if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", + if_printf(sc->hn_ifp, "link TX ring %d to chan%u\n", idx, vmbus_chan_id(chan)); } } - /* Bind channel to a proper CPU */ + /* Bind this channel to a proper CPU. */ vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); -} - -static void -hn_subchan_attach(struct hn_softc *sc, struct vmbus_channel *chan) -{ - KASSERT(!vmbus_chan_is_primary(chan), - ("subchannel callback on primary channel")); - hn_channel_attach(sc, chan); + /* Open this channel */ + error = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, + NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hn_chan_callback, rxr); + if (error) { + if_printf(sc->hn_ifp, "open chan%u failed: %d\n", + vmbus_chan_id(chan), error); + rxr->hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; + if (txr != NULL) + txr->hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; + } + return (error); } -static void -hn_subchan_setup(struct hn_softc *sc) +static int +hn_attach_subchans(struct hn_softc *sc) { struct vmbus_channel **subchans; int subchan_cnt = sc->hn_rx_ring_inuse - 1; - int i; + int i, error = 0; /* Wait for sub-channels setup to complete. */ subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { - struct vmbus_channel *subchan = subchans[i]; - - /* NOTE: Calling order is critical. */ - hn_subchan_attach(sc, subchan); - hv_nv_subchan_attach(subchan, - &sc->hn_rx_ring[vmbus_chan_subidx(subchan)]); + error = hn_chan_attach(sc, subchans[i]); + if (error) + break; } /* Release the sub-channels */ vmbus_subchan_rel(subchans, subchan_cnt); - if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); + + if (error) { + if_printf(sc->hn_ifp, "sub-channels attach failed: %d\n", error); + } else { + if (bootverbose) { + if_printf(sc->hn_ifp, "%d sub-channels attached\n", + subchan_cnt); + } + } + return (error); +} + +static void +hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) +{ + const struct hn_nvs_hdr *hdr; + + if (VMBUS_CHANPKT_DATALEN(pkt) < sizeof(*hdr)) { + if_printf(sc->hn_ifp, "invalid nvs notify\n"); + return; + } + hdr = VMBUS_CHANPKT_CONST_DATA(pkt); + + if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { + /* Useless; ignore */ + return; + } + if_printf(sc->hn_ifp, "got notify, nvs type %u\n", hdr->nvs_type); +} + +static void +hn_nvs_handle_comp(struct hn_softc *sc, struct vmbus_channel *chan, + const struct vmbus_chanpkt_hdr *pkt) +{ + struct hn_send_ctx *sndc; + + sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; + sndc->hn_cb(sndc, sc, chan, VMBUS_CHANPKT_CONST_DATA(pkt), + VMBUS_CHANPKT_DATALEN(pkt)); + /* + * NOTE: + * 'sndc' CAN NOT be accessed anymore, since it can be freed by + * its callback. + */ +} + +static void +hn_nvs_handle_rxbuf(struct hn_softc *sc, struct hn_rx_ring *rxr, + struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) +{ + const struct vmbus_chanpkt_rxbuf *pkt; + const struct hn_nvs_hdr *nvs_hdr; + int count, i, hlen; + + if (__predict_false(VMBUS_CHANPKT_DATALEN(pkthdr) < sizeof(*nvs_hdr))) { + if_printf(rxr->hn_ifp, "invalid nvs RNDIS\n"); + return; + } + nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); + + /* Make sure that this is a RNDIS message. */ + if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { + if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", + nvs_hdr->nvs_type); + return; + } + + hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); + if (__predict_false(hlen < sizeof(*pkt))) { + if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); + return; + } + pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; + + if (__predict_false(pkt->cp_rxbuf_id != HN_NVS_RXBUF_SIG)) { + if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", + pkt->cp_rxbuf_id); + return; + } + + count = pkt->cp_rxbuf_cnt; + if (__predict_false(hlen < + __offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { + if_printf(rxr->hn_ifp, "invalid rxbuf_cnt %d\n", count); + return; + } + + /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ + for (i = 0; i < count; ++i) { + int ofs, len; + + ofs = pkt->cp_rxbuf[i].rb_ofs; + len = pkt->cp_rxbuf[i].rb_len; + if (__predict_false(ofs + len > NETVSC_RECEIVE_BUFFER_SIZE)) { + if_printf(rxr->hn_ifp, "%dth RNDIS msg overflow rxbuf, " + "ofs %d, len %d\n", i, ofs, len); + continue; + } + hv_rf_on_receive(sc, rxr, rxr->hn_rxbuf + ofs, len); + } + + /* + * Moved completion call back here so that all received + * messages (not just data messages) will trigger a response + * message back to the host. + */ + hn_nvs_ack_rxbuf(chan, pkt->cp_hdr.cph_xactid); +} + +/* + * Net VSC on receive completion + * + * Send a receive completion packet to RNDIS device (ie NetVsp) + */ +static void +hn_nvs_ack_rxbuf(struct vmbus_channel *chan, uint64_t tid) +{ + struct hn_nvs_rndis_ack ack; + int retries = 0; + int ret = 0; + + ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; + ack.nvs_status = HN_NVS_STATUS_OK; + +retry_send_cmplt: + /* Send the completion */ + ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, + VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); + if (ret == 0) { + /* success */ + /* no-op */ + } else if (ret == EAGAIN) { + /* no more room... wait a bit and attempt to retry 3 times */ + retries++; + + if (retries < 4) { + DELAY(100); + goto retry_send_cmplt; + } + } +} + +static void +hn_chan_callback(struct vmbus_channel *chan, void *xrxr) +{ + struct hn_rx_ring *rxr = xrxr; + struct hn_softc *sc = rxr->hn_ifp->if_softc; + void *buffer; + int bufferlen = NETVSC_PACKET_SIZE; + + buffer = rxr->hn_rdbuf; + do { + struct vmbus_chanpkt_hdr *pkt = buffer; + uint32_t bytes_rxed; + int ret; + + bytes_rxed = bufferlen; + ret = vmbus_chan_recv_pkt(chan, pkt, &bytes_rxed); + if (ret == 0) { + switch (pkt->cph_type) { + case VMBUS_CHANPKT_TYPE_COMP: + hn_nvs_handle_comp(sc, chan, pkt); + break; + case VMBUS_CHANPKT_TYPE_RXBUF: + hn_nvs_handle_rxbuf(sc, rxr, chan, pkt); + break; + case VMBUS_CHANPKT_TYPE_INBAND: + hn_nvs_handle_notify(sc, pkt); + break; + default: + if_printf(rxr->hn_ifp, + "unknown chan pkt %u\n", + pkt->cph_type); + break; + } + } else if (ret == ENOBUFS) { + /* Handle large packet */ + if (bufferlen > NETVSC_PACKET_SIZE) { + free(buffer, M_NETVSC); + buffer = NULL; + } + + /* alloc new buffer */ + buffer = malloc(bytes_rxed, M_NETVSC, M_NOWAIT); + if (buffer == NULL) { + if_printf(rxr->hn_ifp, + "hv_cb malloc buffer failed, len=%u\n", + bytes_rxed); + bufferlen = 0; + break; + } + bufferlen = bytes_rxed; + } else { + /* No more packets */ + break; + } + } while (1); + + if (bufferlen > NETVSC_PACKET_SIZE) + free(buffer, M_NETVSC); + + hv_rf_channel_rollup(rxr, rxr->hn_txr); } static void Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:17:06 2016 (r307501) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:20:17 2016 (r307502) @@ -1012,7 +1012,7 @@ hv_rf_halt_device(struct hn_softc *sc) */ int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, - int *nchan0, struct hn_rx_ring *rxr) + int *nchan0, int mtu) { int ret; netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; @@ -1031,7 +1031,7 @@ hv_rf_on_device_add(struct hn_softc *sc, * (hv_rf_on_receive()) before this call is completed. * Note: Earlier code used a function pointer here. */ - ret = hv_nv_on_device_add(sc, rxr); + ret = hv_nv_on_device_add(sc, mtu); if (ret != 0) return (ret); Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 08:17:06 2016 (r307501) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Mon Oct 17 08:20:17 2016 (r307502) @@ -44,7 +44,7 @@ void hv_rf_on_receive(struct hn_softc *s const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan, - struct hn_rx_ring *rxr); + int mtu); int hv_rf_on_device_remove(struct hn_softc *sc); int hv_rf_on_open(struct hn_softc *sc); int hv_rf_on_close(struct hn_softc *sc); Modified: stable/11/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Mon Oct 17 08:17:06 2016 (r307501) +++ stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Mon Oct 17 08:20:17 2016 (r307502) @@ -40,6 +40,14 @@ #define HN_NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) #define HN_NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) +/* + * NVS versions. + */ +#define HN_NVS_VERSION_1 0x00002 +#define HN_NVS_VERSION_2 0x30002 +#define HN_NVS_VERSION_4 0x40000 +#define HN_NVS_VERSION_5 0x50000 + #define HN_NVS_RXBUF_SIG 0xcafe #define HN_NVS_CHIM_SIG 0xface From owner-svn-src-stable@freebsd.org Mon Oct 17 08:23:31 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3DDEC140E7; Mon, 17 Oct 2016 08:23:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 58BE21008; Mon, 17 Oct 2016 08:23:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8NUjP033180; Mon, 17 Oct 2016 08:23:30 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8NUHt033179; Mon, 17 Oct 2016 08:23:30 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170823.u9H8NUHt033179@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:23:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307503 - stable/11/sys/dev/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:23:31 -0000 Author: sephe Date: Mon Oct 17 08:23:30 2016 New Revision: 307503 URL: https://svnweb.freebsd.org/changeset/base/307503 Log: MFC 305585 hyperv/kvp: Fix IPv4/IPv6 address injection support. The GUID string provided by hypervisor has leading and trailing braces, while our GUID string does not have braces at all. Both braces should be ignored, when the GUID strings are compared. Submitted by: Hongjiang Zhang Modified by: sephe Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7809 Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 08:20:17 2016 (r307502) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Mon Oct 17 08:23:30 2016 (r307503) @@ -332,20 +332,23 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) { for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { - /* XXX access other driver's softc? are you kidding? */ device_t dev = devs[devcnt]; struct vmbus_channel *chan; char buf[HYPERV_GUID_STRLEN]; + int n; - /* - * Trying to find GUID of Network Device - */ chan = vmbus_get_channel(dev); - hyperv_guid2str(vmbus_chan_guid_inst(chan), - buf, sizeof(buf)); + n = hyperv_guid2str(vmbus_chan_guid_inst(chan), buf, + sizeof(buf)); - if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, - HYPERV_GUID_STRLEN - 1) == 0) { + /* + * The string in the 'kvp_ip_val.adapter_id' has + * braces around the GUID; skip the leading brace + * in 'kvp_ip_val.adapter_id'. + */ + if (strncmp(buf, + ((char *)&umsg->body.kvp_ip_val.adapter_id) + 1, + n) == 0) { strlcpy((char *)umsg->body.kvp_ip_val.adapter_id, device_get_nameunit(dev), MAX_ADAPTER_ID_SIZE); break; From owner-svn-src-stable@freebsd.org Mon Oct 17 08:25:48 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78133C14208; Mon, 17 Oct 2016 08:25:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4E609120A; Mon, 17 Oct 2016 08:25:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8PlRD033317; Mon, 17 Oct 2016 08:25:47 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8PldZ033316; Mon, 17 Oct 2016 08:25:47 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170825.u9H8PldZ033316@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:25:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307504 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:25:48 -0000 Author: sephe Date: Mon Oct 17 08:25:47 2016 New Revision: 307504 URL: https://svnweb.freebsd.org/changeset/base/307504 Log: MFC 305586,305587 305586 hyperv/hn: Function renaming. While I'm here, remove obvious comment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7810 305587 hyperv/hn: Factor out NVS NDIS initialization Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7811 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:23:30 2016 (r307503) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:25:47 2016 (r307504) @@ -470,12 +470,10 @@ hn_nvs_doinit(struct hn_softc *sc, uint3 } /* - * Send NDIS version 2 config packet containing MTU. - * - * Not valid for NDIS version 1. + * Configure MTU and enable VLAN. */ static int -hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu) +hn_nvs_conf_ndis(struct hn_softc *sc, int mtu) { struct hn_nvs_ndis_conf conf; int error; @@ -493,6 +491,24 @@ hv_nv_send_ndis_config(struct hn_softc * } static int +hn_nvs_init_ndis(struct hn_softc *sc) +{ + struct hn_nvs_ndis_init ndis; + int error; + + memset(&ndis, 0, sizeof(ndis)); + ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; + ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver); + ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver); + + /* NOTE: No response. */ + error = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); + if (error) + if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", error); + return (error); +} + +static int hn_nvs_init(struct hn_softc *sc) { int i; @@ -522,47 +538,37 @@ hn_nvs_init(struct hn_softc *sc) return (ENXIO); } -/* - * Net VSC connect to VSP - */ static int hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu) { - int ret = 0; - struct hn_nvs_ndis_init ndis; + int ret; + /* + * Initialize NVS. + */ ret = hn_nvs_init(sc); if (ret != 0) return (ret); - /* - * Set the MTU if supported by this NVSP protocol version - * This needs to be right after the NVSP init message per Haiyang - */ - if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) - ret = hv_nv_send_ndis_config(sc, mtu); + if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) { + /* + * Configure NDIS before initializing it. + */ + ret = hn_nvs_conf_ndis(sc, mtu); + if (ret != 0) + return (ret); + } /* * Initialize NDIS. */ - - memset(&ndis, 0, sizeof(ndis)); - ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; - ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver); - ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver); - - /* NOTE: No response. */ - ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); - if (ret != 0) { - if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); - goto cleanup; - } + ret = hn_nvs_init_ndis(sc); + if (ret != 0) + return (ret); ret = hv_nv_init_rx_buffer_with_net_vsp(sc); if (ret == 0) ret = hv_nv_init_send_buffer_with_net_vsp(sc); - -cleanup: return (ret); } From owner-svn-src-stable@freebsd.org Mon Oct 17 08:27:20 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E797C143A4; Mon, 17 Oct 2016 08:27:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 17A0F13CE; Mon, 17 Oct 2016 08:27:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8RJMm033421; Mon, 17 Oct 2016 08:27:19 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8RJWH033419; Mon, 17 Oct 2016 08:27:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170827.u9H8RJWH033419@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:27:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307505 - in stable/11: lib/libstand sys/boot/i386/pxeldr X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:27:20 -0000 Author: sephe Date: Mon Oct 17 08:27:18 2016 New Revision: 307505 URL: https://svnweb.freebsd.org/changeset/base/307505 Log: MFC 305588 pxeboot: Add nfs.read_size tunable. Increase this tunable improves kernel loading speed. Submitted by: Jun Su Reviewed by: rpokala, wblock (previous version) Obtained from: DragonFlyBSD Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7756 Modified: stable/11/lib/libstand/nfs.c stable/11/sys/boot/i386/pxeldr/pxeboot.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libstand/nfs.c ============================================================================== --- stable/11/lib/libstand/nfs.c Mon Oct 17 08:25:47 2016 (r307504) +++ stable/11/lib/libstand/nfs.c Mon Oct 17 08:27:18 2016 (r307505) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -50,7 +51,8 @@ __FBSDID("$FreeBSD$"); #define NFS_DEBUGxx -#define NFSREAD_SIZE 1024 +#define NFSREAD_MIN_SIZE 1024 +#define NFSREAD_MAX_SIZE 4096 /* Define our own NFS attributes without NQNFS stuff. */ #ifdef OLD_NFSV2 @@ -83,7 +85,7 @@ struct nfs_read_repl { n_long errno; struct nfsv2_fattrs fa; n_long count; - u_char data[NFSREAD_SIZE]; + u_char data[NFSREAD_MAX_SIZE]; }; #ifndef NFS_NOSYMLINK @@ -210,6 +212,8 @@ struct fs_ops nfs_fsops = { nfs_readdir }; +static int nfs_read_size = NFSREAD_MIN_SIZE; + #ifdef OLD_NFSV2 /* * Fetch the root file handle (call mount daemon) @@ -264,6 +268,17 @@ nfs_getrootfh(struct iodesc *d, char *pa if (repl->errno) return (ntohl(repl->errno)); bcopy(repl->fh, fhp, sizeof(repl->fh)); + + /* + * Improve boot performance over NFS + */ + if (getenv("nfs.read_size") != NULL) + nfs_read_size = strtol(getenv("nfs.read_size"), NULL, 0); + if (nfs_read_size < NFSREAD_MIN_SIZE) + nfs_read_size = NFSREAD_MIN_SIZE; + if (nfs_read_size > NFSREAD_MAX_SIZE) + nfs_read_size = NFSREAD_MAX_SIZE; + return (0); } @@ -401,11 +416,11 @@ nfs_readdata(struct nfs_iodesc *d, off_t bcopy(d->fh, args->fh, NFS_FHSIZE); args->off = htonl((n_long)off); - if (len > NFSREAD_SIZE) - len = NFSREAD_SIZE; + if (len > nfs_read_size) + len = nfs_read_size; args->len = htonl((n_long)len); args->xxx = htonl((n_long)0); - hlen = sizeof(*repl) - NFSREAD_SIZE; + hlen = offsetof(struct nfs_read_rpl, data[0]); cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READ, args, sizeof(*args), @@ -1022,7 +1037,7 @@ nfs_readdata(struct nfs_iodesc *d, off_t uint32_t count; uint32_t eof; uint32_t len; - u_char data[NFSREAD_SIZE]; + u_char data[NFSREAD_MAX_SIZE]; } *repl; struct { uint32_t h[RPC_HEADER_WORDS]; @@ -1045,10 +1060,10 @@ nfs_readdata(struct nfs_iodesc *d, off_t pos = roundup(d->fhsize, sizeof(uint32_t)) / sizeof(uint32_t); args->fhoffcnt[pos++] = 0; args->fhoffcnt[pos++] = htonl((uint32_t)off); - if (len > NFSREAD_SIZE) - len = NFSREAD_SIZE; + if (len > nfs_read_size) + len = nfs_read_size; args->fhoffcnt[pos] = htonl((uint32_t)len); - hlen = sizeof(*repl) - NFSREAD_SIZE; + hlen = offsetof(struct repl, data[0]); cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READ, args, 4 * sizeof(uint32_t) + roundup(d->fhsize, sizeof(uint32_t)), Modified: stable/11/sys/boot/i386/pxeldr/pxeboot.8 ============================================================================== --- stable/11/sys/boot/i386/pxeldr/pxeboot.8 Mon Oct 17 08:25:47 2016 (r307504) +++ stable/11/sys/boot/i386/pxeldr/pxeboot.8 Mon Oct 17 08:27:18 2016 (r307505) @@ -85,6 +85,14 @@ expects to fetch .Pa /boot/loader.rc from the specified server before loading any other files. .Pp +.Nm +defaults to a conservative 1024 byte NFS data packet size. +This may be changed by setting the +.Va nfs.read_size +variable in +.Pa /boot/loader.conf . +Valid values range from 1024 to 4096 bytes. +.Pp In all other respects, .Nm acts just like From owner-svn-src-stable@freebsd.org Mon Oct 17 08:29:17 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 824C2C14436; Mon, 17 Oct 2016 08:29:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4703415C7; Mon, 17 Oct 2016 08:29:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8TGQ1033534; Mon, 17 Oct 2016 08:29:16 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8TGJw033533; Mon, 17 Oct 2016 08:29:16 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170829.u9H8TGJw033533@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:29:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307506 - stable/11/sys/x86/x86 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:29:17 -0000 Author: sephe Date: Mon Oct 17 08:29:16 2016 New Revision: 307506 URL: https://svnweb.freebsd.org/changeset/base/307506 Log: MFC 305722 x86: Use sx lock for interrupt sources. - Certain pic_assign_cpu, e.g. msi_assign_cpu can have quite a long call chain. For msi_assign_cpu, mutex makes complex PCI bridge drivers more tricky, e.g. sleep can note be called, etc, it will be pretty tricky for upcoming Hyper-V PCI bridge driver for PCI pass-through. - It is not used on any hot code path nor non-sleepable context, so sx should have the same effect as mutex. PIC list is still protected by mutex to keep suspend/resume work. Discussed with: jhb Reviewed by: jhb Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7784 Modified: stable/11/sys/x86/x86/intr_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/x86/x86/intr_machdep.c ============================================================================== --- stable/11/sys/x86/x86/intr_machdep.c Mon Oct 17 08:27:18 2016 (r307505) +++ stable/11/sys/x86/x86/intr_machdep.c Mon Oct 17 08:29:16 2016 (r307506) @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,8 @@ typedef void (*mask_fn)(void *); static int intrcnt_index; static struct intsrc *interrupt_sources[NUM_IO_INTS]; -static struct mtx intr_table_lock; +static struct sx intrsrc_lock; +static struct mtx intrpic_lock; static struct mtx intrcnt_lock; static TAILQ_HEAD(pics_head, pic) pics; @@ -117,14 +119,14 @@ intr_register_pic(struct pic *pic) { int error; - mtx_lock(&intr_table_lock); + mtx_lock(&intrpic_lock); if (intr_pic_registered(pic)) error = EBUSY; else { TAILQ_INSERT_TAIL(&pics, pic, pics); error = 0; } - mtx_unlock(&intr_table_lock); + mtx_unlock(&intrpic_lock); return (error); } @@ -148,16 +150,16 @@ intr_register_source(struct intsrc *isrc vector); if (error) return (error); - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); if (interrupt_sources[vector] != NULL) { - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); intr_event_destroy(isrc->is_event); return (EEXIST); } intrcnt_register(isrc); interrupt_sources[vector] = isrc; isrc->is_handlers = 0; - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); return (0); } @@ -181,14 +183,14 @@ intr_add_handler(const char *name, int v error = intr_event_add_handler(isrc->is_event, name, filter, handler, arg, intr_priority(flags), flags, cookiep); if (error == 0) { - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); intrcnt_updatename(isrc); isrc->is_handlers++; if (isrc->is_handlers == 1) { isrc->is_pic->pic_enable_intr(isrc); isrc->is_pic->pic_enable_source(isrc); } - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } return (error); } @@ -202,14 +204,14 @@ intr_remove_handler(void *cookie) isrc = intr_handler_source(cookie); error = intr_event_remove_handler(cookie); if (error == 0) { - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); isrc->is_handlers--; if (isrc->is_handlers == 0) { isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI); isrc->is_pic->pic_disable_intr(isrc); } intrcnt_updatename(isrc); - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } return (error); } @@ -283,12 +285,12 @@ intr_resume(bool suspend_cancelled) #ifndef DEV_ATPIC atpic_reset(); #endif - mtx_lock(&intr_table_lock); + mtx_lock(&intrpic_lock); TAILQ_FOREACH(pic, &pics, pics) { if (pic->pic_resume != NULL) pic->pic_resume(pic, suspend_cancelled); } - mtx_unlock(&intr_table_lock); + mtx_unlock(&intrpic_lock); } void @@ -296,12 +298,12 @@ intr_suspend(void) { struct pic *pic; - mtx_lock(&intr_table_lock); + mtx_lock(&intrpic_lock); TAILQ_FOREACH_REVERSE(pic, &pics, pics_head, pics) { if (pic->pic_suspend != NULL) pic->pic_suspend(pic); } - mtx_unlock(&intr_table_lock); + mtx_unlock(&intrpic_lock); } static int @@ -322,9 +324,9 @@ intr_assign_cpu(void *arg, int cpu) if (assign_cpu && cpu != NOCPU) { #endif isrc = arg; - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); error = isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[cpu]); - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } else error = 0; return (error); @@ -384,7 +386,8 @@ intr_init(void *dummy __unused) intrcnt_setname("???", 0); intrcnt_index = 1; TAILQ_INIT(&pics); - mtx_init(&intr_table_lock, "intr sources", NULL, MTX_DEF); + mtx_init(&intrpic_lock, "intrpic", NULL, MTX_DEF); + sx_init(&intrsrc_lock, "intrsrc"); mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN); } SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL); @@ -449,7 +452,7 @@ intr_reprogram(void) struct intsrc *is; int v; - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); for (v = 0; v < NUM_IO_INTS; v++) { is = interrupt_sources[v]; if (is == NULL) @@ -457,7 +460,7 @@ intr_reprogram(void) if (is->is_pic->pic_reprogram_pin != NULL) is->is_pic->pic_reprogram_pin(is); } - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } #ifdef DDB @@ -562,7 +565,7 @@ intr_shuffle_irqs(void *arg __unused) return; /* Round-robin assign a CPU to each enabled source. */ - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); assign_cpu = 1; for (i = 0; i < NUM_IO_INTS; i++) { isrc = interrupt_sources[i]; @@ -583,7 +586,7 @@ intr_shuffle_irqs(void *arg __unused) } } - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } SYSINIT(intr_shuffle_irqs, SI_SUB_SMP, SI_ORDER_SECOND, intr_shuffle_irqs, NULL); From owner-svn-src-stable@freebsd.org Mon Oct 17 08:37:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 47A49C14822; Mon, 17 Oct 2016 08:37:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0FC321D2E; Mon, 17 Oct 2016 08:37:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8bK3x037303; Mon, 17 Oct 2016 08:37:20 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8bJTZ037297; Mon, 17 Oct 2016 08:37:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170837.u9H8bJTZ037297@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:37:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307508 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:37:21 -0000 Author: sephe Date: Mon Oct 17 08:37:19 2016 New Revision: 307508 URL: https://svnweb.freebsd.org/changeset/base/307508 Log: MFC 305724,305725,305727-305730,305760,305761,305763,305788 305724 hyperv/hn: Rename RXBUF connect/disconnect functions. Minor cleanup and wording in error messages. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7823 305725 hyperv/hn: Rename chimney sending buffer connect/disconnect functions. Minor cleanup and wording in error messages. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7825 305727 hyperv/hn: Function rename. - Minor style changes. - Nuke unnecessary indirection. - Nuke unapplied comment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7827 305728 hyperv/hn: Reorganize sub-channel allocation. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7829 305729 hyperv/hn: Reorganize RNDIS attach Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7830 305730 hyperv/hn: Pull ether address and link status extraction up. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7831 305760 hyperv/hn: Reorganize channel attach/detach code. This paves the way for further attach/detach code reorganization. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7858 305761 hyperv/hn: Regroup synthetic parts attach code. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7859 305763 hyperv/hn: Reorganize synthetic parts attach code. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7860 305788 hyperv/hn: Pull RSS key and indirect table setup up. This paves the way for the dynamic RSS key and indirect table setting. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7864 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:35:56 2016 (r307507) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 08:37:19 2016 (r307508) @@ -57,11 +57,10 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper /* * Forward declarations */ -static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); -static int hv_nv_destroy_send_buffer(struct hn_softc *sc); -static int hv_nv_destroy_rx_buffer(struct hn_softc *sc); -static int hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu); +static int hn_nvs_conn_chim(struct hn_softc *sc); +static int hn_nvs_conn_rxbuf(struct hn_softc *); +static int hn_nvs_disconn_chim(struct hn_softc *sc); +static int hn_nvs_disconn_rxbuf(struct hn_softc *sc); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct hn_softc *, struct vmbus_channel *chan, const void *, int); @@ -103,7 +102,7 @@ hn_chim_alloc(struct hn_softc *sc) return (ret); } -const void * +static const void * hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, size_t *resplen0, uint32_t type) { @@ -154,14 +153,8 @@ hn_nvs_req_send(struct hn_softc *sc, voi req, reqlen, &hn_send_ctx_none)); } -/* - * Net VSC initialize receive buffer with net VSP - * - * Net VSP: Network virtual services client, also known as the - * Hyper-V extensible switch and the synthetic data path. - */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) +hn_nvs_conn_rxbuf(struct hn_softc *sc) { struct vmbus_xact *xact = NULL; struct hn_nvs_rxbuf_conn *conn; @@ -188,7 +181,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct error = vmbus_chan_gpadl_connect(sc->hn_prichan, sc->hn_rxbuf_dma.hv_paddr, rxbuf_size, &sc->hn_rxbuf_gpadl); if (error) { - if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n", + if_printf(sc->hn_ifp, "rxbuf gpadl conn failed: %d\n", error); goto cleanup; } @@ -212,7 +205,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len, HN_NVS_TYPE_RXBUF_CONNRESP); if (resp == NULL) { - if_printf(sc->hn_ifp, "exec rxbuf conn failed\n"); + if_printf(sc->hn_ifp, "exec nvs rxbuf conn failed\n"); error = EIO; goto cleanup; } @@ -222,7 +215,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct xact = NULL; if (status != HN_NVS_STATUS_OK) { - if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status); + if_printf(sc->hn_ifp, "nvs rxbuf conn failed: %x\n", status); error = EIO; goto cleanup; } @@ -233,15 +226,12 @@ hv_nv_init_rx_buffer_with_net_vsp(struct cleanup: if (xact != NULL) vmbus_xact_put(xact); - hv_nv_destroy_rx_buffer(sc); + hn_nvs_disconn_rxbuf(sc); return (error); } -/* - * Net VSC initialize send buffer with net VSP - */ static int -hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) +hn_nvs_conn_chim(struct hn_softc *sc) { struct vmbus_xact *xact = NULL; struct hn_nvs_chim_conn *chim; @@ -261,8 +251,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru sc->hn_chim_dma.hv_paddr, NETVSC_SEND_BUFFER_SIZE, &sc->hn_chim_gpadl); if (error) { - if_printf(sc->hn_ifp, "chimney sending buffer gpadl " - "connect failed: %d\n", error); + if_printf(sc->hn_ifp, "chim gpadl conn failed: %d\n", error); goto cleanup; } @@ -285,7 +274,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len, HN_NVS_TYPE_CHIM_CONNRESP); if (resp == NULL) { - if_printf(sc->hn_ifp, "exec chim conn failed\n"); + if_printf(sc->hn_ifp, "exec nvs chim conn failed\n"); error = EIO; goto cleanup; } @@ -296,14 +285,14 @@ hv_nv_init_send_buffer_with_net_vsp(stru xact = NULL; if (status != HN_NVS_STATUS_OK) { - if_printf(sc->hn_ifp, "chim conn failed: %x\n", status); + if_printf(sc->hn_ifp, "nvs chim conn failed: %x\n", status); error = EIO; goto cleanup; } if (sectsz == 0) { if_printf(sc->hn_ifp, "zero chimney sending buffer " "section size\n"); - return 0; + return (0); } sc->hn_chim_szmax = sectsz; @@ -327,22 +316,19 @@ hv_nv_init_send_buffer_with_net_vsp(stru if_printf(sc->hn_ifp, "chimney sending buffer %d/%d\n", sc->hn_chim_szmax, sc->hn_chim_cnt); } - return 0; + return (0); cleanup: if (xact != NULL) vmbus_xact_put(xact); - hv_nv_destroy_send_buffer(sc); + hn_nvs_disconn_chim(sc); return (error); } -/* - * Net VSC destroy receive buffer - */ static int -hv_nv_destroy_rx_buffer(struct hn_softc *sc) +hn_nvs_disconn_rxbuf(struct hn_softc *sc) { - int ret = 0; + int error; if (sc->hn_flags & HN_FLAG_RXBUF_CONNECTED) { struct hn_nvs_rxbuf_disconn disconn; @@ -355,38 +341,35 @@ hv_nv_destroy_rx_buffer(struct hn_softc disconn.nvs_sig = HN_NVS_RXBUF_SIG; /* NOTE: No response. */ - ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); - if (ret != 0) { + error = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); + if (error) { if_printf(sc->hn_ifp, - "send rxbuf disconn failed: %d\n", ret); - return (ret); + "send nvs rxbuf disconn failed: %d\n", error); + return (error); } sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED; } - + if (sc->hn_rxbuf_gpadl != 0) { /* * Disconnect RXBUF from primary channel. */ - ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + error = vmbus_chan_gpadl_disconnect(sc->hn_prichan, sc->hn_rxbuf_gpadl); - if (ret != 0) { + if (error) { if_printf(sc->hn_ifp, - "rxbuf disconn failed: %d\n", ret); - return (ret); + "rxbuf gpadl disconn failed: %d\n", error); + return (error); } sc->hn_rxbuf_gpadl = 0; } - return (ret); + return (0); } -/* - * Net VSC destroy send buffer - */ static int -hv_nv_destroy_send_buffer(struct hn_softc *sc) +hn_nvs_disconn_chim(struct hn_softc *sc) { - int ret = 0; + int error; if (sc->hn_flags & HN_FLAG_CHIM_CONNECTED) { struct hn_nvs_chim_disconn disconn; @@ -399,25 +382,25 @@ hv_nv_destroy_send_buffer(struct hn_soft disconn.nvs_sig = HN_NVS_CHIM_SIG; /* NOTE: No response. */ - ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); - if (ret != 0) { + error = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); + if (error) { if_printf(sc->hn_ifp, - "send chim disconn failed: %d\n", ret); - return (ret); + "send nvs chim disconn failed: %d\n", error); + return (error); } sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED; } - + if (sc->hn_chim_gpadl != 0) { /* * Disconnect chimney sending buffer from primary channel. */ - ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + error = vmbus_chan_gpadl_disconnect(sc->hn_prichan, sc->hn_chim_gpadl); - if (ret != 0) { + if (error) { if_printf(sc->hn_ifp, - "chim disconn failed: %d\n", ret); - return (ret); + "chim gpadl disconn failed: %d\n", error); + return (error); } sc->hn_chim_gpadl = 0; } @@ -426,8 +409,7 @@ hv_nv_destroy_send_buffer(struct hn_soft free(sc->hn_chim_bmap, M_NETVSC); sc->hn_chim_bmap = NULL; } - - return (ret); + return (0); } static int @@ -538,38 +520,48 @@ hn_nvs_init(struct hn_softc *sc) return (ENXIO); } -static int -hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu) +int +hn_nvs_attach(struct hn_softc *sc, int mtu) { - int ret; + int error; /* * Initialize NVS. */ - ret = hn_nvs_init(sc); - if (ret != 0) - return (ret); + error = hn_nvs_init(sc); + if (error) + return (error); if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) { /* * Configure NDIS before initializing it. */ - ret = hn_nvs_conf_ndis(sc, mtu); - if (ret != 0) - return (ret); + error = hn_nvs_conf_ndis(sc, mtu); + if (error) + return (error); } /* * Initialize NDIS. */ - ret = hn_nvs_init_ndis(sc); - if (ret != 0) - return (ret); - - ret = hv_nv_init_rx_buffer_with_net_vsp(sc); - if (ret == 0) - ret = hv_nv_init_send_buffer_with_net_vsp(sc); - return (ret); + error = hn_nvs_init_ndis(sc); + if (error) + return (error); + + /* + * Connect RXBUF. + */ + error = hn_nvs_conn_rxbuf(sc); + if (error) + return (error); + + /* + * Connect chimney sending buffer. + */ + error = hn_nvs_conn_chim(sc); + if (error) + return (error); + return (0); } /* @@ -578,23 +570,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc static void hv_nv_disconnect_from_vsp(struct hn_softc *sc) { - hv_nv_destroy_rx_buffer(sc); - hv_nv_destroy_send_buffer(sc); -} - -/* - * Net VSC on device add - * - * Callback when the device belonging to this driver is added - */ -int -hv_nv_on_device_add(struct hn_softc *sc, int mtu) -{ - - /* - * Connect with the NetVsp - */ - return (hv_nv_connect_to_vsp(sc, mtu)); + hn_nvs_disconn_rxbuf(sc); + hn_nvs_disconn_chim(sc); } /* @@ -605,11 +582,6 @@ hv_nv_on_device_remove(struct hn_softc * { hv_nv_disconnect_from_vsp(sc); - - /* Now, we can close the channel safely */ - - vmbus_chan_close(sc->hn_prichan); - return (0); } @@ -676,3 +648,54 @@ hv_nv_on_send(struct vmbus_channel *chan return (ret); } + +int +hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch0) +{ + struct vmbus_xact *xact; + struct hn_nvs_subch_req *req; + const struct hn_nvs_subch_resp *resp; + int error, nsubch_req; + uint32_t nsubch; + size_t resp_len; + + nsubch_req = *nsubch0; + KASSERT(nsubch_req > 0, ("invalid # of sub-channels %d", nsubch_req)); + + xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs subch alloc\n"); + return (ENXIO); + } + req = vmbus_xact_req_data(xact); + req->nvs_type = HN_NVS_TYPE_SUBCH_REQ; + req->nvs_op = HN_NVS_SUBCH_OP_ALLOC; + req->nvs_nsubch = nsubch_req; + + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len, + HN_NVS_TYPE_SUBCH_RESP); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec nvs subch alloc failed\n"); + error = EIO; + goto done; + } + if (resp->nvs_status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "nvs subch alloc failed: %x\n", + resp->nvs_status); + error = EIO; + goto done; + } + + nsubch = resp->nvs_nsubch; + if (nsubch > nsubch_req) { + if_printf(sc->hn_ifp, "%u subchans are allocated, " + "requested %d\n", nsubch, nsubch_req); + nsubch = nsubch_req; + } + *nsubch0 = nsubch; + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:35:56 2016 (r307507) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:37:19 2016 (r307508) @@ -99,11 +99,6 @@ struct vmbus_channel; #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) #define NETVSC_PACKET_MAXPAGE 32 -typedef struct { - uint8_t mac_addr[ETHER_ADDR_LEN]; - uint32_t link_state; -} netvsc_device_info; - #define HN_XACT_REQ_PGCNT 2 #define HN_XACT_RESP_PGCNT 2 #define HN_XACT_REQ_SIZE (HN_XACT_REQ_PGCNT * PAGE_SIZE) @@ -261,7 +256,7 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -int hv_nv_on_device_add(struct hn_softc *sc, int mtu); +int hn_nvs_attach(struct hn_softc *sc, int mtu); int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:35:56 2016 (r307507) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:37:19 2016 (r307508) @@ -345,8 +345,12 @@ static int hn_create_rx_data(struct hn_s static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_chim_size(struct hn_softc *, int); static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); +static void hn_chan_detach(struct hn_softc *, struct vmbus_channel *); static int hn_attach_subchans(struct hn_softc *); +static void hn_detach_allchans(struct hn_softc *); static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr); +static void hn_set_ring_inuse(struct hn_softc *, int); +static int hn_synth_attach(struct hn_softc *, int); static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt); @@ -364,6 +368,14 @@ static void hn_xmit_txeof(struct hn_tx_r static void hn_xmit_taskfunc(void *, int); static void hn_xmit_txeof_taskfunc(void *, int); +static const uint8_t hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { + 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, + 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, + 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, + 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, + 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa +}; + #if __FreeBSD_version >= 1100099 static void hn_set_lro_lenlim(struct hn_softc *sc, int lenlim) @@ -440,7 +452,8 @@ netvsc_attach(device_t dev) { struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; - netvsc_device_info device_info; + uint8_t eaddr[ETHER_ADDR_LEN]; + uint32_t link_status; hn_softc_t *sc; int unit = device_get_unit(dev); struct ifnet *ifp = NULL; @@ -519,9 +532,17 @@ netvsc_attach(device_t dev) goto failed; /* - * Associate the first TX/RX ring w/ the primary channel. + * Create transaction context for NVS and RNDIS transactions. */ - error = hn_chan_attach(sc, sc->hn_prichan); + sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), + HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); + if (sc->hn_xact == NULL) + goto failed; + + /* + * Attach the synthetic parts, i.e. NVS and RNDIS. + */ + error = hn_synth_attach(sc, ETHERMTU); if (error) goto failed; @@ -559,34 +580,6 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; - sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), - HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); - if (sc->hn_xact == NULL) - goto failed; - - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, ETHERMTU); - if (error) - goto failed; - KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_inuse, - ("invalid channel count %d, should be less than %d", - ring_cnt, sc->hn_rx_ring_inuse)); - - /* - * Set the # of TX/RX rings that could be used according to - * the # of channels that host offered. - */ - if (sc->hn_tx_ring_inuse > ring_cnt) - sc->hn_tx_ring_inuse = ring_cnt; - sc->hn_rx_ring_inuse = ring_cnt; - device_printf(dev, "%d TX ring, %d RX ring\n", - sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); - - if (sc->hn_rx_ring_inuse > 1) { - error = hn_attach_subchans(sc); - if (error) - goto failed; - } - #if __FreeBSD_version >= 1100099 if (sc->hn_rx_ring_inuse > 1) { /* @@ -597,9 +590,11 @@ netvsc_attach(device_t dev) } #endif - if (device_info.link_state == NDIS_MEDIA_STATE_CONNECTED) { + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) + goto failed; + if (link_status == NDIS_MEDIA_STATE_CONNECTED) sc->hn_carrier = 1; - } #if __FreeBSD_version >= 1100045 tso_maxlen = hn_tso_maxlen; @@ -612,7 +607,10 @@ netvsc_attach(device_t dev) (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); #endif - ether_ifattach(ifp, device_info.mac_addr); + error = hn_rndis_get_eaddr(sc, eaddr); + if (error) + goto failed; + ether_ifattach(ifp, eaddr); #if __FreeBSD_version >= 1100045 if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, @@ -663,6 +661,7 @@ netvsc_detach(device_t dev) */ hv_rf_on_device_remove(sc); + hn_detach_allchans(sc); hn_stop_tx_tasks(sc); @@ -1503,8 +1502,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, #ifdef INET struct ifaddr *ifa = (struct ifaddr *)data; #endif - netvsc_device_info device_info; - int mask, error = 0, ring_cnt; + int mask, error = 0; int retry_cnt = 500; switch(cmd) { @@ -1575,43 +1573,16 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, break; } - /* Wait for subchannels to be destroyed */ - vmbus_subchan_drain(sc->hn_prichan); - - sc->hn_rx_ring[0].hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; - sc->hn_tx_ring[0].hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; - hn_chan_attach(sc, sc->hn_prichan); /* XXX check error */ - - ring_cnt = sc->hn_rx_ring_inuse; - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, - ifr->ifr_mtu); - if (error) { - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); - break; - } - /* # of channels can _not_ be changed */ - KASSERT(sc->hn_rx_ring_inuse == ring_cnt, - ("RX ring count %d and channel count %u mismatch", - sc->hn_rx_ring_cnt, ring_cnt)); - if (sc->hn_rx_ring_inuse > 1) { - int r; + /* + * Detach all of the channels. + */ + hn_detach_allchans(sc); - /* - * Skip the rings on primary channel; they are - * handled by the hv_rf_on_device_add() above. - */ - for (r = 1; r < sc->hn_rx_ring_cnt; ++r) { - sc->hn_rx_ring[r].hn_rx_flags &= - ~HN_RX_FLAG_ATTACHED; - } - for (r = 1; r < sc->hn_tx_ring_cnt; ++r) { - sc->hn_tx_ring[r].hn_tx_flags &= - ~HN_TX_FLAG_ATTACHED; - } - hn_attach_subchans(sc); /* XXX check error */ - } + /* + * Attach the synthetic parts, i.e. NVS and RNDIS. + * XXX check error. + */ + hn_synth_attach(sc, ifr->ifr_mtu); if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); @@ -3018,6 +2989,42 @@ hn_chan_attach(struct hn_softc *sc, stru return (error); } +static void +hn_chan_detach(struct hn_softc *sc, struct vmbus_channel *chan) +{ + struct hn_rx_ring *rxr; + int idx; + + idx = vmbus_chan_subidx(chan); + + /* + * Link this channel to RX/TX ring. + */ + KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, + ("invalid channel index %d, should > 0 && < %d", + idx, sc->hn_rx_ring_inuse)); + rxr = &sc->hn_rx_ring[idx]; + KASSERT((rxr->hn_rx_flags & HN_RX_FLAG_ATTACHED), + ("RX ring %d is not attached", idx)); + rxr->hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; + + if (idx < sc->hn_tx_ring_inuse) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[idx]; + + KASSERT((txr->hn_tx_flags & HN_TX_FLAG_ATTACHED), + ("TX ring %d is not attached attached", idx)); + txr->hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; + } + + /* + * Close this channel. + * + * NOTE: + * Channel closing does _not_ destroy the target channel. + */ + vmbus_chan_close(chan); +} + static int hn_attach_subchans(struct hn_softc *sc) { @@ -3025,17 +3032,16 @@ hn_attach_subchans(struct hn_softc *sc) int subchan_cnt = sc->hn_rx_ring_inuse - 1; int i, error = 0; - /* Wait for sub-channels setup to complete. */ - subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); + if (subchan_cnt == 0) + return (0); /* Attach the sub-channels. */ + subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); for (i = 0; i < subchan_cnt; ++i) { error = hn_chan_attach(sc, subchans[i]); if (error) break; } - - /* Release the sub-channels */ vmbus_subchan_rel(subchans, subchan_cnt); if (error) { @@ -3050,6 +3056,202 @@ hn_attach_subchans(struct hn_softc *sc) } static void +hn_detach_allchans(struct hn_softc *sc) +{ + struct vmbus_channel **subchans; + int subchan_cnt = sc->hn_rx_ring_inuse - 1; + int i; + + if (subchan_cnt == 0) + goto back; + + /* Detach the sub-channels. */ + subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); + for (i = 0; i < subchan_cnt; ++i) + hn_chan_detach(sc, subchans[i]); + vmbus_subchan_rel(subchans, subchan_cnt); + +back: + /* + * Detach the primary channel, _after_ all sub-channels + * are detached. + */ + hn_chan_detach(sc, sc->hn_prichan); + + /* Wait for sub-channels to be destroyed, if any. */ + vmbus_subchan_drain(sc->hn_prichan); + +#ifdef INVARIANTS + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + KASSERT((sc->hn_rx_ring[i].hn_rx_flags & + HN_RX_FLAG_ATTACHED) == 0, + ("%dth RX ring is still attached", i)); + } + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + KASSERT((sc->hn_tx_ring[i].hn_tx_flags & + HN_TX_FLAG_ATTACHED) == 0, + ("%dth TX ring is still attached", i)); + } +#endif +} + +static int +hn_synth_alloc_subchans(struct hn_softc *sc, int *nsubch) +{ + struct vmbus_channel **subchans; + int nchan, rxr_cnt, error; + + nchan = *nsubch + 1; + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30 || nchan == 1) { + /* + * Either RSS is not supported, or multiple RX/TX rings + * are not requested. + */ + *nsubch = 0; + return (0); + } + + /* + * Get RSS capabilities, e.g. # of RX rings, and # of indirect + * table entries. + */ + error = hn_rndis_get_rsscaps(sc, &rxr_cnt); + if (error) { + /* No RSS; this is benign. */ + *nsubch = 0; + return (0); + } + if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", + rxr_cnt, nchan); + + if (nchan > rxr_cnt) + nchan = rxr_cnt; + if (nchan == 1) { + if_printf(sc->hn_ifp, "only 1 channel is supported, no vRSS\n"); + *nsubch = 0; + return (0); + } + + /* + * Allocate sub-channels from NVS. + */ + *nsubch = nchan - 1; + error = hn_nvs_alloc_subchans(sc, nsubch); + if (error || *nsubch == 0) { + /* Failed to allocate sub-channels. */ + *nsubch = 0; + return (0); + } + + /* + * Wait for all sub-channels to become ready before moving on. + */ + subchans = vmbus_subchan_get(sc->hn_prichan, *nsubch); + vmbus_subchan_rel(subchans, *nsubch); + return (0); +} + +static int +hn_synth_attach(struct hn_softc *sc, int mtu) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + int error, nsubch, nchan, i; + + /* + * Attach the primary channel _before_ attaching NVS and RNDIS. + */ + error = hn_chan_attach(sc, sc->hn_prichan); + if (error) + return (error); + + /* + * Attach NVS. + */ + error = hn_nvs_attach(sc, mtu); + if (error) + return (error); + + /* + * Attach RNDIS _after_ NVS is attached. + */ + error = hn_rndis_attach(sc); + if (error) + return (error); + + /* + * Allocate sub-channels for multi-TX/RX rings. + * + * NOTE: + * The # of RX rings that can be used is equivalent to the # of + * channels to be requested. + */ + nsubch = sc->hn_rx_ring_cnt - 1; + error = hn_synth_alloc_subchans(sc, &nsubch); + if (error) + return (error); + + nchan = nsubch + 1; + if (nchan == 1) { + /* Only the primary channel can be used; done */ + goto back; + } + + /* + * Configure RSS key and indirect table _after_ all sub-channels + * are allocated. + */ + + /* Setup default RSS key. */ + memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); + + /* Setup default RSS indirect table. */ + /* TODO: Take ndis_rss_caps.ndis_nind into account. */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) + rss->rss_ind[i] = i % nchan; + + error = hn_rndis_conf_rss(sc); + if (error) { + /* + * Failed to configure RSS key or indirect table; only + * the primary channel can be used. + */ + nchan = 1; + } +back: + /* + * Set the # of TX/RX rings that could be used according to + * the # of channels that NVS offered. + */ + hn_set_ring_inuse(sc, nchan); + + /* + * Attach the sub-channels, if any. + */ + error = hn_attach_subchans(sc); + if (error) + return (error); + return (0); +} + +static void +hn_set_ring_inuse(struct hn_softc *sc, int ring_cnt) +{ + KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_cnt, + ("invalid ring count %d", ring_cnt)); + + if (sc->hn_tx_ring_cnt > ring_cnt) + sc->hn_tx_ring_inuse = ring_cnt; + else + sc->hn_tx_ring_inuse = sc->hn_tx_ring_cnt; + sc->hn_rx_ring_inuse = ring_cnt; + + if (bootverbose) { + if_printf(sc->hn_ifp, "%d TX ring, %d RX ring\n", + sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); + } +} + +static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { const struct hn_nvs_hdr *hdr; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:35:56 2016 (r307507) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 08:37:19 2016 (r307508) @@ -75,18 +75,12 @@ static void hv_rf_receive_indicate_statu const void *data, int dlen); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); -static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); -static int hv_rf_query_device_link_status(struct hn_softc *sc, - uint32_t *link_status); -static int hv_rf_init_device(struct hn_softc *sc); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); static int hn_rndis_conf_offload(struct hn_softc *sc); -static int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt); -static int hn_rndis_conf_rss(struct hn_softc *sc, int nchan); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -480,11 +474,8 @@ hv_rf_on_receive(struct hn_softc *sc, st } } -/* - * RNDIS filter query device MAC address - */ -static int -hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr) +int +hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr) { size_t eaddr_len; int error; @@ -501,11 +492,8 @@ hv_rf_query_device_mac(struct hn_softc * return (0); } -/* - * RNDIS filter query device link status - */ -static int -hv_rf_query_device_link_status(struct hn_softc *sc, uint32_t *link_status) +int +hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status) { size_t size; int error; @@ -522,14 +510,6 @@ hv_rf_query_device_link_status(struct hn return (0); } -static uint8_t netvsc_hash_key[NDIS_HASH_KEYSIZE_TOEPLITZ] = { - 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, - 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, - 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, - 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, - 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa -}; - static const void * hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, struct hn_send_ctx *sndc, size_t *comp_len) @@ -721,7 +701,7 @@ done: return (error); } -static int +int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt) { struct ndis_rss_caps in, caps; @@ -856,12 +836,12 @@ hn_rndis_conf_offload(struct hn_softc *s return (error); } -static int -hn_rndis_conf_rss(struct hn_softc *sc, int nchan) +int +hn_rndis_conf_rss(struct hn_softc *sc) { struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; struct ndis_rss_params *prm = &rss->rss_params; - int i, error; + int error; /* * Only NDIS 6.30+ is supported. @@ -869,7 +849,12 @@ hn_rndis_conf_rss(struct hn_softc *sc, i KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); - memset(rss, 0, sizeof(*rss)); + /* + * NOTE: + * DO NOT whack rss_key and rss_ind, which are setup by the caller. + */ + memset(prm, 0, sizeof(*prm)); + prm->ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_PARAMS; prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; prm->ndis_hdr.ndis_size = sizeof(*rss); @@ -884,14 +869,6 @@ hn_rndis_conf_rss(struct hn_softc *sc, i prm->ndis_keyoffset = __offsetof(struct ndis_rssprm_toeplitz, rss_key[0]); - /* Setup RSS key */ - memcpy(rss->rss_key, netvsc_hash_key, sizeof(rss->rss_key)); - - /* Setup RSS indirect table */ - /* TODO: Take ndis_rss_caps.ndis_nind into account */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Oct 17 08:39:18 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50100C14959; Mon, 17 Oct 2016 08:39:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E0411111; Mon, 17 Oct 2016 08:39:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8dHrq037592; Mon, 17 Oct 2016 08:39:17 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8dHMU037591; Mon, 17 Oct 2016 08:39:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170839.u9H8dHMU037591@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:39:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307510 - stable/11/sys/dev/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:39:18 -0000 Author: sephe Date: Mon Oct 17 08:39:17 2016 New Revision: 307510 URL: https://svnweb.freebsd.org/changeset/base/307510 Log: MFC 305789 hyperv/vmbus: Make sure that the sub-channel count is valid. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7865 Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 08:38:24 2016 (r307509) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Oct 17 08:39:17 2016 (r307510) @@ -1346,6 +1346,8 @@ vmbus_subchan_get(struct vmbus_channel * struct vmbus_channel **ret, *chan; int i; + KASSERT(subchan_cnt > 0, ("invalid sub-channel count %d", subchan_cnt)); + ret = malloc(subchan_cnt * sizeof(struct vmbus_channel *), M_TEMP, M_WAITOK); From owner-svn-src-stable@freebsd.org Mon Oct 17 08:42:55 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 927B4C14B52; Mon, 17 Oct 2016 08:42:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A58B1595; Mon, 17 Oct 2016 08:42:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8gsmH041083; Mon, 17 Oct 2016 08:42:54 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8gsNk041081; Mon, 17 Oct 2016 08:42:54 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170842.u9H8gsNk041081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:42:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307511 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:42:55 -0000 Author: sephe Date: Mon Oct 17 08:42:54 2016 New Revision: 307511 URL: https://svnweb.freebsd.org/changeset/base/307511 Log: MFC 305790-305793 305790 hyperv/hn: Remove unused softc field Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7866 305791 hyperv/hn: Deprecate hn_softc_t Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7867 305792 hyperv/hn: Function renaming: hn_ifinit -> hn_init No functional changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7868 305793 hyperv/hn: Cleanup hn_ioctl. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7869 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:39:17 2016 (r307510) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:42:54 2016 (r307511) @@ -198,11 +198,10 @@ struct hn_tx_ring { /* * Device-specific softc structure */ -typedef struct hn_softc { +struct hn_softc { struct ifnet *hn_ifp; struct ifmedia hn_media; device_t hn_dev; - uint8_t hn_unit; int hn_carrier; int hn_if_flags; struct mtx hn_lock; @@ -244,7 +243,7 @@ typedef struct hn_softc { uint32_t hn_ndis_ver; struct ndis_rssprm_toeplitz hn_rss; -} hn_softc_t; +}; #define HN_FLAG_RXBUF_CONNECTED 0x0001 #define HN_FLAG_CHIM_CONNECTED 0x0002 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:39:17 2016 (r307510) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:42:54 2016 (r307511) @@ -312,9 +312,9 @@ static u_int hn_cpu_index; /* * Forward declarations */ -static void hn_stop(hn_softc_t *sc); -static void hn_ifinit_locked(hn_softc_t *sc); -static void hn_ifinit(void *xsc); +static void hn_stop(struct hn_softc *sc); +static void hn_init_locked(struct hn_softc *sc); +static void hn_init(void *xsc); static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int hn_start_locked(struct hn_tx_ring *txr, int len); static void hn_start(struct ifnet *ifp); @@ -450,21 +450,17 @@ netvsc_probe(device_t dev) static int netvsc_attach(device_t dev) { + struct hn_softc *sc = device_get_softc(dev); struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; uint8_t eaddr[ETHER_ADDR_LEN]; uint32_t link_status; - hn_softc_t *sc; - int unit = device_get_unit(dev); struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; #if __FreeBSD_version >= 1100045 int tso_maxlen; #endif - sc = device_get_softc(dev); - - sc->hn_unit = unit; sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); @@ -548,7 +544,7 @@ netvsc_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; - ifp->if_init = hn_ifinit; + ifp->if_init = hn_init; ifp->if_mtu = ETHERMTU; if (hn_use_if_start) { int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); @@ -1497,29 +1493,13 @@ skip: static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - hn_softc_t *sc = ifp->if_softc; + struct hn_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; -#ifdef INET - struct ifaddr *ifa = (struct ifaddr *)data; -#endif int mask, error = 0; int retry_cnt = 500; - switch(cmd) { - - case SIOCSIFADDR: -#ifdef INET - if (ifa->ifa_addr->sa_family == AF_INET) { - ifp->if_flags |= IFF_UP; - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) - hn_ifinit(sc); - arp_ifinit(ifp, ifa); - } else -#endif - error = ether_ioctl(ifp, cmd, data); - break; + switch (cmd) { case SIOCSIFMTU: - /* Check MTU value change */ if (ifp->if_mtu == ifr->ifr_mtu) break; @@ -1587,12 +1567,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); - hn_ifinit_locked(sc); + hn_init_locked(sc); NV_LOCK(sc); sc->temp_unusable = FALSE; NV_UNLOCK(sc); break; + case SIOCSIFFLAGS: do { NV_LOCK(sc); @@ -1633,7 +1614,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, /* do something here for Hyper-V */ } else #endif - hn_ifinit_locked(sc); + hn_init_locked(sc); } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { hn_stop(sc); @@ -1643,8 +1624,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, sc->temp_unusable = FALSE; NV_UNLOCK(sc); sc->hn_if_flags = ifp->if_flags; - error = 0; break; + case SIOCSIFCAP: NV_LOCK(sc); @@ -1683,38 +1664,32 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } NV_UNLOCK(sc); - error = 0; break; + case SIOCADDMULTI: case SIOCDELMULTI: -#ifdef notyet - /* Fixme: Multicast mode? */ - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - NV_LOCK(sc); - netvsc_setmulti(sc); - NV_UNLOCK(sc); - error = 0; - } -#endif - error = EINVAL; + /* Always all-multi */ + /* + * TODO: + * Enable/disable all-multi according to the emptiness of + * the mcast address list. + */ break; + case SIOCSIFMEDIA: case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd); break; + default: error = ether_ioctl(ifp, cmd, data); break; } - return (error); } -/* - * - */ static void -hn_stop(hn_softc_t *sc) +hn_stop(struct hn_softc *sc) { struct ifnet *ifp; int ret, i; @@ -1793,11 +1768,8 @@ do_sched: } } -/* - * - */ static void -hn_ifinit_locked(hn_softc_t *sc) +hn_init_locked(struct hn_softc *sc) { struct ifnet *ifp; int ret, i; @@ -1829,9 +1801,9 @@ hn_ifinit_locked(hn_softc_t *sc) * */ static void -hn_ifinit(void *xsc) +hn_init(void *xsc) { - hn_softc_t *sc = xsc; + struct hn_softc *sc = xsc; NV_LOCK(sc); if (sc->temp_unusable) { @@ -1841,7 +1813,7 @@ hn_ifinit(void *xsc) sc->temp_unusable = TRUE; NV_UNLOCK(sc); - hn_ifinit_locked(sc); + hn_init_locked(sc); NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -1855,11 +1827,9 @@ hn_ifinit(void *xsc) static void hn_watchdog(struct ifnet *ifp) { - hn_softc_t *sc; - sc = ifp->if_softc; - printf("hn%d: watchdog timeout -- resetting\n", sc->hn_unit); - hn_ifinit(sc); /*???*/ + if_printf(ifp, "watchdog timeout -- resetting\n"); + hn_init(ifp->if_softc); /* XXX */ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } #endif @@ -3489,7 +3459,7 @@ static device_method_t netvsc_methods[] static driver_t netvsc_driver = { NETVSC_DEVNAME, netvsc_methods, - sizeof(hn_softc_t) + sizeof(struct hn_softc) }; static devclass_t netvsc_devclass; From owner-svn-src-stable@freebsd.org Mon Oct 17 08:45:00 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC2BAC14BEA; Mon, 17 Oct 2016 08:45:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 99191172E; Mon, 17 Oct 2016 08:45:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8ixw0041220; Mon, 17 Oct 2016 08:44:59 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8ixG1041218; Mon, 17 Oct 2016 08:44:59 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170844.u9H8ixG1041218@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:44:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307512 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:45:00 -0000 Author: sephe Date: Mon Oct 17 08:44:59 2016 New Revision: 307512 URL: https://svnweb.freebsd.org/changeset/base/307512 Log: MFC 305794 hyperv/hn: Use sx for the main lock. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7870 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:42:54 2016 (r307511) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 08:44:59 2016 (r307512) @@ -204,10 +204,7 @@ struct hn_softc { device_t hn_dev; int hn_carrier; int hn_if_flags; - struct mtx hn_lock; - int hn_initdone; - /* See hv_netvsc_drv_freebsd.c for rules on how to use */ - int temp_unusable; + struct sx hn_lock; struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:42:54 2016 (r307511) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:44:59 2016 (r307512) @@ -195,21 +195,12 @@ struct hn_txdesc { #define HN_LRO_ACKCNT_DEF 1 -/* - * Be aware that this sleepable mutex will exhibit WITNESS errors when - * certain TCP and ARP code paths are taken. This appears to be a - * well-known condition, as all other drivers checked use a sleeping - * mutex to protect their transmit paths. - * Also Be aware that mutexes do not play well with semaphores, and there - * is a conflicting semaphore in a certain channel code path. - */ -#define NV_LOCK_INIT(_sc, _name) \ - mtx_init(&(_sc)->hn_lock, _name, MTX_NETWORK_LOCK, MTX_DEF) -#define NV_LOCK(_sc) mtx_lock(&(_sc)->hn_lock) -#define NV_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->hn_lock, MA_OWNED) -#define NV_UNLOCK(_sc) mtx_unlock(&(_sc)->hn_lock) -#define NV_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->hn_lock) - +#define HN_LOCK_INIT(sc) \ + sx_init(&(sc)->hn_lock, device_get_nameunit((sc)->hn_dev)) +#define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED) +#define HN_LOCK_DESTROY(sc) sx_destroy(&(sc)->hn_lock) +#define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) +#define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) /* * Globals @@ -463,6 +454,7 @@ netvsc_attach(device_t dev) sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); + HN_LOCK_INIT(sc); if (hn_tx_taskq == NULL) { sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, @@ -484,7 +476,6 @@ netvsc_attach(device_t dev) } else { sc->hn_tx_taskq = hn_tx_taskq; } - NV_LOCK_INIT(sc, "NetVSCLock"); ifp = sc->hn_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; @@ -669,6 +660,7 @@ netvsc_detach(device_t dev) taskqueue_free(sc->hn_tx_taskq); vmbus_xact_ctx_destroy(sc->hn_xact); + HN_LOCK_DESTROY(sc); return (0); } @@ -1475,39 +1467,27 @@ skip: return (0); } -/* - * Rules for using sc->temp_unusable: - * 1. sc->temp_unusable can only be read or written while holding NV_LOCK() - * 2. code reading sc->temp_unusable under NV_LOCK(), and finding - * sc->temp_unusable set, must release NV_LOCK() and exit - * 3. to retain exclusive control of the interface, - * sc->temp_unusable must be set by code before releasing NV_LOCK() - * 4. only code setting sc->temp_unusable can clear sc->temp_unusable - * 5. code setting sc->temp_unusable must eventually clear sc->temp_unusable - */ - -/* - * Standard ioctl entry point. Called when the user wants to configure - * the interface. - */ static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct hn_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; int mask, error = 0; - int retry_cnt = 500; - + switch (cmd) { case SIOCSIFMTU: - if (ifp->if_mtu == ifr->ifr_mtu) - break; - if (ifr->ifr_mtu > NETVSC_MAX_CONFIGURABLE_MTU) { error = EINVAL; break; } + HN_LOCK(sc); + + if (ifp->if_mtu == ifr->ifr_mtu) { + HN_UNLOCK(sc); + break; + } + /* Obtain and record requested MTU */ ifp->if_mtu = ifr->ifr_mtu; @@ -1516,40 +1496,18 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, * Make sure that LRO aggregation length limit is still * valid, after the MTU change. */ - NV_LOCK(sc); if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < HN_LRO_LENLIM_MIN(ifp)) hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); - NV_UNLOCK(sc); #endif - do { - NV_LOCK(sc); - if (!sc->temp_unusable) { - sc->temp_unusable = TRUE; - retry_cnt = -1; - } - NV_UNLOCK(sc); - if (retry_cnt > 0) { - retry_cnt--; - DELAY(5 * 1000); - } - } while (retry_cnt > 0); - - if (retry_cnt == 0) { - error = EINVAL; - break; - } - /* We must remove and add back the device to cause the new * MTU to take effect. This includes tearing down, but not * deleting the channel, then bringing it back up. */ error = hv_rf_on_device_remove(sc); if (error) { - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); + HN_UNLOCK(sc); break; } @@ -1569,29 +1527,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_init_locked(sc); - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); + HN_UNLOCK(sc); break; case SIOCSIFFLAGS: - do { - NV_LOCK(sc); - if (!sc->temp_unusable) { - sc->temp_unusable = TRUE; - retry_cnt = -1; - } - NV_UNLOCK(sc); - if (retry_cnt > 0) { - retry_cnt--; - DELAY(5 * 1000); - } - } while (retry_cnt > 0); - - if (retry_cnt == 0) { - error = EINVAL; - break; - } + HN_LOCK(sc); if (ifp->if_flags & IFF_UP) { /* @@ -1620,14 +1560,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_stop(sc); } } - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); sc->hn_if_flags = ifp->if_flags; + + HN_UNLOCK(sc); break; case SIOCSIFCAP: - NV_LOCK(sc); + HN_LOCK(sc); mask = ifr->ifr_reqcap ^ ifp->if_capenable; if (mask & IFCAP_TXCSUM) { @@ -1663,7 +1602,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, ifp->if_hwassist &= ~CSUM_IP6_TSO; } - NV_UNLOCK(sc); + HN_UNLOCK(sc); break; case SIOCADDMULTI: @@ -1694,6 +1633,8 @@ hn_stop(struct hn_softc *sc) struct ifnet *ifp; int ret, i; + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; if (bootverbose) @@ -1705,7 +1646,6 @@ hn_stop(struct hn_softc *sc) sc->hn_tx_ring[i].hn_oactive = 0; if_link_state_change(ifp, LINK_STATE_DOWN); - sc->hn_initdone = 0; ret = hv_rf_on_close(sc); } @@ -1774,6 +1714,8 @@ hn_init_locked(struct hn_softc *sc) struct ifnet *ifp; int ret, i; + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; if (ifp->if_drv_flags & IFF_DRV_RUNNING) { @@ -1783,11 +1725,8 @@ hn_init_locked(struct hn_softc *sc) hv_promisc_mode = 1; ret = hv_rf_on_open(sc); - if (ret != 0) { + if (ret != 0) return; - } else { - sc->hn_initdone = 1; - } atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) @@ -1797,27 +1736,14 @@ hn_init_locked(struct hn_softc *sc) if_link_state_change(ifp, LINK_STATE_UP); } -/* - * - */ static void hn_init(void *xsc) { struct hn_softc *sc = xsc; - NV_LOCK(sc); - if (sc->temp_unusable) { - NV_UNLOCK(sc); - return; - } - sc->temp_unusable = TRUE; - NV_UNLOCK(sc); - + HN_LOCK(sc); hn_init_locked(sc); - - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); + HN_UNLOCK(sc); } #ifdef LATER @@ -1848,13 +1774,15 @@ hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS if (error || req->newptr == NULL) return error; + HN_LOCK(sc); if (lenlim < HN_LRO_LENLIM_MIN(sc->hn_ifp) || - lenlim > TCP_LRO_LENGTH_MAX) + lenlim > TCP_LRO_LENGTH_MAX) { + HN_UNLOCK(sc); return EINVAL; - - NV_LOCK(sc); + } hn_set_lro_lenlim(sc, lenlim); - NV_UNLOCK(sc); + HN_UNLOCK(sc); + return 0; } @@ -1881,10 +1809,10 @@ hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS * count limit. */ --ackcnt; - NV_LOCK(sc); + HN_LOCK(sc); for (i = 0; i < sc->hn_rx_ring_inuse; ++i) sc->hn_rx_ring[i].hn_lro.lro_ackcnt_lim = ackcnt; - NV_UNLOCK(sc); + HN_UNLOCK(sc); return 0; } @@ -1905,7 +1833,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARG if (error || req->newptr == NULL) return error; - NV_LOCK(sc); + HN_LOCK(sc); for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; @@ -1914,7 +1842,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARG else rxr->hn_trust_hcsum &= ~hcsum; } - NV_UNLOCK(sc); + HN_UNLOCK(sc); return 0; } @@ -1932,7 +1860,9 @@ hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS) if (chim_size > sc->hn_chim_szmax || chim_size <= 0) return EINVAL; + HN_LOCK(sc); hn_set_chim_size(sc, chim_size); + HN_UNLOCK(sc); return 0; } @@ -2028,12 +1958,12 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG if (error || req->newptr == NULL) return error; - NV_LOCK(sc); + HN_LOCK(sc); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { txr = &sc->hn_tx_ring[i]; *((int *)((uint8_t *)txr + ofs)) = conf; } - NV_UNLOCK(sc); + HN_UNLOCK(sc); return 0; } @@ -2677,10 +2607,8 @@ hn_set_chim_size(struct hn_softc *sc, in { int i; - NV_LOCK(sc); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_chim_size = chim_size; - NV_UNLOCK(sc); } static void From owner-svn-src-stable@freebsd.org Mon Oct 17 08:48:47 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24BA0C14CEE; Mon, 17 Oct 2016 08:48:47 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC81C1A2C; Mon, 17 Oct 2016 08:48:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8mktM041404; Mon, 17 Oct 2016 08:48:46 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8mkte041403; Mon, 17 Oct 2016 08:48:46 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170848.u9H8mkte041403@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:48:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307513 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:48:47 -0000 Author: sephe Date: Mon Oct 17 08:48:45 2016 New Revision: 307513 URL: https://svnweb.freebsd.org/changeset/base/307513 Log: MFC 305795,305796 305795 hyperv/hn: Bring in shims from stable/10 This eases future MFCs to stable/10. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7871 305796 hyperv/hn: Remove the FreeBSD_version check for TSO configuration It is available on both stable/10 and stable/11. This eases future MFCs to stable/10. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7872 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:44:59 2016 (r307512) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:48:45 2016 (r307513) @@ -232,12 +232,10 @@ SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosti "Trust ip packet verification on host side, " "when csum info is missing (global setting)"); -#if __FreeBSD_version >= 1100045 /* Limit TSO burst size */ static int hn_tso_maxlen = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, &hn_tso_maxlen, 0, "TSO burst limit"); -#endif /* Limit chimney send size */ static int hn_tx_chimney_size = 0; @@ -318,8 +316,12 @@ static int hn_lro_ackcnt_sysctl(SYSCTL_H #endif static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); static int hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); +#if __FreeBSD_version < 1100095 +static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS); +#else static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); +#endif +static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); @@ -448,9 +450,7 @@ netvsc_attach(device_t dev) uint32_t link_status; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; -#if __FreeBSD_version >= 1100045 int tso_maxlen; -#endif sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); @@ -583,7 +583,6 @@ netvsc_attach(device_t dev) if (link_status == NDIS_MEDIA_STATE_CONNECTED) sc->hn_carrier = 1; -#if __FreeBSD_version >= 1100045 tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) tso_maxlen = IP_MAXPACKET; @@ -592,17 +591,14 @@ netvsc_attach(device_t dev) ifp->if_hw_tsomaxsegsize = PAGE_SIZE; ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); -#endif error = hn_rndis_get_eaddr(sc, eaddr); if (error) goto failed; ether_ifattach(ifp, eaddr); -#if __FreeBSD_version >= 1100045 if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); -#endif hn_set_chim_size(sc, sc->hn_chim_szmax); if (hn_tx_chimney_size > 0 && @@ -1866,32 +1862,33 @@ hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS) return 0; } +#if __FreeBSD_version < 1100095 static int -hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) +hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; int ofs = arg2, i, error; struct hn_rx_ring *rxr; - u_long stat; + uint64_t stat; stat = 0; - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; - stat += *((u_long *)((uint8_t *)rxr + ofs)); + stat += *((int *)((uint8_t *)rxr + ofs)); } - error = sysctl_handle_long(oidp, &stat, 0, req); + error = sysctl_handle_64(oidp, &stat, 0, req); if (error || req->newptr == NULL) return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; - *((u_long *)((uint8_t *)rxr + ofs)) = 0; + *((int *)((uint8_t *)rxr + ofs)) = 0; } return 0; } - +#else static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS) { @@ -1918,6 +1915,34 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG return 0; } +#endif + +static int +hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int ofs = arg2, i, error; + struct hn_rx_ring *rxr; + u_long stat; + + stat = 0; + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + rxr = &sc->hn_rx_ring[i]; + stat += *((u_long *)((uint8_t *)rxr + ofs)); + } + + error = sysctl_handle_long(oidp, &stat, 0, req); + if (error || req->newptr == NULL) + return error; + + /* Zero out this stat. */ + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + rxr = &sc->hn_rx_ring[i]; + *((u_long *)((uint8_t *)rxr + ofs)) = 0; + } + return 0; +} + static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) { @@ -2168,11 +2193,21 @@ hn_create_rx_data(struct hn_softc *sc, i SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_queued", CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_rx_ring, hn_lro.lro_queued), - hn_rx_stat_u64_sysctl, "LU", "LRO queued"); +#if __FreeBSD_version < 1100095 + hn_rx_stat_int_sysctl, +#else + hn_rx_stat_u64_sysctl, +#endif + "LU", "LRO queued"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_flushed", CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_rx_ring, hn_lro.lro_flushed), - hn_rx_stat_u64_sysctl, "LU", "LRO flushed"); +#if __FreeBSD_version < 1100095 + hn_rx_stat_int_sysctl, +#else + hn_rx_stat_u64_sysctl, +#endif + "LU", "LRO flushed"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_tried", CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_rx_ring, hn_lro_tried), From owner-svn-src-stable@freebsd.org Mon Oct 17 08:53:13 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 462B9C14FCC; Mon, 17 Oct 2016 08:53:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2327C1F5F; Mon, 17 Oct 2016 08:53:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H8rCPG044941; Mon, 17 Oct 2016 08:53:12 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H8rCBA044940; Mon, 17 Oct 2016 08:53:12 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170853.u9H8rCBA044940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 08:53:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307514 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 08:53:13 -0000 Author: sephe Date: Mon Oct 17 08:53:12 2016 New Revision: 307514 URL: https://svnweb.freebsd.org/changeset/base/307514 Log: MFC 305801,305923,305924 305801 hyperv/hn: Fix some ifnet settings - ifnet.if_mtu does not require explicit setting. - ifnet.if_hdrlen must be set after ether_ifattach(). Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7873 305923 hyperv/hn: Regroup ifnet setup code. While I'm here, add comment along the attach DEVMETHOD. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7874 305924 hyperv/hn: Put debug message under bootverbose Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7875 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:48:45 2016 (r307513) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 08:53:12 2016 (r307514) @@ -456,6 +456,9 @@ netvsc_attach(device_t dev) sc->hn_prichan = vmbus_get_channel(dev); HN_LOCK_INIT(sc); + /* + * Setup taskqueue for transmission. + */ if (hn_tx_taskq == NULL) { sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, taskqueue_thread_enqueue, &sc->hn_tx_taskq); @@ -477,11 +480,22 @@ netvsc_attach(device_t dev) sc->hn_tx_taskq = hn_tx_taskq; } + /* + * Allocate ifnet and setup its name earlier, so that if_printf + * can be used by functions, which will be called after + * ether_ifattach(). + */ ifp = sc->hn_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); /* + * Initialize ifmedia earlier so that it can be unconditionally + * destroyed, if error happened later on. + */ + ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts); + + /* * Figure out the # of RX rings (ring_cnt) and the # of TX rings * to use (tx_ring_cnt). * @@ -511,6 +525,10 @@ netvsc_attach(device_t dev) */ sc->hn_cpu = atomic_fetchadd_int(&hn_cpu_index, ring_cnt) % mp_ncpus; + /* + * Create enough TX/RX rings, even if only limited number of + * channels can be allocated. + */ error = hn_create_tx_data(sc, tx_ring_cnt); if (error) goto failed; @@ -533,10 +551,54 @@ netvsc_attach(device_t dev) if (error) goto failed; + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) + goto failed; + if (link_status == NDIS_MEDIA_STATE_CONNECTED) + sc->hn_carrier = 1; + + error = hn_rndis_get_eaddr(sc, eaddr); + if (error) + goto failed; + +#if __FreeBSD_version >= 1100099 + if (sc->hn_rx_ring_inuse > 1) { + /* + * Reduce TCP segment aggregation limit for multiple + * RX rings to increase ACK timeliness. + */ + hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MULTIRX_DEF); + } +#endif + + hn_set_chim_size(sc, sc->hn_chim_szmax); + if (hn_tx_chimney_size > 0 && + hn_tx_chimney_size < sc->hn_chim_szmax) + hn_set_chim_size(sc, hn_tx_chimney_size); + + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, + &sc->hn_nvs_ver, 0, "NVS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_ndis_version_sysctl, "A", "NDIS version"); + + /* + * Setup the ifmedia, which has been initialized earlier. + */ + ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&sc->hn_media, IFM_ETHER | IFM_AUTO); + /* XXX ifmedia_set really should do this for us */ + sc->hn_media.ifm_media = sc->hn_media.ifm_cur->ifm_media; + + /* + * Setup the ifnet for this interface. + */ + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; ifp->if_init = hn_init; - ifp->if_mtu = ETHERMTU; if (hn_use_if_start) { int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); @@ -549,16 +611,6 @@ netvsc_attach(device_t dev) ifp->if_qflush = hn_xmit_qflush; } - ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts); - ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(&sc->hn_media, IFM_ETHER | IFM_AUTO); - /* XXX ifmedia_set really should do this for us */ - sc->hn_media.ifm_media = sc->hn_media.ifm_cur->ifm_media; - - /* - * Tell upper layers that we support full VLAN capability. - */ - ifp->if_hdrlen = sizeof(struct ether_vlan_header); ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO; @@ -567,54 +619,27 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; -#if __FreeBSD_version >= 1100099 - if (sc->hn_rx_ring_inuse > 1) { - /* - * Reduce TCP segment aggregation limit for multiple - * RX rings to increase ACK timeliness. - */ - hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MULTIRX_DEF); - } -#endif - - error = hn_rndis_get_linkstatus(sc, &link_status); - if (error) - goto failed; - if (link_status == NDIS_MEDIA_STATE_CONNECTED) - sc->hn_carrier = 1; - tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) tso_maxlen = IP_MAXPACKET; - ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; ifp->if_hw_tsomaxsegsize = PAGE_SIZE; ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); - error = hn_rndis_get_eaddr(sc, eaddr); - if (error) - goto failed; ether_ifattach(ifp, eaddr); - if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, - ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); - - hn_set_chim_size(sc, sc->hn_chim_szmax); - if (hn_tx_chimney_size > 0 && - hn_tx_chimney_size < sc->hn_chim_szmax) - hn_set_chim_size(sc, hn_tx_chimney_size); + if (bootverbose) { + if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, + ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); + } - ctx = device_get_sysctl_ctx(dev); - child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); - SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, - &sc->hn_nvs_ver, 0, "NVS version"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, - hn_ndis_version_sysctl, "A", "NDIS version"); + /* Inform the upper layer about the long frame support. */ + ifp->if_hdrlen = sizeof(struct ether_vlan_header); return (0); failed: + /* TODO: reuse netvsc_detach() */ hn_destroy_tx_data(sc); if (ifp != NULL) if_free(ifp); From owner-svn-src-stable@freebsd.org Mon Oct 17 09:31:50 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B29E7C15B83; Mon, 17 Oct 2016 09:31:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6EE9311AA; Mon, 17 Oct 2016 09:31:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9H9VnWd061071; Mon, 17 Oct 2016 09:31:49 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9H9Vn8N061053; Mon, 17 Oct 2016 09:31:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610170931.u9H9Vn8N061053@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 17 Oct 2016 09:31:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307516 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 09:31:50 -0000 Author: sephe Date: Mon Oct 17 09:31:49 2016 New Revision: 307516 URL: https://svnweb.freebsd.org/changeset/base/307516 Log: MFC 305925,305926,305960 305925 hyperv/hn: Don't mess up RSS key and indirect table after attachment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7889 305926 hyperv/hn: Add sysctls to dynamic adjust RSS key and indirect table Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7890 305960 hyperv/hn: Apply RSS indirect table fixup before configure RNDIS RSS. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7916 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/dev/hyperv/netvsc/ndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 09:16:44 2016 (r307515) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 17 09:31:49 2016 (r307516) @@ -325,6 +325,8 @@ static int hn_rx_stat_ulong_sysctl(SYSCT static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); @@ -391,6 +393,62 @@ hn_get_txswq_depth(const struct hn_tx_ri } static int +hn_rss_reconfig(struct hn_softc *sc) +{ + int error; + + HN_LOCK_ASSERT(sc); + + /* + * Disable RSS first. + * + * NOTE: + * Direct reconfiguration by setting the UNCHG flags does + * _not_ work properly. + */ + if (bootverbose) + if_printf(sc->hn_ifp, "disable RSS\n"); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_DISABLE); + if (error) { + if_printf(sc->hn_ifp, "RSS disable failed\n"); + return (error); + } + + /* + * Reenable the RSS w/ the updated RSS key or indirect + * table. + */ + if (bootverbose) + if_printf(sc->hn_ifp, "reconfig RSS\n"); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_NONE); + if (error) { + if_printf(sc->hn_ifp, "RSS reconfig failed\n"); + return (error); + } + return (0); +} + +static void +hn_rss_ind_fixup(struct hn_softc *sc, int nchan) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + int i; + + /* + * Check indirect table to make sure that all channels in it + * can be used. + */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) { + if (rss->rss_ind[i] >= nchan) { + if_printf(sc->hn_ifp, + "RSS indirect table %d fixup: %u -> %d\n", + i, rss->rss_ind[i], nchan - 1); + rss->rss_ind[i] = nchan - 1; + } + } +} + +static int hn_ifmedia_upd(struct ifnet *ifp __unused) { @@ -583,6 +641,12 @@ netvsc_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_ndis_version_sysctl, "A", "NDIS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_rss_key_sysctl, "IU", "RSS key"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_ind", + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_rss_ind_sysctl, "IU", "RSS indirect table"); /* * Setup the ifmedia, which has been initialized earlier. @@ -2031,6 +2095,51 @@ hn_ndis_version_sysctl(SYSCTL_HANDLER_AR } static int +hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error; + + HN_LOCK(sc); + + error = SYSCTL_OUT(req, sc->hn_rss.rss_key, sizeof(sc->hn_rss.rss_key)); + if (error || req->newptr == NULL) + goto back; + + error = SYSCTL_IN(req, sc->hn_rss.rss_key, sizeof(sc->hn_rss.rss_key)); + if (error) + goto back; + + error = hn_rss_reconfig(sc); +back: + HN_UNLOCK(sc); + return (error); +} + +static int +hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error; + + HN_LOCK(sc); + + error = SYSCTL_OUT(req, sc->hn_rss.rss_ind, sizeof(sc->hn_rss.rss_ind)); + if (error || req->newptr == NULL) + goto back; + + error = SYSCTL_IN(req, sc->hn_rss.rss_ind, sizeof(sc->hn_rss.rss_ind)); + if (error) + goto back; + + hn_rss_ind_fixup(sc, sc->hn_rx_ring_inuse); + error = hn_rss_reconfig(sc); +back: + HN_UNLOCK(sc); + return (error); +} + +static int hn_check_iplen(const struct mbuf *m, int hoff) { const struct ip *ip; @@ -3159,15 +3268,34 @@ hn_synth_attach(struct hn_softc *sc, int * are allocated. */ - /* Setup default RSS key. */ - memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); + if (!device_is_attached(sc->hn_dev)) { + /* + * Setup default RSS key and indirect table for the + * attach DEVMETHOD. They can be altered later on, + * so don't mess them up once this interface is attached. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "setup default RSS key and " + "indirect table\n"); + } + + /* Setup default RSS key. */ + memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); - /* Setup default RSS indirect table. */ - /* TODO: Take ndis_rss_caps.ndis_nind into account. */ - for (i = 0; i < NDIS_HASH_INDCNT; ++i) - rss->rss_ind[i] = i % nchan; + /* Setup default RSS indirect table. */ + /* TODO: Take ndis_rss_caps.ndis_nind into account. */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) + rss->rss_ind[i] = i % nchan; + } else { + /* + * # of usable channels may be changed, so we have to + * make sure that all entries in RSS indirect table + * are valid. + */ + hn_rss_ind_fixup(sc, nchan); + } - error = hn_rndis_conf_rss(sc); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_NONE); if (error) { /* * Failed to configure RSS key or indirect table; only Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 09:16:44 2016 (r307515) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 17 09:31:49 2016 (r307516) @@ -837,7 +837,7 @@ hn_rndis_conf_offload(struct hn_softc *s } int -hn_rndis_conf_rss(struct hn_softc *sc) +hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags) { struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; struct ndis_rss_params *prm = &rss->rss_params; @@ -858,6 +858,7 @@ hn_rndis_conf_rss(struct hn_softc *sc) prm->ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_PARAMS; prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; prm->ndis_hdr.ndis_size = sizeof(*rss); + prm->ndis_flags = flags; prm->ndis_hash = NDIS_HASH_FUNCTION_TOEPLITZ | NDIS_HASH_IPV4 | NDIS_HASH_TCP_IPV4 | NDIS_HASH_IPV6 | NDIS_HASH_TCP_IPV6; Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 09:16:44 2016 (r307515) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 17 09:31:49 2016 (r307516) @@ -118,7 +118,7 @@ uint32_t hn_chim_alloc(struct hn_softc * void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); int hn_rndis_attach(struct hn_softc *sc); -int hn_rndis_conf_rss(struct hn_softc *sc); +int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags); void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, size_t pktsize, size_t pi_dlen, uint32_t pi_type); int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt); Modified: stable/11/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 09:16:44 2016 (r307515) +++ stable/11/sys/dev/hyperv/netvsc/ndis.h Mon Oct 17 09:31:49 2016 (r307516) @@ -188,6 +188,7 @@ struct ndis_rss_params { #define NDIS_RSS_PARAMS_REV_1 1 /* NDIS 6.0 */ #define NDIS_RSS_PARAMS_REV_2 2 /* NDIS 6.20 */ +#define NDIS_RSS_FLAG_NONE 0x0000 #define NDIS_RSS_FLAG_BCPU_UNCHG 0x0001 #define NDIS_RSS_FLAG_HASH_UNCHG 0x0002 #define NDIS_RSS_FLAG_IND_UNCHG 0x0004 From owner-svn-src-stable@freebsd.org Mon Oct 17 18:04:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 808DCC15B20; Mon, 17 Oct 2016 18:04:21 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 511932E0; Mon, 17 Oct 2016 18:04:21 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HI4KV5057642; Mon, 17 Oct 2016 18:04:20 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HI4K7W057638; Mon, 17 Oct 2016 18:04:20 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201610171804.u9HI4K7W057638@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Mon, 17 Oct 2016 18:04:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307524 - stable/11/sys/dev/qlxgbe X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 18:04:21 -0000 Author: davidcs Date: Mon Oct 17 18:04:19 2016 New Revision: 307524 URL: https://svnweb.freebsd.org/changeset/base/307524 Log: MFC r306790 Add support for adding up to 64 Multicast addresses with a single mailbox command Modified: stable/11/sys/dev/qlxgbe/ql_hw.c stable/11/sys/dev/qlxgbe/ql_hw.h stable/11/sys/dev/qlxgbe/ql_os.c stable/11/sys/dev/qlxgbe/ql_ver.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/qlxgbe/ql_hw.c ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_hw.c Mon Oct 17 15:02:17 2016 (r307523) +++ stable/11/sys/dev/qlxgbe/ql_hw.c Mon Oct 17 18:04:19 2016 (r307524) @@ -1128,12 +1128,21 @@ qla_config_intr_coalesce(qla_host_t *ha, * Can be unicast, multicast or broadcast. */ static int -qla_config_mac_addr(qla_host_t *ha, uint8_t *mac_addr, uint32_t add_mac) +qla_config_mac_addr(qla_host_t *ha, uint8_t *mac_addr, uint32_t add_mac, + uint32_t num_mac) { q80_config_mac_addr_t *cmac; q80_config_mac_addr_rsp_t *cmac_rsp; uint32_t err; device_t dev = ha->pci_dev; + int i; + uint8_t *mac_cpy = mac_addr; + + if (num_mac > Q8_MAX_MAC_ADDRS) { + device_printf(dev, "%s: %s num_mac [0x%x] > Q8_MAX_MAC_ADDRS\n", + __func__, (add_mac ? "Add" : "Del"), num_mac); + return (-1); + } cmac = (q80_config_mac_addr_t *)ha->hw.mbox; bzero(cmac, (sizeof (q80_config_mac_addr_t))); @@ -1149,9 +1158,13 @@ qla_config_mac_addr(qla_host_t *ha, uint cmac->cmd |= Q8_MBX_CMAC_CMD_CAM_INGRESS; - cmac->nmac_entries = 1; + cmac->nmac_entries = num_mac; cmac->cntxt_id = ha->hw.rcv_cntxt_id; - bcopy(mac_addr, cmac->mac_addr[0].addr, 6); + + for (i = 0; i < num_mac; i++) { + bcopy(mac_addr, cmac->mac_addr[i].addr, Q8_ETHER_ADDR_LEN); + mac_addr = mac_addr + ETHER_ADDR_LEN; + } if (qla_mbx_cmd(ha, (uint32_t *)cmac, (sizeof (q80_config_mac_addr_t) >> 2), @@ -1165,11 +1178,14 @@ qla_config_mac_addr(qla_host_t *ha, uint err = Q8_MBX_RSP_STATUS(cmac_rsp->regcnt_status); if (err) { - device_printf(dev, "%s: %s " - "%02x:%02x:%02x:%02x:%02x:%02x failed1 [0x%08x]\n", - __func__, (add_mac ? "Add" : "Del"), - mac_addr[0], mac_addr[1], mac_addr[2], - mac_addr[3], mac_addr[4], mac_addr[5], err); + device_printf(dev, "%s: %s failed1 [0x%08x]\n", __func__, + (add_mac ? "Add" : "Del"), err); + for (i = 0; i < num_mac; i++) { + device_printf(dev, "%s: %02x:%02x:%02x:%02x:%02x:%02x\n", + __func__, mac_cpy[0], mac_cpy[1], mac_cpy[2], + mac_cpy[3], mac_cpy[4], mac_cpy[5]); + mac_cpy += ETHER_ADDR_LEN; + } return (-1); } @@ -2254,6 +2270,7 @@ ql_del_hw_if(qla_host_t *ha) (void)qla_stop_nic_func(ha); qla_del_rcv_cntxt(ha); + qla_del_xmt_cntxt(ha); if (ha->hw.flags.init_intr_cnxt) { @@ -2270,6 +2287,7 @@ ql_del_hw_if(qla_host_t *ha) ha->hw.flags.init_intr_cnxt = 0; } + return; } @@ -2368,7 +2386,7 @@ ql_init_hw_if(qla_host_t *ha) } ha->hw.max_tx_segs = 0; - if (qla_config_mac_addr(ha, ha->hw.mac_addr, 1)) + if (qla_config_mac_addr(ha, ha->hw.mac_addr, 1, 1)) return(-1); ha->hw.flags.unicast_mac = 1; @@ -2376,7 +2394,7 @@ ql_init_hw_if(qla_host_t *ha) bcast_mac[0] = 0xFF; bcast_mac[1] = 0xFF; bcast_mac[2] = 0xFF; bcast_mac[3] = 0xFF; bcast_mac[4] = 0xFF; bcast_mac[5] = 0xFF; - if (qla_config_mac_addr(ha, bcast_mac, 1)) + if (qla_config_mac_addr(ha, bcast_mac, 1, 1)) return (-1); ha->hw.flags.bcast_mac = 1; @@ -2733,14 +2751,14 @@ qla_del_rcv_cntxt(qla_host_t *ha) bcast_mac[0] = 0xFF; bcast_mac[1] = 0xFF; bcast_mac[2] = 0xFF; bcast_mac[3] = 0xFF; bcast_mac[4] = 0xFF; bcast_mac[5] = 0xFF; - if (qla_config_mac_addr(ha, bcast_mac, 0)) + if (qla_config_mac_addr(ha, bcast_mac, 0, 1)) return; ha->hw.flags.bcast_mac = 0; } if (ha->hw.flags.unicast_mac) { - if (qla_config_mac_addr(ha, ha->hw.mac_addr, 0)) + if (qla_config_mac_addr(ha, ha->hw.mac_addr, 0, 1)) return; ha->hw.flags.unicast_mac = 0; } @@ -2926,12 +2944,20 @@ qla_init_xmt_cntxt(qla_host_t *ha) } static int -qla_hw_add_all_mcast(qla_host_t *ha) +qla_hw_all_mcast(qla_host_t *ha, uint32_t add_mcast) { int i, nmcast; + uint32_t count = 0; + uint8_t *mcast; nmcast = ha->hw.nmcast; + QL_DPRINT2(ha, (ha->pci_dev, + "%s:[0x%x] enter nmcast = %d \n", __func__, add_mcast, nmcast)); + + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); + for (i = 0 ; ((i < Q8_MAX_NUM_MULTICAST_ADDRS) && nmcast); i++) { if ((ha->hw.mcast[i].addr[0] != 0) || (ha->hw.mcast[i].addr[1] != 0) || @@ -2940,52 +2966,80 @@ qla_hw_add_all_mcast(qla_host_t *ha) (ha->hw.mcast[i].addr[4] != 0) || (ha->hw.mcast[i].addr[5] != 0)) { - if (qla_config_mac_addr(ha, ha->hw.mcast[i].addr, 1)) { - device_printf(ha->pci_dev, "%s: failed\n", - __func__); - return (-1); + bcopy(ha->hw.mcast[i].addr, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + + if (count == Q8_MAX_MAC_ADDRS) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, + add_mcast, count)) { + device_printf(ha->pci_dev, + "%s: failed\n", __func__); + return (-1); + } + + count = 0; + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, + (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); } nmcast--; } } + + if (count) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, add_mcast, + count)) { + device_printf(ha->pci_dev, "%s: failed\n", __func__); + return (-1); + } + } + QL_DPRINT2(ha, (ha->pci_dev, + "%s:[0x%x] exit nmcast = %d \n", __func__, add_mcast, nmcast)); + return 0; } static int -qla_hw_del_all_mcast(qla_host_t *ha) +qla_hw_add_all_mcast(qla_host_t *ha) { - int i, nmcast; + int ret; - nmcast = ha->hw.nmcast; + ret = qla_hw_all_mcast(ha, 1); - for (i = 0 ; ((i < Q8_MAX_NUM_MULTICAST_ADDRS) && nmcast); i++) { - if ((ha->hw.mcast[i].addr[0] != 0) || - (ha->hw.mcast[i].addr[1] != 0) || - (ha->hw.mcast[i].addr[2] != 0) || - (ha->hw.mcast[i].addr[3] != 0) || - (ha->hw.mcast[i].addr[4] != 0) || - (ha->hw.mcast[i].addr[5] != 0)) { + return (ret); +} - if (qla_config_mac_addr(ha, ha->hw.mcast[i].addr, 0)) - return (-1); +static int +qla_hw_del_all_mcast(qla_host_t *ha) +{ + int ret; - nmcast--; - } - } - return 0; + ret = qla_hw_all_mcast(ha, 0); + + bzero(ha->hw.mcast, (sizeof (qla_mcast_t) * Q8_MAX_NUM_MULTICAST_ADDRS)); + ha->hw.nmcast = 0; + + return (ret); } static int -qla_hw_add_mcast(qla_host_t *ha, uint8_t *mta) +qla_hw_mac_addr_present(qla_host_t *ha, uint8_t *mta) { int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { - if (QL_MAC_CMP(ha->hw.mcast[i].addr, mta) == 0) - return 0; /* its been already added */ + return (0); /* its been already added */ } + return (-1); +} + +static int +qla_hw_add_mcast(qla_host_t *ha, uint8_t *mta, uint32_t nmcast) +{ + int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { @@ -2996,29 +3050,28 @@ qla_hw_add_mcast(qla_host_t *ha, uint8_t (ha->hw.mcast[i].addr[4] == 0) && (ha->hw.mcast[i].addr[5] == 0)) { - if (qla_config_mac_addr(ha, mta, 1)) - return (-1); - bcopy(mta, ha->hw.mcast[i].addr, Q8_MAC_ADDR_LEN); ha->hw.nmcast++; - return 0; + mta = mta + ETHER_ADDR_LEN; + nmcast--; + + if (nmcast == 0) + break; } + } return 0; } static int -qla_hw_del_mcast(qla_host_t *ha, uint8_t *mta) +qla_hw_del_mcast(qla_host_t *ha, uint8_t *mta, uint32_t nmcast) { int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { if (QL_MAC_CMP(ha->hw.mcast[i].addr, mta) == 0) { - if (qla_config_mac_addr(ha, mta, 0)) - return (-1); - ha->hw.mcast[i].addr[0] = 0; ha->hw.mcast[i].addr[1] = 0; ha->hw.mcast[i].addr[2] = 0; @@ -3028,7 +3081,11 @@ qla_hw_del_mcast(qla_host_t *ha, uint8_t ha->hw.nmcast--; - return 0; + mta = mta + ETHER_ADDR_LEN; + nmcast--; + + if (nmcast == 0) + break; } } return 0; @@ -3036,30 +3093,75 @@ qla_hw_del_mcast(qla_host_t *ha, uint8_t /* * Name: ql_hw_set_multi - * Function: Sets the Multicast Addresses provided the host O.S into the + * Function: Sets the Multicast Addresses provided by the host O.S into the * hardware (for the given interface) */ int -ql_hw_set_multi(qla_host_t *ha, uint8_t *mcast, uint32_t mcnt, +ql_hw_set_multi(qla_host_t *ha, uint8_t *mcast_addr, uint32_t mcnt, uint32_t add_mac) { + uint8_t *mta = mcast_addr; int i; - uint8_t *mta = mcast; int ret = 0; + uint32_t count = 0; + uint8_t *mcast; + + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); for (i = 0; i < mcnt; i++) { - if (add_mac) { - ret = qla_hw_add_mcast(ha, mta); - if (ret) - break; - } else { - ret = qla_hw_del_mcast(ha, mta); - if (ret) - break; + if (mta[0] || mta[1] || mta[2] || mta[3] || mta[4] || mta[5]) { + if (add_mac) { + if (qla_hw_mac_addr_present(ha, mta) != 0) { + bcopy(mta, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + } + } else { + if (qla_hw_mac_addr_present(ha, mta) == 0) { + bcopy(mta, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + } + } + } + if (count == Q8_MAX_MAC_ADDRS) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, + add_mac, count)) { + device_printf(ha->pci_dev, "%s: failed\n", + __func__); + return (-1); + } + + if (add_mac) { + qla_hw_add_mcast(ha, ha->hw.mac_addr_arr, + count); + } else { + qla_hw_del_mcast(ha, ha->hw.mac_addr_arr, + count); + } + + count = 0; + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); } mta += Q8_MAC_ADDR_LEN; } + + if (count) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, add_mac, + count)) { + device_printf(ha->pci_dev, "%s: failed\n", __func__); + return (-1); + } + if (add_mac) { + qla_hw_add_mcast(ha, ha->hw.mac_addr_arr, count); + } else { + qla_hw_del_mcast(ha, ha->hw.mac_addr_arr, count); + } + } + return (ret); } Modified: stable/11/sys/dev/qlxgbe/ql_hw.h ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_hw.h Mon Oct 17 15:02:17 2016 (r307523) +++ stable/11/sys/dev/qlxgbe/ql_hw.h Mon Oct 17 18:04:19 2016 (r307524) @@ -210,7 +210,7 @@ #define Q8_NUM_MBOX 512 -#define Q8_MAX_NUM_MULTICAST_ADDRS 1023 +#define Q8_MAX_NUM_MULTICAST_ADDRS 1022 #define Q8_MAC_ADDR_LEN 6 /* @@ -511,8 +511,9 @@ typedef struct _q80_config_intr_coalesc_ /* * Configure MAC Address */ +#define Q8_ETHER_ADDR_LEN 6 typedef struct _q80_mac_addr { - uint8_t addr[6]; + uint8_t addr[Q8_ETHER_ADDR_LEN]; uint16_t vlan_tci; } __packed q80_mac_addr_t; @@ -1548,7 +1549,7 @@ typedef struct _qla_hw_tx_cntxt { typedef struct _qla_mcast { uint16_t rsrvd; - uint8_t addr[6]; + uint8_t addr[ETHER_ADDR_LEN]; } __packed qla_mcast_t; typedef struct _qla_rdesc { @@ -1660,6 +1661,7 @@ typedef struct _qla_hw { /* multicast address list */ uint32_t nmcast; qla_mcast_t mcast[Q8_MAX_NUM_MULTICAST_ADDRS]; + uint8_t mac_addr_arr[(Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)]; /* reset sequence */ #define Q8_MAX_RESET_SEQ_IDX 16 Modified: stable/11/sys/dev/qlxgbe/ql_os.c ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_os.c Mon Oct 17 15:02:17 2016 (r307523) +++ stable/11/sys/dev/qlxgbe/ql_os.c Mon Oct 17 18:04:19 2016 (r307524) @@ -243,6 +243,8 @@ qla_watchdog(void *arg) ha->flags.qla_watchdog_pause = 1; ha->qla_initiate_recovery = 0; ha->err_inject = 0; + device_printf(ha->pci_dev, + "%s: taskqueue_enqueue(err_task) \n", __func__); taskqueue_enqueue(ha->err_tq, &ha->err_task); } else if (ha->flags.qla_interface_up) { @@ -452,7 +454,7 @@ qla_pci_attach(device_t dev) TASK_INIT(&ha->tx_task, 0, qla_tx_done, ha); - ha->tx_tq = taskqueue_create_fast("qla_txq", M_NOWAIT, + ha->tx_tq = taskqueue_create("qla_txq", M_NOWAIT, taskqueue_thread_enqueue, &ha->tx_tq); taskqueue_start_threads(&ha->tx_tq, 1, PI_NET, "%s txq", device_get_nameunit(ha->pci_dev)); @@ -470,13 +472,13 @@ qla_pci_attach(device_t dev) qla_watchdog, ha); TASK_INIT(&ha->err_task, 0, qla_error_recovery, ha); - ha->err_tq = taskqueue_create_fast("qla_errq", M_NOWAIT, + ha->err_tq = taskqueue_create("qla_errq", M_NOWAIT, taskqueue_thread_enqueue, &ha->err_tq); taskqueue_start_threads(&ha->err_tq, 1, PI_NET, "%s errq", device_get_nameunit(ha->pci_dev)); TASK_INIT(&ha->async_event_task, 0, qla_async_event, ha); - ha->async_event_tq = taskqueue_create_fast("qla_asyncq", M_NOWAIT, + ha->async_event_tq = taskqueue_create("qla_asyncq", M_NOWAIT, taskqueue_thread_enqueue, &ha->async_event_tq); taskqueue_start_threads(&ha->async_event_tq, 1, PI_NET, "%s asyncq", device_get_nameunit(ha->pci_dev)); Modified: stable/11/sys/dev/qlxgbe/ql_ver.h ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_ver.h Mon Oct 17 15:02:17 2016 (r307523) +++ stable/11/sys/dev/qlxgbe/ql_ver.h Mon Oct 17 18:04:19 2016 (r307524) @@ -36,6 +36,6 @@ #define QLA_VERSION_MAJOR 3 #define QLA_VERSION_MINOR 10 -#define QLA_VERSION_BUILD 30 +#define QLA_VERSION_BUILD 31 #endif /* #ifndef _QL_VER_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 18:07:53 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9350FC15C02; Mon, 17 Oct 2016 18:07:53 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6140E75E; Mon, 17 Oct 2016 18:07:53 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HI7qAe057810; Mon, 17 Oct 2016 18:07:52 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HI7qjU057806; Mon, 17 Oct 2016 18:07:52 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201610171807.u9HI7qjU057806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Mon, 17 Oct 2016 18:07:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307525 - stable/10/sys/dev/qlxgbe X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 18:07:53 -0000 Author: davidcs Date: Mon Oct 17 18:07:51 2016 New Revision: 307525 URL: https://svnweb.freebsd.org/changeset/base/307525 Log: MFC r306790 Add support for adding up to 64 Multicast addresses with a single mailbox command Modified: stable/10/sys/dev/qlxgbe/ql_hw.c stable/10/sys/dev/qlxgbe/ql_hw.h stable/10/sys/dev/qlxgbe/ql_os.c stable/10/sys/dev/qlxgbe/ql_ver.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/qlxgbe/ql_hw.c ============================================================================== --- stable/10/sys/dev/qlxgbe/ql_hw.c Mon Oct 17 18:04:19 2016 (r307524) +++ stable/10/sys/dev/qlxgbe/ql_hw.c Mon Oct 17 18:07:51 2016 (r307525) @@ -1128,12 +1128,21 @@ qla_config_intr_coalesce(qla_host_t *ha, * Can be unicast, multicast or broadcast. */ static int -qla_config_mac_addr(qla_host_t *ha, uint8_t *mac_addr, uint32_t add_mac) +qla_config_mac_addr(qla_host_t *ha, uint8_t *mac_addr, uint32_t add_mac, + uint32_t num_mac) { q80_config_mac_addr_t *cmac; q80_config_mac_addr_rsp_t *cmac_rsp; uint32_t err; device_t dev = ha->pci_dev; + int i; + uint8_t *mac_cpy = mac_addr; + + if (num_mac > Q8_MAX_MAC_ADDRS) { + device_printf(dev, "%s: %s num_mac [0x%x] > Q8_MAX_MAC_ADDRS\n", + __func__, (add_mac ? "Add" : "Del"), num_mac); + return (-1); + } cmac = (q80_config_mac_addr_t *)ha->hw.mbox; bzero(cmac, (sizeof (q80_config_mac_addr_t))); @@ -1149,9 +1158,13 @@ qla_config_mac_addr(qla_host_t *ha, uint cmac->cmd |= Q8_MBX_CMAC_CMD_CAM_INGRESS; - cmac->nmac_entries = 1; + cmac->nmac_entries = num_mac; cmac->cntxt_id = ha->hw.rcv_cntxt_id; - bcopy(mac_addr, cmac->mac_addr[0].addr, 6); + + for (i = 0; i < num_mac; i++) { + bcopy(mac_addr, cmac->mac_addr[i].addr, Q8_ETHER_ADDR_LEN); + mac_addr = mac_addr + ETHER_ADDR_LEN; + } if (qla_mbx_cmd(ha, (uint32_t *)cmac, (sizeof (q80_config_mac_addr_t) >> 2), @@ -1165,11 +1178,14 @@ qla_config_mac_addr(qla_host_t *ha, uint err = Q8_MBX_RSP_STATUS(cmac_rsp->regcnt_status); if (err) { - device_printf(dev, "%s: %s " - "%02x:%02x:%02x:%02x:%02x:%02x failed1 [0x%08x]\n", - __func__, (add_mac ? "Add" : "Del"), - mac_addr[0], mac_addr[1], mac_addr[2], - mac_addr[3], mac_addr[4], mac_addr[5], err); + device_printf(dev, "%s: %s failed1 [0x%08x]\n", __func__, + (add_mac ? "Add" : "Del"), err); + for (i = 0; i < num_mac; i++) { + device_printf(dev, "%s: %02x:%02x:%02x:%02x:%02x:%02x\n", + __func__, mac_cpy[0], mac_cpy[1], mac_cpy[2], + mac_cpy[3], mac_cpy[4], mac_cpy[5]); + mac_cpy += ETHER_ADDR_LEN; + } return (-1); } @@ -2254,6 +2270,7 @@ ql_del_hw_if(qla_host_t *ha) (void)qla_stop_nic_func(ha); qla_del_rcv_cntxt(ha); + qla_del_xmt_cntxt(ha); if (ha->hw.flags.init_intr_cnxt) { @@ -2270,6 +2287,7 @@ ql_del_hw_if(qla_host_t *ha) ha->hw.flags.init_intr_cnxt = 0; } + return; } @@ -2368,7 +2386,7 @@ ql_init_hw_if(qla_host_t *ha) } ha->hw.max_tx_segs = 0; - if (qla_config_mac_addr(ha, ha->hw.mac_addr, 1)) + if (qla_config_mac_addr(ha, ha->hw.mac_addr, 1, 1)) return(-1); ha->hw.flags.unicast_mac = 1; @@ -2376,7 +2394,7 @@ ql_init_hw_if(qla_host_t *ha) bcast_mac[0] = 0xFF; bcast_mac[1] = 0xFF; bcast_mac[2] = 0xFF; bcast_mac[3] = 0xFF; bcast_mac[4] = 0xFF; bcast_mac[5] = 0xFF; - if (qla_config_mac_addr(ha, bcast_mac, 1)) + if (qla_config_mac_addr(ha, bcast_mac, 1, 1)) return (-1); ha->hw.flags.bcast_mac = 1; @@ -2733,14 +2751,14 @@ qla_del_rcv_cntxt(qla_host_t *ha) bcast_mac[0] = 0xFF; bcast_mac[1] = 0xFF; bcast_mac[2] = 0xFF; bcast_mac[3] = 0xFF; bcast_mac[4] = 0xFF; bcast_mac[5] = 0xFF; - if (qla_config_mac_addr(ha, bcast_mac, 0)) + if (qla_config_mac_addr(ha, bcast_mac, 0, 1)) return; ha->hw.flags.bcast_mac = 0; } if (ha->hw.flags.unicast_mac) { - if (qla_config_mac_addr(ha, ha->hw.mac_addr, 0)) + if (qla_config_mac_addr(ha, ha->hw.mac_addr, 0, 1)) return; ha->hw.flags.unicast_mac = 0; } @@ -2926,12 +2944,20 @@ qla_init_xmt_cntxt(qla_host_t *ha) } static int -qla_hw_add_all_mcast(qla_host_t *ha) +qla_hw_all_mcast(qla_host_t *ha, uint32_t add_mcast) { int i, nmcast; + uint32_t count = 0; + uint8_t *mcast; nmcast = ha->hw.nmcast; + QL_DPRINT2(ha, (ha->pci_dev, + "%s:[0x%x] enter nmcast = %d \n", __func__, add_mcast, nmcast)); + + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); + for (i = 0 ; ((i < Q8_MAX_NUM_MULTICAST_ADDRS) && nmcast); i++) { if ((ha->hw.mcast[i].addr[0] != 0) || (ha->hw.mcast[i].addr[1] != 0) || @@ -2940,52 +2966,80 @@ qla_hw_add_all_mcast(qla_host_t *ha) (ha->hw.mcast[i].addr[4] != 0) || (ha->hw.mcast[i].addr[5] != 0)) { - if (qla_config_mac_addr(ha, ha->hw.mcast[i].addr, 1)) { - device_printf(ha->pci_dev, "%s: failed\n", - __func__); - return (-1); + bcopy(ha->hw.mcast[i].addr, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + + if (count == Q8_MAX_MAC_ADDRS) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, + add_mcast, count)) { + device_printf(ha->pci_dev, + "%s: failed\n", __func__); + return (-1); + } + + count = 0; + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, + (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); } nmcast--; } } + + if (count) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, add_mcast, + count)) { + device_printf(ha->pci_dev, "%s: failed\n", __func__); + return (-1); + } + } + QL_DPRINT2(ha, (ha->pci_dev, + "%s:[0x%x] exit nmcast = %d \n", __func__, add_mcast, nmcast)); + return 0; } static int -qla_hw_del_all_mcast(qla_host_t *ha) +qla_hw_add_all_mcast(qla_host_t *ha) { - int i, nmcast; + int ret; - nmcast = ha->hw.nmcast; + ret = qla_hw_all_mcast(ha, 1); - for (i = 0 ; ((i < Q8_MAX_NUM_MULTICAST_ADDRS) && nmcast); i++) { - if ((ha->hw.mcast[i].addr[0] != 0) || - (ha->hw.mcast[i].addr[1] != 0) || - (ha->hw.mcast[i].addr[2] != 0) || - (ha->hw.mcast[i].addr[3] != 0) || - (ha->hw.mcast[i].addr[4] != 0) || - (ha->hw.mcast[i].addr[5] != 0)) { + return (ret); +} - if (qla_config_mac_addr(ha, ha->hw.mcast[i].addr, 0)) - return (-1); +static int +qla_hw_del_all_mcast(qla_host_t *ha) +{ + int ret; - nmcast--; - } - } - return 0; + ret = qla_hw_all_mcast(ha, 0); + + bzero(ha->hw.mcast, (sizeof (qla_mcast_t) * Q8_MAX_NUM_MULTICAST_ADDRS)); + ha->hw.nmcast = 0; + + return (ret); } static int -qla_hw_add_mcast(qla_host_t *ha, uint8_t *mta) +qla_hw_mac_addr_present(qla_host_t *ha, uint8_t *mta) { int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { - if (QL_MAC_CMP(ha->hw.mcast[i].addr, mta) == 0) - return 0; /* its been already added */ + return (0); /* its been already added */ } + return (-1); +} + +static int +qla_hw_add_mcast(qla_host_t *ha, uint8_t *mta, uint32_t nmcast) +{ + int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { @@ -2996,29 +3050,28 @@ qla_hw_add_mcast(qla_host_t *ha, uint8_t (ha->hw.mcast[i].addr[4] == 0) && (ha->hw.mcast[i].addr[5] == 0)) { - if (qla_config_mac_addr(ha, mta, 1)) - return (-1); - bcopy(mta, ha->hw.mcast[i].addr, Q8_MAC_ADDR_LEN); ha->hw.nmcast++; - return 0; + mta = mta + ETHER_ADDR_LEN; + nmcast--; + + if (nmcast == 0) + break; } + } return 0; } static int -qla_hw_del_mcast(qla_host_t *ha, uint8_t *mta) +qla_hw_del_mcast(qla_host_t *ha, uint8_t *mta, uint32_t nmcast) { int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { if (QL_MAC_CMP(ha->hw.mcast[i].addr, mta) == 0) { - if (qla_config_mac_addr(ha, mta, 0)) - return (-1); - ha->hw.mcast[i].addr[0] = 0; ha->hw.mcast[i].addr[1] = 0; ha->hw.mcast[i].addr[2] = 0; @@ -3028,7 +3081,11 @@ qla_hw_del_mcast(qla_host_t *ha, uint8_t ha->hw.nmcast--; - return 0; + mta = mta + ETHER_ADDR_LEN; + nmcast--; + + if (nmcast == 0) + break; } } return 0; @@ -3036,30 +3093,75 @@ qla_hw_del_mcast(qla_host_t *ha, uint8_t /* * Name: ql_hw_set_multi - * Function: Sets the Multicast Addresses provided the host O.S into the + * Function: Sets the Multicast Addresses provided by the host O.S into the * hardware (for the given interface) */ int -ql_hw_set_multi(qla_host_t *ha, uint8_t *mcast, uint32_t mcnt, +ql_hw_set_multi(qla_host_t *ha, uint8_t *mcast_addr, uint32_t mcnt, uint32_t add_mac) { + uint8_t *mta = mcast_addr; int i; - uint8_t *mta = mcast; int ret = 0; + uint32_t count = 0; + uint8_t *mcast; + + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); for (i = 0; i < mcnt; i++) { - if (add_mac) { - ret = qla_hw_add_mcast(ha, mta); - if (ret) - break; - } else { - ret = qla_hw_del_mcast(ha, mta); - if (ret) - break; + if (mta[0] || mta[1] || mta[2] || mta[3] || mta[4] || mta[5]) { + if (add_mac) { + if (qla_hw_mac_addr_present(ha, mta) != 0) { + bcopy(mta, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + } + } else { + if (qla_hw_mac_addr_present(ha, mta) == 0) { + bcopy(mta, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + } + } + } + if (count == Q8_MAX_MAC_ADDRS) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, + add_mac, count)) { + device_printf(ha->pci_dev, "%s: failed\n", + __func__); + return (-1); + } + + if (add_mac) { + qla_hw_add_mcast(ha, ha->hw.mac_addr_arr, + count); + } else { + qla_hw_del_mcast(ha, ha->hw.mac_addr_arr, + count); + } + + count = 0; + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); } mta += Q8_MAC_ADDR_LEN; } + + if (count) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, add_mac, + count)) { + device_printf(ha->pci_dev, "%s: failed\n", __func__); + return (-1); + } + if (add_mac) { + qla_hw_add_mcast(ha, ha->hw.mac_addr_arr, count); + } else { + qla_hw_del_mcast(ha, ha->hw.mac_addr_arr, count); + } + } + return (ret); } Modified: stable/10/sys/dev/qlxgbe/ql_hw.h ============================================================================== --- stable/10/sys/dev/qlxgbe/ql_hw.h Mon Oct 17 18:04:19 2016 (r307524) +++ stable/10/sys/dev/qlxgbe/ql_hw.h Mon Oct 17 18:07:51 2016 (r307525) @@ -210,7 +210,7 @@ #define Q8_NUM_MBOX 512 -#define Q8_MAX_NUM_MULTICAST_ADDRS 1023 +#define Q8_MAX_NUM_MULTICAST_ADDRS 1022 #define Q8_MAC_ADDR_LEN 6 /* @@ -511,8 +511,9 @@ typedef struct _q80_config_intr_coalesc_ /* * Configure MAC Address */ +#define Q8_ETHER_ADDR_LEN 6 typedef struct _q80_mac_addr { - uint8_t addr[6]; + uint8_t addr[Q8_ETHER_ADDR_LEN]; uint16_t vlan_tci; } __packed q80_mac_addr_t; @@ -1548,7 +1549,7 @@ typedef struct _qla_hw_tx_cntxt { typedef struct _qla_mcast { uint16_t rsrvd; - uint8_t addr[6]; + uint8_t addr[ETHER_ADDR_LEN]; } __packed qla_mcast_t; typedef struct _qla_rdesc { @@ -1660,6 +1661,7 @@ typedef struct _qla_hw { /* multicast address list */ uint32_t nmcast; qla_mcast_t mcast[Q8_MAX_NUM_MULTICAST_ADDRS]; + uint8_t mac_addr_arr[(Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)]; /* reset sequence */ #define Q8_MAX_RESET_SEQ_IDX 16 Modified: stable/10/sys/dev/qlxgbe/ql_os.c ============================================================================== --- stable/10/sys/dev/qlxgbe/ql_os.c Mon Oct 17 18:04:19 2016 (r307524) +++ stable/10/sys/dev/qlxgbe/ql_os.c Mon Oct 17 18:07:51 2016 (r307525) @@ -243,6 +243,8 @@ qla_watchdog(void *arg) ha->flags.qla_watchdog_pause = 1; ha->qla_initiate_recovery = 0; ha->err_inject = 0; + device_printf(ha->pci_dev, + "%s: taskqueue_enqueue(err_task) \n", __func__); taskqueue_enqueue(ha->err_tq, &ha->err_task); } else if (ha->flags.qla_interface_up) { @@ -452,7 +454,7 @@ qla_pci_attach(device_t dev) TASK_INIT(&ha->tx_task, 0, qla_tx_done, ha); - ha->tx_tq = taskqueue_create_fast("qla_txq", M_NOWAIT, + ha->tx_tq = taskqueue_create("qla_txq", M_NOWAIT, taskqueue_thread_enqueue, &ha->tx_tq); taskqueue_start_threads(&ha->tx_tq, 1, PI_NET, "%s txq", device_get_nameunit(ha->pci_dev)); @@ -470,13 +472,13 @@ qla_pci_attach(device_t dev) qla_watchdog, ha); TASK_INIT(&ha->err_task, 0, qla_error_recovery, ha); - ha->err_tq = taskqueue_create_fast("qla_errq", M_NOWAIT, + ha->err_tq = taskqueue_create("qla_errq", M_NOWAIT, taskqueue_thread_enqueue, &ha->err_tq); taskqueue_start_threads(&ha->err_tq, 1, PI_NET, "%s errq", device_get_nameunit(ha->pci_dev)); TASK_INIT(&ha->async_event_task, 0, qla_async_event, ha); - ha->async_event_tq = taskqueue_create_fast("qla_asyncq", M_NOWAIT, + ha->async_event_tq = taskqueue_create("qla_asyncq", M_NOWAIT, taskqueue_thread_enqueue, &ha->async_event_tq); taskqueue_start_threads(&ha->async_event_tq, 1, PI_NET, "%s asyncq", device_get_nameunit(ha->pci_dev)); Modified: stable/10/sys/dev/qlxgbe/ql_ver.h ============================================================================== --- stable/10/sys/dev/qlxgbe/ql_ver.h Mon Oct 17 18:04:19 2016 (r307524) +++ stable/10/sys/dev/qlxgbe/ql_ver.h Mon Oct 17 18:07:51 2016 (r307525) @@ -36,6 +36,6 @@ #define QLA_VERSION_MAJOR 3 #define QLA_VERSION_MINOR 10 -#define QLA_VERSION_BUILD 30 +#define QLA_VERSION_BUILD 31 #endif /* #ifndef _QL_VER_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 18:14:33 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B090C15F20; Mon, 17 Oct 2016 18:14:33 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DFD01F02; Mon, 17 Oct 2016 18:14:32 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HIEW7o061764; Mon, 17 Oct 2016 18:14:32 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HIEVnq061760; Mon, 17 Oct 2016 18:14:31 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201610171814.u9HIEVnq061760@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Mon, 17 Oct 2016 18:14:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r307526 - stable/9/sys/dev/qlxgbe X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 18:14:33 -0000 Author: davidcs Date: Mon Oct 17 18:14:31 2016 New Revision: 307526 URL: https://svnweb.freebsd.org/changeset/base/307526 Log: MFC r306790 Add support for adding up to 64 Multicast addresses with a single mailbox command Modified: stable/9/sys/dev/qlxgbe/ql_hw.c stable/9/sys/dev/qlxgbe/ql_hw.h stable/9/sys/dev/qlxgbe/ql_os.c stable/9/sys/dev/qlxgbe/ql_ver.h Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/dev/qlxgbe/ql_hw.c ============================================================================== --- stable/9/sys/dev/qlxgbe/ql_hw.c Mon Oct 17 18:07:51 2016 (r307525) +++ stable/9/sys/dev/qlxgbe/ql_hw.c Mon Oct 17 18:14:31 2016 (r307526) @@ -1128,12 +1128,21 @@ qla_config_intr_coalesce(qla_host_t *ha, * Can be unicast, multicast or broadcast. */ static int -qla_config_mac_addr(qla_host_t *ha, uint8_t *mac_addr, uint32_t add_mac) +qla_config_mac_addr(qla_host_t *ha, uint8_t *mac_addr, uint32_t add_mac, + uint32_t num_mac) { q80_config_mac_addr_t *cmac; q80_config_mac_addr_rsp_t *cmac_rsp; uint32_t err; device_t dev = ha->pci_dev; + int i; + uint8_t *mac_cpy = mac_addr; + + if (num_mac > Q8_MAX_MAC_ADDRS) { + device_printf(dev, "%s: %s num_mac [0x%x] > Q8_MAX_MAC_ADDRS\n", + __func__, (add_mac ? "Add" : "Del"), num_mac); + return (-1); + } cmac = (q80_config_mac_addr_t *)ha->hw.mbox; bzero(cmac, (sizeof (q80_config_mac_addr_t))); @@ -1149,9 +1158,13 @@ qla_config_mac_addr(qla_host_t *ha, uint cmac->cmd |= Q8_MBX_CMAC_CMD_CAM_INGRESS; - cmac->nmac_entries = 1; + cmac->nmac_entries = num_mac; cmac->cntxt_id = ha->hw.rcv_cntxt_id; - bcopy(mac_addr, cmac->mac_addr[0].addr, 6); + + for (i = 0; i < num_mac; i++) { + bcopy(mac_addr, cmac->mac_addr[i].addr, Q8_ETHER_ADDR_LEN); + mac_addr = mac_addr + ETHER_ADDR_LEN; + } if (qla_mbx_cmd(ha, (uint32_t *)cmac, (sizeof (q80_config_mac_addr_t) >> 2), @@ -1165,11 +1178,14 @@ qla_config_mac_addr(qla_host_t *ha, uint err = Q8_MBX_RSP_STATUS(cmac_rsp->regcnt_status); if (err) { - device_printf(dev, "%s: %s " - "%02x:%02x:%02x:%02x:%02x:%02x failed1 [0x%08x]\n", - __func__, (add_mac ? "Add" : "Del"), - mac_addr[0], mac_addr[1], mac_addr[2], - mac_addr[3], mac_addr[4], mac_addr[5], err); + device_printf(dev, "%s: %s failed1 [0x%08x]\n", __func__, + (add_mac ? "Add" : "Del"), err); + for (i = 0; i < num_mac; i++) { + device_printf(dev, "%s: %02x:%02x:%02x:%02x:%02x:%02x\n", + __func__, mac_cpy[0], mac_cpy[1], mac_cpy[2], + mac_cpy[3], mac_cpy[4], mac_cpy[5]); + mac_cpy += ETHER_ADDR_LEN; + } return (-1); } @@ -2254,6 +2270,7 @@ ql_del_hw_if(qla_host_t *ha) (void)qla_stop_nic_func(ha); qla_del_rcv_cntxt(ha); + qla_del_xmt_cntxt(ha); if (ha->hw.flags.init_intr_cnxt) { @@ -2270,6 +2287,7 @@ ql_del_hw_if(qla_host_t *ha) ha->hw.flags.init_intr_cnxt = 0; } + return; } @@ -2368,7 +2386,7 @@ ql_init_hw_if(qla_host_t *ha) } ha->hw.max_tx_segs = 0; - if (qla_config_mac_addr(ha, ha->hw.mac_addr, 1)) + if (qla_config_mac_addr(ha, ha->hw.mac_addr, 1, 1)) return(-1); ha->hw.flags.unicast_mac = 1; @@ -2376,7 +2394,7 @@ ql_init_hw_if(qla_host_t *ha) bcast_mac[0] = 0xFF; bcast_mac[1] = 0xFF; bcast_mac[2] = 0xFF; bcast_mac[3] = 0xFF; bcast_mac[4] = 0xFF; bcast_mac[5] = 0xFF; - if (qla_config_mac_addr(ha, bcast_mac, 1)) + if (qla_config_mac_addr(ha, bcast_mac, 1, 1)) return (-1); ha->hw.flags.bcast_mac = 1; @@ -2733,14 +2751,14 @@ qla_del_rcv_cntxt(qla_host_t *ha) bcast_mac[0] = 0xFF; bcast_mac[1] = 0xFF; bcast_mac[2] = 0xFF; bcast_mac[3] = 0xFF; bcast_mac[4] = 0xFF; bcast_mac[5] = 0xFF; - if (qla_config_mac_addr(ha, bcast_mac, 0)) + if (qla_config_mac_addr(ha, bcast_mac, 0, 1)) return; ha->hw.flags.bcast_mac = 0; } if (ha->hw.flags.unicast_mac) { - if (qla_config_mac_addr(ha, ha->hw.mac_addr, 0)) + if (qla_config_mac_addr(ha, ha->hw.mac_addr, 0, 1)) return; ha->hw.flags.unicast_mac = 0; } @@ -2926,12 +2944,20 @@ qla_init_xmt_cntxt(qla_host_t *ha) } static int -qla_hw_add_all_mcast(qla_host_t *ha) +qla_hw_all_mcast(qla_host_t *ha, uint32_t add_mcast) { int i, nmcast; + uint32_t count = 0; + uint8_t *mcast; nmcast = ha->hw.nmcast; + QL_DPRINT2(ha, (ha->pci_dev, + "%s:[0x%x] enter nmcast = %d \n", __func__, add_mcast, nmcast)); + + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); + for (i = 0 ; ((i < Q8_MAX_NUM_MULTICAST_ADDRS) && nmcast); i++) { if ((ha->hw.mcast[i].addr[0] != 0) || (ha->hw.mcast[i].addr[1] != 0) || @@ -2940,52 +2966,80 @@ qla_hw_add_all_mcast(qla_host_t *ha) (ha->hw.mcast[i].addr[4] != 0) || (ha->hw.mcast[i].addr[5] != 0)) { - if (qla_config_mac_addr(ha, ha->hw.mcast[i].addr, 1)) { - device_printf(ha->pci_dev, "%s: failed\n", - __func__); - return (-1); + bcopy(ha->hw.mcast[i].addr, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + + if (count == Q8_MAX_MAC_ADDRS) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, + add_mcast, count)) { + device_printf(ha->pci_dev, + "%s: failed\n", __func__); + return (-1); + } + + count = 0; + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, + (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); } nmcast--; } } + + if (count) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, add_mcast, + count)) { + device_printf(ha->pci_dev, "%s: failed\n", __func__); + return (-1); + } + } + QL_DPRINT2(ha, (ha->pci_dev, + "%s:[0x%x] exit nmcast = %d \n", __func__, add_mcast, nmcast)); + return 0; } static int -qla_hw_del_all_mcast(qla_host_t *ha) +qla_hw_add_all_mcast(qla_host_t *ha) { - int i, nmcast; + int ret; - nmcast = ha->hw.nmcast; + ret = qla_hw_all_mcast(ha, 1); - for (i = 0 ; ((i < Q8_MAX_NUM_MULTICAST_ADDRS) && nmcast); i++) { - if ((ha->hw.mcast[i].addr[0] != 0) || - (ha->hw.mcast[i].addr[1] != 0) || - (ha->hw.mcast[i].addr[2] != 0) || - (ha->hw.mcast[i].addr[3] != 0) || - (ha->hw.mcast[i].addr[4] != 0) || - (ha->hw.mcast[i].addr[5] != 0)) { + return (ret); +} - if (qla_config_mac_addr(ha, ha->hw.mcast[i].addr, 0)) - return (-1); +static int +qla_hw_del_all_mcast(qla_host_t *ha) +{ + int ret; - nmcast--; - } - } - return 0; + ret = qla_hw_all_mcast(ha, 0); + + bzero(ha->hw.mcast, (sizeof (qla_mcast_t) * Q8_MAX_NUM_MULTICAST_ADDRS)); + ha->hw.nmcast = 0; + + return (ret); } static int -qla_hw_add_mcast(qla_host_t *ha, uint8_t *mta) +qla_hw_mac_addr_present(qla_host_t *ha, uint8_t *mta) { int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { - if (QL_MAC_CMP(ha->hw.mcast[i].addr, mta) == 0) - return 0; /* its been already added */ + return (0); /* its been already added */ } + return (-1); +} + +static int +qla_hw_add_mcast(qla_host_t *ha, uint8_t *mta, uint32_t nmcast) +{ + int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { @@ -2996,29 +3050,28 @@ qla_hw_add_mcast(qla_host_t *ha, uint8_t (ha->hw.mcast[i].addr[4] == 0) && (ha->hw.mcast[i].addr[5] == 0)) { - if (qla_config_mac_addr(ha, mta, 1)) - return (-1); - bcopy(mta, ha->hw.mcast[i].addr, Q8_MAC_ADDR_LEN); ha->hw.nmcast++; - return 0; + mta = mta + ETHER_ADDR_LEN; + nmcast--; + + if (nmcast == 0) + break; } + } return 0; } static int -qla_hw_del_mcast(qla_host_t *ha, uint8_t *mta) +qla_hw_del_mcast(qla_host_t *ha, uint8_t *mta, uint32_t nmcast) { int i; for (i = 0; i < Q8_MAX_NUM_MULTICAST_ADDRS; i++) { if (QL_MAC_CMP(ha->hw.mcast[i].addr, mta) == 0) { - if (qla_config_mac_addr(ha, mta, 0)) - return (-1); - ha->hw.mcast[i].addr[0] = 0; ha->hw.mcast[i].addr[1] = 0; ha->hw.mcast[i].addr[2] = 0; @@ -3028,7 +3081,11 @@ qla_hw_del_mcast(qla_host_t *ha, uint8_t ha->hw.nmcast--; - return 0; + mta = mta + ETHER_ADDR_LEN; + nmcast--; + + if (nmcast == 0) + break; } } return 0; @@ -3036,30 +3093,75 @@ qla_hw_del_mcast(qla_host_t *ha, uint8_t /* * Name: ql_hw_set_multi - * Function: Sets the Multicast Addresses provided the host O.S into the + * Function: Sets the Multicast Addresses provided by the host O.S into the * hardware (for the given interface) */ int -ql_hw_set_multi(qla_host_t *ha, uint8_t *mcast, uint32_t mcnt, +ql_hw_set_multi(qla_host_t *ha, uint8_t *mcast_addr, uint32_t mcnt, uint32_t add_mac) { + uint8_t *mta = mcast_addr; int i; - uint8_t *mta = mcast; int ret = 0; + uint32_t count = 0; + uint8_t *mcast; + + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); for (i = 0; i < mcnt; i++) { - if (add_mac) { - ret = qla_hw_add_mcast(ha, mta); - if (ret) - break; - } else { - ret = qla_hw_del_mcast(ha, mta); - if (ret) - break; + if (mta[0] || mta[1] || mta[2] || mta[3] || mta[4] || mta[5]) { + if (add_mac) { + if (qla_hw_mac_addr_present(ha, mta) != 0) { + bcopy(mta, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + } + } else { + if (qla_hw_mac_addr_present(ha, mta) == 0) { + bcopy(mta, mcast, ETHER_ADDR_LEN); + mcast = mcast + ETHER_ADDR_LEN; + count++; + } + } + } + if (count == Q8_MAX_MAC_ADDRS) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, + add_mac, count)) { + device_printf(ha->pci_dev, "%s: failed\n", + __func__); + return (-1); + } + + if (add_mac) { + qla_hw_add_mcast(ha, ha->hw.mac_addr_arr, + count); + } else { + qla_hw_del_mcast(ha, ha->hw.mac_addr_arr, + count); + } + + count = 0; + mcast = ha->hw.mac_addr_arr; + memset(mcast, 0, (Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)); } mta += Q8_MAC_ADDR_LEN; } + + if (count) { + if (qla_config_mac_addr(ha, ha->hw.mac_addr_arr, add_mac, + count)) { + device_printf(ha->pci_dev, "%s: failed\n", __func__); + return (-1); + } + if (add_mac) { + qla_hw_add_mcast(ha, ha->hw.mac_addr_arr, count); + } else { + qla_hw_del_mcast(ha, ha->hw.mac_addr_arr, count); + } + } + return (ret); } Modified: stable/9/sys/dev/qlxgbe/ql_hw.h ============================================================================== --- stable/9/sys/dev/qlxgbe/ql_hw.h Mon Oct 17 18:07:51 2016 (r307525) +++ stable/9/sys/dev/qlxgbe/ql_hw.h Mon Oct 17 18:14:31 2016 (r307526) @@ -210,7 +210,7 @@ #define Q8_NUM_MBOX 512 -#define Q8_MAX_NUM_MULTICAST_ADDRS 1023 +#define Q8_MAX_NUM_MULTICAST_ADDRS 1022 #define Q8_MAC_ADDR_LEN 6 /* @@ -511,8 +511,9 @@ typedef struct _q80_config_intr_coalesc_ /* * Configure MAC Address */ +#define Q8_ETHER_ADDR_LEN 6 typedef struct _q80_mac_addr { - uint8_t addr[6]; + uint8_t addr[Q8_ETHER_ADDR_LEN]; uint16_t vlan_tci; } __packed q80_mac_addr_t; @@ -1548,7 +1549,7 @@ typedef struct _qla_hw_tx_cntxt { typedef struct _qla_mcast { uint16_t rsrvd; - uint8_t addr[6]; + uint8_t addr[ETHER_ADDR_LEN]; } __packed qla_mcast_t; typedef struct _qla_rdesc { @@ -1660,6 +1661,7 @@ typedef struct _qla_hw { /* multicast address list */ uint32_t nmcast; qla_mcast_t mcast[Q8_MAX_NUM_MULTICAST_ADDRS]; + uint8_t mac_addr_arr[(Q8_MAX_MAC_ADDRS * ETHER_ADDR_LEN)]; /* reset sequence */ #define Q8_MAX_RESET_SEQ_IDX 16 Modified: stable/9/sys/dev/qlxgbe/ql_os.c ============================================================================== --- stable/9/sys/dev/qlxgbe/ql_os.c Mon Oct 17 18:07:51 2016 (r307525) +++ stable/9/sys/dev/qlxgbe/ql_os.c Mon Oct 17 18:14:31 2016 (r307526) @@ -243,6 +243,8 @@ qla_watchdog(void *arg) ha->flags.qla_watchdog_pause = 1; ha->qla_initiate_recovery = 0; ha->err_inject = 0; + device_printf(ha->pci_dev, + "%s: taskqueue_enqueue(err_task) \n", __func__); taskqueue_enqueue(ha->err_tq, &ha->err_task); } else if (ha->flags.qla_interface_up) { @@ -452,7 +454,7 @@ qla_pci_attach(device_t dev) TASK_INIT(&ha->tx_task, 0, qla_tx_done, ha); - ha->tx_tq = taskqueue_create_fast("qla_txq", M_NOWAIT, + ha->tx_tq = taskqueue_create("qla_txq", M_NOWAIT, taskqueue_thread_enqueue, &ha->tx_tq); taskqueue_start_threads(&ha->tx_tq, 1, PI_NET, "%s txq", device_get_nameunit(ha->pci_dev)); @@ -470,13 +472,13 @@ qla_pci_attach(device_t dev) qla_watchdog, ha); TASK_INIT(&ha->err_task, 0, qla_error_recovery, ha); - ha->err_tq = taskqueue_create_fast("qla_errq", M_NOWAIT, + ha->err_tq = taskqueue_create("qla_errq", M_NOWAIT, taskqueue_thread_enqueue, &ha->err_tq); taskqueue_start_threads(&ha->err_tq, 1, PI_NET, "%s errq", device_get_nameunit(ha->pci_dev)); TASK_INIT(&ha->async_event_task, 0, qla_async_event, ha); - ha->async_event_tq = taskqueue_create_fast("qla_asyncq", M_NOWAIT, + ha->async_event_tq = taskqueue_create("qla_asyncq", M_NOWAIT, taskqueue_thread_enqueue, &ha->async_event_tq); taskqueue_start_threads(&ha->async_event_tq, 1, PI_NET, "%s asyncq", device_get_nameunit(ha->pci_dev)); Modified: stable/9/sys/dev/qlxgbe/ql_ver.h ============================================================================== --- stable/9/sys/dev/qlxgbe/ql_ver.h Mon Oct 17 18:07:51 2016 (r307525) +++ stable/9/sys/dev/qlxgbe/ql_ver.h Mon Oct 17 18:14:31 2016 (r307526) @@ -36,6 +36,6 @@ #define QLA_VERSION_MAJOR 3 #define QLA_VERSION_MINOR 10 -#define QLA_VERSION_BUILD 30 +#define QLA_VERSION_BUILD 31 #endif /* #ifndef _QL_VER_H_ */ From owner-svn-src-stable@freebsd.org Mon Oct 17 18:52:27 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 476D2C1679A; Mon, 17 Oct 2016 18:52:27 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EDB50E68; Mon, 17 Oct 2016 18:52:26 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HIqQhq077374; Mon, 17 Oct 2016 18:52:26 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HIqPt2077370; Mon, 17 Oct 2016 18:52:25 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610171852.u9HIqPt2077370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Mon, 17 Oct 2016 18:52:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307527 - in stable/11/sys/boot: fdt uboot/lib X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 18:52:27 -0000 Author: gonzo Date: Mon Oct 17 18:52:25 2016 New Revision: 307527 URL: https://svnweb.freebsd.org/changeset/base/307527 Log: MFC r302465: Remove extra 0x before %p format strings introduced by r296182 Modified: stable/11/sys/boot/fdt/fdt_loader_cmd.c stable/11/sys/boot/uboot/lib/elf_freebsd.c stable/11/sys/boot/uboot/lib/glue.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/boot/fdt/fdt_loader_cmd.c ============================================================================== --- stable/11/sys/boot/fdt/fdt_loader_cmd.c Mon Oct 17 18:14:31 2016 (r307526) +++ stable/11/sys/boot/fdt/fdt_loader_cmd.c Mon Oct 17 18:52:25 2016 (r307527) @@ -421,7 +421,7 @@ fdt_setup_fdtp() /* If we were given the address of a valid blob in memory, use it. */ if (fdt_to_load != NULL) { if (fdt_load_dtb_addr(fdt_to_load) == 0) { - printf("Using DTB from memory address 0x%p.\n", + printf("Using DTB from memory address %p.\n", fdt_to_load); return (0); } Modified: stable/11/sys/boot/uboot/lib/elf_freebsd.c ============================================================================== --- stable/11/sys/boot/uboot/lib/elf_freebsd.c Mon Oct 17 18:14:31 2016 (r307526) +++ stable/11/sys/boot/uboot/lib/elf_freebsd.c Mon Oct 17 18:52:25 2016 (r307527) @@ -85,7 +85,7 @@ __elfN(uboot_exec)(struct preloaded_file return (error); entry = (void *)e->e_entry; - printf("Kernel entry at 0x%p...\n", entry); + printf("Kernel entry at %p...\n", entry); dev_cleanup(); printf("Kernel args: %s\n", fp->f_args); Modified: stable/11/sys/boot/uboot/lib/glue.c ============================================================================== --- stable/11/sys/boot/uboot/lib/glue.c Mon Oct 17 18:14:31 2016 (r307526) +++ stable/11/sys/boot/uboot/lib/glue.c Mon Oct 17 18:52:25 2016 (r307527) @@ -469,7 +469,7 @@ ub_dump_di(int handle) int i; printf("device info (%d):\n", handle); - printf(" cookie\t= 0x%p\n", di->cookie); + printf(" cookie\t= %p\n", di->cookie); printf(" type\t\t= 0x%08x\n", di->type); if (di->type == DEV_TYP_NET) { From owner-svn-src-stable@freebsd.org Mon Oct 17 21:44:42 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D520C165E4; Mon, 17 Oct 2016 21:44:42 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5BF86C40; Mon, 17 Oct 2016 21:44:42 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HLif8m041735; Mon, 17 Oct 2016 21:44:41 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HLif26041731; Mon, 17 Oct 2016 21:44:41 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201610172144.u9HLif26041731@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 17 Oct 2016 21:44:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307533 - in stable/11: share/man/man3 sys/sys sys/ufs/ffs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 21:44:42 -0000 Author: mckusick Date: Mon Oct 17 21:44:41 2016 New Revision: 307533 URL: https://svnweb.freebsd.org/changeset/base/307533 Log: MFC r304230: Add two new macros, SLIST_CONCAT and LIST_CONCAT. MFC r304239: Bug 211013 reports that a write error to a UFS filesystem running with softupdates panics the kernel. PR: 211013 Modified: stable/11/share/man/man3/queue.3 stable/11/sys/sys/queue.h stable/11/sys/ufs/ffs/ffs_softdep.c stable/11/sys/ufs/ffs/softdep.h Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man3/queue.3 ============================================================================== --- stable/11/share/man/man3/queue.3 Mon Oct 17 21:35:13 2016 (r307532) +++ stable/11/share/man/man3/queue.3 Mon Oct 17 21:44:41 2016 (r307533) @@ -28,12 +28,13 @@ .\" @(#)queue.3 8.2 (Berkeley) 1/24/94 .\" $FreeBSD$ .\" -.Dd June 24, 2015 +.Dd August 15, 2016 .Dt QUEUE 3 .Os .Sh NAME .Nm SLIST_CLASS_ENTRY , .Nm SLIST_CLASS_HEAD , +.Nm SLIST_CONCAT , .Nm SLIST_EMPTY , .Nm SLIST_ENTRY , .Nm SLIST_FIRST , @@ -75,6 +76,7 @@ .Nm STAILQ_SWAP , .Nm LIST_CLASS_ENTRY , .Nm LIST_CLASS_HEAD , +.Nm LIST_CONCAT , .Nm LIST_EMPTY , .Nm LIST_ENTRY , .Nm LIST_FIRST , @@ -125,6 +127,7 @@ lists and tail queues .\" .Fn SLIST_CLASS_ENTRY "CLASSTYPE" .Fn SLIST_CLASS_HEAD "HEADNAME" "CLASSTYPE" +.Fn SLIST_CONCAT "SLIST_HEAD *head1" "SLIST_HEAD *head2" "TYPE" "SLIST_ENTRY NAME" .Fn SLIST_EMPTY "SLIST_HEAD *head" .Fn SLIST_ENTRY "TYPE" .Fn SLIST_FIRST "SLIST_HEAD *head" @@ -168,6 +171,7 @@ lists and tail queues .\" .Fn LIST_CLASS_ENTRY "CLASSTYPE" .Fn LIST_CLASS_HEAD "HEADNAME" "CLASSTYPE" +.Fn LIST_CONCAT "LIST_HEAD *head1" "LIST_HEAD *head2" "TYPE" "LIST_ENTRY NAME" .Fn LIST_EMPTY "LIST_HEAD *head" .Fn LIST_ENTRY "TYPE" .Fn LIST_FIRST "LIST_HEAD *head" @@ -249,6 +253,8 @@ Singly-linked lists add the following fu .Bl -enum -compact -offset indent .It O(n) removal of any entry in the list. +.It +O(n) concatenation of two lists. .El .Pp Singly-linked tail queues add the following functionality: @@ -296,6 +302,8 @@ Linked lists are the simplest of the dou They add the following functionality over the above: .Bl -enum -compact -offset indent .It +O(n) concatenation of two lists. +.It They may be traversed backwards. .El However: @@ -401,6 +409,19 @@ evaluates to an initializer for the list .Fa head . .Pp The macro +.Nm SLIST_CONCAT +concatenates the list headed by +.Fa head2 +onto the end of the one headed by +.Fa head1 +removing all entries from the former. +Use of this macro should be avoided as it traverses the entirety of the +.Fa head1 +list. +A singly-linked tail queue should be used if this macro is needed in +high-usage code paths or to operate on long lists. +.Pp +The macro .Nm SLIST_EMPTY evaluates to true if there are no elements in the list. .Pp @@ -508,6 +529,9 @@ The macro removes the element .Fa elm from the list. +Use of this macro should be avoided as it traverses the entire list. +A doubly-linked list should be used if this macro is needed in +high-usage code paths or to operate on long lists. .Pp The macro .Nm SLIST_SWAP @@ -724,6 +748,9 @@ The macro removes the element .Fa elm from the tail queue. +Use of this macro should be avoided as it traverses the entire list. +A doubly-linked tail queue should be used if this macro is needed in +high-usage code paths or to operate on long tail queues. .Pp The macro .Nm STAILQ_SWAP @@ -823,6 +850,19 @@ evaluates to an initializer for the list .Fa head . .Pp The macro +.Nm LIST_CONCAT +concatenates the list headed by +.Fa head2 +onto the end of the one headed by +.Fa head1 +removing all entries from the former. +Use of this macro should be avoided as it traverses the entirety of the +.Fa head1 +list. +A tail queue should be used if this macro is needed in +high-usage code paths or to operate on long lists. +.Pp +The macro .Nm LIST_EMPTY evaluates to true if there are no elements in the list. .Pp Modified: stable/11/sys/sys/queue.h ============================================================================== --- stable/11/sys/sys/queue.h Mon Oct 17 21:35:13 2016 (r307532) +++ stable/11/sys/sys/queue.h Mon Oct 17 21:44:41 2016 (r307533) @@ -76,6 +76,10 @@ * * For details on the use of these macros, see the queue(3) manual page. * + * Below is a summary of implemented functions where: + * + means the macro is available + * - means the macro is not available + * s means the macro is available but is slow (runs in O(n) time) * * SLIST LIST STAILQ TAILQ * _HEAD + + + + @@ -101,10 +105,10 @@ * _INSERT_BEFORE - + - + * _INSERT_AFTER + + + + * _INSERT_TAIL - - + + - * _CONCAT - - + + + * _CONCAT s s + + * _REMOVE_AFTER + - + - * _REMOVE_HEAD + - + - - * _REMOVE + + + + + * _REMOVE s + s + * _SWAP + + + + * */ @@ -183,6 +187,19 @@ struct { \ /* * Singly-linked List functions. */ +#define SLIST_CONCAT(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ + if (curelm == NULL) { \ + if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \ + SLIST_INIT(head2); \ + } else if (SLIST_FIRST(head2) != NULL) { \ + while (SLIST_NEXT(curelm, field) != NULL) \ + curelm = SLIST_NEXT(curelm, field); \ + SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ + SLIST_INIT(head2); \ + } \ +} while (0) + #define SLIST_EMPTY(head) ((head)->slh_first == NULL) #define SLIST_FIRST(head) ((head)->slh_first) @@ -447,6 +464,23 @@ struct { \ #define QMD_LIST_CHECK_PREV(elm, field) #endif /* (_KERNEL && INVARIANTS) */ +#define LIST_CONCAT(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \ + if (curelm == NULL) { \ + if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \ + LIST_FIRST(head2)->field.le_prev = \ + &LIST_FIRST((head1)); \ + LIST_INIT(head2); \ + } \ + } else if (LIST_FIRST(head2) != NULL) { \ + while (LIST_NEXT(curelm, field) != NULL) \ + curelm = LIST_NEXT(curelm, field); \ + LIST_NEXT(curelm, field) = LIST_FIRST(head2); \ + LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \ + LIST_INIT(head2); \ + } \ +} while (0) + #define LIST_EMPTY(head) ((head)->lh_first == NULL) #define LIST_FIRST(head) ((head)->lh_first) Modified: stable/11/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- stable/11/sys/ufs/ffs/ffs_softdep.c Mon Oct 17 21:35:13 2016 (r307532) +++ stable/11/sys/ufs/ffs/ffs_softdep.c Mon Oct 17 21:44:41 2016 (r307533) @@ -752,16 +752,16 @@ static int flush_newblk_dep(struct vnode static int flush_inodedep_deps(struct vnode *, struct mount *, ino_t); static int flush_deplist(struct allocdirectlst *, int, int *); static int sync_cgs(struct mount *, int); -static int handle_written_filepage(struct pagedep *, struct buf *); +static int handle_written_filepage(struct pagedep *, struct buf *, int); static int handle_written_sbdep(struct sbdep *, struct buf *); static void initiate_write_sbdep(struct sbdep *); static void diradd_inode_written(struct diradd *, struct inodedep *); static int handle_written_indirdep(struct indirdep *, struct buf *, - struct buf**); -static int handle_written_inodeblock(struct inodedep *, struct buf *); + struct buf**, int); +static int handle_written_inodeblock(struct inodedep *, struct buf *, int); static int jnewblk_rollforward(struct jnewblk *, struct fs *, struct cg *, uint8_t *); -static int handle_written_bmsafemap(struct bmsafemap *, struct buf *); +static int handle_written_bmsafemap(struct bmsafemap *, struct buf *, int); static void handle_written_jaddref(struct jaddref *); static void handle_written_jremref(struct jremref *); static void handle_written_jseg(struct jseg *, struct buf *); @@ -10903,6 +10903,10 @@ initiate_write_bmsafemap(bmsafemap, bp) struct fs *fs; ino_t ino; + /* + * If this is a background write, we did this at the time that + * the copy was made, so do not need to do it again. + */ if (bmsafemap->sm_state & IOSTARTED) return; bmsafemap->sm_state |= IOSTARTED; @@ -10976,10 +10980,39 @@ softdep_disk_write_complete(bp) /* * If an error occurred while doing the write, then the data - * has not hit the disk and the dependencies cannot be unrolled. + * has not hit the disk and the dependencies cannot be processed. + * But we do have to go through and roll forward any dependencies + * that were rolled back before the disk write. */ - if ((bp->b_ioflags & BIO_ERROR) != 0 && (bp->b_flags & B_INVAL) == 0) + if ((bp->b_ioflags & BIO_ERROR) != 0 && (bp->b_flags & B_INVAL) == 0) { + LIST_FOREACH(wk, &bp->b_dep, wk_list) { + switch (wk->wk_type) { + + case D_PAGEDEP: + handle_written_filepage(WK_PAGEDEP(wk), bp, 0); + continue; + + case D_INODEDEP: + handle_written_inodeblock(WK_INODEDEP(wk), + bp, 0); + continue; + + case D_BMSAFEMAP: + handle_written_bmsafemap(WK_BMSAFEMAP(wk), + bp, 0); + continue; + + case D_INDIRDEP: + handle_written_indirdep(WK_INDIRDEP(wk), + bp, &sbp, 0); + continue; + default: + /* nothing to roll forward */ + continue; + } + } return; + } if ((wk = LIST_FIRST(&bp->b_dep)) == NULL) return; ump = VFSTOUFS(wk->wk_mp); @@ -10999,17 +11032,20 @@ softdep_disk_write_complete(bp) switch (wk->wk_type) { case D_PAGEDEP: - if (handle_written_filepage(WK_PAGEDEP(wk), bp)) + if (handle_written_filepage(WK_PAGEDEP(wk), bp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; case D_INODEDEP: - if (handle_written_inodeblock(WK_INODEDEP(wk), bp)) + if (handle_written_inodeblock(WK_INODEDEP(wk), bp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; case D_BMSAFEMAP: - if (handle_written_bmsafemap(WK_BMSAFEMAP(wk), bp)) + if (handle_written_bmsafemap(WK_BMSAFEMAP(wk), bp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; @@ -11028,7 +11064,8 @@ softdep_disk_write_complete(bp) continue; case D_INDIRDEP: - if (handle_written_indirdep(WK_INDIRDEP(wk), bp, &sbp)) + if (handle_written_indirdep(WK_INDIRDEP(wk), bp, &sbp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; @@ -11328,12 +11365,17 @@ handle_bufwait(inodedep, refhd) * Called from within softdep_disk_write_complete above to restore * in-memory inode block contents to their most up-to-date state. Note * that this routine is always called from interrupt level with further - * splbio interrupts blocked. + * interrupts from this device blocked. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. */ static int -handle_written_inodeblock(inodedep, bp) +handle_written_inodeblock(inodedep, bp, flags) struct inodedep *inodedep; struct buf *bp; /* buffer containing the inode block */ + int flags; { struct freefile *freefile; struct allocdirect *adp, *nextadp; @@ -11363,7 +11405,8 @@ handle_written_inodeblock(inodedep, bp) /* * Leave this inodeblock dirty until it's in the list. */ - if ((inodedep->id_state & (UNLINKED | UNLINKONLIST)) == UNLINKED) { + if ((inodedep->id_state & (UNLINKED | UNLINKONLIST)) == UNLINKED && + (flags & WRITESUCCEEDED)) { struct inodedep *inon; inon = TAILQ_NEXT(inodedep, id_unlinked); @@ -11402,7 +11445,8 @@ handle_written_inodeblock(inodedep, bp) goto bufwait; return (1); } - inodedep->id_state |= COMPLETE; + if (flags & WRITESUCCEEDED) + inodedep->id_state |= COMPLETE; /* * Roll forward anything that had to be rolled back before * the inode could be updated. @@ -11517,6 +11561,13 @@ handle_written_inodeblock(inodedep, bp) bdirty(bp); bufwait: /* + * If the write did not succeed, we have done all the roll-forward + * operations, but we cannot take the actions that will allow its + * dependencies to be processed. + */ + if ((flags & WRITESUCCEEDED) == 0) + return (hadchanges); + /* * Process any allocdirects that completed during the update. */ if ((adp = TAILQ_FIRST(&inodedep->id_inoupdt)) != NULL) @@ -11573,11 +11624,20 @@ bufwait: return (hadchanges); } +/* + * Perform needed roll-forwards and kick off any dependencies that + * can now be processed. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. + */ static int -handle_written_indirdep(indirdep, bp, bpp) +handle_written_indirdep(indirdep, bp, bpp, flags) struct indirdep *indirdep; struct buf *bp; struct buf **bpp; + int flags; { struct allocindir *aip; struct buf *sbp; @@ -11602,6 +11662,16 @@ handle_written_indirdep(indirdep, bp, bp indirdep->ir_state &= ~(UNDONE | IOSTARTED); indirdep->ir_state |= ATTACHED; /* + * If the write did not succeed, we have done all the roll-forward + * operations, but we cannot take the actions that will allow its + * dependencies to be processed. + */ + if ((flags & WRITESUCCEEDED) == 0) { + stat_indir_blk_ptrs++; + bdirty(bp); + return (1); + } + /* * Move allocindirs with written pointers to the completehd if * the indirdep's pointer is not yet written. Otherwise * free them here. @@ -11755,11 +11825,16 @@ jnewblk_rollforward(jnewblk, fs, cgp, bl * Complete a write to a bmsafemap structure. Roll forward any bitmap * changes if it's not a background write. Set all written dependencies * to DEPCOMPLETE and free the structure if possible. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. */ static int -handle_written_bmsafemap(bmsafemap, bp) +handle_written_bmsafemap(bmsafemap, bp, flags) struct bmsafemap *bmsafemap; struct buf *bp; + int flags; { struct newblk *newblk; struct inodedep *inodedep; @@ -11775,15 +11850,20 @@ handle_written_bmsafemap(bmsafemap, bp) int chgs; if ((bmsafemap->sm_state & IOSTARTED) == 0) - panic("initiate_write_bmsafemap: Not started\n"); + panic("handle_written_bmsafemap: Not started\n"); ump = VFSTOUFS(bmsafemap->sm_list.wk_mp); chgs = 0; bmsafemap->sm_state &= ~IOSTARTED; foreground = (bp->b_xflags & BX_BKGRDMARKER) == 0; /* - * Release journal work that was waiting on the write. + * If write was successful, release journal work that was waiting + * on the write. Otherwise move the work back. */ - handle_jwork(&bmsafemap->sm_freewr); + if (flags & WRITESUCCEEDED) + handle_jwork(&bmsafemap->sm_freewr); + else + LIST_CONCAT(&bmsafemap->sm_freehd, &bmsafemap->sm_freewr, + worklist, wk_list); /* * Restore unwritten inode allocation pending jaddref writes. @@ -11833,6 +11913,20 @@ handle_written_bmsafemap(bmsafemap, bp) free_jnewblk(jnewblk); } } + /* + * If the write did not succeed, we have done all the roll-forward + * operations, but we cannot take the actions that will allow its + * dependencies to be processed. + */ + if ((flags & WRITESUCCEEDED) == 0) { + LIST_CONCAT(&bmsafemap->sm_newblkhd, &bmsafemap->sm_newblkwr, + newblk, nb_deps); + LIST_CONCAT(&bmsafemap->sm_freehd, &bmsafemap->sm_freewr, + worklist, wk_list); + if (foreground) + bdirty(bp); + return (1); + } while ((newblk = LIST_FIRST(&bmsafemap->sm_newblkwr))) { newblk->nb_state |= DEPCOMPLETE; newblk->nb_state &= ~ONDEPLIST; @@ -11936,12 +12030,17 @@ free_pagedep(pagedep) * A write operation was just completed. Removed inodes can * now be freed and associated block pointers may be committed. * Note that this routine is always called from interrupt level - * with further splbio interrupts blocked. + * with further interrupts from this device blocked. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. */ static int -handle_written_filepage(pagedep, bp) +handle_written_filepage(pagedep, bp, flags) struct pagedep *pagedep; struct buf *bp; /* buffer containing the written page */ + int flags; { struct dirrem *dirrem; struct diradd *dap, *nextdap; @@ -11951,6 +12050,8 @@ handle_written_filepage(pagedep, bp) if ((pagedep->pd_state & IOSTARTED) == 0) panic("handle_written_filepage: not started"); pagedep->pd_state &= ~IOSTARTED; + if ((flags & WRITESUCCEEDED) == 0) + goto rollforward; /* * Process any directory removals that have been committed. */ @@ -11970,6 +12071,7 @@ handle_written_filepage(pagedep, bp) if ((pagedep->pd_state & NEWBLOCK) == 0) while ((dap = LIST_FIRST(&pagedep->pd_pendinghd)) != NULL) free_diradd(dap, NULL); +rollforward: /* * Uncommitted directory entries must be restored. */ @@ -12002,7 +12104,7 @@ handle_written_filepage(pagedep, bp) * marked dirty so that its will eventually get written back in * its correct form. */ - if (chgs) { + if (chgs || (flags & WRITESUCCEEDED) == 0) { if ((bp->b_flags & B_DELWRI) == 0) stat_dir_entry++; bdirty(bp); Modified: stable/11/sys/ufs/ffs/softdep.h ============================================================================== --- stable/11/sys/ufs/ffs/softdep.h Mon Oct 17 21:35:13 2016 (r307532) +++ stable/11/sys/ufs/ffs/softdep.h Mon Oct 17 21:44:41 2016 (r307533) @@ -140,6 +140,7 @@ #define UNLINKPREV 0x100000 /* inodedep is pointed at in the unlink list */ #define UNLINKONLIST 0x200000 /* inodedep is in the unlinked list on disk */ #define UNLINKLINKS (UNLINKNEXT | UNLINKPREV) +#define WRITESUCCEEDED 0x400000 /* the disk write completed successfully */ #define ALLCOMPLETE (ATTACHED | COMPLETE | DEPCOMPLETE) From owner-svn-src-stable@freebsd.org Mon Oct 17 21:49:56 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 12AE7C1670C; Mon, 17 Oct 2016 21:49:56 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CE1A0F09; Mon, 17 Oct 2016 21:49:55 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HLnsZC041974; Mon, 17 Oct 2016 21:49:54 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HLnsQW041970; Mon, 17 Oct 2016 21:49:54 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201610172149.u9HLnsQW041970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 17 Oct 2016 21:49:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307534 - in stable/10: share/man/man3 sys/sys sys/ufs/ffs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 21:49:56 -0000 Author: mckusick Date: Mon Oct 17 21:49:54 2016 New Revision: 307534 URL: https://svnweb.freebsd.org/changeset/base/307534 Log: MFC r304230: Add two new macros, SLIST_CONCAT and LIST_CONCAT. MFC r304239: Bug 211013 reports that a write error to a UFS filesystem running with softupdates panics the kernel. PR: 211013 Modified: stable/10/share/man/man3/queue.3 stable/10/sys/sys/queue.h stable/10/sys/ufs/ffs/ffs_softdep.c stable/10/sys/ufs/ffs/softdep.h Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man3/queue.3 ============================================================================== --- stable/10/share/man/man3/queue.3 Mon Oct 17 21:44:41 2016 (r307533) +++ stable/10/share/man/man3/queue.3 Mon Oct 17 21:49:54 2016 (r307534) @@ -32,12 +32,13 @@ .\" @(#)queue.3 8.2 (Berkeley) 1/24/94 .\" $FreeBSD$ .\" -.Dd June 24, 2015 +.Dd August 15, 2016 .Dt QUEUE 3 .Os .Sh NAME .Nm SLIST_CLASS_ENTRY , .Nm SLIST_CLASS_HEAD , +.Nm SLIST_CONCAT , .Nm SLIST_EMPTY , .Nm SLIST_ENTRY , .Nm SLIST_FIRST , @@ -79,6 +80,7 @@ .Nm STAILQ_SWAP , .Nm LIST_CLASS_ENTRY , .Nm LIST_CLASS_HEAD , +.Nm LIST_CONCAT , .Nm LIST_EMPTY , .Nm LIST_ENTRY , .Nm LIST_FIRST , @@ -129,6 +131,7 @@ lists and tail queues .\" .Fn SLIST_CLASS_ENTRY "CLASSTYPE" .Fn SLIST_CLASS_HEAD "HEADNAME" "CLASSTYPE" +.Fn SLIST_CONCAT "SLIST_HEAD *head1" "SLIST_HEAD *head2" "TYPE" "SLIST_ENTRY NAME" .Fn SLIST_EMPTY "SLIST_HEAD *head" .Fn SLIST_ENTRY "TYPE" .Fn SLIST_FIRST "SLIST_HEAD *head" @@ -172,6 +175,7 @@ lists and tail queues .\" .Fn LIST_CLASS_ENTRY "CLASSTYPE" .Fn LIST_CLASS_HEAD "HEADNAME" "CLASSTYPE" +.Fn LIST_CONCAT "LIST_HEAD *head1" "LIST_HEAD *head2" "TYPE" "LIST_ENTRY NAME" .Fn LIST_EMPTY "LIST_HEAD *head" .Fn LIST_ENTRY "TYPE" .Fn LIST_FIRST "LIST_HEAD *head" @@ -253,6 +257,8 @@ Singly-linked lists add the following fu .Bl -enum -compact -offset indent .It O(n) removal of any entry in the list. +.It +O(n) concatenation of two lists. .El .Pp Singly-linked tail queues add the following functionality: @@ -300,6 +306,8 @@ Linked lists are the simplest of the dou They add the following functionality over the above: .Bl -enum -compact -offset indent .It +O(n) concatenation of two lists. +.It They may be traversed backwards. .El However: @@ -405,6 +413,19 @@ evaluates to an initializer for the list .Fa head . .Pp The macro +.Nm SLIST_CONCAT +concatenates the list headed by +.Fa head2 +onto the end of the one headed by +.Fa head1 +removing all entries from the former. +Use of this macro should be avoided as it traverses the entirety of the +.Fa head1 +list. +A singly-linked tail queue should be used if this macro is needed in +high-usage code paths or to operate on long lists. +.Pp +The macro .Nm SLIST_EMPTY evaluates to true if there are no elements in the list. .Pp @@ -512,6 +533,9 @@ The macro removes the element .Fa elm from the list. +Use of this macro should be avoided as it traverses the entire list. +A doubly-linked list should be used if this macro is needed in +high-usage code paths or to operate on long lists. .Pp The macro .Nm SLIST_SWAP @@ -728,6 +752,9 @@ The macro removes the element .Fa elm from the tail queue. +Use of this macro should be avoided as it traverses the entire list. +A doubly-linked tail queue should be used if this macro is needed in +high-usage code paths or to operate on long tail queues. .Pp The macro .Nm STAILQ_SWAP @@ -827,6 +854,19 @@ evaluates to an initializer for the list .Fa head . .Pp The macro +.Nm LIST_CONCAT +concatenates the list headed by +.Fa head2 +onto the end of the one headed by +.Fa head1 +removing all entries from the former. +Use of this macro should be avoided as it traverses the entirety of the +.Fa head1 +list. +A tail queue should be used if this macro is needed in +high-usage code paths or to operate on long lists. +.Pp +The macro .Nm LIST_EMPTY evaluates to true if there are no elements in the list. .Pp Modified: stable/10/sys/sys/queue.h ============================================================================== --- stable/10/sys/sys/queue.h Mon Oct 17 21:44:41 2016 (r307533) +++ stable/10/sys/sys/queue.h Mon Oct 17 21:49:54 2016 (r307534) @@ -76,6 +76,10 @@ * * For details on the use of these macros, see the queue(3) manual page. * + * Below is a summary of implemented functions where: + * + means the macro is available + * - means the macro is not available + * s means the macro is available but is slow (runs in O(n) time) * * SLIST LIST STAILQ TAILQ * _HEAD + + + + @@ -101,10 +105,10 @@ * _INSERT_BEFORE - + - + * _INSERT_AFTER + + + + * _INSERT_TAIL - - + + - * _CONCAT - - + + + * _CONCAT s s + + * _REMOVE_AFTER + - + - * _REMOVE_HEAD + - + - - * _REMOVE + + + + + * _REMOVE s + s + * _SWAP + + + + * */ @@ -183,6 +187,19 @@ struct { \ /* * Singly-linked List functions. */ +#define SLIST_CONCAT(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ + if (curelm == NULL) { \ + if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \ + SLIST_INIT(head2); \ + } else if (SLIST_FIRST(head2) != NULL) { \ + while (SLIST_NEXT(curelm, field) != NULL) \ + curelm = SLIST_NEXT(curelm, field); \ + SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ + SLIST_INIT(head2); \ + } \ +} while (0) + #define SLIST_EMPTY(head) ((head)->slh_first == NULL) #define SLIST_FIRST(head) ((head)->slh_first) @@ -447,6 +464,23 @@ struct { \ #define QMD_LIST_CHECK_PREV(elm, field) #endif /* (_KERNEL && INVARIANTS) */ +#define LIST_CONCAT(head1, head2, type, field) do { \ + QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \ + if (curelm == NULL) { \ + if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \ + LIST_FIRST(head2)->field.le_prev = \ + &LIST_FIRST((head1)); \ + LIST_INIT(head2); \ + } \ + } else if (LIST_FIRST(head2) != NULL) { \ + while (LIST_NEXT(curelm, field) != NULL) \ + curelm = LIST_NEXT(curelm, field); \ + LIST_NEXT(curelm, field) = LIST_FIRST(head2); \ + LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \ + LIST_INIT(head2); \ + } \ +} while (0) + #define LIST_EMPTY(head) ((head)->lh_first == NULL) #define LIST_FIRST(head) ((head)->lh_first) Modified: stable/10/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- stable/10/sys/ufs/ffs/ffs_softdep.c Mon Oct 17 21:44:41 2016 (r307533) +++ stable/10/sys/ufs/ffs/ffs_softdep.c Mon Oct 17 21:49:54 2016 (r307534) @@ -751,16 +751,16 @@ static int flush_newblk_dep(struct vnode static int flush_inodedep_deps(struct vnode *, struct mount *, ino_t); static int flush_deplist(struct allocdirectlst *, int, int *); static int sync_cgs(struct mount *, int); -static int handle_written_filepage(struct pagedep *, struct buf *); +static int handle_written_filepage(struct pagedep *, struct buf *, int); static int handle_written_sbdep(struct sbdep *, struct buf *); static void initiate_write_sbdep(struct sbdep *); static void diradd_inode_written(struct diradd *, struct inodedep *); static int handle_written_indirdep(struct indirdep *, struct buf *, - struct buf**); -static int handle_written_inodeblock(struct inodedep *, struct buf *); + struct buf**, int); +static int handle_written_inodeblock(struct inodedep *, struct buf *, int); static int jnewblk_rollforward(struct jnewblk *, struct fs *, struct cg *, uint8_t *); -static int handle_written_bmsafemap(struct bmsafemap *, struct buf *); +static int handle_written_bmsafemap(struct bmsafemap *, struct buf *, int); static void handle_written_jaddref(struct jaddref *); static void handle_written_jremref(struct jremref *); static void handle_written_jseg(struct jseg *, struct buf *); @@ -10868,6 +10868,10 @@ initiate_write_bmsafemap(bmsafemap, bp) struct fs *fs; ino_t ino; + /* + * If this is a background write, we did this at the time that + * the copy was made, so do not need to do it again. + */ if (bmsafemap->sm_state & IOSTARTED) return; bmsafemap->sm_state |= IOSTARTED; @@ -10941,10 +10945,39 @@ softdep_disk_write_complete(bp) /* * If an error occurred while doing the write, then the data - * has not hit the disk and the dependencies cannot be unrolled. + * has not hit the disk and the dependencies cannot be processed. + * But we do have to go through and roll forward any dependencies + * that were rolled back before the disk write. */ - if ((bp->b_ioflags & BIO_ERROR) != 0 && (bp->b_flags & B_INVAL) == 0) + if ((bp->b_ioflags & BIO_ERROR) != 0 && (bp->b_flags & B_INVAL) == 0) { + LIST_FOREACH(wk, &bp->b_dep, wk_list) { + switch (wk->wk_type) { + + case D_PAGEDEP: + handle_written_filepage(WK_PAGEDEP(wk), bp, 0); + continue; + + case D_INODEDEP: + handle_written_inodeblock(WK_INODEDEP(wk), + bp, 0); + continue; + + case D_BMSAFEMAP: + handle_written_bmsafemap(WK_BMSAFEMAP(wk), + bp, 0); + continue; + + case D_INDIRDEP: + handle_written_indirdep(WK_INDIRDEP(wk), + bp, &sbp, 0); + continue; + default: + /* nothing to roll forward */ + continue; + } + } return; + } if ((wk = LIST_FIRST(&bp->b_dep)) == NULL) return; ump = VFSTOUFS(wk->wk_mp); @@ -10964,17 +10997,20 @@ softdep_disk_write_complete(bp) switch (wk->wk_type) { case D_PAGEDEP: - if (handle_written_filepage(WK_PAGEDEP(wk), bp)) + if (handle_written_filepage(WK_PAGEDEP(wk), bp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; case D_INODEDEP: - if (handle_written_inodeblock(WK_INODEDEP(wk), bp)) + if (handle_written_inodeblock(WK_INODEDEP(wk), bp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; case D_BMSAFEMAP: - if (handle_written_bmsafemap(WK_BMSAFEMAP(wk), bp)) + if (handle_written_bmsafemap(WK_BMSAFEMAP(wk), bp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; @@ -10993,7 +11029,8 @@ softdep_disk_write_complete(bp) continue; case D_INDIRDEP: - if (handle_written_indirdep(WK_INDIRDEP(wk), bp, &sbp)) + if (handle_written_indirdep(WK_INDIRDEP(wk), bp, &sbp, + WRITESUCCEEDED)) WORKLIST_INSERT(&reattach, wk); continue; @@ -11293,12 +11330,17 @@ handle_bufwait(inodedep, refhd) * Called from within softdep_disk_write_complete above to restore * in-memory inode block contents to their most up-to-date state. Note * that this routine is always called from interrupt level with further - * splbio interrupts blocked. + * interrupts from this device blocked. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. */ static int -handle_written_inodeblock(inodedep, bp) +handle_written_inodeblock(inodedep, bp, flags) struct inodedep *inodedep; struct buf *bp; /* buffer containing the inode block */ + int flags; { struct freefile *freefile; struct allocdirect *adp, *nextadp; @@ -11328,7 +11370,8 @@ handle_written_inodeblock(inodedep, bp) /* * Leave this inodeblock dirty until it's in the list. */ - if ((inodedep->id_state & (UNLINKED | UNLINKONLIST)) == UNLINKED) { + if ((inodedep->id_state & (UNLINKED | UNLINKONLIST)) == UNLINKED && + (flags & WRITESUCCEEDED)) { struct inodedep *inon; inon = TAILQ_NEXT(inodedep, id_unlinked); @@ -11367,7 +11410,8 @@ handle_written_inodeblock(inodedep, bp) goto bufwait; return (1); } - inodedep->id_state |= COMPLETE; + if (flags & WRITESUCCEEDED) + inodedep->id_state |= COMPLETE; /* * Roll forward anything that had to be rolled back before * the inode could be updated. @@ -11482,6 +11526,13 @@ handle_written_inodeblock(inodedep, bp) bdirty(bp); bufwait: /* + * If the write did not succeed, we have done all the roll-forward + * operations, but we cannot take the actions that will allow its + * dependencies to be processed. + */ + if ((flags & WRITESUCCEEDED) == 0) + return (hadchanges); + /* * Process any allocdirects that completed during the update. */ if ((adp = TAILQ_FIRST(&inodedep->id_inoupdt)) != NULL) @@ -11538,11 +11589,20 @@ bufwait: return (hadchanges); } +/* + * Perform needed roll-forwards and kick off any dependencies that + * can now be processed. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. + */ static int -handle_written_indirdep(indirdep, bp, bpp) +handle_written_indirdep(indirdep, bp, bpp, flags) struct indirdep *indirdep; struct buf *bp; struct buf **bpp; + int flags; { struct allocindir *aip; struct buf *sbp; @@ -11567,6 +11627,16 @@ handle_written_indirdep(indirdep, bp, bp indirdep->ir_state &= ~(UNDONE | IOSTARTED); indirdep->ir_state |= ATTACHED; /* + * If the write did not succeed, we have done all the roll-forward + * operations, but we cannot take the actions that will allow its + * dependencies to be processed. + */ + if ((flags & WRITESUCCEEDED) == 0) { + stat_indir_blk_ptrs++; + bdirty(bp); + return (1); + } + /* * Move allocindirs with written pointers to the completehd if * the indirdep's pointer is not yet written. Otherwise * free them here. @@ -11720,11 +11790,16 @@ jnewblk_rollforward(jnewblk, fs, cgp, bl * Complete a write to a bmsafemap structure. Roll forward any bitmap * changes if it's not a background write. Set all written dependencies * to DEPCOMPLETE and free the structure if possible. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. */ static int -handle_written_bmsafemap(bmsafemap, bp) +handle_written_bmsafemap(bmsafemap, bp, flags) struct bmsafemap *bmsafemap; struct buf *bp; + int flags; { struct newblk *newblk; struct inodedep *inodedep; @@ -11740,15 +11815,20 @@ handle_written_bmsafemap(bmsafemap, bp) int chgs; if ((bmsafemap->sm_state & IOSTARTED) == 0) - panic("initiate_write_bmsafemap: Not started\n"); + panic("handle_written_bmsafemap: Not started\n"); ump = VFSTOUFS(bmsafemap->sm_list.wk_mp); chgs = 0; bmsafemap->sm_state &= ~IOSTARTED; foreground = (bp->b_xflags & BX_BKGRDMARKER) == 0; /* - * Release journal work that was waiting on the write. + * If write was successful, release journal work that was waiting + * on the write. Otherwise move the work back. */ - handle_jwork(&bmsafemap->sm_freewr); + if (flags & WRITESUCCEEDED) + handle_jwork(&bmsafemap->sm_freewr); + else + LIST_CONCAT(&bmsafemap->sm_freehd, &bmsafemap->sm_freewr, + worklist, wk_list); /* * Restore unwritten inode allocation pending jaddref writes. @@ -11798,6 +11878,20 @@ handle_written_bmsafemap(bmsafemap, bp) free_jnewblk(jnewblk); } } + /* + * If the write did not succeed, we have done all the roll-forward + * operations, but we cannot take the actions that will allow its + * dependencies to be processed. + */ + if ((flags & WRITESUCCEEDED) == 0) { + LIST_CONCAT(&bmsafemap->sm_newblkhd, &bmsafemap->sm_newblkwr, + newblk, nb_deps); + LIST_CONCAT(&bmsafemap->sm_freehd, &bmsafemap->sm_freewr, + worklist, wk_list); + if (foreground) + bdirty(bp); + return (1); + } while ((newblk = LIST_FIRST(&bmsafemap->sm_newblkwr))) { newblk->nb_state |= DEPCOMPLETE; newblk->nb_state &= ~ONDEPLIST; @@ -11901,12 +11995,17 @@ free_pagedep(pagedep) * A write operation was just completed. Removed inodes can * now be freed and associated block pointers may be committed. * Note that this routine is always called from interrupt level - * with further splbio interrupts blocked. + * with further interrupts from this device blocked. + * + * If the write did not succeed, we will do all the roll-forward + * operations, but we will not take the actions that will allow its + * dependencies to be processed. */ static int -handle_written_filepage(pagedep, bp) +handle_written_filepage(pagedep, bp, flags) struct pagedep *pagedep; struct buf *bp; /* buffer containing the written page */ + int flags; { struct dirrem *dirrem; struct diradd *dap, *nextdap; @@ -11916,6 +12015,8 @@ handle_written_filepage(pagedep, bp) if ((pagedep->pd_state & IOSTARTED) == 0) panic("handle_written_filepage: not started"); pagedep->pd_state &= ~IOSTARTED; + if ((flags & WRITESUCCEEDED) == 0) + goto rollforward; /* * Process any directory removals that have been committed. */ @@ -11935,6 +12036,7 @@ handle_written_filepage(pagedep, bp) if ((pagedep->pd_state & NEWBLOCK) == 0) while ((dap = LIST_FIRST(&pagedep->pd_pendinghd)) != NULL) free_diradd(dap, NULL); +rollforward: /* * Uncommitted directory entries must be restored. */ @@ -11967,7 +12069,7 @@ handle_written_filepage(pagedep, bp) * marked dirty so that its will eventually get written back in * its correct form. */ - if (chgs) { + if (chgs || (flags & WRITESUCCEEDED) == 0) { if ((bp->b_flags & B_DELWRI) == 0) stat_dir_entry++; bdirty(bp); Modified: stable/10/sys/ufs/ffs/softdep.h ============================================================================== --- stable/10/sys/ufs/ffs/softdep.h Mon Oct 17 21:44:41 2016 (r307533) +++ stable/10/sys/ufs/ffs/softdep.h Mon Oct 17 21:49:54 2016 (r307534) @@ -140,6 +140,7 @@ #define UNLINKPREV 0x100000 /* inodedep is pointed at in the unlink list */ #define UNLINKONLIST 0x200000 /* inodedep is in the unlinked list on disk */ #define UNLINKLINKS (UNLINKNEXT | UNLINKPREV) +#define WRITESUCCEEDED 0x400000 /* the disk write completed successfully */ #define ALLCOMPLETE (ATTACHED | COMPLETE | DEPCOMPLETE) From owner-svn-src-stable@freebsd.org Mon Oct 17 22:33:30 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EAE65C157EC; Mon, 17 Oct 2016 22:33:30 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AB98F1C9; Mon, 17 Oct 2016 22:33:30 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HMXTbr061033; Mon, 17 Oct 2016 22:33:29 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HMXTMW061029; Mon, 17 Oct 2016 22:33:29 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201610172233.u9HMXTMW061029@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 17 Oct 2016 22:33:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307535 - stable/11/sbin/fsck_ffs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 22:33:31 -0000 Author: mckusick Date: Mon Oct 17 22:33:29 2016 New Revision: 307535 URL: https://svnweb.freebsd.org/changeset/base/307535 Log: MFC 304438: Fsck_ufs was using an int rather than a ufs2_daddr_t to store the alternate superblock location when given in the -b option. Modified: stable/11/sbin/fsck_ffs/fsck.h stable/11/sbin/fsck_ffs/globs.c stable/11/sbin/fsck_ffs/main.c stable/11/sbin/fsck_ffs/setup.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/fsck.h ============================================================================== --- stable/11/sbin/fsck_ffs/fsck.h Mon Oct 17 21:49:54 2016 (r307534) +++ stable/11/sbin/fsck_ffs/fsck.h Mon Oct 17 22:33:29 2016 (r307535) @@ -305,7 +305,7 @@ extern u_int real_dev_bsize; /* actual extern char nflag; /* assume a no response */ extern char yflag; /* assume a yes response */ extern int bkgrdflag; /* use a snapshot to run on an active system */ -extern int bflag; /* location of alternate super block */ +extern ufs2_daddr_t bflag; /* location of alternate super block */ extern int debug; /* output debugging info */ extern int Eflag; /* delete empty data blocks */ extern int Zflag; /* zero empty data blocks */ Modified: stable/11/sbin/fsck_ffs/globs.c ============================================================================== --- stable/11/sbin/fsck_ffs/globs.c Mon Oct 17 21:49:54 2016 (r307534) +++ stable/11/sbin/fsck_ffs/globs.c Mon Oct 17 22:33:29 2016 (r307535) @@ -77,7 +77,7 @@ u_int real_dev_bsize; /* actual disk se char nflag; /* assume a no response */ char yflag; /* assume a yes response */ int bkgrdflag; /* use a snapshot to run on an active system */ -int bflag; /* location of alternate super block */ +ufs2_daddr_t bflag; /* location of alternate super block */ int debug; /* output debugging info */ int Eflag; /* delete empty data blocks */ int Zflag; /* zero empty data blocks */ Modified: stable/11/sbin/fsck_ffs/main.c ============================================================================== --- stable/11/sbin/fsck_ffs/main.c Mon Oct 17 21:49:54 2016 (r307534) +++ stable/11/sbin/fsck_ffs/main.c Mon Oct 17 22:33:29 2016 (r307535) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -68,7 +69,7 @@ __FBSDID("$FreeBSD$"); int restarts; static void usage(void) __dead2; -static int argtoi(int flag, const char *req, const char *str, int base); +static intmax_t argtoimax(int flag, const char *req, const char *str, int base); static int checkfilesys(char *filesys); static int chkdoreload(struct statfs *mntp); static struct statfs *getmntpt(const char *); @@ -88,8 +89,8 @@ main(int argc, char *argv[]) switch (ch) { case 'b': skipclean = 0; - bflag = argtoi('b', "number", optarg, 10); - printf("Alternate super block location: %d\n", bflag); + bflag = argtoimax('b', "number", optarg, 10); + printf("Alternate super block location: %jd\n", bflag); break; case 'B': @@ -98,7 +99,8 @@ main(int argc, char *argv[]) case 'c': skipclean = 0; - cvtlevel = argtoi('c', "conversion level", optarg, 10); + cvtlevel = argtoimax('c', "conversion level", optarg, + 10); if (cvtlevel < 3) errx(EEXIT, "cannot do level %d conversion", cvtlevel); @@ -121,7 +123,7 @@ main(int argc, char *argv[]) break; case 'm': - lfmode = argtoi('m', "mode", optarg, 8); + lfmode = argtoimax('m', "mode", optarg, 8); if (lfmode &~ 07777) errx(EEXIT, "bad mode to -m: %o", lfmode); printf("** lost+found creation mode %o\n", lfmode); @@ -203,13 +205,13 @@ main(int argc, char *argv[]) exit(ret); } -static int -argtoi(int flag, const char *req, const char *str, int base) +static intmax_t +argtoimax(int flag, const char *req, const char *str, int base) { char *cp; - int ret; + intmax_t ret; - ret = (int)strtol(str, &cp, base); + ret = strtoimax(str, &cp, base); if (cp == str || *cp) errx(EEXIT, "-%c flag requires a %s", flag, req); return (ret); Modified: stable/11/sbin/fsck_ffs/setup.c ============================================================================== --- stable/11/sbin/fsck_ffs/setup.c Mon Oct 17 21:49:54 2016 (r307534) +++ stable/11/sbin/fsck_ffs/setup.c Mon Oct 17 22:33:29 2016 (r307535) @@ -196,7 +196,7 @@ setup(char *dev) bflag = 0; return(0); } - pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag); + pwarn("USING ALTERNATE SUPERBLOCK AT %jd\n", bflag); bflag = 0; } if (skipclean && ckclean && sblock.fs_clean) { @@ -329,7 +329,7 @@ readsb(int listerr) } if (sblock.fs_magic != FS_UFS1_MAGIC && sblock.fs_magic != FS_UFS2_MAGIC) { - fprintf(stderr, "%d is not a file system superblock\n", + fprintf(stderr, "%jd is not a file system superblock\n", bflag); return (0); } From owner-svn-src-stable@freebsd.org Mon Oct 17 22:34:43 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4285EC15896; Mon, 17 Oct 2016 22:34:43 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0645B382; Mon, 17 Oct 2016 22:34:42 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9HMYgqg061138; Mon, 17 Oct 2016 22:34:42 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9HMYfqY061134; Mon, 17 Oct 2016 22:34:41 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201610172234.u9HMYfqY061134@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 17 Oct 2016 22:34:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307536 - stable/10/sbin/fsck_ffs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2016 22:34:43 -0000 Author: mckusick Date: Mon Oct 17 22:34:41 2016 New Revision: 307536 URL: https://svnweb.freebsd.org/changeset/base/307536 Log: MFC 304438: Fsck_ufs was using an int rather than a ufs2_daddr_t to store the alternate superblock location when given in the -b option. Modified: stable/10/sbin/fsck_ffs/fsck.h stable/10/sbin/fsck_ffs/globs.c stable/10/sbin/fsck_ffs/main.c stable/10/sbin/fsck_ffs/setup.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fsck_ffs/fsck.h ============================================================================== --- stable/10/sbin/fsck_ffs/fsck.h Mon Oct 17 22:33:29 2016 (r307535) +++ stable/10/sbin/fsck_ffs/fsck.h Mon Oct 17 22:34:41 2016 (r307536) @@ -305,7 +305,7 @@ extern u_int real_dev_bsize; /* actual extern char nflag; /* assume a no response */ extern char yflag; /* assume a yes response */ extern int bkgrdflag; /* use a snapshot to run on an active system */ -extern int bflag; /* location of alternate super block */ +extern ufs2_daddr_t bflag; /* location of alternate super block */ extern int debug; /* output debugging info */ extern int Eflag; /* delete empty data blocks */ extern int Zflag; /* zero empty data blocks */ Modified: stable/10/sbin/fsck_ffs/globs.c ============================================================================== --- stable/10/sbin/fsck_ffs/globs.c Mon Oct 17 22:33:29 2016 (r307535) +++ stable/10/sbin/fsck_ffs/globs.c Mon Oct 17 22:34:41 2016 (r307536) @@ -77,7 +77,7 @@ u_int real_dev_bsize; /* actual disk se char nflag; /* assume a no response */ char yflag; /* assume a yes response */ int bkgrdflag; /* use a snapshot to run on an active system */ -int bflag; /* location of alternate super block */ +ufs2_daddr_t bflag; /* location of alternate super block */ int debug; /* output debugging info */ int Eflag; /* delete empty data blocks */ int Zflag; /* zero empty data blocks */ Modified: stable/10/sbin/fsck_ffs/main.c ============================================================================== --- stable/10/sbin/fsck_ffs/main.c Mon Oct 17 22:33:29 2016 (r307535) +++ stable/10/sbin/fsck_ffs/main.c Mon Oct 17 22:34:41 2016 (r307536) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -68,7 +69,7 @@ __FBSDID("$FreeBSD$"); int restarts; static void usage(void) __dead2; -static int argtoi(int flag, const char *req, const char *str, int base); +static intmax_t argtoimax(int flag, const char *req, const char *str, int base); static int checkfilesys(char *filesys); static int chkdoreload(struct statfs *mntp); static struct statfs *getmntpt(const char *); @@ -88,8 +89,8 @@ main(int argc, char *argv[]) switch (ch) { case 'b': skipclean = 0; - bflag = argtoi('b', "number", optarg, 10); - printf("Alternate super block location: %d\n", bflag); + bflag = argtoimax('b', "number", optarg, 10); + printf("Alternate super block location: %jd\n", bflag); break; case 'B': @@ -98,7 +99,8 @@ main(int argc, char *argv[]) case 'c': skipclean = 0; - cvtlevel = argtoi('c', "conversion level", optarg, 10); + cvtlevel = argtoimax('c', "conversion level", optarg, + 10); if (cvtlevel < 3) errx(EEXIT, "cannot do level %d conversion", cvtlevel); @@ -121,7 +123,7 @@ main(int argc, char *argv[]) break; case 'm': - lfmode = argtoi('m', "mode", optarg, 8); + lfmode = argtoimax('m', "mode", optarg, 8); if (lfmode &~ 07777) errx(EEXIT, "bad mode to -m: %o", lfmode); printf("** lost+found creation mode %o\n", lfmode); @@ -203,13 +205,13 @@ main(int argc, char *argv[]) exit(ret); } -static int -argtoi(int flag, const char *req, const char *str, int base) +static intmax_t +argtoimax(int flag, const char *req, const char *str, int base) { char *cp; - int ret; + intmax_t ret; - ret = (int)strtol(str, &cp, base); + ret = strtoimax(str, &cp, base); if (cp == str || *cp) errx(EEXIT, "-%c flag requires a %s", flag, req); return (ret); Modified: stable/10/sbin/fsck_ffs/setup.c ============================================================================== --- stable/10/sbin/fsck_ffs/setup.c Mon Oct 17 22:33:29 2016 (r307535) +++ stable/10/sbin/fsck_ffs/setup.c Mon Oct 17 22:34:41 2016 (r307536) @@ -198,7 +198,7 @@ setup(char *dev) bflag = 0; return(0); } - pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag); + pwarn("USING ALTERNATE SUPERBLOCK AT %jd\n", bflag); bflag = 0; } if (skipclean && ckclean && sblock.fs_clean) { @@ -332,7 +332,7 @@ readsb(int listerr) } if (sblock.fs_magic != FS_UFS1_MAGIC && sblock.fs_magic != FS_UFS2_MAGIC) { - fprintf(stderr, "%d is not a file system superblock\n", + fprintf(stderr, "%jd is not a file system superblock\n", bflag); return (0); } From owner-svn-src-stable@freebsd.org Tue Oct 18 10:12:57 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30C55C1757F; Tue, 18 Oct 2016 10:12:57 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F397CACA; Tue, 18 Oct 2016 10:12:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9IACuLl025078; Tue, 18 Oct 2016 10:12:56 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9IACu9b025077; Tue, 18 Oct 2016 10:12:56 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610181012.u9IACu9b025077@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 18 Oct 2016 10:12:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307552 - stable/11/sys/vm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 18 Oct 2016 10:12:57 -0000 Author: kib Date: Tue Oct 18 10:12:55 2016 New Revision: 307552 URL: https://svnweb.freebsd.org/changeset/base/307552 Log: MFC r307064: When downgrading exclusively busied page to shared-busy state, wakeup waiters. Modified: stable/11/sys/vm/vm_page.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Tue Oct 18 07:16:49 2016 (r307551) +++ stable/11/sys/vm/vm_page.c Tue Oct 18 10:12:55 2016 (r307552) @@ -657,15 +657,26 @@ void vm_page_busy_downgrade(vm_page_t m) { u_int x; + bool locked; vm_page_assert_xbusied(m); + locked = mtx_owned(vm_page_lockptr(m)); for (;;) { x = m->busy_lock; x &= VPB_BIT_WAITERS; + if (x != 0 && !locked) + vm_page_lock(m); if (atomic_cmpset_rel_int(&m->busy_lock, - VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1) | x)) + VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1))) break; + if (x != 0 && !locked) + vm_page_unlock(m); + } + if (x != 0) { + wakeup(m); + if (!locked) + vm_page_unlock(m); } } From owner-svn-src-stable@freebsd.org Tue Oct 18 10:33:30 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 215B6C17A90; Tue, 18 Oct 2016 10:33:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DCB0E1597; Tue, 18 Oct 2016 10:33:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9IAXSuq032728; Tue, 18 Oct 2016 10:33:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9IAXSxm032727; Tue, 18 Oct 2016 10:33:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610181033.u9IAXSxm032727@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 18 Oct 2016 10:33:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307555 - stable/10/sys/vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 18 Oct 2016 10:33:30 -0000 Author: kib Date: Tue Oct 18 10:33:28 2016 New Revision: 307555 URL: https://svnweb.freebsd.org/changeset/base/307555 Log: MFC r307064: When downgrading exclusively busied page to shared-busy state, wakeup waiters. Modified: stable/10/sys/vm/vm_page.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/vm/vm_page.c ============================================================================== --- stable/10/sys/vm/vm_page.c Tue Oct 18 10:20:58 2016 (r307554) +++ stable/10/sys/vm/vm_page.c Tue Oct 18 10:33:28 2016 (r307555) @@ -515,15 +515,26 @@ void vm_page_busy_downgrade(vm_page_t m) { u_int x; + bool locked; vm_page_assert_xbusied(m); + locked = mtx_owned(vm_page_lockptr(m)); for (;;) { x = m->busy_lock; x &= VPB_BIT_WAITERS; + if (x != 0 && !locked) + vm_page_lock(m); if (atomic_cmpset_rel_int(&m->busy_lock, - VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1) | x)) + VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1))) break; + if (x != 0 && !locked) + vm_page_unlock(m); + } + if (x != 0) { + wakeup(m); + if (!locked) + vm_page_unlock(m); } } From owner-svn-src-stable@freebsd.org Tue Oct 18 19:15:46 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 49C86C170C3; Tue, 18 Oct 2016 19:15:46 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 181AC2E4; Tue, 18 Oct 2016 19:15:46 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9IJFjfg039758; Tue, 18 Oct 2016 19:15:45 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9IJFh4T039744; Tue, 18 Oct 2016 19:15:43 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610181915.u9IJFh4T039744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 18 Oct 2016 19:15:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307575 - in stable/11/sys: arm/broadcom/bcm2835 contrib/vchiq/interface/vchiq_arm dev/usb/controller X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 18 Oct 2016 19:15:46 -0000 Author: gonzo Date: Tue Oct 18 19:15:43 2016 New Revision: 307575 URL: https://svnweb.freebsd.org/changeset/base/307575 Log: MFC r307067, r307068, r307087, r307088, r307089, r307091, r307092, r307093, r307095, r307098, r307115: r307067: Make intc driver compatible with upstream DTS - Fix compatibility strings - Properly decode upstream's two-cell interrupt specs. Our home-made dts does not have two-cell interrupts so no need to preserve backward compatibility r307068: Make Rapsberry Pi watchdog driver compatible with upstream DTS - Fix compatibility strings - Compensate the difference in base address for our custom DTS and upstream one (for backward compatibility) r307087: Make sure intc is attached before interrupt consumers If pass order is not specified devices are attached in the order they are defined in dts. Some interrupt consumers may be defined before intc. Also make sure intc interrupt-parent local_intc is attached before intc itself. r307088: Add compatible strings used in upstream dts files r307089: Make framebuffer driver compatible with upstream DT - Add compatibility string - Add simplebus as possible parent bus r307091: Add compatibility string from upstream DT r307092: Make BCM2835 GPIO driver compatible with upstream DT - Add compatibility string - Make reserverd and read-only properties optional r307093: Make BCM283x USB driver compatible with upstream DT - Make resource allocation logic depend on compatibility string to check what format of DTS node should be used - FreeBSD's or upstream r307095: Make VCHI driver compatible with upstream DT - Add compatibility string - Compensate difference in base address between our custom DTB and upstream one r307098: Make BCM28x USB driver compatible with upstream device tree This should have been committed in r307093: resource allocation depends on source of the device tree. upstream dts has extra interrupt that we can ignore r307115: Fix typo in comment Spotted by: loos Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Tue Oct 18 19:15:43 2016 (r307575) @@ -52,6 +52,12 @@ __FBSDID("$FreeBSD$"); #include "iicbus_if.h" +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-bsc", 1}, + {"brcm,bcm2708-i2c", 1}, + {NULL, 0} +}; + static void bcm_bsc_intr(void *); static int bcm_bsc_detach(device_t); @@ -214,7 +220,7 @@ bcm_bsc_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-bsc")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2708/2835 BSC controller"); Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 18 19:15:43 2016 (r307575) @@ -56,7 +56,8 @@ fdt_intc_decode_ic(phandle_t node, pcell int *pol) { - if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic")) { + if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic") || + fdt_is_compatible(node, "brcm,bcm2836-armctrl-ic")) { *interrupt = fdt32_to_cpu(intr[0]); *trig = INTR_TRIGGER_CONFORM; *pol = INTR_POLARITY_CONFORM; Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c Tue Oct 18 19:15:43 2016 (r307575) @@ -154,6 +154,12 @@ struct bcm_dma_softc { static struct bcm_dma_softc *bcm_dma_sc = NULL; static uint32_t bcm_dma_channel_mask; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-dma", 1}, + {"brcm,bcm2835-dma", 1}, + {NULL, 0} +}; + static void bcm_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err) @@ -658,7 +664,7 @@ bcm_dma_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-dma")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2835 DMA Controller"); Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c Tue Oct 18 19:15:43 2016 (r307575) @@ -111,6 +111,12 @@ struct bcmsc_softc { static struct bcmsc_softc bcmsc; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-fb", 1}, + {"brcm,bcm2708-fb", 1}, + {NULL, 0} +}; + static int bcm_fb_probe(device_t); static int bcm_fb_attach(device_t); static void bcmfb_update_margins(video_adapter_t *adp); @@ -121,8 +127,9 @@ bcm_fb_probe(device_t dev) { int error; - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); + device_set_desc(dev, "BCM2835 framebuffer device"); error = sc_probe_unit(device_get_unit(dev), device_get_flags(dev) | SC_AUTODETECT_KBD); @@ -196,6 +203,7 @@ static driver_t bcm_fb_driver = { }; DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, bcm_fb_devclass, 0, 0); +DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0); /* * Video driver routines and glue. Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Tue Oct 18 19:15:43 2016 (r307575) @@ -65,6 +65,12 @@ struct bcmsc_softc { device_t dev; }; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-fb", 1}, + {"brcm,bcm2708-fb", 1}, + {NULL, 0} +}; + static int bcm_fb_probe(device_t); static int bcm_fb_attach(device_t); @@ -189,7 +195,8 @@ bcm_fb_sysctl_init(struct bcmsc_softc *s static int bcm_fb_probe(device_t dev) { - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb")) + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2835 VT framebuffer driver"); @@ -263,3 +270,4 @@ static driver_t bcm_fb_driver = { }; DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, bcm_fb_devclass, 0, 0); +DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0); Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Tue Oct 18 19:15:43 2016 (r307575) @@ -82,8 +82,6 @@ static struct resource_spec bcm_gpio_res { SYS_RES_MEMORY, 0, RF_ACTIVE }, { SYS_RES_IRQ, 0, RF_ACTIVE }, /* bank 0 interrupt */ { SYS_RES_IRQ, 1, RF_ACTIVE }, /* bank 1 interrupt */ - { SYS_RES_IRQ, 2, RF_ACTIVE }, /* bank 1 interrupt (mirrored) */ - { SYS_RES_IRQ, 3, RF_ACTIVE }, /* bank 0-1 interrupt (united) */ { -1, 0, 0 } }; @@ -159,6 +157,12 @@ enum bcm_gpio_pud { #define BCM_GPIO_GPPUD(_bank) (0x94) /* Pin Pull up/down */ #define BCM_GPIO_GPPUDCLK(_bank) (0x98 + _bank * 4) /* Pin Pull up clock */ +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-gpio", 1}, + {"brcm,bcm2835-gpio", 1}, + {NULL, 0} +}; + static struct bcm_gpio_softc *bcm_gpio_sc = NULL; #ifdef INTRNG @@ -672,11 +676,11 @@ bcm_gpio_get_reserved_pins(struct bcm_gp phandle_t gpio, node, reserved; ssize_t len; - /* Get read-only pins. */ + /* Get read-only pins if they're provided */ gpio = ofw_bus_get_node(sc->sc_dev); if (bcm_gpio_get_ro_pins(sc, gpio, "broadcom,read-only", "read-only") != 0) - return (-1); + return (0); /* Traverse the GPIO subnodes to find the reserved pins node. */ reserved = 0; node = OF_child(gpio); @@ -742,7 +746,7 @@ bcm_gpio_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-gpio")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2708/2835 GPIO controller"); Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c Tue Oct 18 19:15:43 2016 (r307575) @@ -270,6 +270,7 @@ bcm_intc_map_intr(device_t dev, struct i u_int irq; struct intr_map_data_fdt *daf; struct bcm_intc_softc *sc; + bool valid; if (data->type != INTR_MAP_DATA_FDT) return (ENOTSUP); @@ -277,8 +278,36 @@ bcm_intc_map_intr(device_t dev, struct i daf = (struct intr_map_data_fdt *)data; if (daf->ncells == 1) irq = daf->cells[0]; - else if (daf->ncells == 2) - irq = daf->cells[0] * 32 + daf->cells[1]; + else if (daf->ncells == 2) { + valid = true; + switch (daf->cells[0]) { + case 0: + irq = daf->cells[1]; + if (irq >= BANK1_START) + valid = false; + break; + case 1: + irq = daf->cells[1] + BANK1_START; + if (irq > BANK1_END) + valid = false; + break; + case 2: + irq = daf->cells[1] + BANK2_START; + if (irq > BANK2_END) + valid = false; + break; + default: + valid = false; + break; + } + + if (!valid) { + device_printf(dev, + "invalid IRQ config: bank=%d, irq=%d\n", + daf->cells[0], daf->cells[1]); + return (EINVAL); + } + } else return (EINVAL); @@ -355,7 +384,8 @@ bcm_intc_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic")) + if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic") && + !ofw_bus_is_compatible(dev, "brcm,bcm2836-armctrl-ic")) return (ENXIO); device_set_desc(dev, "BCM2835 Interrupt Controller"); return (BUS_PROBE_DEFAULT); @@ -438,7 +468,8 @@ static driver_t bcm_intc_driver = { static devclass_t bcm_intc_devclass; -DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass, 0, 0); +EARLY_DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass, + 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); #ifndef INTRNG int Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Tue Oct 18 19:15:43 2016 (r307575) @@ -92,6 +92,12 @@ struct bcm_mbox_softc { #define mbox_write_4(sc, reg, val) \ bus_space_write_4((sc)->bst, (sc)->bsh, reg, val) +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-mbox", 1}, + {"brcm,bcm2835-mbox", 1}, + {NULL, 0} +}; + static int bcm_mbox_read_msg(struct bcm_mbox_softc *sc, int *ochan) { @@ -138,12 +144,12 @@ bcm_mbox_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-mbox")) { - device_set_desc(dev, "BCM2835 VideoCore Mailbox"); - return(BUS_PROBE_DEFAULT); - } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "BCM2835 VideoCore Mailbox"); - return (ENXIO); + return (BUS_PROBE_DEFAULT); } static int Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Tue Oct 18 19:15:43 2016 (r307575) @@ -71,6 +71,12 @@ __FBSDID("$FreeBSD$"); static int bcm2835_sdhci_hs = 1; static int bcm2835_sdhci_pio_mode = 0; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-sdhci", 1}, + {"brcm,bcm2835-mmc", 1}, + {NULL, 0} +}; + TUNABLE_INT("hw.bcm2835.sdhci.hs", &bcm2835_sdhci_hs); TUNABLE_INT("hw.bcm2835.sdhci.pio_mode", &bcm2835_sdhci_pio_mode); @@ -126,10 +132,11 @@ bcm_sdhci_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-sdhci")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "Broadcom 2708 SDHCI controller"); + return (BUS_PROBE_DEFAULT); } Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c Tue Oct 18 19:15:43 2016 (r307575) @@ -58,6 +58,12 @@ __FBSDID("$FreeBSD$"); #include "spibus_if.h" +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-spi", 1}, + {"brcm,bcm2835-spi", 1}, + {NULL, 0} +}; + static void bcm_spi_intr(void *); #ifdef BCM_SPI_DEBUG @@ -233,7 +239,7 @@ bcm_spi_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-spi")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2708/2835 SPI controller"); Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Tue Oct 18 19:15:43 2016 (r307575) @@ -53,8 +53,8 @@ __FBSDID("$FreeBSD$"); #define BCM2835_WDOG_TIME_MASK 0x000fffff #define BCM2835_WDOG_TIME_SHIFT 0 -#define READ(_sc, _r) bus_space_read_4((_sc)->bst, (_sc)->bsh, (_r)) -#define WRITE(_sc, _r, _v) bus_space_write_4((_sc)->bst, (_sc)->bsh, (_r), (_v)) +#define READ(_sc, _r) bus_space_read_4((_sc)->bst, (_sc)->bsh, (_r) + (_sc)->regs_offset) +#define WRITE(_sc, _r, _v) bus_space_write_4((_sc)->bst, (_sc)->bsh, (_r) + (_sc)->regs_offset, (_v)) #define BCM2835_RSTC_WRCFG_CLR 0xffffffcf #define BCM2835_RSTC_WRCFG_SET 0x00000030 @@ -76,6 +76,17 @@ struct bcmwd_softc { int wdog_period; char wdog_passwd; struct mtx mtx; + int regs_offset; +}; + +#define BSD_DTB 1 +#define UPSTREAM_DTB 2 +#define UPSTREAM_DTB_REGS_OFFSET 0x1c + +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-wdt", BSD_DTB}, + {"brcm,bcm2835-pm-wdt", UPSTREAM_DTB}, + {NULL, 0} }; static void bcmwd_watchdog_fn(void *private, u_int cmd, int *error); @@ -87,12 +98,12 @@ bcmwd_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-wdt")) { - device_set_desc(dev, "BCM2708/2835 Watchdog"); - return (BUS_PROBE_DEFAULT); - } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "BCM2708/2835 Watchdog"); - return (ENXIO); + return (BUS_PROBE_DEFAULT); } static int @@ -120,6 +131,11 @@ bcmwd_attach(device_t dev) sc->bst = rman_get_bustag(sc->res); sc->bsh = rman_get_bushandle(sc->res); + /* compensate base address difference */ + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data + == UPSTREAM_DTB) + sc->regs_offset = UPSTREAM_DTB_REGS_OFFSET; + bcmwd_lsc = sc; mtx_init(&sc->mtx, "BCM2835 Watchdog", "bcmwd", MTX_DEF); EVENTHANDLER_REGISTER(watchdog_list, bcmwd_watchdog_fn, sc, 0); Modified: stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c Tue Oct 18 19:15:43 2016 (r307575) @@ -51,6 +51,12 @@ __FBSDID("$FreeBSD$"); #include +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-usb", 1}, + {"brcm,bcm2708-usb", 1}, + {NULL, 0} +}; + static device_probe_t bcm283x_dwc_otg_probe; static device_attach_t bcm283x_dwc_otg_attach; @@ -61,7 +67,7 @@ bcm283x_dwc_otg_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-usb")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "DWC OTG 2.0 integrated USB controller (bcm283x)"); Modified: stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c ============================================================================== --- stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c Tue Oct 18 19:15:43 2016 (r307575) @@ -73,14 +73,25 @@ struct bcm_vchiq_softc { void* intr_hl; bus_space_tag_t bst; bus_space_handle_t bsh; + int regs_offset; }; static struct bcm_vchiq_softc *bcm_vchiq_sc = NULL; +#define BSD_DTB 1 +#define UPSTREAM_DTB 2 +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-vchiq", BSD_DTB}, + {"brcm,bcm2835-vchiq", UPSTREAM_DTB}, + {NULL, 0} +}; + #define vchiq_read_4(reg) \ - bus_space_read_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, reg) + bus_space_read_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, (reg) + \ + bcm_vchiq_sc->regs_offset) #define vchiq_write_4(reg, val) \ - bus_space_write_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, reg, val) + bus_space_write_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, (reg) + \ + bcm_vchiq_sc->regs_offset, val) /* * Extern functions */ @@ -122,12 +133,11 @@ static int bcm_vchiq_probe(device_t dev) { - if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-vchiq")) { - device_set_desc(dev, "BCM2835 VCHIQ"); - return(BUS_PROBE_DEFAULT); - } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); - return (ENXIO); + device_set_desc(dev, "BCM2835 VCHIQ"); + return (BUS_PROBE_DEFAULT); } static int @@ -157,6 +167,9 @@ bcm_vchiq_attach(device_t dev) return (ENXIO); } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == UPSTREAM_DTB) + sc->regs_offset = -0x40; + node = ofw_bus_get_node(dev); if ((OF_getencprop(node, "cache-line-size", &cell, sizeof(cell))) > 0) g_cache_line_size = cell; Modified: stable/11/sys/dev/usb/controller/dwc_otg_fdt.c ============================================================================== --- stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Tue Oct 18 16:18:25 2016 (r307574) +++ stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Tue Oct 18 19:15:43 2016 (r307575) @@ -121,7 +121,12 @@ dwc_otg_attach(device_t dev) sc->sc_otg.sc_io_hdl = rman_get_bushandle(sc->sc_otg.sc_io_res); sc->sc_otg.sc_io_size = rman_get_size(sc->sc_otg.sc_io_res); - rid = 0; + + /* + * brcm,bcm2708-usb FDT provides two interrupts, + * we need only second one (VC_USB) + */ + rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; sc->sc_otg.sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->sc_otg.sc_irq_res == NULL) From owner-svn-src-stable@freebsd.org Tue Oct 18 20:17:58 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF4C1C1762C; Tue, 18 Oct 2016 20:17:58 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B236A03; Tue, 18 Oct 2016 20:17:58 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9IKHvCf063221; Tue, 18 Oct 2016 20:17:57 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9IKHvTD063219; Tue, 18 Oct 2016 20:17:57 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610182017.u9IKHvTD063219@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 18 Oct 2016 20:17:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307576 - in stable/11/sys: dev/atkbdc sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 18 Oct 2016 20:17:59 -0000 Author: gonzo Date: Tue Oct 18 20:17:57 2016 New Revision: 307576 URL: https://svnweb.freebsd.org/changeset/base/307576 Log: MFC r306355, r306474, r306746: r306355: Add Elantech trackpad support Elantech trackpads are found in some laptops like the Asus UX31E. They are "synaptics compatible" but use a slightly different protocol. Elantech hardware support is not enabled by default and just like Synaptic or TrackPoint devices it should be enabled by setting tunable, in this case hw.psm.elantech_support, to non-zero value PR: 205690 Submitted by: Vladimir Kondratyev MFC after: 1 week r306474: Replace explicit TUNABLE_INT to sysctl with CTLFLAG_TUN - Replace tunables-only hw.psm.synaptics_support, hw.psm.trackpoint_support, and hw.psm.elantech_support with respective sysctls declared with CTLFLAG_TUN. It simplifies checking them in userland, also makes them easier to get discovered by user - Get rid of debug.psm.loglevel and hw.psm.tap_enabled TUNABLE_INT declaration by adding CTLFLAG_TUN to read/write sysctls that were already declared for these tunables. Suggested by: jhb r306746: Fix extended buttons support on synaptic clickpad Fix regression introduced by r306355 on synaptic clickpads with extended buttons (buttons stopped working) PR: 205690 Submitted by: Vladimir Kondratyev Modified: stable/11/sys/dev/atkbdc/psm.c stable/11/sys/sys/mouse.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/atkbdc/psm.c ============================================================================== --- stable/11/sys/dev/atkbdc/psm.c Tue Oct 18 19:15:43 2016 (r307575) +++ stable/11/sys/dev/atkbdc/psm.c Tue Oct 18 20:17:57 2016 (r307576) @@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -161,40 +162,6 @@ typedef struct packetbuf { #define PSM_PACKETQUEUE 128 #endif -enum { - SYNAPTICS_SYSCTL_MIN_PRESSURE, - SYNAPTICS_SYSCTL_MAX_PRESSURE, - SYNAPTICS_SYSCTL_MAX_WIDTH, - SYNAPTICS_SYSCTL_MARGIN_TOP, - SYNAPTICS_SYSCTL_MARGIN_RIGHT, - SYNAPTICS_SYSCTL_MARGIN_BOTTOM, - SYNAPTICS_SYSCTL_MARGIN_LEFT, - SYNAPTICS_SYSCTL_NA_TOP, - SYNAPTICS_SYSCTL_NA_RIGHT, - SYNAPTICS_SYSCTL_NA_BOTTOM, - SYNAPTICS_SYSCTL_NA_LEFT, - SYNAPTICS_SYSCTL_WINDOW_MIN, - SYNAPTICS_SYSCTL_WINDOW_MAX, - SYNAPTICS_SYSCTL_MULTIPLICATOR, - SYNAPTICS_SYSCTL_WEIGHT_CURRENT, - SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS, - SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS_NA, - SYNAPTICS_SYSCTL_WEIGHT_LEN_SQUARED, - SYNAPTICS_SYSCTL_DIV_MIN, - SYNAPTICS_SYSCTL_DIV_MAX, - SYNAPTICS_SYSCTL_DIV_MAX_NA, - SYNAPTICS_SYSCTL_DIV_LEN, - SYNAPTICS_SYSCTL_TAP_MAX_DELTA, - SYNAPTICS_SYSCTL_TAP_MIN_QUEUE, - SYNAPTICS_SYSCTL_TAPHOLD_TIMEOUT, - SYNAPTICS_SYSCTL_VSCROLL_HOR_AREA, - SYNAPTICS_SYSCTL_VSCROLL_VER_AREA, - SYNAPTICS_SYSCTL_VSCROLL_MIN_DELTA, - SYNAPTICS_SYSCTL_VSCROLL_DIV_MIN, - SYNAPTICS_SYSCTL_VSCROLL_DIV_MAX, - SYNAPTICS_SYSCTL_TOUCHPAD_OFF -}; - typedef struct synapticsinfo { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; @@ -231,6 +198,11 @@ typedef struct synapticsinfo { int vscroll_div_min; int vscroll_div_max; int touchpad_off; + int softbuttons_y; + int softbutton2_x; + int softbutton3_x; + int max_x; + int max_y; } synapticsinfo_t; typedef struct synapticspacket { @@ -246,22 +218,29 @@ typedef struct synapticspacket { ((synhw).infoMajor > (major) || \ ((synhw).infoMajor == (major) && (synhw).infoMinor >= (minor))) -typedef struct synapticsaction { +typedef struct smoother { synapticspacket_t queue[SYNAPTICS_PACKETQUEUE]; int queue_len; int queue_cursor; - int window_min; int start_x; int start_y; int avg_dx; int avg_dy; int squelch_x; int squelch_y; + int is_fuzzy; + int active; +} smoother_t; + +typedef struct gesture { + int window_min; int fingers_nb; int tap_button; int in_taphold; int in_vscroll; -} synapticsaction_t; + int zmax; /* maximum pressure value */ + struct timeval taptimeout; /* tap timeout for touchpads */ +} gesture_t; enum { TRACKPOINT_SYSCTL_SENSITIVITY, @@ -295,6 +274,100 @@ typedef struct trackpointinfo { int skipback; } trackpointinfo_t; +typedef struct finger { + int x; + int y; + int p; + int w; + int flags; +} finger_t; +#define PSM_FINGERS 2 /* # of processed fingers */ +#define PSM_FINGER_IS_PEN (1<<0) +#define PSM_FINGER_FUZZY (1<<1) +#define PSM_FINGER_DEFAULT_P tap_threshold +#define PSM_FINGER_DEFAULT_W 1 +#define PSM_FINGER_IS_SET(f) ((f).x != -1 && (f).y != -1 && (f).p != 0) +#define PSM_FINGER_RESET(f) do { \ + (f) = (finger_t) { .x = -1, .y = -1, .p = 0, .w = 0, .flags = 0 }; \ +} while (0) + +typedef struct elantechhw { + int hwversion; + int fwversion; + int sizex; + int sizey; + int dpmmx; + int dpmmy; + int ntracesx; + int ntracesy; + int issemimt; + int isclickpad; + int hascrc; + int hastrackpoint; + int haspressure; +} elantechhw_t; + +/* minimum versions supported by this driver */ +#define ELANTECH_HW_IS_V1(fwver) ((fwver) < 0x020030 || (fwver) == 0x020600) + +#define ELANTECH_MAGIC(magic) \ + ((magic)[0] == 0x3c && (magic)[1] == 0x03 && \ + ((magic)[2] == 0xc8 || (magic)[2] == 0x00)) + +#define ELANTECH_FW_ID 0x00 +#define ELANTECH_FW_VERSION 0x01 +#define ELANTECH_CAPABILITIES 0x02 +#define ELANTECH_SAMPLE 0x03 +#define ELANTECH_RESOLUTION 0x04 +#define ELANTECH_REG_READ 0x10 +#define ELANTECH_REG_WRITE 0x11 +#define ELANTECH_REG_RDWR 0x00 +#define ELANTECH_CUSTOM_CMD 0xf8 + +#define ELANTECH_MAX_FINGERS PSM_FINGERS + +#define ELANTECH_FINGER_SET_XYP(pb) (finger_t) { \ + .x = (((pb)->ipacket[1] & 0x0f) << 8) | (pb)->ipacket[2], \ + .y = (((pb)->ipacket[4] & 0x0f) << 8) | (pb)->ipacket[5], \ + .p = ((pb)->ipacket[1] & 0xf0) | (((pb)->ipacket[4] >> 4) & 0x0f), \ + .w = PSM_FINGER_DEFAULT_W, \ + .flags = 0 \ +} + +enum { + ELANTECH_PKT_NOP, + ELANTECH_PKT_TRACKPOINT, + ELANTECH_PKT_V2_COMMON, + ELANTECH_PKT_V2_2FINGER, + ELANTECH_PKT_V3, + ELANTECH_PKT_V4_STATUS, + ELANTECH_PKT_V4_HEAD, + ELANTECH_PKT_V4_MOTION +}; + +#define ELANTECH_PKT_IS_TRACKPOINT(pb) (((pb)->ipacket[3] & 0x0f) == 0x06) +#define ELANTECH_PKT_IS_DEBOUNCE(pb, hwversion) ((hwversion) == 4 ? 0 : \ + (pb)->ipacket[0] == ((hwversion) == 2 ? 0x84 : 0xc4) && \ + (pb)->ipacket[1] == 0xff && (pb)->ipacket[2] == 0xff && \ + (pb)->ipacket[3] == 0x02 && (pb)->ipacket[4] == 0xff && \ + (pb)->ipacket[5] == 0xff) +#define ELANTECH_PKT_IS_V2(pb) \ + (((pb)->ipacket[0] & 0x0c) == 0x04 && ((pb)->ipacket[3] & 0x0f) == 0x02) +#define ELANTECH_PKT_IS_V3_HEAD(pb, hascrc) ((hascrc) ? \ + ((pb)->ipacket[3] & 0x09) == 0x08 : \ + ((pb)->ipacket[0] & 0x0c) == 0x04 && ((pb)->ipacket[3] & 0xcf) == 0x02) +#define ELANTECH_PKT_IS_V3_TAIL(pb, hascrc) ((hascrc) ? \ + ((pb)->ipacket[3] & 0x09) == 0x09 : \ + ((pb)->ipacket[0] & 0x0c) == 0x0c && ((pb)->ipacket[3] & 0xce) == 0x0c) +#define ELANTECH_PKT_IS_V4(pb, hascrc) ((hascrc) ? \ + ((pb)->ipacket[3] & 0x08) == 0x00 : \ + ((pb)->ipacket[0] & 0x0c) == 0x04 && ((pb)->ipacket[3] & 0x1c) == 0x10) + +typedef struct elantechaction { + finger_t fingers[ELANTECH_MAX_FINGERS]; + int mask; +} elantechaction_t; + /* driver control block */ struct psm_softc { /* Driver status information */ int unit; @@ -308,7 +381,10 @@ struct psm_softc { /* Driver status inf mousehw_t hw; /* hardware information */ synapticshw_t synhw; /* Synaptics hardware information */ synapticsinfo_t syninfo; /* Synaptics configuration */ - synapticsaction_t synaction; /* Synaptics action context */ + smoother_t smoother[PSM_FINGERS]; /* Motion smoothing */ + gesture_t gesture; /* Gesture context */ + elantechhw_t elanhw; /* Elantech hardware information */ + elantechaction_t elanaction; /* Elantech action context */ int tphw; /* TrackPoint hardware information */ trackpointinfo_t tpinfo; /* TrackPoint configuration */ mousemode_t mode; /* operation mode */ @@ -324,13 +400,13 @@ struct psm_softc { /* Driver status inf int xaverage; /* average X position */ int yaverage; /* average Y position */ int squelch; /* level to filter movement at low speed */ - int zmax; /* maximum pressure value for touchpads */ int syncerrors; /* # of bytes discarded to synchronize */ int pkterrors; /* # of packets failed during quaranteen. */ struct timeval inputtimeout; struct timeval lastsoftintr; /* time of last soft interrupt */ struct timeval lastinputerr; /* time last sync error happened */ - struct timeval taptimeout; /* tap timeout for touchpads */ + struct timeval idletimeout; + packetbuf_t idlepacket; /* packet to send after idle timeout */ int watchdog; /* watchdog timer flag */ struct callout callout; /* watchdog timer call out */ struct callout softcallout; /* buffer timer call out */ @@ -381,16 +457,10 @@ static devclass_t psm_devclass; /* Tunables */ static int tap_enabled = -1; -TUNABLE_INT("hw.psm.tap_enabled", &tap_enabled); - +static int verbose = PSM_DEBUG; static int synaptics_support = 0; -TUNABLE_INT("hw.psm.synaptics_support", &synaptics_support); - static int trackpoint_support = 0; -TUNABLE_INT("hw.psm.trackpoint_support", &trackpoint_support); - -static int verbose = PSM_DEBUG; -TUNABLE_INT("debug.psm.loglevel", &verbose); +static int elantech_support = 0; /* for backward compatibility */ #define OLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_t) @@ -411,6 +481,44 @@ typedef struct old_mousemode { int accelfactor; } old_mousemode_t; +#define SYN_OFFSET(field) offsetof(struct psm_softc, syninfo.field) +enum { + SYNAPTICS_SYSCTL_MIN_PRESSURE = SYN_OFFSET(min_pressure), + SYNAPTICS_SYSCTL_MAX_PRESSURE = SYN_OFFSET(max_pressure), + SYNAPTICS_SYSCTL_MAX_WIDTH = SYN_OFFSET(max_width), + SYNAPTICS_SYSCTL_MARGIN_TOP = SYN_OFFSET(margin_top), + SYNAPTICS_SYSCTL_MARGIN_RIGHT = SYN_OFFSET(margin_right), + SYNAPTICS_SYSCTL_MARGIN_BOTTOM = SYN_OFFSET(margin_bottom), + SYNAPTICS_SYSCTL_MARGIN_LEFT = SYN_OFFSET(margin_left), + SYNAPTICS_SYSCTL_NA_TOP = SYN_OFFSET(na_top), + SYNAPTICS_SYSCTL_NA_RIGHT = SYN_OFFSET(na_right), + SYNAPTICS_SYSCTL_NA_BOTTOM = SYN_OFFSET(na_bottom), + SYNAPTICS_SYSCTL_NA_LEFT = SYN_OFFSET(na_left), + SYNAPTICS_SYSCTL_WINDOW_MIN = SYN_OFFSET(window_min), + SYNAPTICS_SYSCTL_WINDOW_MAX = SYN_OFFSET(window_max), + SYNAPTICS_SYSCTL_MULTIPLICATOR = SYN_OFFSET(multiplicator), + SYNAPTICS_SYSCTL_WEIGHT_CURRENT = SYN_OFFSET(weight_current), + SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS = SYN_OFFSET(weight_previous), + SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS_NA = SYN_OFFSET(weight_previous_na), + SYNAPTICS_SYSCTL_WEIGHT_LEN_SQUARED = SYN_OFFSET(weight_len_squared), + SYNAPTICS_SYSCTL_DIV_MIN = SYN_OFFSET(div_min), + SYNAPTICS_SYSCTL_DIV_MAX = SYN_OFFSET(div_max), + SYNAPTICS_SYSCTL_DIV_MAX_NA = SYN_OFFSET(div_max_na), + SYNAPTICS_SYSCTL_DIV_LEN = SYN_OFFSET(div_len), + SYNAPTICS_SYSCTL_TAP_MAX_DELTA = SYN_OFFSET(tap_max_delta), + SYNAPTICS_SYSCTL_TAP_MIN_QUEUE = SYN_OFFSET(tap_min_queue), + SYNAPTICS_SYSCTL_TAPHOLD_TIMEOUT = SYN_OFFSET(taphold_timeout), + SYNAPTICS_SYSCTL_VSCROLL_HOR_AREA = SYN_OFFSET(vscroll_hor_area), + SYNAPTICS_SYSCTL_VSCROLL_VER_AREA = SYN_OFFSET(vscroll_ver_area), + SYNAPTICS_SYSCTL_VSCROLL_MIN_DELTA = SYN_OFFSET(vscroll_min_delta), + SYNAPTICS_SYSCTL_VSCROLL_DIV_MIN = SYN_OFFSET(vscroll_div_min), + SYNAPTICS_SYSCTL_VSCROLL_DIV_MAX = SYN_OFFSET(vscroll_div_max), + SYNAPTICS_SYSCTL_TOUCHPAD_OFF = SYN_OFFSET(touchpad_off), + SYNAPTICS_SYSCTL_SOFTBUTTONS_Y = SYN_OFFSET(softbuttons_y), + SYNAPTICS_SYSCTL_SOFTBUTTON2_X = SYN_OFFSET(softbutton2_x), + SYNAPTICS_SYSCTL_SOFTBUTTON3_X = SYN_OFFSET(softbutton3_x), +}; + /* packet formatting function */ typedef int packetfunc_t(struct psm_softc *, u_char *, int *, int, mousestatus_t *); @@ -446,6 +554,7 @@ static int doopen(struct psm_softc *, in static int reinitialize(struct psm_softc *, int); static char *model_name(int); static void psmsoftintr(void *); +static void psmsoftintridle(void *); static void psmintr(void *); static void psmtimeout(void *); static int timeelapsed(const struct timeval *, int, int, @@ -458,6 +567,13 @@ static int proc_synaptics(struct psm_sof mousestatus_t *, int *, int *, int *); static void proc_versapad(struct psm_softc *, packetbuf_t *, mousestatus_t *, int *, int *, int *); +static int proc_elantech(struct psm_softc *, packetbuf_t *, + mousestatus_t *, int *, int *, int *); +static int psmpalmdetect(struct psm_softc *, finger_t *, int); +static void psmgestures(struct psm_softc *, finger_t *, int, + mousestatus_t *); +static void psmsmoother(struct psm_softc *, finger_t *, int, + mousestatus_t *, int *, int *); static int tame_mouse(struct psm_softc *, packetbuf_t *, mousestatus_t *, u_char *); @@ -480,6 +596,7 @@ static probefunc_t enable_mmanplus; static probefunc_t enable_synaptics; static probefunc_t enable_trackpoint; static probefunc_t enable_versapad; +static probefunc_t enable_elantech; static void set_trackpoint_parameters(struct psm_softc *sc); static void synaptics_passthrough_on(struct psm_softc *sc); @@ -511,6 +628,8 @@ static struct { 0xc8, MOUSE_4DPLUS_PACKETSIZE, enable_4dplus }, { MOUSE_MODEL_SYNAPTICS, /* Synaptics Touchpad */ 0xc0, MOUSE_SYNAPTICS_PACKETSIZE, enable_synaptics }, + { MOUSE_MODEL_ELANTECH, /* Elantech Touchpad */ + 0x04, MOUSE_ELANTECH_PACKETSIZE, enable_elantech }, { MOUSE_MODEL_INTELLI, /* Microsoft IntelliMouse */ 0x08, MOUSE_PS2INTELLI_PACKETSIZE, enable_msintelli }, { MOUSE_MODEL_GLIDEPOINT, /* ALPS GlidePoint */ @@ -762,6 +881,7 @@ model_name(int model) { MOUSE_MODEL_4DPLUS, "4D+ Mouse" }, { MOUSE_MODEL_SYNAPTICS, "Synaptics Touchpad" }, { MOUSE_MODEL_TRACKPOINT, "IBM/Lenovo TrackPoint" }, + { MOUSE_MODEL_ELANTECH, "Elantech Touchpad" }, { MOUSE_MODEL_GENERIC, "Generic PS/2 mouse" }, { MOUSE_MODEL_UNKNOWN, "Unknown" }, }; @@ -1504,6 +1624,7 @@ psmattach(device_t dev) case MOUSE_MODEL_SYNAPTICS: case MOUSE_MODEL_GLIDEPOINT: case MOUSE_MODEL_VERSAPAD: + case MOUSE_MODEL_ELANTECH: sc->config |= PSM_CONFIG_INITAFTERSUSPEND; break; default: @@ -1512,6 +1633,11 @@ psmattach(device_t dev) break; } + /* Elantech trackpad`s sync bit differs from touchpad`s one */ + if (sc->hw.model == MOUSE_MODEL_ELANTECH && + (sc->elanhw.hascrc || sc->elanhw.hastrackpoint)) + sc->config |= PSM_CONFIG_NOCHECKSYNC; + if (!verbose) printf("psm%d: model %s, device ID %d\n", unit, model_name(sc->hw.model), sc->hw.hwid & 0x00ff); @@ -2165,20 +2291,6 @@ psmioctl(struct cdev *dev, u_long cmd, c (*(int *)addr > PSM_LEVEL_MAX)) return (EINVAL); sc->mode.level = *(int *)addr; - - if (sc->hw.model == MOUSE_MODEL_SYNAPTICS) { - /* - * If we are entering PSM_LEVEL_NATIVE, we want to - * enable sending of "extended W mode" packets to - * userland. Reset the mode of the touchpad so that the - * change in the level is picked up. - */ - error = block_mouse_data(sc, &command_byte); - if (error) - return (error); - synaptics_set_mode(sc, synaptics_preferred_mode(sc)); - unblock_mouse_data(sc, command_byte); - } break; case MOUSE_GETSTATUS: @@ -2339,7 +2451,7 @@ psmtimeout(void *arg) static SYSCTL_NODE(_debug, OID_AUTO, psm, CTLFLAG_RD, 0, "ps/2 mouse"); static SYSCTL_NODE(_hw, OID_AUTO, psm, CTLFLAG_RD, 0, "ps/2 mouse"); -SYSCTL_INT(_debug_psm, OID_AUTO, loglevel, CTLFLAG_RW, &verbose, 0, +SYSCTL_INT(_debug_psm, OID_AUTO, loglevel, CTLFLAG_RWTUN, &verbose, 0, "Verbosity level"); static int psmhz = 20; @@ -2361,7 +2473,7 @@ static int pkterrthresh = 2; SYSCTL_INT(_debug_psm, OID_AUTO, pkterrthresh, CTLFLAG_RW, &pkterrthresh, 0, "Number of error packets allowed before reinitializing the mouse"); -SYSCTL_INT(_hw_psm, OID_AUTO, tap_enabled, CTLFLAG_RW, &tap_enabled, 0, +SYSCTL_INT(_hw_psm, OID_AUTO, tap_enabled, CTLFLAG_RWTUN, &tap_enabled, 0, "Enable tap and drag gestures"); static int tap_threshold = PSM_TAP_THRESHOLD; SYSCTL_INT(_hw_psm, OID_AUTO, tap_threshold, CTLFLAG_RW, &tap_threshold, 0, @@ -2370,6 +2482,16 @@ static int tap_timeout = PSM_TAP_TIMEOUT SYSCTL_INT(_hw_psm, OID_AUTO, tap_timeout, CTLFLAG_RW, &tap_timeout, 0, "Tap timeout for touchpads"); +/* Tunables */ +SYSCTL_INT(_hw_psm, OID_AUTO, synaptics_support, CTLFLAG_RDTUN, + &synaptics_support, 0, "Enable support for Synaptics touchpads"); + +SYSCTL_INT(_hw_psm, OID_AUTO, trackpoint_support, CTLFLAG_RDTUN, + &trackpoint_support, 0, "Enable support for IBM/Lenovo TrackPoint"); + +SYSCTL_INT(_hw_psm, OID_AUTO, elantech_support, CTLFLAG_RDTUN, + &elantech_support, 0, "Enable support for Elantech touchpads"); + static void psmintr(void *arg) { @@ -2627,7 +2749,10 @@ proc_synaptics(struct psm_softc *sc, pac { static int touchpad_buttons; static int guest_buttons; - int w, x0, y0; + static finger_t f[PSM_FINGERS]; + int w, id, nfingers, ewcode, extended_buttons; + + extended_buttons = 0; /* TouchPad PS/2 absolute mode message format with capFourButtons: * @@ -2683,6 +2808,7 @@ proc_synaptics(struct psm_softc *sc, pac return (-1); *x = *y = 0; + ms->button = ms->obutton; /* * Pressure value. @@ -2718,34 +2844,80 @@ proc_synaptics(struct psm_softc *sc, pac w = 4; } - /* - * Handle packets from the guest device. See: - * Synaptics PS/2 TouchPad Interfacing Guide, Section 5.1 - */ - if (w == 3 && sc->synhw.capPassthrough) { - *x = ((pb->ipacket[1] & 0x10) ? - pb->ipacket[4] - 256 : pb->ipacket[4]); - *y = ((pb->ipacket[1] & 0x20) ? - pb->ipacket[5] - 256 : pb->ipacket[5]); - *z = 0; + switch (w) { + case 3: + /* + * Handle packets from the guest device. See: + * Synaptics PS/2 TouchPad Interfacing Guide, Section 5.1 + */ + if (sc->synhw.capPassthrough) { + *x = ((pb->ipacket[1] & 0x10) ? + pb->ipacket[4] - 256 : pb->ipacket[4]); + *y = ((pb->ipacket[1] & 0x20) ? + pb->ipacket[5] - 256 : pb->ipacket[5]); + *z = 0; + + guest_buttons = 0; + if (pb->ipacket[1] & 0x01) + guest_buttons |= MOUSE_BUTTON1DOWN; + if (pb->ipacket[1] & 0x04) + guest_buttons |= MOUSE_BUTTON2DOWN; + if (pb->ipacket[1] & 0x02) + guest_buttons |= MOUSE_BUTTON3DOWN; - guest_buttons = 0; - if (pb->ipacket[1] & 0x01) - guest_buttons |= MOUSE_BUTTON1DOWN; - if (pb->ipacket[1] & 0x04) - guest_buttons |= MOUSE_BUTTON2DOWN; - if (pb->ipacket[1] & 0x02) - guest_buttons |= MOUSE_BUTTON3DOWN; + ms->button = touchpad_buttons | guest_buttons | + sc->extended_buttons; + } + goto SYNAPTICS_END; - ms->button = touchpad_buttons | guest_buttons; + case 2: + /* Handle Extended W mode packets */ + ewcode = (pb->ipacket[5] & 0xf0) >> 4; +#if PSM_FINGERS > 1 + switch (ewcode) { + case 1: + /* Secondary finger */ + if (sc->synhw.capAdvancedGestures) + f[1] = (finger_t) { + .x = (((pb->ipacket[4] & 0x0f) << 8) | + pb->ipacket[1]) << 1, + .y = (((pb->ipacket[4] & 0xf0) << 4) | + pb->ipacket[2]) << 1, + .p = ((pb->ipacket[3] & 0x30) | + (pb->ipacket[5] & 0x0f)) << 1, + .w = PSM_FINGER_DEFAULT_W, + .flags = PSM_FINGER_FUZZY, + }; + else if (sc->synhw.capReportsV) + f[1] = (finger_t) { + .x = (((pb->ipacket[4] & 0x0f) << 8) | + (pb->ipacket[1] & 0xfe)) << 1, + .y = (((pb->ipacket[4] & 0xf0) << 4) | + (pb->ipacket[2] & 0xfe)) << 1, + .p = ((pb->ipacket[3] & 0x30) | + (pb->ipacket[5] & 0x0e)) << 1, + .w = (((pb->ipacket[5] & 0x01) << 2) | + ((pb->ipacket[2] & 0x01) << 1) | + (pb->ipacket[1] & 0x01)) + 8, + .flags = PSM_FINGER_FUZZY, + }; + default: + break; + } +#endif goto SYNAPTICS_END; + + case 1: + case 0: + nfingers = w + 2; + break; + + default: + nfingers = 1; } - if (sc->syninfo.touchpad_off) { - *x = *y = *z = 0; - ms->button = ms->obutton; + if (sc->syninfo.touchpad_off) goto SYNAPTICS_END; - } /* Button presses */ touchpad_buttons = 0; @@ -2769,21 +2941,21 @@ proc_synaptics(struct psm_softc *sc, pac if ((pb->ipacket[0] ^ pb->ipacket[3]) & 0x02) { if (sc->syninfo.directional_scrolls) { if (pb->ipacket[4] & 0x01) - touchpad_buttons |= MOUSE_BUTTON4DOWN; + extended_buttons |= MOUSE_BUTTON4DOWN; if (pb->ipacket[5] & 0x01) - touchpad_buttons |= MOUSE_BUTTON5DOWN; + extended_buttons |= MOUSE_BUTTON5DOWN; if (pb->ipacket[4] & 0x02) - touchpad_buttons |= MOUSE_BUTTON6DOWN; + extended_buttons |= MOUSE_BUTTON6DOWN; if (pb->ipacket[5] & 0x02) - touchpad_buttons |= MOUSE_BUTTON7DOWN; + extended_buttons |= MOUSE_BUTTON7DOWN; } else { if (pb->ipacket[4] & 0x01) - touchpad_buttons |= MOUSE_BUTTON1DOWN; + extended_buttons |= MOUSE_BUTTON1DOWN; if (pb->ipacket[5] & 0x01) - touchpad_buttons |= MOUSE_BUTTON3DOWN; + extended_buttons |= MOUSE_BUTTON3DOWN; if (pb->ipacket[4] & 0x02) - touchpad_buttons |= MOUSE_BUTTON2DOWN; - sc->extended_buttons = touchpad_buttons; + extended_buttons |= MOUSE_BUTTON2DOWN; + sc->extended_buttons = extended_buttons; } /* @@ -2806,101 +2978,193 @@ proc_synaptics(struct psm_softc *sc, pac pb->ipacket[4] &= ~(mask); pb->ipacket[5] &= ~(mask); } else if (!sc->syninfo.directional_scrolls && - !sc->synaction.in_vscroll) { + !sc->gesture.in_vscroll) { /* * Keep reporting MOUSE DOWN until we get a new packet * indicating otherwise. */ - touchpad_buttons |= sc->extended_buttons; + extended_buttons |= sc->extended_buttons; } } - /* Handle ClickPad. */ + /* Handle ClickPad */ if (sc->synhw.capClickPad && ((pb->ipacket[0] ^ pb->ipacket[3]) & 0x01)) touchpad_buttons |= MOUSE_BUTTON1DOWN; - ms->button = touchpad_buttons | guest_buttons; + if (sc->synhw.capReportsV && nfingers > 1) + f[0] = (finger_t) { + .x = ((pb->ipacket[3] & 0x10) << 8) | + ((pb->ipacket[1] & 0x0f) << 8) | + (pb->ipacket[4] & 0xfd), + .y = ((pb->ipacket[3] & 0x20) << 7) | + ((pb->ipacket[1] & 0xf0) << 4) | + (pb->ipacket[5] & 0xfd), + .p = *z & 0xfe, + .w = (((pb->ipacket[2] & 0x01) << 2) | + (pb->ipacket[5] & 0x02) | + ((pb->ipacket[4] & 0x02) >> 1)) + 8, + .flags = PSM_FINGER_FUZZY, + }; + else + f[0] = (finger_t) { + .x = ((pb->ipacket[3] & 0x10) << 8) | + ((pb->ipacket[1] & 0x0f) << 8) | + pb->ipacket[4], + .y = ((pb->ipacket[3] & 0x20) << 7) | + ((pb->ipacket[1] & 0xf0) << 4) | + pb->ipacket[5], + .p = *z, + .w = w, + .flags = nfingers > 1 ? PSM_FINGER_FUZZY : 0, + }; + + /* Ignore hovering and unmeasurable touches */ + if (f[0].p < sc->syninfo.min_pressure || f[0].x < 2) + nfingers = 0; + + for (id = 0; id < PSM_FINGERS; id++) + if (id >= nfingers) + PSM_FINGER_RESET(f[id]); + + ms->button = touchpad_buttons; + + /* Palm detection doesn't terminate the current action. */ + if (!psmpalmdetect(sc, &f[0], nfingers)) { + psmgestures(sc, &f[0], nfingers, ms); + for (id = 0; id < PSM_FINGERS; id++) + psmsmoother(sc, &f[id], id, ms, x, y); + } else { + VLOG(2, (LOG_DEBUG, "synaptics: palm detected! (%d)\n", f[0].w)); + } + + ms->button |= extended_buttons | guest_buttons; + +SYNAPTICS_END: + /* + * Use the extra buttons as a scrollwheel + * + * XXX X.Org uses the Z axis for vertical wheel only, + * whereas moused(8) understands special values to differ + * vertical and horizontal wheels. + * + * xf86-input-mouse needs therefore a small patch to + * understand these special values. Without it, the + * horizontal wheel acts as a vertical wheel in X.Org. + * + * That's why the horizontal wheel is disabled by + * default for now. + */ + if (ms->button & MOUSE_BUTTON4DOWN) + *z = -1; + else if (ms->button & MOUSE_BUTTON5DOWN) + *z = 1; + else if (ms->button & MOUSE_BUTTON6DOWN) + *z = -2; + else if (ms->button & MOUSE_BUTTON7DOWN) + *z = 2; + else + *z = 0; + ms->button &= ~(MOUSE_BUTTON4DOWN | MOUSE_BUTTON5DOWN | + MOUSE_BUTTON6DOWN | MOUSE_BUTTON7DOWN); + + return (0); +} + +static int +psmpalmdetect(struct psm_softc *sc, finger_t *f, int nfingers) +{ + if (!( + ((sc->synhw.capMultiFinger || + sc->synhw.capAdvancedGestures) && nfingers > 1) || + (sc->synhw.capPalmDetect && f->w <= sc->syninfo.max_width) || + (!sc->synhw.capPalmDetect && f->p <= sc->syninfo.max_pressure) || + (sc->synhw.capPen && f->flags & PSM_FINGER_IS_PEN))) { + /* + * We consider the packet irrelevant for the current + * action when: + * - the width isn't comprised in: + * [1; max_width] + * - the pressure isn't comprised in: + * [min_pressure; max_pressure] + * - pen aren't supported but PSM_FINGER_IS_PEN is set + */ + return (1); + } + return (0); +} + +static void +psmgestures(struct psm_softc *sc, finger_t *fingers, int nfingers, + mousestatus_t *ms) +{ + smoother_t *smoother; + gesture_t *gest; + finger_t *f; + int y_ok, center_button, center_x, right_button, right_x, i; + + f = &fingers[0]; + smoother = &sc->smoother[0]; + gest = &sc->gesture; + + /* Find first active finger. */ + if (nfingers > 0) { + for (i = 0; i < PSM_FINGERS; i++) { + if (PSM_FINGER_IS_SET(fingers[i])) { + f = &fingers[i]; + smoother = &sc->smoother[i]; + break; + } + } + } /* * Check pressure to detect a real wanted action on the * touchpad. */ - if (*z >= sc->syninfo.min_pressure) { - synapticsaction_t *synaction; - int cursor, peer, window; - int dx, dy, dxp, dyp; - int max_width, max_pressure; + if (f->p >= sc->syninfo.min_pressure) { + int x0, y0; + int dxp, dyp; + int start_x, start_y; + int queue_len; int margin_top, margin_right, margin_bottom, margin_left; - int na_top, na_right, na_bottom, na_left; int window_min, window_max; - int multiplicator; - int weight_current, weight_previous, weight_len_squared; - int div_min, div_max, div_len; int vscroll_hor_area, vscroll_ver_area; int two_finger_scroll; - int len, weight_prev_x, weight_prev_y; - int div_max_x, div_max_y, div_x, div_y; - int exiting_scroll; + int max_x, max_y; /* Read sysctl. */ /* XXX Verify values? */ - max_width = sc->syninfo.max_width; - max_pressure = sc->syninfo.max_pressure; margin_top = sc->syninfo.margin_top; margin_right = sc->syninfo.margin_right; margin_bottom = sc->syninfo.margin_bottom; margin_left = sc->syninfo.margin_left; - na_top = sc->syninfo.na_top; - na_right = sc->syninfo.na_right; - na_bottom = sc->syninfo.na_bottom; - na_left = sc->syninfo.na_left; window_min = sc->syninfo.window_min; window_max = sc->syninfo.window_max; - multiplicator = sc->syninfo.multiplicator; - weight_current = sc->syninfo.weight_current; - weight_previous = sc->syninfo.weight_previous; - weight_len_squared = sc->syninfo.weight_len_squared; - div_min = sc->syninfo.div_min; - div_max = sc->syninfo.div_max; - div_len = sc->syninfo.div_len; vscroll_hor_area = sc->syninfo.vscroll_hor_area; vscroll_ver_area = sc->syninfo.vscroll_ver_area; two_finger_scroll = sc->syninfo.two_finger_scroll; - - exiting_scroll = 0; - - /* Palm detection. */ - if (!( - ((sc->synhw.capMultiFinger || - sc->synhw.capAdvancedGestures) && (w == 0 || w == 1)) || - (sc->synhw.capPalmDetect && w >= 4 && w <= max_width) || - (!sc->synhw.capPalmDetect && *z <= max_pressure) || - (sc->synhw.capPen && w == 2))) { - /* - * We consider the packet irrelevant for the current - * action when: - * - the width isn't comprised in: - * [4; max_width] - * - the pressure isn't comprised in: - * [min_pressure; max_pressure] - * - pen aren't supported but w is 2 - * - * Note that this doesn't terminate the current action. - */ - VLOG(2, (LOG_DEBUG, - "synaptics: palm detected! (%d)\n", w)); - goto SYNAPTICS_END; - } + max_x = sc->syninfo.max_x; + max_y = sc->syninfo.max_y; /* Read current absolute position. */ - x0 = ((pb->ipacket[3] & 0x10) << 8) | - ((pb->ipacket[1] & 0x0f) << 8) | - pb->ipacket[4]; - y0 = ((pb->ipacket[3] & 0x20) << 7) | - ((pb->ipacket[1] & 0xf0) << 4) | - pb->ipacket[5]; + x0 = f->x; + y0 = f->y; + + /* + * Limit the coordinates to the specified margins because + * this area isn't very reliable. + */ + if (x0 <= margin_left) + x0 = margin_left; + else if (x0 >= max_x - margin_right) + x0 = max_x - margin_right; + if (y0 <= margin_bottom) + y0 = margin_bottom; + else if (y0 >= max_y - margin_top) + y0 = max_y - margin_top; - synaction = &(sc->synaction); + VLOG(3, (LOG_DEBUG, "synaptics: ipacket: [%d, %d], %d, %d\n", + x0, y0, f->p, f->w)); /* * If the action is just beginning, init the structure and @@ -2909,107 +3173,82 @@ proc_synaptics(struct psm_softc *sc, pac if (!(sc->flags & PSM_FLAGS_FINGERDOWN)) { VLOG(3, (LOG_DEBUG, "synaptics: ----\n")); - /* Store the first point of this action. */ - synaction->start_x = x0; - synaction->start_y = y0; - dx = dy = 0; - /* Initialize queue. */ - synaction->queue_cursor = SYNAPTICS_PACKETQUEUE; - synaction->queue_len = 0; - synaction->window_min = window_min; - - /* Reset average. */ - synaction->avg_dx = 0; - synaction->avg_dy = 0; - - /* Reset squelch. */ - synaction->squelch_x = 0; - synaction->squelch_y = 0; + gest->window_min = window_min; /* Reset pressure peak. */ - sc->zmax = 0; + gest->zmax = 0; /* Reset fingers count. */ - synaction->fingers_nb = 0; + gest->fingers_nb = 0; /* Reset virtual scrolling state. */ - synaction->in_vscroll = 0; + gest->in_vscroll = 0; /* Compute tap timeout. */ - sc->taptimeout.tv_sec = tap_timeout / 1000000; - sc->taptimeout.tv_usec = tap_timeout % 1000000; - timevaladd(&sc->taptimeout, &sc->lastsoftintr); + gest->taptimeout.tv_sec = tap_timeout / 1000000; + gest->taptimeout.tv_usec = tap_timeout % 1000000; + timevaladd(&gest->taptimeout, &sc->lastsoftintr); sc->flags |= PSM_FLAGS_FINGERDOWN; + + /* Smoother has not been reset yet */ + queue_len = 1; + start_x = x0; + start_y = y0; } else { - /* Calculate the current delta. */ - cursor = synaction->queue_cursor; - dx = x0 - synaction->queue[cursor].x; - dy = y0 - synaction->queue[cursor].y; + queue_len = smoother->queue_len + 1; + start_x = smoother->start_x; + start_y = smoother->start_y; } - /* If in tap-hold, add the recorded button. */ - if (synaction->in_taphold) - ms->button |= synaction->tap_button; - - /* - * From now on, we can use the SYNAPTICS_END label to skip - * the current packet. - */ - - /* - * Limit the coordinates to the specified margins because - * this area isn't very reliable. - */ - if (x0 <= margin_left) - x0 = margin_left; - else if (x0 >= 6143 - margin_right) - x0 = 6143 - margin_right; - if (y0 <= margin_bottom) - y0 = margin_bottom; - else if (y0 >= 6143 - margin_top) - y0 = 6143 - margin_top; + /* Process ClickPad softbuttons */ + if (sc->synhw.capClickPad && ms->button & MOUSE_BUTTON1DOWN) { + y_ok = sc->syninfo.softbuttons_y >= 0 ? + start_y < sc->syninfo.softbuttons_y : + start_y > max_y - sc->syninfo.softbuttons_y; + + center_button = MOUSE_BUTTON2DOWN; + center_x = sc->syninfo.softbutton2_x; + right_button = MOUSE_BUTTON3DOWN; + right_x = sc->syninfo.softbutton3_x; + + if (center_x > 0 && right_x > 0 && center_x > right_x) { + center_button = MOUSE_BUTTON3DOWN; + center_x = sc->syninfo.softbutton3_x; + right_button = MOUSE_BUTTON2DOWN; + right_x = sc->syninfo.softbutton2_x; + } - VLOG(3, (LOG_DEBUG, "synaptics: ipacket: [%d, %d], %d, %d\n", - x0, y0, *z, w)); + if (right_x > 0 && start_x > right_x && y_ok) + ms->button = (ms->button & + ~MOUSE_BUTTON1DOWN) | right_button; + else if (center_x > 0 && start_x > center_x && y_ok) + ms->button = (ms->button & + ~MOUSE_BUTTON1DOWN) | center_button; + } - /* Queue this new packet. */ - cursor = SYNAPTICS_QUEUE_CURSOR(synaction->queue_cursor - 1); - synaction->queue[cursor].x = x0; - synaction->queue[cursor].y = y0; - synaction->queue_cursor = cursor; - if (synaction->queue_len < SYNAPTICS_PACKETQUEUE) - synaction->queue_len++; - VLOG(5, (LOG_DEBUG, - "synaptics: cursor[%d]: x=%d, y=%d, dx=%d, dy=%d\n", - cursor, x0, y0, dx, dy)); + /* If in tap-hold, add the recorded button. */ + if (gest->in_taphold) + ms->button |= gest->tap_button; /* * For tap, we keep the maximum number of fingers and the * pressure peak. Also with multiple fingers, we increase * the minimum window. */ - switch (w) { - case 1: /* Three or more fingers. */ - synaction->fingers_nb = imax(3, synaction->fingers_nb); - synaction->window_min = window_max; - break; - case 0: /* Two fingers. */ - synaction->fingers_nb = imax(2, synaction->fingers_nb); - synaction->window_min = window_max; - break; - default: /* One finger or undetectable. */ - synaction->fingers_nb = imax(1, synaction->fingers_nb); - } - sc->zmax = imax(*z, sc->zmax); - - /* Do we have enough packets to consider this a movement? */ - if (synaction->queue_len < synaction->window_min) - goto SYNAPTICS_END; + if (nfingers > 1) + gest->window_min = window_max; + gest->fingers_nb = imax(nfingers, gest->fingers_nb); + gest->zmax = imax(f->p, gest->zmax); + + /* Do we have enough packets to consider this a gesture? */ + if (queue_len < gest->window_min) + return; /* Is a scrolling action occurring? */ - if (!synaction->in_taphold && !synaction->in_vscroll) { + if (!gest->in_taphold && !ms->button && + (!gest->in_vscroll || two_finger_scroll)) { /* * A scrolling action must not conflict with a tap * action. Here are the conditions to consider a @@ -3020,12 +3259,10 @@ proc_synaptics(struct psm_softc *sc, pac * first should be above a configurable minimum * . tap timed out */ - dxp = abs(synaction->queue[synaction->queue_cursor].x - - synaction->start_x); - dyp = abs(synaction->queue[synaction->queue_cursor].y - - synaction->start_y); + dxp = abs(x0 - start_x); + dyp = abs(y0 - start_y); - if (timevalcmp(&sc->lastsoftintr, &sc->taptimeout, >) || + if (timevalcmp(&sc->lastsoftintr, &gest->taptimeout, >) || dxp >= sc->syninfo.vscroll_min_delta || dyp >= sc->syninfo.vscroll_min_delta) { /* @@ -3034,176 +3271,65 @@ proc_synaptics(struct psm_softc *sc, pac * as that keeps the maximum number of fingers. */ if (two_finger_scroll) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Tue Oct 18 22:24:04 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB1B1C17B01; Tue, 18 Oct 2016 22:24:04 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7EE10302; Tue, 18 Oct 2016 22:24:04 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9IMO3Of013623; Tue, 18 Oct 2016 22:24:03 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9IMO3b0013622; Tue, 18 Oct 2016 22:24:03 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610182224.u9IMO3b0013622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 18 Oct 2016 22:24:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307579 - stable/11/usr.sbin/moused X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 18 Oct 2016 22:24:04 -0000 Author: gonzo Date: Tue Oct 18 22:24:03 2016 New Revision: 307579 URL: https://svnweb.freebsd.org/changeset/base/307579 Log: MFC r306356: Add Elantech trackpad to the list of known models PR: 205690 Submitted by: Vladimir Kondratyev MFC after: 1 week Modified: stable/11/usr.sbin/moused/moused.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/moused/moused.c ============================================================================== --- stable/11/usr.sbin/moused/moused.c Tue Oct 18 21:33:57 2016 (r307578) +++ stable/11/usr.sbin/moused/moused.c Tue Oct 18 22:24:03 2016 (r307579) @@ -246,6 +246,7 @@ static symtab_t rmodels[] = { { "4D+ Mouse", MOUSE_MODEL_4DPLUS, 0 }, { "Synaptics Touchpad", MOUSE_MODEL_SYNAPTICS, 0 }, { "TrackPoint", MOUSE_MODEL_TRACKPOINT, 0 }, + { "Elantech Touchpad", MOUSE_MODEL_ELANTECH, 0 }, { "generic", MOUSE_MODEL_GENERIC, 0 }, { NULL, MOUSE_MODEL_UNKNOWN, 0 }, }; From owner-svn-src-stable@freebsd.org Tue Oct 18 22:26:39 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9752C17C50; Tue, 18 Oct 2016 22:26:39 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 886797A0; Tue, 18 Oct 2016 22:26:39 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9IMQcFm013798; Tue, 18 Oct 2016 22:26:38 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9IMQcwc013797; Tue, 18 Oct 2016 22:26:38 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610182226.u9IMQcwc013797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 18 Oct 2016 22:26:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307580 - stable/11/share/man/man4 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 18 Oct 2016 22:26:39 -0000 Author: gonzo Date: Tue Oct 18 22:26:38 2016 New Revision: 307580 URL: https://svnweb.freebsd.org/changeset/base/307580 Log: MFC r306357: Document hw.psm.elantech_support in psm(4) PR: 205690 Submitted by: Vladimir Kondratyev MFC after: 1 week Modified: stable/11/share/man/man4/psm.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/psm.4 ============================================================================== --- stable/11/share/man/man4/psm.4 Tue Oct 18 22:24:03 2016 (r307579) +++ stable/11/share/man/man4/psm.4 Tue Oct 18 22:26:38 2016 (r307580) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 18, 2013 +.Dd September 26, 2016 .Dt PSM 4 .Os .Sh NAME @@ -340,10 +340,12 @@ at boot-time. This will enable .Nm to handle packets from guest devices (sticks) and extra buttons. -Similarly, extended support for IBM/Lenovo TrackPoint can be enabled -by setting +Similarly, extended support for IBM/Lenovo TrackPoint and Elantech touchpads +can be enabled by setting .Va hw.psm.trackpoint_support -to +or +.Va hw.psm.elantech_support, +respectively, to .Em 1 at boot-time. .Pp From owner-svn-src-stable@freebsd.org Tue Oct 18 23:27:51 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E7B0C17EF3; Tue, 18 Oct 2016 23:27:51 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1EBD41AA5; Tue, 18 Oct 2016 23:27:51 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9INRoKE037342; Tue, 18 Oct 2016 23:27:50 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9INRovA037341; Tue, 18 Oct 2016 23:27:50 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610182327.u9INRovA037341@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 18 Oct 2016 23:27:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307585 - stable/11/sys/dev/usb/net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 18 Oct 2016 23:27:51 -0000 Author: gonzo Date: Tue Oct 18 23:27:50 2016 New Revision: 307585 URL: https://svnweb.freebsd.org/changeset/base/307585 Log: MFC r307154: [fdt] Add one more heuristic to determine MAC address of the SMSC device - If check for net,ethernet/usb,device compatible node fails, try to find .../usb/hub/ethernet, where ... is bus path that can depend on actual HW. net,ethernet/usb,device compatibity strings are FreeBSD custom invention that is used only in RPi DTBs and since there is no other way to tie USB device to FDT node we just do our best effort here to work with upstream device tree - Use -1 value to indicate invalid phandle_t, 0 is valid phandle value and shouldn't be used as error signal Modified: stable/11/sys/dev/usb/net/if_smsc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/net/if_smsc.c ============================================================================== --- stable/11/sys/dev/usb/net/if_smsc.c Tue Oct 18 23:20:49 2016 (r307584) +++ stable/11/sys/dev/usb/net/if_smsc.c Tue Oct 18 23:27:50 2016 (r307585) @@ -1556,6 +1556,9 @@ smsc_ioctl(struct ifnet *ifp, u_long cmd } #ifdef FDT +/* + * This is FreeBSD-specific compatibility strings for RPi/RPi2 + */ static phandle_t smsc_fdt_find_eth_node(phandle_t start) { @@ -1567,11 +1570,68 @@ smsc_fdt_find_eth_node(phandle_t start) fdt_is_compatible(node, "usb,device")) return (node); child = smsc_fdt_find_eth_node(node); - if (child != 0) + if (child != -1) return (child); } - return (0); + return (-1); +} + +/* + * Check if node's path is <*>/usb/hub/ethernet + */ +static int +smsc_fdt_is_usb_eth(phandle_t node) +{ + char name[16]; + int len; + + memset(name, 0, sizeof(name)); + len = OF_getprop(node, "name", name, sizeof(name)); + if (len <= 0) + return (0); + + if (strcmp(name, "ethernet")) + return (0); + + node = OF_parent(node); + if (node == -1) + return (0); + len = OF_getprop(node, "name", name, sizeof(name)); + if (len <= 0) + return (0); + + if (strcmp(name, "hub")) + return (0); + + node = OF_parent(node); + if (node == -1) + return (0); + len = OF_getprop(node, "name", name, sizeof(name)); + if (len <= 0) + return (0); + + if (strcmp(name, "usb")) + return (0); + + return (1); +} + +static phandle_t +smsc_fdt_find_eth_node_by_path(phandle_t start) +{ + phandle_t child, node; + + /* Traverse through entire tree to find usb ethernet nodes. */ + for (node = OF_child(start); node != 0; node = OF_peer(node)) { + if (smsc_fdt_is_usb_eth(node)) + return (node); + child = smsc_fdt_find_eth_node_by_path(node); + if (child != -1) + return (child); + } + + return (-1); } /** @@ -1587,8 +1647,14 @@ smsc_fdt_find_mac(unsigned char *mac) root = OF_finddevice("/"); node = smsc_fdt_find_eth_node(root); - if (node != 0) { + /* + * If it's not FreeBSD FDT blob for RPi, try more + * generic .../usb/hub/ethernet + */ + if (node == -1) + node = smsc_fdt_find_eth_node_by_path(root); + if (node != -1) { /* Check if there is property */ if ((len = OF_getproplen(node, "local-mac-address")) > 0) { if (len != ETHER_ADDR_LEN) From owner-svn-src-stable@freebsd.org Wed Oct 19 00:14:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6863AC12BE1; Wed, 19 Oct 2016 00:14:21 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E676F6C; Wed, 19 Oct 2016 00:14:21 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J0EKX6055873; Wed, 19 Oct 2016 00:14:20 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J0EKqO055872; Wed, 19 Oct 2016 00:14:20 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201610190014.u9J0EKqO055872@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Wed, 19 Oct 2016 00:14:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307587 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 00:14:21 -0000 Author: vangyzen Date: Wed Oct 19 00:14:20 2016 New Revision: 307587 URL: https://svnweb.freebsd.org/changeset/base/307587 Log: MFC r306346 Make no assertions about mutex state when the scheduler is stopped. This changes the assert path to match the lock and unlock paths. Sponsored by: Dell EMC Modified: stable/11/sys/kern/kern_mutex.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_mutex.c ============================================================================== --- stable/11/sys/kern/kern_mutex.c Tue Oct 18 23:48:47 2016 (r307586) +++ stable/11/sys/kern/kern_mutex.c Wed Oct 19 00:14:20 2016 (r307587) @@ -887,7 +887,7 @@ __mtx_assert(const volatile uintptr_t *c { const struct mtx *m; - if (panicstr != NULL || dumping) + if (panicstr != NULL || dumping || SCHEDULER_STOPPED()) return; m = mtxlock2mtx(c); From owner-svn-src-stable@freebsd.org Wed Oct 19 00:14:24 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2ACDAC12C03; Wed, 19 Oct 2016 00:14:24 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ECF4BF73; Wed, 19 Oct 2016 00:14:23 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J0ENoa055921; Wed, 19 Oct 2016 00:14:23 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J0ENcq055920; Wed, 19 Oct 2016 00:14:23 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201610190014.u9J0ENcq055920@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Wed, 19 Oct 2016 00:14:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307588 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 00:14:24 -0000 Author: vangyzen Date: Wed Oct 19 00:14:22 2016 New Revision: 307588 URL: https://svnweb.freebsd.org/changeset/base/307588 Log: MFC r306346 Make no assertions about mutex state when the scheduler is stopped. This changes the assert path to match the lock and unlock paths. Sponsored by: Dell EMC Modified: stable/10/sys/kern/kern_mutex.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_mutex.c ============================================================================== --- stable/10/sys/kern/kern_mutex.c Wed Oct 19 00:14:20 2016 (r307587) +++ stable/10/sys/kern/kern_mutex.c Wed Oct 19 00:14:22 2016 (r307588) @@ -848,7 +848,7 @@ __mtx_assert(const volatile uintptr_t *c { const struct mtx *m; - if (panicstr != NULL || dumping) + if (panicstr != NULL || dumping || SCHEDULER_STOPPED()) return; m = mtxlock2mtx(c); From owner-svn-src-stable@freebsd.org Wed Oct 19 01:35:23 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33601C15E81; Wed, 19 Oct 2016 01:35:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB73F397; Wed, 19 Oct 2016 01:35:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J1ZLPx085705; Wed, 19 Oct 2016 01:35:21 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J1ZLc9085703; Wed, 19 Oct 2016 01:35:21 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610190135.u9J1ZLc9085703@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 19 Oct 2016 01:35:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307589 - in stable/11/sys: dev/fb sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 01:35:23 -0000 Author: gonzo Date: Wed Oct 19 01:35:21 2016 New Revision: 307589 URL: https://svnweb.freebsd.org/changeset/base/307589 Log: MFC r306555: Provide way for framebuffer driver to request mmap(2) mapping type On ARM if memattr is not overriden mmap(2) maps framebuffer memory as WBWA which means part of changes to content in userland end up in cache and appear on screen gradually as cache lines are evicted. This change adds configurable memattr that hardware fb implementation can set to get the memory mapping type it requires: - Add new flag FB_FLAG_MEMATTR that indicates that framebuffer driver overrides default memattr - Add new field fb_memattr to struct fb_info to specify requested memattr Reviewed by: ray Differential Revision: https://reviews.freebsd.org/D8064 Modified: stable/11/sys/dev/fb/fbd.c stable/11/sys/sys/fbio.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/fb/fbd.c ============================================================================== --- stable/11/sys/dev/fb/fbd.c Wed Oct 19 00:14:22 2016 (r307588) +++ stable/11/sys/dev/fb/fbd.c Wed Oct 19 01:35:21 2016 (r307589) @@ -178,6 +178,8 @@ fb_mmap(struct cdev *dev, vm_ooffset_t o *paddr = vtophys((uint8_t *)info->fb_vbase + offset); else *paddr = info->fb_pbase + offset; + if (info->fb_flags & FB_FLAG_MEMATTR) + *memattr = info->fb_memattr; return (0); } return (EINVAL); Modified: stable/11/sys/sys/fbio.h ============================================================================== --- stable/11/sys/sys/fbio.h Wed Oct 19 00:14:22 2016 (r307588) +++ stable/11/sys/sys/fbio.h Wed Oct 19 01:35:21 2016 (r307589) @@ -142,6 +142,8 @@ struct fb_info { uint32_t fb_flags; #define FB_FLAG_NOMMAP 1 /* mmap unsupported. */ #define FB_FLAG_NOWRITE 2 /* disable writes for the time being */ +#define FB_FLAG_MEMATTR 4 /* override memattr for mmap */ + vm_memattr_t fb_memattr; int fb_stride; int fb_bpp; /* bits per pixel */ uint32_t fb_cmap[16]; From owner-svn-src-stable@freebsd.org Wed Oct 19 01:38:24 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E2CFC15F7C; Wed, 19 Oct 2016 01:38:24 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6FDE17A6; Wed, 19 Oct 2016 01:38:24 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J1cNnU085860; Wed, 19 Oct 2016 01:38:23 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J1cNLW085859; Wed, 19 Oct 2016 01:38:23 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610190138.u9J1cNLW085859@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 19 Oct 2016 01:38:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307590 - stable/11/sys/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 01:38:24 -0000 Author: gonzo Date: Wed Oct 19 01:38:23 2016 New Revision: 307590 URL: https://svnweb.freebsd.org/changeset/base/307590 Log: Bump __FreeBSD_version for struct fb_info change in r307589 Modified: stable/11/sys/sys/param.h Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Wed Oct 19 01:35:21 2016 (r307589) +++ stable/11/sys/sys/param.h Wed Oct 19 01:38:23 2016 (r307590) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100504 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100505 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Wed Oct 19 01:55:51 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E0804C173EC; Wed, 19 Oct 2016 01:55:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E397E69; Wed, 19 Oct 2016 01:55:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J1toMS093177; Wed, 19 Oct 2016 01:55:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J1toMF093173; Wed, 19 Oct 2016 01:55:50 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190155.u9J1toMF093173@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 01:55:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307591 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 01:55:52 -0000 Author: sephe Date: Wed Oct 19 01:55:50 2016 New Revision: 307591 URL: https://svnweb.freebsd.org/changeset/base/307591 Log: MFC 305962,305964-305967 305962 hyperv/hn: Don't allow NVS and NDIS version change upon reinitailization NVS and NDIS version change would break too much assumption and static configuration. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7919 305964 hyperv/hn: Save capabilities for later use. And don't allow capability changes during reinitialization, which breaks too much static configuration. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7922 305965 hyperv/hn: Don't allow MTU change, if it is not supported by the NVS. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7923 305966 hyperv/hn: Stringent RSS sysctl checks - Don't change RNDIS RSS configuration for RSS key sysctl, if the interface is not capable of RSS yet. - Don't change RSS indirect table (both cached one and RNDIS RSS configuration), if the interface is not capable of RSS yet. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7924 305967 hyperv/hn: Allow RSS capability flipping upon attach/reinit. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7927 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 19 01:38:23 2016 (r307590) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 19 01:55:50 2016 (r307591) @@ -467,9 +467,15 @@ hn_nvs_conf_ndis(struct hn_softc *sc, in /* NOTE: No response. */ error = hn_nvs_req_send(sc, &conf, sizeof(conf)); - if (error) + if (error) { if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); - return (error); + return (error); + } + + if (bootverbose) + if_printf(sc->hn_ifp, "nvs ndis conf done\n"); + sc->hn_caps |= HN_CAP_MTU | HN_CAP_VLAN; + return (0); } static int @@ -495,6 +501,22 @@ hn_nvs_init(struct hn_softc *sc) { int i; + if (device_is_attached(sc->hn_dev)) { + /* + * NVS version and NDIS version MUST NOT be changed. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "reinit NVS version 0x%x, " + "NDIS version %u.%u\n", sc->hn_nvs_ver, + HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + } + return (hn_nvs_doinit(sc, sc->hn_nvs_ver)); + } + + /* + * Find the supported NVS version and set NDIS version accordingly. + */ for (i = 0; i < nitems(hn_nvs_version); ++i) { int error; Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 01:38:23 2016 (r307590) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 01:55:50 2016 (r307591) @@ -228,7 +228,8 @@ struct hn_softc { struct vmbus_xact_ctx *hn_xact; uint32_t hn_nvs_ver; - uint32_t hn_flags; + uint32_t hn_caps; /* HN_CAP_ */ + uint32_t hn_flags; /* HN_FLAG_ */ void *hn_rxbuf; uint32_t hn_rxbuf_gpadl; struct hyperv_dma hn_rxbuf_dma; @@ -244,6 +245,18 @@ struct hn_softc { #define HN_FLAG_RXBUF_CONNECTED 0x0001 #define HN_FLAG_CHIM_CONNECTED 0x0002 +#define HN_FLAG_HAS_RSSKEY 0x0004 +#define HN_FLAG_HAS_RSSIND 0x0008 + +#define HN_CAP_VLAN 0x0001 +#define HN_CAP_MTU 0x0002 +#define HN_CAP_IPCS 0x0004 +#define HN_CAP_TCP4CS 0x0008 +#define HN_CAP_TCP6CS 0x0010 +#define HN_CAP_UDP4CS 0x0020 +#define HN_CAP_UDP6CS 0x0040 +#define HN_CAP_TSO4 0x0080 +#define HN_CAP_TSO6 0x0100 /* * Externs Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 01:38:23 2016 (r307590) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 01:55:50 2016 (r307591) @@ -325,6 +325,7 @@ static int hn_rx_stat_ulong_sysctl(SYSCT static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_caps_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); @@ -434,6 +435,8 @@ hn_rss_ind_fixup(struct hn_softc *sc, in struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; int i; + KASSERT(nchan > 1, ("invalid # of channels %d", nchan)); + /* * Check indirect table to make sure that all channels in it * can be used. @@ -641,6 +644,9 @@ netvsc_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_ndis_version_sysctl, "A", "NDIS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "caps", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_caps_sysctl, "A", "capabilities"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, hn_rss_key_sysctl, "IU", "RSS key"); @@ -1568,6 +1574,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, HN_LOCK(sc); + if ((sc->hn_caps & HN_CAP_MTU) == 0) { + /* Can't change MTU */ + HN_UNLOCK(sc); + error = EOPNOTSUPP; + break; + } + if (ifp->if_mtu == ifr->ifr_mtu) { HN_UNLOCK(sc); break; @@ -2095,6 +2108,30 @@ hn_ndis_version_sysctl(SYSCTL_HANDLER_AR } static int +hn_caps_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char caps_str[128]; + uint32_t caps; + + HN_LOCK(sc); + caps = sc->hn_caps; + HN_UNLOCK(sc); + snprintf(caps_str, sizeof(caps_str), "%b", caps, + "\020" + "\001VLAN" + "\002MTU" + "\003IPCS" + "\004TCP4CS" + "\005TCP6CS" + "\006UDP4CS" + "\007UDP6CS" + "\010TSO4" + "\011TSO6"); + return sysctl_handle_string(oidp, caps_str, sizeof(caps_str), req); +} + +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; @@ -2109,8 +2146,14 @@ hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) error = SYSCTL_IN(req, sc->hn_rss.rss_key, sizeof(sc->hn_rss.rss_key)); if (error) goto back; + sc->hn_flags |= HN_FLAG_HAS_RSSKEY; - error = hn_rss_reconfig(sc); + if (sc->hn_rx_ring_inuse > 1) { + error = hn_rss_reconfig(sc); + } else { + /* Not RSS capable, at least for now; just save the RSS key. */ + error = 0; + } back: HN_UNLOCK(sc); return (error); @@ -2128,9 +2171,19 @@ hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS) if (error || req->newptr == NULL) goto back; + /* + * Don't allow RSS indirect table change, if this interface is not + * RSS capable currently. + */ + if (sc->hn_rx_ring_inuse == 1) { + error = EOPNOTSUPP; + goto back; + } + error = SYSCTL_IN(req, sc->hn_rss.rss_ind, sizeof(sc->hn_rss.rss_ind)); if (error) goto back; + sc->hn_flags |= HN_FLAG_HAS_RSSIND; hn_rss_ind_fixup(sc, sc->hn_rx_ring_inuse); error = hn_rss_reconfig(sc); @@ -3223,6 +3276,11 @@ hn_synth_attach(struct hn_softc *sc, int { struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; int error, nsubch, nchan, i; + uint32_t old_caps; + + /* Save capabilities for later verification. */ + old_caps = sc->hn_caps; + sc->hn_caps = 0; /* * Attach the primary channel _before_ attaching NVS and RNDIS. @@ -3246,6 +3304,17 @@ hn_synth_attach(struct hn_softc *sc, int return (error); /* + * Make sure capabilities are not changed. + */ + if (device_is_attached(sc->hn_dev) && old_caps != sc->hn_caps) { + if_printf(sc->hn_ifp, "caps mismatch old 0x%08x, new 0x%08x\n", + old_caps, sc->hn_caps); + /* Restore old capabilities and abort. */ + sc->hn_caps = old_caps; + return ENXIO; + } + + /* * Allocate sub-channels for multi-TX/RX rings. * * NOTE: @@ -3268,24 +3337,29 @@ hn_synth_attach(struct hn_softc *sc, int * are allocated. */ - if (!device_is_attached(sc->hn_dev)) { + if ((sc->hn_flags & HN_FLAG_HAS_RSSKEY) == 0) { /* - * Setup default RSS key and indirect table for the - * attach DEVMETHOD. They can be altered later on, - * so don't mess them up once this interface is attached. + * RSS key is not set yet; set it to the default RSS key. */ - if (bootverbose) { - if_printf(sc->hn_ifp, "setup default RSS key and " - "indirect table\n"); - } - - /* Setup default RSS key. */ + if (bootverbose) + if_printf(sc->hn_ifp, "setup default RSS key\n"); memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); + sc->hn_flags |= HN_FLAG_HAS_RSSKEY; + } - /* Setup default RSS indirect table. */ + if ((sc->hn_flags & HN_FLAG_HAS_RSSIND) == 0) { + /* + * RSS indirect table is not set yet; set it up in round- + * robin fashion. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "setup default RSS indirect " + "table\n"); + } /* TODO: Take ndis_rss_caps.ndis_nind into account. */ for (i = 0; i < NDIS_HASH_INDCNT; ++i) rss->rss_ind[i] = i % nchan; + sc->hn_flags |= HN_FLAG_HAS_RSSIND; } else { /* * # of usable channels may be changed, so we have to Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 01:38:23 2016 (r307590) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 01:55:50 2016 (r307591) @@ -800,6 +800,7 @@ static int hn_rndis_conf_offload(struct hn_softc *sc) { struct ndis_offload_params params; + uint32_t caps; size_t paramsz; int error; @@ -816,24 +817,29 @@ hn_rndis_conf_offload(struct hn_softc *s } params.ndis_hdr.ndis_size = paramsz; + caps = HN_CAP_IPCS | HN_CAP_TCP4CS | HN_CAP_TCP6CS; params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + caps |= HN_CAP_UDP4CS | HN_CAP_UDP6CS; params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; } + caps |= HN_CAP_TSO4; params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; /* XXX ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON */ error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); if (error) { if_printf(sc->hn_ifp, "offload config failed: %d\n", error); - } else { - if (bootverbose) - if_printf(sc->hn_ifp, "offload config done\n"); + return (error); } - return (error); + + if (bootverbose) + if_printf(sc->hn_ifp, "offload config done\n"); + sc->hn_caps |= caps; + return (0); } int From owner-svn-src-stable@freebsd.org Wed Oct 19 02:08:05 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99D17C17849; Wed, 19 Oct 2016 02:08:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 57BAF8DB; Wed, 19 Oct 2016 02:08:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J284Qo097107; Wed, 19 Oct 2016 02:08:04 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J284K6097104; Wed, 19 Oct 2016 02:08:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190208.u9J284K6097104@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 02:08:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307594 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 02:08:05 -0000 Author: sephe Date: Wed Oct 19 02:08:04 2016 New Revision: 307594 URL: https://svnweb.freebsd.org/changeset/base/307594 Log: MFC 306013,306014 306013 hyperv/hn: Fix ifnet hwassist setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7948 306014 hyperv/hn: Let the caller of hn_nvs_doinit() do the error logging. So that NVS version probing failure does not look too scary. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7950 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 19 02:03:30 2016 (r307593) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 19 02:08:04 2016 (r307594) @@ -444,8 +444,15 @@ hn_nvs_doinit(struct hn_softc *sc, uint3 vmbus_xact_put(xact); if (status != HN_NVS_STATUS_OK) { - if_printf(sc->hn_ifp, "nvs init failed for ver 0x%x\n", - nvs_ver); + if (bootverbose) { + /* + * Caller may try another NVS version, and will log + * error if there are no more NVS versions to try, + * so don't bark out loud here. + */ + if_printf(sc->hn_ifp, "nvs init failed for ver 0x%x\n", + nvs_ver); + } return (EINVAL); } return (0); @@ -499,7 +506,7 @@ hn_nvs_init_ndis(struct hn_softc *sc) static int hn_nvs_init(struct hn_softc *sc) { - int i; + int i, error; if (device_is_attached(sc->hn_dev)) { /* @@ -511,15 +518,19 @@ hn_nvs_init(struct hn_softc *sc) HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } - return (hn_nvs_doinit(sc, sc->hn_nvs_ver)); + + error = hn_nvs_doinit(sc, sc->hn_nvs_ver); + if (error) { + if_printf(sc->hn_ifp, "reinit NVS version 0x%x " + "failed: %d\n", sc->hn_nvs_ver, error); + } + return (error); } /* * Find the supported NVS version and set NDIS version accordingly. */ for (i = 0; i < nitems(hn_nvs_version); ++i) { - int error; - error = hn_nvs_doinit(sc, hn_nvs_version[i]); if (!error) { sc->hn_nvs_ver = hn_nvs_version[i]; Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 02:03:30 2016 (r307593) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 02:08:04 2016 (r307594) @@ -180,14 +180,6 @@ struct hn_txdesc { #define HN_TXD_FLAG_ONLIST 0x1 #define HN_TXD_FLAG_DMAMAP 0x2 -/* - * Only enable UDP checksum offloading when it is on 2012R2 or - * later. UDP checksum offloading doesn't work on earlier - * Windows releases. - */ -#define HN_CSUM_ASSIST_WIN8 (CSUM_IP | CSUM_TCP) -#define HN_CSUM_ASSIST (CSUM_IP | CSUM_UDP | CSUM_TCP) - #define HN_LRO_LENLIM_MULTIRX_DEF (12 * ETHERMTU) #define HN_LRO_LENLIM_DEF (25 * ETHERMTU) /* YYY 2*MTU is a bit rough, but should be good enough. */ @@ -202,6 +194,13 @@ struct hn_txdesc { #define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) #define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) +#define HN_CSUM_IP_MASK (CSUM_IP | CSUM_IP_TCP | CSUM_IP_UDP) +#define HN_CSUM_IP6_MASK (CSUM_IP6_TCP | CSUM_IP6_UDP) +#define HN_CSUM_IP_HWASSIST(sc) \ + ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP_MASK) +#define HN_CSUM_IP6_HWASSIST(sc) \ + ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP6_MASK) + /* * Globals */ @@ -326,12 +325,14 @@ static int hn_tx_stat_ulong_sysctl(SYSCT static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); static int hn_caps_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_hwassist_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); static int hn_create_tx_data(struct hn_softc *, int); +static void hn_fixup_tx_data(struct hn_softc *); static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); @@ -632,10 +633,10 @@ netvsc_attach(device_t dev) } #endif - hn_set_chim_size(sc, sc->hn_chim_szmax); - if (hn_tx_chimney_size > 0 && - hn_tx_chimney_size < sc->hn_chim_szmax) - hn_set_chim_size(sc, hn_tx_chimney_size); + /* + * Fixup TX stuffs after synthetic parts are attached. + */ + hn_fixup_tx_data(sc); ctx = device_get_sysctl_ctx(dev); child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); @@ -647,6 +648,9 @@ netvsc_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "caps", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_caps_sysctl, "A", "capabilities"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "hwassist", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_hwassist_sysctl, "A", "hwassist"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, hn_rss_key_sysctl, "IU", "RSS key"); @@ -681,13 +685,32 @@ netvsc_attach(device_t dev) ifp->if_qflush = hn_xmit_qflush; } - ifp->if_capabilities |= - IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | - IFCAP_LRO; - ifp->if_capenable |= - IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | - IFCAP_LRO; - ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; + ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_LRO; +#ifdef foo + /* We can't diff IPv6 packets from IPv4 packets on RX path. */ + ifp->if_capabilities |= IFCAP_RXCSUM_IPV6; +#endif + if (sc->hn_caps & HN_CAP_VLAN) { + /* XXX not sure about VLAN_MTU. */ + ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU; + } + + ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist; + if (ifp->if_hwassist & HN_CSUM_IP_MASK) + ifp->if_capabilities |= IFCAP_TXCSUM; + if (ifp->if_hwassist & HN_CSUM_IP6_MASK) + ifp->if_capabilities |= IFCAP_TXCSUM_IPV6; + if (sc->hn_caps & HN_CAP_TSO4) { + ifp->if_capabilities |= IFCAP_TSO4; + ifp->if_hwassist |= CSUM_IP_TSO; + } + if (sc->hn_caps & HN_CAP_TSO6) { + ifp->if_capabilities |= IFCAP_TSO6; + ifp->if_hwassist |= CSUM_IP6_TSO; + } + + /* Enable all available capabilities by default. */ + ifp->if_capenable = ifp->if_capabilities; tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) @@ -1041,14 +1064,19 @@ hn_encap(struct hn_tx_ring *txr, struct } else if (m_head->m_pkthdr.csum_flags & txr->hn_csum_assist) { pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, NDIS_TXCSUM_INFO_SIZE, NDIS_PKTINFO_TYPE_CSUM); - *pi_data = NDIS_TXCSUM_INFO_IPV4; - - if (m_head->m_pkthdr.csum_flags & CSUM_IP) - *pi_data |= NDIS_TXCSUM_INFO_IPCS; + if (m_head->m_pkthdr.csum_flags & + (CSUM_IP6_TCP | CSUM_IP6_UDP)) { + *pi_data = NDIS_TXCSUM_INFO_IPV6; + } else { + *pi_data = NDIS_TXCSUM_INFO_IPV4; + if (m_head->m_pkthdr.csum_flags & CSUM_IP) + *pi_data |= NDIS_TXCSUM_INFO_IPCS; + } - if (m_head->m_pkthdr.csum_flags & CSUM_TCP) + if (m_head->m_pkthdr.csum_flags & (CSUM_IP_TCP | CSUM_IP6_TCP)) *pi_data |= NDIS_TXCSUM_INFO_TCPCS; - else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) + else if (m_head->m_pkthdr.csum_flags & + (CSUM_IP_UDP | CSUM_IP6_UDP)) *pi_data |= NDIS_TXCSUM_INFO_UDPCS; } @@ -1665,21 +1693,31 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, case SIOCSIFCAP: HN_LOCK(sc); - mask = ifr->ifr_reqcap ^ ifp->if_capenable; + if (mask & IFCAP_TXCSUM) { ifp->if_capenable ^= IFCAP_TXCSUM; - if (ifp->if_capenable & IFCAP_TXCSUM) { - ifp->if_hwassist |= - sc->hn_tx_ring[0].hn_csum_assist; - } else { - ifp->if_hwassist &= - ~sc->hn_tx_ring[0].hn_csum_assist; - } + if (ifp->if_capenable & IFCAP_TXCSUM) + ifp->if_hwassist |= HN_CSUM_IP_HWASSIST(sc); + else + ifp->if_hwassist &= ~HN_CSUM_IP_HWASSIST(sc); + } + if (mask & IFCAP_TXCSUM_IPV6) { + ifp->if_capenable ^= IFCAP_TXCSUM_IPV6; + if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) + ifp->if_hwassist |= HN_CSUM_IP6_HWASSIST(sc); + else + ifp->if_hwassist &= ~HN_CSUM_IP6_HWASSIST(sc); } + /* TODO: flip RNDIS offload parameters for RXCSUM. */ if (mask & IFCAP_RXCSUM) ifp->if_capenable ^= IFCAP_RXCSUM; +#ifdef foo + /* We can't diff IPv6 packets from IPv4 packets on RX path. */ + if (mask & IFCAP_RXCSUM_IPV6) + ifp->if_capenable ^= IFCAP_RXCSUM_IPV6; +#endif if (mask & IFCAP_LRO) ifp->if_capenable ^= IFCAP_LRO; @@ -1691,7 +1729,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, else ifp->if_hwassist &= ~CSUM_IP_TSO; } - if (mask & IFCAP_TSO6) { ifp->if_capenable ^= IFCAP_TSO6; if (ifp->if_capenable & IFCAP_TSO6) @@ -2132,6 +2169,20 @@ hn_caps_sysctl(SYSCTL_HANDLER_ARGS) } static int +hn_hwassist_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char assist_str[128]; + uint32_t hwassist; + + HN_LOCK(sc); + hwassist = sc->hn_ifp->if_hwassist; + HN_UNLOCK(sc); + snprintf(assist_str, sizeof(assist_str), "%b", hwassist, CSUM_BITS); + return sysctl_handle_string(oidp, assist_str, sizeof(assist_str), req); +} + +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; @@ -2488,7 +2539,6 @@ hn_create_tx_ring(struct hn_softc *sc, i device_t dev = sc->hn_dev; bus_dma_tag_t parent_dtag; int error, i; - uint32_t version; txr->hn_sc = sc; txr->hn_tx_idx = id; @@ -2527,18 +2577,6 @@ hn_create_tx_ring(struct hn_softc *sc, i } txr->hn_direct_tx_size = hn_direct_tx_size; - version = VMBUS_GET_VERSION(device_get_parent(dev), dev); - if (version >= VMBUS_VERSION_WIN8_1) { - txr->hn_csum_assist = HN_CSUM_ASSIST; - } else { - txr->hn_csum_assist = HN_CSUM_ASSIST_WIN8; - if (id == 0) { - device_printf(dev, "bus version %u.%u, " - "no UDP checksum offloading\n", - VMBUS_VERSION_MAJOR(version), - VMBUS_VERSION_MINOR(version)); - } - } /* * Always schedule transmission instead of trying to do direct @@ -2834,6 +2872,35 @@ hn_set_chim_size(struct hn_softc *sc, in } static void +hn_fixup_tx_data(struct hn_softc *sc) +{ + uint64_t csum_assist; + int i; + + hn_set_chim_size(sc, sc->hn_chim_szmax); + if (hn_tx_chimney_size > 0 && + hn_tx_chimney_size < sc->hn_chim_szmax) + hn_set_chim_size(sc, hn_tx_chimney_size); + + csum_assist = 0; + if (sc->hn_caps & HN_CAP_IPCS) + csum_assist |= CSUM_IP; + if (sc->hn_caps & HN_CAP_TCP4CS) + csum_assist |= CSUM_IP_TCP; + if (sc->hn_caps & HN_CAP_UDP4CS) + csum_assist |= CSUM_IP_UDP; +#ifdef notyet + if (sc->hn_caps & HN_CAP_TCP6CS) + csum_assist |= CSUM_IP6_TCP; + if (sc->hn_caps & HN_CAP_UDP6CS) + csum_assist |= CSUM_IP6_UDP; +#endif + + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + sc->hn_tx_ring[i].hn_csum_assist = csum_assist; +} + +static void hn_destroy_tx_data(struct hn_softc *sc) { int i; From owner-svn-src-stable@freebsd.org Wed Oct 19 02:14:06 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05E94C17A6A; Wed, 19 Oct 2016 02:14:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7F69CCA; Wed, 19 Oct 2016 02:14:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J2E4fS001169; Wed, 19 Oct 2016 02:14:04 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J2E4dj001165; Wed, 19 Oct 2016 02:14:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190214.u9J2E4dj001165@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 02:14:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307595 - in stable/11/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 02:14:06 -0000 Author: sephe Date: Wed Oct 19 02:14:04 2016 New Revision: 307595 URL: https://svnweb.freebsd.org/changeset/base/307595 Log: MFC 306072-306074,306076 306072 hyperv/vmbus: Allow bufrings preallocation. The assumption that the channel is only opened upon synthetic device attach time no longer holds, e.g. Hyper-V network device MTU changes. We have to allow device drivers to preallocate bufrings, e.g. in attach DEVMETHOD, to prevent bufring allocation failure once the system memory is fragmented after running for a while. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7960 306073 hyperv/hn: Allocate bufrings in attach DEVMETHOD. So that reinitialization, e.g. MTU change, will not fail when the system memory is excessively fragmented. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7961 306074 hyperv/vmbus: Assert that the bufring address is page aligned. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7962 306076 hyperv/hn: Put debug messages under bootverbose While I'm here, strip blank line. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7963 Modified: stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Wed Oct 19 02:08:04 2016 (r307594) +++ stable/11/sys/dev/hyperv/include/vmbus.h Wed Oct 19 02:14:04 2016 (r307595) @@ -108,6 +108,13 @@ struct vmbus_chanpkt_rxbuf { struct vmbus_rxbuf_desc cp_rxbuf[]; } __packed; +struct vmbus_chan_br { + void *cbr; + bus_addr_t cbr_paddr; + int cbr_txsz; + int cbr_rxsz; +}; + struct vmbus_channel; struct hyperv_guid; @@ -122,6 +129,9 @@ vmbus_get_channel(device_t dev) int vmbus_chan_open(struct vmbus_channel *chan, int txbr_size, int rxbr_size, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); +int vmbus_chan_open_br(struct vmbus_channel *chan, + const struct vmbus_chan_br *cbr, const void *udata, + int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 02:08:04 2016 (r307594) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 02:14:04 2016 (r307595) @@ -136,6 +136,9 @@ struct hn_rx_ring { /* Rarely used stuffs */ struct sysctl_oid *hn_rx_sysctl_tree; int hn_rx_flags; + + void *hn_br; /* TX/RX bufring */ + struct hyperv_dma hn_br_dma; } __aligned(CACHE_LINE_SIZE); #define HN_TRUST_HCSUM_IP 0x0001 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 02:08:04 2016 (r307594) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 02:14:04 2016 (r307595) @@ -2358,7 +2358,8 @@ hn_create_rx_data(struct hn_softc *sc, i lroent_cnt = hn_lro_entry_count; if (lroent_cnt < TCP_LRO_ENTRIES) lroent_cnt = TCP_LRO_ENTRIES; - device_printf(dev, "LRO: entry count %d\n", lroent_cnt); + if (bootverbose) + device_printf(dev, "LRO: entry count %d\n", lroent_cnt); #endif #endif /* INET || INET6 */ @@ -2372,6 +2373,16 @@ hn_create_rx_data(struct hn_softc *sc, i for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; + rxr->hn_br = hyperv_dmamem_alloc(bus_get_dma_tag(dev), + PAGE_SIZE, 0, + NETVSC_DEVICE_RING_BUFFER_SIZE + + NETVSC_DEVICE_RING_BUFFER_SIZE, + &rxr->hn_br_dma, BUS_DMA_WAITOK); + if (rxr->hn_br == NULL) { + device_printf(dev, "allocate bufring failed\n"); + return (ENOMEM); + } + if (hn_trust_hosttcp) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_TCP; if (hn_trust_hostudp) @@ -2520,6 +2531,11 @@ hn_destroy_rx_data(struct hn_softc *sc) for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; + if (rxr->hn_br == NULL) + continue; + hyperv_dmamem_free(&rxr->hn_br_dma, rxr->hn_br); + rxr->hn_br = NULL; + #if defined(INET) || defined(INET6) tcp_lro_free(&rxr->hn_lro); #endif @@ -3125,6 +3141,7 @@ hn_xmit_txeof_taskfunc(void *xtxr, int p static int hn_chan_attach(struct hn_softc *sc, struct vmbus_channel *chan) { + struct vmbus_chan_br cbr; struct hn_rx_ring *rxr; struct hn_tx_ring *txr = NULL; int idx, error; @@ -3163,9 +3180,14 @@ hn_chan_attach(struct hn_softc *sc, stru /* Bind this channel to a proper CPU. */ vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); - /* Open this channel */ - error = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, - NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hn_chan_callback, rxr); + /* + * Open this channel + */ + cbr.cbr = rxr->hn_br; + cbr.cbr_paddr = rxr->hn_br_dma.hv_paddr; + cbr.cbr_txsz = NETVSC_DEVICE_RING_BUFFER_SIZE; + cbr.cbr_rxsz = NETVSC_DEVICE_RING_BUFFER_SIZE; + error = vmbus_chan_open_br(chan, &cbr, NULL, 0, hn_chan_callback, rxr); if (error) { if_printf(sc->hn_ifp, "open chan%u failed: %d\n", vmbus_chan_id(chan), error); @@ -3308,8 +3330,10 @@ hn_synth_alloc_subchans(struct hn_softc *nsubch = 0; return (0); } - if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", - rxr_cnt, nchan); + if (bootverbose) { + if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", + rxr_cnt, nchan); + } if (nchan > rxr_cnt) nchan = rxr_cnt; @@ -3318,7 +3342,7 @@ hn_synth_alloc_subchans(struct hn_softc *nsubch = 0; return (0); } - + /* * Allocate sub-channels from NVS. */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 02:08:04 2016 (r307594) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 02:14:04 2016 (r307595) @@ -196,13 +196,45 @@ int vmbus_chan_open(struct vmbus_channel *chan, int txbr_size, int rxbr_size, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) { + struct vmbus_chan_br cbr; + int error; + + /* + * Allocate the TX+RX bufrings. + */ + KASSERT(chan->ch_bufring == NULL, ("bufrings are allocated")); + chan->ch_bufring = hyperv_dmamem_alloc(bus_get_dma_tag(chan->ch_dev), + PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, + BUS_DMA_WAITOK); + if (chan->ch_bufring == NULL) { + device_printf(chan->ch_dev, "bufring allocation failed\n"); + return (ENOMEM); + } + + cbr.cbr = chan->ch_bufring; + cbr.cbr_paddr = chan->ch_bufring_dma.hv_paddr; + cbr.cbr_txsz = txbr_size; + cbr.cbr_rxsz = rxbr_size; + + error = vmbus_chan_open_br(chan, &cbr, udata, udlen, cb, cbarg); + if (error) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; + } + return (error); +} + +int +vmbus_chan_open_br(struct vmbus_channel *chan, const struct vmbus_chan_br *cbr, + const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) +{ struct vmbus_softc *sc = chan->ch_vmbus; const struct vmbus_chanmsg_chopen_resp *resp; const struct vmbus_message *msg; struct vmbus_chanmsg_chopen *req; struct vmbus_msghc *mh; uint32_t status; - int error; + int error, txbr_size, rxbr_size; uint8_t *br; if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { @@ -210,10 +242,21 @@ vmbus_chan_open(struct vmbus_channel *ch "invalid udata len %d for chan%u\n", udlen, chan->ch_id); return EINVAL; } + + br = cbr->cbr; + txbr_size = cbr->cbr_txsz; + rxbr_size = cbr->cbr_rxsz; KASSERT((txbr_size & PAGE_MASK) == 0, ("send bufring size is not multiple page")); KASSERT((rxbr_size & PAGE_MASK) == 0, ("recv bufring size is not multiple page")); + KASSERT((cbr->cbr_paddr & PAGE_MASK) == 0, + ("bufring is not page aligned")); + + /* + * Zero out the TX/RX bufrings, in case that they were used before. + */ + memset(br, 0, txbr_size + rxbr_size); if (atomic_testandset_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED_SHIFT)) @@ -230,20 +273,6 @@ vmbus_chan_open(struct vmbus_channel *ch else TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); - /* - * Allocate the TX+RX bufrings. - * XXX should use ch_dev dtag - */ - br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), - PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, - BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (br == NULL) { - device_printf(sc->vmbus_dev, "bufring allocation failed\n"); - error = ENOMEM; - goto failed; - } - chan->ch_bufring = br; - /* TX bufring comes first */ vmbus_txbr_setup(&chan->ch_txbr, br, txbr_size); /* RX bufring immediately follows TX bufring */ @@ -255,7 +284,7 @@ vmbus_chan_open(struct vmbus_channel *ch /* * Connect the bufrings, both RX and TX, to this channel. */ - error = vmbus_chan_gpadl_connect(chan, chan->ch_bufring_dma.hv_paddr, + error = vmbus_chan_gpadl_connect(chan, cbr->cbr_paddr, txbr_size + rxbr_size, &chan->ch_bufring_gpadl); if (error) { device_printf(sc->vmbus_dev, @@ -316,10 +345,6 @@ failed: vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); chan->ch_bufring_gpadl = 0; } - if (chan->ch_bufring != NULL) { - hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); - chan->ch_bufring = NULL; - } atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); return error; } From owner-svn-src-stable@freebsd.org Wed Oct 19 02:15:42 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4574C17AEA; Wed, 19 Oct 2016 02:15:42 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B40D2E37; Wed, 19 Oct 2016 02:15:42 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J2Ffwh001289; Wed, 19 Oct 2016 02:15:41 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J2Ff2t001288; Wed, 19 Oct 2016 02:15:41 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610190215.u9J2Ff2t001288@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 19 Oct 2016 02:15:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307596 - stable/11/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 02:15:43 -0000 Author: gonzo Date: Wed Oct 19 02:15:41 2016 New Revision: 307596 URL: https://svnweb.freebsd.org/changeset/base/307596 Log: MFC r306557, r307240, r307241: r306557: Use VM_MEMATTR_WRITE_COMBINING memattr for mmap(2) on framebuffer VM_MEMATTR_WRITE_COMBINING sets write-through cache flag for framebuffer memory that prevents pixel data from being stuck in cache until evicition happens r307240: Fix BCM238x framebuffer driver build for ARM64 VM_MEMATTR_WRITE_COMBINING can be undefined for some platforms, use it only if it's defined r307241: Do not set FB_FLAG_MEMATTR if VM_MEMATTR_WRITE_COMBINING is not available Pintyhat to: gonzo Spotted by: jmallett Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Wed Oct 19 02:14:04 2016 (r307595) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Wed Oct 19 02:15:41 2016 (r307596) @@ -119,6 +119,10 @@ bcm_fb_setup_fbd(struct bcmsc_softc *sc) sc->info.fb_stride = fb.pitch; sc->info.fb_width = fb.xres; sc->info.fb_height = fb.yres; +#ifdef VM_MEMATTR_WRITE_COMBINING + sc->info.fb_flags = FB_FLAG_MEMATTR; + sc->info.fb_memattr = VM_MEMATTR_WRITE_COMBINING; +#endif if (sc->fbswap) { switch (sc->info.fb_bpp) { From owner-svn-src-stable@freebsd.org Wed Oct 19 02:20:49 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2E48C17D3D; Wed, 19 Oct 2016 02:20:49 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B199D114; Wed, 19 Oct 2016 02:20:49 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J2KmPf001546; Wed, 19 Oct 2016 02:20:48 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J2KmZ0001545; Wed, 19 Oct 2016 02:20:48 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190220.u9J2KmZ0001545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 02:20:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307597 - stable/11/sys/dev/pci X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 02:20:50 -0000 Author: sephe Date: Wed Oct 19 02:20:48 2016 New Revision: 307597 URL: https://svnweb.freebsd.org/changeset/base/307597 Log: MFC 306359 pci: Clear the MEM/PORT_EN bit when updating PCI BAR It's unsafe to update the BAR when the related EN bit is set. Submitted by: Dexuan Cui Reviewed by: jhb Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7914 Modified: stable/11/sys/dev/pci/pci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/pci/pci.c ============================================================================== --- stable/11/sys/dev/pci/pci.c Wed Oct 19 02:15:41 2016 (r307596) +++ stable/11/sys/dev/pci/pci.c Wed Oct 19 02:20:48 2016 (r307597) @@ -4999,6 +4999,7 @@ pci_reserve_map(device_t dev, device_t c struct resource_list *rl = &dinfo->resources; struct resource *res; struct pci_map *pm; + uint16_t cmd; pci_addr_t map, testval; int mapsize; @@ -5088,8 +5089,17 @@ pci_reserve_map(device_t dev, device_t c device_printf(child, "Lazy allocation of %#jx bytes rid %#x type %d at %#jx\n", count, *rid, type, rman_get_start(res)); + + /* Disable decoding via the CMD register before updating the BAR */ + cmd = pci_read_config(child, PCIR_COMMAND, 2); + pci_write_config(child, PCIR_COMMAND, + cmd & ~(PCI_BAR_MEM(map) ? PCIM_CMD_MEMEN : PCIM_CMD_PORTEN), 2); + map = rman_get_start(res); pci_write_bar(child, pm, map); + + /* Restore the original value of the CMD register */ + pci_write_config(child, PCIR_COMMAND, cmd, 2); out: return (res); } From owner-svn-src-stable@freebsd.org Wed Oct 19 02:24:19 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 300BFC17F8F; Wed, 19 Oct 2016 02:24:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C06568A6; Wed, 19 Oct 2016 02:24:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J2OHEk005085; Wed, 19 Oct 2016 02:24:17 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J2OHhn005079; Wed, 19 Oct 2016 02:24:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190224.u9J2OHhn005079@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 02:24:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307599 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 02:24:19 -0000 Author: sephe Date: Wed Oct 19 02:24:17 2016 New Revision: 307599 URL: https://svnweb.freebsd.org/changeset/base/307599 Log: MFC 306360,306387,306389 306360 hyperv/vmbus: Add dynamic device add and remove support Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8008 306387 hyperv/vmbus: Add functions to test RX/TX bufring emptiness Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8044 306389 hyperv/vmbus: Add function to drain channel interrupt task. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8045 Modified: stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Wed Oct 19 02:23:29 2016 (r307598) +++ stable/11/sys/dev/hyperv/include/vmbus.h Wed Oct 19 02:24:17 2016 (r307599) @@ -133,6 +133,7 @@ int vmbus_chan_open_br(struct vmbus_cha const struct vmbus_chan_br *cbr, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); +void vmbus_chan_intr_drain(struct vmbus_channel *chan); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); @@ -173,5 +174,7 @@ const struct hyperv_guid * vmbus_chan_guid_inst(const struct vmbus_channel *chan); int vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, int dlen_max); +bool vmbus_chan_rx_empty(const struct vmbus_channel *chan); +bool vmbus_chan_tx_empty(const struct vmbus_channel *chan); #endif /* !_VMBUS_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Wed Oct 19 02:23:29 2016 (r307598) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Wed Oct 19 02:24:17 2016 (r307599) @@ -83,9 +83,7 @@ static int vmbus_connect(struct vmbus_ static int vmbus_req_channels(struct vmbus_softc *sc); static void vmbus_disconnect(struct vmbus_softc *); static int vmbus_scan(struct vmbus_softc *); -static void vmbus_scan_wait(struct vmbus_softc *); -static void vmbus_scan_newchan(struct vmbus_softc *); -static void vmbus_scan_newdev(struct vmbus_softc *); +static void vmbus_scan_teardown(struct vmbus_softc *); static void vmbus_scan_done(struct vmbus_softc *, const struct vmbus_message *); static void vmbus_chanmsg_handle(struct vmbus_softc *, @@ -393,50 +391,22 @@ vmbus_req_channels(struct vmbus_softc *s } static void -vmbus_scan_newchan(struct vmbus_softc *sc) +vmbus_scan_done_task(void *xsc, int pending __unused) { - mtx_lock(&sc->vmbus_scan_lock); - if ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) - sc->vmbus_scan_chcnt++; - mtx_unlock(&sc->vmbus_scan_lock); + struct vmbus_softc *sc = xsc; + + mtx_lock(&Giant); + sc->vmbus_scandone = true; + mtx_unlock(&Giant); + wakeup(&sc->vmbus_scandone); } static void vmbus_scan_done(struct vmbus_softc *sc, const struct vmbus_message *msg __unused) { - mtx_lock(&sc->vmbus_scan_lock); - sc->vmbus_scan_chcnt |= VMBUS_SCAN_CHCNT_DONE; - mtx_unlock(&sc->vmbus_scan_lock); - wakeup(&sc->vmbus_scan_chcnt); -} - -static void -vmbus_scan_newdev(struct vmbus_softc *sc) -{ - mtx_lock(&sc->vmbus_scan_lock); - sc->vmbus_scan_devcnt++; - mtx_unlock(&sc->vmbus_scan_lock); - wakeup(&sc->vmbus_scan_devcnt); -} - -static void -vmbus_scan_wait(struct vmbus_softc *sc) -{ - uint32_t chancnt; - - mtx_lock(&sc->vmbus_scan_lock); - while ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) { - mtx_sleep(&sc->vmbus_scan_chcnt, &sc->vmbus_scan_lock, 0, - "waitch", 0); - } - chancnt = sc->vmbus_scan_chcnt & ~VMBUS_SCAN_CHCNT_DONE; - while (sc->vmbus_scan_devcnt != chancnt) { - mtx_sleep(&sc->vmbus_scan_devcnt, &sc->vmbus_scan_lock, 0, - "waitdev", 0); - } - mtx_unlock(&sc->vmbus_scan_lock); + taskqueue_enqueue(sc->vmbus_devtq, &sc->vmbus_scandone_task); } static int @@ -445,31 +415,71 @@ vmbus_scan(struct vmbus_softc *sc) int error; /* + * Identify, probe and attach for non-channel devices. + */ + bus_generic_probe(sc->vmbus_dev); + bus_generic_attach(sc->vmbus_dev); + + /* + * This taskqueue serializes vmbus devices' attach and detach + * for channel offer and rescind messages. + */ + sc->vmbus_devtq = taskqueue_create("vmbus dev", M_WAITOK, + taskqueue_thread_enqueue, &sc->vmbus_devtq); + taskqueue_start_threads(&sc->vmbus_devtq, 1, PI_NET, "vmbusdev"); + TASK_INIT(&sc->vmbus_scandone_task, 0, vmbus_scan_done_task, sc); + + /* + * This taskqueue handles sub-channel detach, so that vmbus + * device's detach running in vmbus_devtq can drain its sub- + * channels. + */ + sc->vmbus_subchtq = taskqueue_create("vmbus subch", M_WAITOK, + taskqueue_thread_enqueue, &sc->vmbus_subchtq); + taskqueue_start_threads(&sc->vmbus_subchtq, 1, PI_NET, "vmbussch"); + + /* * Start vmbus scanning. */ error = vmbus_req_channels(sc); if (error) { device_printf(sc->vmbus_dev, "channel request failed: %d\n", error); - return error; + return (error); } /* - * Wait for all devices are added to vmbus. + * Wait for all vmbus devices from the initial channel offers to be + * attached. */ - vmbus_scan_wait(sc); - - /* - * Identify, probe and attach. - */ - bus_generic_probe(sc->vmbus_dev); - bus_generic_attach(sc->vmbus_dev); + GIANT_REQUIRED; + while (!sc->vmbus_scandone) + mtx_sleep(&sc->vmbus_scandone, &Giant, 0, "vmbusdev", 0); if (bootverbose) { device_printf(sc->vmbus_dev, "device scan, probe and attach " "done\n"); } - return 0; + return (0); +} + +static void +vmbus_scan_teardown(struct vmbus_softc *sc) +{ + + GIANT_REQUIRED; + if (sc->vmbus_devtq != NULL) { + mtx_unlock(&Giant); + taskqueue_free(sc->vmbus_devtq); + mtx_lock(&Giant); + sc->vmbus_devtq = NULL; + } + if (sc->vmbus_subchtq != NULL) { + mtx_unlock(&Giant); + taskqueue_free(sc->vmbus_subchtq); + mtx_lock(&Giant); + sc->vmbus_subchtq = NULL; + } } static void @@ -918,45 +928,35 @@ vmbus_add_child(struct vmbus_channel *ch { struct vmbus_softc *sc = chan->ch_vmbus; device_t parent = sc->vmbus_dev; - int error = 0; - /* New channel has been offered */ - vmbus_scan_newchan(sc); + mtx_lock(&Giant); chan->ch_dev = device_add_child(parent, NULL, -1); if (chan->ch_dev == NULL) { + mtx_unlock(&Giant); device_printf(parent, "device_add_child for chan%u failed\n", chan->ch_id); - error = ENXIO; - goto done; + return (ENXIO); } device_set_ivars(chan->ch_dev, chan); + device_probe_and_attach(chan->ch_dev); -done: - /* New device has been/should be added to vmbus. */ - vmbus_scan_newdev(sc); - return error; + mtx_unlock(&Giant); + return (0); } int vmbus_delete_child(struct vmbus_channel *chan) { - int error; - - if (chan->ch_dev == NULL) { - /* Failed to add a device. */ - return 0; - } + int error = 0; - /* - * XXXKYS: Ensure that this is the opposite of - * device_add_child() - */ mtx_lock(&Giant); - error = device_delete_child(chan->ch_vmbus->vmbus_dev, chan->ch_dev); + if (chan->ch_dev != NULL) { + error = device_delete_child(chan->ch_vmbus->vmbus_dev, + chan->ch_dev); + } mtx_unlock(&Giant); - - return error; + return (error); } static int @@ -1028,10 +1028,11 @@ vmbus_doattach(struct vmbus_softc *sc) return (0); sc->vmbus_flags |= VMBUS_FLAG_ATTACHED; - mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF); sc->vmbus_gpadl = VMBUS_GPADL_START; mtx_init(&sc->vmbus_prichan_lock, "vmbus prichan", NULL, MTX_DEF); TAILQ_INIT(&sc->vmbus_prichans); + mtx_init(&sc->vmbus_chan_lock, "vmbus channel", NULL, MTX_DEF); + TAILQ_INIT(&sc->vmbus_chans); sc->vmbus_chmap = malloc( sizeof(struct vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); @@ -1095,6 +1096,7 @@ vmbus_doattach(struct vmbus_softc *sc) return (ret); cleanup: + vmbus_scan_teardown(sc); vmbus_intr_teardown(sc); vmbus_dma_free(sc); if (sc->vmbus_xc != NULL) { @@ -1102,8 +1104,8 @@ cleanup: sc->vmbus_xc = NULL; } free(sc->vmbus_chmap, M_DEVBUF); - mtx_destroy(&sc->vmbus_scan_lock); mtx_destroy(&sc->vmbus_prichan_lock); + mtx_destroy(&sc->vmbus_chan_lock); return (ret); } @@ -1146,8 +1148,11 @@ vmbus_detach(device_t dev) { struct vmbus_softc *sc = device_get_softc(dev); + bus_generic_detach(dev); vmbus_chan_destroy_all(sc); + vmbus_scan_teardown(sc); + vmbus_disconnect(sc); if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) { @@ -1164,8 +1169,8 @@ vmbus_detach(device_t dev) } free(sc->vmbus_chmap, M_DEVBUF); - mtx_destroy(&sc->vmbus_scan_lock); mtx_destroy(&sc->vmbus_prichan_lock); + mtx_destroy(&sc->vmbus_chan_lock); return (0); } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Oct 19 02:23:29 2016 (r307598) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Oct 19 02:24:17 2016 (r307599) @@ -83,6 +83,20 @@ vmbus_txbr_maxpktsz(const struct vmbus_t return (tbr->txbr_dsize - sizeof(uint64_t) - 1); } +static __inline bool +vmbus_txbr_empty(const struct vmbus_txbr *tbr) +{ + + return (tbr->txbr_windex == tbr->txbr_rindex ? true : false); +} + +static __inline bool +vmbus_rxbr_empty(const struct vmbus_rxbr *rbr) +{ + + return (rbr->rxbr_windex == rbr->rxbr_rindex ? true : false); +} + static __inline int vmbus_br_nelem(int br_size, int elem_size) { Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 02:23:29 2016 (r307598) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 02:24:17 2016 (r307599) @@ -59,10 +59,30 @@ static struct vmbus_channel *vmbus_chan_ static void vmbus_chan_free(struct vmbus_channel *); static int vmbus_chan_add(struct vmbus_channel *); static void vmbus_chan_cpu_default(struct vmbus_channel *); +static int vmbus_chan_release(struct vmbus_channel *); +static void vmbus_chan_set_chmap(struct vmbus_channel *); +static void vmbus_chan_clear_chmap(struct vmbus_channel *); + +static void vmbus_chan_ins_prilist(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_rem_prilist(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_ins_list(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_rem_list(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_ins_sublist(struct vmbus_channel *, + struct vmbus_channel *); +static void vmbus_chan_rem_sublist(struct vmbus_channel *, + struct vmbus_channel *); static void vmbus_chan_task(void *, int); static void vmbus_chan_task_nobatch(void *, int); -static void vmbus_chan_detach_task(void *, int); +static void vmbus_chan_clrchmap_task(void *, int); +static void vmbus_prichan_attach_task(void *, int); +static void vmbus_subchan_attach_task(void *, int); +static void vmbus_prichan_detach_task(void *, int); +static void vmbus_subchan_detach_task(void *, int); static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, const struct vmbus_message *); @@ -96,6 +116,83 @@ vmbus_chan_signal_tx(const struct vmbus_ hypercall_signal_event(chan->ch_monprm_dma.hv_paddr); } +static void +vmbus_chan_ins_prilist(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_prichan_lock, MA_OWNED); + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONPRIL_SHIFT)) + panic("channel is already on the prilist"); + TAILQ_INSERT_TAIL(&sc->vmbus_prichans, chan, ch_prilink); +} + +static void +vmbus_chan_rem_prilist(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_prichan_lock, MA_OWNED); + if (atomic_testandclear_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONPRIL_SHIFT) == 0) + panic("channel is not on the prilist"); + TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); +} + +static void +vmbus_chan_ins_sublist(struct vmbus_channel *prichan, + struct vmbus_channel *chan) +{ + + mtx_assert(&prichan->ch_subchan_lock, MA_OWNED); + + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONSUBL_SHIFT)) + panic("channel is already on the sublist"); + TAILQ_INSERT_TAIL(&prichan->ch_subchans, chan, ch_sublink); + + /* Bump sub-channel count. */ + prichan->ch_subchan_cnt++; +} + +static void +vmbus_chan_rem_sublist(struct vmbus_channel *prichan, + struct vmbus_channel *chan) +{ + + mtx_assert(&prichan->ch_subchan_lock, MA_OWNED); + + KASSERT(prichan->ch_subchan_cnt > 0, + ("invalid subchan_cnt %d", prichan->ch_subchan_cnt)); + prichan->ch_subchan_cnt--; + + if (atomic_testandclear_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONSUBL_SHIFT) == 0) + panic("channel is not on the sublist"); + TAILQ_REMOVE(&prichan->ch_subchans, chan, ch_sublink); +} + +static void +vmbus_chan_ins_list(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_chan_lock, MA_OWNED); + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONLIST_SHIFT)) + panic("channel is already on the list"); + TAILQ_INSERT_TAIL(&sc->vmbus_chans, chan, ch_link); +} + +static void +vmbus_chan_rem_list(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_chan_lock, MA_OWNED); + if (atomic_testandclear_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONLIST_SHIFT) == 0) + panic("channel is not on the list"); + TAILQ_REMOVE(&sc->vmbus_chans, chan, ch_link); +} + static int vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS) { @@ -235,6 +332,7 @@ vmbus_chan_open_br(struct vmbus_channel struct vmbus_msghc *mh; uint32_t status; int error, txbr_size, rxbr_size; + task_fn_t *task_fn; uint8_t *br; if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { @@ -269,9 +367,10 @@ vmbus_chan_open_br(struct vmbus_channel chan->ch_tq = VMBUS_PCPU_GET(chan->ch_vmbus, event_tq, chan->ch_cpuid); if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - TASK_INIT(&chan->ch_task, 0, vmbus_chan_task, chan); + task_fn = vmbus_chan_task; else - TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); + task_fn = vmbus_chan_task_nobatch; + TASK_INIT(&chan->ch_task, 0, task_fn, chan); /* TX bufring comes first */ vmbus_txbr_setup(&chan->ch_txbr, br, txbr_size); @@ -293,6 +392,12 @@ vmbus_chan_open_br(struct vmbus_channel } /* + * Install this channel, before it is opened, but after everything + * else has been setup. + */ + vmbus_chan_set_chmap(chan); + + /* * Open channel w/ the bufring GPADL on the target CPU. */ mh = vmbus_msghc_get(sc, sizeof(*req)); @@ -341,6 +446,7 @@ vmbus_chan_open_br(struct vmbus_channel error = ENXIO; failed: + vmbus_chan_clear_chmap(chan); if (chan->ch_bufring_gpadl) { vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); chan->ch_bufring_gpadl = 0; @@ -517,12 +623,38 @@ vmbus_chan_gpadl_disconnect(struct vmbus } static void +vmbus_chan_clrchmap_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + + critical_enter(); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = NULL; + critical_exit(); +} + +static void +vmbus_chan_clear_chmap(struct vmbus_channel *chan) +{ + struct task chmap_task; + + TASK_INIT(&chmap_task, 0, vmbus_chan_clrchmap_task, chan); + taskqueue_enqueue(chan->ch_tq, &chmap_task); + taskqueue_drain(chan->ch_tq, &chmap_task); +} + +static void +vmbus_chan_set_chmap(struct vmbus_channel *chan) +{ + __compiler_membar(); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan; +} + +static void vmbus_chan_close_internal(struct vmbus_channel *chan) { struct vmbus_softc *sc = chan->ch_vmbus; struct vmbus_msghc *mh; struct vmbus_chanmsg_chclose *req; - struct taskqueue *tq = chan->ch_tq; int error; /* TODO: stringent check */ @@ -535,12 +667,14 @@ vmbus_chan_close_internal(struct vmbus_c sysctl_ctx_free(&chan->ch_sysctl_ctx); /* - * Set ch_tq to NULL to avoid more requests be scheduled. - * XXX pretty broken; need rework. + * NOTE: + * Order is critical. This channel _must_ be uninstalled first, + * else the channel task may be enqueued by the IDT after it has + * been drained. */ + vmbus_chan_clear_chmap(chan); + taskqueue_drain(chan->ch_tq, &chan->ch_task); chan->ch_tq = NULL; - taskqueue_drain(tq, &chan->ch_task); - chan->ch_cb = NULL; /* * Close this channel. @@ -622,6 +756,13 @@ vmbus_chan_close(struct vmbus_channel *c vmbus_chan_close_internal(chan); } +void +vmbus_chan_intr_drain(struct vmbus_channel *chan) +{ + + taskqueue_drain(chan->ch_tq, &chan->ch_task); +} + int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, uint16_t flags, void *data, int dlen, uint64_t xactid) @@ -884,10 +1025,11 @@ vmbus_event_flags_proc(struct vmbus_soft flags &= ~(1UL << chid_ofs); chan = sc->vmbus_chmap[chid_base + chid_ofs]; - - /* if channel is closed or closing */ - if (chan == NULL || chan->ch_tq == NULL) + if (__predict_false(chan == NULL)) { + /* Channel is closed. */ continue; + } + __compiler_membar(); if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) vmbus_rxbr_intr_mask(&chan->ch_rxbr); @@ -968,7 +1110,6 @@ vmbus_chan_alloc(struct vmbus_softc *sc) chan->ch_vmbus = sc; mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); TAILQ_INIT(&chan->ch_subchans); - TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); vmbus_rxbr_init(&chan->ch_rxbr); vmbus_txbr_init(&chan->ch_txbr); @@ -978,9 +1119,14 @@ vmbus_chan_alloc(struct vmbus_softc *sc) static void vmbus_chan_free(struct vmbus_channel *chan) { - /* TODO: assert sub-channel list is empty */ - /* TODO: asset no longer on the primary channel's sub-channel list */ - /* TODO: asset no longer on the vmbus channel list */ + + KASSERT(TAILQ_EMPTY(&chan->ch_subchans) && chan->ch_subchan_cnt == 0, + ("still owns sub-channels")); + KASSERT((chan->ch_stflags & + (VMBUS_CHAN_ST_OPENED | + VMBUS_CHAN_ST_ONPRIL | + VMBUS_CHAN_ST_ONSUBL | + VMBUS_CHAN_ST_ONLIST)) == 0, ("free busy channel")); hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); vmbus_rxbr_deinit(&chan->ch_rxbr); @@ -1007,7 +1153,6 @@ vmbus_chan_add(struct vmbus_channel *new newchan->ch_id); return EINVAL; } - sc->vmbus_chmap[newchan->ch_id] = newchan; if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u subidx%u offer\n", @@ -1029,10 +1174,9 @@ vmbus_chan_add(struct vmbus_channel *new if (VMBUS_CHAN_ISPRIMARY(newchan)) { if (prichan == NULL) { /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&sc->vmbus_prichans, newchan, - ch_prilink); + vmbus_chan_ins_prilist(sc, newchan); mtx_unlock(&sc->vmbus_prichan_lock); - return 0; + goto done; } else { mtx_unlock(&sc->vmbus_prichan_lock); device_printf(sc->vmbus_dev, "duplicated primary " @@ -1066,16 +1210,20 @@ vmbus_chan_add(struct vmbus_channel *new newchan->ch_dev = prichan->ch_dev; mtx_lock(&prichan->ch_subchan_lock); - TAILQ_INSERT_TAIL(&prichan->ch_subchans, newchan, ch_sublink); + vmbus_chan_ins_sublist(prichan, newchan); + mtx_unlock(&prichan->ch_subchan_lock); /* - * Bump up sub-channel count and notify anyone that is - * interested in this sub-channel, after this sub-channel - * is setup. + * Notify anyone that is interested in this sub-channel, + * after this sub-channel is setup. */ - prichan->ch_subchan_cnt++; - mtx_unlock(&prichan->ch_subchan_lock); wakeup(prichan); - +done: + /* + * Hook this channel up for later rescind. + */ + mtx_lock(&sc->vmbus_chan_lock); + vmbus_chan_ins_list(sc, newchan); + mtx_unlock(&sc->vmbus_chan_lock); return 0; } @@ -1126,6 +1274,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_ { const struct vmbus_chanmsg_choffer *offer; struct vmbus_channel *chan; + task_fn_t *detach_fn, *attach_fn; int error; offer = (const struct vmbus_chanmsg_choffer *)msg->msg_data; @@ -1174,6 +1323,21 @@ vmbus_chan_msgproc_choffer(struct vmbus_ &sc->vmbus_tx_evtflags[chan->ch_id >> VMBUS_EVTFLAG_SHIFT]; chan->ch_evtflag_mask = 1UL << (chan->ch_id & VMBUS_EVTFLAG_MASK); + /* + * Setup attach and detach tasks. + */ + if (VMBUS_CHAN_ISPRIMARY(chan)) { + chan->ch_mgmt_tq = sc->vmbus_devtq; + attach_fn = vmbus_prichan_attach_task; + detach_fn = vmbus_prichan_detach_task; + } else { + chan->ch_mgmt_tq = sc->vmbus_subchtq; + attach_fn = vmbus_subchan_attach_task; + detach_fn = vmbus_subchan_detach_task; + } + TASK_INIT(&chan->ch_attach_task, 0, attach_fn, chan); + TASK_INIT(&chan->ch_detach_task, 0, detach_fn, chan); + /* Select default cpu for this channel. */ vmbus_chan_cpu_default(chan); @@ -1184,22 +1348,9 @@ vmbus_chan_msgproc_choffer(struct vmbus_ vmbus_chan_free(chan); return; } - - if (VMBUS_CHAN_ISPRIMARY(chan)) { - /* - * Add device for this primary channel. - * - * NOTE: - * Error is ignored here; don't have much to do if error - * really happens. - */ - vmbus_add_child(chan); - } + taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_attach_task); } -/* - * XXX pretty broken; need rework. - */ static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc, const struct vmbus_message *msg) @@ -1219,91 +1370,162 @@ vmbus_chan_msgproc_chrescind(struct vmbu note->chm_chanid); } - chan = sc->vmbus_chmap[note->chm_chanid]; - if (chan == NULL) + /* + * Find and remove the target channel from the channel list. + */ + mtx_lock(&sc->vmbus_chan_lock); + TAILQ_FOREACH(chan, &sc->vmbus_chans, ch_link) { + if (chan->ch_id == note->chm_chanid) + break; + } + if (chan == NULL) { + mtx_unlock(&sc->vmbus_chan_lock); + device_printf(sc->vmbus_dev, "chan%u is not offered\n", + note->chm_chanid); return; - sc->vmbus_chmap[note->chm_chanid] = NULL; + } + vmbus_chan_rem_list(sc, chan); + mtx_unlock(&sc->vmbus_chan_lock); + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * The target channel is a primary channel; remove the + * target channel from the primary channel list now, + * instead of later, so that it will not be found by + * other sub-channel offers, which are processed in + * this thread. + */ + mtx_lock(&sc->vmbus_prichan_lock); + vmbus_chan_rem_prilist(sc, chan); + mtx_unlock(&sc->vmbus_prichan_lock); + } - taskqueue_enqueue(taskqueue_thread, &chan->ch_detach_task); + /* Detach the target channel. */ + taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_detach_task); } -static void -vmbus_chan_detach_task(void *xchan, int pending __unused) +static int +vmbus_chan_release(struct vmbus_channel *chan) { - struct vmbus_channel *chan = xchan; + struct vmbus_softc *sc = chan->ch_vmbus; + struct vmbus_chanmsg_chfree *req; + struct vmbus_msghc *mh; + int error; - if (VMBUS_CHAN_ISPRIMARY(chan)) { - /* Only primary channel owns the device */ - vmbus_delete_child(chan); - /* NOTE: DO NOT free primary channel for now */ + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, "can not get msg hypercall for " + "chfree(chan%u)\n", chan->ch_id); + return (ENXIO); + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; + req->chm_chanid = chan->ch_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, "chfree(chan%u) failed: %d", + chan->ch_id, error); } else { - struct vmbus_softc *sc = chan->ch_vmbus; - struct vmbus_channel *pri_chan = chan->ch_prichan; - struct vmbus_chanmsg_chfree *req; - struct vmbus_msghc *mh; - int error; - - mh = vmbus_msghc_get(sc, sizeof(*req)); - if (mh == NULL) { - device_printf(sc->vmbus_dev, - "can not get msg hypercall for chfree(chan%u)\n", + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u freed\n", chan->ch_id); - goto remove; } + } + return (error); +} - req = vmbus_msghc_dataptr(mh); - req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; - req->chm_chanid = chan->ch_id; +static void +vmbus_prichan_detach_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; - error = vmbus_msghc_exec_noresult(mh); - vmbus_msghc_put(sc, mh); + KASSERT(VMBUS_CHAN_ISPRIMARY(chan), + ("chan%u is not primary channel", chan->ch_id)); - if (error) { - device_printf(sc->vmbus_dev, - "chfree(chan%u) failed: %d", - chan->ch_id, error); - /* NOTE: Move on! */ - } else { - if (bootverbose) { - device_printf(sc->vmbus_dev, "chan%u freed\n", - chan->ch_id); - } - } -remove: - mtx_lock(&pri_chan->ch_subchan_lock); - TAILQ_REMOVE(&pri_chan->ch_subchans, chan, ch_sublink); - KASSERT(pri_chan->ch_subchan_cnt > 0, - ("invalid subchan_cnt %d", pri_chan->ch_subchan_cnt)); - pri_chan->ch_subchan_cnt--; - mtx_unlock(&pri_chan->ch_subchan_lock); - wakeup(pri_chan); + /* Delete and detach the device associated with this channel. */ + vmbus_delete_child(chan); - vmbus_chan_free(chan); - } + /* Release this channel (back to vmbus). */ + vmbus_chan_release(chan); + + /* Free this channel's resource. */ + vmbus_chan_free(chan); +} + +static void +vmbus_subchan_detach_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + struct vmbus_channel *pri_chan = chan->ch_prichan; + + KASSERT(!VMBUS_CHAN_ISPRIMARY(chan), + ("chan%u is primary channel", chan->ch_id)); + + /* Release this channel (back to vmbus). */ + vmbus_chan_release(chan); + + /* Unlink from its primary channel's sub-channel list. */ + mtx_lock(&pri_chan->ch_subchan_lock); + vmbus_chan_rem_sublist(pri_chan, chan); + mtx_unlock(&pri_chan->ch_subchan_lock); + /* Notify anyone that is waiting for this sub-channel to vanish. */ + wakeup(pri_chan); + + /* Free this channel's resource. */ + vmbus_chan_free(chan); +} + +static void +vmbus_prichan_attach_task(void *xchan, int pending __unused) +{ + + /* + * Add device for this primary channel. + */ + vmbus_add_child(xchan); +} + +static void +vmbus_subchan_attach_task(void *xchan __unused, int pending __unused) +{ + + /* Nothing */ } -/* - * Detach all devices and destroy the corresponding primary channels. - */ void vmbus_chan_destroy_all(struct vmbus_softc *sc) { - struct vmbus_channel *chan; - mtx_lock(&sc->vmbus_prichan_lock); - while ((chan = TAILQ_FIRST(&sc->vmbus_prichans)) != NULL) { - KASSERT(VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel")); - TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); - mtx_unlock(&sc->vmbus_prichan_lock); + /* + * Detach all devices and destroy the corresponding primary + * channels. + */ + for (;;) { + struct vmbus_channel *chan; - vmbus_delete_child(chan); - vmbus_chan_free(chan); + mtx_lock(&sc->vmbus_chan_lock); + TAILQ_FOREACH(chan, &sc->vmbus_chans, ch_link) { + if (VMBUS_CHAN_ISPRIMARY(chan)) + break; + } + if (chan == NULL) { + /* No more primary channels; done. */ + mtx_unlock(&sc->vmbus_chan_lock); + break; + } + vmbus_chan_rem_list(sc, chan); + mtx_unlock(&sc->vmbus_chan_lock); mtx_lock(&sc->vmbus_prichan_lock); + vmbus_chan_rem_prilist(sc, chan); + mtx_unlock(&sc->vmbus_prichan_lock); + + taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_detach_task); } - bzero(sc->vmbus_chmap, - sizeof(struct vmbus_channel *) * VMBUS_CHAN_MAX); - mtx_unlock(&sc->vmbus_prichan_lock); } /* @@ -1477,3 +1699,17 @@ vmbus_chan_prplist_nelem(int br_size, in return (vmbus_br_nelem(br_size, elem_size)); } + +bool +vmbus_chan_tx_empty(const struct vmbus_channel *chan) +{ + + return (vmbus_txbr_empty(&chan->ch_txbr)); +} + +bool +vmbus_chan_rx_empty(const struct vmbus_channel *chan) +{ + + return (vmbus_rxbr_empty(&chan->ch_rxbr)); +} Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 19 02:23:29 2016 (r307598) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 19 02:24:17 2016 (r307599) @@ -124,8 +124,14 @@ struct vmbus_channel { struct hyperv_dma ch_bufring_dma; uint32_t ch_bufring_gpadl; - struct task ch_detach_task; + struct task ch_attach_task; /* run in ch_mgmt_tq */ + struct task ch_detach_task; /* run in ch_mgmt_tq */ + struct taskqueue *ch_mgmt_tq; + + /* If this is a primary channel */ TAILQ_ENTRY(vmbus_channel) ch_prilink; /* primary chan link */ + + TAILQ_ENTRY(vmbus_channel) ch_link; /* channel link */ uint32_t ch_subidx; /* subchan index */ volatile uint32_t ch_stflags; /* atomic-op */ /* VMBUS_CHAN_ST_ */ @@ -150,7 +156,13 @@ struct vmbus_channel { #define VMBUS_CHAN_TXF_HASMNF 0x0001 #define VMBUS_CHAN_ST_OPENED_SHIFT 0 +#define VMBUS_CHAN_ST_ONPRIL_SHIFT 1 +#define VMBUS_CHAN_ST_ONSUBL_SHIFT 2 +#define VMBUS_CHAN_ST_ONLIST_SHIFT 3 #define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) +#define VMBUS_CHAN_ST_ONPRIL (1 << VMBUS_CHAN_ST_ONPRIL_SHIFT) +#define VMBUS_CHAN_ST_ONSUBL (1 << VMBUS_CHAN_ST_ONSUBL_SHIFT) +#define VMBUS_CHAN_ST_ONLIST (1 << VMBUS_CHAN_ST_ONLIST_SHIFT) struct vmbus_softc; struct vmbus_message; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Wed Oct 19 02:23:29 2016 (r307598) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Wed Oct 19 02:24:17 2016 (r307599) @@ -107,14 +107,19 @@ struct vmbus_softc { struct hyperv_dma vmbus_mnf1_dma; struct hyperv_dma vmbus_mnf2_dma; - struct mtx vmbus_scan_lock; - uint32_t vmbus_scan_chcnt; -#define VMBUS_SCAN_CHCNT_DONE 0x80000000 - uint32_t vmbus_scan_devcnt; + bool vmbus_scandone; + struct task vmbus_scandone_task; + + struct taskqueue *vmbus_devtq; /* for dev attach/detach */ + struct taskqueue *vmbus_subchtq; /* for sub-chan attach/detach */ /* Primary channels */ struct mtx vmbus_prichan_lock; TAILQ_HEAD(, vmbus_channel) vmbus_prichans; + + /* Complete channel list */ + struct mtx vmbus_chan_lock; + TAILQ_HEAD(, vmbus_channel) vmbus_chans; }; #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ From owner-svn-src-stable@freebsd.org Wed Oct 19 02:39:26 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CEE9C1827A; Wed, 19 Oct 2016 02:39:26 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B6D5FFC7; Wed, 19 Oct 2016 02:39:25 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J2dO68009309; Wed, 19 Oct 2016 02:39:24 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J2dOCV009308; Wed, 19 Oct 2016 02:39:24 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610190239.u9J2dOCV009308@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 19 Oct 2016 02:39:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307601 - stable/11/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 02:39:26 -0000 Author: gonzo Date: Wed Oct 19 02:39:24 2016 New Revision: 307601 URL: https://svnweb.freebsd.org/changeset/base/307601 Log: MFC r307239: Fix BCM283x(Raspberry Pi) SDHCI driver for ARM64 build - Revert BUS_SPACE_PHYSADDR back to rman_get_start. BUS_SPACE_PHYSADDR was introduced in 2013 as temporary wrapper until proper solution appears. It's ARM only and since we need this file for ARM64 build and no proper API has been introduced - just revert the change and make sure it's going to appear when people grep for BUS_SPACE_PHYSADDR in sources. - Fix printf format for size_t variables Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Wed Oct 19 02:24:57 2016 (r307600) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Wed Oct 19 02:39:24 2016 (r307601) @@ -246,8 +246,9 @@ bcm_sdhci_attach(device_t dev) goto fail; } - sc->sc_sdhci_buffer_phys = BUS_SPACE_PHYSADDR(sc->sc_mem_res, - SDHCI_BUFFER); + /* FIXME: Fix along with other BUS_SPACE_PHYSADDR instances */ + sc->sc_sdhci_buffer_phys = rman_get_start(sc->sc_mem_res) + + SDHCI_BUFFER; bus_generic_probe(dev); bus_generic_attach(dev); @@ -552,7 +553,7 @@ bcm_sdhci_read_dma(device_t dev, struct slot->curcmd->data->len - slot->offset); KASSERT((left & 3) == 0, - ("%s: len = %d, not word-aligned", __func__, left)); + ("%s: len = %zu, not word-aligned", __func__, left)); if (bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map, (uint8_t *)slot->curcmd->data->data + slot->offset, left, @@ -581,7 +582,7 @@ bcm_sdhci_write_dma(device_t dev, struct slot->curcmd->data->len - slot->offset); KASSERT((left & 3) == 0, - ("%s: len = %d, not word-aligned", __func__, left)); + ("%s: len = %zu, not word-aligned", __func__, left)); if (bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map, (uint8_t *)slot->curcmd->data->data + slot->offset, left, From owner-svn-src-stable@freebsd.org Wed Oct 19 05:08:48 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71F92C17182; Wed, 19 Oct 2016 05:08:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 319321595; Wed, 19 Oct 2016 05:08:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J58l1g066446; Wed, 19 Oct 2016 05:08:47 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J58kKo066439; Wed, 19 Oct 2016 05:08:46 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190508.u9J58kKo066439@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 05:08:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307603 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 05:08:48 -0000 Author: sephe Date: Wed Oct 19 05:08:46 2016 New Revision: 307603 URL: https://svnweb.freebsd.org/changeset/base/307603 Log: MFC 306390-306392 306390 hyperv/hn: Suspend and resume the backend properly upon MTU change. Suspend: - Prevent the backend from being touched on TX path. - Clear the RNDIS RX filter, and wait for RX to drain. - Make sure that NVS see the chimney sending buffer and RXBUF disconnection, before unlink these buffers from the channel. Resume: - Reconfigure the RNDIS filter. - Allow TX path to work on the backend. - Kick start the TX eof task, in case the OACTIVE is set. This fixes various panics, when the interface has traffic and MTU is being changed. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8046 306391 hyperv/hn: Reorganize the synthetic parts detach. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8047 306392 hyperv/hn: Reorder the comment a little bit. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8048 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 19 05:03:46 2016 (r307602) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 19 05:08:46 2016 (r307603) @@ -348,6 +348,16 @@ hn_nvs_disconn_rxbuf(struct hn_softc *sc return (error); } sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED; + + /* + * Wait for the hypervisor to receive this NVS request. + */ + while (!vmbus_chan_tx_empty(sc->hn_prichan)) + pause("waittx", 1); + /* + * Linger long enough for NVS to disconnect RXBUF. + */ + pause("lingtx", (200 * hz) / 1000); } if (sc->hn_rxbuf_gpadl != 0) { @@ -389,6 +399,17 @@ hn_nvs_disconn_chim(struct hn_softc *sc) return (error); } sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED; + + /* + * Wait for the hypervisor to receive this NVS request. + */ + while (!vmbus_chan_tx_empty(sc->hn_prichan)) + pause("waittx", 1); + /* + * Linger long enough for NVS to disconnect chimney + * sending buffer. + */ + pause("lingtx", (200 * hz) / 1000); } if (sc->hn_chim_gpadl != 0) { @@ -597,27 +618,15 @@ hn_nvs_attach(struct hn_softc *sc, int m return (0); } -/* - * Net VSC disconnect from VSP - */ -static void -hv_nv_disconnect_from_vsp(struct hn_softc *sc) +void +hn_nvs_detach(struct hn_softc *sc) { + + /* NOTE: there are no requests to stop the NVS. */ hn_nvs_disconn_rxbuf(sc); hn_nvs_disconn_chim(sc); } -/* - * Net VSC on device remove - */ -int -hv_nv_on_device_remove(struct hn_softc *sc) -{ - - hv_nv_disconnect_from_vsp(sc); - return (0); -} - void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 05:03:46 2016 (r307602) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 05:08:46 2016 (r307603) @@ -178,6 +178,7 @@ struct hn_tx_ring { bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; + int hn_suspended; int hn_gpa_cnt; struct vmbus_gpa hn_gpa[NETVSC_PACKET_MAXPAGE]; @@ -268,8 +269,6 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -int hn_nvs_attach(struct hn_softc *sc, int mtu); -int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 05:03:46 2016 (r307602) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 05:08:46 2016 (r307603) @@ -348,6 +348,11 @@ static void hn_detach_allchans(struct hn static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr); static void hn_set_ring_inuse(struct hn_softc *, int); static int hn_synth_attach(struct hn_softc *, int); +static void hn_synth_detach(struct hn_softc *); +static bool hn_tx_ring_pending(struct hn_tx_ring *); +static void hn_suspend(struct hn_softc *); +static void hn_resume(struct hn_softc *); +static void hn_tx_ring_qflush(struct hn_tx_ring *); static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt); @@ -740,29 +745,19 @@ failed: } /* - * Standard detach entry point + * TODO: Use this for error handling on attach path. */ static int netvsc_detach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); - if (bootverbose) - printf("netvsc_detach\n"); - - /* - * XXXKYS: Need to clean up all our - * driver state; this is the driver - * unloading. - */ + /* TODO: ether_ifdetach */ - /* - * XXXKYS: Need to stop outgoing traffic and unregister - * the netdevice. - */ - - hv_rf_on_device_remove(sc); - hn_detach_allchans(sc); + HN_LOCK(sc); + /* TODO: hn_stop */ + hn_synth_detach(sc); + HN_UNLOCK(sc); hn_stop_tx_tasks(sc); @@ -775,6 +770,8 @@ netvsc_detach(device_t dev) vmbus_xact_ctx_destroy(sc->hn_xact); HN_LOCK_DESTROY(sc); + + /* TODO: if_free */ return (0); } @@ -905,6 +902,23 @@ hn_txdesc_hold(struct hn_txdesc *txd) atomic_add_int(&txd->refs, 1); } +static bool +hn_tx_ring_pending(struct hn_tx_ring *txr) +{ + bool pending = false; + +#ifndef HN_USE_TXDESC_BUFRING + mtx_lock_spin(&txr->hn_txlist_spin); + if (txr->hn_txdesc_avail != txr->hn_txdesc_cnt) + pending = true; + mtx_unlock_spin(&txr->hn_txlist_spin); +#else + if (!buf_ring_full(txr->hn_txdesc_br)) + pending = true; +#endif + return (pending); +} + static __inline void hn_txeof(struct hn_tx_ring *txr) { @@ -1241,6 +1255,9 @@ hn_start_locked(struct hn_tx_ring *txr, KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); mtx_assert(&txr->hn_tx_lock, MA_OWNED); + if (__predict_false(txr->hn_suspended)) + return 0; + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return 0; @@ -1627,23 +1644,17 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); #endif - /* We must remove and add back the device to cause the new - * MTU to take effect. This includes tearing down, but not - * deleting the channel, then bringing it back up. - */ - error = hv_rf_on_device_remove(sc); - if (error) { - HN_UNLOCK(sc); - break; - } + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_suspend(sc); /* - * Detach all of the channels. + * Detach the synthetics parts, i.e. NVS and RNDIS. */ - hn_detach_allchans(sc); + hn_synth_detach(sc); /* - * Attach the synthetic parts, i.e. NVS and RNDIS. + * Reattach the synthetic parts, i.e. NVS and RNDIS, + * with the new MTU setting. * XXX check error. */ hn_synth_attach(sc, ifr->ifr_mtu); @@ -1651,7 +1662,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); - hn_init_locked(sc); + /* All done! Resume now. */ + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_resume(sc); HN_UNLOCK(sc); break; @@ -2984,6 +2997,9 @@ hn_xmit(struct hn_tx_ring *txr, int len) KASSERT(hn_use_if_start == 0, ("hn_xmit is called, when if_start is enabled")); + if (__predict_false(txr->hn_suspended)) + return 0; + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || txr->hn_oactive) return 0; @@ -3070,20 +3086,24 @@ do_sched: } static void +hn_tx_ring_qflush(struct hn_tx_ring *txr) +{ + struct mbuf *m; + + mtx_lock(&txr->hn_tx_lock); + while ((m = buf_ring_dequeue_sc(txr->hn_mbuf_br)) != NULL) + m_freem(m); + mtx_unlock(&txr->hn_tx_lock); +} + +static void hn_xmit_qflush(struct ifnet *ifp) { struct hn_softc *sc = ifp->if_softc; int i; - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { - struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; - struct mbuf *m; - - mtx_lock(&txr->hn_tx_lock); - while ((m = buf_ring_dequeue_sc(txr->hn_mbuf_br)) != NULL) - m_freem(m); - mtx_unlock(&txr->hn_tx_lock); - } + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) + hn_tx_ring_qflush(&sc->hn_tx_ring[i]); if_qflush(ifp); } @@ -3484,6 +3504,26 @@ back: return (0); } +/* + * NOTE: + * The interface must have been suspended though hn_suspend(), before + * this function get called. + */ +static void +hn_synth_detach(struct hn_softc *sc) +{ + HN_LOCK_ASSERT(sc); + + /* Detach the RNDIS first. */ + hn_rndis_detach(sc); + + /* Detach NVS. */ + hn_nvs_detach(sc); + + /* Detach all of the channels. */ + hn_detach_allchans(sc); +} + static void hn_set_ring_inuse(struct hn_softc *sc, int ring_cnt) { @@ -3503,6 +3543,113 @@ hn_set_ring_inuse(struct hn_softc *sc, i } static void +hn_rx_drain(struct vmbus_channel *chan) +{ + + while (!vmbus_chan_rx_empty(chan) || !vmbus_chan_tx_empty(chan)) + pause("waitch", 1); + vmbus_chan_intr_drain(chan); +} + +static void +hn_suspend(struct hn_softc *sc) +{ + struct vmbus_channel **subch = NULL; + int i, nsubch; + + HN_LOCK_ASSERT(sc); + + /* + * Suspend TX. + */ + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_suspended = 1; + mtx_unlock(&txr->hn_tx_lock); + /* No one is able send more packets now. */ + + /* Wait for all pending sends to finish. */ + while (hn_tx_ring_pending(txr)) + pause("hnwtx", 1 /* 1 tick */); + } + + /* + * Disable RX. + */ + hv_rf_on_close(sc); + + /* + * Give RNDIS enough time to flush all pending data packets. + */ + pause("waitrx", (200 * hz) / 1000); + + /* + * Drain RX/TX bufrings and interrupts. + */ + nsubch = sc->hn_rx_ring_inuse - 1; + if (nsubch > 0) + subch = vmbus_subchan_get(sc->hn_prichan, nsubch); + + if (subch != NULL) { + for (i = 0; i < nsubch; ++i) + hn_rx_drain(subch[i]); + } + hn_rx_drain(sc->hn_prichan); + + if (subch != NULL) + vmbus_subchan_rel(subch, nsubch); +} + +static void +hn_resume(struct hn_softc *sc) +{ + struct hn_tx_ring *txr; + int i; + + HN_LOCK_ASSERT(sc); + + /* + * Re-enable RX. + */ + hv_rf_on_open(sc); + + /* + * Make sure to clear suspend status on "all" TX rings, + * since hn_tx_ring_inuse can be changed after hn_suspend(). + */ + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_suspended = 0; + mtx_unlock(&txr->hn_tx_lock); + } + + if (!hn_use_if_start) { + /* + * Flush unused drbrs, since hn_tx_ring_inuse may be + * reduced. + */ + for (i = sc->hn_tx_ring_inuse; i < sc->hn_tx_ring_cnt; ++i) + hn_tx_ring_qflush(&sc->hn_tx_ring[i]); + } + + /* + * Kick start TX. + */ + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + txr = &sc->hn_tx_ring[i]; + /* + * Use txeof task, so that any pending oactive can be + * cleared properly. + */ + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); + } +} + +static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { const struct hn_nvs_hdr *hdr; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 05:03:46 2016 (r307602) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 05:08:46 2016 (r307603) @@ -957,11 +957,8 @@ done: return (error); } -/* - * RNDIS filter halt device - */ static int -hv_rf_halt_device(struct hn_softc *sc) +hn_rndis_halt(struct hn_softc *sc) { struct vmbus_xact *xact; struct rndis_halt_req *halt; @@ -1008,21 +1005,12 @@ hn_rndis_attach(struct hn_softc *sc) return (0); } -/* - * RNDIS filter on device remove - */ -int -hv_rf_on_device_remove(struct hn_softc *sc) +void +hn_rndis_detach(struct hn_softc *sc) { - int ret; - - /* Halt and release the rndis device */ - ret = hv_rf_halt_device(sc); - - /* Pass control to inner driver to remove the device */ - ret |= hv_nv_on_device_remove(sc); - return (ret); + /* Halt the RNDIS. */ + hn_rndis_halt(sc); } /* Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Oct 19 05:03:46 2016 (r307602) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Oct 19 05:08:46 2016 (r307603) @@ -43,7 +43,6 @@ struct hn_rx_ring; void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); -int hv_rf_on_device_remove(struct hn_softc *sc); int hv_rf_on_open(struct hn_softc *sc); int hv_rf_on_close(struct hn_softc *sc); Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 05:03:46 2016 (r307602) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 05:08:46 2016 (r307603) @@ -118,6 +118,7 @@ uint32_t hn_chim_alloc(struct hn_softc * void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); int hn_rndis_attach(struct hn_softc *sc); +void hn_rndis_detach(struct hn_softc *sc); int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags); void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, size_t pktsize, size_t pi_dlen, uint32_t pi_type); @@ -127,6 +128,7 @@ int hn_rndis_get_linkstatus(struct hn_s uint32_t *link_status); int hn_nvs_attach(struct hn_softc *sc, int mtu); +void hn_nvs_detach(struct hn_softc *sc); int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch); void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); From owner-svn-src-stable@freebsd.org Wed Oct 19 05:38:52 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6B83C178A1; Wed, 19 Oct 2016 05:38:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7798598D; Wed, 19 Oct 2016 05:38:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J5cpp7078044; Wed, 19 Oct 2016 05:38:51 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J5cpmp078039; Wed, 19 Oct 2016 05:38:51 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190538.u9J5cpmp078039@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 05:38:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307604 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 05:38:52 -0000 Author: sephe Date: Wed Oct 19 05:38:50 2016 New Revision: 307604 URL: https://svnweb.freebsd.org/changeset/base/307604 Log: MFC 306393 hyperv/hn: Flatten RX filter configuration. This paves way for more fixes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8049 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 05:08:46 2016 (r307603) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 05:38:50 2016 (r307604) @@ -265,7 +265,6 @@ struct hn_softc { /* * Externs */ -extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 05:08:46 2016 (r307603) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 05:38:50 2016 (r307604) @@ -205,8 +205,6 @@ struct hn_txdesc { * Globals */ -int hv_promisc_mode = 0; /* normal mode by default */ - SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Hyper-V network interface"); @@ -1779,7 +1777,7 @@ static void hn_stop(struct hn_softc *sc) { struct ifnet *ifp; - int ret, i; + int i; HN_LOCK_ASSERT(sc); @@ -1795,7 +1793,8 @@ hn_stop(struct hn_softc *sc) if_link_state_change(ifp, LINK_STATE_DOWN); - ret = hv_rf_on_close(sc); + /* Disable RX by clearing RX filter. */ + hn_rndis_set_rxfilter(sc, 0); } /* @@ -1870,9 +1869,8 @@ hn_init_locked(struct hn_softc *sc) return; } - hv_promisc_mode = 1; - - ret = hv_rf_on_open(sc); + /* TODO: add hn_rx_filter */ + ret = hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); if (ret != 0) return; @@ -3576,9 +3574,9 @@ hn_suspend(struct hn_softc *sc) } /* - * Disable RX. + * Disable RX by clearing RX filter. */ - hv_rf_on_close(sc); + hn_rndis_set_rxfilter(sc, 0); /* * Give RNDIS enough time to flush all pending data packets. @@ -3612,8 +3610,9 @@ hn_resume(struct hn_softc *sc) /* * Re-enable RX. + * TODO: add hn_rx_filter. */ - hv_rf_on_open(sc); + hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); /* * Make sure to clear suspend status on "all" TX rings, Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 05:08:46 2016 (r307603) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 05:38:50 2016 (r307604) @@ -887,7 +887,7 @@ hn_rndis_conf_rss(struct hn_softc *sc, u return (error); } -static int +int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter) { int error; @@ -1013,35 +1013,6 @@ hn_rndis_detach(struct hn_softc *sc) hn_rndis_halt(sc); } -/* - * RNDIS filter on open - */ -int -hv_rf_on_open(struct hn_softc *sc) -{ - uint32_t filter; - - /* XXX */ - if (hv_promisc_mode != 1) { - filter = NDIS_PACKET_TYPE_BROADCAST | - NDIS_PACKET_TYPE_ALL_MULTICAST | - NDIS_PACKET_TYPE_DIRECTED; - } else { - filter = NDIS_PACKET_TYPE_PROMISCUOUS; - } - return (hn_rndis_set_rxfilter(sc, filter)); -} - -/* - * RNDIS filter on close - */ -int -hv_rf_on_close(struct hn_softc *sc) -{ - - return (hn_rndis_set_rxfilter(sc, 0)); -} - void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Oct 19 05:08:46 2016 (r307603) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Oct 19 05:38:50 2016 (r307604) @@ -43,8 +43,6 @@ struct hn_rx_ring; void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); -int hv_rf_on_open(struct hn_softc *sc); -int hv_rf_on_close(struct hn_softc *sc); #endif /* __HV_RNDIS_FILTER_H__ */ Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 05:08:46 2016 (r307603) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 05:38:50 2016 (r307604) @@ -126,6 +126,8 @@ int hn_rndis_get_rsscaps(struct hn_soft int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr); int hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status); +/* filter: NDIS_PACKET_TYPE_ or 0. */ +int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter); int hn_nvs_attach(struct hn_softc *sc, int mtu); void hn_nvs_detach(struct hn_softc *sc); From owner-svn-src-stable@freebsd.org Wed Oct 19 06:15:29 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10885C184AA; Wed, 19 Oct 2016 06:15:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B6AE6F5D; Wed, 19 Oct 2016 06:15:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J6FR4j092793; Wed, 19 Oct 2016 06:15:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J6FRCs092791; Wed, 19 Oct 2016 06:15:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190615.u9J6FRCs092791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 06:15:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307606 - in stable/11/sys: cam/ata sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 06:15:29 -0000 Author: sephe Date: Wed Oct 19 06:15:27 2016 New Revision: 307606 URL: https://svnweb.freebsd.org/changeset/base/307606 Log: MFC 306396 cam/ata: Allow drivers to veto ATA disk attachment. This eventhandler is mainly used by VMs, e.g. Hyper-V, whose disk controllers share the disks with the simulated ATA controllers. Submitted by: Hongjiang Zhang Discussed with: mav Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7693 Modified: stable/11/sys/cam/ata/ata_xpt.c stable/11/sys/sys/eventhandler.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/11/sys/cam/ata/ata_xpt.c Wed Oct 19 05:53:43 2016 (r307605) +++ stable/11/sys/cam/ata/ata_xpt.c Wed Oct 19 06:15:27 2016 (r307606) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -824,12 +825,24 @@ noerror: { struct ccb_pathinq cpi; int16_t *ptr; + int veto = 0; ident_buf = &softc->ident_data; for (ptr = (int16_t *)ident_buf; ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) { *ptr = le16toh(*ptr); } + + /* + * Allow others to veto this ATA disk attachment. This + * is mainly used by VMs, whose disk controllers may + * share the disks with the simulated ATA controllers. + */ + EVENTHANDLER_INVOKE(ada_probe_veto, path, ident_buf, &veto); + if (veto) { + goto device_fail; + } + if (strncmp(ident_buf->model, "FX", 2) && strncmp(ident_buf->model, "NEC", 3) && strncmp(ident_buf->model, "Pioneer", 7) && Modified: stable/11/sys/sys/eventhandler.h ============================================================================== --- stable/11/sys/sys/eventhandler.h Wed Oct 19 05:53:43 2016 (r307605) +++ stable/11/sys/sys/eventhandler.h Wed Oct 19 06:15:27 2016 (r307606) @@ -270,4 +270,11 @@ typedef void (*unregister_framebuffer_fn EVENTHANDLER_DECLARE(register_framebuffer, register_framebuffer_fn); EVENTHANDLER_DECLARE(unregister_framebuffer, unregister_framebuffer_fn); +/* Veto ada attachment */ +struct cam_path; +struct ata_params; +typedef void (*ada_probe_veto_fn)(void *, struct cam_path *, + struct ata_params *, int *); +EVENTHANDLER_DECLARE(ada_probe_veto, ada_probe_veto_fn); + #endif /* _SYS_EVENTHANDLER_H_ */ From owner-svn-src-stable@freebsd.org Wed Oct 19 06:45:54 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B806AC18DB4; Wed, 19 Oct 2016 06:45:54 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7BAE769A; Wed, 19 Oct 2016 06:45:54 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J6jrpm004060; Wed, 19 Oct 2016 06:45:53 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J6jrjN004056; Wed, 19 Oct 2016 06:45:53 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190645.u9J6jrjN004056@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 06:45:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307607 - in stable/11/sys: conf dev/hyperv/stordisengage dev/hyperv/storvsc modules/hyperv modules/hyperv/stordisengage X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 06:45:54 -0000 Author: sephe Date: Wed Oct 19 06:45:53 2016 New Revision: 307607 URL: https://svnweb.freebsd.org/changeset/base/307607 Log: MFC 306426 hyperv/storvsc: Fix the blkvsc disk attachment issues. - The original 'disengage' ATA controller model does not work properly for all possible disk configurations. Use the newly added ATA disk veto eventhandler to fit into all possible disk configuration. - If the 'invalid LUN' happens on blkvsc controllers, return CAM_DEV_NOT_THERE so that CAM will not destroy attached disks under the blkvsc controllers. Submitted by: Hongjiang Zhang Discussed with: mav Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7693 Deleted: stable/11/sys/dev/hyperv/stordisengage/ stable/11/sys/modules/hyperv/stordisengage/ Modified: stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.i386 stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/modules/hyperv/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Wed Oct 19 06:15:27 2016 (r307606) +++ stable/11/sys/conf/files.amd64 Wed Oct 19 06:45:53 2016 (r307607) @@ -294,7 +294,6 @@ dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hv_net_vsc.c optional hyperv dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv -dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Modified: stable/11/sys/conf/files.i386 ============================================================================== --- stable/11/sys/conf/files.i386 Wed Oct 19 06:15:27 2016 (r307606) +++ stable/11/sys/conf/files.i386 Wed Oct 19 06:45:53 2016 (r307607) @@ -251,7 +251,6 @@ dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hv_net_vsc.c optional hyperv dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv -dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 19 06:15:27 2016 (r307606) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 19 06:45:53 2016 (r307607) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -202,6 +203,7 @@ struct storvsc_softc { struct vmbus_channel *hs_sel_chan[MAXCPU]; }; +static eventhandler_tag storvsc_handler_tag; /* * The size of the vmscsi_request has changed in win8. The * additional size is for the newly added elements in the @@ -898,21 +900,15 @@ hv_storvsc_on_channel_callback(struct vm static int storvsc_probe(device_t dev) { - int ata_disk_enable = 0; int ret = ENXIO; switch (storvsc_get_storage_type(dev)) { case DRIVER_BLKVSC: if(bootverbose) - device_printf(dev, "DRIVER_BLKVSC-Emulated ATA/IDE probe\n"); - if (!getenv_int("hw.ata.disk_enable", &ata_disk_enable)) { - if(bootverbose) - device_printf(dev, - "Enlightened ATA/IDE detected\n"); - device_set_desc(dev, g_drv_props_table[DRIVER_BLKVSC].drv_desc); - ret = BUS_PROBE_DEFAULT; - } else if(bootverbose) - device_printf(dev, "Emulated ATA/IDE set (hw.ata.disk_enable set)\n"); + device_printf(dev, + "Enlightened ATA/IDE detected\n"); + device_set_desc(dev, g_drv_props_table[DRIVER_BLKVSC].drv_desc); + ret = BUS_PROBE_DEFAULT; break; case DRIVER_STORVSC: if(bootverbose) @@ -2155,27 +2151,45 @@ storvsc_io_done(struct hv_storvsc_reques ccb->ccb_h.status &= ~CAM_STATUS_MASK; if (vm_srb->scsi_status == SCSI_STATUS_OK) { const struct scsi_generic *cmd; - + cmd = (const struct scsi_generic *) + ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? + csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); if (vm_srb->srb_status != SRB_STATUS_SUCCESS) { - if (vm_srb->srb_status == SRB_STATUS_INVALID_LUN) { - xpt_print(ccb->ccb_h.path, "invalid LUN %d\n", - vm_srb->lun); - } else { - xpt_print(ccb->ccb_h.path, "Unknown SRB flag: %d\n", - vm_srb->srb_status); - } /* * If there are errors, for example, invalid LUN, * host will inform VM through SRB status. */ - ccb->ccb_h.status |= CAM_SEL_TIMEOUT; + if (bootverbose) { + if (vm_srb->srb_status == SRB_STATUS_INVALID_LUN) { + xpt_print(ccb->ccb_h.path, + "invalid LUN %d for op: %s\n", + vm_srb->lun, + scsi_op_desc(cmd->opcode, NULL)); + } else { + xpt_print(ccb->ccb_h.path, + "Unknown SRB flag: %d for op: %s\n", + vm_srb->srb_status, + scsi_op_desc(cmd->opcode, NULL)); + } + } + + /* + * XXX For a selection timeout, all of the LUNs + * on the target will be gone. It works for SCSI + * disks, but does not work for IDE disks. + * + * For CAM_DEV_NOT_THERE, CAM will only get + * rid of the device(s) specified by the path. + */ + if (storvsc_get_storage_type(sc->hs_dev) == + DRIVER_STORVSC) + ccb->ccb_h.status |= CAM_SEL_TIMEOUT; + else + ccb->ccb_h.status |= CAM_DEV_NOT_THERE; } else { ccb->ccb_h.status |= CAM_REQ_CMP; } - cmd = (const struct scsi_generic *) - ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? - csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); if (cmd->opcode == INQUIRY) { struct scsi_inquiry_data *inq_data = (struct scsi_inquiry_data *)csio->data_ptr; @@ -2287,3 +2301,58 @@ storvsc_get_storage_type(device_t dev) return DRIVER_STORVSC; return DRIVER_UNKNOWN; } + +#define PCI_VENDOR_INTEL 0x8086 +#define PCI_PRODUCT_PIIX4 0x7111 + +static void +storvsc_ada_probe_veto(void *arg __unused, struct cam_path *path, + struct ata_params *ident_buf __unused, int *veto) +{ + + /* + * The ATA disks are shared with the controllers managed + * by this driver, so veto the ATA disks' attachment; the + * ATA disks will be attached as SCSI disks once this driver + * attached. + */ + if (path->device->protocol == PROTO_ATA) { + struct ccb_pathinq cpi; + + bzero(&cpi, sizeof(cpi)); + xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); + cpi.ccb_h.func_code = XPT_PATH_INQ; + xpt_action((union ccb *)&cpi); + if (cpi.ccb_h.status == CAM_REQ_CMP && + cpi.hba_vendor == PCI_VENDOR_INTEL && + cpi.hba_device == PCI_PRODUCT_PIIX4) { + (*veto)++; + if (bootverbose) { + xpt_print(path, + "Disable ATA disks on " + "simulated ATA controller (0x%04x%04x)\n", + cpi.hba_device, cpi.hba_vendor); + } + } + } +} + +static void +storvsc_sysinit(void *arg __unused) +{ + if (vm_guest == VM_GUEST_HV) { + storvsc_handler_tag = EVENTHANDLER_REGISTER(ada_probe_veto, + storvsc_ada_probe_veto, NULL, EVENTHANDLER_PRI_ANY); + } +} +SYSINIT(storvsc_sys_init, SI_SUB_DRIVERS, SI_ORDER_SECOND, storvsc_sysinit, + NULL); + +static void +storvsc_sysuninit(void *arg __unused) +{ + if (storvsc_handler_tag != NULL) + EVENTHANDLER_DEREGISTER(ada_probe_veto, storvsc_handler_tag); +} +SYSUNINIT(storvsc_sys_uninit, SI_SUB_DRIVERS, SI_ORDER_SECOND, + storvsc_sysuninit, NULL); Modified: stable/11/sys/modules/hyperv/Makefile ============================================================================== --- stable/11/sys/modules/hyperv/Makefile Wed Oct 19 06:15:27 2016 (r307606) +++ stable/11/sys/modules/hyperv/Makefile Wed Oct 19 06:45:53 2016 (r307607) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR = vmbus netvsc stordisengage storvsc utilities +SUBDIR = vmbus netvsc storvsc utilities .include From owner-svn-src-stable@freebsd.org Wed Oct 19 06:57:20 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 266D8C16278; Wed, 19 Oct 2016 06:57:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DAD92DE8; Wed, 19 Oct 2016 06:57:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J6vIQM007812; Wed, 19 Oct 2016 06:57:18 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J6vIdA007811; Wed, 19 Oct 2016 06:57:18 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190657.u9J6vIdA007811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 06:57:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307608 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 06:57:20 -0000 Author: sephe Date: Wed Oct 19 06:57:18 2016 New Revision: 307608 URL: https://svnweb.freebsd.org/changeset/base/307608 Log: MFC 306431,306432 306431 hyperv/hn: Move TX tasks' draining into hn_suspend(). This prepares to consolidate hn_stop() and netvsc_detach(). Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8055 306432 hyperv/hn: Consolidate hn_init() and hn_stop() Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8056 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 06:45:53 2016 (r307607) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 06:57:18 2016 (r307608) @@ -334,7 +334,6 @@ static void hn_fixup_tx_data(struct hn_s static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); -static void hn_stop_tx_tasks(struct hn_softc *); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); @@ -350,6 +349,8 @@ static void hn_synth_detach(struct hn_so static bool hn_tx_ring_pending(struct hn_tx_ring *); static void hn_suspend(struct hn_softc *); static void hn_resume(struct hn_softc *); +static void hn_rx_drain(struct vmbus_channel *); +static void hn_tx_resume(struct hn_softc *, int); static void hn_tx_ring_qflush(struct hn_tx_ring *); static void hn_nvs_handle_notify(struct hn_softc *sc, @@ -757,8 +758,6 @@ netvsc_detach(device_t dev) hn_synth_detach(sc); HN_UNLOCK(sc); - hn_stop_tx_tasks(sc); - ifmedia_removeall(&sc->hn_media); hn_destroy_rx_data(sc); hn_destroy_tx_data(sc); @@ -1776,25 +1775,19 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, static void hn_stop(struct hn_softc *sc) { - struct ifnet *ifp; + struct ifnet *ifp = sc->hn_ifp; int i; HN_LOCK_ASSERT(sc); - ifp = sc->hn_ifp; - - if (bootverbose) - printf(" Closing Device ...\n"); + /* Clear RUNNING bit _before_ hn_suspend() */ + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + hn_suspend(sc); - atomic_clear_int(&ifp->if_drv_flags, - (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); + /* Clear OACTIVE bit. */ + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_oactive = 0; - - if_link_state_change(ifp, LINK_STATE_DOWN); - - /* Disable RX by clearing RX filter. */ - hn_rndis_set_rxfilter(sc, 0); } /* @@ -1858,27 +1851,29 @@ do_sched: static void hn_init_locked(struct hn_softc *sc) { - struct ifnet *ifp; - int ret, i; + struct ifnet *ifp = sc->hn_ifp; + int i; HN_LOCK_ASSERT(sc); - ifp = sc->hn_ifp; - - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) return; - } /* TODO: add hn_rx_filter */ - ret = hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); - if (ret != 0) - return; + hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); + /* Clear OACTIVE bit. */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_oactive = 0; + /* Clear TX 'suspended' bit. */ + hn_tx_resume(sc, sc->hn_tx_ring_inuse); + + /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + + /* TODO: check RNDIS link status. */ if_link_state_change(ifp, LINK_STATE_UP); } @@ -2971,19 +2966,6 @@ hn_start_txeof_taskfunc(void *xtxr, int mtx_unlock(&txr->hn_tx_lock); } -static void -hn_stop_tx_tasks(struct hn_softc *sc) -{ - int i; - - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { - struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; - - taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); - taskqueue_drain(txr->hn_tx_taskq, &txr->hn_txeof_task); - } -} - static int hn_xmit(struct hn_tx_ring *txr, int len) { @@ -3571,6 +3553,9 @@ hn_suspend(struct hn_softc *sc) /* Wait for all pending sends to finish. */ while (hn_tx_ring_pending(txr)) pause("hnwtx", 1 /* 1 tick */); + + taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); + taskqueue_drain(txr->hn_tx_taskq, &txr->hn_txeof_task); } /* @@ -3601,9 +3586,25 @@ hn_suspend(struct hn_softc *sc) } static void +hn_tx_resume(struct hn_softc *sc, int tx_ring_cnt) +{ + int i; + + KASSERT(tx_ring_cnt <= sc->hn_tx_ring_cnt, + ("invalid TX ring count %d", tx_ring_cnt)); + + for (i = 0; i < tx_ring_cnt; ++i) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_suspended = 0; + mtx_unlock(&txr->hn_tx_lock); + } +} + +static void hn_resume(struct hn_softc *sc) { - struct hn_tx_ring *txr; int i; HN_LOCK_ASSERT(sc); @@ -3618,13 +3619,7 @@ hn_resume(struct hn_softc *sc) * Make sure to clear suspend status on "all" TX rings, * since hn_tx_ring_inuse can be changed after hn_suspend(). */ - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { - txr = &sc->hn_tx_ring[i]; - - mtx_lock(&txr->hn_tx_lock); - txr->hn_suspended = 0; - mtx_unlock(&txr->hn_tx_lock); - } + hn_tx_resume(sc, sc->hn_tx_ring_cnt); if (!hn_use_if_start) { /* @@ -3639,7 +3634,8 @@ hn_resume(struct hn_softc *sc) * Kick start TX. */ for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { - txr = &sc->hn_tx_ring[i]; + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + /* * Use txeof task, so that any pending oactive can be * cleared properly. From owner-svn-src-stable@freebsd.org Wed Oct 19 06:59:46 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E35FDC16421; Wed, 19 Oct 2016 06:59:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A3CC0FF; Wed, 19 Oct 2016 06:59:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J6xjKj007948; Wed, 19 Oct 2016 06:59:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J6xjgC007946; Wed, 19 Oct 2016 06:59:45 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190659.u9J6xjgC007946@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 06:59:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307609 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 06:59:47 -0000 Author: sephe Date: Wed Oct 19 06:59:45 2016 New Revision: 307609 URL: https://svnweb.freebsd.org/changeset/base/307609 Log: MFC 306433 hyperv/hn: Don't set HASHVAL pktinfo for NDIS < 6.30 This unbreaks packet sending on WS2008R2. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8057 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 06:57:18 2016 (r307608) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 06:59:45 2016 (r307609) @@ -168,6 +168,7 @@ struct hn_tx_ring { struct buf_ring *hn_mbuf_br; int hn_oactive; int hn_tx_idx; + int hn_tx_flags; struct mtx hn_tx_lock; struct hn_softc *hn_sc; @@ -194,10 +195,10 @@ struct hn_tx_ring { struct hn_txdesc *hn_txdesc; bus_dma_tag_t hn_tx_rndis_dtag; struct sysctl_oid *hn_tx_sysctl_tree; - int hn_tx_flags; } __aligned(CACHE_LINE_SIZE); #define HN_TX_FLAG_ATTACHED 0x1 +#define HN_TX_FLAG_HASHVAL 0x2 /* support HASHVAL pktinfo */ /* * Device-specific softc structure Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 06:57:18 2016 (r307608) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 06:59:45 2016 (r307609) @@ -1006,14 +1006,16 @@ hn_encap(struct hn_tx_ring *txr, struct pkt->rm_pktinfooffset = sizeof(*pkt); pkt->rm_pktinfolen = 0; - /* - * Set the hash value for this packet, so that the host could - * dispatch the TX done event for this packet back to this TX - * ring's channel. - */ - pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, - HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL); - *pi_data = txr->hn_tx_idx; + if (txr->hn_tx_flags & HN_TX_FLAG_HASHVAL) { + /* + * Set the hash value for this packet, so that the host could + * dispatch the TX done event for this packet back to this TX + * ring's channel. + */ + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL); + *pi_data = txr->hn_tx_idx; + } if (m_head->m_flags & M_VLANTAG) { pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, @@ -2920,6 +2922,12 @@ hn_fixup_tx_data(struct hn_softc *sc) for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_csum_assist = csum_assist; + + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + /* Support HASHVAL pktinfo on TX path. */ + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + sc->hn_tx_ring[i].hn_tx_flags |= HN_TX_FLAG_HASHVAL; + } } static void From owner-svn-src-stable@freebsd.org Wed Oct 19 07:03:56 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 113D2C16759; Wed, 19 Oct 2016 07:03:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D453C920; Wed, 19 Oct 2016 07:03:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J73smP011576; Wed, 19 Oct 2016 07:03:54 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J73sni011575; Wed, 19 Oct 2016 07:03:54 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190703.u9J73sni011575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:03:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307610 - stable/11/sys/x86/x86 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:03:56 -0000 Author: sephe Date: Wed Oct 19 07:03:54 2016 New Revision: 307610 URL: https://svnweb.freebsd.org/changeset/base/307610 Log: MFC 306481 x86/ioapic: Fix destination cpu for Hyper-V On Hyper-V: - Stick to the first cpu for all I/O APIC pins. - And don't allow destination cpu changes. Reviewed by: jhb Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7949 Modified: stable/11/sys/x86/x86/io_apic.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/x86/x86/io_apic.c ============================================================================== --- stable/11/sys/x86/x86/io_apic.c Wed Oct 19 06:59:45 2016 (r307609) +++ stable/11/sys/x86/x86/io_apic.c Wed Oct 19 07:03:54 2016 (r307610) @@ -412,6 +412,18 @@ ioapic_assign_cpu(struct intsrc *isrc, u u_int old_id; /* + * On Hyper-V: + * - Stick to the first cpu for all I/O APIC pins. + * - And don't allow destination cpu changes. + */ + if (vm_guest == VM_GUEST_HV) { + if (intpin->io_vector) + return (EINVAL); + else + apic_id = 0; + } + + /* * keep 1st core as the destination for NMI */ if (intpin->io_irq == IRQ_NMI) From owner-svn-src-stable@freebsd.org Wed Oct 19 07:08:29 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4862C168C3; Wed, 19 Oct 2016 07:08:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6789CB3C; Wed, 19 Oct 2016 07:08:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J78S1X011786; Wed, 19 Oct 2016 07:08:28 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J78SKF011784; Wed, 19 Oct 2016 07:08:28 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190708.u9J78SKF011784@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:08:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307611 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:08:29 -0000 Author: sephe Date: Wed Oct 19 07:08:28 2016 New Revision: 307611 URL: https://svnweb.freebsd.org/changeset/base/307611 Log: MFC 306482,306483 306482 hyperv/hn: If synthetic parts are detached, don't touch them. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8065 306483 hyperv/hn: Fix detach and attach error handling. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8066 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 07:03:54 2016 (r307610) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 07:08:28 2016 (r307611) @@ -252,6 +252,7 @@ struct hn_softc { #define HN_FLAG_CHIM_CONNECTED 0x0002 #define HN_FLAG_HAS_RSSKEY 0x0004 #define HN_FLAG_HAS_RSSIND 0x0008 +#define HN_FLAG_SYNTH_ATTACHED 0x0010 #define HN_CAP_VLAN 0x0001 #define HN_CAP_MTU 0x0002 Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 07:03:54 2016 (r307610) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 07:08:28 2016 (r307611) @@ -352,6 +352,7 @@ static void hn_resume(struct hn_softc *) static void hn_rx_drain(struct vmbus_channel *); static void hn_tx_resume(struct hn_softc *, int); static void hn_tx_ring_qflush(struct hn_tx_ring *); +static int netvsc_detach(device_t dev); static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt); @@ -405,6 +406,9 @@ hn_rss_reconfig(struct hn_softc *sc) HN_LOCK_ASSERT(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) + return (ENXIO); + /* * Disable RSS first. * @@ -736,27 +740,28 @@ netvsc_attach(device_t dev) return (0); failed: - /* TODO: reuse netvsc_detach() */ - hn_destroy_tx_data(sc); - if (ifp != NULL) - if_free(ifp); + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) + hn_synth_detach(sc); + netvsc_detach(dev); return (error); } -/* - * TODO: Use this for error handling on attach path. - */ static int netvsc_detach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); + struct ifnet *ifp = sc->hn_ifp; - /* TODO: ether_ifdetach */ - - HN_LOCK(sc); - /* TODO: hn_stop */ - hn_synth_detach(sc); - HN_UNLOCK(sc); + if (device_is_attached(dev)) { + HN_LOCK(sc); + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_stop(sc); + hn_synth_detach(sc); + } + HN_UNLOCK(sc); + ether_ifdetach(ifp); + } ifmedia_removeall(&sc->hn_media); hn_destroy_rx_data(sc); @@ -765,10 +770,12 @@ netvsc_detach(device_t dev) if (sc->hn_tx_taskq != hn_tx_taskq) taskqueue_free(sc->hn_tx_taskq); - vmbus_xact_ctx_destroy(sc->hn_xact); - HN_LOCK_DESTROY(sc); + if (sc->hn_xact != NULL) + vmbus_xact_ctx_destroy(sc->hn_xact); + + if_free(ifp); - /* TODO: if_free */ + HN_LOCK_DESTROY(sc); return (0); } @@ -1618,6 +1625,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, HN_LOCK(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) { + HN_UNLOCK(sc); + break; + } + if ((sc->hn_caps & HN_CAP_MTU) == 0) { /* Can't change MTU */ HN_UNLOCK(sc); @@ -1671,6 +1683,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, case SIOCSIFFLAGS: HN_LOCK(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) { + HN_UNLOCK(sc); + break; + } + if (ifp->if_flags & IFF_UP) { /* * If only the state of the PROMISC flag changed, @@ -1782,6 +1799,9 @@ hn_stop(struct hn_softc *sc) HN_LOCK_ASSERT(sc); + KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, + ("synthetic parts were not attached")); + /* Clear RUNNING bit _before_ hn_suspend() */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); hn_suspend(sc); @@ -1858,6 +1878,9 @@ hn_init_locked(struct hn_softc *sc) HN_LOCK_ASSERT(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) + return; + if (ifp->if_drv_flags & IFF_DRV_RUNNING) return; @@ -3377,6 +3400,9 @@ hn_synth_attach(struct hn_softc *sc, int int error, nsubch, nchan, i; uint32_t old_caps; + KASSERT((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0, + ("synthetic parts were attached")); + /* Save capabilities for later verification. */ old_caps = sc->hn_caps; sc->hn_caps = 0; @@ -3489,6 +3515,8 @@ back: error = hn_attach_subchans(sc); if (error) return (error); + + sc->hn_flags |= HN_FLAG_SYNTH_ATTACHED; return (0); } @@ -3502,6 +3530,9 @@ hn_synth_detach(struct hn_softc *sc) { HN_LOCK_ASSERT(sc); + KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, + ("synthetic parts were not attached")); + /* Detach the RNDIS first. */ hn_rndis_detach(sc); @@ -3510,6 +3541,8 @@ hn_synth_detach(struct hn_softc *sc) /* Detach all of the channels. */ hn_detach_allchans(sc); + + sc->hn_flags &= ~HN_FLAG_SYNTH_ATTACHED; } static void From owner-svn-src-stable@freebsd.org Wed Oct 19 07:16:28 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67358C16CE3; Wed, 19 Oct 2016 07:16:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BC6419C; Wed, 19 Oct 2016 07:16:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J7GRMA015427; Wed, 19 Oct 2016 07:16:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J7GQ8H015424; Wed, 19 Oct 2016 07:16:26 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190716.u9J7GQ8H015424@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:16:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307612 - in stable/11/sys: dev/hyperv/netvsc modules/hyperv/vmbus net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:16:28 -0000 Author: sephe Date: Wed Oct 19 07:16:26 2016 New Revision: 307612 URL: https://svnweb.freebsd.org/changeset/base/307612 Log: MFC 306484,306485 306484 hyperv/vmbus: Add missing vmbus_if.c to module build. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8067 306485 hyperv/hn: Add stubs for OFFLOAD_CURRENT_CONFIG and NETWORK_CHANGE status Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8068 Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/modules/hyperv/vmbus/Makefile stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 07:08:28 2016 (r307611) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 07:16:26 2016 (r307612) @@ -155,6 +155,15 @@ hv_rf_receive_indicate_status(struct hn_ netvsc_linkstatus_callback(sc, 0); break; + case RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG: + /* Not really useful; ignore. */ + break; + + case RNDIS_STATUS_NETWORK_CHANGE: + /* TODO */ + if_printf(sc->hn_ifp, "network changed\n"); + break; + default: /* TODO: */ if_printf(sc->hn_ifp, "unknown RNDIS status 0x%08x\n", Modified: stable/11/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/11/sys/modules/hyperv/vmbus/Makefile Wed Oct 19 07:08:28 2016 (r307611) +++ stable/11/sys/modules/hyperv/vmbus/Makefile Wed Oct 19 07:16:26 2016 (r307612) @@ -11,6 +11,7 @@ SRCS= hyperv.c \ vmbus_br.c \ vmbus_chan.c \ vmbus_et.c \ + vmbus_if.c \ vmbus_xact.c SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h vmbus_if.h Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Wed Oct 19 07:08:28 2016 (r307611) +++ stable/11/sys/net/rndis.h Wed Oct 19 07:16:26 2016 (r307612) @@ -31,6 +31,8 @@ #define RNDIS_STATUS_PENDING 0x00000103L #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL +#define RNDIS_STATUS_NETWORK_CHANGE 0x40010018L +#define RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG 0x40020006L #define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L #define RNDIS_STATUS_FAILURE 0xC0000001L #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL From owner-svn-src-stable@freebsd.org Wed Oct 19 07:24:34 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C73AC17086; Wed, 19 Oct 2016 07:24:34 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 54485AFD; Wed, 19 Oct 2016 07:24:34 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J7OX4U019374; Wed, 19 Oct 2016 07:24:33 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J7OXto019368; Wed, 19 Oct 2016 07:24:33 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190724.u9J7OXto019368@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:24:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307613 - in stable/11/sys: dev/hyperv/netvsc net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:24:34 -0000 Author: sephe Date: Wed Oct 19 07:24:32 2016 New Revision: 307613 URL: https://svnweb.freebsd.org/changeset/base/307613 Log: MFC 306936-306939 306936 hyperv/hn: Fix checksum offload settings The _correct_ way to identify the supported checksum offloading and TSO parameters is to query OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8088 306937 hyperv/hn: Fix if_hw_tsomax setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8089 306938 hyperv/hn: Generalize RSS capabilities query. - Support NDIS < 6.30. - Stringent response checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8090 306939 hyperv/hn: Suffix NDIS offload size with NDIS version. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8091 Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/dev/hyperv/netvsc/ndis.h stable/11/sys/net/rndis.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 07:16:26 2016 (r307612) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 07:24:32 2016 (r307613) @@ -244,6 +244,8 @@ struct hn_softc { uint32_t hn_rndis_rid; uint32_t hn_ndis_ver; + int hn_ndis_tso_szmax; + int hn_ndis_tso_sgmin; struct ndis_rssprm_toeplitz hn_rss; }; Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 07:16:26 2016 (r307612) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 07:24:32 2016 (r307613) @@ -230,7 +230,7 @@ SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosti "when csum info is missing (global setting)"); /* Limit TSO burst size */ -static int hn_tso_maxlen = 0; +static int hn_tso_maxlen = IP_MAXPACKET; SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, &hn_tso_maxlen, 0, "TSO burst limit"); @@ -338,6 +338,7 @@ static int hn_encap(struct hn_tx_ring *, static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_chim_size(struct hn_softc *, int); +static void hn_set_tso_maxsize(struct hn_softc *, int, int); static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); static void hn_chan_detach(struct hn_softc *, struct vmbus_channel *); static int hn_attach_subchans(struct hn_softc *); @@ -520,7 +521,6 @@ netvsc_attach(device_t dev) uint32_t link_status; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; - int tso_maxlen; sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); @@ -720,18 +720,16 @@ netvsc_attach(device_t dev) /* Enable all available capabilities by default. */ ifp->if_capenable = ifp->if_capabilities; - tso_maxlen = hn_tso_maxlen; - if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) - tso_maxlen = IP_MAXPACKET; - ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; - ifp->if_hw_tsomaxsegsize = PAGE_SIZE; - ifp->if_hw_tsomax = tso_maxlen - - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { + hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); + ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; + ifp->if_hw_tsomaxsegsize = PAGE_SIZE; + } ether_ifattach(ifp, eaddr); - if (bootverbose) { - if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, + if ((ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) && bootverbose) { + if_printf(ifp, "TSO segcnt %u segsz %u\n", ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); } @@ -1672,6 +1670,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); + hn_set_tso_maxsize(sc, hn_tso_maxlen, ifr->ifr_mtu); /* All done! Resume now. */ if (ifp->if_drv_flags & IFF_DRV_RUNNING) @@ -2919,6 +2918,34 @@ hn_set_chim_size(struct hn_softc *sc, in } static void +hn_set_tso_maxsize(struct hn_softc *sc, int tso_maxlen, int mtu) +{ + struct ifnet *ifp = sc->hn_ifp; + int tso_minlen; + + if ((ifp->if_capabilities & (IFCAP_TSO4 | IFCAP_TSO6)) == 0) + return; + + KASSERT(sc->hn_ndis_tso_sgmin >= 2, + ("invalid NDIS tso sgmin %d", sc->hn_ndis_tso_sgmin)); + tso_minlen = sc->hn_ndis_tso_sgmin * mtu; + + KASSERT(sc->hn_ndis_tso_szmax >= tso_minlen && + sc->hn_ndis_tso_szmax <= IP_MAXPACKET, + ("invalid NDIS tso szmax %d", sc->hn_ndis_tso_szmax)); + + if (tso_maxlen < tso_minlen) + tso_maxlen = tso_minlen; + else if (tso_maxlen > IP_MAXPACKET) + tso_maxlen = IP_MAXPACKET; + if (tso_maxlen > sc->hn_ndis_tso_szmax) + tso_maxlen = sc->hn_ndis_tso_szmax; + ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + if (bootverbose) + if_printf(ifp, "TSO size max %u\n", ifp->if_hw_tsomax); +} + +static void hn_fixup_tx_data(struct hn_softc *sc) { uint64_t csum_assist; @@ -3424,7 +3451,7 @@ hn_synth_attach(struct hn_softc *sc, int /* * Attach RNDIS _after_ NVS is attached. */ - error = hn_rndis_attach(sc); + error = hn_rndis_attach(sc, mtu); if (error) return (error); Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 07:16:26 2016 (r307612) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 07:24:32 2016 (r307613) @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -68,6 +70,18 @@ __FBSDID("$FreeBSD$"); #define HN_RNDIS_XFER_SIZE 2048 +#define HN_NDIS_TXCSUM_CAP_IP4 \ + (NDIS_TXCSUM_CAP_IP4 | NDIS_TXCSUM_CAP_IP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP4 \ + (NDIS_TXCSUM_CAP_TCP4 | NDIS_TXCSUM_CAP_TCP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP6 \ + (NDIS_TXCSUM_CAP_TCP6 | NDIS_TXCSUM_CAP_TCP6OPT | \ + NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_TXCSUM_CAP_UDP6 \ + (NDIS_TXCSUM_CAP_UDP6 | NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_LSOV2_CAP_IP6 \ + (NDIS_LSOV2_CAP_IP6EXT | NDIS_LSOV2_CAP_TCP6OPT) + /* * Forward declarations */ @@ -78,9 +92,14 @@ static void hv_rf_receive_data(struct hn static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); +static int hn_rndis_query2(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0, + size_t min_odlen); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); -static int hn_rndis_conf_offload(struct hn_softc *sc); +static int hn_rndis_conf_offload(struct hn_softc *sc, int mtu); +static int hn_rndis_query_hwcaps(struct hn_softc *sc, + struct ndis_offload *caps); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -624,6 +643,15 @@ static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0) { + + return (hn_rndis_query2(sc, oid, idata, idlen, odata, odlen0, *odlen0)); +} + +static int +hn_rndis_query2(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0, + size_t min_odlen) +{ struct rndis_query_req *req; const struct rndis_query_comp *comp; struct vmbus_xact *xact; @@ -661,7 +689,7 @@ hn_rndis_query(struct hn_softc *sc, uint memcpy(req + 1, idata, idlen); } - comp_len = sizeof(*comp) + odlen; + comp_len = sizeof(*comp) + min_odlen; comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, REMOTE_NDIS_QUERY_CMPLT); if (comp == NULL) { @@ -717,26 +745,44 @@ hn_rndis_get_rsscaps(struct hn_softc *sc size_t caps_len; int error; - /* - * Only NDIS 6.30+ is supported. - */ - KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, - ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); *rxr_cnt = 0; memset(&in, 0, sizeof(in)); in.ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_CAPS; - in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; - in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30) { + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_1; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE_6_0; + } else { + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + } caps_len = NDIS_RSS_CAPS_SIZE; - error = hn_rndis_query(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, - &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len); + error = hn_rndis_query2(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, + &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len, NDIS_RSS_CAPS_SIZE_6_0); if (error) return (error); - if (caps_len < NDIS_RSS_CAPS_SIZE_6_0) { - if_printf(sc->hn_ifp, "invalid NDIS RSS caps len %zu", - caps_len); + + /* + * Preliminary verification. + */ + if (caps.ndis_hdr.ndis_type != NDIS_OBJTYPE_RSS_CAPS) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps.ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_rev < NDIS_RSS_CAPS_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps.ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps.ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps.ndis_hdr.ndis_size < NDIS_RSS_CAPS_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps.ndis_hdr.ndis_size); return (EINVAL); } @@ -746,7 +792,7 @@ hn_rndis_get_rsscaps(struct hn_softc *sc } *rxr_cnt = caps.ndis_nrxr; - if (caps_len == NDIS_RSS_CAPS_SIZE) { + if (caps.ndis_hdr.ndis_size == NDIS_RSS_CAPS_SIZE) { if (bootverbose) { if_printf(sc->hn_ifp, "RSS indirect table size %u\n", caps.ndis_nind); @@ -806,12 +852,19 @@ done: } static int -hn_rndis_conf_offload(struct hn_softc *sc) +hn_rndis_conf_offload(struct hn_softc *sc, int mtu) { + struct ndis_offload hwcaps; struct ndis_offload_params params; - uint32_t caps; + uint32_t caps = 0; size_t paramsz; - int error; + int error, tso_maxsz, tso_minsg; + + error = hn_rndis_query_hwcaps(sc, &hwcaps); + if (error) { + if_printf(sc->hn_ifp, "hwcaps query failed: %d\n", error); + return (error); + } /* NOTE: 0 means "no change" */ memset(¶ms, 0, sizeof(params)); @@ -826,18 +879,136 @@ hn_rndis_conf_offload(struct hn_softc *s } params.ndis_hdr.ndis_size = paramsz; - caps = HN_CAP_IPCS | HN_CAP_TCP4CS | HN_CAP_TCP6CS; - params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; - if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { - caps |= HN_CAP_UDP4CS | HN_CAP_UDP6CS; - params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; - } - caps |= HN_CAP_TSO4; - params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; - /* XXX ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON */ + /* + * TSO4/TSO6 setup. + */ + tso_maxsz = IP_MAXPACKET; + tso_minsg = 2; + if (hwcaps.ndis_lsov2.ndis_ip4_encap & NDIS_OFFLOAD_ENCAP_8023) { + caps |= HN_CAP_TSO4; + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; + + if (hwcaps.ndis_lsov2.ndis_ip4_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip4_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip4_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip4_minsg; + } + if ((hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && + (hwcaps.ndis_lsov2.ndis_ip6_opts & HN_NDIS_LSOV2_CAP_IP6) == + HN_NDIS_LSOV2_CAP_IP6) { +#ifdef notyet + caps |= HN_CAP_TSO6; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON; + + if (hwcaps.ndis_lsov2.ndis_ip6_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip6_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip6_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip6_minsg; +#endif + } + sc->hn_ndis_tso_szmax = 0; + sc->hn_ndis_tso_sgmin = 0; + if (caps & (HN_CAP_TSO4 | HN_CAP_TSO6)) { + KASSERT(tso_maxsz <= IP_MAXPACKET, + ("invalid NDIS TSO maxsz %d", tso_maxsz)); + KASSERT(tso_minsg >= 2, + ("invalid NDIS TSO minsg %d", tso_minsg)); + if (tso_maxsz < tso_minsg * mtu) { + if_printf(sc->hn_ifp, "invalid NDIS TSO config: " + "maxsz %d, minsg %d, mtu %d; " + "disable TSO4 and TSO6\n", + tso_maxsz, tso_minsg, mtu); + caps &= ~(HN_CAP_TSO4 | HN_CAP_TSO6); + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_OFF; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_OFF; + } else { + sc->hn_ndis_tso_szmax = tso_maxsz; + sc->hn_ndis_tso_sgmin = tso_minsg; + if (bootverbose) { + if_printf(sc->hn_ifp, "NDIS TSO " + "szmax %d sgmin %d\n", + sc->hn_ndis_tso_szmax, + sc->hn_ndis_tso_sgmin); + } + } + } + + /* IPv4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_IP4) == + HN_NDIS_TXCSUM_CAP_IP4) { + caps |= HN_CAP_IPCS; + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_IP4) { + if (params.ndis_ip4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_TCP4) == + HN_NDIS_TXCSUM_CAP_TCP4) { + caps |= HN_CAP_TCP4CS; + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_TCP4) { + if (params.ndis_tcp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP4 checksum */ + if (hwcaps.ndis_csum.ndis_ip4_txcsum & NDIS_TXCSUM_CAP_UDP4) { + caps |= HN_CAP_UDP4CS; + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_UDP4) { + if (params.ndis_udp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_TCP6) == + HN_NDIS_TXCSUM_CAP_TCP6) { + caps |= HN_CAP_TCP6CS; + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_TCP6) { + if (params.ndis_tcp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_UDP6) == + HN_NDIS_TXCSUM_CAP_UDP6) { + caps |= HN_CAP_UDP6CS; + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_UDP6) { + if (params.ndis_udp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + if (bootverbose) { + if_printf(sc->hn_ifp, "offload csum: " + "ip4 %u, tcp4 %u, udp4 %u, tcp6 %u, udp6 %u\n", + params.ndis_ip4csum, + params.ndis_tcp4csum, + params.ndis_udp4csum, + params.ndis_tcp6csum, + params.ndis_udp6csum); + if_printf(sc->hn_ifp, "offload lsov2: ip4 %u, ip6 %u\n", + params.ndis_lsov2_ip4, + params.ndis_lsov2_ip6); + } error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); if (error) { @@ -994,8 +1165,92 @@ hn_rndis_halt(struct hn_softc *sc) return (0); } +static int +hn_rndis_query_hwcaps(struct hn_softc *sc, struct ndis_offload *caps) +{ + struct ndis_offload in; + size_t caps_len, size; + int error; + + memset(&in, 0, sizeof(in)); + in.ndis_hdr.ndis_type = NDIS_OBJTYPE_OFFLOAD; + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_3; + size = NDIS_OFFLOAD_SIZE; + } else if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_1) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_2; + size = NDIS_OFFLOAD_SIZE_6_1; + } else { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_1; + size = NDIS_OFFLOAD_SIZE_6_0; + } + in.ndis_hdr.ndis_size = size; + + caps_len = NDIS_OFFLOAD_SIZE; + error = hn_rndis_query2(sc, OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES, + &in, size, caps, &caps_len, NDIS_OFFLOAD_SIZE_6_0); + if (error) + return (error); + + /* + * Preliminary verification. + */ + if (caps->ndis_hdr.ndis_type != NDIS_OBJTYPE_OFFLOAD) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps->ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_rev < NDIS_OFFLOAD_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps->ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps->ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps->ndis_hdr.ndis_size < NDIS_OFFLOAD_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps->ndis_hdr.ndis_size); + return (EINVAL); + } + + if (bootverbose) { + /* + * NOTE: + * caps->ndis_hdr.ndis_size MUST be checked before accessing + * NDIS 6.1+ specific fields. + */ + if_printf(sc->hn_ifp, "hwcaps rev %u\n", + caps->ndis_hdr.ndis_rev); + + if_printf(sc->hn_ifp, "hwcaps csum: " + "ip4 tx 0x%x/0x%x rx 0x%x/0x%x, " + "ip6 tx 0x%x/0x%x rx 0x%x/0x%x\n", + caps->ndis_csum.ndis_ip4_txcsum, + caps->ndis_csum.ndis_ip4_txenc, + caps->ndis_csum.ndis_ip4_rxcsum, + caps->ndis_csum.ndis_ip4_rxenc, + caps->ndis_csum.ndis_ip6_txcsum, + caps->ndis_csum.ndis_ip6_txenc, + caps->ndis_csum.ndis_ip6_rxcsum, + caps->ndis_csum.ndis_ip6_rxenc); + if_printf(sc->hn_ifp, "hwcaps lsov2: " + "ip4 maxsz %u minsg %u encap 0x%x, " + "ip6 maxsz %u minsg %u encap 0x%x opts 0x%x\n", + caps->ndis_lsov2.ndis_ip4_maxsz, + caps->ndis_lsov2.ndis_ip4_minsg, + caps->ndis_lsov2.ndis_ip4_encap, + caps->ndis_lsov2.ndis_ip6_maxsz, + caps->ndis_lsov2.ndis_ip6_minsg, + caps->ndis_lsov2.ndis_ip6_encap, + caps->ndis_lsov2.ndis_ip6_opts); + } + return (0); +} + int -hn_rndis_attach(struct hn_softc *sc) +hn_rndis_attach(struct hn_softc *sc, int mtu) { int error; @@ -1010,7 +1265,7 @@ hn_rndis_attach(struct hn_softc *sc) * Configure NDIS offload settings. * XXX no offloading, if error happened? */ - hn_rndis_conf_offload(sc); + hn_rndis_conf_offload(sc, mtu); return (0); } Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 07:16:26 2016 (r307612) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 07:24:32 2016 (r307613) @@ -117,7 +117,7 @@ struct rndis_packet_msg; uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); -int hn_rndis_attach(struct hn_softc *sc); +int hn_rndis_attach(struct hn_softc *sc, int mtu); void hn_rndis_detach(struct hn_softc *sc); int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags); void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, Modified: stable/11/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/ndis.h Wed Oct 19 07:16:26 2016 (r307612) +++ stable/11/sys/dev/hyperv/netvsc/ndis.h Wed Oct 19 07:24:32 2016 (r307613) @@ -59,6 +59,7 @@ #define NDIS_OBJTYPE_DEFAULT 0x80 #define NDIS_OBJTYPE_RSS_CAPS 0x88 #define NDIS_OBJTYPE_RSS_PARAMS 0x89 +#define NDIS_OBJTYPE_OFFLOAD 0xa7 struct ndis_object_hdr { uint8_t ndis_type; /* NDIS_OBJTYPE_ */ @@ -205,6 +206,129 @@ struct ndis_rssprm_toeplitz { }; /* + * OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES + * ndis_type: NDIS_OBJTYPE_OFFLOAD + */ + +#define NDIS_OFFLOAD_ENCAP_NONE 0x0000 +#define NDIS_OFFLOAD_ENCAP_NULL 0x0001 +#define NDIS_OFFLOAD_ENCAP_8023 0x0002 +#define NDIS_OFFLOAD_ENCAP_8023PQ 0x0004 +#define NDIS_OFFLOAD_ENCAP_8023PQ_OOB 0x0008 +#define NDIS_OFFLOAD_ENCAP_RFC1483 0x0010 + +struct ndis_csum_offload { + uint32_t ndis_ip4_txenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_txcsum; +#define NDIS_TXCSUM_CAP_IP4OPT 0x001 +#define NDIS_TXCSUM_CAP_TCP4OPT 0x004 +#define NDIS_TXCSUM_CAP_TCP4 0x010 +#define NDIS_TXCSUM_CAP_UDP4 0x040 +#define NDIS_TXCSUM_CAP_IP4 0x100 + uint32_t ndis_ip4_rxenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_rxcsum; +#define NDIS_RXCSUM_CAP_IP4OPT 0x001 +#define NDIS_RXCSUM_CAP_TCP4OPT 0x004 +#define NDIS_RXCSUM_CAP_TCP4 0x010 +#define NDIS_RXCSUM_CAP_UDP4 0x040 +#define NDIS_RXCSUM_CAP_IP4 0x100 + uint32_t ndis_ip6_txenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_txcsum; +#define NDIS_TXCSUM_CAP_IP6EXT 0x001 +#define NDIS_TXCSUM_CAP_TCP6OPT 0x004 +#define NDIS_TXCSUM_CAP_TCP6 0x010 +#define NDIS_TXCSUM_CAP_UDP6 0x040 + uint32_t ndis_ip6_rxenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_rxcsum; +#define NDIS_RXCSUM_CAP_IP6EXT 0x001 +#define NDIS_RXCSUM_CAP_TCP6OPT 0x004 +#define NDIS_RXCSUM_CAP_TCP6 0x010 +#define NDIS_RXCSUM_CAP_UDP6 0x040 +}; + +struct ndis_lsov1_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_maxsize; + uint32_t ndis_minsegs; + uint32_t ndis_opts; +}; + +struct ndis_ipsecv1_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ah_esp; + uint32_t ndis_xport_tun; + uint32_t ndis_ip4_opts; + uint32_t ndis_flags; + uint32_t ndis_ip4_ah; + uint32_t ndis_ip4_esp; +}; + +struct ndis_lsov2_offload { + uint32_t ndis_ip4_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_maxsz; + uint32_t ndis_ip4_minsg; + uint32_t ndis_ip6_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_maxsz; + uint32_t ndis_ip6_minsg; + uint32_t ndis_ip6_opts; +#define NDIS_LSOV2_CAP_IP6EXT 0x001 +#define NDIS_LSOV2_CAP_TCP6OPT 0x004 +}; + +struct ndis_ipsecv2_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint16_t ndis_ip6; + uint16_t ndis_ip4opt; + uint16_t ndis_ip6ext; + uint16_t ndis_ah; + uint16_t ndis_esp; + uint16_t ndis_ah_esp; + uint16_t ndis_xport; + uint16_t ndis_tun; + uint16_t ndis_xport_tun; + uint16_t ndis_lso; + uint16_t ndis_extseq; + uint32_t ndis_udp_esp; + uint32_t ndis_auth; + uint32_t ndis_crypto; + uint32_t ndis_sa_caps; +}; + +struct ndis_rsc_offload { + uint16_t ndis_ip4; + uint16_t ndis_ip6; +}; + +struct ndis_encap_offload { + uint32_t ndis_flags; + uint32_t ndis_maxhdr; +}; + +struct ndis_offload { + struct ndis_object_hdr ndis_hdr; + struct ndis_csum_offload ndis_csum; + struct ndis_lsov1_offload ndis_lsov1; + struct ndis_ipsecv1_offload ndis_ipsecv1; + struct ndis_lsov2_offload ndis_lsov2; + uint32_t ndis_flags; + /* NDIS >= 6.1 */ + struct ndis_ipsecv2_offload ndis_ipsecv2; + /* NDIS >= 6.30 */ + struct ndis_rsc_offload ndis_rsc; + struct ndis_encap_offload ndis_encap_gre; +}; + +#define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload) +#define NDIS_OFFLOAD_SIZE_6_0 \ + __offsetof(struct ndis_offload, ndis_ipsecv2) +#define NDIS_OFFLOAD_SIZE_6_1 \ + __offsetof(struct ndis_offload, ndis_rsc) + +#define NDIS_OFFLOAD_REV_1 1 /* NDIS 6.0 */ +#define NDIS_OFFLOAD_REV_2 2 /* NDIS 6.1 */ +#define NDIS_OFFLOAD_REV_3 3 /* NDIS 6.30 */ + +/* * Per-packet-info */ Modified: stable/11/sys/net/rndis.h ============================================================================== --- stable/11/sys/net/rndis.h Wed Oct 19 07:16:26 2016 (r307612) +++ stable/11/sys/net/rndis.h Wed Oct 19 07:24:32 2016 (r307613) @@ -87,6 +87,7 @@ #define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C +#define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D #define RNDIS_MEDIUM_802_3 0x00000000 From owner-svn-src-stable@freebsd.org Wed Oct 19 07:27:47 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 399AAC1713D; Wed, 19 Oct 2016 07:27:47 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1129DCB8; Wed, 19 Oct 2016 07:27:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J7Rk1f019558; Wed, 19 Oct 2016 07:27:46 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J7RjvC019552; Wed, 19 Oct 2016 07:27:45 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190727.u9J7RjvC019552@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:27:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307614 - in stable/11/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:27:47 -0000 Author: sephe Date: Wed Oct 19 07:27:45 2016 New Revision: 307614 URL: https://svnweb.freebsd.org/changeset/base/307614 Log: MFC 307012,307013,307262 307012 hyperv/vmbus: Allow driver to inject synchronous task into channel taskq. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8208 307013 hyperv/hn: Rework link status support. This is the preamble for network device SR-IOV and NDIS_STATUS_NETWORK_CHANGE handling. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8209 307262 hyperv/hn: Management parts always need suspend and resume. Sponsored by: Microsoft Modified: stable/11/sys/dev/hyperv/include/vmbus.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/11/sys/dev/hyperv/include/vmbus.h Wed Oct 19 07:24:32 2016 (r307613) +++ stable/11/sys/dev/hyperv/include/vmbus.h Wed Oct 19 07:27:45 2016 (r307614) @@ -117,6 +117,7 @@ struct vmbus_chan_br { struct vmbus_channel; struct hyperv_guid; +struct task; typedef void (*vmbus_chan_callback_t)(struct vmbus_channel *, void *); @@ -134,6 +135,8 @@ int vmbus_chan_open_br(struct vmbus_cha int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); void vmbus_chan_intr_drain(struct vmbus_channel *chan); +void vmbus_chan_run_task(struct vmbus_channel *chan, + struct task *task); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 07:24:32 2016 (r307613) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 07:27:45 2016 (r307614) @@ -233,6 +233,10 @@ struct hn_softc { struct vmbus_xact_ctx *hn_xact; uint32_t hn_nvs_ver; + struct taskqueue *hn_mgmt_taskq; + struct taskqueue *hn_mgmt_taskq0; + struct task hn_link_task; + uint32_t hn_caps; /* HN_CAP_ */ uint32_t hn_flags; /* HN_FLAG_ */ void *hn_rxbuf; @@ -271,7 +275,6 @@ struct hn_softc { */ struct hn_send_ctx; -void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 07:24:32 2016 (r307613) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 07:27:45 2016 (r307614) @@ -334,6 +334,8 @@ static void hn_fixup_tx_data(struct hn_s static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); +static void hn_link_taskfunc(void *, int); +static void hn_suspend_mgmt_taskfunc(void *, int); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); @@ -349,7 +351,11 @@ static int hn_synth_attach(struct hn_sof static void hn_synth_detach(struct hn_softc *); static bool hn_tx_ring_pending(struct hn_tx_ring *); static void hn_suspend(struct hn_softc *); +static void hn_suspend_data(struct hn_softc *); +static void hn_suspend_mgmt(struct hn_softc *); static void hn_resume(struct hn_softc *); +static void hn_resume_data(struct hn_softc *); +static void hn_resume_mgmt(struct hn_softc *); static void hn_rx_drain(struct vmbus_channel *); static void hn_tx_resume(struct hn_softc *, int); static void hn_tx_ring_qflush(struct hn_tx_ring *); @@ -518,7 +524,6 @@ netvsc_attach(device_t dev) struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; uint8_t eaddr[ETHER_ADDR_LEN]; - uint32_t link_status; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; @@ -551,6 +556,15 @@ netvsc_attach(device_t dev) } /* + * Setup taskqueue for mangement tasks, e.g. link status. + */ + sc->hn_mgmt_taskq0 = taskqueue_create("hn_mgmt", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_mgmt_taskq0); + taskqueue_start_threads(&sc->hn_mgmt_taskq0, 1, PI_NET, "%s mgmt", + device_get_nameunit(dev)); + TASK_INIT(&sc->hn_link_task, 0, hn_link_taskfunc, sc); + + /* * Allocate ifnet and setup its name earlier, so that if_printf * can be used by functions, which will be called after * ether_ifattach(). @@ -621,12 +635,6 @@ netvsc_attach(device_t dev) if (error) goto failed; - error = hn_rndis_get_linkstatus(sc, &link_status); - if (error) - goto failed; - if (link_status == NDIS_MEDIA_STATE_CONNECTED) - sc->hn_carrier = 1; - error = hn_rndis_get_eaddr(sc, eaddr); if (error) goto failed; @@ -736,6 +744,12 @@ netvsc_attach(device_t dev) /* Inform the upper layer about the long frame support. */ ifp->if_hdrlen = sizeof(struct ether_vlan_header); + /* + * Kick off link status check. + */ + sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; + hn_link_status_update(sc); + return (0); failed: if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) @@ -755,6 +769,12 @@ netvsc_detach(device_t dev) if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) hn_stop(sc); + /* + * NOTE: + * hn_stop() only suspends data, so managment + * stuffs have to be suspended manually here. + */ + hn_suspend_mgmt(sc); hn_synth_detach(sc); } HN_UNLOCK(sc); @@ -767,6 +787,7 @@ netvsc_detach(device_t dev) if (sc->hn_tx_taskq != hn_tx_taskq) taskqueue_free(sc->hn_tx_taskq); + taskqueue_free(sc->hn_mgmt_taskq0); if (sc->hn_xact != NULL) vmbus_xact_ctx_destroy(sc->hn_xact); @@ -786,6 +807,36 @@ netvsc_shutdown(device_t dev) return (0); } +static void +hn_link_taskfunc(void *xsc, int pending __unused) +{ + struct hn_softc *sc = xsc; + struct ifnet *ifp = sc->hn_ifp; + uint32_t link_status; + int error; + + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) { + /* XXX what to do? */ + return; + } + + if (link_status == NDIS_MEDIA_STATE_CONNECTED) + sc->hn_carrier = 1; + else + sc->hn_carrier = 0; + if_link_state_change(ifp, + sc->hn_carrier ? LINK_STATE_UP : LINK_STATE_DOWN); +} + +void +hn_link_status_update(struct hn_softc *sc) +{ + + if (sc->hn_mgmt_taskq != NULL) + taskqueue_enqueue(sc->hn_mgmt_taskq, &sc->hn_link_task); +} + static __inline int hn_txdesc_dmamap_load(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head, bus_dma_segment_t *segs, int *nsegs) @@ -1311,19 +1362,6 @@ hn_start_locked(struct hn_tx_ring *txr, } /* - * Link up/down notification - */ -void -netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status) -{ - if (status == 1) { - sc->hn_carrier = 1; - } else { - sc->hn_carrier = 0; - } -} - -/* * Append the specified data to the indicated mbuf chain, * Extend the mbuf chain if the new data does not fit in * existing space. @@ -1653,8 +1691,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); #endif - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_suspend(sc); + /* + * Suspend this interface before the synthetic parts + * are ripped. + */ + hn_suspend(sc); /* * Detach the synthetics parts, i.e. NVS and RNDIS. @@ -1672,9 +1713,10 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_chim_size(sc, sc->hn_chim_szmax); hn_set_tso_maxsize(sc, hn_tso_maxlen, ifr->ifr_mtu); - /* All done! Resume now. */ - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_resume(sc); + /* + * All done! Resume the interface now. + */ + hn_resume(sc); HN_UNLOCK(sc); break; @@ -1801,9 +1843,9 @@ hn_stop(struct hn_softc *sc) KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, ("synthetic parts were not attached")); - /* Clear RUNNING bit _before_ hn_suspend() */ + /* Clear RUNNING bit _before_ hn_suspend_data() */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); - hn_suspend(sc); + hn_suspend_data(sc); /* Clear OACTIVE bit. */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); @@ -1896,9 +1938,6 @@ hn_init_locked(struct hn_softc *sc) /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); - - /* TODO: check RNDIS link status. */ - if_link_state_change(ifp, LINK_STATE_UP); } static void @@ -3600,7 +3639,7 @@ hn_rx_drain(struct vmbus_channel *chan) } static void -hn_suspend(struct hn_softc *sc) +hn_suspend_data(struct hn_softc *sc) { struct vmbus_channel **subch = NULL; int i, nsubch; @@ -3654,6 +3693,42 @@ hn_suspend(struct hn_softc *sc) } static void +hn_suspend_mgmt_taskfunc(void *xsc, int pending __unused) +{ + + ((struct hn_softc *)xsc)->hn_mgmt_taskq = NULL; +} + +static void +hn_suspend_mgmt(struct hn_softc *sc) +{ + struct task task; + + HN_LOCK_ASSERT(sc); + + /* + * Make sure that hn_mgmt_taskq0 can nolonger be accessed + * through hn_mgmt_taskq. + */ + TASK_INIT(&task, 0, hn_suspend_mgmt_taskfunc, sc); + vmbus_chan_run_task(sc->hn_prichan, &task); + + /* + * Make sure that all pending management tasks are completed. + */ + taskqueue_drain_all(sc->hn_mgmt_taskq0); +} + +static void +hn_suspend(struct hn_softc *sc) +{ + + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_suspend_data(sc); + hn_suspend_mgmt(sc); +} + +static void hn_tx_resume(struct hn_softc *sc, int tx_ring_cnt) { int i; @@ -3671,7 +3746,7 @@ hn_tx_resume(struct hn_softc *sc, int tx } static void -hn_resume(struct hn_softc *sc) +hn_resume_data(struct hn_softc *sc) { int i; @@ -3685,7 +3760,8 @@ hn_resume(struct hn_softc *sc) /* * Make sure to clear suspend status on "all" TX rings, - * since hn_tx_ring_inuse can be changed after hn_suspend(). + * since hn_tx_ring_inuse can be changed after + * hn_suspend_data(). */ hn_tx_resume(sc, sc->hn_tx_ring_cnt); @@ -3713,6 +3789,26 @@ hn_resume(struct hn_softc *sc) } static void +hn_resume_mgmt(struct hn_softc *sc) +{ + + /* + * Kick off link status check. + */ + sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; + hn_link_status_update(sc); +} + +static void +hn_resume(struct hn_softc *sc) +{ + + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_resume_data(sc); + hn_resume_mgmt(sc); +} + +static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { const struct hn_nvs_hdr *hdr; Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 07:24:32 2016 (r307613) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 07:27:45 2016 (r307614) @@ -167,11 +167,8 @@ hv_rf_receive_indicate_status(struct hn_ switch (msg->rm_status) { case RNDIS_STATUS_MEDIA_CONNECT: - netvsc_linkstatus_callback(sc, 1); - break; - case RNDIS_STATUS_MEDIA_DISCONNECT: - netvsc_linkstatus_callback(sc, 0); + hn_link_status_update(sc); break; case RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG: Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 07:24:32 2016 (r307613) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 07:27:45 2016 (r307614) @@ -138,6 +138,7 @@ void hn_nvs_sent_xact(struct hn_send_ct int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_recvinfo *info); void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); +void hn_link_status_update(struct hn_softc *sc); extern struct hn_send_ctx hn_send_ctx_none; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 07:24:32 2016 (r307613) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 07:27:45 2016 (r307614) @@ -1713,3 +1713,11 @@ vmbus_chan_rx_empty(const struct vmbus_c return (vmbus_rxbr_empty(&chan->ch_rxbr)); } + +void +vmbus_chan_run_task(struct vmbus_channel *chan, struct task *task) +{ + + taskqueue_enqueue(chan->ch_tq, task); + taskqueue_drain(chan->ch_tq, task); +} From owner-svn-src-stable@freebsd.org Wed Oct 19 07:33:44 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55592C173DC; Wed, 19 Oct 2016 07:33:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 245D01ED; Wed, 19 Oct 2016 07:33:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J7Xh5b023128; Wed, 19 Oct 2016 07:33:43 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J7Xh98023127; Wed, 19 Oct 2016 07:33:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190733.u9J7Xh98023127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:33:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307615 - stable/11/sys/net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:33:44 -0000 Author: sephe Date: Wed Oct 19 07:33:43 2016 New Revision: 307615 URL: https://svnweb.freebsd.org/changeset/base/307615 Log: MFC 307078 ifnet: Use if_link_state snapshot to invoke ifnet_link_event So that everyone in this task have consistent view of link state. Reviewed by: ae Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8214 Modified: stable/11/sys/net/if.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if.c ============================================================================== --- stable/11/sys/net/if.c Wed Oct 19 07:27:45 2016 (r307614) +++ stable/11/sys/net/if.c Wed Oct 19 07:33:43 2016 (r307615) @@ -2206,7 +2206,7 @@ do_link_state_change(void *arg, int pend if (log_link_state_change) log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname, (link_state == LINK_STATE_UP) ? "UP" : "DOWN" ); - EVENTHANDLER_INVOKE(ifnet_link_event, ifp, ifp->if_link_state); + EVENTHANDLER_INVOKE(ifnet_link_event, ifp, link_state); CURVNET_RESTORE(); } From owner-svn-src-stable@freebsd.org Wed Oct 19 07:43:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20365C17929; Wed, 19 Oct 2016 07:43:41 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E254CC1F; Wed, 19 Oct 2016 07:43:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J7hdIH026846; Wed, 19 Oct 2016 07:43:39 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J7hdOq026845; Wed, 19 Oct 2016 07:43:39 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190743.u9J7hdOq026845@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:43:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307617 - stable/11/sys/dev/hyperv/storvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:43:41 -0000 Author: sephe Date: Wed Oct 19 07:43:39 2016 New Revision: 307617 URL: https://svnweb.freebsd.org/changeset/base/307617 Log: MFC 307261 hyperv/stor: Fix off-by-one bug; this brings back TRIM support. Submitted by: Hongjiang Zhang Reported by: Lili Deng Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8238 Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 19 07:40:51 2016 (r307616) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 19 07:43:39 2016 (r307617) @@ -2210,7 +2210,7 @@ storvsc_io_done(struct hv_storvsc_reques resp_buf[3], resp_buf[4]); } if (vm_srb->srb_status == SRB_STATUS_SUCCESS && - data_len > SHORT_INQUIRY_LENGTH) { + data_len >= SHORT_INQUIRY_LENGTH) { char vendor[16]; cam_strvis(vendor, inq_data->vendor, From owner-svn-src-stable@freebsd.org Wed Oct 19 07:46:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90704C179E1; Wed, 19 Oct 2016 07:46:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5759FDD7; Wed, 19 Oct 2016 07:46:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J7kKPX027017; Wed, 19 Oct 2016 07:46:20 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J7kKp2027016; Wed, 19 Oct 2016 07:46:20 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190746.u9J7kKp2027016@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 07:46:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307618 - stable/11/sys/dev/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 07:46:21 -0000 Author: sephe Date: Wed Oct 19 07:46:20 2016 New Revision: 307618 URL: https://svnweb.freebsd.org/changeset/base/307618 Log: MFC 307263 hyperv/vmbus: Add __FBSDID Sponsored by: Microsoft Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_br.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_br.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_br.c Wed Oct 19 07:43:39 2016 (r307617) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_br.c Wed Oct 19 07:46:20 2016 (r307618) @@ -26,6 +26,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include From owner-svn-src-stable@freebsd.org Wed Oct 19 08:23:56 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30477C18844; Wed, 19 Oct 2016 08:23:56 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A4A09C9; Wed, 19 Oct 2016 08:23:55 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J8NtEO042123; Wed, 19 Oct 2016 08:23:55 GMT (envelope-from gahr@FreeBSD.org) Received: (from gahr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J8NttB042122; Wed, 19 Oct 2016 08:23:55 GMT (envelope-from gahr@FreeBSD.org) Message-Id: <201610190823.u9J8NttB042122@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gahr set sender to gahr@FreeBSD.org using -f From: Pietro Cerutti Date: Wed, 19 Oct 2016 08:23:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307619 - stable/11/usr.bin/ul X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 08:23:56 -0000 Author: gahr (ports committer) Date: Wed Oct 19 08:23:54 2016 New Revision: 307619 URL: https://svnweb.freebsd.org/changeset/base/307619 Log: MFC r302558: Do not truncate lines longer than 512 chars. PR: 210344 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6881 Modified: stable/11/usr.bin/ul/ul.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/ul/ul.c ============================================================================== --- stable/11/usr.bin/ul/ul.c Wed Oct 19 07:46:20 2016 (r307618) +++ stable/11/usr.bin/ul/ul.c Wed Oct 19 08:23:54 2016 (r307619) @@ -78,7 +78,9 @@ struct CHAR { int c_width; /* width or -1 if multi-column char. filler */ } ; -static struct CHAR obuf[MAXBUF]; +static struct CHAR sobuf[MAXBUF]; /* static output buffer */ +static struct CHAR *obuf = sobuf; +static int buflen = MAXBUF; static int col, maxcol; static int mode; static int halfpos; @@ -151,6 +153,9 @@ main(int argc, char **argv) else filter(f); } + if (obuf != sobuf) { + free(obuf); + } exit(0); } @@ -166,128 +171,148 @@ filter(FILE *f) { wint_t c; int i, w; + int copy; + + copy = 0; + + while ((c = getwc(f)) != WEOF) { + if (col == buflen) { + if (obuf == sobuf) { + obuf = NULL; + copy = 1; + } + obuf = realloc(obuf, sizeof(*obuf) * 2 * buflen); + if (obuf == NULL) { + obuf = sobuf; + break; + } else if (copy) { + memcpy(obuf, sobuf, sizeof(*obuf) * buflen); + copy = 0; + } + bzero((char *)(obuf + buflen), sizeof(*obuf) * buflen); + buflen *= 2; + } + switch(c) { + case '\b': + if (col > 0) + col--; + continue; - while ((c = getwc(f)) != WEOF && col < MAXBUF) switch(c) { + case '\t': + col = (col+8) & ~07; + if (col > maxcol) + maxcol = col; + continue; - case '\b': - if (col > 0) - col--; - continue; - - case '\t': - col = (col+8) & ~07; - if (col > maxcol) - maxcol = col; - continue; - - case '\r': - col = 0; - continue; - - case SO: - mode |= ALTSET; - continue; - - case SI: - mode &= ~ALTSET; - continue; - - case IESC: - switch (c = getwc(f)) { - - case HREV: - if (halfpos == 0) { - mode |= SUPERSC; - halfpos--; - } else if (halfpos > 0) { - mode &= ~SUBSC; - halfpos--; - } else { - halfpos = 0; - reverse(); - } + case '\r': + col = 0; continue; - case HFWD: - if (halfpos == 0) { - mode |= SUBSC; - halfpos++; - } else if (halfpos < 0) { - mode &= ~SUPERSC; - halfpos++; - } else { - halfpos = 0; - fwd(); - } + case SO: + mode |= ALTSET; continue; - case FREV: - reverse(); + case SI: + mode &= ~ALTSET; continue; - default: - errx(1, "unknown escape sequence in input: %o, %o", IESC, c); - } - continue; + case IESC: + switch (c = getwc(f)) { - case '_': - if (obuf[col].c_char || obuf[col].c_width < 0) { - while (col > 0 && obuf[col].c_width < 0) - col--; - w = obuf[col].c_width; - for (i = 0; i < w; i++) - obuf[col++].c_mode |= UNDERL | mode; + case HREV: + if (halfpos == 0) { + mode |= SUPERSC; + halfpos--; + } else if (halfpos > 0) { + mode &= ~SUBSC; + halfpos--; + } else { + halfpos = 0; + reverse(); + } + continue; + + case HFWD: + if (halfpos == 0) { + mode |= SUBSC; + halfpos++; + } else if (halfpos < 0) { + mode &= ~SUPERSC; + halfpos++; + } else { + halfpos = 0; + fwd(); + } + continue; + + case FREV: + reverse(); + continue; + + default: + errx(1, "unknown escape sequence in input: %o, %o", IESC, c); + } + continue; + + case '_': + if (obuf[col].c_char || obuf[col].c_width < 0) { + while (col > 0 && obuf[col].c_width < 0) + col--; + w = obuf[col].c_width; + for (i = 0; i < w; i++) + obuf[col++].c_mode |= UNDERL | mode; + if (col > maxcol) + maxcol = col; + continue; + } + obuf[col].c_char = '_'; + obuf[col].c_width = 1; + /* FALLTHROUGH */ + case ' ': + col++; if (col > maxcol) maxcol = col; continue; - } - obuf[col].c_char = '_'; - obuf[col].c_width = 1; - /* FALLTHROUGH */ - case ' ': - col++; - if (col > maxcol) - maxcol = col; - continue; - case '\n': - flushln(); - continue; + case '\n': + flushln(); + continue; - case '\f': - flushln(); - putwchar('\f'); - continue; + case '\f': + flushln(); + putwchar('\f'); + continue; - default: - if ((w = wcwidth(c)) <= 0) /* non printing */ + default: + if ((w = wcwidth(c)) <= 0) /* non printing */ + continue; + if (obuf[col].c_char == '\0') { + obuf[col].c_char = c; + for (i = 0; i < w; i++) + obuf[col + i].c_mode = mode; + obuf[col].c_width = w; + for (i = 1; i < w; i++) + obuf[col + i].c_width = -1; + } else if (obuf[col].c_char == '_') { + obuf[col].c_char = c; + for (i = 0; i < w; i++) + obuf[col + i].c_mode |= UNDERL|mode; + obuf[col].c_width = w; + for (i = 1; i < w; i++) + obuf[col + i].c_width = -1; + } else if ((wint_t)obuf[col].c_char == c) { + for (i = 0; i < w; i++) + obuf[col + i].c_mode |= BOLD|mode; + } else { + w = obuf[col].c_width; + for (i = 0; i < w; i++) + obuf[col + i].c_mode = mode; + } + col += w; + if (col > maxcol) + maxcol = col; continue; - if (obuf[col].c_char == '\0') { - obuf[col].c_char = c; - for (i = 0; i < w; i++) - obuf[col + i].c_mode = mode; - obuf[col].c_width = w; - for (i = 1; i < w; i++) - obuf[col + i].c_width = -1; - } else if (obuf[col].c_char == '_') { - obuf[col].c_char = c; - for (i = 0; i < w; i++) - obuf[col + i].c_mode |= UNDERL|mode; - obuf[col].c_width = w; - for (i = 1; i < w; i++) - obuf[col + i].c_width = -1; - } else if ((wint_t)obuf[col].c_char == c) { - for (i = 0; i < w; i++) - obuf[col + i].c_mode |= BOLD|mode; - } else { - w = obuf[col].c_width; - for (i = 0; i < w; i++) - obuf[col + i].c_mode = mode; } - col += w; - if (col > maxcol) - maxcol = col; - continue; } if (ferror(f)) err(1, NULL); @@ -405,7 +430,7 @@ static void initbuf(void) { - bzero((char *)obuf, sizeof (obuf)); /* depends on NORMAL == 0 */ + bzero((char *)obuf, buflen * sizeof(*obuf)); /* depends on NORMAL == 0 */ col = 0; maxcol = 0; mode &= ALTSET; From owner-svn-src-stable@freebsd.org Wed Oct 19 08:32:26 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C992C18B0E; Wed, 19 Oct 2016 08:32:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC8ECF1C; Wed, 19 Oct 2016 08:32:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J8WP1Y045793; Wed, 19 Oct 2016 08:32:25 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J8WOOG045787; Wed, 19 Oct 2016 08:32:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190832.u9J8WOOG045787@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 08:32:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307620 - in stable/10/sys: dev/hyperv/netvsc net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 08:32:26 -0000 Author: sephe Date: Wed Oct 19 08:32:24 2016 New Revision: 307620 URL: https://svnweb.freebsd.org/changeset/base/307620 Log: MFC 306936-306939 306936 hyperv/hn: Fix checksum offload settings The _correct_ way to identify the supported checksum offloading and TSO parameters is to query OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8088 306937 hyperv/hn: Fix if_hw_tsomax setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8089 306938 hyperv/hn: Generalize RSS capabilities query. - Support NDIS < 6.30. - Stringent response checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8090 306939 hyperv/hn: Suffix NDIS offload size with NDIS version. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8091 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/netvsc/ndis.h stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 08:23:54 2016 (r307619) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 08:32:24 2016 (r307620) @@ -245,6 +245,8 @@ struct hn_softc { uint32_t hn_rndis_rid; uint32_t hn_ndis_ver; + int hn_ndis_tso_szmax; + int hn_ndis_tso_sgmin; struct ndis_rssprm_toeplitz hn_rss; }; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 08:23:54 2016 (r307619) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 08:32:24 2016 (r307620) @@ -232,7 +232,7 @@ SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosti "when csum info is missing (global setting)"); /* Limit TSO burst size */ -static int hn_tso_maxlen = 0; +static int hn_tso_maxlen = IP_MAXPACKET; SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, &hn_tso_maxlen, 0, "TSO burst limit"); @@ -340,6 +340,7 @@ static int hn_encap(struct hn_tx_ring *, static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_chim_size(struct hn_softc *, int); +static void hn_set_tso_maxsize(struct hn_softc *, int, int); static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); static void hn_chan_detach(struct hn_softc *, struct vmbus_channel *); static int hn_attach_subchans(struct hn_softc *); @@ -535,7 +536,6 @@ netvsc_attach(device_t dev) uint32_t link_status; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; - int tso_maxlen; sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); @@ -736,18 +736,16 @@ netvsc_attach(device_t dev) /* Enable all available capabilities by default. */ ifp->if_capenable = ifp->if_capabilities; - tso_maxlen = hn_tso_maxlen; - if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) - tso_maxlen = IP_MAXPACKET; - ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; - ifp->if_hw_tsomaxsegsize = PAGE_SIZE; - ifp->if_hw_tsomax = tso_maxlen - - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { + hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); + ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; + ifp->if_hw_tsomaxsegsize = PAGE_SIZE; + } ether_ifattach(ifp, eaddr); - if (bootverbose) { - if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, + if ((ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) && bootverbose) { + if_printf(ifp, "TSO segcnt %u segsz %u\n", ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); } @@ -1692,6 +1690,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); + hn_set_tso_maxsize(sc, hn_tso_maxlen, ifr->ifr_mtu); /* All done! Resume now. */ if (ifp->if_drv_flags & IFF_DRV_RUNNING) @@ -2939,6 +2938,34 @@ hn_set_chim_size(struct hn_softc *sc, in } static void +hn_set_tso_maxsize(struct hn_softc *sc, int tso_maxlen, int mtu) +{ + struct ifnet *ifp = sc->hn_ifp; + int tso_minlen; + + if ((ifp->if_capabilities & (IFCAP_TSO4 | IFCAP_TSO6)) == 0) + return; + + KASSERT(sc->hn_ndis_tso_sgmin >= 2, + ("invalid NDIS tso sgmin %d", sc->hn_ndis_tso_sgmin)); + tso_minlen = sc->hn_ndis_tso_sgmin * mtu; + + KASSERT(sc->hn_ndis_tso_szmax >= tso_minlen && + sc->hn_ndis_tso_szmax <= IP_MAXPACKET, + ("invalid NDIS tso szmax %d", sc->hn_ndis_tso_szmax)); + + if (tso_maxlen < tso_minlen) + tso_maxlen = tso_minlen; + else if (tso_maxlen > IP_MAXPACKET) + tso_maxlen = IP_MAXPACKET; + if (tso_maxlen > sc->hn_ndis_tso_szmax) + tso_maxlen = sc->hn_ndis_tso_szmax; + ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + if (bootverbose) + if_printf(ifp, "TSO size max %u\n", ifp->if_hw_tsomax); +} + +static void hn_fixup_tx_data(struct hn_softc *sc) { uint64_t csum_assist; @@ -3444,7 +3471,7 @@ hn_synth_attach(struct hn_softc *sc, int /* * Attach RNDIS _after_ NVS is attached. */ - error = hn_rndis_attach(sc); + error = hn_rndis_attach(sc, mtu); if (error) return (error); Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 08:23:54 2016 (r307619) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 08:32:24 2016 (r307620) @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -69,6 +71,18 @@ __FBSDID("$FreeBSD$"); #define HN_RNDIS_XFER_SIZE 2048 +#define HN_NDIS_TXCSUM_CAP_IP4 \ + (NDIS_TXCSUM_CAP_IP4 | NDIS_TXCSUM_CAP_IP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP4 \ + (NDIS_TXCSUM_CAP_TCP4 | NDIS_TXCSUM_CAP_TCP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP6 \ + (NDIS_TXCSUM_CAP_TCP6 | NDIS_TXCSUM_CAP_TCP6OPT | \ + NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_TXCSUM_CAP_UDP6 \ + (NDIS_TXCSUM_CAP_UDP6 | NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_LSOV2_CAP_IP6 \ + (NDIS_LSOV2_CAP_IP6EXT | NDIS_LSOV2_CAP_TCP6OPT) + /* * Forward declarations */ @@ -79,9 +93,14 @@ static void hv_rf_receive_data(struct hn static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); +static int hn_rndis_query2(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0, + size_t min_odlen); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); -static int hn_rndis_conf_offload(struct hn_softc *sc); +static int hn_rndis_conf_offload(struct hn_softc *sc, int mtu); +static int hn_rndis_query_hwcaps(struct hn_softc *sc, + struct ndis_offload *caps); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -625,6 +644,15 @@ static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0) { + + return (hn_rndis_query2(sc, oid, idata, idlen, odata, odlen0, *odlen0)); +} + +static int +hn_rndis_query2(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0, + size_t min_odlen) +{ struct rndis_query_req *req; const struct rndis_query_comp *comp; struct vmbus_xact *xact; @@ -662,7 +690,7 @@ hn_rndis_query(struct hn_softc *sc, uint memcpy(req + 1, idata, idlen); } - comp_len = sizeof(*comp) + odlen; + comp_len = sizeof(*comp) + min_odlen; comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, REMOTE_NDIS_QUERY_CMPLT); if (comp == NULL) { @@ -718,26 +746,44 @@ hn_rndis_get_rsscaps(struct hn_softc *sc size_t caps_len; int error; - /* - * Only NDIS 6.30+ is supported. - */ - KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, - ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); *rxr_cnt = 0; memset(&in, 0, sizeof(in)); in.ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_CAPS; - in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; - in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30) { + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_1; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE_6_0; + } else { + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + } caps_len = NDIS_RSS_CAPS_SIZE; - error = hn_rndis_query(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, - &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len); + error = hn_rndis_query2(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, + &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len, NDIS_RSS_CAPS_SIZE_6_0); if (error) return (error); - if (caps_len < NDIS_RSS_CAPS_SIZE_6_0) { - if_printf(sc->hn_ifp, "invalid NDIS RSS caps len %zu", - caps_len); + + /* + * Preliminary verification. + */ + if (caps.ndis_hdr.ndis_type != NDIS_OBJTYPE_RSS_CAPS) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps.ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_rev < NDIS_RSS_CAPS_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps.ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps.ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps.ndis_hdr.ndis_size < NDIS_RSS_CAPS_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps.ndis_hdr.ndis_size); return (EINVAL); } @@ -747,7 +793,7 @@ hn_rndis_get_rsscaps(struct hn_softc *sc } *rxr_cnt = caps.ndis_nrxr; - if (caps_len == NDIS_RSS_CAPS_SIZE) { + if (caps.ndis_hdr.ndis_size == NDIS_RSS_CAPS_SIZE) { if (bootverbose) { if_printf(sc->hn_ifp, "RSS indirect table size %u\n", caps.ndis_nind); @@ -807,12 +853,19 @@ done: } static int -hn_rndis_conf_offload(struct hn_softc *sc) +hn_rndis_conf_offload(struct hn_softc *sc, int mtu) { + struct ndis_offload hwcaps; struct ndis_offload_params params; - uint32_t caps; + uint32_t caps = 0; size_t paramsz; - int error; + int error, tso_maxsz, tso_minsg; + + error = hn_rndis_query_hwcaps(sc, &hwcaps); + if (error) { + if_printf(sc->hn_ifp, "hwcaps query failed: %d\n", error); + return (error); + } /* NOTE: 0 means "no change" */ memset(¶ms, 0, sizeof(params)); @@ -827,18 +880,136 @@ hn_rndis_conf_offload(struct hn_softc *s } params.ndis_hdr.ndis_size = paramsz; - caps = HN_CAP_IPCS | HN_CAP_TCP4CS | HN_CAP_TCP6CS; - params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; - if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { - caps |= HN_CAP_UDP4CS | HN_CAP_UDP6CS; - params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; - } - caps |= HN_CAP_TSO4; - params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; - /* XXX ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON */ + /* + * TSO4/TSO6 setup. + */ + tso_maxsz = IP_MAXPACKET; + tso_minsg = 2; + if (hwcaps.ndis_lsov2.ndis_ip4_encap & NDIS_OFFLOAD_ENCAP_8023) { + caps |= HN_CAP_TSO4; + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; + + if (hwcaps.ndis_lsov2.ndis_ip4_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip4_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip4_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip4_minsg; + } + if ((hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && + (hwcaps.ndis_lsov2.ndis_ip6_opts & HN_NDIS_LSOV2_CAP_IP6) == + HN_NDIS_LSOV2_CAP_IP6) { +#ifdef notyet + caps |= HN_CAP_TSO6; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON; + + if (hwcaps.ndis_lsov2.ndis_ip6_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip6_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip6_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip6_minsg; +#endif + } + sc->hn_ndis_tso_szmax = 0; + sc->hn_ndis_tso_sgmin = 0; + if (caps & (HN_CAP_TSO4 | HN_CAP_TSO6)) { + KASSERT(tso_maxsz <= IP_MAXPACKET, + ("invalid NDIS TSO maxsz %d", tso_maxsz)); + KASSERT(tso_minsg >= 2, + ("invalid NDIS TSO minsg %d", tso_minsg)); + if (tso_maxsz < tso_minsg * mtu) { + if_printf(sc->hn_ifp, "invalid NDIS TSO config: " + "maxsz %d, minsg %d, mtu %d; " + "disable TSO4 and TSO6\n", + tso_maxsz, tso_minsg, mtu); + caps &= ~(HN_CAP_TSO4 | HN_CAP_TSO6); + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_OFF; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_OFF; + } else { + sc->hn_ndis_tso_szmax = tso_maxsz; + sc->hn_ndis_tso_sgmin = tso_minsg; + if (bootverbose) { + if_printf(sc->hn_ifp, "NDIS TSO " + "szmax %d sgmin %d\n", + sc->hn_ndis_tso_szmax, + sc->hn_ndis_tso_sgmin); + } + } + } + + /* IPv4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_IP4) == + HN_NDIS_TXCSUM_CAP_IP4) { + caps |= HN_CAP_IPCS; + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_IP4) { + if (params.ndis_ip4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_TCP4) == + HN_NDIS_TXCSUM_CAP_TCP4) { + caps |= HN_CAP_TCP4CS; + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_TCP4) { + if (params.ndis_tcp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP4 checksum */ + if (hwcaps.ndis_csum.ndis_ip4_txcsum & NDIS_TXCSUM_CAP_UDP4) { + caps |= HN_CAP_UDP4CS; + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_UDP4) { + if (params.ndis_udp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_TCP6) == + HN_NDIS_TXCSUM_CAP_TCP6) { + caps |= HN_CAP_TCP6CS; + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_TCP6) { + if (params.ndis_tcp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_UDP6) == + HN_NDIS_TXCSUM_CAP_UDP6) { + caps |= HN_CAP_UDP6CS; + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_UDP6) { + if (params.ndis_udp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + if (bootverbose) { + if_printf(sc->hn_ifp, "offload csum: " + "ip4 %u, tcp4 %u, udp4 %u, tcp6 %u, udp6 %u\n", + params.ndis_ip4csum, + params.ndis_tcp4csum, + params.ndis_udp4csum, + params.ndis_tcp6csum, + params.ndis_udp6csum); + if_printf(sc->hn_ifp, "offload lsov2: ip4 %u, ip6 %u\n", + params.ndis_lsov2_ip4, + params.ndis_lsov2_ip6); + } error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); if (error) { @@ -995,8 +1166,92 @@ hn_rndis_halt(struct hn_softc *sc) return (0); } +static int +hn_rndis_query_hwcaps(struct hn_softc *sc, struct ndis_offload *caps) +{ + struct ndis_offload in; + size_t caps_len, size; + int error; + + memset(&in, 0, sizeof(in)); + in.ndis_hdr.ndis_type = NDIS_OBJTYPE_OFFLOAD; + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_3; + size = NDIS_OFFLOAD_SIZE; + } else if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_1) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_2; + size = NDIS_OFFLOAD_SIZE_6_1; + } else { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_1; + size = NDIS_OFFLOAD_SIZE_6_0; + } + in.ndis_hdr.ndis_size = size; + + caps_len = NDIS_OFFLOAD_SIZE; + error = hn_rndis_query2(sc, OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES, + &in, size, caps, &caps_len, NDIS_OFFLOAD_SIZE_6_0); + if (error) + return (error); + + /* + * Preliminary verification. + */ + if (caps->ndis_hdr.ndis_type != NDIS_OBJTYPE_OFFLOAD) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps->ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_rev < NDIS_OFFLOAD_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps->ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps->ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps->ndis_hdr.ndis_size < NDIS_OFFLOAD_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps->ndis_hdr.ndis_size); + return (EINVAL); + } + + if (bootverbose) { + /* + * NOTE: + * caps->ndis_hdr.ndis_size MUST be checked before accessing + * NDIS 6.1+ specific fields. + */ + if_printf(sc->hn_ifp, "hwcaps rev %u\n", + caps->ndis_hdr.ndis_rev); + + if_printf(sc->hn_ifp, "hwcaps csum: " + "ip4 tx 0x%x/0x%x rx 0x%x/0x%x, " + "ip6 tx 0x%x/0x%x rx 0x%x/0x%x\n", + caps->ndis_csum.ndis_ip4_txcsum, + caps->ndis_csum.ndis_ip4_txenc, + caps->ndis_csum.ndis_ip4_rxcsum, + caps->ndis_csum.ndis_ip4_rxenc, + caps->ndis_csum.ndis_ip6_txcsum, + caps->ndis_csum.ndis_ip6_txenc, + caps->ndis_csum.ndis_ip6_rxcsum, + caps->ndis_csum.ndis_ip6_rxenc); + if_printf(sc->hn_ifp, "hwcaps lsov2: " + "ip4 maxsz %u minsg %u encap 0x%x, " + "ip6 maxsz %u minsg %u encap 0x%x opts 0x%x\n", + caps->ndis_lsov2.ndis_ip4_maxsz, + caps->ndis_lsov2.ndis_ip4_minsg, + caps->ndis_lsov2.ndis_ip4_encap, + caps->ndis_lsov2.ndis_ip6_maxsz, + caps->ndis_lsov2.ndis_ip6_minsg, + caps->ndis_lsov2.ndis_ip6_encap, + caps->ndis_lsov2.ndis_ip6_opts); + } + return (0); +} + int -hn_rndis_attach(struct hn_softc *sc) +hn_rndis_attach(struct hn_softc *sc, int mtu) { int error; @@ -1011,7 +1266,7 @@ hn_rndis_attach(struct hn_softc *sc) * Configure NDIS offload settings. * XXX no offloading, if error happened? */ - hn_rndis_conf_offload(sc); + hn_rndis_conf_offload(sc, mtu); return (0); } Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 08:23:54 2016 (r307619) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 08:32:24 2016 (r307620) @@ -117,7 +117,7 @@ struct rndis_packet_msg; uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); -int hn_rndis_attach(struct hn_softc *sc); +int hn_rndis_attach(struct hn_softc *sc, int mtu); void hn_rndis_detach(struct hn_softc *sc); int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags); void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Wed Oct 19 08:23:54 2016 (r307619) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Wed Oct 19 08:32:24 2016 (r307620) @@ -59,6 +59,7 @@ #define NDIS_OBJTYPE_DEFAULT 0x80 #define NDIS_OBJTYPE_RSS_CAPS 0x88 #define NDIS_OBJTYPE_RSS_PARAMS 0x89 +#define NDIS_OBJTYPE_OFFLOAD 0xa7 struct ndis_object_hdr { uint8_t ndis_type; /* NDIS_OBJTYPE_ */ @@ -205,6 +206,129 @@ struct ndis_rssprm_toeplitz { }; /* + * OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES + * ndis_type: NDIS_OBJTYPE_OFFLOAD + */ + +#define NDIS_OFFLOAD_ENCAP_NONE 0x0000 +#define NDIS_OFFLOAD_ENCAP_NULL 0x0001 +#define NDIS_OFFLOAD_ENCAP_8023 0x0002 +#define NDIS_OFFLOAD_ENCAP_8023PQ 0x0004 +#define NDIS_OFFLOAD_ENCAP_8023PQ_OOB 0x0008 +#define NDIS_OFFLOAD_ENCAP_RFC1483 0x0010 + +struct ndis_csum_offload { + uint32_t ndis_ip4_txenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_txcsum; +#define NDIS_TXCSUM_CAP_IP4OPT 0x001 +#define NDIS_TXCSUM_CAP_TCP4OPT 0x004 +#define NDIS_TXCSUM_CAP_TCP4 0x010 +#define NDIS_TXCSUM_CAP_UDP4 0x040 +#define NDIS_TXCSUM_CAP_IP4 0x100 + uint32_t ndis_ip4_rxenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_rxcsum; +#define NDIS_RXCSUM_CAP_IP4OPT 0x001 +#define NDIS_RXCSUM_CAP_TCP4OPT 0x004 +#define NDIS_RXCSUM_CAP_TCP4 0x010 +#define NDIS_RXCSUM_CAP_UDP4 0x040 +#define NDIS_RXCSUM_CAP_IP4 0x100 + uint32_t ndis_ip6_txenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_txcsum; +#define NDIS_TXCSUM_CAP_IP6EXT 0x001 +#define NDIS_TXCSUM_CAP_TCP6OPT 0x004 +#define NDIS_TXCSUM_CAP_TCP6 0x010 +#define NDIS_TXCSUM_CAP_UDP6 0x040 + uint32_t ndis_ip6_rxenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_rxcsum; +#define NDIS_RXCSUM_CAP_IP6EXT 0x001 +#define NDIS_RXCSUM_CAP_TCP6OPT 0x004 +#define NDIS_RXCSUM_CAP_TCP6 0x010 +#define NDIS_RXCSUM_CAP_UDP6 0x040 +}; + +struct ndis_lsov1_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_maxsize; + uint32_t ndis_minsegs; + uint32_t ndis_opts; +}; + +struct ndis_ipsecv1_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ah_esp; + uint32_t ndis_xport_tun; + uint32_t ndis_ip4_opts; + uint32_t ndis_flags; + uint32_t ndis_ip4_ah; + uint32_t ndis_ip4_esp; +}; + +struct ndis_lsov2_offload { + uint32_t ndis_ip4_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_maxsz; + uint32_t ndis_ip4_minsg; + uint32_t ndis_ip6_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_maxsz; + uint32_t ndis_ip6_minsg; + uint32_t ndis_ip6_opts; +#define NDIS_LSOV2_CAP_IP6EXT 0x001 +#define NDIS_LSOV2_CAP_TCP6OPT 0x004 +}; + +struct ndis_ipsecv2_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint16_t ndis_ip6; + uint16_t ndis_ip4opt; + uint16_t ndis_ip6ext; + uint16_t ndis_ah; + uint16_t ndis_esp; + uint16_t ndis_ah_esp; + uint16_t ndis_xport; + uint16_t ndis_tun; + uint16_t ndis_xport_tun; + uint16_t ndis_lso; + uint16_t ndis_extseq; + uint32_t ndis_udp_esp; + uint32_t ndis_auth; + uint32_t ndis_crypto; + uint32_t ndis_sa_caps; +}; + +struct ndis_rsc_offload { + uint16_t ndis_ip4; + uint16_t ndis_ip6; +}; + +struct ndis_encap_offload { + uint32_t ndis_flags; + uint32_t ndis_maxhdr; +}; + +struct ndis_offload { + struct ndis_object_hdr ndis_hdr; + struct ndis_csum_offload ndis_csum; + struct ndis_lsov1_offload ndis_lsov1; + struct ndis_ipsecv1_offload ndis_ipsecv1; + struct ndis_lsov2_offload ndis_lsov2; + uint32_t ndis_flags; + /* NDIS >= 6.1 */ + struct ndis_ipsecv2_offload ndis_ipsecv2; + /* NDIS >= 6.30 */ + struct ndis_rsc_offload ndis_rsc; + struct ndis_encap_offload ndis_encap_gre; +}; + +#define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload) +#define NDIS_OFFLOAD_SIZE_6_0 \ + __offsetof(struct ndis_offload, ndis_ipsecv2) +#define NDIS_OFFLOAD_SIZE_6_1 \ + __offsetof(struct ndis_offload, ndis_rsc) + +#define NDIS_OFFLOAD_REV_1 1 /* NDIS 6.0 */ +#define NDIS_OFFLOAD_REV_2 2 /* NDIS 6.1 */ +#define NDIS_OFFLOAD_REV_3 3 /* NDIS 6.30 */ + +/* * Per-packet-info */ Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Wed Oct 19 08:23:54 2016 (r307619) +++ stable/10/sys/net/rndis.h Wed Oct 19 08:32:24 2016 (r307620) @@ -87,6 +87,7 @@ #define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C +#define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D #define RNDIS_MEDIUM_802_3 0x00000000 From owner-svn-src-stable@freebsd.org Wed Oct 19 08:40:26 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15246C18CE6; Wed, 19 Oct 2016 08:40:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E31C02FA; Wed, 19 Oct 2016 08:40:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J8ePmf046150; Wed, 19 Oct 2016 08:40:25 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J8eOrc046144; Wed, 19 Oct 2016 08:40:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190840.u9J8eOrc046144@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 08:40:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307621 - in stable/10/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 08:40:26 -0000 Author: sephe Date: Wed Oct 19 08:40:24 2016 New Revision: 307621 URL: https://svnweb.freebsd.org/changeset/base/307621 Log: MFC 307012,307013,307262 307012 hyperv/vmbus: Allow driver to inject synchronous task into channel taskq. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8208 307013 hyperv/hn: Rework link status support. This is the preamble for network device SR-IOV and NDIS_STATUS_NETWORK_CHANGE handling. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8209 307262 hyperv/hn: Management parts always need suspend and resume. Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 19 08:32:24 2016 (r307620) +++ stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 19 08:40:24 2016 (r307621) @@ -118,6 +118,7 @@ struct vmbus_chan_br { struct vmbus_channel; struct hyperv_guid; +struct task; typedef void (*vmbus_chan_callback_t)(struct vmbus_channel *, void *); @@ -135,6 +136,8 @@ int vmbus_chan_open_br(struct vmbus_cha int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); void vmbus_chan_intr_drain(struct vmbus_channel *chan); +void vmbus_chan_run_task(struct vmbus_channel *chan, + struct task *task); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 08:32:24 2016 (r307620) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 19 08:40:24 2016 (r307621) @@ -234,6 +234,10 @@ struct hn_softc { struct vmbus_xact_ctx *hn_xact; uint32_t hn_nvs_ver; + struct taskqueue *hn_mgmt_taskq; + struct taskqueue *hn_mgmt_taskq0; + struct task hn_link_task; + uint32_t hn_caps; /* HN_CAP_ */ uint32_t hn_flags; /* HN_FLAG_ */ void *hn_rxbuf; @@ -272,7 +276,6 @@ struct hn_softc { */ struct hn_send_ctx; -void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 08:32:24 2016 (r307620) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 19 08:40:24 2016 (r307621) @@ -336,6 +336,8 @@ static void hn_fixup_tx_data(struct hn_s static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); +static void hn_link_taskfunc(void *, int); +static void hn_suspend_mgmt_taskfunc(void *, int); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); @@ -351,7 +353,11 @@ static int hn_synth_attach(struct hn_sof static void hn_synth_detach(struct hn_softc *); static bool hn_tx_ring_pending(struct hn_tx_ring *); static void hn_suspend(struct hn_softc *); +static void hn_suspend_data(struct hn_softc *); +static void hn_suspend_mgmt(struct hn_softc *); static void hn_resume(struct hn_softc *); +static void hn_resume_data(struct hn_softc *); +static void hn_resume_mgmt(struct hn_softc *); static void hn_rx_drain(struct vmbus_channel *); static void hn_tx_resume(struct hn_softc *, int); static void hn_tx_ring_qflush(struct hn_tx_ring *); @@ -533,7 +539,6 @@ netvsc_attach(device_t dev) struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; uint8_t eaddr[ETHER_ADDR_LEN]; - uint32_t link_status; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; @@ -567,6 +572,15 @@ netvsc_attach(device_t dev) } /* + * Setup taskqueue for mangement tasks, e.g. link status. + */ + sc->hn_mgmt_taskq0 = taskqueue_create("hn_mgmt", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_mgmt_taskq0); + taskqueue_start_threads(&sc->hn_mgmt_taskq0, 1, PI_NET, "%s mgmt", + device_get_nameunit(dev)); + TASK_INIT(&sc->hn_link_task, 0, hn_link_taskfunc, sc); + + /* * Allocate ifnet and setup its name earlier, so that if_printf * can be used by functions, which will be called after * ether_ifattach(). @@ -637,12 +651,6 @@ netvsc_attach(device_t dev) if (error) goto failed; - error = hn_rndis_get_linkstatus(sc, &link_status); - if (error) - goto failed; - if (link_status == NDIS_MEDIA_STATE_CONNECTED) - sc->hn_carrier = 1; - error = hn_rndis_get_eaddr(sc, eaddr); if (error) goto failed; @@ -752,6 +760,12 @@ netvsc_attach(device_t dev) /* Inform the upper layer about the long frame support. */ ifp->if_hdrlen = sizeof(struct ether_vlan_header); + /* + * Kick off link status check. + */ + sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; + hn_link_status_update(sc); + return (0); failed: if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) @@ -771,6 +785,12 @@ netvsc_detach(device_t dev) if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) hn_stop(sc); + /* + * NOTE: + * hn_stop() only suspends data, so managment + * stuffs have to be suspended manually here. + */ + hn_suspend_mgmt(sc); hn_synth_detach(sc); } HN_UNLOCK(sc); @@ -783,6 +803,7 @@ netvsc_detach(device_t dev) if (sc->hn_tx_taskq != hn_tx_taskq) taskqueue_free(sc->hn_tx_taskq); + taskqueue_free(sc->hn_mgmt_taskq0); if (sc->hn_xact != NULL) vmbus_xact_ctx_destroy(sc->hn_xact); @@ -802,6 +823,36 @@ netvsc_shutdown(device_t dev) return (0); } +static void +hn_link_taskfunc(void *xsc, int pending __unused) +{ + struct hn_softc *sc = xsc; + struct ifnet *ifp = sc->hn_ifp; + uint32_t link_status; + int error; + + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) { + /* XXX what to do? */ + return; + } + + if (link_status == NDIS_MEDIA_STATE_CONNECTED) + sc->hn_carrier = 1; + else + sc->hn_carrier = 0; + if_link_state_change(ifp, + sc->hn_carrier ? LINK_STATE_UP : LINK_STATE_DOWN); +} + +void +hn_link_status_update(struct hn_softc *sc) +{ + + if (sc->hn_mgmt_taskq != NULL) + taskqueue_enqueue(sc->hn_mgmt_taskq, &sc->hn_link_task); +} + static __inline int hn_txdesc_dmamap_load(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head, bus_dma_segment_t *segs, int *nsegs) @@ -1333,19 +1384,6 @@ hn_start_locked(struct hn_tx_ring *txr, } /* - * Link up/down notification - */ -void -netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status) -{ - if (status == 1) { - sc->hn_carrier = 1; - } else { - sc->hn_carrier = 0; - } -} - -/* * Append the specified data to the indicated mbuf chain, * Extend the mbuf chain if the new data does not fit in * existing space. @@ -1673,8 +1711,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); #endif - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_suspend(sc); + /* + * Suspend this interface before the synthetic parts + * are ripped. + */ + hn_suspend(sc); /* * Detach the synthetics parts, i.e. NVS and RNDIS. @@ -1692,9 +1733,10 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_chim_size(sc, sc->hn_chim_szmax); hn_set_tso_maxsize(sc, hn_tso_maxlen, ifr->ifr_mtu); - /* All done! Resume now. */ - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_resume(sc); + /* + * All done! Resume the interface now. + */ + hn_resume(sc); HN_UNLOCK(sc); break; @@ -1821,9 +1863,9 @@ hn_stop(struct hn_softc *sc) KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, ("synthetic parts were not attached")); - /* Clear RUNNING bit _before_ hn_suspend() */ + /* Clear RUNNING bit _before_ hn_suspend_data() */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); - hn_suspend(sc); + hn_suspend_data(sc); /* Clear OACTIVE bit. */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); @@ -1916,9 +1958,6 @@ hn_init_locked(struct hn_softc *sc) /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); - - /* TODO: check RNDIS link status. */ - if_link_state_change(ifp, LINK_STATE_UP); } static void @@ -3620,7 +3659,7 @@ hn_rx_drain(struct vmbus_channel *chan) } static void -hn_suspend(struct hn_softc *sc) +hn_suspend_data(struct hn_softc *sc) { struct vmbus_channel **subch = NULL; int i, nsubch; @@ -3674,6 +3713,42 @@ hn_suspend(struct hn_softc *sc) } static void +hn_suspend_mgmt_taskfunc(void *xsc, int pending __unused) +{ + + ((struct hn_softc *)xsc)->hn_mgmt_taskq = NULL; +} + +static void +hn_suspend_mgmt(struct hn_softc *sc) +{ + struct task task; + + HN_LOCK_ASSERT(sc); + + /* + * Make sure that hn_mgmt_taskq0 can nolonger be accessed + * through hn_mgmt_taskq. + */ + TASK_INIT(&task, 0, hn_suspend_mgmt_taskfunc, sc); + vmbus_chan_run_task(sc->hn_prichan, &task); + + /* + * Make sure that all pending management tasks are completed. + */ + taskqueue_drain_all(sc->hn_mgmt_taskq0); +} + +static void +hn_suspend(struct hn_softc *sc) +{ + + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_suspend_data(sc); + hn_suspend_mgmt(sc); +} + +static void hn_tx_resume(struct hn_softc *sc, int tx_ring_cnt) { int i; @@ -3691,7 +3766,7 @@ hn_tx_resume(struct hn_softc *sc, int tx } static void -hn_resume(struct hn_softc *sc) +hn_resume_data(struct hn_softc *sc) { int i; @@ -3705,7 +3780,8 @@ hn_resume(struct hn_softc *sc) /* * Make sure to clear suspend status on "all" TX rings, - * since hn_tx_ring_inuse can be changed after hn_suspend(). + * since hn_tx_ring_inuse can be changed after + * hn_suspend_data(). */ hn_tx_resume(sc, sc->hn_tx_ring_cnt); @@ -3733,6 +3809,26 @@ hn_resume(struct hn_softc *sc) } static void +hn_resume_mgmt(struct hn_softc *sc) +{ + + /* + * Kick off link status check. + */ + sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; + hn_link_status_update(sc); +} + +static void +hn_resume(struct hn_softc *sc) +{ + + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_resume_data(sc); + hn_resume_mgmt(sc); +} + +static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { const struct hn_nvs_hdr *hdr; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 08:32:24 2016 (r307620) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 19 08:40:24 2016 (r307621) @@ -168,11 +168,8 @@ hv_rf_receive_indicate_status(struct hn_ switch (msg->rm_status) { case RNDIS_STATUS_MEDIA_CONNECT: - netvsc_linkstatus_callback(sc, 1); - break; - case RNDIS_STATUS_MEDIA_DISCONNECT: - netvsc_linkstatus_callback(sc, 0); + hn_link_status_update(sc); break; case RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG: Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 08:32:24 2016 (r307620) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Wed Oct 19 08:40:24 2016 (r307621) @@ -138,6 +138,7 @@ void hn_nvs_sent_xact(struct hn_send_ct int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_recvinfo *info); void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); +void hn_link_status_update(struct hn_softc *sc); extern struct hn_send_ctx hn_send_ctx_none; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 08:32:24 2016 (r307620) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 19 08:40:24 2016 (r307621) @@ -1713,3 +1713,11 @@ vmbus_chan_rx_empty(const struct vmbus_c return (vmbus_rxbr_empty(&chan->ch_rxbr)); } + +void +vmbus_chan_run_task(struct vmbus_channel *chan, struct task *task) +{ + + taskqueue_enqueue(chan->ch_tq, task); + taskqueue_drain(chan->ch_tq, task); +} From owner-svn-src-stable@freebsd.org Wed Oct 19 08:43:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C3ADC18E21; Wed, 19 Oct 2016 08:43:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 62DCF927; Wed, 19 Oct 2016 08:43:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J8hKrN049580; Wed, 19 Oct 2016 08:43:20 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J8hKw2049579; Wed, 19 Oct 2016 08:43:20 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190843.u9J8hKw2049579@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 08:43:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307622 - stable/10/sys/net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 08:43:21 -0000 Author: sephe Date: Wed Oct 19 08:43:20 2016 New Revision: 307622 URL: https://svnweb.freebsd.org/changeset/base/307622 Log: MFC 307078 ifnet: Use if_link_state snapshot to invoke ifnet_link_event So that everyone in this task have consistent view of link state. Reviewed by: ae Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8214 Modified: stable/10/sys/net/if.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/net/if.c ============================================================================== --- stable/10/sys/net/if.c Wed Oct 19 08:40:24 2016 (r307621) +++ stable/10/sys/net/if.c Wed Oct 19 08:43:20 2016 (r307622) @@ -2171,7 +2171,7 @@ do_link_state_change(void *arg, int pend if (log_link_state_change) log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname, (link_state == LINK_STATE_UP) ? "UP" : "DOWN" ); - EVENTHANDLER_INVOKE(ifnet_link_event, ifp, ifp->if_link_state); + EVENTHANDLER_INVOKE(ifnet_link_event, ifp, link_state); CURVNET_RESTORE(); } From owner-svn-src-stable@freebsd.org Wed Oct 19 08:45:20 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FBA5C18E8C; Wed, 19 Oct 2016 08:45:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 61057AA4; Wed, 19 Oct 2016 08:45:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9J8jJ9A049725; Wed, 19 Oct 2016 08:45:19 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9J8jJnl049724; Wed, 19 Oct 2016 08:45:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610190845.u9J8jJnl049724@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 19 Oct 2016 08:45:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307623 - stable/10/sys/dev/hyperv/storvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 08:45:20 -0000 Author: sephe Date: Wed Oct 19 08:45:19 2016 New Revision: 307623 URL: https://svnweb.freebsd.org/changeset/base/307623 Log: MFC 307261 hyperv/stor: Fix off-by-one bug; this brings back TRIM support. Submitted by: Hongjiang Zhang Reported by: Lili Deng Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8238 Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 19 08:43:20 2016 (r307622) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 19 08:45:19 2016 (r307623) @@ -2210,7 +2210,7 @@ storvsc_io_done(struct hv_storvsc_reques resp_buf[3], resp_buf[4]); } if (vm_srb->srb_status == SRB_STATUS_SUCCESS && - data_len > SHORT_INQUIRY_LENGTH) { + data_len >= SHORT_INQUIRY_LENGTH) { char vendor[16]; cam_strvis(vendor, inq_data->vendor, From owner-svn-src-stable@freebsd.org Wed Oct 19 13:19:46 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C10FC17D6A; Wed, 19 Oct 2016 13:19:46 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4197C9FF; Wed, 19 Oct 2016 13:19:46 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JDJj2s052185; Wed, 19 Oct 2016 13:19:45 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JDJjYb052183; Wed, 19 Oct 2016 13:19:45 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610191319.u9JDJjYb052183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 19 Oct 2016 13:19:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307631 - stable/11/gnu/usr.bin/groff X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 13:19:46 -0000 Author: emaste Date: Wed Oct 19 13:19:45 2016 New Revision: 307631 URL: https://svnweb.freebsd.org/changeset/base/307631 Log: MFC r306740, r307150: groff: use changelog date in man pages r306740: groff: use changelog date rather than file modification date in man pages The source checkout date is not particularly relevant, and this makes groff man pages build reproducibly. r307150: Avoid using 'head' in generating groff doc date It may not be available in certain cross build cases. Note that this is a slight change in functionality, in that now only the first line of the source ChangeLog file is processed. This is acceptable as groff will be retired and we won't encounter a possibly-different ChangeLog format. Added: stable/11/gnu/usr.bin/groff/mdate.sh - copied, changed from r306740, head/gnu/usr.bin/groff/mdate.sh Modified: stable/11/gnu/usr.bin/groff/Makefile.inc Directory Properties: stable/11/ (props changed) Modified: stable/11/gnu/usr.bin/groff/Makefile.inc ============================================================================== --- stable/11/gnu/usr.bin/groff/Makefile.inc Wed Oct 19 12:33:58 2016 (r307630) +++ stable/11/gnu/usr.bin/groff/Makefile.inc Wed Oct 19 13:19:45 2016 (r307631) @@ -119,7 +119,7 @@ revision=`sed -e 's/^0$$//' -e 's/^[1-9] -e "s;@TMAC_MDIR@;$(tmacdir)/mm;g" \ -e "s;@BROKEN_SPOOLER_FLAGS@;$(BROKEN_SPOOLER_FLAGS);g" \ -e "s;@VERSION@;$(version)$(revision);g" \ - -e "s;@MDATE@;`$(SHELL) ${GROFF_DIST}/mdate.sh $<`;g" \ + -e "s;@MDATE@;$(MDATE);g" \ -e "s;@g@;$(g);g" \ -e "s;@G@;`echo $(g) | LC_ALL=C tr a-z A-Z`;g" \ $< >$@ @@ -141,4 +141,5 @@ TOPREL?= .. GROFF_DIST= ${.CURDIR}/${TOPREL}/../../../contrib/groff DIST_SUBDIR?= ${.CURDIR:T} DIST_DIR= ${GROFF_DIST}/${DIST_SUBDIR} +MDATE!= sh ${.CURDIR}/${TOPREL}/mdate.sh ${GROFF_DIST}/ChangeLog .PATH: ${DIST_DIR} Copied and modified: stable/11/gnu/usr.bin/groff/mdate.sh (from r306740, head/gnu/usr.bin/groff/mdate.sh) ============================================================================== --- head/gnu/usr.bin/groff/mdate.sh Wed Oct 5 23:25:29 2016 (r306740, copy source) +++ stable/11/gnu/usr.bin/groff/mdate.sh Wed Oct 19 13:19:45 2016 (r307631) @@ -4,6 +4,5 @@ set -e test -r "$1" export LC_ALL=C -changelog_date=$(sed -E -n 's/^([0-9]{4}-[0-9]{2}-[0-9]{2}).*$/\1/p' "$1" |\ - head -n 1) +changelog_date=$(sed -E -n '1s/^([0-9]{4}-[0-9]{2}-[0-9]{2}).*$/\1/p' "$1") echo $(date -j -f %Y-%m-%d +"%e %B %Y" $changelog_date) From owner-svn-src-stable@freebsd.org Wed Oct 19 13:26:10 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1436BC18020; Wed, 19 Oct 2016 13:26:10 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E2A08E9D; Wed, 19 Oct 2016 13:26:09 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JDQ94U055778; Wed, 19 Oct 2016 13:26:09 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JDQ7pm055767; Wed, 19 Oct 2016 13:26:07 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610191326.u9JDQ7pm055767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Wed, 19 Oct 2016 13:26:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307632 - in stable/11: lib/libstand sys/boot/common sys/boot/efi/loader sys/boot/i386/libi386 sys/boot/i386/loader sys/boot/pc98/loader X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 13:26:10 -0000 Author: bapt Date: Wed Oct 19 13:26:07 2016 New Revision: 307632 URL: https://svnweb.freebsd.org/changeset/base/307632 Log: MFC: 304677, 304680, 305125, 305770, 305769 r304677: Add tftpfs support for the EFI loader Allow netbooting on efi without having to setup any NFS server by rebuilding the loader with LOADER_TFTP_SUPPORT like for the i386 pxeloader r305125: Netboot: allow both tftpfs and nfs in both pxeboot and loader.efi Add a new 'netproto' variable which can be set for now to NET_TFTP or NET_NFS (default to NET_NONE) From the dhcp options if one sets the root-path option to: "ip:path", the loader will consider it is booting over NFS (meaning same behaviour as the default current behaviour) if the dhcp option "tftp server address" is set (option 150) the loader will consider it is booting over tftpfs, it will then consider the root-path options with 2 possible case 1. "path" then the IP of the tftp server will be the one passed by the option 150, and the files will be retrieved under "path" on the tftp server 2. "ip:path" then the IP of the tftp server will be the one passed in the option "overwritting the IP from the option 150. We could not "abuse" the rootpath option in the form or tftp://ip:path because this is already used for other purpose by iPXE preventing any chainload from iPXE to the FreeBSD loader. Given at each open(), the loader loops over all available filesystems and keep the "best" error, we needed to prevent tftpfs to fallback on nfs and vice versa. the tftpfs and nfs implementation in libstand now return EINVAL early if 'netproto' for that purpose. Relnotes: yes Sponsored by: Gandi.net Modified: stable/11/lib/libstand/bootp.c stable/11/lib/libstand/bootp.h stable/11/lib/libstand/globals.c stable/11/lib/libstand/net.h stable/11/lib/libstand/nfs.c stable/11/lib/libstand/tftp.c stable/11/sys/boot/common/dev_net.c stable/11/sys/boot/efi/loader/conf.c stable/11/sys/boot/i386/libi386/pxe.c stable/11/sys/boot/i386/loader/conf.c stable/11/sys/boot/pc98/loader/conf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libstand/bootp.c ============================================================================== --- stable/11/lib/libstand/bootp.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/lib/libstand/bootp.c Wed Oct 19 13:26:07 2016 (r307632) @@ -411,6 +411,10 @@ vend_rfc1048(cp, len) bcopy(cp, &dhcp_serverip.s_addr, sizeof(dhcp_serverip.s_addr)); } + if (tag == TAG_TFTP_SERVER) { + bcopy(cp, &tftpip.s_addr, + sizeof(tftpip.s_addr)); + } #endif cp += size; } Modified: stable/11/lib/libstand/bootp.h ============================================================================== --- stable/11/lib/libstand/bootp.h Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/lib/libstand/bootp.h Wed Oct 19 13:26:07 2016 (r307632) @@ -106,6 +106,7 @@ struct bootp { #define TAG_T2 ((unsigned char) 59) #define TAG_CLASSID ((unsigned char) 60) #define TAG_CLIENTID ((unsigned char) 61) +#define TAG_TFTP_SERVER ((unsigned char) 150) #endif #define TAG_END ((unsigned char) 255) Modified: stable/11/lib/libstand/globals.c ============================================================================== --- stable/11/lib/libstand/globals.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/lib/libstand/globals.c Wed Oct 19 13:26:07 2016 (r307632) @@ -25,12 +25,14 @@ char hostname[FNAME_SIZE]; /* our hostn int hostnamelen; char domainname[FNAME_SIZE]; /* our DNS domain */ int domainnamelen; +int netproto = NET_NONE; /* Network prototol */ char ifname[IFNAME_SIZE]; /* name of interface (e.g. "le0") */ struct in_addr myip; /* my ip address */ struct in_addr nameip; /* DNS server ip address */ struct in_addr rootip; /* root ip address */ struct in_addr swapip; /* swap ip address */ struct in_addr gateip; /* gateway ip address */ +struct in_addr tftpip; /* TFTP ip address */ n_long netmask = 0xffffff00; /* subnet or net mask */ u_int intf_mtu; /* interface mtu from bootp/dhcp */ int errno; /* our old friend */ Modified: stable/11/lib/libstand/net.h ============================================================================== --- stable/11/lib/libstand/net.h Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/lib/libstand/net.h Wed Oct 19 13:26:07 2016 (r307632) @@ -36,6 +36,8 @@ * $FreeBSD$ */ +#ifndef _STAND_NET_H +#define _STAND_NET_H #ifndef _KERNEL /* XXX - see */ #undef __IPADDR #define __IPADDR(x) htonl((u_int32_t)(x)) @@ -45,6 +47,12 @@ #define BA { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } +enum net_proto { + NET_NONE, + NET_NFS, + NET_TFTP +}; + /* Returns true if n_long's on the same net */ #define SAMENET(a1, a2, m) ((a1.s_addr & m) == (a2.s_addr & m)) @@ -74,6 +82,7 @@ extern char hostname[FNAME_SIZE]; extern int hostnamelen; extern char domainname[FNAME_SIZE]; extern int domainnamelen; +extern int netproto; extern char ifname[IFNAME_SIZE]; /* All of these are in network order. */ @@ -82,6 +91,7 @@ extern struct in_addr rootip; extern struct in_addr swapip; extern struct in_addr gateip; extern struct in_addr nameip; +extern struct in_addr tftpip; extern n_long netmask; extern u_int intf_mtu; @@ -120,3 +130,4 @@ n_long inet_addr(char *); /* Machine-dependent functions: */ time_t getsecs(void); +#endif /* ! _STAND_NET_H */ Modified: stable/11/lib/libstand/nfs.c ============================================================================== --- stable/11/lib/libstand/nfs.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/lib/libstand/nfs.c Wed Oct 19 13:26:07 2016 (r307632) @@ -473,6 +473,9 @@ nfs_open(const char *upath, struct open_ int error; char *path; + if (netproto != NET_NFS) + return (EINVAL); + #ifdef NFS_DEBUG if (debug) printf("nfs_open: %s (rootpath=%s)\n", upath, rootpath); @@ -1115,6 +1118,9 @@ nfs_open(const char *upath, struct open_ int error; char *path; + if (netproto != NET_NFS) + return (EINVAL); + #ifdef NFS_DEBUG if (debug) printf("nfs_open: %s (rootpath=%s)\n", upath, rootpath); Modified: stable/11/lib/libstand/tftp.c ============================================================================== --- stable/11/lib/libstand/tftp.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/lib/libstand/tftp.c Wed Oct 19 13:26:07 2016 (r307632) @@ -402,6 +402,9 @@ tftp_open(const char *path, struct open_ size_t pathsize; const char *extraslash; + if (netproto != NET_TFTP) + return (EINVAL); + if (strcmp(f->f_dev->dv_name, "net") != 0) { #ifdef __i386__ if (strcmp(f->f_dev->dv_name, "pxe") != 0) Modified: stable/11/sys/boot/common/dev_net.c ============================================================================== --- stable/11/sys/boot/common/dev_net.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/sys/boot/common/dev_net.c Wed Oct 19 13:26:07 2016 (r307632) @@ -167,8 +167,14 @@ net_open(struct open_file *f, ...) setenv("boot.netif.ip", inet_ntoa(myip), 1); setenv("boot.netif.netmask", intoa(netmask), 1); setenv("boot.netif.gateway", inet_ntoa(gateip), 1); - setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); - setenv("boot.nfsroot.path", rootpath, 1); + setenv("boot.netif.server", inet_ntoa(rootip), 1); + if (netproto == NET_TFTP) { + setenv("boot.tftproot.server", inet_ntoa(rootip), 1); + setenv("boot.tftproot.path", rootpath, 1); + } else if (netproto == NET_NFS) { + setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); + setenv("boot.nfsroot.path", rootpath, 1); + } if (intf_mtu != 0) { char mtu[16]; sprintf(mtu, "%u", intf_mtu); @@ -365,6 +371,13 @@ net_parse_rootpath() int i; n_long addr = INADDR_NONE; + netproto = NET_NFS; + + if (tftpip.s_addr != 0) { + netproto = NET_TFTP; + addr = tftpip.s_addr; + } + for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++) if (rootpath[i] == ':') break; @@ -373,5 +386,6 @@ net_parse_rootpath() addr = inet_addr(&rootpath[0]); bcopy(&rootpath[i], rootpath, strlen(&rootpath[i])+1); } + return (addr); } Modified: stable/11/sys/boot/efi/loader/conf.c ============================================================================== --- stable/11/sys/boot/efi/loader/conf.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/sys/boot/efi/loader/conf.c Wed Oct 19 13:26:07 2016 (r307632) @@ -51,6 +51,7 @@ struct fs_ops *file_system[] = { &dosfs_fsops, &ufs_fsops, &cd9660_fsops, + &tftp_fsops, &nfs_fsops, &gzipfs_fsops, &bzipfs_fsops, Modified: stable/11/sys/boot/i386/libi386/pxe.c ============================================================================== --- stable/11/sys/boot/i386/libi386/pxe.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/sys/boot/i386/libi386/pxe.c Wed Oct 19 13:26:07 2016 (r307632) @@ -288,10 +288,15 @@ pxe_open(struct open_file *f, ...) bootp(pxe_sock, BOOTP_PXE); if (rootip.s_addr == 0) rootip.s_addr = bootplayer.sip; -#ifdef LOADER_NFS_SUPPORT - if (!rootpath[0]) + + netproto = NET_NFS; + if (tftpip.s_addr != 0) { + netproto = NET_TFTP; + rootip.s_addr = tftpip.s_addr; + } + + if (netproto == NET_NFS && !rootpath[0]) strcpy(rootpath, PXENFSROOTPATH); -#endif for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++) if (rootpath[i] == ':') @@ -315,17 +320,17 @@ pxe_open(struct open_file *f, ...) sprintf(mtu, "%u", intf_mtu); setenv("boot.netif.mtu", mtu, 1); } -#ifdef LOADER_NFS_SUPPORT printf("pxe_open: server addr: %s\n", inet_ntoa(rootip)); printf("pxe_open: server path: %s\n", rootpath); printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); - setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); - setenv("boot.nfsroot.path", rootpath, 1); -#else - setenv("boot.netif.server", inet_ntoa(rootip), 1); - setenv("boot.tftproot.path", rootpath, 1); -#endif + if (netproto == NET_NFS) { + setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); + setenv("boot.nfsroot.path", rootpath, 1); + } else if (netproto == NET_TFTP) { + setenv("boot.netif.server", inet_ntoa(rootip), 1); + setenv("boot.tftproot.path", rootpath, 1); + } setenv("dhcp.host-name", hostname, 1); setenv("pxeboot.ip", inet_ntoa(myip), 1); @@ -359,10 +364,10 @@ pxe_close(struct open_file *f) if (pxe_opens > 0) return(0); -#ifdef LOADER_NFS_SUPPORT - /* get an NFS filehandle for our root filesystem */ - pxe_setnfshandle(rootpath); -#endif + if (netproto == NET_NFS) { + /* get an NFS filehandle for our root filesystem */ + pxe_setnfshandle(rootpath); + } if (pxe_sock >= 0) { @@ -422,7 +427,6 @@ pxe_perror(int err) return; } -#ifdef LOADER_NFS_SUPPORT /* * Reach inside the libstand NFS code and dig out an NFS handle * for the root filesystem. @@ -533,7 +537,6 @@ pxe_setnfshandle(char *rootpath) setenv("boot.nfsroot.nfshandlelen", buf, 1); } #endif /* OLD_NFSV2 */ -#endif /* LOADER_NFS_SUPPORT */ void pxenv_call(int func) Modified: stable/11/sys/boot/i386/loader/conf.c ============================================================================== --- stable/11/sys/boot/i386/loader/conf.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/sys/boot/i386/loader/conf.c Wed Oct 19 13:26:07 2016 (r307632) @@ -45,10 +45,6 @@ __FBSDID("$FreeBSD$"); * XXX as libi386 and biosboot merge, some of these can become linker sets. */ -#if defined(LOADER_NFS_SUPPORT) && defined(LOADER_TFTP_SUPPORT) -#error "Cannot have both tftp and nfs support yet." -#endif - #if defined(LOADER_FIREWIRE_SUPPORT) extern struct devsw fwohci; #endif Modified: stable/11/sys/boot/pc98/loader/conf.c ============================================================================== --- stable/11/sys/boot/pc98/loader/conf.c Wed Oct 19 13:19:45 2016 (r307631) +++ stable/11/sys/boot/pc98/loader/conf.c Wed Oct 19 13:26:07 2016 (r307632) @@ -42,10 +42,6 @@ __FBSDID("$FreeBSD$"); * XXX as libi386 and biosboot merge, some of these can become linker sets. */ -#if defined(LOADER_NFS_SUPPORT) && defined(LOADER_TFTP_SUPPORT) -#error "Cannot have both tftp and nfs support yet." -#endif - /* Exported for libstand */ struct devsw *devsw[] = { &bioscd, From owner-svn-src-stable@freebsd.org Wed Oct 19 13:36:53 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 511D7C18409; Wed, 19 Oct 2016 13:36:53 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1FF38986; Wed, 19 Oct 2016 13:36:53 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JDaqew059641; Wed, 19 Oct 2016 13:36:52 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JDaqdb059640; Wed, 19 Oct 2016 13:36:52 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610191336.u9JDaqdb059640@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 19 Oct 2016 13:36:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307633 - stable/11/sys/mips/conf X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 13:36:53 -0000 Author: emaste Date: Wed Oct 19 13:36:52 2016 New Revision: 307633 URL: https://svnweb.freebsd.org/changeset/base/307633 Log: MFC r307152: Add COMPAT_FREEBSD10 to the MIPS ERL kernel config As of r302092, pipe is a wrapper around pipe2 and the pipe syscall is no longer used. It is included only with the COMPAT_FREEBSD10 kernel option. Add the compat option to support upgrades from systems with an earlier userland. Modified: stable/11/sys/mips/conf/ERL Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/mips/conf/ERL ============================================================================== --- stable/11/sys/mips/conf/ERL Wed Oct 19 13:26:07 2016 (r307632) +++ stable/11/sys/mips/conf/ERL Wed Oct 19 13:36:52 2016 (r307633) @@ -73,6 +73,7 @@ options PSEUDOFS # Pseudo-filesystem f options GEOM_PART_GPT # GUID Partition Tables. options GEOM_LABEL # Provides labelization options COMPAT_FREEBSD32 # Compatible with o32 binaries +options COMPAT_FREEBSD10 # Compatible with FreeBSD10 options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI options KTRACE # ktrace(1) support options STACK # stack(9) support From owner-svn-src-stable@freebsd.org Wed Oct 19 13:37:45 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 358EAC184B4; Wed, 19 Oct 2016 13:37:45 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F2E53AF4; Wed, 19 Oct 2016 13:37:44 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JDbi2t059727; Wed, 19 Oct 2016 13:37:44 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JDbimb059726; Wed, 19 Oct 2016 13:37:44 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610191337.u9JDbimb059726@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 19 Oct 2016 13:37:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307634 - stable/11/sys/dev/kbd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 13:37:45 -0000 Author: emaste Date: Wed Oct 19 13:37:43 2016 New Revision: 307634 URL: https://svnweb.freebsd.org/changeset/base/307634 Log: MFC r307145: Use M_WAITOK in PIO_KEYMAP ioctl The malloc return value is not checked. Modified: stable/11/sys/dev/kbd/kbd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/kbd/kbd.c ============================================================================== --- stable/11/sys/dev/kbd/kbd.c Wed Oct 19 13:36:52 2016 (r307633) +++ stable/11/sys/dev/kbd/kbd.c Wed Oct 19 13:37:43 2016 (r307634) @@ -888,7 +888,7 @@ genkbd_commonioctl(keyboard_t *kbd, u_lo case PIO_KEYMAP: /* set keyboard translation table */ case OPIO_KEYMAP: /* set keyboard translation table (compat) */ #ifndef KBD_DISABLE_KEYMAP_LOAD - mapp = malloc(sizeof *mapp, M_TEMP, M_NOWAIT); + mapp = malloc(sizeof *mapp, M_TEMP, M_WAITOK); if (cmd == OPIO_KEYMAP) { omapp = (okeymap_t *)arg; mapp->n_keys = omapp->n_keys; From owner-svn-src-stable@freebsd.org Wed Oct 19 13:42:42 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43C1DC18879; Wed, 19 Oct 2016 13:42:42 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1373E8B; Wed, 19 Oct 2016 13:42:42 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JDgfA2063457; Wed, 19 Oct 2016 13:42:41 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JDgfL7063456; Wed, 19 Oct 2016 13:42:41 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610191342.u9JDgfL7063456@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 19 Oct 2016 13:42:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307635 - stable/10/sys/dev/kbd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 13:42:42 -0000 Author: emaste Date: Wed Oct 19 13:42:40 2016 New Revision: 307635 URL: https://svnweb.freebsd.org/changeset/base/307635 Log: MFC r307145: Use M_WAITOK in PIO_KEYMAP ioctl The malloc return value is not checked. Modified: stable/10/sys/dev/kbd/kbd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/kbd/kbd.c ============================================================================== --- stable/10/sys/dev/kbd/kbd.c Wed Oct 19 13:37:43 2016 (r307634) +++ stable/10/sys/dev/kbd/kbd.c Wed Oct 19 13:42:40 2016 (r307635) @@ -888,7 +888,7 @@ genkbd_commonioctl(keyboard_t *kbd, u_lo case PIO_KEYMAP: /* set keyboard translation table */ case OPIO_KEYMAP: /* set keyboard translation table (compat) */ #ifndef KBD_DISABLE_KEYMAP_LOAD - mapp = malloc(sizeof *mapp, M_TEMP, M_NOWAIT); + mapp = malloc(sizeof *mapp, M_TEMP, M_WAITOK); if (cmd == OPIO_KEYMAP) { omapp = (okeymap_t *)arg; mapp->n_keys = omapp->n_keys; From owner-svn-src-stable@freebsd.org Wed Oct 19 16:33:44 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C66CAC189A9; Wed, 19 Oct 2016 16:33:44 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9805ABAA; Wed, 19 Oct 2016 16:33:44 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JGXhVB038488; Wed, 19 Oct 2016 16:33:43 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JGXhDb038487; Wed, 19 Oct 2016 16:33:43 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610191633.u9JGXhDb038487@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 19 Oct 2016 16:33:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307640 - stable/11/lib/libc/db/btree X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 16:33:44 -0000 Author: pfg Date: Wed Oct 19 16:33:43 2016 New Revision: 307640 URL: https://svnweb.freebsd.org/changeset/base/307640 Log: MFC r306332: btree(3): don't shortcut closing if the metadata is dirty. Obtained from: NetBSD (from krb5 tree) Modified: stable/11/lib/libc/db/btree/bt_close.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/db/btree/bt_close.c ============================================================================== --- stable/11/lib/libc/db/btree/bt_close.c Wed Oct 19 15:13:08 2016 (r307639) +++ stable/11/lib/libc/db/btree/bt_close.c Wed Oct 19 16:33:43 2016 (r307640) @@ -134,7 +134,8 @@ __bt_sync(const DB *dbp, u_int flags) return (RET_ERROR); } - if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED)) + if (F_ISSET(t, B_INMEM | B_RDONLY) || + !F_ISSET(t, B_MODIFIED | B_METADIRTY)) return (RET_SUCCESS); if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR) From owner-svn-src-stable@freebsd.org Wed Oct 19 16:40:40 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE959C18DB7; Wed, 19 Oct 2016 16:40:40 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 81765220; Wed, 19 Oct 2016 16:40:39 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JGeckN038768; Wed, 19 Oct 2016 16:40:38 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JGecRs038767; Wed, 19 Oct 2016 16:40:38 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610191640.u9JGecRs038767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 19 Oct 2016 16:40:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307641 - stable/10/lib/libc/db/btree X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 16:40:41 -0000 Author: pfg Date: Wed Oct 19 16:40:38 2016 New Revision: 307641 URL: https://svnweb.freebsd.org/changeset/base/307641 Log: MFC r306332: btree(3): don't shortcut closing if the metadata is dirty. Obtained from: NetBSD (from krb5 tree) Modified: stable/10/lib/libc/db/btree/bt_close.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/db/btree/bt_close.c ============================================================================== --- stable/10/lib/libc/db/btree/bt_close.c Wed Oct 19 16:33:43 2016 (r307640) +++ stable/10/lib/libc/db/btree/bt_close.c Wed Oct 19 16:40:38 2016 (r307641) @@ -134,7 +134,8 @@ __bt_sync(const DB *dbp, u_int flags) return (RET_ERROR); } - if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED)) + if (F_ISSET(t, B_INMEM | B_RDONLY) || + !F_ISSET(t, B_MODIFIED | B_METADIRTY)) return (RET_SUCCESS); if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR) From owner-svn-src-stable@freebsd.org Wed Oct 19 17:18:49 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF76EC19A40; Wed, 19 Oct 2016 17:18:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9F314C7A; Wed, 19 Oct 2016 17:18:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JHImFr053790; Wed, 19 Oct 2016 17:18:48 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JHIm6t053789; Wed, 19 Oct 2016 17:18:48 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610191718.u9JHIm6t053789@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Oct 2016 17:18:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307642 - stable/11/libexec/ypxfr X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 17:18:49 -0000 Author: markj Date: Wed Oct 19 17:18:48 2016 New Revision: 307642 URL: https://svnweb.freebsd.org/changeset/base/307642 Log: MFC r307398: Reference the libc symbols ypresp_{allfn,data} instead of local symbols. PR: 213506 Modified: stable/11/libexec/ypxfr/ypxfr_getmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/libexec/ypxfr/ypxfr_getmap.c ============================================================================== --- stable/11/libexec/ypxfr/ypxfr_getmap.c Wed Oct 19 16:40:38 2016 (r307641) +++ stable/11/libexec/ypxfr/ypxfr_getmap.c Wed Oct 19 17:18:48 2016 (r307642) @@ -43,8 +43,8 @@ __FBSDID("$FreeBSD$"); extern bool_t xdr_ypresp_all_seq(XDR *, unsigned long *); -static int (*ypresp_allfn)(); -static void *ypresp_data; +extern int (*ypresp_allfn)(); +extern void *ypresp_data; extern DB *specdbp; extern enum ypstat yp_errno; From owner-svn-src-stable@freebsd.org Wed Oct 19 17:21:40 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80FF3C19BE7; Wed, 19 Oct 2016 17:21:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50ECFF99; Wed, 19 Oct 2016 17:21:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JHLdtB056581; Wed, 19 Oct 2016 17:21:39 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JHLdhS056580; Wed, 19 Oct 2016 17:21:39 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610191721.u9JHLdhS056580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Oct 2016 17:21:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307643 - stable/11/usr.sbin/pmcstat X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 17:21:40 -0000 Author: markj Date: Wed Oct 19 17:21:39 2016 New Revision: 307643 URL: https://svnweb.freebsd.org/changeset/base/307643 Log: MFC r307384: Remove an unused field from struct pmcstat_image. Modified: stable/11/usr.sbin/pmcstat/pmcstat_log.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/pmcstat/pmcstat_log.h ============================================================================== --- stable/11/usr.sbin/pmcstat/pmcstat_log.h Wed Oct 19 17:18:48 2016 (r307642) +++ stable/11/usr.sbin/pmcstat/pmcstat_log.h Wed Oct 19 17:21:39 2016 (r307643) @@ -76,7 +76,6 @@ enum pmcstat_image_type { struct pmcstat_image { LIST_ENTRY(pmcstat_image) pi_next; /* hash link */ - TAILQ_ENTRY(pmcstat_image) pi_lru; /* LRU list */ pmcstat_interned_string pi_execpath; /* cookie */ pmcstat_interned_string pi_samplename; /* sample path name */ pmcstat_interned_string pi_fullpath; /* path to FS object */ From owner-svn-src-stable@freebsd.org Wed Oct 19 17:23:51 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7177AC19C86; Wed, 19 Oct 2016 17:23:51 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 344DD33C; Wed, 19 Oct 2016 17:23:51 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JHNovM057412; Wed, 19 Oct 2016 17:23:50 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JHNo5h057410; Wed, 19 Oct 2016 17:23:50 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610191723.u9JHNo5h057410@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Oct 2016 17:23:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307644 - stable/11/sys/netinet6 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 17:23:51 -0000 Author: markj Date: Wed Oct 19 17:23:50 2016 New Revision: 307644 URL: https://svnweb.freebsd.org/changeset/base/307644 Log: MFC r306792-r306795, r306826, r306828: Miscellaneous ND6 code cleanups. Modified: stable/11/sys/netinet6/nd6.c stable/11/sys/netinet6/nd6_rtr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/nd6.c ============================================================================== --- stable/11/sys/netinet6/nd6.c Wed Oct 19 17:21:39 2016 (r307643) +++ stable/11/sys/netinet6/nd6.c Wed Oct 19 17:23:50 2016 (r307644) @@ -1227,7 +1227,7 @@ nd6_is_new_addr_neighbor(const struct so struct ifaddr *dstaddr; struct rt_addrinfo info; struct sockaddr_in6 rt_key; - struct sockaddr *dst6; + const struct sockaddr *dst6; int fibnum; /* @@ -1273,7 +1273,7 @@ nd6_is_new_addr_neighbor(const struct so if (!(pr->ndpr_stateflags & NDPRF_ONLINK)) { /* Always use the default FIB here. */ - dst6 = (struct sockaddr *)&pr->ndpr_prefix; + dst6 = (const struct sockaddr *)&pr->ndpr_prefix; /* Restore length field before retrying lookup */ rt_key.sin6_len = sizeof(rt_key); Modified: stable/11/sys/netinet6/nd6_rtr.c ============================================================================== --- stable/11/sys/netinet6/nd6_rtr.c Wed Oct 19 17:21:39 2016 (r307643) +++ stable/11/sys/netinet6/nd6_rtr.c Wed Oct 19 17:23:50 2016 (r307644) @@ -76,17 +76,16 @@ static int prelist_update(struct nd_pref struct mbuf *, int); static struct in6_ifaddr *in6_ifadd(struct nd_prefixctl *, int); static struct nd_pfxrouter *pfxrtr_lookup(struct nd_prefix *, - struct nd_defrouter *); + struct nd_defrouter *); static void pfxrtr_add(struct nd_prefix *, struct nd_defrouter *); static void pfxrtr_del(struct nd_pfxrouter *); -static struct nd_pfxrouter *find_pfxlist_reachable_router -(struct nd_prefix *); +static struct nd_pfxrouter *find_pfxlist_reachable_router(struct nd_prefix *); static void defrouter_delreq(struct nd_defrouter *); static void nd6_rtmsg(int, struct rtentry *); static int in6_init_prefix_ltimes(struct nd_prefix *); static void in6_init_address_ltimes(struct nd_prefix *, - struct in6_addrlifetime *); + struct in6_addrlifetime *); static int nd6_prefix_onlink(struct nd_prefix *); static int nd6_prefix_offlink(struct nd_prefix *); @@ -1432,7 +1431,7 @@ find_pfxlist_reachable_router(struct nd_ * we have moved from the network but the lifetime of the prefix has not * expired yet. So we should not use the prefix if there is another prefix * that has an available router. - * But, if there is no prefix that has an available router, we still regards + * But, if there is no prefix that has an available router, we still regard * all the prefixes as on-link. This is because we can't tell if all the * routers are simply dead or if we really moved from the network and there * is no router around us. @@ -1485,40 +1484,26 @@ pfxlist_onlink_check(void) */ LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) { /* XXX: a link-local prefix should never be detached */ - if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr)) - continue; - - /* - * we aren't interested in prefixes without the L bit - * set. - */ - if (pr->ndpr_raf_onlink == 0) - continue; - - if (pr->ndpr_raf_auto == 0) + if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr) || + pr->ndpr_raf_onlink == 0 || + pr->ndpr_raf_auto == 0) continue; if ((pr->ndpr_stateflags & NDPRF_DETACHED) == 0 && find_pfxlist_reachable_router(pr) == NULL) pr->ndpr_stateflags |= NDPRF_DETACHED; - if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 && + else if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 && find_pfxlist_reachable_router(pr) != NULL) pr->ndpr_stateflags &= ~NDPRF_DETACHED; } } else { /* there is no prefix that has a reachable router */ LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) { - if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr)) + if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr) || + pr->ndpr_raf_onlink == 0 || + pr->ndpr_raf_auto == 0) continue; - - if (pr->ndpr_raf_onlink == 0) - continue; - - if (pr->ndpr_raf_auto == 0) - continue; - - if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0) - pr->ndpr_stateflags &= ~NDPRF_DETACHED; + pr->ndpr_stateflags &= ~NDPRF_DETACHED; } } @@ -1531,16 +1516,12 @@ pfxlist_onlink_check(void) * so we don't have to care about them. */ LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) { - int e; char ip6buf[INET6_ADDRSTRLEN]; + int e; - if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr)) - continue; - - if (pr->ndpr_raf_onlink == 0) - continue; - - if (pr->ndpr_raf_auto == 0) + if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr) || + pr->ndpr_raf_onlink == 0 || + pr->ndpr_raf_auto == 0) continue; if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 && @@ -1753,11 +1734,11 @@ nd6_prefix_onlink(struct nd_prefix *pr) /* XXX: freebsd does not have ifa_ifwithaf */ IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - if (ifa->ifa_addr->sa_family == AF_INET6) + if (ifa->ifa_addr->sa_family == AF_INET6) { + ifa_ref(ifa); break; + } } - if (ifa != NULL) - ifa_ref(ifa); IF_ADDR_RUNLOCK(ifp); /* should we care about ia6_flags? */ } @@ -1844,17 +1825,12 @@ nd6_prefix_offlink(struct nd_prefix *pr) * interface. */ LIST_FOREACH(opr, &V_nd_prefix, ndpr_entry) { - if (opr == pr) - continue; - - if ((opr->ndpr_stateflags & NDPRF_ONLINK) != 0) - continue; - /* * KAME specific: detached prefixes should not be * on-link. */ - if ((opr->ndpr_stateflags & NDPRF_DETACHED) != 0) + if (opr == pr || (opr->ndpr_stateflags & + (NDPRF_ONLINK | NDPRF_DETACHED)) != 0) continue; if (opr->ndpr_plen == pr->ndpr_plen && From owner-svn-src-stable@freebsd.org Wed Oct 19 17:24:37 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F404C19CE3; Wed, 19 Oct 2016 17:24:37 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 170476E1; Wed, 19 Oct 2016 17:24:37 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JHOaAD057495; Wed, 19 Oct 2016 17:24:36 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JHOa6M057494; Wed, 19 Oct 2016 17:24:36 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610191724.u9JHOa6M057494@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Oct 2016 17:24:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307645 - stable/11/sys/geom/mirror X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 17:24:37 -0000 Author: markj Date: Wed Oct 19 17:24:36 2016 New Revision: 307645 URL: https://svnweb.freebsd.org/changeset/base/307645 Log: MFC r306742: gmirror: Use bool instead of boolean_t. Modified: stable/11/sys/geom/mirror/g_mirror.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/11/sys/geom/mirror/g_mirror.c Wed Oct 19 17:23:50 2016 (r307644) +++ stable/11/sys/geom/mirror/g_mirror.c Wed Oct 19 17:24:36 2016 (r307645) @@ -99,7 +99,7 @@ struct g_class g_mirror_class = { static void g_mirror_destroy_provider(struct g_mirror_softc *sc); static int g_mirror_update_disk(struct g_mirror_disk *disk, u_int state); -static void g_mirror_update_device(struct g_mirror_softc *sc, boolean_t force); +static void g_mirror_update_device(struct g_mirror_softc *sc, bool force); static void g_mirror_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp); static void g_mirror_sync_stop(struct g_mirror_disk *disk, int type); @@ -1822,7 +1822,7 @@ g_mirror_worker(void *arg) "Running event for device %s.", sc->sc_name); ep->e_error = 0; - g_mirror_update_device(sc, 1); + g_mirror_update_device(sc, true); } else { /* Update disk status. */ G_MIRROR_DEBUG(3, "Running event for disk %s.", @@ -1830,7 +1830,7 @@ g_mirror_worker(void *arg) ep->e_error = g_mirror_update_disk(ep->e_disk, ep->e_state); if (ep->e_error == 0) - g_mirror_update_device(sc, 0); + g_mirror_update_device(sc, false); } if ((ep->e_flags & G_MIRROR_EVENT_DONTWAIT) != 0) { KASSERT(ep->e_error == 0, @@ -2228,7 +2228,7 @@ g_mirror_determine_state(struct g_mirror * Update device state. */ static void -g_mirror_update_device(struct g_mirror_softc *sc, boolean_t force) +g_mirror_update_device(struct g_mirror_softc *sc, bool force) { struct g_mirror_disk *disk; u_int state; From owner-svn-src-stable@freebsd.org Wed Oct 19 17:32:00 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A6BA4C19E5D; Wed, 19 Oct 2016 17:32:00 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 768D8C31; Wed, 19 Oct 2016 17:32:00 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JHVxIn059814; Wed, 19 Oct 2016 17:31:59 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JHVxYK059813; Wed, 19 Oct 2016 17:31:59 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610191731.u9JHVxYK059813@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Oct 2016 17:31:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307646 - stable/10/usr.sbin/rtsold X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 17:32:00 -0000 Author: markj Date: Wed Oct 19 17:31:59 2016 New Revision: 307646 URL: https://svnweb.freebsd.org/changeset/base/307646 Log: MFC r306571: rtsold: Log messages about unexpected RAs at LOG_DEBUG. Modified: stable/10/usr.sbin/rtsold/rtsol.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/rtsold/rtsol.c ============================================================================== --- stable/10/usr.sbin/rtsold/rtsol.c Wed Oct 19 17:24:36 2016 (r307645) +++ stable/10/usr.sbin/rtsold/rtsol.c Wed Oct 19 17:31:59 2016 (r307646) @@ -347,7 +347,7 @@ rtsol_input(int s) /* xxx: more validation? */ if ((ifi = find_ifinfo(pi->ipi6_ifindex)) == NULL) { - warnmsg(LOG_INFO, __func__, + warnmsg(LOG_DEBUG, __func__, "received RA from %s on an unexpected IF(%s)", inet_ntop(AF_INET6, &from.sin6_addr, ntopbuf, sizeof(ntopbuf)), From owner-svn-src-stable@freebsd.org Wed Oct 19 17:32:39 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9EA4C19EB5; Wed, 19 Oct 2016 17:32:39 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AB8AFE00; Wed, 19 Oct 2016 17:32:39 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JHWc7J061150; Wed, 19 Oct 2016 17:32:38 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JHWcgM061149; Wed, 19 Oct 2016 17:32:38 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610191732.u9JHWcgM061149@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Oct 2016 17:32:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307647 - stable/11/usr.sbin/rtsold X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 19 Oct 2016 17:32:40 -0000 Author: markj Date: Wed Oct 19 17:32:38 2016 New Revision: 307647 URL: https://svnweb.freebsd.org/changeset/base/307647 Log: MFC r306571: rtsold: Log messages about unexpected RAs at LOG_DEBUG. Modified: stable/11/usr.sbin/rtsold/rtsol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/rtsold/rtsol.c ============================================================================== --- stable/11/usr.sbin/rtsold/rtsol.c Wed Oct 19 17:31:59 2016 (r307646) +++ stable/11/usr.sbin/rtsold/rtsol.c Wed Oct 19 17:32:38 2016 (r307647) @@ -347,7 +347,7 @@ rtsol_input(int s) /* xxx: more validation? */ if ((ifi = find_ifinfo(pi->ipi6_ifindex)) == NULL) { - warnmsg(LOG_INFO, __func__, + warnmsg(LOG_DEBUG, __func__, "received RA from %s on an unexpected IF(%s)", inet_ntop(AF_INET6, &from.sin6_addr, ntopbuf, sizeof(ntopbuf)), From owner-svn-src-stable@freebsd.org Thu Oct 20 02:03:20 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E955FC193C0; Thu, 20 Oct 2016 02:03:20 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BABB2F93; Thu, 20 Oct 2016 02:03:20 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9K23J3D056866; Thu, 20 Oct 2016 02:03:19 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9K23Jwx056865; Thu, 20 Oct 2016 02:03:19 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201610200203.u9K23Jwx056865@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 20 Oct 2016 02:03:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307664 - stable/11/sys/netinet X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Oct 2016 02:03:21 -0000 Author: rmacklem Date: Thu Oct 20 02:03:19 2016 New Revision: 307664 URL: https://svnweb.freebsd.org/changeset/base/307664 Log: MFC: r306559 r297225 broke udp_output() for the case where the "addr" argument is NULL and the function jumps to the "release:" label. For this case, the "inp" was write locked, but the code attempted to read unlock it. This patch fixes the problem. This case could occur for NFS over UDP mounts, where the server was down for a few minutes under certain circumstances. Modified: stable/11/sys/netinet/udp_usrreq.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/udp_usrreq.c ============================================================================== --- stable/11/sys/netinet/udp_usrreq.c Thu Oct 20 01:21:10 2016 (r307663) +++ stable/11/sys/netinet/udp_usrreq.c Thu Oct 20 02:03:19 2016 (r307664) @@ -1559,12 +1559,18 @@ udp_output(struct inpcb *inp, struct mbu release: if (unlock_udbinfo == UH_WLOCKED) { + KASSERT(unlock_inp == UH_WLOCKED, + ("%s: excl udbinfo lock, shared inp lock", __func__)); INP_HASH_WUNLOCK(pcbinfo); INP_WUNLOCK(inp); } else if (unlock_udbinfo == UH_RLOCKED) { + KASSERT(unlock_inp == UH_RLOCKED, + ("%s: shared udbinfo lock, excl inp lock", __func__)); INP_HASH_RUNLOCK(pcbinfo); INP_RUNLOCK(inp); - } else + } else if (unlock_inp == UH_WLOCKED) + INP_WUNLOCK(inp); + else INP_RUNLOCK(inp); m_freem(m); return (error); From owner-svn-src-stable@freebsd.org Thu Oct 20 08:49:00 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71F9DC19291; Thu, 20 Oct 2016 08:49:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3274A3BF; Thu, 20 Oct 2016 08:49:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9K8mxQn008084; Thu, 20 Oct 2016 08:48:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9K8mxbx008081; Thu, 20 Oct 2016 08:48:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610200848.u9K8mxbx008081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 20 Oct 2016 08:48:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307665 - stable/11/sys/geom/mirror X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Oct 2016 08:49:00 -0000 Author: mav Date: Thu Oct 20 08:48:58 2016 New Revision: 307665 URL: https://svnweb.freebsd.org/changeset/base/307665 Log: MFC r306762: Fix possible geom destruction before final provider close. Introduce internal counter to track opens. Using provider's counters is not very successfull after calling g_wither_provider(). Modified: stable/11/sys/geom/mirror/g_mirror.c stable/11/sys/geom/mirror/g_mirror.h stable/11/sys/geom/mirror/g_mirror_ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/11/sys/geom/mirror/g_mirror.c Thu Oct 20 02:03:19 2016 (r307664) +++ stable/11/sys/geom/mirror/g_mirror.c Thu Oct 20 08:48:58 2016 (r307665) @@ -2137,10 +2137,9 @@ g_mirror_destroy_provider(struct g_mirro } } mtx_unlock(&sc->sc_queue_mtx); - G_MIRROR_DEBUG(0, "Device %s: provider %s destroyed.", sc->sc_name, - sc->sc_provider->name); g_wither_provider(sc->sc_provider, ENXIO); sc->sc_provider = NULL; + G_MIRROR_DEBUG(0, "Device %s: provider destroyed.", sc->sc_name); g_topology_unlock(); LIST_FOREACH(disk, &sc->sc_disks, d_next) { if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) @@ -2866,7 +2865,7 @@ static int g_mirror_access(struct g_provider *pp, int acr, int acw, int ace) { struct g_mirror_softc *sc; - int dcr, dcw, dce, error = 0; + int error = 0; g_topology_assert(); G_MIRROR_DEBUG(2, "Access request for %s: r%dw%de%d.", pp->name, acr, @@ -2877,30 +2876,21 @@ g_mirror_access(struct g_provider *pp, i return (0); KASSERT(sc != NULL, ("NULL softc (provider=%s).", pp->name)); - dcr = pp->acr + acr; - dcw = pp->acw + acw; - dce = pp->ace + ace; - g_topology_unlock(); sx_xlock(&sc->sc_lock); if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROY) != 0 || + (sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROYING) != 0 || LIST_EMPTY(&sc->sc_disks)) { if (acr > 0 || acw > 0 || ace > 0) error = ENXIO; goto end; } - if (dcw == 0) - g_mirror_idle(sc, dcw); - if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROYING) != 0) { - if (acr > 0 || acw > 0 || ace > 0) { - error = ENXIO; - goto end; - } - if (dcr == 0 && dcw == 0 && dce == 0) { - g_post_event(g_mirror_destroy_delayed, sc, M_WAITOK, - sc, NULL); - } - } + sc->sc_provider_open += acr + acw + ace; + if (pp->acw + acw == 0) + g_mirror_idle(sc, 0); + if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROYING) != 0 && + sc->sc_provider_open == 0) + g_post_event(g_mirror_destroy_delayed, sc, M_WAITOK, sc, NULL); end: sx_xunlock(&sc->sc_lock); g_topology_lock(); @@ -2957,6 +2947,7 @@ g_mirror_create(struct g_class *mp, cons gp->softc = sc; sc->sc_geom = gp; sc->sc_provider = NULL; + sc->sc_provider_open = 0; /* * Synchronization geom. */ @@ -2997,26 +2988,23 @@ int g_mirror_destroy(struct g_mirror_softc *sc, int how) { struct g_mirror_disk *disk; - struct g_provider *pp; g_topology_assert_not(); if (sc == NULL) return (ENXIO); sx_assert(&sc->sc_lock, SX_XLOCKED); - pp = sc->sc_provider; - if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0 || - SCHEDULER_STOPPED())) { + if (sc->sc_provider_open != 0 || SCHEDULER_STOPPED()) { switch (how) { case G_MIRROR_DESTROY_SOFT: G_MIRROR_DEBUG(1, - "Device %s is still open (r%dw%de%d).", pp->name, - pp->acr, pp->acw, pp->ace); + "Device %s is still open (%d).", sc->sc_name, + sc->sc_provider_open); return (EBUSY); case G_MIRROR_DESTROY_DELAYED: G_MIRROR_DEBUG(1, "Device %s will be destroyed on last close.", - pp->name); + sc->sc_name); LIST_FOREACH(disk, &sc->sc_disks, d_next) { if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) { @@ -3027,7 +3015,7 @@ g_mirror_destroy(struct g_mirror_softc * return (EBUSY); case G_MIRROR_DESTROY_HARD: G_MIRROR_DEBUG(1, "Device %s is still open, so it " - "can't be definitely removed.", pp->name); + "can't be definitely removed.", sc->sc_name); } } Modified: stable/11/sys/geom/mirror/g_mirror.h ============================================================================== --- stable/11/sys/geom/mirror/g_mirror.h Thu Oct 20 02:03:19 2016 (r307664) +++ stable/11/sys/geom/mirror/g_mirror.h Thu Oct 20 08:48:58 2016 (r307665) @@ -179,6 +179,7 @@ struct g_mirror_softc { struct g_geom *sc_geom; struct g_provider *sc_provider; + int sc_provider_open; uint32_t sc_id; /* Mirror unique ID. */ Modified: stable/11/sys/geom/mirror/g_mirror_ctl.c ============================================================================== --- stable/11/sys/geom/mirror/g_mirror_ctl.c Thu Oct 20 02:03:19 2016 (r307664) +++ stable/11/sys/geom/mirror/g_mirror_ctl.c Thu Oct 20 08:48:58 2016 (r307665) @@ -658,8 +658,7 @@ g_mirror_ctl_resize(struct gctl_req *req return; } /* Deny shrinking of an opened provider */ - if ((g_debugflags & 16) == 0 && (sc->sc_provider->acr > 0 || - sc->sc_provider->acw > 0 || sc->sc_provider->ace > 0)) { + if ((g_debugflags & 16) == 0 && sc->sc_provider_open > 0) { if (sc->sc_mediasize > mediasize) { gctl_error(req, "Device %s is busy.", sc->sc_provider->name); From owner-svn-src-stable@freebsd.org Thu Oct 20 09:06:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B8F3C1997C; Thu, 20 Oct 2016 09:06:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 02FB7F21; Thu, 20 Oct 2016 09:06:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9K96ecw015438; Thu, 20 Oct 2016 09:06:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9K96d7e015434; Thu, 20 Oct 2016 09:06:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610200906.u9K96d7e015434@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 20 Oct 2016 09:06:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307666 - stable/10/sys/geom/mirror X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Oct 2016 09:06:41 -0000 Author: mav Date: Thu Oct 20 09:06:39 2016 New Revision: 307666 URL: https://svnweb.freebsd.org/changeset/base/307666 Log: MFC r306762: Fix possible geom destruction before final provider close. Introduce internal counter to track opens. Using provider's counters is not very successfull after calling g_wither_provider(). Modified: stable/10/sys/geom/mirror/g_mirror.c stable/10/sys/geom/mirror/g_mirror.h stable/10/sys/geom/mirror/g_mirror_ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/10/sys/geom/mirror/g_mirror.c Thu Oct 20 08:48:58 2016 (r307665) +++ stable/10/sys/geom/mirror/g_mirror.c Thu Oct 20 09:06:39 2016 (r307666) @@ -2143,10 +2143,9 @@ g_mirror_destroy_provider(struct g_mirro } } mtx_unlock(&sc->sc_queue_mtx); - G_MIRROR_DEBUG(0, "Device %s: provider %s destroyed.", sc->sc_name, - sc->sc_provider->name); g_wither_provider(sc->sc_provider, ENXIO); sc->sc_provider = NULL; + G_MIRROR_DEBUG(0, "Device %s: provider destroyed.", sc->sc_name); g_topology_unlock(); LIST_FOREACH(disk, &sc->sc_disks, d_next) { if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) @@ -2872,7 +2871,7 @@ static int g_mirror_access(struct g_provider *pp, int acr, int acw, int ace) { struct g_mirror_softc *sc; - int dcr, dcw, dce, error = 0; + int error = 0; g_topology_assert(); G_MIRROR_DEBUG(2, "Access request for %s: r%dw%de%d.", pp->name, acr, @@ -2883,30 +2882,21 @@ g_mirror_access(struct g_provider *pp, i return (0); KASSERT(sc != NULL, ("NULL softc (provider=%s).", pp->name)); - dcr = pp->acr + acr; - dcw = pp->acw + acw; - dce = pp->ace + ace; - g_topology_unlock(); sx_xlock(&sc->sc_lock); if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROY) != 0 || + (sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROYING) != 0 || LIST_EMPTY(&sc->sc_disks)) { if (acr > 0 || acw > 0 || ace > 0) error = ENXIO; goto end; } - if (dcw == 0) - g_mirror_idle(sc, dcw); - if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROYING) != 0) { - if (acr > 0 || acw > 0 || ace > 0) { - error = ENXIO; - goto end; - } - if (dcr == 0 && dcw == 0 && dce == 0) { - g_post_event(g_mirror_destroy_delayed, sc, M_WAITOK, - sc, NULL); - } - } + sc->sc_provider_open += acr + acw + ace; + if (pp->acw + acw == 0) + g_mirror_idle(sc, 0); + if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROYING) != 0 && + sc->sc_provider_open == 0) + g_post_event(g_mirror_destroy_delayed, sc, M_WAITOK, sc, NULL); end: sx_xunlock(&sc->sc_lock); g_topology_lock(); @@ -2963,6 +2953,7 @@ g_mirror_create(struct g_class *mp, cons gp->softc = sc; sc->sc_geom = gp; sc->sc_provider = NULL; + sc->sc_provider_open = 0; /* * Synchronization geom. */ @@ -3003,25 +2994,23 @@ int g_mirror_destroy(struct g_mirror_softc *sc, int how) { struct g_mirror_disk *disk; - struct g_provider *pp; g_topology_assert_not(); if (sc == NULL) return (ENXIO); sx_assert(&sc->sc_lock, SX_XLOCKED); - pp = sc->sc_provider; - if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) { + if (sc->sc_provider_open != 0) { switch (how) { case G_MIRROR_DESTROY_SOFT: G_MIRROR_DEBUG(1, - "Device %s is still open (r%dw%de%d).", pp->name, - pp->acr, pp->acw, pp->ace); + "Device %s is still open (%d).", sc->sc_name, + sc->sc_provider_open); return (EBUSY); case G_MIRROR_DESTROY_DELAYED: G_MIRROR_DEBUG(1, "Device %s will be destroyed on last close.", - pp->name); + sc->sc_name); LIST_FOREACH(disk, &sc->sc_disks, d_next) { if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) { @@ -3032,7 +3021,7 @@ g_mirror_destroy(struct g_mirror_softc * return (EBUSY); case G_MIRROR_DESTROY_HARD: G_MIRROR_DEBUG(1, "Device %s is still open, so it " - "can't be definitely removed.", pp->name); + "can't be definitely removed.", sc->sc_name); } } Modified: stable/10/sys/geom/mirror/g_mirror.h ============================================================================== --- stable/10/sys/geom/mirror/g_mirror.h Thu Oct 20 08:48:58 2016 (r307665) +++ stable/10/sys/geom/mirror/g_mirror.h Thu Oct 20 09:06:39 2016 (r307666) @@ -179,6 +179,7 @@ struct g_mirror_softc { struct g_geom *sc_geom; struct g_provider *sc_provider; + int sc_provider_open; uint32_t sc_id; /* Mirror unique ID. */ Modified: stable/10/sys/geom/mirror/g_mirror_ctl.c ============================================================================== --- stable/10/sys/geom/mirror/g_mirror_ctl.c Thu Oct 20 08:48:58 2016 (r307665) +++ stable/10/sys/geom/mirror/g_mirror_ctl.c Thu Oct 20 09:06:39 2016 (r307666) @@ -658,8 +658,7 @@ g_mirror_ctl_resize(struct gctl_req *req return; } /* Deny shrinking of an opened provider */ - if ((g_debugflags & 16) == 0 && (sc->sc_provider->acr > 0 || - sc->sc_provider->acw > 0 || sc->sc_provider->ace > 0)) { + if ((g_debugflags & 16) == 0 && sc->sc_provider_open > 0) { if (sc->sc_mediasize > mediasize) { gctl_error(req, "Device %s is busy.", sc->sc_provider->name); From owner-svn-src-stable@freebsd.org Thu Oct 20 11:42:31 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CF47C1A0F0; Thu, 20 Oct 2016 11:42:31 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C19EBE5; Thu, 20 Oct 2016 11:42:31 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9KBgUPt076445; Thu, 20 Oct 2016 11:42:30 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9KBgTEr076438; Thu, 20 Oct 2016 11:42:29 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610201142.u9KBgTEr076438@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 20 Oct 2016 11:42:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307671 - in stable/11/sys: cddl/contrib/opensolaris/uts/common/fs/zfs dev/drm2/i915 dev/drm2/ttm kern vm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Oct 2016 11:42:31 -0000 Author: kib Date: Thu Oct 20 11:42:29 2016 New Revision: 307671 URL: https://svnweb.freebsd.org/changeset/base/307671 Log: MFC r307218: Fix a race in vm_page_busy_sleep(9). Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c stable/11/sys/dev/drm2/i915/i915_gem.c stable/11/sys/dev/drm2/ttm/ttm_bo_vm.c stable/11/sys/kern/vfs_bio.c stable/11/sys/vm/vm_object.c stable/11/sys/vm/vm_page.c stable/11/sys/vm/vm_page.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Oct 20 11:31:11 2016 (r307670) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Oct 20 11:42:29 2016 (r307671) @@ -421,7 +421,7 @@ page_busy(vnode_t *vp, int64_t start, in vm_page_reference(pp); vm_page_lock(pp); zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb"); + vm_page_busy_sleep(pp, "zfsmwb", true); zfs_vmobject_wlock(obj); continue; } @@ -476,7 +476,7 @@ page_hold(vnode_t *vp, int64_t start) vm_page_reference(pp); vm_page_lock(pp); zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb"); + vm_page_busy_sleep(pp, "zfsmwb", true); zfs_vmobject_wlock(obj); continue; } Modified: stable/11/sys/dev/drm2/i915/i915_gem.c ============================================================================== --- stable/11/sys/dev/drm2/i915/i915_gem.c Thu Oct 20 11:31:11 2016 (r307670) +++ stable/11/sys/dev/drm2/i915/i915_gem.c Thu Oct 20 11:42:29 2016 (r307671) @@ -1533,7 +1533,7 @@ retry: DRM_UNLOCK(dev); vm_page_lock(page); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(page, "915pee"); + vm_page_busy_sleep(page, "915pee", false); goto retry; } goto have_page; @@ -1575,7 +1575,7 @@ retry: DRM_UNLOCK(dev); vm_page_lock(page); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(page, "915pbs"); + vm_page_busy_sleep(page, "915pbs", false); goto retry; } if (vm_page_insert(page, vm_obj, OFF_TO_IDX(offset))) { Modified: stable/11/sys/dev/drm2/ttm/ttm_bo_vm.c ============================================================================== --- stable/11/sys/dev/drm2/ttm/ttm_bo_vm.c Thu Oct 20 11:31:11 2016 (r307670) +++ stable/11/sys/dev/drm2/ttm/ttm_bo_vm.c Thu Oct 20 11:42:29 2016 (r307671) @@ -236,7 +236,7 @@ reserve: if (vm_page_busied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(m, "ttmpbs"); + vm_page_busy_sleep(m, "ttmpbs", false); VM_OBJECT_WLOCK(vm_obj); ttm_mem_io_unlock(man); ttm_bo_unreserve(bo); Modified: stable/11/sys/kern/vfs_bio.c ============================================================================== --- stable/11/sys/kern/vfs_bio.c Thu Oct 20 11:31:11 2016 (r307670) +++ stable/11/sys/kern/vfs_bio.c Thu Oct 20 11:42:29 2016 (r307671) @@ -2637,7 +2637,7 @@ vfs_vmio_invalidate(struct buf *bp) while (vm_page_xbusied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(obj); - vm_page_busy_sleep(m, "mbncsh"); + vm_page_busy_sleep(m, "mbncsh", true); VM_OBJECT_WLOCK(obj); } if (pmap_page_wired_mappings(m) == 0) @@ -4202,7 +4202,7 @@ vfs_drain_busy_pages(struct buf *bp) while (vm_page_xbusied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(bp->b_bufobj->bo_object); - vm_page_busy_sleep(m, "vbpage"); + vm_page_busy_sleep(m, "vbpage", true); VM_OBJECT_WLOCK(bp->b_bufobj->bo_object); } } Modified: stable/11/sys/vm/vm_object.c ============================================================================== --- stable/11/sys/vm/vm_object.c Thu Oct 20 11:31:11 2016 (r307670) +++ stable/11/sys/vm/vm_object.c Thu Oct 20 11:42:29 2016 (r307671) @@ -1186,7 +1186,7 @@ shadowlookup: if (object != tobject) VM_OBJECT_WUNLOCK(object); VM_OBJECT_WUNLOCK(tobject); - vm_page_busy_sleep(m, "madvpo"); + vm_page_busy_sleep(m, "madvpo", false); VM_OBJECT_WLOCK(object); goto relookup; } @@ -1365,7 +1365,7 @@ retry: VM_OBJECT_WUNLOCK(new_object); vm_page_lock(m); VM_OBJECT_WUNLOCK(orig_object); - vm_page_busy_sleep(m, "spltwt"); + vm_page_busy_sleep(m, "spltwt", false); VM_OBJECT_WLOCK(orig_object); VM_OBJECT_WLOCK(new_object); goto retry; @@ -1453,7 +1453,7 @@ vm_object_collapse_scan_wait(vm_object_t if (p == NULL) VM_WAIT; else - vm_page_busy_sleep(p, "vmocol"); + vm_page_busy_sleep(p, "vmocol", false); VM_OBJECT_WLOCK(object); VM_OBJECT_WLOCK(backing_object); return (TAILQ_FIRST(&backing_object->memq)); @@ -1912,7 +1912,7 @@ again: vm_page_lock(p); if (vm_page_xbusied(p)) { VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(p, "vmopax"); + vm_page_busy_sleep(p, "vmopax", true); VM_OBJECT_WLOCK(object); goto again; } @@ -1927,7 +1927,7 @@ again: } if (vm_page_busied(p)) { VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(p, "vmopar"); + vm_page_busy_sleep(p, "vmopar", false); VM_OBJECT_WLOCK(object); goto again; } Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Thu Oct 20 11:31:11 2016 (r307670) +++ stable/11/sys/vm/vm_page.c Thu Oct 20 11:42:29 2016 (r307671) @@ -743,21 +743,20 @@ vm_page_sunbusy(vm_page_t m) * This is used to implement the hard-path of busying mechanism. * * The given page must be locked. + * + * If nonshared is true, sleep only if the page is xbusy. */ void -vm_page_busy_sleep(vm_page_t m, const char *wmesg) +vm_page_busy_sleep(vm_page_t m, const char *wmesg, bool nonshared) { u_int x; - vm_page_lock_assert(m, MA_OWNED); + vm_page_assert_locked(m); x = m->busy_lock; - if (x == VPB_UNBUSIED) { - vm_page_unlock(m); - return; - } - if ((x & VPB_BIT_WAITERS) == 0 && - !atomic_cmpset_int(&m->busy_lock, x, x | VPB_BIT_WAITERS)) { + if (x == VPB_UNBUSIED || (nonshared && (x & VPB_BIT_SHARED) != 0) || + ((x & VPB_BIT_WAITERS) == 0 && + !atomic_cmpset_int(&m->busy_lock, x, x | VPB_BIT_WAITERS))) { vm_page_unlock(m); return; } @@ -1094,7 +1093,7 @@ vm_page_sleep_if_busy(vm_page_t m, const obj = m->object; vm_page_lock(m); VM_OBJECT_WUNLOCK(obj); - vm_page_busy_sleep(m, msg); + vm_page_busy_sleep(m, msg, false); VM_OBJECT_WLOCK(obj); return (TRUE); } @@ -3466,7 +3465,8 @@ retrylookup: vm_page_aflag_set(m, PGA_REFERENCED); vm_page_lock(m); VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(m, "pgrbwt"); + vm_page_busy_sleep(m, "pgrbwt", (allocflags & + VM_ALLOC_IGN_SBUSY) != 0); VM_OBJECT_WLOCK(object); goto retrylookup; } else { Modified: stable/11/sys/vm/vm_page.h ============================================================================== --- stable/11/sys/vm/vm_page.h Thu Oct 20 11:31:11 2016 (r307670) +++ stable/11/sys/vm/vm_page.h Thu Oct 20 11:42:29 2016 (r307671) @@ -437,7 +437,7 @@ malloc2vm_flags(int malloc_flags) #endif void vm_page_busy_downgrade(vm_page_t m); -void vm_page_busy_sleep(vm_page_t m, const char *msg); +void vm_page_busy_sleep(vm_page_t m, const char *msg, bool nonshared); void vm_page_flash(vm_page_t m); void vm_page_hold(vm_page_t mem); void vm_page_unhold(vm_page_t mem); From owner-svn-src-stable@freebsd.org Thu Oct 20 13:12:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71D7BC19115; Thu, 20 Oct 2016 13:12:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2F11AE4C; Thu, 20 Oct 2016 13:12:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9KDCKTT010335; Thu, 20 Oct 2016 13:12:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9KDCJXx010328; Thu, 20 Oct 2016 13:12:19 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610201312.u9KDCJXx010328@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 20 Oct 2016 13:12:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307672 - in stable/10/sys: cddl/contrib/opensolaris/uts/common/fs/zfs dev/drm2/i915 dev/drm2/ttm kern vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Oct 2016 13:12:21 -0000 Author: kib Date: Thu Oct 20 13:12:19 2016 New Revision: 307672 URL: https://svnweb.freebsd.org/changeset/base/307672 Log: MFC r307218: Fix a race in vm_page_busy_sleep(9). Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c stable/10/sys/dev/drm2/i915/i915_gem.c stable/10/sys/dev/drm2/ttm/ttm_bo_vm.c stable/10/sys/kern/vfs_bio.c stable/10/sys/vm/vm_object.c stable/10/sys/vm/vm_page.c stable/10/sys/vm/vm_page.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Oct 20 11:42:29 2016 (r307671) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Oct 20 13:12:19 2016 (r307672) @@ -421,7 +421,7 @@ page_busy(vnode_t *vp, int64_t start, in vm_page_reference(pp); vm_page_lock(pp); zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb"); + vm_page_busy_sleep(pp, "zfsmwb", true); zfs_vmobject_wlock(obj); continue; } @@ -476,7 +476,7 @@ page_hold(vnode_t *vp, int64_t start) vm_page_reference(pp); vm_page_lock(pp); zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb"); + vm_page_busy_sleep(pp, "zfsmwb", true); zfs_vmobject_wlock(obj); continue; } Modified: stable/10/sys/dev/drm2/i915/i915_gem.c ============================================================================== --- stable/10/sys/dev/drm2/i915/i915_gem.c Thu Oct 20 11:42:29 2016 (r307671) +++ stable/10/sys/dev/drm2/i915/i915_gem.c Thu Oct 20 13:12:19 2016 (r307672) @@ -1976,7 +1976,7 @@ retry: DRM_UNLOCK(dev); vm_page_lock(m); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(m, "915pee"); + vm_page_busy_sleep(m, "915pee", false); goto retry; } goto have_page; @@ -2037,7 +2037,7 @@ retry: DRM_UNLOCK(dev); vm_page_lock(m); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(m, "915pbs"); + vm_page_busy_sleep(m, "915pbs", false); goto retry; } if (vm_page_insert(m, vm_obj, OFF_TO_IDX(offset))) { Modified: stable/10/sys/dev/drm2/ttm/ttm_bo_vm.c ============================================================================== --- stable/10/sys/dev/drm2/ttm/ttm_bo_vm.c Thu Oct 20 11:42:29 2016 (r307671) +++ stable/10/sys/dev/drm2/ttm/ttm_bo_vm.c Thu Oct 20 13:12:19 2016 (r307672) @@ -239,7 +239,7 @@ reserve: if (vm_page_busied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(m, "ttmpbs"); + vm_page_busy_sleep(m, "ttmpbs", false); VM_OBJECT_WLOCK(vm_obj); ttm_mem_io_unlock(man); ttm_bo_unreserve(bo); Modified: stable/10/sys/kern/vfs_bio.c ============================================================================== --- stable/10/sys/kern/vfs_bio.c Thu Oct 20 11:42:29 2016 (r307671) +++ stable/10/sys/kern/vfs_bio.c Thu Oct 20 13:12:19 2016 (r307672) @@ -1724,7 +1724,7 @@ brelse(struct buf *bp) while (vm_page_xbusied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(obj); - vm_page_busy_sleep(m, "mbncsh"); + vm_page_busy_sleep(m, "mbncsh", true); VM_OBJECT_WLOCK(obj); } if (pmap_page_wired_mappings(m) == 0) @@ -4069,7 +4069,7 @@ vfs_drain_busy_pages(struct buf *bp) while (vm_page_xbusied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(bp->b_bufobj->bo_object); - vm_page_busy_sleep(m, "vbpage"); + vm_page_busy_sleep(m, "vbpage", true); VM_OBJECT_WLOCK(bp->b_bufobj->bo_object); } } Modified: stable/10/sys/vm/vm_object.c ============================================================================== --- stable/10/sys/vm/vm_object.c Thu Oct 20 11:42:29 2016 (r307671) +++ stable/10/sys/vm/vm_object.c Thu Oct 20 13:12:19 2016 (r307672) @@ -1182,7 +1182,7 @@ shadowlookup: if (object != tobject) VM_OBJECT_WUNLOCK(object); VM_OBJECT_WUNLOCK(tobject); - vm_page_busy_sleep(m, "madvpo"); + vm_page_busy_sleep(m, "madvpo", false); VM_OBJECT_WLOCK(object); goto relookup; } @@ -1361,7 +1361,7 @@ retry: VM_OBJECT_WUNLOCK(new_object); vm_page_lock(m); VM_OBJECT_WUNLOCK(orig_object); - vm_page_busy_sleep(m, "spltwt"); + vm_page_busy_sleep(m, "spltwt", false); VM_OBJECT_WLOCK(orig_object); VM_OBJECT_WLOCK(new_object); goto retry; @@ -1450,7 +1450,7 @@ vm_object_backing_scan_wait(vm_object_t if (p == NULL) VM_WAIT; else - vm_page_busy_sleep(p, "vmocol"); + vm_page_busy_sleep(p, "vmocol", false); VM_OBJECT_WLOCK(object); VM_OBJECT_WLOCK(backing_object); return (TAILQ_FIRST(&backing_object->memq)); @@ -1917,7 +1917,7 @@ again: vm_page_lock(p); if (vm_page_xbusied(p)) { VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(p, "vmopax"); + vm_page_busy_sleep(p, "vmopax", true); VM_OBJECT_WLOCK(object); goto again; } @@ -1932,7 +1932,7 @@ again: } if (vm_page_busied(p)) { VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(p, "vmopar"); + vm_page_busy_sleep(p, "vmopar", false); VM_OBJECT_WLOCK(object); goto again; } Modified: stable/10/sys/vm/vm_page.c ============================================================================== --- stable/10/sys/vm/vm_page.c Thu Oct 20 11:42:29 2016 (r307671) +++ stable/10/sys/vm/vm_page.c Thu Oct 20 13:12:19 2016 (r307672) @@ -601,21 +601,20 @@ vm_page_sunbusy(vm_page_t m) * This is used to implement the hard-path of busying mechanism. * * The given page must be locked. + * + * If nonshared is true, sleep only if the page is xbusy. */ void -vm_page_busy_sleep(vm_page_t m, const char *wmesg) +vm_page_busy_sleep(vm_page_t m, const char *wmesg, bool nonshared) { u_int x; - vm_page_lock_assert(m, MA_OWNED); + vm_page_assert_locked(m); x = m->busy_lock; - if (x == VPB_UNBUSIED) { - vm_page_unlock(m); - return; - } - if ((x & VPB_BIT_WAITERS) == 0 && - !atomic_cmpset_int(&m->busy_lock, x, x | VPB_BIT_WAITERS)) { + if (x == VPB_UNBUSIED || (nonshared && (x & VPB_BIT_SHARED) != 0) || + ((x & VPB_BIT_WAITERS) == 0 && + !atomic_cmpset_int(&m->busy_lock, x, x | VPB_BIT_WAITERS))) { vm_page_unlock(m); return; } @@ -928,7 +927,7 @@ vm_page_sleep_if_busy(vm_page_t m, const obj = m->object; vm_page_lock(m); VM_OBJECT_WUNLOCK(obj); - vm_page_busy_sleep(m, msg); + vm_page_busy_sleep(m, msg, false); VM_OBJECT_WLOCK(obj); return (TRUE); } @@ -2717,7 +2716,8 @@ retrylookup: vm_page_aflag_set(m, PGA_REFERENCED); vm_page_lock(m); VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(m, "pgrbwt"); + vm_page_busy_sleep(m, "pgrbwt", (allocflags & + VM_ALLOC_IGN_SBUSY) != 0); VM_OBJECT_WLOCK(object); goto retrylookup; } else { Modified: stable/10/sys/vm/vm_page.h ============================================================================== --- stable/10/sys/vm/vm_page.h Thu Oct 20 11:42:29 2016 (r307671) +++ stable/10/sys/vm/vm_page.h Thu Oct 20 13:12:19 2016 (r307672) @@ -420,7 +420,7 @@ malloc2vm_flags(int malloc_flags) #endif void vm_page_busy_downgrade(vm_page_t m); -void vm_page_busy_sleep(vm_page_t m, const char *msg); +void vm_page_busy_sleep(vm_page_t m, const char *msg, bool nonshared); void vm_page_flash(vm_page_t m); void vm_page_hold(vm_page_t mem); void vm_page_unhold(vm_page_t mem); From owner-svn-src-stable@freebsd.org Thu Oct 20 17:16:10 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70BCEC1A186; Thu, 20 Oct 2016 17:16:10 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3F2C18EA; Thu, 20 Oct 2016 17:16:10 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9KHG9vs004827; Thu, 20 Oct 2016 17:16:09 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9KHG9Xi004826; Thu, 20 Oct 2016 17:16:09 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610201716.u9KHG9Xi004826@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 20 Oct 2016 17:16:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307678 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 20 Oct 2016 17:16:10 -0000 Author: gjb Date: Thu Oct 20 17:16:09 2016 New Revision: 307678 URL: https://svnweb.freebsd.org/changeset/base/307678 Log: Add an EN item regarding some recent systems that fail to boot under certain circumstances. Approved by: re (implicit) Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Thu Oct 20 17:10:26 2016 (r307677) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Thu Oct 20 17:16:09 2016 (r307678) @@ -198,6 +198,17 @@ boot + + + [2016-10-20] Several recent Dell + systems fail to find a bootable disk when the system boots + in Legacy/BIOS/CSM mode, the boot disk is partitioned with + GPT, and the Active flag in the + Protective MBR is not set. To work + around this issue, either configure the system to boot in + UEFI mode, or choose the "GPT + + Active" scheme. + From owner-svn-src-stable@freebsd.org Fri Oct 21 03:10:08 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DB68C195A8; Fri, 21 Oct 2016 03:10:08 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B1BA13BF; Fri, 21 Oct 2016 03:10:08 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L3A7SH033820; Fri, 21 Oct 2016 03:10:07 GMT (envelope-from araujo@FreeBSD.org) Received: (from araujo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L3A59r033802; Fri, 21 Oct 2016 03:10:05 GMT (envelope-from araujo@FreeBSD.org) Message-Id: <201610210310.u9L3A59r033802@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: araujo set sender to araujo@FreeBSD.org using -f From: Marcelo Araujo Date: Fri, 21 Oct 2016 03:10:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307697 - in stable/11: sbin/natd usr.bin/calendar usr.bin/gzip usr.bin/indent usr.bin/locale usr.bin/localedef usr.bin/netstat usr.bin/procstat usr.bin/rpcgen usr.bin/systat usr.sbin/c... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 03:10:08 -0000 Author: araujo Date: Fri Oct 21 03:10:05 2016 New Revision: 307697 URL: https://svnweb.freebsd.org/changeset/base/307697 Log: MFC r303541, r303542, r303543, r303545, r303546, r303547, r304225, r304226, r304605, r304676, r305212, r305863: r303541: Use nitems() from sys/param.h. Sponsored by: gandi.net (BSD Day Taiwan) MFC after: 2 weeks. r303542: Use nitems() from sys/param.h. MFC after: 2 weeks. Sponsored by: gandi.net (BSD Day Taiwan) r303543: Use nitems() from sys/param.h. MFC after: 2 weeks. Sponsored by: gandi.net (BSD Day Taiwan) r303545: Use nitems() from sys/param.h. MFC after: 2 weeks. Sponsored by: gandi.net (BSD Day Taiwan) r303546: Use nitems() from sys/param.h. MFC after: 2 weeks. Sponsored by: gandi.net (BSD Day Taiwan) r303547: Use nitems() from sys/param.h. MFC after: 2 weeks. Sponsored by: gandi.net (BSD Day Taiwan) r304225: Use nitems() from sys/param.h. MFC after: 2 weeks. r304226: Use nitems() from sys/param.h. MFC after: 2 weeks. r304605: Fix calloc(3) argument order. Reviewed by: trasz MFC after: 4 weeks. Differential Revision: https://reviews.freebsd.org/D7532 r304676: Fix calloc(3) argument order. MFC after: 4 weeks. r305212: - Invert calloc(3) argument order. MFC after: 4 weeks r305863: Invert calloc(3) argument order. Reviewed by: ed. MFC after: 4 weeks. Differential Revision: https://reviews.freebsd.org/D7902 Modified: stable/11/sbin/natd/natd.c stable/11/usr.bin/calendar/io.c stable/11/usr.bin/gzip/gzip.c stable/11/usr.bin/indent/indent.c stable/11/usr.bin/locale/locale.c stable/11/usr.bin/localedef/collate.c stable/11/usr.bin/netstat/pfkey.c stable/11/usr.bin/procstat/procstat_files.c stable/11/usr.bin/rpcgen/rpc_main.c stable/11/usr.bin/systat/main.c stable/11/usr.sbin/ctld/chap.c stable/11/usr.sbin/ctld/keys.c stable/11/usr.sbin/ctld/pdu.c stable/11/usr.sbin/fifolog/lib/fifolog_int.c stable/11/usr.sbin/fifolog/lib/fifolog_reader.c stable/11/usr.sbin/iscsid/chap.c stable/11/usr.sbin/iscsid/keys.c stable/11/usr.sbin/iscsid/pdu.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/natd/natd.c ============================================================================== --- stable/11/sbin/natd/natd.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/sbin/natd/natd.c Fri Oct 21 03:10:05 2016 (r307697) @@ -2006,7 +2006,7 @@ NewInstance(const char *name) } } ninstance++; - ip = calloc(sizeof *ip, 1); + ip = calloc(1, sizeof(*ip)); ip->name = strdup(name); ip->la = LibAliasInit (ip->la); ip->assignAliasAddr = 0; Modified: stable/11/usr.bin/calendar/io.c ============================================================================== --- stable/11/usr.bin/calendar/io.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/calendar/io.c Fri Oct 21 03:10:05 2016 (r307697) @@ -118,7 +118,7 @@ cal_fopen(const char *file) return (NULL); } - for (i = 0; i < sizeof(calendarHomes)/sizeof(calendarHomes[0]) ; i++) { + for (i = 0; i < nitems(calendarHomes); i++) { if (chdir(calendarHomes[i]) != 0) continue; Modified: stable/11/usr.bin/gzip/gzip.c ============================================================================== --- stable/11/usr.bin/gzip/gzip.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/gzip/gzip.c Fri Oct 21 03:10:05 2016 (r307697) @@ -155,7 +155,7 @@ static suffixes_t suffixes[] = { #endif /* SMALL */ #undef SUFFIX }; -#define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0]) +#define NUM_SUFFIXES (nitems(suffixes)) #define SUFFIX_MAXLEN 30 static const char gzip_version[] = "FreeBSD gzip 20150413"; Modified: stable/11/usr.bin/indent/indent.c ============================================================================== --- stable/11/usr.bin/indent/indent.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/indent/indent.c Fri Oct 21 03:10:05 2016 (r307697) @@ -1133,7 +1133,7 @@ check_type: while ((c = getc(input)) == '\n'); ungetc(c, input); } - if ((size_t)ifdef_level < sizeof(state_stack)/sizeof(state_stack[0])) { + if ((size_t)ifdef_level < nitems(state_stack)) { match_state[ifdef_level].tos = -1; state_stack[ifdef_level++] = ps; } Modified: stable/11/usr.bin/locale/locale.c ============================================================================== --- stable/11/usr.bin/locale/locale.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/locale/locale.c Fri Oct 21 03:10:05 2016 (r307697) @@ -220,10 +220,10 @@ struct _kwinfo { "(POSIX legacy)" } /* compat */ }; -#define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0])) +#define NKWINFO (nitems(kwinfo)) const char *boguslocales[] = { "UTF-8" }; -#define NBOGUS (sizeof(boguslocales)/sizeof(boguslocales[0])) +#define NBOGUS (nitems(boguslocales)) int main(int argc, char *argv[]) Modified: stable/11/usr.bin/localedef/collate.c ============================================================================== --- stable/11/usr.bin/localedef/collate.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/localedef/collate.c Fri Oct 21 03:10:05 2016 (r307697) @@ -490,7 +490,7 @@ define_collsym(char *name) { collsym_t *sym; - if ((sym = calloc(sizeof (*sym), 1)) == NULL) { + if ((sym = calloc(1, sizeof(*sym))) == NULL) { fprintf(stderr,"out of memory"); return; } @@ -536,7 +536,7 @@ get_collundef(char *name) srch.name = name; if ((ud = RB_FIND(collundefs, &collundefs, &srch)) == NULL) { - if (((ud = calloc(sizeof (*ud), 1)) == NULL) || + if (((ud = calloc(1, sizeof(*ud))) == NULL) || ((ud->name = strdup(name)) == NULL)) { fprintf(stderr,"out of memory"); free(ud); @@ -561,7 +561,7 @@ get_collchar(wchar_t wc, int create) srch.wc = wc; cc = RB_FIND(collchars, &collchars, &srch); if ((cc == NULL) && create) { - if ((cc = calloc(sizeof (*cc), 1)) == NULL) { + if ((cc = calloc(1, sizeof(*cc))) == NULL) { fprintf(stderr, "out of memory"); return (NULL); } @@ -793,7 +793,7 @@ define_collelem(char *name, wchar_t *wcs return; } - if ((e = calloc(sizeof (*e), 1)) == NULL) { + if ((e = calloc(1, sizeof(*e))) == NULL) { fprintf(stderr, "out of memory"); return; } @@ -927,7 +927,7 @@ add_order_subst(void) s = RB_FIND(substs_ref, &substs_ref[curr_weight], &srch); if (s == NULL) { - if ((s = calloc(sizeof (*s), 1)) == NULL) { + if ((s = calloc(1, sizeof(*s))) == NULL) { fprintf(stderr,"out of memory"); return; } @@ -1035,7 +1035,7 @@ add_weight(int32_t ref, int pass) if (RB_FIND(weights, &weights[pass], &srch) != NULL) return; - if ((w = calloc(sizeof (*w), 1)) == NULL) { + if ((w = calloc(1, sizeof(*w))) == NULL) { fprintf(stderr, "out of memory"); return; } Modified: stable/11/usr.bin/netstat/pfkey.c ============================================================================== --- stable/11/usr.bin/netstat/pfkey.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/netstat/pfkey.c Fri Oct 21 03:10:05 2016 (r307697) @@ -101,8 +101,7 @@ static const char *pfkey_msgtype_names ( static const char * pfkey_msgtype_names(int x) { - const int max = - sizeof(pfkey_msgtypenames)/sizeof(pfkey_msgtypenames[0]); + const int max = nitems(pfkey_msgtypenames); static char buf[20]; if (x < max && pfkey_msgtypenames[x]) Modified: stable/11/usr.bin/procstat/procstat_files.c ============================================================================== --- stable/11/usr.bin/procstat/procstat_files.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/procstat/procstat_files.c Fri Oct 21 03:10:05 2016 (r307697) @@ -235,8 +235,7 @@ static struct cap_desc { { CAP_SOCK_CLIENT, "scl" }, { CAP_SOCK_SERVER, "ssr" }, }; -static const u_int cap_desc_count = sizeof(cap_desc) / - sizeof(cap_desc[0]); +static const u_int cap_desc_count = nitems(cap_desc); static u_int width_capability(cap_rights_t *rightsp) Modified: stable/11/usr.bin/rpcgen/rpc_main.c ============================================================================== --- stable/11/usr.bin/rpcgen/rpc_main.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/rpcgen/rpc_main.c Fri Oct 21 03:10:05 2016 (r307697) @@ -82,11 +82,11 @@ static char pathbuf[MAXPATHLEN + 1]; static const char *allv[] = { "rpcgen", "-s", "udp", "-s", "tcp", }; -static int allc = sizeof (allv)/sizeof (allv[0]); +static int allc = nitems(allv); static const char *allnv[] = { "rpcgen", "-s", "netpath", }; -static int allnc = sizeof (allnv)/sizeof (allnv[0]); +static int allnc = nitems(allnv); /* * machinations for handling expanding argument list Modified: stable/11/usr.bin/systat/main.c ============================================================================== --- stable/11/usr.bin/systat/main.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.bin/systat/main.c Fri Oct 21 03:10:05 2016 (r307697) @@ -261,7 +261,7 @@ display(void) int i, j; /* Get the load average over the last minute. */ - (void) getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0])); + (void) getloadavg(avenrun, nitems(avenrun)); (*curcmd->c_fetch)(); if (curcmd->c_flags & CF_LOADAV) { j = 5.0*avenrun[0] + 0.5; @@ -293,7 +293,7 @@ display(void) GETSYSCTL("kstat.zfs.misc.arcstats.l2_hdr_size", arc[5]); GETSYSCTL("kstat.zfs.misc.arcstats.other_size", arc[6]); wmove(wload, 0, 0); wclrtoeol(wload); - for (i = 0 ; i < sizeof(arc) / sizeof(arc[0]) ; i++) { + for (i = 0 ; i < nitems(arc); i++) { if (arc[i] > 10llu * 1024 * 1024 * 1024 ) { wprintw(wload, "%7lluG", arc[i] >> 30); } @@ -318,7 +318,7 @@ void load(void) { - (void) getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0])); + (void) getloadavg(avenrun, nitems(avenrun)); mvprintw(CMDLINE, 0, "%4.1f %4.1f %4.1f", avenrun[0], avenrun[1], avenrun[2]); clrtoeol(); Modified: stable/11/usr.sbin/ctld/chap.c ============================================================================== --- stable/11/usr.sbin/ctld/chap.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/ctld/chap.c Fri Oct 21 03:10:05 2016 (r307697) @@ -232,7 +232,7 @@ chap_new(void) { struct chap *chap; - chap = calloc(sizeof(*chap), 1); + chap = calloc(1, sizeof(*chap)); if (chap == NULL) log_err(1, "calloc"); @@ -333,7 +333,7 @@ rchap_new(const char *secret) { struct rchap *rchap; - rchap = calloc(sizeof(*rchap), 1); + rchap = calloc(1, sizeof(*rchap)); if (rchap == NULL) log_err(1, "calloc"); Modified: stable/11/usr.sbin/ctld/keys.c ============================================================================== --- stable/11/usr.sbin/ctld/keys.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/ctld/keys.c Fri Oct 21 03:10:05 2016 (r307697) @@ -43,7 +43,7 @@ keys_new(void) { struct keys *keys; - keys = calloc(sizeof(*keys), 1); + keys = calloc(1, sizeof(*keys)); if (keys == NULL) log_err(1, "calloc"); Modified: stable/11/usr.sbin/ctld/pdu.c ============================================================================== --- stable/11/usr.sbin/ctld/pdu.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/ctld/pdu.c Fri Oct 21 03:10:05 2016 (r307697) @@ -81,11 +81,11 @@ pdu_new(struct connection *conn) { struct pdu *pdu; - pdu = calloc(sizeof(*pdu), 1); + pdu = calloc(1, sizeof(*pdu)); if (pdu == NULL) log_err(1, "calloc"); - pdu->pdu_bhs = calloc(sizeof(*pdu->pdu_bhs), 1); + pdu->pdu_bhs = calloc(1, sizeof(*pdu->pdu_bhs)); if (pdu->pdu_bhs == NULL) log_err(1, "calloc"); Modified: stable/11/usr.sbin/fifolog/lib/fifolog_int.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_int.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/fifolog/lib/fifolog_int.c Fri Oct 21 03:10:05 2016 (r307697) @@ -125,7 +125,7 @@ fifolog_int_open_i(struct fifolog_file * /* Initialize zlib handling */ - f->zs = calloc(sizeof *f->zs, 1); + f->zs = calloc(1, sizeof(*f->zs)); if (f->zs == NULL) return ("cannot malloc"); Modified: stable/11/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_reader.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/fifolog/lib/fifolog_reader.c Fri Oct 21 03:10:05 2016 (r307697) @@ -59,7 +59,7 @@ fifolog_reader_open(const char *fname) struct fifolog_reader *fr; int i; - fr = calloc(sizeof *fr, 1); + fr = calloc(1, sizeof(*fr)); if (fr == NULL) err(1, "Cannot malloc"); Modified: stable/11/usr.sbin/iscsid/chap.c ============================================================================== --- stable/11/usr.sbin/iscsid/chap.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/iscsid/chap.c Fri Oct 21 03:10:05 2016 (r307697) @@ -232,7 +232,7 @@ chap_new(void) { struct chap *chap; - chap = calloc(sizeof(*chap), 1); + chap = calloc(1, sizeof(*chap)); if (chap == NULL) log_err(1, "calloc"); @@ -333,7 +333,7 @@ rchap_new(const char *secret) { struct rchap *rchap; - rchap = calloc(sizeof(*rchap), 1); + rchap = calloc(1, sizeof(*rchap)); if (rchap == NULL) log_err(1, "calloc"); Modified: stable/11/usr.sbin/iscsid/keys.c ============================================================================== --- stable/11/usr.sbin/iscsid/keys.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/iscsid/keys.c Fri Oct 21 03:10:05 2016 (r307697) @@ -43,7 +43,7 @@ keys_new(void) { struct keys *keys; - keys = calloc(sizeof(*keys), 1); + keys = calloc(1, sizeof(*keys)); if (keys == NULL) log_err(1, "calloc"); Modified: stable/11/usr.sbin/iscsid/pdu.c ============================================================================== --- stable/11/usr.sbin/iscsid/pdu.c Fri Oct 21 02:16:11 2016 (r307696) +++ stable/11/usr.sbin/iscsid/pdu.c Fri Oct 21 03:10:05 2016 (r307697) @@ -81,11 +81,11 @@ pdu_new(struct connection *conn) { struct pdu *pdu; - pdu = calloc(sizeof(*pdu), 1); + pdu = calloc(1, sizeof(*pdu)); if (pdu == NULL) log_err(1, "calloc"); - pdu->pdu_bhs = calloc(sizeof(*pdu->pdu_bhs), 1); + pdu->pdu_bhs = calloc(1, sizeof(*pdu->pdu_bhs)); if (pdu->pdu_bhs == NULL) log_err(1, "calloc"); From owner-svn-src-stable@freebsd.org Fri Oct 21 08:22:40 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7FC84C1879E; Fri, 21 Oct 2016 08:22:40 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4F59583C; Fri, 21 Oct 2016 08:22:40 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8MdHD055942; Fri, 21 Oct 2016 08:22:39 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8MdCw055941; Fri, 21 Oct 2016 08:22:39 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210822.u9L8MdCw055941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:22:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307715 - stable/11/tests/sys/mac/bsdextended X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:22:40 -0000 Author: ngie Date: Fri Oct 21 08:22:39 2016 New Revision: 307715 URL: https://svnweb.freebsd.org/changeset/base/307715 Log: MFC r305916,r305918: r305916: Make sure $TMPDIR is created with 0755 permissions This is required to ensure that the temporary script can be executed, as the default mode is apparently too restrictive r305918: Only chmod $TMPDIR if it's not /tmp This is a safety belt to ensure that the /tmp sticky bit stuff doesn't get whacked by accident if someone runs the script outright Modified: stable/11/tests/sys/mac/bsdextended/matches_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/mac/bsdextended/matches_test.sh ============================================================================== --- stable/11/tests/sys/mac/bsdextended/matches_test.sh Fri Oct 21 08:21:23 2016 (r307714) +++ stable/11/tests/sys/mac/bsdextended/matches_test.sh Fri Oct 21 08:22:39 2016 (r307715) @@ -36,6 +36,12 @@ if ! sysctl -N security.mac.bsdextended echo "1..0 # SKIP mac_bsdextended(4) support isn't available" exit 0 fi +if [ "$TMPDIR" != "/tmp" ]; then + if ! chmod -Rf 0755 $TMPDIR; then + echo "1..0 # SKIP failed to chmod $TMPDIR" + exit 0 + fi +fi if ! playground=$(mktemp -d $TMPDIR/tmp.XXXXXXX); then echo "1..0 # SKIP failed to create temporary directory" exit 0 From owner-svn-src-stable@freebsd.org Fri Oct 21 08:25:04 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64F04C1888B; Fri, 21 Oct 2016 08:25:04 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 33BEFAB2; Fri, 21 Oct 2016 08:25:04 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8P3pi056186; Fri, 21 Oct 2016 08:25:03 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8P3fY056185; Fri, 21 Oct 2016 08:25:03 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210825.u9L8P3fY056185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:25:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307716 - stable/10/tests/sys/mac/bsdextended X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:25:04 -0000 Author: ngie Date: Fri Oct 21 08:25:03 2016 New Revision: 307716 URL: https://svnweb.freebsd.org/changeset/base/307716 Log: MFstable/11 r307715: MFC r305916,r305918: r305916: Make sure $TMPDIR is created with 0755 permissions This is required to ensure that the temporary script can be executed, as the default mode is apparently too restrictive r305918: Only chmod $TMPDIR if it's not /tmp This is a safety belt to ensure that the /tmp sticky bit stuff doesn't get whacked by accident if someone runs the script outright Modified: stable/10/tests/sys/mac/bsdextended/matches_test.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/tests/sys/mac/bsdextended/matches_test.sh ============================================================================== --- stable/10/tests/sys/mac/bsdextended/matches_test.sh Fri Oct 21 08:22:39 2016 (r307715) +++ stable/10/tests/sys/mac/bsdextended/matches_test.sh Fri Oct 21 08:25:03 2016 (r307716) @@ -36,6 +36,12 @@ if ! sysctl -N security.mac.bsdextended echo "1..0 # SKIP mac_bsdextended(4) support isn't available" exit 0 fi +if [ "$TMPDIR" != "/tmp" ]; then + if ! chmod -Rf 0755 $TMPDIR; then + echo "1..0 # SKIP failed to chmod $TMPDIR" + exit 0 + fi +fi if ! playground=$(mktemp -d $TMPDIR/tmp.XXXXXXX); then echo "1..0 # SKIP failed to create temporary directory" exit 0 From owner-svn-src-stable@freebsd.org Fri Oct 21 08:29:18 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80C36C18959; Fri, 21 Oct 2016 08:29:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 51CECD60; Fri, 21 Oct 2016 08:29:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8TH3v056476; Fri, 21 Oct 2016 08:29:17 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8THF2056474; Fri, 21 Oct 2016 08:29:17 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210829.u9L8THF2056474@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:29:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307717 - in stable/11/lib/libc/tests: iconv net/getaddrinfo X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:29:18 -0000 Author: ngie Date: Fri Oct 21 08:29:17 2016 New Revision: 307717 URL: https://svnweb.freebsd.org/changeset/base/307717 Log: MFC r305919: Don't define PACKAGE in lib/libc/tests/{iconv,net/getaddrinfo} needlessly This is already being done by bsd.test.mk The other subdirectory Makefiles were intentionally left alone Modified: stable/11/lib/libc/tests/iconv/Makefile stable/11/lib/libc/tests/net/getaddrinfo/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/tests/iconv/Makefile ============================================================================== --- stable/11/lib/libc/tests/iconv/Makefile Fri Oct 21 08:25:03 2016 (r307716) +++ stable/11/lib/libc/tests/iconv/Makefile Fri Oct 21 08:29:17 2016 (r307717) @@ -1,7 +1,5 @@ # $FreeBSD$ -PACKAGE= tests - TESTSDIR= ${TESTSBASE}/lib/libc/iconv ATF_TESTS_C+= iconvctl_test Modified: stable/11/lib/libc/tests/net/getaddrinfo/Makefile ============================================================================== --- stable/11/lib/libc/tests/net/getaddrinfo/Makefile Fri Oct 21 08:25:03 2016 (r307716) +++ stable/11/lib/libc/tests/net/getaddrinfo/Makefile Fri Oct 21 08:29:17 2016 (r307717) @@ -1,7 +1,5 @@ # $FreeBSD$ -PACKAGE= tests - TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/net/${.CURDIR:T} .include From owner-svn-src-stable@freebsd.org Fri Oct 21 08:31:16 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AAA91C18A29; Fri, 21 Oct 2016 08:31:16 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6009AF66; Fri, 21 Oct 2016 08:31:16 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8VF5E056654; Fri, 21 Oct 2016 08:31:15 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8VFe8056652; Fri, 21 Oct 2016 08:31:15 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210831.u9L8VFe8056652@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:31:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307718 - stable/11/lib/libc/tests/stdio X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:31:16 -0000 Author: ngie Date: Fri Oct 21 08:31:15 2016 New Revision: 307718 URL: https://svnweb.freebsd.org/changeset/base/307718 Log: MFC r305920: Remove spurious newlines from atf_tc_fail calls This changes the results from broken (incorrect) to failed (correct) on i386 Modified: stable/11/lib/libc/tests/stdio/printbasic_test.c stable/11/lib/libc/tests/stdio/printfloat_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/tests/stdio/printbasic_test.c ============================================================================== --- stable/11/lib/libc/tests/stdio/printbasic_test.c Fri Oct 21 08:29:17 2016 (r307717) +++ stable/11/lib/libc/tests/stdio/printbasic_test.c Fri Oct 21 08:31:15 2016 (r307718) @@ -80,7 +80,7 @@ _testfmt(const char *result, const char vsnprintf(s, sizeof(s), fmt, ap); if (strcmp(result, s) != 0) { atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]\n", + "printf(\"%s\", %s) ==> [%s], expected [%s]", fmt, argstr, s, result); } @@ -91,7 +91,7 @@ _testfmt(const char *result, const char vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); if (wcscmp(wresult, ws) != 0) { atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n", + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", wfmt, argstr, ws, wresult); } va_end(ap); Modified: stable/11/lib/libc/tests/stdio/printfloat_test.c ============================================================================== --- stable/11/lib/libc/tests/stdio/printfloat_test.c Fri Oct 21 08:29:17 2016 (r307717) +++ stable/11/lib/libc/tests/stdio/printfloat_test.c Fri Oct 21 08:31:15 2016 (r307718) @@ -72,7 +72,7 @@ _testfmt(const char *result, const char vsnprintf(s, sizeof(s), fmt, ap); if (strcmp(result, s) != 0) { atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]\n", + "printf(\"%s\", %s) ==> [%s], expected [%s]", fmt, argstr, s, result); } @@ -83,7 +83,7 @@ _testfmt(const char *result, const char vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); if (wcscmp(wresult, ws) != 0) { atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n", + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", wfmt, argstr, ws, wresult); } va_end(ap); From owner-svn-src-stable@freebsd.org Fri Oct 21 08:32:28 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15635C18BD6; Fri, 21 Oct 2016 08:32:28 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE7AF3D5; Fri, 21 Oct 2016 08:32:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8WQsu060129; Fri, 21 Oct 2016 08:32:26 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8WQl9060128; Fri, 21 Oct 2016 08:32:26 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210832.u9L8WQl9060128@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:32:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307719 - stable/10/lib/libc/tests/stdio X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:32:28 -0000 Author: ngie Date: Fri Oct 21 08:32:26 2016 New Revision: 307719 URL: https://svnweb.freebsd.org/changeset/base/307719 Log: MFstable/11 r307718: MFC r305920: Remove spurious newlines from atf_tc_fail calls This changes the results from broken (incorrect) to failed (correct) on i386 Modified: stable/10/lib/libc/tests/stdio/printbasic_test.c stable/10/lib/libc/tests/stdio/printfloat_test.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/tests/stdio/printbasic_test.c ============================================================================== --- stable/10/lib/libc/tests/stdio/printbasic_test.c Fri Oct 21 08:31:15 2016 (r307718) +++ stable/10/lib/libc/tests/stdio/printbasic_test.c Fri Oct 21 08:32:26 2016 (r307719) @@ -80,7 +80,7 @@ _testfmt(const char *result, const char vsnprintf(s, sizeof(s), fmt, ap); if (strcmp(result, s) != 0) { atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]\n", + "printf(\"%s\", %s) ==> [%s], expected [%s]", fmt, argstr, s, result); } @@ -91,7 +91,7 @@ _testfmt(const char *result, const char vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); if (wcscmp(wresult, ws) != 0) { atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n", + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", wfmt, argstr, ws, wresult); } va_end(ap); Modified: stable/10/lib/libc/tests/stdio/printfloat_test.c ============================================================================== --- stable/10/lib/libc/tests/stdio/printfloat_test.c Fri Oct 21 08:31:15 2016 (r307718) +++ stable/10/lib/libc/tests/stdio/printfloat_test.c Fri Oct 21 08:32:26 2016 (r307719) @@ -72,7 +72,7 @@ _testfmt(const char *result, const char vsnprintf(s, sizeof(s), fmt, ap); if (strcmp(result, s) != 0) { atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]\n", + "printf(\"%s\", %s) ==> [%s], expected [%s]", fmt, argstr, s, result); } @@ -83,7 +83,7 @@ _testfmt(const char *result, const char vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); if (wcscmp(wresult, ws) != 0) { atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n", + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", wfmt, argstr, ws, wresult); } va_end(ap); From owner-svn-src-stable@freebsd.org Fri Oct 21 08:33:53 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 13D50C18C88; Fri, 21 Oct 2016 08:33:53 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D94E28BF; Fri, 21 Oct 2016 08:33:52 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8XquT060341; Fri, 21 Oct 2016 08:33:52 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8Xp5i060340; Fri, 21 Oct 2016 08:33:51 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210833.u9L8Xp5i060340@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:33:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307720 - in stable/11/lib/libc/tests: net/getaddrinfo sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:33:53 -0000 Author: ngie Date: Fri Oct 21 08:33:51 2016 New Revision: 307720 URL: https://svnweb.freebsd.org/changeset/base/307720 Log: MFC r305961: Re-add PACKAGE=> tests to lib/libc/tests/net/getaddrinfo/Makefile and add it to lib/libc/tests/sys/Makefile [*] Even though make -VPACKAGE and make -n install seem to do the right thing, the effects are a bit different, depending on the build host. Obtained from: HardenedBSD (af602f0db) [*] Modified: stable/11/lib/libc/tests/net/getaddrinfo/Makefile stable/11/lib/libc/tests/sys/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/tests/net/getaddrinfo/Makefile ============================================================================== --- stable/11/lib/libc/tests/net/getaddrinfo/Makefile Fri Oct 21 08:32:26 2016 (r307719) +++ stable/11/lib/libc/tests/net/getaddrinfo/Makefile Fri Oct 21 08:33:51 2016 (r307720) @@ -1,5 +1,7 @@ # $FreeBSD$ +PACKAGE= tests + TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/net/${.CURDIR:T} .include Modified: stable/11/lib/libc/tests/sys/Makefile ============================================================================== --- stable/11/lib/libc/tests/sys/Makefile Fri Oct 21 08:32:26 2016 (r307719) +++ stable/11/lib/libc/tests/sys/Makefile Fri Oct 21 08:33:51 2016 (r307720) @@ -1,5 +1,7 @@ # $FreeBSD$ +PACKAGE= tests + .include ATF_TESTS_C+= queue_test From owner-svn-src-stable@freebsd.org Fri Oct 21 08:35:22 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3474CC18D43; Fri, 21 Oct 2016 08:35:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 05F6AB18; Fri, 21 Oct 2016 08:35:21 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8ZL7A060550; Fri, 21 Oct 2016 08:35:21 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8ZLFx060549; Fri, 21 Oct 2016 08:35:21 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210835.u9L8ZLFx060549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:35:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307721 - in stable/11/libexec/atf: atf-check atf-sh X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:35:22 -0000 Author: ngie Date: Fri Oct 21 08:35:20 2016 New Revision: 307721 URL: https://svnweb.freebsd.org/changeset/base/307721 Log: MFC r306029: Use SRCTOP instead of the longhand version for defining the path to contrib/atf Modified: stable/11/libexec/atf/atf-check/Makefile stable/11/libexec/atf/atf-sh/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/libexec/atf/atf-check/Makefile ============================================================================== --- stable/11/libexec/atf/atf-check/Makefile Fri Oct 21 08:33:51 2016 (r307720) +++ stable/11/libexec/atf/atf-check/Makefile Fri Oct 21 08:35:20 2016 (r307721) @@ -28,7 +28,7 @@ .include .include -ATF= ${.CURDIR:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-sh PROG_CXX= atf-check Modified: stable/11/libexec/atf/atf-sh/Makefile ============================================================================== --- stable/11/libexec/atf/atf-sh/Makefile Fri Oct 21 08:33:51 2016 (r307720) +++ stable/11/libexec/atf/atf-sh/Makefile Fri Oct 21 08:35:20 2016 (r307721) @@ -28,7 +28,7 @@ .include .include -ATF= ${.CURDIR:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-sh PROG_CXX= atf-sh From owner-svn-src-stable@freebsd.org Fri Oct 21 08:36:32 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B55DC18E5A; Fri, 21 Oct 2016 08:36:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD7E9E3F; Fri, 21 Oct 2016 08:36:31 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8aUox060824; Fri, 21 Oct 2016 08:36:30 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8aUC6060823; Fri, 21 Oct 2016 08:36:30 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210836.u9L8aUC6060823@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:36:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307722 - in stable/10/libexec/atf: atf-check atf-sh X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:36:32 -0000 Author: ngie Date: Fri Oct 21 08:36:30 2016 New Revision: 307722 URL: https://svnweb.freebsd.org/changeset/base/307722 Log: MFstable/11 r307721: MFC r306029: Use SRCTOP instead of the longhand version for defining the path to contrib/atf Modified: stable/10/libexec/atf/atf-check/Makefile stable/10/libexec/atf/atf-sh/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/libexec/atf/atf-check/Makefile ============================================================================== --- stable/10/libexec/atf/atf-check/Makefile Fri Oct 21 08:35:20 2016 (r307721) +++ stable/10/libexec/atf/atf-check/Makefile Fri Oct 21 08:36:30 2016 (r307722) @@ -27,7 +27,7 @@ .include -ATF= ${.CURDIR:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-sh PROG_CXX= atf-check Modified: stable/10/libexec/atf/atf-sh/Makefile ============================================================================== --- stable/10/libexec/atf/atf-sh/Makefile Fri Oct 21 08:35:20 2016 (r307721) +++ stable/10/libexec/atf/atf-sh/Makefile Fri Oct 21 08:36:30 2016 (r307722) @@ -27,7 +27,7 @@ .include -ATF= ${.CURDIR:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-sh PROG_CXX= atf-sh From owner-svn-src-stable@freebsd.org Fri Oct 21 08:38:20 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44801C18F30; Fri, 21 Oct 2016 08:38:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 14520DC; Fri, 21 Oct 2016 08:38:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8cJpG060955; Fri, 21 Oct 2016 08:38:19 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8cJ4d060954; Fri, 21 Oct 2016 08:38:19 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210838.u9L8cJ4d060954@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:38:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307723 - stable/11/tests/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:38:20 -0000 Author: ngie Date: Fri Oct 21 08:38:18 2016 New Revision: 307723 URL: https://svnweb.freebsd.org/changeset/base/307723 Log: MFC r305963,r305970: r305963: Reindent TESTSDIR definition for consistency/readability r305970: Remove change accidentally committed via r305963 for upcoming tests/sys/fs/... work Modified: stable/11/tests/sys/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/Makefile ============================================================================== --- stable/11/tests/sys/Makefile Fri Oct 21 08:36:30 2016 (r307722) +++ stable/11/tests/sys/Makefile Fri Oct 21 08:38:18 2016 (r307723) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/sys +TESTSDIR= ${TESTSBASE}/sys TESTS_SUBDIRS+= acl TESTS_SUBDIRS+= aio From owner-svn-src-stable@freebsd.org Fri Oct 21 08:40:25 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46C28C1B05B; Fri, 21 Oct 2016 08:40:25 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1861B6D1; Fri, 21 Oct 2016 08:40:25 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L8eOMQ061290; Fri, 21 Oct 2016 08:40:24 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L8eOLH061289; Fri, 21 Oct 2016 08:40:24 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610210840.u9L8eOLH061289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 21 Oct 2016 08:40:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307724 - stable/11/usr.bin/sed/tests X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 08:40:25 -0000 Author: ngie Date: Fri Oct 21 08:40:24 2016 New Revision: 307724 URL: https://svnweb.freebsd.org/changeset/base/307724 Log: MFC r303367: Testcase 7.8 no longer needs to be marked TODO It passes out of the box today Modified: stable/11/usr.bin/sed/tests/multi_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/sed/tests/multi_test.sh ============================================================================== --- stable/11/usr.bin/sed/tests/multi_test.sh Fri Oct 21 08:38:18 2016 (r307723) +++ stable/11/usr.bin/sed/tests/multi_test.sh Fri Oct 21 08:40:24 2016 (r307724) @@ -383,7 +383,6 @@ test_print() mark '7.8' echo line1 > lines3 echo "" >> lines3 - TODO=1 $SED -n -e '$p' lines3 /dev/null } From owner-svn-src-stable@freebsd.org Fri Oct 21 09:15:35 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A5734C1BB63; Fri, 21 Oct 2016 09:15:35 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 74423155E; Fri, 21 Oct 2016 09:15:35 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9L9FYWf077382; Fri, 21 Oct 2016 09:15:34 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9L9FYtc077381; Fri, 21 Oct 2016 09:15:34 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610210915.u9L9FYtc077381@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Fri, 21 Oct 2016 09:15:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307725 - stable/11/sys/boot/userboot/userboot X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 09:15:35 -0000 Author: bapt Date: Fri Oct 21 09:15:34 2016 New Revision: 307725 URL: https://svnweb.freebsd.org/changeset/base/307725 Log: MFC: r307316 Fix build WITHOUT_FORTH Sponsored by: Gandi.net Modified: stable/11/sys/boot/userboot/userboot/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/boot/userboot/userboot/Makefile ============================================================================== --- stable/11/sys/boot/userboot/userboot/Makefile Fri Oct 21 08:40:24 2016 (r307724) +++ stable/11/sys/boot/userboot/userboot/Makefile Fri Oct 21 09:15:34 2016 (r307725) @@ -49,9 +49,10 @@ BOOT_FORTH= yes CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 CFLAGS+= -DBF_DICTSIZE=15000 LIBFICL= ${.OBJDIR}/../ficl/libficl.a -LIBSTAND= ${.OBJDIR}/../libstand/libstand.a .endif +LIBSTAND= ${.OBJDIR}/../libstand/libstand.a + .if ${MK_ZFS} != "no" CFLAGS+= -DUSERBOOT_ZFS_SUPPORT LIBZFSBOOT= ${.OBJDIR}/../zfs/libzfsboot.a From owner-svn-src-stable@freebsd.org Fri Oct 21 14:28:37 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86FFCC1BA53; Fri, 21 Oct 2016 14:28:37 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 41E9F30F; Fri, 21 Oct 2016 14:28:37 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LESa5t011114; Fri, 21 Oct 2016 14:28:36 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LESZXI011102; Fri, 21 Oct 2016 14:28:35 GMT (envelope-from des@FreeBSD.org) Message-Id: <201610211428.u9LESZXI011102@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Fri, 21 Oct 2016 14:28:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307729 - in stable/11: contrib/unbound contrib/unbound/cachedb contrib/unbound/compat contrib/unbound/contrib contrib/unbound/daemon contrib/unbound/dns64 contrib/unbound/dnstap contri... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 14:28:37 -0000 Author: des Date: Fri Oct 21 14:28:35 2016 New Revision: 307729 URL: https://svnweb.freebsd.org/changeset/base/307729 Log: MFH (r305381, r306457): upgrade to unbound 1.5.10 via 1.5.9 Added: stable/11/contrib/unbound/cachedb/ - copied from r305381, head/contrib/unbound/cachedb/ stable/11/contrib/unbound/compat/strsep.c - copied unchanged from r305381, head/contrib/unbound/compat/strsep.c stable/11/contrib/unbound/contrib/ - copied from r306457, head/contrib/unbound/contrib/ stable/11/contrib/unbound/util/ub_event.c - copied, changed from r305381, head/contrib/unbound/util/ub_event.c stable/11/contrib/unbound/util/ub_event.h - copied unchanged from r305381, head/contrib/unbound/util/ub_event.h stable/11/contrib/unbound/util/ub_event_pluggable.c - copied, changed from r305381, head/contrib/unbound/util/ub_event_pluggable.c Modified: stable/11/contrib/unbound/Makefile.in stable/11/contrib/unbound/acx_nlnetlabs.m4 stable/11/contrib/unbound/acx_python.m4 stable/11/contrib/unbound/compat/arc4random.c stable/11/contrib/unbound/compat/explicit_bzero.c stable/11/contrib/unbound/compat/getentropy_linux.c stable/11/contrib/unbound/config.h stable/11/contrib/unbound/config.h.in stable/11/contrib/unbound/configure stable/11/contrib/unbound/configure.ac stable/11/contrib/unbound/daemon/acl_list.c stable/11/contrib/unbound/daemon/acl_list.h stable/11/contrib/unbound/daemon/daemon.c stable/11/contrib/unbound/daemon/daemon.h stable/11/contrib/unbound/daemon/remote.c stable/11/contrib/unbound/daemon/remote.h stable/11/contrib/unbound/daemon/unbound.c stable/11/contrib/unbound/daemon/worker.c stable/11/contrib/unbound/dns64/dns64.c stable/11/contrib/unbound/dnstap/dnstap.c stable/11/contrib/unbound/doc/Changelog stable/11/contrib/unbound/doc/README stable/11/contrib/unbound/doc/example.conf stable/11/contrib/unbound/doc/example.conf.in stable/11/contrib/unbound/doc/libunbound.3 stable/11/contrib/unbound/doc/libunbound.3.in stable/11/contrib/unbound/doc/unbound-anchor.8 stable/11/contrib/unbound/doc/unbound-anchor.8.in stable/11/contrib/unbound/doc/unbound-checkconf.8 stable/11/contrib/unbound/doc/unbound-checkconf.8.in stable/11/contrib/unbound/doc/unbound-control.8 stable/11/contrib/unbound/doc/unbound-control.8.in stable/11/contrib/unbound/doc/unbound-host.1 stable/11/contrib/unbound/doc/unbound-host.1.in stable/11/contrib/unbound/doc/unbound.8 stable/11/contrib/unbound/doc/unbound.8.in stable/11/contrib/unbound/doc/unbound.conf.5 stable/11/contrib/unbound/doc/unbound.conf.5.in stable/11/contrib/unbound/doc/unbound.doxygen stable/11/contrib/unbound/iterator/iter_fwd.c stable/11/contrib/unbound/iterator/iter_hints.c stable/11/contrib/unbound/iterator/iter_utils.c stable/11/contrib/unbound/iterator/iter_utils.h stable/11/contrib/unbound/iterator/iterator.c stable/11/contrib/unbound/iterator/iterator.h stable/11/contrib/unbound/libunbound/context.h stable/11/contrib/unbound/libunbound/libunbound.c stable/11/contrib/unbound/libunbound/libworker.c stable/11/contrib/unbound/libunbound/libworker.h stable/11/contrib/unbound/libunbound/python/libunbound.i stable/11/contrib/unbound/libunbound/ubsyms.def stable/11/contrib/unbound/libunbound/unbound-event.h stable/11/contrib/unbound/libunbound/worker.h stable/11/contrib/unbound/services/cache/dns.c stable/11/contrib/unbound/services/listen_dnsport.c stable/11/contrib/unbound/services/listen_dnsport.h stable/11/contrib/unbound/services/localzone.c stable/11/contrib/unbound/services/localzone.h stable/11/contrib/unbound/services/mesh.c stable/11/contrib/unbound/services/modstack.c stable/11/contrib/unbound/services/outside_network.c stable/11/contrib/unbound/services/outside_network.h stable/11/contrib/unbound/sldns/keyraw.c stable/11/contrib/unbound/sldns/parseutil.c stable/11/contrib/unbound/sldns/rrdef.h stable/11/contrib/unbound/sldns/str2wire.c stable/11/contrib/unbound/sldns/wire2str.c stable/11/contrib/unbound/sldns/wire2str.h stable/11/contrib/unbound/smallapp/unbound-anchor.c stable/11/contrib/unbound/smallapp/unbound-checkconf.c stable/11/contrib/unbound/smallapp/unbound-control.c stable/11/contrib/unbound/smallapp/unbound-host.c stable/11/contrib/unbound/smallapp/worker_cb.c stable/11/contrib/unbound/util/alloc.c stable/11/contrib/unbound/util/config_file.c stable/11/contrib/unbound/util/config_file.h stable/11/contrib/unbound/util/configlexer.lex stable/11/contrib/unbound/util/configparser.y stable/11/contrib/unbound/util/data/dname.c stable/11/contrib/unbound/util/data/msgencode.c stable/11/contrib/unbound/util/data/msgparse.c stable/11/contrib/unbound/util/data/msgparse.h stable/11/contrib/unbound/util/data/msgreply.c stable/11/contrib/unbound/util/data/msgreply.h stable/11/contrib/unbound/util/fptr_wlist.c stable/11/contrib/unbound/util/fptr_wlist.h stable/11/contrib/unbound/util/iana_ports.inc stable/11/contrib/unbound/util/module.h stable/11/contrib/unbound/util/net_help.c stable/11/contrib/unbound/util/netevent.c stable/11/contrib/unbound/util/netevent.h stable/11/contrib/unbound/util/storage/dnstree.c stable/11/contrib/unbound/util/storage/dnstree.h stable/11/contrib/unbound/util/storage/lookup3.c stable/11/contrib/unbound/util/tube.c stable/11/contrib/unbound/util/tube.h stable/11/contrib/unbound/util/winsock_event.c stable/11/contrib/unbound/validator/autotrust.c stable/11/contrib/unbound/validator/val_anchor.c stable/11/contrib/unbound/validator/val_secalgo.c stable/11/contrib/unbound/validator/val_secalgo.h stable/11/contrib/unbound/validator/val_sigcrypt.c stable/11/contrib/unbound/validator/validator.c stable/11/lib/libunbound/Makefile stable/11/usr.sbin/unbound/checkconf/Makefile stable/11/usr.sbin/unbound/control/Makefile stable/11/usr.sbin/unbound/daemon/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/unbound/Makefile.in ============================================================================== --- stable/11/contrib/unbound/Makefile.in Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/Makefile.in Fri Oct 21 14:28:35 2016 (r307729) @@ -81,7 +81,7 @@ LINTFLAGS+=@NETBSD_LINTFLAGS@ # compat with OpenBSD LINTFLAGS+="-Dsigset_t=long" # FreeBSD -LINTFLAGS+="-D__uint16_t=uint16_t" "-DEVP_PKEY_ASN1_METHOD=int" "-D_RuneLocale=int" "-D__va_list=va_list" +LINTFLAGS+="-D__uint16_t=uint16_t" "-DEVP_PKEY_ASN1_METHOD=int" "-D_RuneLocale=int" "-D__va_list=va_list" "-D__uint32_t=uint32_t" INSTALL=$(SHELL) $(srcdir)/install-sh @@ -108,11 +108,12 @@ util/fptr_wlist.c util/locks.c util/log. util/netevent.c util/net_help.c util/random.c util/rbtree.c util/regional.c \ util/rtt.c util/storage/dnstree.c util/storage/lookup3.c \ util/storage/lruhash.c util/storage/slabhash.c util/timehist.c util/tube.c \ -util/winsock_event.c validator/autotrust.c validator/val_anchor.c \ -validator/validator.c validator/val_kcache.c validator/val_kentry.c \ -validator/val_neg.c validator/val_nsec3.c validator/val_nsec.c \ -validator/val_secalgo.c validator/val_sigcrypt.c \ -validator/val_utils.c dns64/dns64.c $(CHECKLOCK_SRC) $(DNSTAP_SRC) +util/ub_event.c util/ub_event_pluggable.c util/winsock_event.c \ +validator/autotrust.c validator/val_anchor.c validator/validator.c \ +validator/val_kcache.c validator/val_kentry.c validator/val_neg.c \ +validator/val_nsec3.c validator/val_nsec.c validator/val_secalgo.c \ +validator/val_sigcrypt.c validator/val_utils.c dns64/dns64.c cachedb/cachedb.c $(CHECKLOCK_SRC) \ +$(DNSTAP_SRC) COMMON_OBJ_WITHOUT_NETCALL=dns.lo infra.lo rrset.lo dname.lo msgencode.lo \ as112.lo msgparse.lo msgreply.lo packed_rrset.lo iterator.lo iter_delegpt.lo \ iter_donotq.lo iter_fwd.lo iter_hints.lo iter_priv.lo iter_resptype.lo \ @@ -122,10 +123,11 @@ fptr_wlist.lo locks.lo log.lo mini_event random.lo rbtree.lo regional.lo rtt.lo dnstree.lo lookup3.lo lruhash.lo \ slabhash.lo timehist.lo tube.lo winsock_event.lo autotrust.lo val_anchor.lo \ validator.lo val_kcache.lo val_kentry.lo val_neg.lo val_nsec3.lo val_nsec.lo \ -val_secalgo.lo val_sigcrypt.lo val_utils.lo dns64.lo \ +val_secalgo.lo val_sigcrypt.lo val_utils.lo dns64.lo cachedb.lo \ $(PYTHONMOD_OBJ) $(CHECKLOCK_OBJ) $(DNSTAP_OBJ) -COMMON_OBJ=$(COMMON_OBJ_WITHOUT_NETCALL) netevent.lo listen_dnsport.lo \ +COMMON_OBJ_WITHOUT_UB_EVENT=$(COMMON_OBJ_WITHOUT_NETCALL) netevent.lo listen_dnsport.lo \ outside_network.lo +COMMON_OBJ=$(COMMON_OBJ_WITHOUT_UB_EVENT) ub_event.lo # set to $COMMON_OBJ or to "" if --enableallsymbols COMMON_OBJ_ALL_SYMBOLS=@COMMON_OBJ_ALL_SYMBOLS@ COMPAT_SRC=compat/ctime_r.c compat/fake-rfc2553.c compat/gmtime_r.c \ @@ -134,7 +136,8 @@ compat/memcmp.c compat/memmove.c compat/ compat/strlcpy.c compat/strptime.c compat/getentropy_linux.c \ compat/getentropy_osx.c compat/getentropy_solaris.c compat/getentropy_win.c \ compat/explicit_bzero.c compat/arc4random.c compat/arc4random_uniform.c \ -compat/arc4_lock.c compat/sha512.c compat/reallocarray.c compat/isblank.c +compat/arc4_lock.c compat/sha512.c compat/reallocarray.c compat/isblank.c \ +compat/strsep.c COMPAT_OBJ=$(LIBOBJS:.o=.lo) COMPAT_OBJ_WITHOUT_CTIME=$(LIBOBJ_WITHOUT_CTIME:.o=.lo) COMPAT_OBJ_WITHOUT_CTIMEARC4=$(LIBOBJ_WITHOUT_CTIMEARC4:.o=.lo) @@ -177,7 +180,8 @@ daemon/worker.c daemon/acl_list.c daemon testcode/replay.c testcode/fake_event.c TESTBOUND_OBJ=testbound.lo replay.lo fake_event.lo TESTBOUND_OBJ_LINK=$(TESTBOUND_OBJ) testpkts.lo worker.lo acl_list.lo \ -daemon.lo stats.lo $(COMMON_OBJ_WITHOUT_NETCALL) $(SLDNS_OBJ) $(COMPAT_OBJ) +daemon.lo stats.lo $(COMMON_OBJ_WITHOUT_NETCALL) ub_event.lo $(SLDNS_OBJ) \ +$(COMPAT_OBJ) LOCKVERIFY_SRC=testcode/lock_verify.c LOCKVERIFY_OBJ=lock_verify.lo LOCKVERIFY_OBJ_LINK=$(LOCKVERIFY_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ) \ @@ -209,8 +213,8 @@ DELAYER_OBJ_LINK=$(DELAYER_OBJ) worker_c $(SLDNS_OBJ) LIBUNBOUND_SRC=libunbound/context.c libunbound/libunbound.c \ libunbound/libworker.c -LIBUNBOUND_OBJ=context.lo libunbound.lo libworker.lo -LIBUNBOUND_OBJ_LINK=$(LIBUNBOUND_OBJ) $(COMMON_OBJ) $(SLDNS_OBJ) $(COMPAT_OBJ) +LIBUNBOUND_OBJ=context.lo libunbound.lo libworker.lo ub_event_pluggable.lo +LIBUNBOUND_OBJ_LINK=$(LIBUNBOUND_OBJ) $(COMMON_OBJ_WITHOUT_UB_EVENT) $(SLDNS_OBJ) $(COMPAT_OBJ) # win apps or "" if not on windows WINAPPS=@WINAPPS@ @@ -224,7 +228,7 @@ SVCUNINST_OBJ_LINK=$(SVCUNINST_OBJ) w_in $(COMPAT_OBJ_WITHOUT_CTIMEARC4) ANCHORUPD_SRC=winrc/anchor-update.c ANCHORUPD_OBJ=anchor-update.lo -ANCHORUPD_OBJ_LINK=$(ANCHORUPD_OBJ) rsrc_anchorupd.o $(COMPAT_OBJ_WITHOUT_CTIMEARC4) +ANCHORUPD_OBJ_LINK=$(ANCHORUPD_OBJ) rsrc_anchorupd.o $(COMPAT_OBJ_WITHOUT_CTIMEARC4) wire2str.lo str2wire.lo parseutil.lo sbuffer.lo rrdef.lo keyraw.lo parse.lo RSRC_OBJ=rsrc_svcinst.o rsrc_svcuninst.o rsrc_anchorupd.o rsrc_unbound.o \ rsrc_unbound_host.o rsrc_unbound_anchor.o rsrc_unbound_control.o \ rsrc_unbound_checkconf.o @@ -552,7 +556,7 @@ uninstall: $(PYTHONMOD_UNINSTALL) $(PYUN @echo "You still need to remove "`dirname $(DESTDIR)$(configfile)`" , $(DESTDIR)$(configfile) by hand" iana_update: - curl -o port-numbers.tmp http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml --compressed + curl -o port-numbers.tmp https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml --compressed if file port-numbers.tmp | grep 'gzip' >/dev/null; then zcat port-numbers.tmp; else cat port-numbers.tmp; fi | awk '// {p=0;} /udp/ {p=1;} /[^u]/ {p=0;} /Decomissioned|Decommissioned|Removed|De-registered|unassigned|Unassigned|Reserved/ {u=1;} // { if(u==1) {u=0;} else { if(p==1) { match($$0,/[0-9]+/); print substr($$0, RSTART, RLENGTH) ","}}}' | sort -nu > util/iana_ports.inc rm -f port-numbers.tmp @@ -596,7 +600,6 @@ depend: rm -f $(DEPEND_TMP) $(DEPEND_TMP2) # Dependencies -as112.lo as112.o: $(srcdir)/util/as112.c $(srcdir)/util/as112.h dns.lo dns.o: $(srcdir)/services/cache/dns.c config.h $(srcdir)/iterator/iter_delegpt.h $(srcdir)/util/log.h \ $(srcdir)/validator/val_nsec.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \ $(srcdir)/util/locks.h $(srcdir)/services/cache/dns.h $(srcdir)/util/data/msgreply.h \ @@ -614,6 +617,7 @@ rrset.lo rrset.o: $(srcdir)/services/cac $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/storage/slabhash.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/config_file.h \ $(srcdir)/util/data/msgreply.h $(srcdir)/util/regional.h $(srcdir)/util/alloc.h +as112.lo as112.o: $(srcdir)/util/as112.c $(srcdir)/util/as112.h dname.lo dname.o: $(srcdir)/util/data/dname.c config.h $(srcdir)/util/data/dname.h \ $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/msgparse.h \ $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/storage/lookup3.h $(srcdir)/sldns/sbuffer.h @@ -624,9 +628,9 @@ msgencode.lo msgencode.o: $(srcdir)/util $(srcdir)/sldns/sbuffer.h msgparse.lo msgparse.o: $(srcdir)/util/data/msgparse.c config.h $(srcdir)/util/data/msgparse.h \ $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/sldns/pkthdr.h \ - $(srcdir)/sldns/rrdef.h $(srcdir)/util/data/dname.h $(srcdir)/util/data/packed_rrset.h \ - $(srcdir)/util/storage/lookup3.h $(srcdir)/util/regional.h $(srcdir)/sldns/sbuffer.h $(srcdir)/sldns/parseutil.h \ - $(srcdir)/sldns/wire2str.h + $(srcdir)/sldns/rrdef.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \ + $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/regional.h $(srcdir)/sldns/sbuffer.h \ + $(srcdir)/sldns/parseutil.h $(srcdir)/sldns/wire2str.h msgreply.lo msgreply.o: $(srcdir)/util/data/msgreply.c config.h $(srcdir)/util/data/msgreply.h \ $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/packed_rrset.h \ $(srcdir)/util/storage/lookup3.h $(srcdir)/util/alloc.h $(srcdir)/util/netevent.h $(srcdir)/util/net_help.h \ @@ -700,11 +704,12 @@ listen_dnsport.lo listen_dnsport.o: $(sr $(srcdir)/util/rbtree.h $(srcdir)/util/log.h $(srcdir)/util/config_file.h \ $(srcdir)/util/net_help.h $(srcdir)/sldns/sbuffer.h localzone.lo localzone.o: $(srcdir)/services/localzone.c config.h $(srcdir)/services/localzone.h \ - $(srcdir)/util/rbtree.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/sldns/str2wire.h $(srcdir)/sldns/rrdef.h \ - $(srcdir)/sldns/sbuffer.h $(srcdir)/util/regional.h $(srcdir)/util/config_file.h $(srcdir)/util/data/dname.h \ - $(srcdir)/util/storage/lruhash.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgencode.h \ - $(srcdir)/util/net_help.h $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h \ - $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h $(srcdir)/util/as112.h + $(srcdir)/util/rbtree.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/storage/dnstree.h \ + $(srcdir)/sldns/str2wire.h $(srcdir)/sldns/rrdef.h $(srcdir)/sldns/sbuffer.h $(srcdir)/util/regional.h \ + $(srcdir)/util/config_file.h $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h \ + $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgencode.h $(srcdir)/util/net_help.h \ + $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ + $(srcdir)/util/as112.h mesh.lo mesh.o: $(srcdir)/services/mesh.c config.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \ $(srcdir)/util/netevent.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \ $(srcdir)/util/log.h $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/module.h \ @@ -718,7 +723,7 @@ modstack.lo modstack.o: $(srcdir)/servic $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/netevent.h \ $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/dns64/dns64.h \ $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/validator/validator.h \ - $(srcdir)/validator/val_utils.h + $(srcdir)/validator/val_utils.h $(PYTHONMOD_HEADER) $(srcdir)/cachedb/cachedb.h outbound_list.lo outbound_list.o: $(srcdir)/services/outbound_list.c config.h \ $(srcdir)/services/outbound_list.h $(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h \ $(srcdir)/util/netevent.h @@ -755,14 +760,15 @@ fptr_wlist.lo fptr_wlist.o: $(srcdir)/ut $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/tube.h \ $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/util/mini_event.h \ $(srcdir)/util/rbtree.h $(srcdir)/services/outside_network.h \ - $(srcdir)/services/localzone.h $(srcdir)/services/cache/infra.h $(srcdir)/util/storage/dnstree.h \ + $(srcdir)/services/localzone.h $(srcdir)/util/storage/dnstree.h $(srcdir)/services/cache/infra.h \ $(srcdir)/util/rtt.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/dns64/dns64.h \ $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_fwd.h \ $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h $(srcdir)/validator/val_anchor.h \ $(srcdir)/validator/val_nsec3.h $(srcdir)/validator/val_sigcrypt.h $(srcdir)/validator/val_kentry.h \ $(srcdir)/validator/val_neg.h $(srcdir)/validator/autotrust.h $(srcdir)/libunbound/libworker.h \ $(srcdir)/libunbound/context.h $(srcdir)/util/alloc.h $(srcdir)/libunbound/unbound.h \ - $(srcdir)/libunbound/worker.h $(srcdir)/sldns/sbuffer.h $(srcdir)/util/config_file.h + $(srcdir)/libunbound/worker.h $(srcdir)/sldns/sbuffer.h $(srcdir)/util/config_file.h \ + $(PYTHONMOD_HEADER) $(srcdir)/cachedb/cachedb.h locks.lo locks.o: $(srcdir)/util/locks.c config.h $(srcdir)/util/locks.h $(srcdir)/util/log.h log.lo log.o: $(srcdir)/util/log.c config.h $(srcdir)/util/log.h $(srcdir)/util/locks.h $(srcdir)/sldns/sbuffer.h mini_event.lo mini_event.o: $(srcdir)/util/mini_event.c config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ @@ -773,12 +779,12 @@ mini_event.lo mini_event.o: $(srcdir)/ut module.lo module.o: $(srcdir)/util/module.c config.h $(srcdir)/util/module.h $(srcdir)/util/storage/lruhash.h \ $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \ $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h -netevent.lo netevent.o: $(srcdir)/util/netevent.c config.h $(srcdir)/util/netevent.h $(srcdir)/util/log.h \ - $(srcdir)/util/net_help.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \ - $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \ +netevent.lo netevent.o: $(srcdir)/util/netevent.c config.h $(srcdir)/util/netevent.h $(srcdir)/util/ub_event.h \ + $(srcdir)/util/log.h $(srcdir)/util/net_help.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/storage/lruhash.h \ + $(srcdir)/util/locks.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \ $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/tube.h \ $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/sldns/sbuffer.h \ - $(srcdir)/dnstap/dnstap.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h + $(srcdir)/dnstap/dnstap.h net_help.lo net_help.o: $(srcdir)/util/net_help.c config.h $(srcdir)/util/net_help.h $(srcdir)/util/log.h \ $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/module.h \ $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h \ @@ -808,7 +814,15 @@ tube.lo tube.o: $(srcdir)/util/tube.c co $(srcdir)/util/netevent.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \ $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \ $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/services/mesh.h \ - $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h + $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/util/ub_event.h +ub_event.lo ub_event.o: $(srcdir)/util/ub_event.c config.h $(srcdir)/util/ub_event.h $(srcdir)/util/log.h \ + $(srcdir)/util/netevent.h $(srcdir)/util/tube.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h +ub_event_pluggable.lo ub_event_pluggable.o: $(srcdir)/util/ub_event_pluggable.c config.h $(srcdir)/util/ub_event.h \ + $(srcdir)/libunbound/unbound-event.h $(srcdir)/util/netevent.h $(srcdir)/util/log.h $(srcdir)/util/fptr_wlist.h \ + $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \ + $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ + $(srcdir)/sldns/rrdef.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \ + $(srcdir)/services/modstack.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h winsock_event.lo winsock_event.o: $(srcdir)/util/winsock_event.c config.h autotrust.lo autotrust.o: $(srcdir)/validator/autotrust.c config.h $(srcdir)/validator/autotrust.h \ $(srcdir)/util/rbtree.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \ @@ -822,8 +836,8 @@ autotrust.lo autotrust.o: $(srcdir)/vali val_anchor.lo val_anchor.o: $(srcdir)/validator/val_anchor.c config.h $(srcdir)/validator/val_anchor.h \ $(srcdir)/util/rbtree.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/validator/val_sigcrypt.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/validator/autotrust.h \ - $(srcdir)/util/data/dname.h $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h $(srcdir)/sldns/sbuffer.h \ - $(srcdir)/sldns/rrdef.h $(srcdir)/sldns/str2wire.h $(srcdir)/util/as112.h + $(srcdir)/util/data/dname.h $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h $(srcdir)/util/as112.h \ + $(srcdir)/sldns/sbuffer.h $(srcdir)/sldns/rrdef.h $(srcdir)/sldns/str2wire.h validator.lo validator.o: $(srcdir)/validator/validator.c config.h $(srcdir)/validator/validator.h \ $(srcdir)/util/module.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \ $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h \ @@ -880,7 +894,7 @@ val_utils.lo val_utils.o: $(srcdir)/vali $(srcdir)/validator/val_sigcrypt.h $(srcdir)/validator/val_anchor.h $(srcdir)/util/rbtree.h \ $(srcdir)/validator/val_nsec.h $(srcdir)/validator/val_neg.h $(srcdir)/services/cache/rrset.h \ $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/dns.h $(srcdir)/util/data/dname.h \ - $(srcdir)/util/net_help.h $(srcdir)/util/regional.h + $(srcdir)/util/net_help.h $(srcdir)/util/regional.h $(srcdir)/sldns/wire2str.h $(srcdir)/sldns/parseutil.h dns64.lo dns64.o: $(srcdir)/dns64/dns64.c config.h $(srcdir)/dns64/dns64.h $(srcdir)/util/module.h \ $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/msgreply.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ @@ -888,6 +902,14 @@ dns64.lo dns64.o: $(srcdir)/dns64/dns64. $(srcdir)/util/storage/slabhash.h $(srcdir)/util/config_file.h $(srcdir)/util/fptr_wlist.h \ $(srcdir)/util/netevent.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \ $(srcdir)/services/modstack.h $(srcdir)/util/net_help.h $(srcdir)/util/regional.h +cachedb.lo cachedb.o: $(srcdir)/cachedb/cachedb.c config.h $(srcdir)/cachedb/cachedb.h $(srcdir)/util/module.h \ + $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/msgreply.h \ + $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ + $(srcdir)/sldns/rrdef.h $(srcdir)/util/regional.h $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h \ + $(srcdir)/util/data/msgencode.h $(srcdir)/services/cache/dns.h $(srcdir)/validator/val_neg.h \ + $(srcdir)/util/rbtree.h $(srcdir)/validator/val_secalgo.h $(srcdir)/iterator/iter_utils.h \ + $(srcdir)/iterator/iter_resptype.h $(srcdir)/sldns/parseutil.h $(srcdir)/sldns/wire2str.h \ + $(srcdir)/sldns/sbuffer.h checklocks.lo checklocks.o: $(srcdir)/testcode/checklocks.c config.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \ $(srcdir)/testcode/checklocks.h unitanchor.lo unitanchor.o: $(srcdir)/testcode/unitanchor.c config.h $(srcdir)/util/log.h $(srcdir)/util/data/dname.h \ @@ -935,7 +957,8 @@ unitldns.lo unitldns.o: $(srcdir)/testco $(srcdir)/sldns/sbuffer.h $(srcdir)/sldns/str2wire.h $(srcdir)/sldns/rrdef.h $(srcdir)/sldns/wire2str.h acl_list.lo acl_list.o: $(srcdir)/daemon/acl_list.c config.h $(srcdir)/daemon/acl_list.h \ $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/regional.h $(srcdir)/util/log.h \ - $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h + $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/services/localzone.h $(srcdir)/util/locks.h \ + $(srcdir)/sldns/str2wire.h $(srcdir)/sldns/rrdef.h cachedump.lo cachedump.o: $(srcdir)/daemon/cachedump.c config.h $(srcdir)/daemon/cachedump.h \ $(srcdir)/daemon/remote.h $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/sldns/sbuffer.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \ @@ -994,7 +1017,7 @@ unbound.lo unbound.o: $(srcdir)/daemon/u $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/rtt.h $(srcdir)/util/fptr_wlist.h \ $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ $(srcdir)/sldns/rrdef.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/util/net_help.h \ - $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h + $(srcdir)/util/ub_event.h worker.lo worker.o: $(srcdir)/daemon/worker.c config.h $(srcdir)/util/log.h $(srcdir)/util/net_help.h \ $(srcdir)/util/random.h $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/sldns/sbuffer.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \ @@ -1020,7 +1043,7 @@ testbound.lo testbound.o: $(srcdir)/test $(srcdir)/util/data/packed_rrset.h $(srcdir)/services/cache/infra.h $(srcdir)/util/storage/dnstree.h \ $(srcdir)/util/rtt.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \ $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/tube.h \ - $(srcdir)/services/mesh.h $(srcdir)/util/net_help.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h + $(srcdir)/services/mesh.h $(srcdir)/util/net_help.h $(srcdir)/util/ub_event.h testpkts.lo testpkts.o: $(srcdir)/testcode/testpkts.c config.h $(srcdir)/testcode/testpkts.h \ $(srcdir)/util/net_help.h $(srcdir)/util/log.h $(srcdir)/sldns/sbuffer.h $(srcdir)/sldns/rrdef.h $(srcdir)/sldns/pkthdr.h \ $(srcdir)/sldns/str2wire.h $(srcdir)/sldns/wire2str.h @@ -1042,7 +1065,8 @@ worker.lo worker.o: $(srcdir)/daemon/wor $(srcdir)/libunbound/libworker.h acl_list.lo acl_list.o: $(srcdir)/daemon/acl_list.c config.h $(srcdir)/daemon/acl_list.h \ $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/regional.h $(srcdir)/util/log.h \ - $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h + $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/services/localzone.h $(srcdir)/util/locks.h \ + $(srcdir)/sldns/str2wire.h $(srcdir)/sldns/rrdef.h daemon.lo daemon.o: $(srcdir)/daemon/daemon.c config.h $(srcdir)/daemon/daemon.h $(srcdir)/util/locks.h \ $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h \ $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/sldns/sbuffer.h \ @@ -1101,7 +1125,7 @@ unbound-checkconf.lo unbound-checkconf.o $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_fwd.h \ $(srcdir)/util/rbtree.h $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h \ $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h $(srcdir)/services/localzone.h \ - $(srcdir)/sldns/sbuffer.h + $(srcdir)/sldns/sbuffer.h $(PYTHONMOD_HEADER) worker_cb.lo worker_cb.o: $(srcdir)/smallapp/worker_cb.c config.h $(srcdir)/libunbound/context.h \ $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h \ $(srcdir)/libunbound/unbound.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \ @@ -1113,17 +1137,18 @@ context.lo context.o: $(srcdir)/libunbou $(srcdir)/libunbound/unbound.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \ $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ $(srcdir)/sldns/rrdef.h $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/services/localzone.h \ - $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h \ - $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rtt.h $(srcdir)/sldns/sbuffer.h + $(srcdir)/util/storage/dnstree.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \ + $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/sldns/sbuffer.h libunbound.lo libunbound.o: $(srcdir)/libunbound/libunbound.c $(srcdir)/libunbound/unbound.h \ $(srcdir)/libunbound/unbound-event.h config.h $(srcdir)/libunbound/context.h $(srcdir)/util/locks.h \ $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/libunbound/libworker.h \ $(srcdir)/util/config_file.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \ $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/regional.h \ - $(srcdir)/util/random.h $(srcdir)/util/net_help.h $(srcdir)/util/tube.h $(srcdir)/services/localzone.h \ - $(srcdir)/services/cache/infra.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rtt.h \ - $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/sldns/sbuffer.h + $(srcdir)/util/random.h $(srcdir)/util/net_help.h $(srcdir)/util/tube.h $(srcdir)/util/ub_event.h \ + $(srcdir)/services/localzone.h $(srcdir)/util/storage/dnstree.h $(srcdir)/services/cache/infra.h \ + $(srcdir)/util/rtt.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \ + $(srcdir)/sldns/sbuffer.h libworker.lo libworker.o: $(srcdir)/libunbound/libworker.c config.h $(srcdir)/libunbound/libworker.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \ $(srcdir)/libunbound/context.h $(srcdir)/util/alloc.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h \ @@ -1131,11 +1156,12 @@ libworker.lo libworker.o: $(srcdir)/libu $(srcdir)/libunbound/unbound-event.h $(srcdir)/services/outside_network.h $(srcdir)/util/netevent.h \ $(srcdir)/services/mesh.h $(srcdir)/util/data/msgparse.h \ $(srcdir)/sldns/pkthdr.h $(srcdir)/sldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \ - $(srcdir)/services/localzone.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \ - $(srcdir)/services/outbound_list.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/tube.h $(srcdir)/util/regional.h \ - $(srcdir)/util/random.h $(srcdir)/util/config_file.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/net_help.h \ - $(srcdir)/util/data/dname.h $(srcdir)/util/data/msgencode.h $(srcdir)/iterator/iter_fwd.h \ - $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h $(srcdir)/sldns/str2wire.h + $(srcdir)/services/localzone.h $(srcdir)/util/storage/dnstree.h $(srcdir)/services/cache/rrset.h \ + $(srcdir)/util/storage/slabhash.h $(srcdir)/services/outbound_list.h $(srcdir)/util/fptr_wlist.h \ + $(srcdir)/util/tube.h $(srcdir)/util/regional.h $(srcdir)/util/random.h $(srcdir)/util/config_file.h \ + $(srcdir)/util/storage/lookup3.h $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h \ + $(srcdir)/util/data/msgencode.h $(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_hints.h \ + $(srcdir)/sldns/str2wire.h unbound-host.lo unbound-host.o: $(srcdir)/smallapp/unbound-host.c config.h $(srcdir)/libunbound/unbound.h \ $(srcdir)/sldns/rrdef.h $(srcdir)/sldns/wire2str.h asynclook.lo asynclook.o: $(srcdir)/testcode/asynclook.c config.h $(srcdir)/libunbound/unbound.h \ @@ -1163,14 +1189,15 @@ pythonmod_utils.lo pythonmod_utils.o: $( $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ $(srcdir)/sldns/rrdef.h $(srcdir)/util/netevent.h $(srcdir)/util/net_help.h $(srcdir)/services/cache/dns.h \ $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/util/regional.h \ - $(srcdir)/iterator/iter_delegpt.h $(srcdir)/sldns/sbuffer.h + $(srcdir)/iterator/iter_delegpt.h $(srcdir)/sldns/sbuffer.h \ + win_svc.lo win_svc.o: $(srcdir)/winrc/win_svc.c config.h $(srcdir)/winrc/win_svc.h $(srcdir)/winrc/w_inst.h \ $(srcdir)/daemon/daemon.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h \ $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h \ $(srcdir)/sldns/sbuffer.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \ $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/sldns/pkthdr.h \ $(srcdir)/sldns/rrdef.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \ - $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/remote.h $(srcdir)/util/config_file.h $(srcdir)/util/winsock_event.h + $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/remote.h $(srcdir)/util/config_file.h $(srcdir)/util/ub_event.h w_inst.lo w_inst.o: $(srcdir)/winrc/w_inst.c config.h $(srcdir)/winrc/w_inst.h $(srcdir)/winrc/win_svc.h unbound-service-install.lo unbound-service-install.o: $(srcdir)/winrc/unbound-service-install.c config.h \ $(srcdir)/winrc/w_inst.h @@ -1213,3 +1240,4 @@ arc4_lock.lo arc4_lock.o: $(srcdir)/comp sha512.lo sha512.o: $(srcdir)/compat/sha512.c config.h reallocarray.lo reallocarray.o: $(srcdir)/compat/reallocarray.c config.h isblank.lo isblank.o: $(srcdir)/compat/isblank.c config.h +strsep.lo strsep.o: $(srcdir)/compat/strsep.c config.h Modified: stable/11/contrib/unbound/acx_nlnetlabs.m4 ============================================================================== --- stable/11/contrib/unbound/acx_nlnetlabs.m4 Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/acx_nlnetlabs.m4 Fri Oct 21 14:28:35 2016 (r307729) @@ -2,7 +2,9 @@ # Copyright 2009, Wouter Wijngaards, NLnet Labs. # BSD licensed. # -# Version 32 +# Version 34 +# 2016-03-21 Check -ldl -pthread for libcrypto for ldns and openssl 1.1.0. +# 2016-03-21 Use HMAC_Update instead of HMAC_CTX_Init (for openssl-1.1.0). # 2016-01-04 -D_DEFAULT_SOURCE defined with -D_BSD_SOURCE for Linux glibc 2.20 # 2015-12-11 FLTO check for new OSX, clang. # 2015-11-18 spelling check fix. @@ -671,16 +673,16 @@ AC_DEFUN([ACX_SSL_CHECKS], [ ACX_RUNTIME_PATH_ADD([$ssldir/lib]) fi - AC_MSG_CHECKING([for HMAC_CTX_init in -lcrypto]) + AC_MSG_CHECKING([for HMAC_Update in -lcrypto]) LIBS="$LIBS -lcrypto" LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto" AC_TRY_LINK(, [ - int HMAC_CTX_init(void); - (void)HMAC_CTX_init(); + int HMAC_Update(void); + (void)HMAC_Update(); ], [ AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_HMAC_CTX_INIT], 1, - [If you have HMAC_CTX_init]) + AC_DEFINE([HAVE_HMAC_UPDATE], 1, + [If you have HMAC_Update]) ], [ AC_MSG_RESULT(no) # check if -lwsock32 or -lgdi32 are needed. @@ -690,11 +692,11 @@ AC_DEFUN([ACX_SSL_CHECKS], [ LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32" AC_MSG_CHECKING([if -lcrypto needs -lgdi32]) AC_TRY_LINK([], [ - int HMAC_CTX_init(void); - (void)HMAC_CTX_init(); + int HMAC_Update(void); + (void)HMAC_Update(); ],[ - AC_DEFINE([HAVE_HMAC_CTX_INIT], 1, - [If you have HMAC_CTX_init]) + AC_DEFINE([HAVE_HMAC_UPDATE], 1, + [If you have HMAC_Update]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) @@ -704,15 +706,30 @@ AC_DEFUN([ACX_SSL_CHECKS], [ LIBSSL_LIBS="$LIBSSL_LIBS -ldl" AC_MSG_CHECKING([if -lcrypto needs -ldl]) AC_TRY_LINK([], [ - int HMAC_CTX_init(void); - (void)HMAC_CTX_init(); + int HMAC_Update(void); + (void)HMAC_Update(); ],[ - AC_DEFINE([HAVE_HMAC_CTX_INIT], 1, - [If you have HMAC_CTX_init]) + AC_DEFINE([HAVE_HMAC_UPDATE], 1, + [If you have HMAC_Update]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) - AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) + LIBS="$BAKLIBS" + LIBSSL_LIBS="$BAKSSLLIBS" + LIBS="$LIBS -ldl -pthread" + LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread" + AC_MSG_CHECKING([if -lcrypto needs -ldl -pthread]) + AC_TRY_LINK([], [ + int HMAC_Update(void); + (void)HMAC_Update(); + ],[ + AC_DEFINE([HAVE_HMAC_UPDATE], 1, + [If you have HMAC_Update]) + AC_MSG_RESULT(yes) + ],[ + AC_MSG_RESULT(no) + AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) + ]) ]) ]) ]) Modified: stable/11/contrib/unbound/acx_python.m4 ============================================================================== --- stable/11/contrib/unbound/acx_python.m4 Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/acx_python.m4 Fri Oct 21 14:28:35 2016 (r307729) @@ -54,7 +54,7 @@ $ac_distutils_result]) AC_MSG_CHECKING([for Python library path]) if test -z "$PYTHON_LDFLAGS"; then PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \ - print(get_config_var('BLDLIBRARY'));"` + print('-L'+get_config_var('LIBDIR')+' -L'+get_config_var('LIBDEST')+' '+get_config_var('BLDLIBRARY'));"` fi AC_MSG_RESULT([$PYTHON_LDFLAGS]) AC_SUBST([PYTHON_LDFLAGS]) Modified: stable/11/contrib/unbound/compat/arc4random.c ============================================================================== --- stable/11/contrib/unbound/compat/arc4random.c Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/compat/arc4random.c Fri Oct 21 14:28:35 2016 (r307729) @@ -48,6 +48,9 @@ #else /* !__GNUC__ */ #define inline #endif /* !__GNUC__ */ +#ifndef MAP_ANON +#define MAP_ANON MAP_ANONYMOUS +#endif #define KEYSZ 32 #define IVSZ 8 Modified: stable/11/contrib/unbound/compat/explicit_bzero.c ============================================================================== --- stable/11/contrib/unbound/compat/explicit_bzero.c Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/compat/explicit_bzero.c Fri Oct 21 14:28:35 2016 (r307729) @@ -6,7 +6,11 @@ #include "config.h" #include +#ifdef HAVE_ATTR_WEAK __attribute__((weak)) void +#else +void +#endif __explicit_bzero_hook(void *ATTR_UNUSED(buf), size_t ATTR_UNUSED(len)) { } Modified: stable/11/contrib/unbound/compat/getentropy_linux.c ============================================================================== --- stable/11/contrib/unbound/compat/getentropy_linux.c Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/compat/getentropy_linux.c Fri Oct 21 14:28:35 2016 (r307729) @@ -60,6 +60,9 @@ #include #endif #include +#ifndef MAP_ANON +#define MAP_ANON MAP_ANONYMOUS +#endif #define REPEAT 5 #define min(a, b) (((a) < (b)) ? (a) : (b)) @@ -94,7 +97,7 @@ int getentropy(void *buf, size_t len); extern int main(int, char *argv[]); #endif static int gotdata(char *buf, size_t len); -#ifdef SYS_getrandom +#if defined(SYS_getrandom) && defined(__NR_getrandom) static int getentropy_getrandom(void *buf, size_t len); #endif static int getentropy_urandom(void *buf, size_t len); @@ -113,7 +116,7 @@ getentropy(void *buf, size_t len) return -1; } -#ifdef SYS_getrandom +#if defined(SYS_getrandom) && defined(__NR_getrandom) /* * Try descriptor-less getrandom() */ @@ -209,7 +212,7 @@ gotdata(char *buf, size_t len) return 0; } -#ifdef SYS_getrandom +#if defined(SYS_getrandom) && defined(__NR_getrandom) static int getentropy_getrandom(void *buf, size_t len) { Copied: stable/11/contrib/unbound/compat/strsep.c (from r305381, head/contrib/unbound/compat/strsep.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/unbound/compat/strsep.c Fri Oct 21 14:28:35 2016 (r307729, copy of r305381, head/contrib/unbound/compat/strsep.c) @@ -0,0 +1,65 @@ +/** + * strsep implementation for compatibility. + * + * LICENSE + * Copyright (c) 2016, NLnet Labs + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of NLnetLabs nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + **/ + +#include "config.h" + +/** see if character is in the delimiter array */ +static int +in_delim(char c, const char* delim) +{ + const char* p; + if(!delim) + return 0; + for(p=delim; *p; p++) { + if(*p == c) + return 1; + } + return 0; +} + +char *strsep(char **stringp, const char *delim) +{ + char* s; + char* orig; + if(stringp == NULL || *stringp == NULL) + return NULL; + orig = *stringp; + s = *stringp; + while(*s && !in_delim(*s, delim)) + s++; + if(*s) { + *s = 0; + *stringp = s+1; + } else { + *stringp = NULL; + } + return orig; +} Modified: stable/11/contrib/unbound/config.h ============================================================================== --- stable/11/contrib/unbound/config.h Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/config.h Fri Oct 21 14:28:35 2016 (r307729) @@ -43,12 +43,18 @@ /* Whether the C compiler accepts the "unused" attribute */ #define HAVE_ATTR_UNUSED 1 +/* Whether the C compiler accepts the "weak" attribute */ +#define HAVE_ATTR_WEAK 1 + /* Define to 1 if you have the `chown' function. */ #define HAVE_CHOWN 1 /* Define to 1 if you have the `chroot' function. */ #define HAVE_CHROOT 1 +/* Define to 1 if you have the `CRYPTO_cleanup_all_ex_data' function. */ +#define HAVE_CRYPTO_CLEANUP_ALL_EX_DATA 1 + /* Define to 1 if you have the `ctime_r' function. */ #define HAVE_CTIME_R 1 @@ -108,9 +114,18 @@ /* Define to 1 if you have the `endprotoent' function. */ #define HAVE_ENDPROTOENT 1 +/* Define to 1 if you have the `endpwent' function. */ +#define HAVE_ENDPWENT 1 + /* Define to 1 if you have the `endservent' function. */ #define HAVE_ENDSERVENT 1 +/* Define to 1 if you have the `ERR_free_strings' function. */ +#define HAVE_ERR_FREE_STRINGS 1 + +/* Define to 1 if you have the `ERR_load_crypto_strings' function. */ +#define HAVE_ERR_LOAD_CRYPTO_STRINGS 1 + /* Define to 1 if you have the `event_base_free' function. */ /* #undef HAVE_EVENT_BASE_FREE */ @@ -126,6 +141,12 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_EVENT_H */ +/* Define to 1 if you have the `EVP_cleanup' function. */ +#define HAVE_EVP_CLEANUP 1 + +/* Define to 1 if you have the `EVP_MD_CTX_new' function. */ +/* #undef HAVE_EVP_MD_CTX_NEW */ + /* Define to 1 if you have the `EVP_sha1' function. */ #define HAVE_EVP_SHA1 1 @@ -189,8 +210,8 @@ /* Define to 1 if you have the header file. */ #define HAVE_GRP_H 1 -/* If you have HMAC_CTX_init */ -#define HAVE_HMAC_CTX_INIT 1 +/* If you have HMAC_Update */ +#define HAVE_HMAC_UPDATE 1 /* Define to 1 if you have the `inet_aton' function. */ #define HAVE_INET_ATON 1 @@ -249,24 +270,48 @@ /* Use libnettle for crypto */ /* #undef HAVE_NETTLE */ +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_DSA_COMPAT_H */ + /* Use libnss for crypto */ /* #undef HAVE_NSS */ +/* Define to 1 if you have the `OpenSSL_add_all_digests' function. */ +#define HAVE_OPENSSL_ADD_ALL_DIGESTS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_BN_H 1 + /* Define to 1 if you have the `OPENSSL_config' function. */ #define HAVE_OPENSSL_CONFIG 1 /* Define to 1 if you have the header file. */ #define HAVE_OPENSSL_CONF_H 1 +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_DH_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_DSA_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_OPENSSL_ENGINE_H 1 /* Define to 1 if you have the header file. */ #define HAVE_OPENSSL_ERR_H 1 +/* Define to 1 if you have the `OPENSSL_init_crypto' function. */ +/* #undef HAVE_OPENSSL_INIT_CRYPTO */ + +/* Define to 1 if you have the `OPENSSL_init_ssl' function. */ +/* #undef HAVE_OPENSSL_INIT_SSL */ + /* Define to 1 if you have the header file. */ #define HAVE_OPENSSL_RAND_H 1 +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_RSA_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_OPENSSL_SSL_H 1 @@ -291,6 +336,9 @@ /* Define to 1 if you have the `random' function. */ #define HAVE_RANDOM 1 +/* Define to 1 if you have the `RAND_cleanup' function. */ +#define HAVE_RAND_CLEANUP 1 + /* Define to 1 if you have the `reallocarray' function. */ #define HAVE_REALLOCARRAY 1 @@ -378,6 +426,9 @@ /* Define to 1 if you have the `strptime' function. */ #define HAVE_STRPTIME 1 +/* Define to 1 if you have the `strsep' function. */ +#define HAVE_STRSEP 1 + /* Define to 1 if `ipi_spec_dst' is a member of `struct in_pktinfo'. */ /* #undef HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST */ @@ -515,7 +566,7 @@ #define PACKAGE_NAME "unbound" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "unbound 1.5.8" +#define PACKAGE_STRING "unbound 1.5.10" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "unbound" @@ -524,7 +575,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.5.8" +#define PACKAGE_VERSION "1.5.10" /* default pidfile location */ #define PIDFILE "/var/unbound/unbound.pid" @@ -543,7 +594,7 @@ #define ROOT_CERT_FILE "/var/unbound/icannbundle.pem" /* version number for resource files */ -#define RSRC_PACKAGE_VERSION 1,5,8,0 +#define RSRC_PACKAGE_VERSION 1,5,10,0 /* Directory to chdir to */ #define RUN_DIR "/var/unbound" @@ -581,9 +632,15 @@ /* define this to enable debug checks. */ /* #undef UNBOUND_DEBUG */ +/* Define to 1 to use cachedb support */ +/* #undef USE_CACHEDB */ + /* Define to 1 to enable dnstap support */ /* #undef USE_DNSTAP */ +/* Define this to enable DSA support. */ +#define USE_DSA 1 + /* Define this to enable ECDSA support. */ #define USE_ECDSA 1 @@ -596,6 +653,12 @@ /* Define if you want to use internal select based events */ #define USE_MINI_EVENT 1 +/* Define this to enable client TCP Fast Open. */ +/* #undef USE_MSG_FASTOPEN */ + +/* Define this to enable client TCP Fast Open. */ +/* #undef USE_OSX_MSG_FASTOPEN */ + /* Define this to enable SHA256 and SHA512 support. */ #define USE_SHA2 1 @@ -621,6 +684,9 @@ #endif +/* Define this to enable server TCP Fast Open. */ +/* #undef USE_TCP_FASTOPEN */ + /* Whether the windows socket API is used */ /* #undef USE_WINSOCK */ @@ -980,6 +1046,11 @@ int memcmp(const void *x, const void *y, char *ctime_r(const time_t *timep, char *buf); #endif +#ifndef HAVE_STRSEP +#define strsep unbound_strsep +char *strsep(char **stringp, const char *delim); +#endif + #ifndef HAVE_ISBLANK #define isblank unbound_isblank int isblank(int c); Modified: stable/11/contrib/unbound/config.h.in ============================================================================== --- stable/11/contrib/unbound/config.h.in Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/config.h.in Fri Oct 21 14:28:35 2016 (r307729) @@ -42,12 +42,18 @@ /* Whether the C compiler accepts the "unused" attribute */ #undef HAVE_ATTR_UNUSED +/* Whether the C compiler accepts the "weak" attribute */ +#undef HAVE_ATTR_WEAK + /* Define to 1 if you have the `chown' function. */ #undef HAVE_CHOWN /* Define to 1 if you have the `chroot' function. */ #undef HAVE_CHROOT +/* Define to 1 if you have the `CRYPTO_cleanup_all_ex_data' function. */ +#undef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA + /* Define to 1 if you have the `ctime_r' function. */ #undef HAVE_CTIME_R @@ -107,9 +113,18 @@ /* Define to 1 if you have the `endprotoent' function. */ #undef HAVE_ENDPROTOENT +/* Define to 1 if you have the `endpwent' function. */ +#undef HAVE_ENDPWENT + /* Define to 1 if you have the `endservent' function. */ #undef HAVE_ENDSERVENT +/* Define to 1 if you have the `ERR_free_strings' function. */ +#undef HAVE_ERR_FREE_STRINGS + +/* Define to 1 if you have the `ERR_load_crypto_strings' function. */ +#undef HAVE_ERR_LOAD_CRYPTO_STRINGS + /* Define to 1 if you have the `event_base_free' function. */ #undef HAVE_EVENT_BASE_FREE @@ -125,6 +140,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_EVENT_H +/* Define to 1 if you have the `EVP_cleanup' function. */ +#undef HAVE_EVP_CLEANUP + +/* Define to 1 if you have the `EVP_MD_CTX_new' function. */ +#undef HAVE_EVP_MD_CTX_NEW + /* Define to 1 if you have the `EVP_sha1' function. */ #undef HAVE_EVP_SHA1 @@ -188,8 +209,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_GRP_H -/* If you have HMAC_CTX_init */ -#undef HAVE_HMAC_CTX_INIT +/* If you have HMAC_Update */ +#undef HAVE_HMAC_UPDATE /* Define to 1 if you have the `inet_aton' function. */ #undef HAVE_INET_ATON @@ -248,24 +269,48 @@ /* Use libnettle for crypto */ #undef HAVE_NETTLE +/* Define to 1 if you have the header file. */ +#undef HAVE_NETTLE_DSA_COMPAT_H + /* Use libnss for crypto */ #undef HAVE_NSS +/* Define to 1 if you have the `OpenSSL_add_all_digests' function. */ +#undef HAVE_OPENSSL_ADD_ALL_DIGESTS + +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_BN_H + /* Define to 1 if you have the `OPENSSL_config' function. */ #undef HAVE_OPENSSL_CONFIG /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_CONF_H +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_DH_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_DSA_H + /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_ENGINE_H /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_ERR_H +/* Define to 1 if you have the `OPENSSL_init_crypto' function. */ +#undef HAVE_OPENSSL_INIT_CRYPTO + +/* Define to 1 if you have the `OPENSSL_init_ssl' function. */ +#undef HAVE_OPENSSL_INIT_SSL + /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_RAND_H +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_RSA_H + /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_SSL_H @@ -290,6 +335,9 @@ /* Define to 1 if you have the `random' function. */ #undef HAVE_RANDOM +/* Define to 1 if you have the `RAND_cleanup' function. */ +#undef HAVE_RAND_CLEANUP + /* Define to 1 if you have the `reallocarray' function. */ #undef HAVE_REALLOCARRAY @@ -377,6 +425,9 @@ /* Define to 1 if you have the `strptime' function. */ #undef HAVE_STRPTIME +/* Define to 1 if you have the `strsep' function. */ +#undef HAVE_STRSEP + /* Define to 1 if `ipi_spec_dst' is a member of `struct in_pktinfo'. */ #undef HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST @@ -580,9 +631,15 @@ /* define this to enable debug checks. */ #undef UNBOUND_DEBUG +/* Define to 1 to use cachedb support */ +#undef USE_CACHEDB + /* Define to 1 to enable dnstap support */ #undef USE_DNSTAP +/* Define this to enable DSA support. */ +#undef USE_DSA + /* Define this to enable ECDSA support. */ #undef USE_ECDSA @@ -595,6 +652,12 @@ /* Define if you want to use internal select based events */ #undef USE_MINI_EVENT +/* Define this to enable client TCP Fast Open. */ +#undef USE_MSG_FASTOPEN + +/* Define this to enable client TCP Fast Open. */ +#undef USE_OSX_MSG_FASTOPEN + /* Define this to enable SHA256 and SHA512 support. */ #undef USE_SHA2 @@ -620,6 +683,9 @@ #endif +/* Define this to enable server TCP Fast Open. */ +#undef USE_TCP_FASTOPEN + /* Whether the windows socket API is used */ #undef USE_WINSOCK @@ -979,6 +1045,11 @@ int memcmp(const void *x, const void *y, char *ctime_r(const time_t *timep, char *buf); #endif +#ifndef HAVE_STRSEP +#define strsep unbound_strsep +char *strsep(char **stringp, const char *delim); +#endif + #ifndef HAVE_ISBLANK #define isblank unbound_isblank int isblank(int c); Modified: stable/11/contrib/unbound/configure ============================================================================== --- stable/11/contrib/unbound/configure Fri Oct 21 13:51:47 2016 (r307728) +++ stable/11/contrib/unbound/configure Fri Oct 21 14:28:35 2016 (r307729) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for unbound 1.5.8. +# Generated by GNU Autoconf 2.69 for unbound 1.5.10. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='unbound' PACKAGE_TARNAME='unbound' -PACKAGE_VERSION='1.5.8' -PACKAGE_STRING='unbound 1.5.8' +PACKAGE_VERSION='1.5.10' +PACKAGE_STRING='unbound 1.5.10' PACKAGE_BUGREPORT='unbound-bugs@nlnetlabs.nl' PACKAGE_URL='' @@ -832,7 +832,10 @@ with_ssl enable_sha2 enable_gost enable_ecdsa +enable_dsa enable_event_api *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Fri Oct 21 16:11:30 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 92449C1C25F; Fri, 21 Oct 2016 16:11:30 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49C5E91E; Fri, 21 Oct 2016 16:11:30 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LGBTEp057318; Fri, 21 Oct 2016 16:11:29 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LGBTRO057317; Fri, 21 Oct 2016 16:11:29 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610211611.u9LGBTRO057317@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 21 Oct 2016 16:11:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307732 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 16:11:30 -0000 Author: gjb Date: Fri Oct 21 16:11:29 2016 New Revision: 307732 URL: https://svnweb.freebsd.org/changeset/base/307732 Log: Document two errata items that may affect systems with ZFS boot pools on GPT. Submitted by: lidl Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 15:23:54 2016 (r307731) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:11:29 2016 (r307732) @@ -209,6 +209,44 @@ boot UEFI mode, or choose the "GPT + Active" scheme. + + + [2016-10-21] Support for sha512 and + skein checksumming has been added to the + ZFS filesystem. This was not mentioned + in the release notes. + + Systems being upgraded from earlier &os; releases with + ZFS will see a message in zpool + status output noting the pool is not at the + latest version, and some features may not be enabled. + Additional instructions on how to any ZFS + pools to the latest version and update the boot blocks for + all boot drives in the pool will also be provided in the + output. + + This information is also documented is also documented + in /usr/src/UPDATING, which is + included if the src component is selected + during installation. + + + + [2016-10-21] The size of the GPT + enabled ZFS boot blocks + (/boot/gptzfsboot) has increased past + 64K. Systems upgraded from older releases may experience + a problem where the size of the existing + "freebsd-boot" partition is too small to hold the + new gptzfsboot. + + Systems where the boot partition is immediately followed + by the swap partition, such as those installed via + &man.bsdinstall.8;, can resize the swap partition slightly + using the &man.gpart.8; resize command, + so space can be reclaimed to increase the size of the + freebsd-boot partition. + From owner-svn-src-stable@freebsd.org Fri Oct 21 16:12:10 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5AA36C1C2B9; Fri, 21 Oct 2016 16:12:10 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 295E9AFD; Fri, 21 Oct 2016 16:12:10 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LGC9ux059414; Fri, 21 Oct 2016 16:12:09 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LGC976059413; Fri, 21 Oct 2016 16:12:09 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610211612.u9LGC976059413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 21 Oct 2016 16:12:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307733 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 16:12:10 -0000 Author: gjb Date: Fri Oct 21 16:12:09 2016 New Revision: 307733 URL: https://svnweb.freebsd.org/changeset/base/307733 Log: Fix a spacing nit and a typo. Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:11:29 2016 (r307732) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:12:09 2016 (r307733) @@ -97,8 +97,8 @@ An issue was discovered with Amazon® EC2™ images which would cause the virtual machine to hang during - boot when upgrading from previous FreeBSD versions. New - EC2™ installations are not affected, but exisiting + boot when upgrading from previous FreeBSD versions. New + EC2™ installations are not affected, but existing installations running earlier releases are advised to wait until the issue is resolved in an Errata Notice before upgrading. An Errata Notice to address this is planned From owner-svn-src-stable@freebsd.org Fri Oct 21 16:14:59 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97FA0C1C42C; Fri, 21 Oct 2016 16:14:59 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 63B24FA6; Fri, 21 Oct 2016 16:14:59 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LGEw1o060311; Fri, 21 Oct 2016 16:14:58 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LGEwLb060310; Fri, 21 Oct 2016 16:14:58 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610211614.u9LGEwLb060310@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 21 Oct 2016 16:14:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307735 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 16:14:59 -0000 Author: gjb Date: Fri Oct 21 16:14:58 2016 New Revision: 307735 URL: https://svnweb.freebsd.org/changeset/base/307735 Log: Fix a copy/paste error. Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:12:23 2016 (r307734) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:14:58 2016 (r307735) @@ -225,10 +225,10 @@ boot all boot drives in the pool will also be provided in the output. - This information is also documented is also documented - in /usr/src/UPDATING, which is - included if the src component is selected - during installation. + This information is also documented in + /usr/src/UPDATING, which is included if + the src component is selected during + installation. From owner-svn-src-stable@freebsd.org Fri Oct 21 16:43:15 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 409DAC1C9ED; Fri, 21 Oct 2016 16:43:15 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0CD06279; Fri, 21 Oct 2016 16:43:14 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LGhEOd071733; Fri, 21 Oct 2016 16:43:14 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LGhEYR071732; Fri, 21 Oct 2016 16:43:14 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610211643.u9LGhEYR071732@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 21 Oct 2016 16:43:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307739 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 16:43:15 -0000 Author: gjb Date: Fri Oct 21 16:43:13 2016 New Revision: 307739 URL: https://svnweb.freebsd.org/changeset/base/307739 Log: Document an issue with clang and source-based upgrades from 10.2 and earlier. Submitted by: imp Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:42:39 2016 (r307738) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:43:13 2016 (r307739) @@ -247,6 +247,19 @@ boot so space can be reclaimed to increase the size of the freebsd-boot partition. + + + [2016-10-21] Due to a bug in earlier versions of + &man.clang.1; that are difficult to work around in the + upgrade process, to upgrade the system from sources via + buildworld to -CURRENT or &release;, it is necessary to + upgrade machines running 9.x to at least revision r286035, + or machines running 10.x to revision r286033. Source-based + upgrades from 10.3-RELEASE are not affected. This differs + from the historical situation where one could generally + upgrade from anywhere on earlier stable branches, so caution + should be exercised. + From owner-svn-src-stable@freebsd.org Fri Oct 21 16:47:03 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C046C1CB72; Fri, 21 Oct 2016 16:47:03 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5BC1077A; Fri, 21 Oct 2016 16:47:03 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LGl2sB071997; Fri, 21 Oct 2016 16:47:02 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LGl2QS071996; Fri, 21 Oct 2016 16:47:02 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610211647.u9LGl2QS071996@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 21 Oct 2016 16:47:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307740 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 16:47:03 -0000 Author: gjb Date: Fri Oct 21 16:47:02 2016 New Revision: 307740 URL: https://svnweb.freebsd.org/changeset/base/307740 Log: Fix wording. Submitted by: adamw Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:43:13 2016 (r307739) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 16:47:02 2016 (r307740) @@ -220,10 +220,10 @@ boot ZFS will see a message in zpool status output noting the pool is not at the latest version, and some features may not be enabled. - Additional instructions on how to any ZFS - pools to the latest version and update the boot blocks for - all boot drives in the pool will also be provided in the - output. + Additional instructions on how to update + ZFS pools to the latest version and + update the boot blocks for all boot drives in the pool will + also be provided in the output. This information is also documented in /usr/src/UPDATING, which is included if From owner-svn-src-stable@freebsd.org Fri Oct 21 17:39:07 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06244C1BB3A; Fri, 21 Oct 2016 17:39:07 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A6E5D850; Fri, 21 Oct 2016 17:39:06 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LHd5oe091107; Fri, 21 Oct 2016 17:39:05 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LHd5J8091105; Fri, 21 Oct 2016 17:39:05 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201610211739.u9LHd5J8091105@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 21 Oct 2016 17:39:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307742 - in stable/10: sbin/mount_msdosfs sys/fs/msdosfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 17:39:07 -0000 Author: asomers Date: Fri Oct 21 17:39:05 2016 New Revision: 307742 URL: https://svnweb.freebsd.org/changeset/base/307742 Log: MFC r306276, but don't remove findwin95 Mount msdosfs with longnames support by default. The old behavior depended on the FAT version and on what files were in the root directory. "mount_msdosfs -o shortnames" is still supported. Modified: stable/10/sbin/mount_msdosfs/mount_msdosfs.8 stable/10/sys/fs/msdosfs/msdosfs_vfsops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/mount_msdosfs/mount_msdosfs.8 ============================================================================== --- stable/10/sbin/mount_msdosfs/mount_msdosfs.8 Fri Oct 21 17:25:19 2016 (r307741) +++ stable/10/sbin/mount_msdosfs/mount_msdosfs.8 Fri Oct 21 17:39:05 2016 (r307742) @@ -142,15 +142,8 @@ If neither nor .Fl l are given, -.Nm -searches the root directory of the file system to -be mounted for any existing Win'95 long filenames. -If no such entries are found, but short DOS filenames are found, -.Fl s -is the default. -Otherwise .Fl l -is assumed. +is the default. .It Fl 9 Ignore the special Win'95 directory entries even if deleting or renaming a file. Modified: stable/10/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- stable/10/sys/fs/msdosfs/msdosfs_vfsops.c Fri Oct 21 17:25:19 2016 (r307741) +++ stable/10/sys/fs/msdosfs/msdosfs_vfsops.c Fri Oct 21 17:39:05 2016 (r307742) @@ -175,24 +175,8 @@ update_mp(struct mount *mp, struct threa if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) pmp->pm_flags |= MSDOSFSMNT_SHORTNAME; - else if (!(pmp->pm_flags & - (MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) { - struct vnode *rootvp; - - /* - * Try to divine whether to support Win'95 long filenames - */ - if (FAT32(pmp)) - pmp->pm_flags |= MSDOSFSMNT_LONGNAME; - else { - if ((error = - msdosfs_root(mp, LK_EXCLUSIVE, &rootvp)) != 0) - return error; - pmp->pm_flags |= findwin95(VTODE(rootvp)) ? - MSDOSFSMNT_LONGNAME : MSDOSFSMNT_SHORTNAME; - vput(rootvp); - } - } + else + pmp->pm_flags |= MSDOSFSMNT_LONGNAME; return 0; } From owner-svn-src-stable@freebsd.org Fri Oct 21 17:43:27 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FD66C1BCE8; Fri, 21 Oct 2016 17:43:27 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CF86FC26; Fri, 21 Oct 2016 17:43:26 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LHhPGP094623; Fri, 21 Oct 2016 17:43:25 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LHhPfm094622; Fri, 21 Oct 2016 17:43:25 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610211743.u9LHhPfm094622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 21 Oct 2016 17:43:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307743 - stable/10/sys/vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 17:43:27 -0000 Author: markj Date: Fri Oct 21 17:43:25 2016 New Revision: 307743 URL: https://svnweb.freebsd.org/changeset/base/307743 Log: MFC r307236: Plug a vnode lock leak in vm_fault_hold(). Modified: stable/10/sys/vm/vm_fault.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/vm/vm_fault.c ============================================================================== --- stable/10/sys/vm/vm_fault.c Fri Oct 21 17:39:05 2016 (r307742) +++ stable/10/sys/vm/vm_fault.c Fri Oct 21 17:43:25 2016 (r307743) @@ -320,6 +320,8 @@ RetryFault:; growstack = FALSE; goto RetryFault; } + if (fs.vp != NULL) + vput(fs.vp); return (result); } From owner-svn-src-stable@freebsd.org Fri Oct 21 17:44:48 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B5B4C1BDAC; Fri, 21 Oct 2016 17:44:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 69AD4E68; Fri, 21 Oct 2016 17:44:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LHiltA094727; Fri, 21 Oct 2016 17:44:47 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LHilfL094726; Fri, 21 Oct 2016 17:44:47 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610211744.u9LHilfL094726@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 21 Oct 2016 17:44:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307744 - stable/11/sys/vm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 17:44:48 -0000 Author: markj Date: Fri Oct 21 17:44:47 2016 New Revision: 307744 URL: https://svnweb.freebsd.org/changeset/base/307744 Log: MFC r307236: Plug a vnode lock leak in vm_fault_hold(). Modified: stable/11/sys/vm/vm_fault.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_fault.c ============================================================================== --- stable/11/sys/vm/vm_fault.c Fri Oct 21 17:43:25 2016 (r307743) +++ stable/11/sys/vm/vm_fault.c Fri Oct 21 17:44:47 2016 (r307744) @@ -321,6 +321,8 @@ RetryFault:; growstack = FALSE; goto RetryFault; } + if (fs.vp != NULL) + vput(fs.vp); return (result); } From owner-svn-src-stable@freebsd.org Fri Oct 21 18:57:59 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8010FC1B1E9; Fri, 21 Oct 2016 18:57:59 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 37397651; Fri, 21 Oct 2016 18:57:59 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LIvwKC021759; Fri, 21 Oct 2016 18:57:58 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LIvwfO021757; Fri, 21 Oct 2016 18:57:58 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201610211857.u9LIvwfO021757@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 21 Oct 2016 18:57:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307748 - in stable/11: sbin/mount_msdosfs sys/fs/msdosfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 18:57:59 -0000 Author: asomers Date: Fri Oct 21 18:57:58 2016 New Revision: 307748 URL: https://svnweb.freebsd.org/changeset/base/307748 Log: MFC r306276, but don't remove findwin95 Mount msdosfs with longnames support by default. The old behavior depended on the FAT version and on what files were in the root directory. "mount_msdosfs -o shortnames" is still supported. Modified: stable/11/sbin/mount_msdosfs/mount_msdosfs.8 stable/11/sys/fs/msdosfs/msdosfs_vfsops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mount_msdosfs/mount_msdosfs.8 ============================================================================== --- stable/11/sbin/mount_msdosfs/mount_msdosfs.8 Fri Oct 21 18:54:56 2016 (r307747) +++ stable/11/sbin/mount_msdosfs/mount_msdosfs.8 Fri Oct 21 18:57:58 2016 (r307748) @@ -142,15 +142,8 @@ If neither nor .Fl l are given, -.Nm -searches the root directory of the file system to -be mounted for any existing Win'95 long filenames. -If no such entries are found, but short DOS filenames are found, -.Fl s -is the default. -Otherwise .Fl l -is assumed. +is the default. .It Fl 9 Ignore the special Win'95 directory entries even if deleting or renaming a file. Modified: stable/11/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- stable/11/sys/fs/msdosfs/msdosfs_vfsops.c Fri Oct 21 18:54:56 2016 (r307747) +++ stable/11/sys/fs/msdosfs/msdosfs_vfsops.c Fri Oct 21 18:57:58 2016 (r307748) @@ -175,24 +175,8 @@ update_mp(struct mount *mp, struct threa if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) pmp->pm_flags |= MSDOSFSMNT_SHORTNAME; - else if (!(pmp->pm_flags & - (MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) { - struct vnode *rootvp; - - /* - * Try to divine whether to support Win'95 long filenames - */ - if (FAT32(pmp)) - pmp->pm_flags |= MSDOSFSMNT_LONGNAME; - else { - if ((error = - msdosfs_root(mp, LK_EXCLUSIVE, &rootvp)) != 0) - return error; - pmp->pm_flags |= findwin95(VTODE(rootvp)) ? - MSDOSFSMNT_LONGNAME : MSDOSFSMNT_SHORTNAME; - vput(rootvp); - } - } + else + pmp->pm_flags |= MSDOSFSMNT_LONGNAME; return 0; } From owner-svn-src-stable@freebsd.org Fri Oct 21 19:23:52 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90E4FC1BDDA; Fri, 21 Oct 2016 19:23:52 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FC30A0D; Fri, 21 Oct 2016 19:23:52 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9LJNpNx032937; Fri, 21 Oct 2016 19:23:51 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9LJNpFV032936; Fri, 21 Oct 2016 19:23:51 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610211923.u9LJNpFV032936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 21 Oct 2016 19:23:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307749 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 21 Oct 2016 19:23:52 -0000 Author: gjb Date: Fri Oct 21 19:23:51 2016 New Revision: 307749 URL: https://svnweb.freebsd.org/changeset/base/307749 Log: Fix grammar. Submitted by: Kevin P. Neal Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 18:57:58 2016 (r307748) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Fri Oct 21 19:23:51 2016 (r307749) @@ -250,7 +250,7 @@ boot [2016-10-21] Due to a bug in earlier versions of - &man.clang.1; that are difficult to work around in the + &man.clang.1; that is difficult to work around in the upgrade process, to upgrade the system from sources via buildworld to -CURRENT or &release;, it is necessary to upgrade machines running 9.x to at least revision r286035, From owner-svn-src-stable@freebsd.org Sat Oct 22 00:35:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA572C1C98A; Sat, 22 Oct 2016 00:35:41 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8A375C1B; Sat, 22 Oct 2016 00:35:41 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M0ZeAi050205; Sat, 22 Oct 2016 00:35:40 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M0ZeVC050200; Sat, 22 Oct 2016 00:35:40 GMT (envelope-from des@FreeBSD.org) Message-Id: <201610220035.u9M0ZeVC050200@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Sat, 22 Oct 2016 00:35:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307757 - in stable/11: contrib/top usr.bin/top X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 00:35:41 -0000 Author: des Date: Sat Oct 22 00:35:40 2016 New Revision: 307757 URL: https://svnweb.freebsd.org/changeset/base/307757 Log: MFH (r305414): add a toggle to show approximate swap usage. Modified: stable/11/contrib/top/commands.c stable/11/contrib/top/machine.h stable/11/contrib/top/top.c stable/11/contrib/top/top.xs stable/11/usr.bin/top/machine.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/top/commands.c ============================================================================== --- stable/11/contrib/top/commands.c Fri Oct 21 23:50:02 2016 (r307756) +++ stable/11/contrib/top/commands.c Sat Oct 22 00:35:40 2016 (r307757) @@ -104,6 +104,7 @@ S - toggle the displaying of syste a - toggle the displaying of process titles\n\ t - toggle the display of this process\n\ u - display processes for only one user (+ selects all users)\n\ +w - toggle the display of swap use for each process\n\ z - toggle the displaying of the system idle process\n\ \n\ \n", stdout); Modified: stable/11/contrib/top/machine.h ============================================================================== --- stable/11/contrib/top/machine.h Fri Oct 21 23:50:02 2016 (r307756) +++ stable/11/contrib/top/machine.h Sat Oct 22 00:35:40 2016 (r307757) @@ -72,6 +72,7 @@ struct process_select int wcpu; /* show weighted cpu */ int jid; /* only this jid (unless jid == -1) */ int jail; /* show jail ID */ + int swap; /* show swap usage */ int kidle; /* show per-CPU idle threads */ char *command; /* only this command (unless == NULL) */ }; @@ -82,8 +83,8 @@ char *format_header(); char *format_next_process(); void toggle_pcpustats(void); void get_system_info(struct system_info *si); -int machine_init(struct statics *statics, char do_unames); -int proc_owner(int pid); +int machine_init(struct statics *statics, char do_unames); +int proc_owner(int pid); /* non-int routines typically used by the machine dependent module */ char *printable(); Modified: stable/11/contrib/top/top.c ============================================================================== --- stable/11/contrib/top/top.c Fri Oct 21 23:50:02 2016 (r307756) +++ stable/11/contrib/top/top.c Sat Oct 22 00:35:40 2016 (r307757) @@ -188,9 +188,9 @@ char *argv[]; fd_set readfds; #ifdef ORDER - static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJo"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJwo"; #else - static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJ"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJw"; #endif /* these defines enumerate the "strchr"s of the commands in command_chars */ #define CMD_redraw 0 @@ -219,8 +219,9 @@ char *argv[]; #define CMD_kidletog 22 #define CMD_pcputog 23 #define CMD_jail 24 +#define CMD_swaptog 25 #ifdef ORDER -#define CMD_order 25 +#define CMD_order 26 #endif /* set the buffer for stdout */ @@ -254,6 +255,7 @@ char *argv[]; ps.wcpu = 1; ps.jid = -1; ps.jail = No; + ps.swap = No; ps.kidle = Yes; ps.command = NULL; @@ -280,7 +282,7 @@ char *argv[]; optind = 1; } - while ((i = getopt(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:t")) != EOF) + while ((i = getopt(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:tw")) != EOF) { switch(i) { @@ -418,6 +420,10 @@ char *argv[]; pcpu_stats = !pcpu_stats; break; + case 'w': + ps.swap = 1; + break; + case 'z': ps.kidle = !ps.kidle; break; @@ -1141,6 +1147,15 @@ restart: reset_display(); putchar('\r'); break; + case CMD_swaptog: + ps.swap = !ps.swap; + new_message(MT_standout | MT_delayed, + " %sisplaying per-process swap usage.", + ps.swap ? "D" : "Not d"); + header_text = format_header(uname_field); + reset_display(); + putchar('\r'); + break; default: new_message(MT_standout, " BAD CASE IN SWITCH!"); putchar('\r'); Modified: stable/11/contrib/top/top.xs ============================================================================== --- stable/11/contrib/top/top.xs Fri Oct 21 23:50:02 2016 (r307756) +++ stable/11/contrib/top/top.xs Sat Oct 22 00:35:40 2016 (r307757) @@ -10,7 +10,7 @@ top \- display and update information ab .SH SYNOPSIS .B top [ -.B \-abCHIijnPqStuvz +.B \-abCHIijnPqStuvwz ] [ .BI \-d count ] [ @@ -148,6 +148,9 @@ Write version number information to stde No other processing takes place when this option is used. To see current revision information while top is running, use the help command \*(lq?\*(rq. .TP +.B \-w +Display approximate swap usage for each process. +.TP .B \-z Do not display the system idle process. .TP @@ -167,11 +170,12 @@ Set the delay between screen updates to seconds. The default delay between updates is \nD seconds. .TP .BI \-o field -Sort the process display area on the specified field. The field name is -the name of the column as seen in the output, but in lower case. Likely -values are \*(lqcpu\*(rq, \*(lqsize\*(rq, \*(lqres\*(rq, and \*(lqtime\*(rq, -but may vary on different operating systems. Note that -not all operating systems support this option. +Sort the process display area on the specified field. The field name +is the name of the column as seen in the output, but in lower case: +\*(lqcpu\*(lq, \*(rqsize\*(lq, \*(rqres\*(lq, \*(rqtime\*(lq, +\*(rqpri\*(lq, \*(rqthreads\*(lq, \*(lqtotal\*(lq, \*(rqread\*(lq, +\*(rqwrite\*(lq, \*(rqfault\*(lq, \*(rqvcsw\*(lq, \*(rqivcsw\*(lq, +\*(lqjid\*(lq, \*(rqswap\*(lq or \*(rqpid\*(lq. .TP .BI \-J jail Show only those processes owned by @@ -226,6 +230,7 @@ The options .BR \-S , .BR \-t , .BR \-u , +.BR \-w , and .B \-z are actually toggles. A second specification of any of these options @@ -346,6 +351,9 @@ Toggle the display of the .I top process. .TP +.B w +Toggle the display of swap usage. +.TP .B z Toggle the display of the system idle process. .SH "THE DISPLAY" @@ -379,8 +387,9 @@ is specified, a UID column will be subst PRI is the current priority of the process, NICE is the nice amount (in the range \-20 to 20), SIZE is the total size of the process (text, data, and stack), -RES is the current amount of resident memory (both SIZE and RES are -given in kilobytes), +RES is the current amount of resident memory, +SWAP is the approximate amount of swap, if enabled +(SIZE, RES and SWAP are given in kilobytes), STATE is the current state (one of \*(lqSTART\*(rq, \*(lqRUN\*(rq (shown as \*(lqCPUn\*(rq on SMP systems), \*(lqSLEEP\*(rq, \*(lqSTOP\*(rq, \*(lqZOMB\*(rq, \*(lqWAIT\*(rq, \*(lqLOCK\*(rq or the event on which the Modified: stable/11/usr.bin/top/machine.c ============================================================================== --- stable/11/usr.bin/top/machine.c Fri Oct 21 23:50:02 2016 (r307756) +++ stable/11/usr.bin/top/machine.c Sat Oct 22 00:35:40 2016 (r307757) @@ -69,7 +69,9 @@ static int namelength = 8; #endif /* TOP_JID_LEN based on max of 999999 */ #define TOP_JID_LEN 7 +#define TOP_SWAP_LEN 6 static int jidlength; +static int swaplength; static int cmdlengthdelta; /* Prototypes for top internals */ @@ -111,20 +113,20 @@ static char io_header[] = "%5d%*s %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %6.2f%% %.*s" static char smp_header_thr[] = - " PID%*s %-*.*s THR PRI NICE SIZE RES STATE C TIME %7s COMMAND"; + " PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND"; static char smp_header[] = - " PID%*s %-*.*s " "PRI NICE SIZE RES STATE C TIME %7s COMMAND"; + " PID%*s %-*.*s " "PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND"; #define smp_Proc_format \ - "%5d%*s %-*.*s %s%3d %4s%7s %6s %-6.6s %2d%7s %6.2f%% %.*s" + "%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s %2d%7s %6.2f%% %.*s" static char up_header_thr[] = - " PID%*s %-*.*s THR PRI NICE SIZE RES STATE TIME %7s COMMAND"; + " PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE TIME %7s COMMAND"; static char up_header[] = - " PID%*s %-*.*s " "PRI NICE SIZE RES STATE TIME %7s COMMAND"; + " PID%*s %-*.*s " "PRI NICE SIZE RES%*s STATE TIME %7s COMMAND"; #define up_Proc_format \ - "%5d%*s %-*.*s %s%3d %4s%7s %6s %-6.6s%.0d%7s %6.2f%% %.*s" + "%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s%.0d%7s %6.2f%% %.*s" /* process state names for the "STATE" column of the display */ @@ -227,6 +229,10 @@ static int pageshift; /* log base 2 of #define pagetok(size) ((size) << pageshift) +/* swap usage */ +#define ki_swap(kip) \ + ((kip)->ki_swrss > (kip)->ki_rssize ? (kip)->ki_swrss - (kip)->ki_rssize : 0) + /* useful externals */ long percentages(); @@ -237,7 +243,7 @@ long percentages(); char *ordernames[] = { "cpu", "size", "res", "time", "pri", "threads", "total", "read", "write", "fault", "vcsw", "ivcsw", - "jid", "pid", NULL + "jid", "swap", "pid", NULL }; #endif @@ -252,6 +258,7 @@ static long *pcpu_cp_old; static long *pcpu_cp_diff; static int *pcpu_cpu_states; +static int compare_swap(const void *a, const void *b); static int compare_jid(const void *a, const void *b); static int compare_pid(const void *a, const void *b); static int compare_tid(const void *a, const void *b); @@ -412,6 +419,11 @@ format_header(char *uname_field) else jidlength = 0; + if (ps.swap) + swaplength = TOP_SWAP_LEN + 1; /* +1 for extra left space */ + else + swaplength = 0; + switch (displaymode) { case DISP_CPU: /* @@ -426,6 +438,7 @@ format_header(char *uname_field) snprintf(Header, sizeof(Header), prehead, jidlength, ps.jail ? " JID" : "", namelength, namelength, uname_field, + swaplength, ps.swap ? " SWAP" : "", ps.wcpu ? "WCPU" : "CPU"); break; case DISP_IO: @@ -902,7 +915,8 @@ format_next_process(caddr_t handle, char int cpu, state; struct rusage ru, *rup; long p_tot, s_tot; - char *proc_fmt, thr_buf[6], jid_buf[TOP_JID_LEN + 1]; + char *proc_fmt, thr_buf[6]; + char jid_buf[TOP_JID_LEN + 1], swap_buf[TOP_SWAP_LEN + 1]; char *cmdbuf = NULL; char **args; const int cmdlen = 128; @@ -1061,6 +1075,13 @@ format_next_process(caddr_t handle, char snprintf(jid_buf, sizeof(jid_buf), "%*d", jidlength - 1, pp->ki_jid); + if (ps.swap == 0) + swap_buf[0] = '\0'; + else + snprintf(swap_buf, sizeof(swap_buf), "%*s", + swaplength - 1, + format_k2(pagetok(ki_swap(pp)))); /* XXX */ + if (displaymode == DISP_IO) { oldp = get_old_proc(pp); if (oldp != NULL) { @@ -1122,6 +1143,7 @@ format_next_process(caddr_t handle, char format_nice(pp), format_k2(PROCSIZE(pp)), format_k2(pagetok(pp->ki_rssize)), + swaplength, swaplength, swap_buf, status, cpu, format_time(cputime), @@ -1309,6 +1331,12 @@ static int sorted_state[] = { return (diff > 0 ? 1 : -1); \ } while (0) +#define ORDERKEY_SWAP(a, b) do { \ + int diff = (int)ki_swap(b) - (int)ki_swap(a); \ + if (diff != 0) \ + return (diff > 0 ? 1 : -1); \ +} while (0) + /* compare_cpu - the comparison function for sorting by cpu percentage */ int @@ -1357,6 +1385,7 @@ int (*compares[])() = { compare_vcsw, compare_ivcsw, compare_jid, + compare_swap, NULL }; @@ -1467,6 +1496,24 @@ compare_jid(const void *arg1, const void return (0); } + +/* compare_swap - the comparison function for sorting by swap */ +static int +compare_swap(const void *arg1, const void *arg2) +{ + struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1; + struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2; + + ORDERKEY_SWAP(p1, p2); + ORDERKEY_PCTCPU(p1, p2); + ORDERKEY_CPTICKS(p1, p2); + ORDERKEY_STATE(p1, p2); + ORDERKEY_PRIO(p1, p2); + ORDERKEY_RSSIZE(p1, p2); + ORDERKEY_MEM(p1, p2); + + return (0); +} #endif /* ORDER */ /* assorted comparison functions for sorting by i/o */ From owner-svn-src-stable@freebsd.org Sat Oct 22 00:38:49 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01C8EC1C9F4; Sat, 22 Oct 2016 00:38:48 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE5BAD83; Sat, 22 Oct 2016 00:38:48 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M0cleT050352; Sat, 22 Oct 2016 00:38:47 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M0clLe050350; Sat, 22 Oct 2016 00:38:47 GMT (envelope-from des@FreeBSD.org) Message-Id: <201610220038.u9M0clLe050350@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Sat, 22 Oct 2016 00:38:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307758 - stable/11/lib/libc/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 00:38:49 -0000 Author: des Date: Sat Oct 22 00:38:47 2016 New Revision: 307758 URL: https://svnweb.freebsd.org/changeset/base/307758 Log: MFH (r306488, r306494, r306495, r306496): fix markup and cross-references Modified: stable/11/lib/libc/sys/getrlimit.2 stable/11/lib/libc/sys/sigaction.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/getrlimit.2 ============================================================================== --- stable/11/lib/libc/sys/getrlimit.2 Sat Oct 22 00:35:40 2016 (r307757) +++ stable/11/lib/libc/sys/getrlimit.2 Sat Oct 22 00:38:47 2016 (r307758) @@ -28,7 +28,7 @@ .\" @(#)getrlimit.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd August 19, 2015 +.Dd September 30, 2016 .Dt GETRLIMIT 2 .Os .Sh NAME @@ -137,7 +137,7 @@ For example, if the RSS hard limit is ex .Pp The .Vt rlimit -structure is used to specify the hard and soft limits on a resource, +structure is used to specify the hard and soft limits on a resource. .Bd -literal -offset indent struct rlimit { rlim_t rlim_cur; /* current (soft) limit */ @@ -183,9 +183,9 @@ soft limit will cause the write to fail to be generated; this normally terminates the process, but may be caught. When -the soft cpu time limit is exceeded, a signal +the soft cpu time limit is exceeded, a .Dv SIGXCPU -is sent to the +signal is sent to the offending process. .Pp When most operations would allocate more virtual memory than allowed by the @@ -198,7 +198,9 @@ A notable exception is stack extension, If stack extension would allocate more virtual memory than allowed by the soft limit of .Dv RLIMIT_AS , -the signal SIGSEGV will be delivered. +a +.Dv SIGSEGV +signal will be delivered. The caller is free to raise the soft address space limit up to the hard limit and retry the allocation. .Sh RETURN VALUES Modified: stable/11/lib/libc/sys/sigaction.2 ============================================================================== --- stable/11/lib/libc/sys/sigaction.2 Sat Oct 22 00:35:40 2016 (r307757) +++ stable/11/lib/libc/sys/sigaction.2 Sat Oct 22 00:38:47 2016 (r307758) @@ -28,7 +28,7 @@ .\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94 .\" $FreeBSD$ .\" -.Dd September 6, 2013 +.Dd September 30, 2016 .Dt SIGACTION 2 .Os .Sh NAME @@ -307,46 +307,38 @@ The following is a list of all signals with names as in the include file .In signal.h : .Bl -column SIGVTALARMXX "create core imagexxx" -.It Sy "NAME Default Action Description" -.It Dv SIGHUP No " terminate process" " terminal line hangup" -.It Dv SIGINT No " terminate process" " interrupt program" -.It Dv SIGQUIT No " create core image" " quit program" -.It Dv SIGILL No " create core image" " illegal instruction" -.It Dv SIGTRAP No " create core image" " trace trap" -.It Dv SIGABRT No " create core image" Ta Xr abort 3 -call (formerly -.Dv SIGIOT ) -.It Dv SIGEMT No " create core image" " emulate instruction executed" -.It Dv SIGFPE No " create core image" " floating-point exception" -.It Dv SIGKILL No " terminate process" " kill program" -.It Dv SIGBUS No " create core image" " bus error" -.It Dv SIGSEGV No " create core image" " segmentation violation" -.It Dv SIGSYS No " create core image" " non-existent system call invoked" -.It Dv SIGPIPE No " terminate process" " write on a pipe with no reader" -.It Dv SIGALRM No " terminate process" " real-time timer expired" -.It Dv SIGTERM No " terminate process" " software termination signal" -.It Dv SIGURG No " discard signal" " urgent condition present on socket" -.It Dv SIGSTOP No " stop process" " stop (cannot be caught or ignored)" -.It Dv SIGTSTP No " stop process" " stop signal generated from keyboard" -.It Dv SIGCONT No " discard signal" " continue after stop" -.It Dv SIGCHLD No " discard signal" " child status has changed" -.It Dv SIGTTIN No " stop process" " background read attempted from control terminal" -.It Dv SIGTTOU No " stop process" " background write attempted to control terminal" -.It Dv SIGIO No " discard signal" Tn " I/O" -is possible on a descriptor (see -.Xr fcntl 2 ) -.It Dv SIGXCPU No " terminate process" " cpu time limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGXFSZ No " terminate process" " file size limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGVTALRM No " terminate process" " virtual time alarm (see" -.Xr setitimer 2 ) -.It Dv SIGPROF No " terminate process" " profiling timer alarm (see" -.Xr setitimer 2 ) -.It Dv SIGWINCH No " discard signal" " Window size change" -.It Dv SIGINFO No " discard signal" " status request from keyboard" -.It Dv SIGUSR1 No " terminate process" " User defined signal 1" -.It Dv SIGUSR2 No " terminate process" " User defined signal 2" +.It Sy NAME Ta Sy Default Action Ta Sy Description +.It Dv SIGHUP Ta terminate process Ta terminal line hangup +.It Dv SIGINT Ta terminate process Ta interrupt program +.It Dv SIGQUIT Ta create core image Ta quit program +.It Dv SIGILL Ta create core image Ta illegal instruction +.It Dv SIGTRAP Ta create core image Ta trace trap +.It Dv SIGABRT Ta create core image Ta Xr abort 3 call (formerly Dv SIGIOT ) +.It Dv SIGEMT Ta create core image Ta emulate instruction executed +.It Dv SIGFPE Ta create core image Ta floating-point exception +.It Dv SIGKILL Ta terminate process Ta kill program +.It Dv SIGBUS Ta create core image Ta bus error +.It Dv SIGSEGV Ta create core image Ta segmentation violation +.It Dv SIGSYS Ta create core image Ta non-existent system call invoked +.It Dv SIGPIPE Ta terminate process Ta write on a pipe with no reader +.It Dv SIGALRM Ta terminate process Ta real-time timer expired +.It Dv SIGTERM Ta terminate process Ta software termination signal +.It Dv SIGURG Ta discard signal Ta urgent condition present on socket +.It Dv SIGSTOP Ta stop process Ta stop (cannot be caught or ignored) +.It Dv SIGTSTP Ta stop process Ta stop signal generated from keyboard +.It Dv SIGCONT Ta discard signal Ta continue after stop +.It Dv SIGCHLD Ta discard signal Ta child status has changed +.It Dv SIGTTIN Ta stop process Ta background read attempted from control terminal +.It Dv SIGTTOU Ta stop process Ta background write attempted to control terminal +.It Dv SIGIO Ta discard signal Ta I/O is possible on a descriptor (see Xr fcntl 2 ) +.It Dv SIGXCPU Ta terminate process Ta cpu time limit exceeded (see Xr setrlimit 2 ) +.It Dv SIGXFSZ Ta terminate process Ta file size limit exceeded (see Xr setrlimit 2 ) +.It Dv SIGVTALRM Ta terminate process Ta virtual time alarm (see Xr setitimer 2 ) +.It Dv SIGPROF Ta terminate process Ta profiling timer alarm (see Xr setitimer 2 ) +.It Dv SIGWINCH Ta discard signal Ta window size change +.It Dv SIGINFO Ta discard signal Ta status request from keyboard +.It Dv SIGUSR1 Ta terminate process Ta user defined signal 1 +.It Dv SIGUSR2 Ta terminate process Ta user defined signal 2 .El .Sh NOTE The @@ -739,6 +731,8 @@ or .Xr kill 1 , .Xr kill 2 , .Xr ptrace 2 , +.Xr setitimer 2 , +.Xr setrlimit 2 , .Xr sigaltstack 2 , .Xr sigpending 2 , .Xr sigprocmask 2 , From owner-svn-src-stable@freebsd.org Sat Oct 22 01:38:23 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62CA6C1B54E; Sat, 22 Oct 2016 01:38:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 25AA4846; Sat, 22 Oct 2016 01:38:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M1cMD6072854; Sat, 22 Oct 2016 01:38:22 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M1cLJ1072846; Sat, 22 Oct 2016 01:38:21 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610220138.u9M1cLJ1072846@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 01:38:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307760 - in stable/11: etc/mtree include sys/conf sys/dev/evdev X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 01:38:23 -0000 Author: gonzo Date: Sat Oct 22 01:38:21 2016 New Revision: 307760 URL: https://svnweb.freebsd.org/changeset/base/307760 Log: MFC r305706, r305749, r306274 r305706: Add evdev protocol implementation evdev is a generic input event interface compatible with Linux evdev API at ioctl level. It allows using unmodified (apart from header name) input evdev drivers in Xorg, Wayland, Qt. This commit has only generic kernel API. evdev support for individual hardware drivers like ukbd, ums, atkbd, etc. will be committed later. Project was started by Jakub Klama as part of GSoC 2014. Jakub's evdev implementation was later used as a base, updated and finished by Vladimir Kondratiev. Submitted by: Vladimir Kondratiev Reviewed by: adrian, hans Differential Revision: https://reviews.freebsd.org/D6998 r305749: Remove semicolon from the end of the macro definition Reported by: hans r306274: Handle NULL argument in evdev_free Add check for evdev argument of evdev_free being NULL. This is valid value and should not cause crash. In this case evdev_free does nothing Submitted by: Vladimir Kondratiev Added: stable/11/sys/dev/evdev/ - copied from r305706, head/sys/dev/evdev/ Modified: stable/11/etc/mtree/BSD.include.dist stable/11/include/Makefile stable/11/sys/conf/NOTES stable/11/sys/conf/files stable/11/sys/conf/options stable/11/sys/dev/evdev/cdev.c stable/11/sys/dev/evdev/evdev.c stable/11/sys/dev/evdev/uinput.c Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/mtree/BSD.include.dist ============================================================================== --- stable/11/etc/mtree/BSD.include.dist Sat Oct 22 00:48:58 2016 (r307759) +++ stable/11/etc/mtree/BSD.include.dist Sat Oct 22 01:38:21 2016 (r307760) @@ -110,6 +110,8 @@ .. ciss .. + evdev + .. filemon .. firewire Modified: stable/11/include/Makefile ============================================================================== --- stable/11/include/Makefile Sat Oct 22 00:48:58 2016 (r307759) +++ stable/11/include/Makefile Sat Oct 22 01:38:21 2016 (r307760) @@ -154,7 +154,7 @@ copies: .PHONY .META done; \ fi .endfor -.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS} +.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/evdev:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS} cd ${.CURDIR}/../sys; \ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \ ${DESTDIR}${INCLUDEDIR}/$i @@ -177,6 +177,13 @@ copies: .PHONY .META ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \ ${DESTDIR}${INCLUDEDIR}/dev/nand .endif + cd ${.CURDIR}/../sys/dev/evdev; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 input.h \ + ${DESTDIR}${INCLUDEDIR}/dev/evdev; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 input-event-codes.h \ + ${DESTDIR}${INCLUDEDIR}/dev/evdev; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 uinput.h \ + ${DESTDIR}${INCLUDEDIR}/dev/evdev cd ${.CURDIR}/../sys/dev/pci; \ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \ ${DESTDIR}${INCLUDEDIR}/dev/pci @@ -238,7 +245,7 @@ symlinks: .PHONY .META ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ done .endfor -.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} +.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/evdev:Ndev/nand:Ndev/pci} cd ${.CURDIR}/../sys/$i; \ for h in *.h; do \ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ @@ -266,6 +273,11 @@ symlinks: .PHONY .META ${DESTDIR}${INCLUDEDIR}/dev/nand; \ done .endif + cd ${.CURDIR}/../sys/dev/evdev; \ + for h in input.h input-event-codes.h uinput.h; do \ + ln -fs ../../../../sys/dev/evdev/$$h \ + ${DESTDIR}${INCLUDEDIR}/dev/evdev; \ + done cd ${.CURDIR}/../sys/dev/pci; \ for h in pcireg.h; do \ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/pci/$$h \ Modified: stable/11/sys/conf/NOTES ============================================================================== --- stable/11/sys/conf/NOTES Sat Oct 22 00:48:58 2016 (r307759) +++ stable/11/sys/conf/NOTES Sat Oct 22 01:38:21 2016 (r307760) @@ -3062,3 +3062,8 @@ options GZIO # BHND(4) drivers options BHND_LOGLEVEL # Logging threshold level + +# evdev interface +options EVDEV +options EVDEV_DEBUG +options UINPUT_DEBUG Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Sat Oct 22 00:48:58 2016 (r307759) +++ stable/11/sys/conf/files Sat Oct 22 01:38:21 2016 (r307760) @@ -1497,6 +1497,11 @@ dev/etherswitch/ip17x/ip17x_vlans.c opti dev/etherswitch/miiproxy.c optional miiproxy dev/etherswitch/rtl8366/rtl8366rb.c optional rtl8366rb dev/etherswitch/ukswitch/ukswitch.c optional ukswitch +dev/evdev/cdev.c optional evdev +dev/evdev/evdev.c optional evdev +dev/evdev/evdev_mt.c optional evdev +dev/evdev/evdev_utils.c optional evdev +dev/evdev/uinput.c optional evdev uinput dev/ex/if_ex.c optional ex dev/ex/if_ex_isa.c optional ex isa dev/ex/if_ex_pccard.c optional ex pccard Modified: stable/11/sys/conf/options ============================================================================== --- stable/11/sys/conf/options Sat Oct 22 00:48:58 2016 (r307759) +++ stable/11/sys/conf/options Sat Oct 22 01:38:21 2016 (r307760) @@ -986,3 +986,8 @@ BHND_LOGLEVEL opt_global.h # GPIO and child devices GPIO_SPI_DEBUG opt_gpio.h + +# evdev protocol support +EVDEV opt_evdev.h +EVDEV_DEBUG opt_evdev.h +UINPUT_DEBUG opt_evdev.h Modified: stable/11/sys/dev/evdev/cdev.c ============================================================================== --- head/sys/dev/evdev/cdev.c Sun Sep 11 18:56:38 2016 (r305706) +++ stable/11/sys/dev/evdev/cdev.c Sat Oct 22 01:38:21 2016 (r307760) @@ -49,7 +49,7 @@ #include #ifdef EVDEV_DEBUG -#define debugf(client, fmt, args...) printf("evdev cdev: "fmt"\n", ##args); +#define debugf(client, fmt, args...) printf("evdev cdev: "fmt"\n", ##args) #else #define debugf(client, fmt, args...) #endif Modified: stable/11/sys/dev/evdev/evdev.c ============================================================================== --- head/sys/dev/evdev/evdev.c Sun Sep 11 18:56:38 2016 (r305706) +++ stable/11/sys/dev/evdev/evdev.c Sat Oct 22 01:38:21 2016 (r307760) @@ -92,7 +92,8 @@ void evdev_free(struct evdev_dev *evdev) { - if (evdev->ev_cdev != NULL && evdev->ev_cdev->si_drv1 != NULL) + if (evdev != NULL && evdev->ev_cdev != NULL && + evdev->ev_cdev->si_drv1 != NULL) evdev_unregister(evdev); free(evdev, M_EVDEV); Modified: stable/11/sys/dev/evdev/uinput.c ============================================================================== --- head/sys/dev/evdev/uinput.c Sun Sep 11 18:56:38 2016 (r305706) +++ stable/11/sys/dev/evdev/uinput.c Sat Oct 22 01:38:21 2016 (r307760) @@ -50,7 +50,7 @@ #include #ifdef UINPUT_DEBUG -#define debugf(state, fmt, args...) printf("uinput: " fmt "\n", ##args); +#define debugf(state, fmt, args...) printf("uinput: " fmt "\n", ##args) #else #define debugf(state, fmt, args...) #endif From owner-svn-src-stable@freebsd.org Sat Oct 22 01:58:23 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2ABC8C1BCA8; Sat, 22 Oct 2016 01:58:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E02492DE; Sat, 22 Oct 2016 01:58:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M1wMvM080442; Sat, 22 Oct 2016 01:58:22 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M1wLUI080438; Sat, 22 Oct 2016 01:58:21 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610220158.u9M1wLUI080438@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 01:58:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307762 - in stable/11/sys/arm: conf ti X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 01:58:23 -0000 Author: gonzo Date: Sat Oct 22 01:58:21 2016 New Revision: 307762 URL: https://svnweb.freebsd.org/changeset/base/307762 Log: MFC r305708, r305719 r305708: Add evdev support to TI ADC/touchscreen driver Add generic evdev support to touchscreen part of ti_adc: two absolute coordinates + button touch to indicate pen position. Pressure value reporting is not implemented yet. Tested on: Beaglebone Black + 4DCAPE-43T + tslib r305719: Cleanup evdev support for TI ADC/TS - evdev_set_methods call is not required if actual methods are no-ops - evdev_set_serial is also optional if there is no meaningful input device identifier - evdev_set_id on the other hand is mandatory, so set virtual bus with dummy vendor/product/version Suggested by: Vladimir Kondratiev Modified: stable/11/sys/arm/conf/BEAGLEBONE stable/11/sys/arm/ti/ti_adc.c stable/11/sys/arm/ti/ti_adcreg.h stable/11/sys/arm/ti/ti_adcvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/conf/BEAGLEBONE ============================================================================== --- stable/11/sys/arm/conf/BEAGLEBONE Sat Oct 22 01:57:15 2016 (r307761) +++ stable/11/sys/arm/conf/BEAGLEBONE Sat Oct 22 01:58:21 2016 (r307762) @@ -133,3 +133,6 @@ device hdmi device ums device ukbd device kbdmux + +# Uncomment to enable evdev support for ti_adc +# options EVDEV Modified: stable/11/sys/arm/ti/ti_adc.c ============================================================================== --- stable/11/sys/arm/ti/ti_adc.c Sat Oct 22 01:57:15 2016 (r307761) +++ stable/11/sys/arm/ti/ti_adc.c Sat Oct 22 01:58:21 2016 (r307762) @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_evdev.h" + #include #include #include @@ -52,6 +54,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef EVDEV +#include +#include +#endif + #include #include #include @@ -80,6 +87,20 @@ static struct ti_adc_input ti_adc_inputs static int ti_adc_samples[5] = { 0, 2, 4, 8, 16 }; +static int ti_adc_detach(device_t dev); + +#ifdef EVDEV +static void +ti_adc_ev_report(struct ti_adc_softc *sc) +{ + + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_X, sc->sc_x); + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_Y, sc->sc_y); + evdev_push_event(sc->sc_evdev, EV_KEY, BTN_TOUCH, sc->sc_pen_down); + evdev_sync(sc->sc_evdev); +} +#endif /* EVDEV */ + static void ti_adc_enable(struct ti_adc_softc *sc) { @@ -450,7 +471,14 @@ ti_adc_tsc_read_data(struct ti_adc_softc #ifdef DEBUG_TSC device_printf(sc->sc_dev, "touchscreen x: %d, y: %d\n", x, y); #endif - /* TODO: That's where actual event reporting should take place */ + +#ifdef EVDEV + if ((sc->sc_x != x) || (sc->sc_y != y)) { + sc->sc_x = x; + sc->sc_y = y; + ti_adc_ev_report(sc); + } +#endif } static void @@ -488,11 +516,17 @@ ti_adc_intr(void *arg) status |= ADC_IRQ_HW_PEN_ASYNC; ADC_WRITE4(sc, ADC_IRQENABLE_CLR, ADC_IRQ_HW_PEN_ASYNC); +#ifdef EVDEV + ti_adc_ev_report(sc); +#endif } if (rawstatus & ADC_IRQ_PEN_UP) { sc->sc_pen_down = 0; status |= ADC_IRQ_PEN_UP; +#ifdef EVDEV + ti_adc_ev_report(sc); +#endif } if (status & ADC_IRQ_FIFO0_THRES) @@ -840,6 +874,38 @@ ti_adc_attach(device_t dev) ti_adc_setup(sc); TI_ADC_UNLOCK(sc); +#ifdef EVDEV + if (sc->sc_tsc_wires > 0) { + sc->sc_evdev = evdev_alloc(); + evdev_set_name(sc->sc_evdev, device_get_desc(dev)); + evdev_set_phys(sc->sc_evdev, device_get_nameunit(dev)); + evdev_set_id(sc->sc_evdev, BUS_VIRTUAL, 0, 0, 0); + evdev_support_prop(sc->sc_evdev, INPUT_PROP_DIRECT); + evdev_support_event(sc->sc_evdev, EV_SYN); + evdev_support_event(sc->sc_evdev, EV_ABS); + evdev_support_event(sc->sc_evdev, EV_KEY); + + evdev_support_abs(sc->sc_evdev, ABS_X, 0, 0, + ADC_MAX_VALUE, 0, 0, 0); + evdev_support_abs(sc->sc_evdev, ABS_Y, 0, 0, + ADC_MAX_VALUE, 0, 0, 0); + + evdev_support_key(sc->sc_evdev, BTN_TOUCH); + + err = evdev_register(sc->sc_evdev); + if (err) { + device_printf(dev, + "failed to register evdev: error=%d\n", err); + ti_adc_detach(dev); + return (err); + } + + sc->sc_pen_down = 0; + sc->sc_x = -1; + sc->sc_y = -1; + } +#endif /* EVDEV */ + return (0); } @@ -854,6 +920,11 @@ ti_adc_detach(device_t dev) TI_ADC_LOCK(sc); ti_adc_reset(sc); ti_adc_setup(sc); + +#ifdef EVDEV + evdev_free(sc->sc_evdev); +#endif + TI_ADC_UNLOCK(sc); TI_ADC_LOCK_DESTROY(sc); Modified: stable/11/sys/arm/ti/ti_adcreg.h ============================================================================== --- stable/11/sys/arm/ti/ti_adcreg.h Sat Oct 22 01:57:15 2016 (r307761) +++ stable/11/sys/arm/ti/ti_adcreg.h Sat Oct 22 01:58:21 2016 (r307762) @@ -122,5 +122,6 @@ #define ADC_FIFO_STEP_ID_MSK 0x000f0000 #define ADC_FIFO_STEP_ID_SHIFT 16 #define ADC_FIFO_DATA_MSK 0x00000fff +#define ADC_MAX_VALUE 0xfff #endif /* _TI_ADCREG_H_ */ Modified: stable/11/sys/arm/ti/ti_adcvar.h ============================================================================== --- stable/11/sys/arm/ti/ti_adcvar.h Sat Oct 22 01:57:15 2016 (r307761) +++ stable/11/sys/arm/ti/ti_adcvar.h Sat Oct 22 01:58:21 2016 (r307762) @@ -55,6 +55,11 @@ struct ti_adc_softc { int sc_yn_bit, sc_yn_inp; uint32_t sc_tsc_enabled; int sc_pen_down; +#ifdef EVDEV + int sc_x; + int sc_y; + struct evdev_dev *sc_evdev; +#endif }; struct ti_adc_input { From owner-svn-src-stable@freebsd.org Sat Oct 22 02:15:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67060C1B03C; Sat, 22 Oct 2016 02:15:41 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E0C7D1C; Sat, 22 Oct 2016 02:15:41 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M2FecS087727; Sat, 22 Oct 2016 02:15:40 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M2FeOo087725; Sat, 22 Oct 2016 02:15:40 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610220215.u9M2FeOo087725@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 02:15:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307764 - in stable/11/sys: dev/usb/input modules/usb/ukbd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 02:15:41 -0000 Author: gonzo Date: Sat Oct 22 02:15:39 2016 New Revision: 307764 URL: https://svnweb.freebsd.org/changeset/base/307764 Log: MFC r306132, r306275: r306132: Add evdev support to ukbd driver event generation is disabled by default in favour of kbdmux. This behavoiur is controlled by kern.evdev.rcpt_mask sysctl, bit 3 should be set to give priority to hw over mux Submitted by: Vladimir Kondratiev Reviewed by: hans Differential Revision: https://reviews.freebsd.org/D7957 r306275: Do not perform extra check for NULL, evdev_free can handle NULL value Submitted by: Vladimir Kondratiev Modified: stable/11/sys/dev/usb/input/ukbd.c stable/11/sys/modules/usb/ukbd/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/11/sys/dev/usb/input/ukbd.c Sat Oct 22 02:11:53 2016 (r307763) +++ stable/11/sys/dev/usb/input/ukbd.c Sat Oct 22 02:15:39 2016 (r307764) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" #include "opt_kbd.h" #include "opt_ukbd.h" +#include "opt_evdev.h" #include #include @@ -73,6 +74,11 @@ __FBSDID("$FreeBSD$"); #include +#ifdef EVDEV +#include +#include +#endif + #include #include #include @@ -162,6 +168,9 @@ struct ukbd_softc { struct usb_device *sc_udev; struct usb_interface *sc_iface; struct usb_xfer *sc_xfer[UKBD_N_TRANSFER]; +#ifdef EVDEV + struct evdev_dev *sc_evdev; +#endif uint32_t sc_ntime[UKBD_NKEYCODE]; uint32_t sc_otime[UKBD_NKEYCODE]; @@ -377,6 +386,12 @@ static device_attach_t ukbd_attach; static device_detach_t ukbd_detach; static device_resume_t ukbd_resume; +#ifdef EVDEV +static struct evdev_methods ukbd_evdev_methods = { + .ev_event = evdev_ev_kbd_event, +}; +#endif + static uint8_t ukbd_any_key_pressed(struct ukbd_softc *sc) { @@ -405,6 +420,14 @@ ukbd_put_key(struct ukbd_softc *sc, uint DPRINTF("0x%02x (%d) %s\n", key, key, (key & KEY_RELEASE) ? "released" : "pressed"); +#ifdef EVDEV + if (evdev_rcpt_mask & EVDEV_RCPT_HW_KBD && sc->sc_evdev != NULL) { + evdev_push_event(sc->sc_evdev, EV_KEY, + evdev_hid2key(KEY_INDEX(key)), !(key & KEY_RELEASE)); + evdev_sync(sc->sc_evdev); + } +#endif + if (sc->sc_inputs < UKBD_IN_BUF_SIZE) { sc->sc_input[sc->sc_inputtail] = key; ++(sc->sc_inputs); @@ -918,6 +941,11 @@ ukbd_set_leds_callback(struct usb_xfer * if (!any) break; +#ifdef EVDEV + if (sc->sc_evdev != NULL) + evdev_push_leds(sc->sc_evdev, sc->sc_leds); +#endif + /* range check output report length */ len = sc->sc_led_size; if (len > (UKBD_BUFFER_SIZE - 1)) @@ -1193,6 +1221,10 @@ ukbd_attach(device_t dev) usb_error_t err; uint16_t n; uint16_t hid_len; +#ifdef EVDEV + struct evdev_dev *evdev; + int i; +#endif #ifdef USB_DEBUG int rate; #endif @@ -1307,6 +1339,37 @@ ukbd_attach(device_t dev) goto detach; } #endif + +#ifdef EVDEV + evdev = evdev_alloc(); + evdev_set_name(evdev, device_get_desc(dev)); + evdev_set_phys(evdev, device_get_nameunit(dev)); + evdev_set_id(evdev, BUS_USB, uaa->info.idVendor, + uaa->info.idProduct, 0); + evdev_set_serial(evdev, usb_get_serial(uaa->device)); + evdev_set_methods(evdev, kbd, &ukbd_evdev_methods); + evdev_support_event(evdev, EV_SYN); + evdev_support_event(evdev, EV_KEY); + if (sc->sc_flags & (UKBD_FLAG_NUMLOCK | UKBD_FLAG_CAPSLOCK | + UKBD_FLAG_SCROLLLOCK)) + evdev_support_event(evdev, EV_LED); + evdev_support_event(evdev, EV_REP); + + for (i = 0x00; i <= 0xFF; i++) + evdev_support_key(evdev, evdev_hid2key(i)); + if (sc->sc_flags & UKBD_FLAG_NUMLOCK) + evdev_support_led(evdev, LED_NUML); + if (sc->sc_flags & UKBD_FLAG_CAPSLOCK) + evdev_support_led(evdev, LED_CAPSL); + if (sc->sc_flags & UKBD_FLAG_SCROLLLOCK) + evdev_support_led(evdev, LED_SCROLLL); + + if (evdev_register(evdev)) + evdev_free(evdev); + else + sc->sc_evdev = evdev; +#endif + sc->sc_flags |= UKBD_FLAG_ATTACHED; if (bootverbose) { @@ -1377,6 +1440,11 @@ ukbd_detach(device_t dev) } } #endif + +#ifdef EVDEV + evdev_free(sc->sc_evdev); +#endif + if (KBD_IS_CONFIGURED(&sc->sc_kbd)) { error = kbd_unregister(&sc->sc_kbd); if (error) { @@ -1908,6 +1976,10 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_lon else kbd->kb_delay1 = ((int *)arg)[0]; kbd->kb_delay2 = ((int *)arg)[1]; +#ifdef EVDEV + if (sc->sc_evdev != NULL) + evdev_push_repeats(sc->sc_evdev, kbd); +#endif return (0); #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ @@ -2056,6 +2128,9 @@ ukbd_set_leds(struct ukbd_softc *sc, uin static int ukbd_set_typematic(keyboard_t *kbd, int code) { +#ifdef EVDEV + struct ukbd_softc *sc = kbd->kb_data; +#endif static const int delays[] = {250, 500, 750, 1000}; static const int rates[] = {34, 38, 42, 46, 50, 55, 59, 63, 68, 76, 84, 92, 100, 110, 118, 126, @@ -2067,6 +2142,10 @@ ukbd_set_typematic(keyboard_t *kbd, int } kbd->kb_delay1 = delays[(code >> 5) & 3]; kbd->kb_delay2 = rates[code & 0x1f]; +#ifdef EVDEV + if (sc->sc_evdev != NULL) + evdev_push_repeats(sc->sc_evdev, kbd); +#endif return (0); } Modified: stable/11/sys/modules/usb/ukbd/Makefile ============================================================================== --- stable/11/sys/modules/usb/ukbd/Makefile Sat Oct 22 02:11:53 2016 (r307763) +++ stable/11/sys/modules/usb/ukbd/Makefile Sat Oct 22 02:15:39 2016 (r307764) @@ -30,7 +30,7 @@ S= ${.CURDIR}/../../.. .PATH: $S/dev/usb/input KMOD= ukbd -SRCS= opt_bus.h opt_compat.h opt_kbd.h opt_ukbd.h opt_usb.h \ +SRCS= opt_bus.h opt_compat.h opt_evdev.h opt_kbd.h opt_ukbd.h opt_usb.h \ device_if.h bus_if.h usb_if.h usbdevs.h \ ukbd.c From owner-svn-src-stable@freebsd.org Sat Oct 22 02:26:34 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AADFFC1B463; Sat, 22 Oct 2016 02:26:34 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6DE3820F; Sat, 22 Oct 2016 02:26:34 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M2QXIq091875; Sat, 22 Oct 2016 02:26:33 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M2QXCX091872; Sat, 22 Oct 2016 02:26:33 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610220226.u9M2QXCX091872@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 02:26:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307765 - in stable/11/sys: dev/usb/input modules/usb/ums X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 02:26:34 -0000 Author: gonzo Date: Sat Oct 22 02:26:33 2016 New Revision: 307765 URL: https://svnweb.freebsd.org/changeset/base/307765 Log: MFC r306134: Add evdev support to ums(4) event generation is disabled by default in favour of sysmouse. This behavoiur is controlled by kern.evdev.rcpt_mask sysctl, bit 2 should be set to give priority to hw over sysmouse Submitted by: Vladimir Kondratiev Reviewed by: hans Differential Revision: https://reviews.freebsd.org/D7863 Modified: stable/11/sys/dev/usb/input/ums.c stable/11/sys/modules/usb/ums/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/input/ums.c ============================================================================== --- stable/11/sys/dev/usb/input/ums.c Sat Oct 22 02:15:39 2016 (r307764) +++ stable/11/sys/dev/usb/input/ums.c Sat Oct 22 02:26:33 2016 (r307765) @@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$"); * HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf */ +#include "opt_evdev.h" + #include #include #include @@ -68,6 +70,11 @@ __FBSDID("$FreeBSD$"); #include +#ifdef EVDEV +#include +#include +#endif + #include #include #include @@ -135,10 +142,18 @@ struct ums_softc { int sc_pollrate; int sc_fflags; +#ifdef EVDEV + int sc_evflags; +#define UMS_EVDEV_OPENED 1 +#endif uint8_t sc_buttons; uint8_t sc_iid; uint8_t sc_temp[64]; + +#ifdef EVDEV + struct evdev_dev *sc_evdev; +#endif }; static void ums_put_queue_timeout(void *__sc); @@ -149,25 +164,39 @@ static device_probe_t ums_probe; static device_attach_t ums_attach; static device_detach_t ums_detach; -static usb_fifo_cmd_t ums_start_read; -static usb_fifo_cmd_t ums_stop_read; -static usb_fifo_open_t ums_open; -static usb_fifo_close_t ums_close; -static usb_fifo_ioctl_t ums_ioctl; +static usb_fifo_cmd_t ums_fifo_start_read; +static usb_fifo_cmd_t ums_fifo_stop_read; +static usb_fifo_open_t ums_fifo_open; +static usb_fifo_close_t ums_fifo_close; +static usb_fifo_ioctl_t ums_fifo_ioctl; + +#ifdef EVDEV +static evdev_open_t ums_ev_open; +static evdev_close_t ums_ev_close; +#endif +static void ums_start_rx(struct ums_softc *); +static void ums_stop_rx(struct ums_softc *); static void ums_put_queue(struct ums_softc *, int32_t, int32_t, int32_t, int32_t, int32_t); static int ums_sysctl_handler_parseinfo(SYSCTL_HANDLER_ARGS); static struct usb_fifo_methods ums_fifo_methods = { - .f_open = &ums_open, - .f_close = &ums_close, - .f_ioctl = &ums_ioctl, - .f_start_read = &ums_start_read, - .f_stop_read = &ums_stop_read, + .f_open = &ums_fifo_open, + .f_close = &ums_fifo_close, + .f_ioctl = &ums_fifo_ioctl, + .f_start_read = &ums_fifo_start_read, + .f_stop_read = &ums_fifo_stop_read, .basename[0] = "ums", }; +#ifdef EVDEV +static struct evdev_methods ums_evdev_methods = { + .ev_open = &ums_ev_open, + .ev_close = &ums_ev_close, +}; +#endif + static void ums_put_queue_timeout(void *__sc) { @@ -327,11 +356,17 @@ ums_intr_callback(struct usb_xfer *xfer, case USB_ST_SETUP: tr_setup: /* check if we can put more data into the FIFO */ - if (usb_fifo_put_bytes_max( - sc->sc_fifo.fp[USB_FIFO_RX]) != 0) { - usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); - usbd_transfer_submit(xfer); + if (usb_fifo_put_bytes_max(sc->sc_fifo.fp[USB_FIFO_RX]) == 0) { +#ifdef EVDEV + if (sc->sc_evflags == 0) + break; +#else + break; +#endif } + + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); + usbd_transfer_submit(xfer); break; default: /* Error */ @@ -655,6 +690,41 @@ ums_attach(device_t dev) if (err) goto detach; +#ifdef EVDEV + sc->sc_evdev = evdev_alloc(); + evdev_set_name(sc->sc_evdev, device_get_desc(dev)); + evdev_set_phys(sc->sc_evdev, device_get_nameunit(dev)); + evdev_set_id(sc->sc_evdev, BUS_USB, uaa->info.idVendor, + uaa->info.idProduct, 0); + evdev_set_serial(sc->sc_evdev, usb_get_serial(uaa->device)); + evdev_set_methods(sc->sc_evdev, sc, &ums_evdev_methods); + evdev_support_prop(sc->sc_evdev, INPUT_PROP_POINTER); + evdev_support_event(sc->sc_evdev, EV_SYN); + evdev_support_event(sc->sc_evdev, EV_REL); + evdev_support_event(sc->sc_evdev, EV_KEY); + + info = &sc->sc_info[0]; + + if (info->sc_flags & UMS_FLAG_X_AXIS) + evdev_support_rel(sc->sc_evdev, REL_X); + + if (info->sc_flags & UMS_FLAG_Y_AXIS) + evdev_support_rel(sc->sc_evdev, REL_Y); + + if (info->sc_flags & UMS_FLAG_Z_AXIS) + evdev_support_rel(sc->sc_evdev, REL_WHEEL); + + if (info->sc_flags & UMS_FLAG_T_AXIS) + evdev_support_rel(sc->sc_evdev, REL_HWHEEL); + + for (i = 0; i < info->sc_buttons; i++) + evdev_support_key(sc->sc_evdev, BTN_MOUSE + i); + + err = evdev_register(sc->sc_evdev); + if (err) + goto detach; +#endif + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "parseinfo", CTLTYPE_STRING|CTLFLAG_RD, @@ -680,6 +750,10 @@ ums_detach(device_t self) usb_fifo_detach(&sc->sc_fifo); +#ifdef EVDEV + evdev_free(sc->sc_evdev); +#endif + usbd_transfer_unsetup(sc->sc_xfer, UMS_N_TRANSFER); usb_callout_drain(&sc->sc_callout); @@ -690,9 +764,44 @@ ums_detach(device_t self) } static void -ums_start_read(struct usb_fifo *fifo) +ums_reset(struct ums_softc *sc) +{ + + /* reset all USB mouse parameters */ + + if (sc->sc_buttons > MOUSE_MSC_MAXBUTTON) + sc->sc_hw.buttons = MOUSE_MSC_MAXBUTTON; + else + sc->sc_hw.buttons = sc->sc_buttons; + + sc->sc_hw.iftype = MOUSE_IF_USB; + sc->sc_hw.type = MOUSE_MOUSE; + sc->sc_hw.model = MOUSE_MODEL_GENERIC; + sc->sc_hw.hwid = 0; + + sc->sc_mode.protocol = MOUSE_PROTO_MSC; + sc->sc_mode.rate = -1; + sc->sc_mode.resolution = MOUSE_RES_UNKNOWN; + sc->sc_mode.accelfactor = 0; + sc->sc_mode.level = 0; + sc->sc_mode.packetsize = MOUSE_MSC_PACKETSIZE; + sc->sc_mode.syncmask[0] = MOUSE_MSC_SYNCMASK; + sc->sc_mode.syncmask[1] = MOUSE_MSC_SYNC; + + /* reset status */ + + sc->sc_status.flags = 0; + sc->sc_status.button = 0; + sc->sc_status.obutton = 0; + sc->sc_status.dx = 0; + sc->sc_status.dy = 0; + sc->sc_status.dz = 0; + /* sc->sc_status.dt = 0; */ +} + +static void +ums_start_rx(struct ums_softc *sc) { - struct ums_softc *sc = usb_fifo_softc(fifo); int rate; /* Check if we should override the default polling interval */ @@ -715,14 +824,28 @@ ums_start_read(struct usb_fifo *fifo) } static void -ums_stop_read(struct usb_fifo *fifo) +ums_stop_rx(struct ums_softc *sc) { - struct ums_softc *sc = usb_fifo_softc(fifo); - usbd_transfer_stop(sc->sc_xfer[UMS_INTR_DT]); usb_callout_stop(&sc->sc_callout); } +static void +ums_fifo_start_read(struct usb_fifo *fifo) +{ + struct ums_softc *sc = usb_fifo_softc(fifo); + + ums_start_rx(sc); +} + +static void +ums_fifo_stop_read(struct usb_fifo *fifo) +{ + struct ums_softc *sc = usb_fifo_softc(fifo); + + ums_stop_rx(sc); +} + #if ((MOUSE_SYS_PACKETSIZE != 8) || \ (MOUSE_MSC_PACKETSIZE != 5)) @@ -769,6 +892,21 @@ ums_put_queue(struct ums_softc *sc, int3 usb_fifo_put_data_linear(sc->sc_fifo.fp[USB_FIFO_RX], buf, sc->sc_mode.packetsize, 1); +#ifdef EVDEV + if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE) { + /* Push evdev event */ + evdev_push_event(sc->sc_evdev, EV_REL, REL_X, dx); + evdev_push_event(sc->sc_evdev, EV_REL, REL_Y, -dy); + evdev_push_event(sc->sc_evdev, EV_REL, REL_WHEEL, -dz); + evdev_push_event(sc->sc_evdev, EV_REL, REL_HWHEEL, dt); + evdev_push_mouse_btn(sc->sc_evdev, + (buttons & ~MOUSE_STDBUTTONS) | + (buttons & (1 << 2) ? MOUSE_BUTTON1DOWN : 0) | + (buttons & (1 << 1) ? MOUSE_BUTTON2DOWN : 0) | + (buttons & (1 << 0) ? MOUSE_BUTTON3DOWN : 0)); + evdev_sync(sc->sc_evdev); + } +#endif } else { DPRINTF("Buffer full, discarded packet\n"); } @@ -781,8 +919,44 @@ ums_reset_buf(struct ums_softc *sc) usb_fifo_reset(sc->sc_fifo.fp[USB_FIFO_RX]); } +#ifdef EVDEV +static int +ums_ev_open(struct evdev_dev *evdev, void *ev_softc) +{ + struct ums_softc *sc = (struct ums_softc *)ev_softc; + + mtx_lock(&sc->sc_mtx); + + sc->sc_evflags = UMS_EVDEV_OPENED; + + if (sc->sc_fflags == 0) { + ums_reset(sc); + ums_start_rx(sc); + } + + mtx_unlock(&sc->sc_mtx); + + return (0); +} + +static void +ums_ev_close(struct evdev_dev *evdev, void *ev_softc) +{ + struct ums_softc *sc = (struct ums_softc *)ev_softc; + + mtx_lock(&sc->sc_mtx); + + sc->sc_evflags = 0; + + if (sc->sc_fflags == 0) + ums_stop_rx(sc); + + mtx_unlock(&sc->sc_mtx); +} +#endif + static int -ums_open(struct usb_fifo *fifo, int fflags) +ums_fifo_open(struct usb_fifo *fifo, int fflags) { struct ums_softc *sc = usb_fifo_softc(fifo); @@ -793,39 +967,13 @@ ums_open(struct usb_fifo *fifo, int ffla return (EBUSY); /* check for first open */ - if (sc->sc_fflags == 0) { - - /* reset all USB mouse parameters */ - - if (sc->sc_buttons > MOUSE_MSC_MAXBUTTON) - sc->sc_hw.buttons = MOUSE_MSC_MAXBUTTON; - else - sc->sc_hw.buttons = sc->sc_buttons; - - sc->sc_hw.iftype = MOUSE_IF_USB; - sc->sc_hw.type = MOUSE_MOUSE; - sc->sc_hw.model = MOUSE_MODEL_GENERIC; - sc->sc_hw.hwid = 0; - - sc->sc_mode.protocol = MOUSE_PROTO_MSC; - sc->sc_mode.rate = -1; - sc->sc_mode.resolution = MOUSE_RES_UNKNOWN; - sc->sc_mode.accelfactor = 0; - sc->sc_mode.level = 0; - sc->sc_mode.packetsize = MOUSE_MSC_PACKETSIZE; - sc->sc_mode.syncmask[0] = MOUSE_MSC_SYNCMASK; - sc->sc_mode.syncmask[1] = MOUSE_MSC_SYNC; - - /* reset status */ - - sc->sc_status.flags = 0; - sc->sc_status.button = 0; - sc->sc_status.obutton = 0; - sc->sc_status.dx = 0; - sc->sc_status.dy = 0; - sc->sc_status.dz = 0; - /* sc->sc_status.dt = 0; */ - } +#ifdef EVDEV + if (sc->sc_fflags == 0 && sc->sc_evflags == 0) + ums_reset(sc); +#else + if (sc->sc_fflags == 0) + ums_reset(sc); +#endif if (fflags & FREAD) { /* allocate RX buffer */ @@ -840,7 +988,7 @@ ums_open(struct usb_fifo *fifo, int ffla } static void -ums_close(struct usb_fifo *fifo, int fflags) +ums_fifo_close(struct usb_fifo *fifo, int fflags) { struct ums_softc *sc = usb_fifo_softc(fifo); @@ -853,7 +1001,7 @@ ums_close(struct usb_fifo *fifo, int ffl } static int -ums_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags) +ums_fifo_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags) { struct ums_softc *sc = usb_fifo_softc(fifo); mousemode_t mode; Modified: stable/11/sys/modules/usb/ums/Makefile ============================================================================== --- stable/11/sys/modules/usb/ums/Makefile Sat Oct 22 02:15:39 2016 (r307764) +++ stable/11/sys/modules/usb/ums/Makefile Sat Oct 22 02:26:33 2016 (r307765) @@ -30,7 +30,7 @@ S= ${.CURDIR}/../../.. .PATH: $S/dev/usb/input KMOD= ums -SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h vnode_if.h usbdevs.h \ - ums.c +SRCS= opt_bus.h opt_evdev.h opt_usb.h device_if.h bus_if.h usb_if.h \ + vnode_if.h usbdevs.h ums.c .include From owner-svn-src-stable@freebsd.org Sat Oct 22 02:31:50 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE920C1B726; Sat, 22 Oct 2016 02:31:50 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ADAF1842; Sat, 22 Oct 2016 02:31:50 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M2VnVd093497; Sat, 22 Oct 2016 02:31:49 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M2Vn03093496; Sat, 22 Oct 2016 02:31:49 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610220231.u9M2Vn03093496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 02:31:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307766 - stable/11/sys/dev/evdev X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 02:31:51 -0000 Author: gonzo Date: Sat Oct 22 02:31:49 2016 New Revision: 307766 URL: https://svnweb.freebsd.org/changeset/base/307766 Log: MFC r306578: Fix gcc compilation error input_absinfo.code is unsigned so condition is always false Modified: stable/11/sys/dev/evdev/uinput.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/evdev/uinput.c ============================================================================== --- stable/11/sys/dev/evdev/uinput.c Sat Oct 22 02:26:33 2016 (r307765) +++ stable/11/sys/dev/evdev/uinput.c Sat Oct 22 02:31:49 2016 (r307766) @@ -527,7 +527,7 @@ uinput_ioctl_sub(struct uinput_cdev_stat return (EINVAL); uabs = (struct uinput_abs_setup *)data; - if (uabs->code > ABS_MAX || uabs->code < 0) + if (uabs->code > ABS_MAX) return (EINVAL); evdev_support_abs(state->ucs_evdev, uabs->code, From owner-svn-src-stable@freebsd.org Sat Oct 22 02:38:00 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F973C1B8D7; Sat, 22 Oct 2016 02:38:00 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 69DA6B8B; Sat, 22 Oct 2016 02:38:00 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9M2bxZm095795; Sat, 22 Oct 2016 02:37:59 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9M2bxfL095791; Sat, 22 Oct 2016 02:37:59 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610220237.u9M2bxfL095791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 02:37:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307767 - in stable/11/sys: arm/broadcom/bcm2835 boot/fdt/dts/arm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 02:38:00 -0000 Author: gonzo Date: Sat Oct 22 02:37:59 2016 New Revision: 307767 URL: https://svnweb.freebsd.org/changeset/base/307767 Log: MFC r306430 Add touchscreen support for the official 7" RPi touch display Technically touchscreen chip is FT5406 but all hardware communication is performed by VideCore and only final results are presented to ARM part through memory region shared between VC and ARM. evdev is used as userland interface. FT5406 supports up to 10 touchpoints, but for now driver emulates single touch device because I do not have GUI bits to test this functionality. Driver is not enabled in default config for RPI and RPI2 Tested with: evdev-dump, tslib Added: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c - copied unchanged from r306430, head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Modified: stable/11/sys/arm/broadcom/bcm2835/files.bcm283x stable/11/sys/boot/fdt/dts/arm/rpi.dts stable/11/sys/boot/fdt/dts/arm/rpi2.dts Directory Properties: stable/11/ (props changed) Copied: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c (from r306430, head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Sat Oct 22 02:37:59 2016 (r307767, copy of r306430, head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c) @@ -0,0 +1,337 @@ +/*- + * Copyright (C) 2016 Oleksandr Tymoshenko + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#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 "mbox_if.h" + +#ifdef DEBUG +#define DPRINTF(fmt, ...) do { \ + printf("%s:%u: ", __func__, __LINE__); \ + printf(fmt, ##__VA_ARGS__); \ +} while (0) +#else +#define DPRINTF(fmt, ...) +#endif + +#define FT5406_LOCK(_sc) \ + mtx_lock(&(_sc)->sc_mtx) +#define FT5406_UNLOCK(_sc) \ + mtx_unlock(&(_sc)->sc_mtx) +#define FT5406_LOCK_INIT(_sc) \ + mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->sc_dev), \ + "ft5406", MTX_DEF) +#define FT5406_LOCK_DESTROY(_sc) \ + mtx_destroy(&_sc->sc_mtx); +#define FT5406_LOCK_ASSERT(_sc) \ + mtx_assert(&(_sc)->sc_mtx, MA_OWNED) + +#define FT5406_DEVICE_MODE 0 +#define FT5406_GESTURE_ID 1 +#define FT5406_NUM_POINTS 2 +#define FT5406_POINT_XH(n) (0 + 3 + (n)*6) +#define FT5406_POINT_XL(n) (1 + 3 + (n)*6) +#define FT5406_POINT_YH(n) (2 + 3 + (n)*6) +#define FT5406_POINT_YL(n) (3 + 3 + (n)*6) +#define FT5406_WINDOW_SIZE 64 + +#define GET_NUM_POINTS(buf) (buf[FT5406_NUM_POINTS]) +#define GET_X(buf, n) (((buf[FT5406_POINT_XH(n)] & 0xf) << 8) | \ + (buf[FT5406_POINT_XL(n)])) +#define GET_Y(buf, n) (((buf[FT5406_POINT_YH(n)] & 0xf) << 8) | \ + (buf[FT5406_POINT_YL(n)])) +#define GET_TOUCH_ID(buf, n) ((buf[FT5406_POINT_YH(n)] >> 4) & 0xf) + +#define NO_POINTS 99 +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 480 + +struct ft5406ts_softc { + device_t sc_dev; + struct mtx sc_mtx; + struct proc *sc_worker; + + /* mbox buffer (mapped to KVA) */ + uint8_t *touch_buf; + + /* initial hook for waiting mbox intr */ + struct intr_config_hook sc_init_hook; + + struct evdev_dev *sc_evdev; + int sc_detaching; +}; + +static void +ft5406ts_worker(void *data) +{ + struct ft5406ts_softc *sc = (struct ft5406ts_softc *)data; + int points; + int id, new_x, new_y, i, new_pen_down, updated; + int x, y, pen_down; + uint8_t window[FT5406_WINDOW_SIZE]; + int tick; + + /* 60Hz */ + tick = hz*17/1000; + if (tick == 0) + tick = 1; + + x = y = -1; + pen_down = 0; + + FT5406_LOCK(sc); + while(1) { + msleep(sc, &sc->sc_mtx, PCATCH | PZERO, "ft5406ts", tick); + + if (sc->sc_detaching) + break; + + memcpy(window, sc->touch_buf, sizeof(window)); + sc->touch_buf[FT5406_NUM_POINTS] = NO_POINTS; + + points = GET_NUM_POINTS(window); + /* + * No update from VC - do nothing + */ + if (points == NO_POINTS) + continue; + + /* No points and pen is already up */ + if ((points == 0) && !pen_down) + continue; + + new_pen_down = 0; + for (i = 0; i < points; i++) { + id = GET_TOUCH_ID(window, 0); + /* For now consider only touch 0 */ + if (id != 0) + continue; + new_pen_down = 1; + new_x = GET_X(window, 0); + new_y = GET_Y(window, 0); + } + + updated = 0; + + if (new_x != x) { + x = new_x; + updated = 1; + } + + if (new_y != y) { + y = new_y; + updated = 1; + } + + if (new_pen_down != pen_down) { + pen_down = new_pen_down; + updated = 1; + } + + if (updated) { + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_X, x); + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_Y, y); + evdev_push_event(sc->sc_evdev, EV_KEY, BTN_TOUCH, pen_down); + evdev_sync(sc->sc_evdev); + } + } + FT5406_UNLOCK(sc); + + kproc_exit(0); +} + +static void +ft5406ts_init(void *arg) +{ + struct ft5406ts_softc *sc = arg; + struct bcm2835_mbox_tag_touchbuf msg; + uint32_t touchbuf; + int err; + + /* release this hook (continue boot) */ + config_intrhook_disestablish(&sc->sc_init_hook); + + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_TOUCHBUF; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body); + msg.end_tag = 0; + + /* call mailbox property */ + err = bcm2835_mbox_property(&msg, sizeof(msg)); + if (err) { + device_printf(sc->sc_dev, "failed to get touchbuf address\n"); + return; + } + + if (msg.body.resp.address == 0) { + device_printf(sc->sc_dev, "touchscreen not detected\n"); + return; + } + + touchbuf = VCBUS_TO_PHYS(msg.body.resp.address); + sc->touch_buf = (uint8_t*)pmap_mapdev(touchbuf, FT5406_WINDOW_SIZE); + + sc->sc_evdev = evdev_alloc(); + evdev_set_name(sc->sc_evdev, device_get_desc(sc->sc_dev)); + evdev_set_phys(sc->sc_evdev, device_get_nameunit(sc->sc_dev)); + evdev_set_id(sc->sc_evdev, BUS_VIRTUAL, 0, 0, 0); + evdev_support_prop(sc->sc_evdev, INPUT_PROP_DIRECT); + evdev_support_event(sc->sc_evdev, EV_SYN); + evdev_support_event(sc->sc_evdev, EV_ABS); + evdev_support_event(sc->sc_evdev, EV_KEY); + + evdev_support_abs(sc->sc_evdev, ABS_X, 0, 0, + SCREEN_WIDTH, 0, 0, 0); + evdev_support_abs(sc->sc_evdev, ABS_Y, 0, 0, + SCREEN_HEIGHT, 0, 0, 0); + + evdev_support_key(sc->sc_evdev, BTN_TOUCH); + + err = evdev_register(sc->sc_evdev); + if (err) { + evdev_free(sc->sc_evdev); + return; + } + + sc->touch_buf[FT5406_NUM_POINTS] = NO_POINTS; + if (kproc_create(ft5406ts_worker, (void*)sc, &sc->sc_worker, 0, 0, + "ft5406ts_worker") != 0) { + printf("failed to create ft5406ts_worker\n"); + } +} + +static int +ft5406ts_probe(device_t dev) +{ + + if (!ofw_bus_is_compatible(dev, "rpi,rpi-ft5406")) + return (ENXIO); + + device_set_desc(dev, "FT5406 touchscreen (VC memory interface)"); + + return (BUS_PROBE_DEFAULT); +} + +static int +ft5406ts_attach(device_t dev) +{ + struct ft5406ts_softc *sc; + + /* set self dev */ + sc = device_get_softc(dev); + sc->sc_dev = dev; + + /* register callback for using mbox when interrupts are enabled */ + sc->sc_init_hook.ich_func = ft5406ts_init; + sc->sc_init_hook.ich_arg = sc; + + if (config_intrhook_establish(&sc->sc_init_hook) != 0) { + device_printf(dev, "config_intrhook_establish failed\n"); + return (ENOMEM); + } + + FT5406_LOCK_INIT(sc); + + return (0); +} + +static int +ft5406ts_detach(device_t dev) +{ + struct ft5406ts_softc *sc; + + sc = device_get_softc(dev); + + FT5406_LOCK(sc); + if (sc->sc_worker) + sc->sc_detaching = 1; + + if (sc->sc_evdev) + evdev_free(sc->sc_evdev); + FT5406_UNLOCK(sc); + + FT5406_LOCK_DESTROY(sc); + + return (0); +} + +static device_method_t ft5406ts_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ft5406ts_probe), + DEVMETHOD(device_attach, ft5406ts_attach), + DEVMETHOD(device_detach, ft5406ts_detach), + + DEVMETHOD_END +}; + +static devclass_t ft5406ts_devclass; +static driver_t ft5406ts_driver = { + "ft5406ts", + ft5406ts_methods, + sizeof(struct ft5406ts_softc), +}; + +DRIVER_MODULE(ft5406ts, ofwbus, ft5406ts_driver, ft5406ts_devclass, 0, 0); Modified: stable/11/sys/arm/broadcom/bcm2835/files.bcm283x ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/files.bcm283x Sat Oct 22 02:31:49 2016 (r307766) +++ stable/11/sys/arm/broadcom/bcm2835/files.bcm283x Sat Oct 22 02:37:59 2016 (r307767) @@ -6,6 +6,7 @@ arm/broadcom/bcm2835/bcm2835_cpufreq.c arm/broadcom/bcm2835/bcm2835_dma.c standard arm/broadcom/bcm2835/bcm2835_fb.c optional sc arm/broadcom/bcm2835/bcm2835_fbd.c optional vt +arm/broadcom/bcm2835/bcm2835_ft5406.c optional evdev bcm2835_ft5406 arm/broadcom/bcm2835/bcm2835_gpio.c optional gpio arm/broadcom/bcm2835/bcm2835_intr.c standard arm/broadcom/bcm2835/bcm2835_machdep.c standard Modified: stable/11/sys/boot/fdt/dts/arm/rpi.dts ============================================================================== --- stable/11/sys/boot/fdt/dts/arm/rpi.dts Sat Oct 22 02:31:49 2016 (r307766) +++ stable/11/sys/boot/fdt/dts/arm/rpi.dts Sat Oct 22 02:37:59 2016 (r307767) @@ -322,6 +322,11 @@ broadcom,depth = <0>; /* Set by VideoCore */ }; + rpi_ft5406 { + compatible = "rpi,rpi-ft5406"; + status = "okay"; + }; + leds { compatible = "gpio-leds"; Modified: stable/11/sys/boot/fdt/dts/arm/rpi2.dts ============================================================================== --- stable/11/sys/boot/fdt/dts/arm/rpi2.dts Sat Oct 22 02:31:49 2016 (r307766) +++ stable/11/sys/boot/fdt/dts/arm/rpi2.dts Sat Oct 22 02:37:59 2016 (r307767) @@ -337,6 +337,11 @@ broadcom,depth = <0>; /* Set by VideoCore */ }; + rpi_ft5406 { + compatible = "rpi,rpi-ft5406"; + status = "okay"; + }; + leds { compatible = "gpio-leds"; From owner-svn-src-stable@freebsd.org Sat Oct 22 13:09:31 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A15FC1C08D; Sat, 22 Oct 2016 13:09:31 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 295AAD53; Sat, 22 Oct 2016 13:09:31 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MD9Uqg035992; Sat, 22 Oct 2016 13:09:30 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MD9U3a035991; Sat, 22 Oct 2016 13:09:30 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610221309.u9MD9U3a035991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 13:09:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307770 - stable/11 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 13:09:31 -0000 Author: bapt Date: Sat Oct 22 13:09:30 2016 New Revision: 307770 URL: https://svnweb.freebsd.org/changeset/base/307770 Log: MFC: 306864,307648 Groff is needed only if MK_GROFF and MK_SHAREDOCS are both true. Modified: stable/11/Makefile.inc1 Modified: stable/11/Makefile.inc1 ============================================================================== --- stable/11/Makefile.inc1 Sat Oct 22 11:26:22 2016 (r307769) +++ stable/11/Makefile.inc1 Sat Oct 22 13:09:30 2016 (r307770) @@ -1570,7 +1570,7 @@ _strfile= usr.bin/fortune/strfile _gperf= gnu/usr.bin/gperf .endif -.if ${MK_GROFF} != "no" +.if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no" _groff= gnu/usr.bin/groff \ usr.bin/soelim .endif From owner-svn-src-stable@freebsd.org Sat Oct 22 13:15:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31D1DC1C35F; Sat, 22 Oct 2016 13:15:21 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E225B691; Sat, 22 Oct 2016 13:15:20 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MDFKHU039786; Sat, 22 Oct 2016 13:15:20 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MDFJ2p039783; Sat, 22 Oct 2016 13:15:19 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610221315.u9MDFJ2p039783@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 13:15:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307772 - stable/11/usr.bin/sdiff X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 13:15:21 -0000 Author: bapt Date: Sat Oct 22 13:15:19 2016 New Revision: 307772 URL: https://svnweb.freebsd.org/changeset/base/307772 Log: MFC: 307368,307369,307372,307381 Remove the common.h include which is actually not used in sdiff.c Turn editit into a static function Move cleanup() into the edit.c file which is the only users of that function Remove common.{c,h} Fix typos in sdiff(1) message and improve display Deleted: stable/11/usr.bin/sdiff/common.c stable/11/usr.bin/sdiff/common.h Modified: stable/11/usr.bin/sdiff/Makefile stable/11/usr.bin/sdiff/edit.c stable/11/usr.bin/sdiff/sdiff.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/sdiff/Makefile ============================================================================== --- stable/11/usr.bin/sdiff/Makefile Sat Oct 22 13:11:09 2016 (r307771) +++ stable/11/usr.bin/sdiff/Makefile Sat Oct 22 13:15:19 2016 (r307772) @@ -3,7 +3,7 @@ .include PROG= sdiff -SRCS= common.c edit.c sdiff.c +SRCS= edit.c sdiff.c WARNS= 3 MAN1= sdiff.1 Modified: stable/11/usr.bin/sdiff/edit.c ============================================================================== --- stable/11/usr.bin/sdiff/edit.c Sat Oct 22 13:11:09 2016 (r307771) +++ stable/11/usr.bin/sdiff/edit.c Sat Oct 22 13:15:19 2016 (r307772) @@ -21,10 +21,16 @@ __FBSDID("$FreeBSD$"); #include #include -#include "common.h" #include "extern.h" -int editit(const char *); +static void +cleanup(const char *filename) +{ + + if (unlink(filename)) + err(2, "could not delete: %s", filename); + exit(2); +} /* * Execute an editor on the specified pathname, which is interpreted @@ -32,7 +38,7 @@ int editit(const char *); * * Returns -1 on error, or the exit value on success. */ -int +static int editit(const char *pathname) { sig_t sighup, sigint, sigquit, sigchld; Modified: stable/11/usr.bin/sdiff/sdiff.c ============================================================================== --- stable/11/usr.bin/sdiff/sdiff.c Sat Oct 22 13:11:09 2016 (r307771) +++ stable/11/usr.bin/sdiff/sdiff.c Sat Oct 22 13:15:19 2016 (r307772) @@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "common.h" #include "extern.h" #define DIFF_PATH "/usr/bin/diff" @@ -144,24 +143,25 @@ static struct option longopts[] = { }; static const char *help_msg[] = { - "\nusage: sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1 file2\n", - "\t-l, --left-column, Only print the left column for identical lines.", - "\t-o OUTFILE, --output=OUTFILE, nteractively merge file1 and file2 into outfile.", - "\t-s, --suppress-common-lines, Skip identical lines.", - "\t-w WIDTH, --width=WIDTH, Print a maximum of WIDTH characters on each line.", - "\tOptions passed to diff(1) are:", - "\t\t-a, --text, Treat file1 and file2 as text files.", - "\t\t-b, --ignore-trailing-cr, Ignore trailing blank spaces.", - "\t\t-d, --minimal, Minimize diff size.", - "\t\t-I RE, --ignore-matching-lines=RE, Ignore changes whose line matches RE.", - "\t\t-i, --ignore-case, Do a case-insensitive comparison.", - "\t\t-t, --expand-tabs Expand tabs to spaces.", - "\t\t-W, --ignore-all-spaces, Ignore all spaces.", - "\t\t--speed-large-files, Assume large file with scattered changes.", - "\t\t--strip-trailing-cr, Strip trailing carriage return.", - "\t\t--ignore-file-name-case, Ignore case of file names.", - "\t\t--no-ignore-file-name-case, Do not ignore file name case", - "\t\t--tabsize NUM, Change size of tabs (default 8.)", + "usage: sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1 file2\n", + "-l, --left-column: only print the left column for identical lines.", + "-o OUTFILE, --output=OUTFILE: interactively merge file1 and file2 into outfile.", + "-s, --suppress-common-lines: skip identical lines.", + "-w WIDTH, --width=WIDTH: print a maximum of WIDTH characters on each line.", + "", + "Options passed to diff(1) are:", + "\t-a, --text: treat file1 and file2 as text files.", + "\t-b, --ignore-trailing-cr: ignore trailing blank spaces.", + "\t-d, --minimal: minimize diff size.", + "\t-I RE, --ignore-matching-lines=RE: ignore changes whose line matches RE.", + "\t-i, --ignore-case: do a case-insensitive comparison.", + "\t-t, --expand-tabs: sxpand tabs to spaces.", + "\t-W, --ignore-all-spaces: ignore all spaces.", + "\t--speed-large-files: assume large file with scattered changes.", + "\t--strip-trailing-cr: strip trailing carriage return.", + "\t--ignore-file-name-case: ignore case of file names.", + "\t--no-ignore-file-name-case: do not ignore file name case", + "\t--tabsize NUM: change size of tabs (default 8.)", NULL, }; From owner-svn-src-stable@freebsd.org Sat Oct 22 13:20:04 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04BADC1C417; Sat, 22 Oct 2016 13:20:04 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE704883; Sat, 22 Oct 2016 13:20:03 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MDK29X039998; Sat, 22 Oct 2016 13:20:02 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MDK2iL039997; Sat, 22 Oct 2016 13:20:02 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610221320.u9MDK2iL039997@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 13:20:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307773 - stable/11/usr.bin/tee X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 13:20:04 -0000 Author: bapt Date: Sat Oct 22 13:20:02 2016 New Revision: 307773 URL: https://svnweb.freebsd.org/changeset/base/307773 Log: MFC: 305937 Capsicum-ize tee(1) Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D7940 Modified: stable/11/usr.bin/tee/tee.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/tee/tee.c ============================================================================== --- stable/11/usr.bin/tee/tee.c Sat Oct 22 13:15:19 2016 (r307772) +++ stable/11/usr.bin/tee/tee.c Sat Oct 22 13:20:02 2016 (r307773) @@ -41,14 +41,18 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ -#include +#include #include +#include + #include +#include #include #include #include #include #include +#include #include typedef struct _list { @@ -69,6 +73,8 @@ main(int argc, char *argv[]) char *bp; int append, ch, exitval; char *buf; + cap_rights_t rights; + unsigned long cmd; #define BSIZE (8 * 1024) append = 0; @@ -90,6 +96,16 @@ main(int argc, char *argv[]) if ((buf = malloc(BSIZE)) == NULL) err(1, "malloc"); + cap_rights_init(&rights, CAP_READ, CAP_FSTAT); + if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to limit rights for stdin"); + cap_rights_init(&rights, CAP_WRITE, CAP_FSTAT, CAP_IOCTL); + if (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to limit rights for stderr"); + cmd = TIOCGETA; + if (cap_ioctls_limit(STDERR_FILENO, &cmd, 1) < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to limit ioctls for stderr"); + add(STDOUT_FILENO, "stdout"); for (exitval = 0; *argv; ++argv) @@ -100,6 +116,8 @@ main(int argc, char *argv[]) } else add(fd, *argv); + if (cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to enter capability mode"); while ((rval = read(STDIN_FILENO, buf, BSIZE)) > 0) for (p = head; p; p = p->next) { n = rval; @@ -129,6 +147,21 @@ static void add(int fd, const char *name) { LIST *p; + cap_rights_t rights; + unsigned long cmd; + + if (fd == STDOUT_FILENO) + cap_rights_init(&rights, CAP_WRITE, CAP_FSTAT, CAP_IOCTL); + else + cap_rights_init(&rights, CAP_WRITE, CAP_FSTAT); + if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to limit rights"); + + if (fd == STDOUT_FILENO) { + cmd = TIOCGETA; + if (cap_ioctls_limit(fd, &cmd, 1) < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to limit ioctls for stdout"); + } if ((p = malloc(sizeof(LIST))) == NULL) err(1, "malloc"); From owner-svn-src-stable@freebsd.org Sat Oct 22 15:26:35 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 011A9C1D792; Sat, 22 Oct 2016 15:26:35 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C26D3A72; Sat, 22 Oct 2016 15:26:34 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MFQXNt089053; Sat, 22 Oct 2016 15:26:33 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MFQWMo089042; Sat, 22 Oct 2016 15:26:32 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610221526.u9MFQWMo089042@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 15:26:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307775 - in stable/11/sys: arm/broadcom/bcm2835 arm/conf arm/ti conf dev/evdev dev/usb/input modules modules/evdev modules/uinput X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 15:26:35 -0000 Author: gonzo Date: Sat Oct 22 15:26:32 2016 New Revision: 307775 URL: https://svnweb.freebsd.org/changeset/base/307775 Log: MFC r306530, r306531, r306532, r306579: r306530: Declare a module for evdev and add dependency to ukbd(4) and ums(4) Prepare for making evdev a module. "Pure" evdev device drivers (like touchscreen) and evdev itself can be built as a modules regardless of "options EVDEV" in kernel config. So if people does not require evdev functionality in hybrid drivers like ums and ukbd they can, for instance, kldload evdev and utouchscreen to run FreeBSD in kiosk mode. r306531: Add dependency to evdev module (if required) r306532: Add dependency to evdev module r306579: Modularize evdev - Convert "options EVDEV" to "device evdev" and "device uinput", add modules for both new devices. They are isolated subsystems and do not require any compile-time changes to general kernel subsytems - For hybrid drivers that have evdev as an optional way to deliver input events add option EVDEV_SUPPORT. Update all existing hybrid drivers to use it instead of EVDEV - Remove no-op DECLARE_MODULE in evdev, it's not required, MODULE_VERSION is enough - Add evdev module dependency to uinput Submitted by: Vladimir Kondratiev Added: stable/11/sys/modules/evdev/ - copied from r306579, head/sys/modules/evdev/ stable/11/sys/modules/uinput/ - copied from r306579, head/sys/modules/uinput/ Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c stable/11/sys/arm/conf/BEAGLEBONE stable/11/sys/arm/ti/ti_adc.c stable/11/sys/arm/ti/ti_adcvar.h stable/11/sys/conf/NOTES stable/11/sys/conf/options stable/11/sys/dev/evdev/evdev.c stable/11/sys/dev/evdev/uinput.c stable/11/sys/dev/usb/input/ukbd.c stable/11/sys/dev/usb/input/ums.c stable/11/sys/modules/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Sat Oct 22 15:26:32 2016 (r307775) @@ -335,3 +335,4 @@ static driver_t ft5406ts_driver = { }; DRIVER_MODULE(ft5406ts, ofwbus, ft5406ts_driver, ft5406ts_devclass, 0, 0); +MODULE_DEPEND(ft5406ts, evdev, 1, 1, 1); Modified: stable/11/sys/arm/conf/BEAGLEBONE ============================================================================== --- stable/11/sys/arm/conf/BEAGLEBONE Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/arm/conf/BEAGLEBONE Sat Oct 22 15:26:32 2016 (r307775) @@ -135,4 +135,4 @@ device ukbd device kbdmux # Uncomment to enable evdev support for ti_adc -# options EVDEV +# options EVDEV_SUPPORT Modified: stable/11/sys/arm/ti/ti_adc.c ============================================================================== --- stable/11/sys/arm/ti/ti_adc.c Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/arm/ti/ti_adc.c Sat Oct 22 15:26:32 2016 (r307775) @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef EVDEV +#ifdef EVDEV_SUPPORT #include #include #endif @@ -89,7 +89,7 @@ static int ti_adc_samples[5] = { 0, 2, 4 static int ti_adc_detach(device_t dev); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static void ti_adc_ev_report(struct ti_adc_softc *sc) { @@ -472,7 +472,7 @@ ti_adc_tsc_read_data(struct ti_adc_softc device_printf(sc->sc_dev, "touchscreen x: %d, y: %d\n", x, y); #endif -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if ((sc->sc_x != x) || (sc->sc_y != y)) { sc->sc_x = x; sc->sc_y = y; @@ -516,7 +516,7 @@ ti_adc_intr(void *arg) status |= ADC_IRQ_HW_PEN_ASYNC; ADC_WRITE4(sc, ADC_IRQENABLE_CLR, ADC_IRQ_HW_PEN_ASYNC); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT ti_adc_ev_report(sc); #endif } @@ -524,7 +524,7 @@ ti_adc_intr(void *arg) if (rawstatus & ADC_IRQ_PEN_UP) { sc->sc_pen_down = 0; status |= ADC_IRQ_PEN_UP; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT ti_adc_ev_report(sc); #endif } @@ -874,7 +874,7 @@ ti_adc_attach(device_t dev) ti_adc_setup(sc); TI_ADC_UNLOCK(sc); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_tsc_wires > 0) { sc->sc_evdev = evdev_alloc(); evdev_set_name(sc->sc_evdev, device_get_desc(dev)); @@ -921,7 +921,7 @@ ti_adc_detach(device_t dev) ti_adc_reset(sc); ti_adc_setup(sc); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev_free(sc->sc_evdev); #endif @@ -958,3 +958,6 @@ static devclass_t ti_adc_devclass; DRIVER_MODULE(ti_adc, simplebus, ti_adc_driver, ti_adc_devclass, 0, 0); MODULE_VERSION(ti_adc, 1); MODULE_DEPEND(ti_adc, simplebus, 1, 1, 1); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(ti_adc, evdev, 1, 1, 1); +#endif Modified: stable/11/sys/arm/ti/ti_adcvar.h ============================================================================== --- stable/11/sys/arm/ti/ti_adcvar.h Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/arm/ti/ti_adcvar.h Sat Oct 22 15:26:32 2016 (r307775) @@ -55,7 +55,7 @@ struct ti_adc_softc { int sc_yn_bit, sc_yn_inp; uint32_t sc_tsc_enabled; int sc_pen_down; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT int sc_x; int sc_y; struct evdev_dev *sc_evdev; Modified: stable/11/sys/conf/NOTES ============================================================================== --- stable/11/sys/conf/NOTES Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/conf/NOTES Sat Oct 22 15:26:32 2016 (r307775) @@ -3064,6 +3064,8 @@ options GZIO options BHND_LOGLEVEL # Logging threshold level # evdev interface -options EVDEV -options EVDEV_DEBUG -options UINPUT_DEBUG +device evdev # input event device support +options EVDEV_SUPPORT # evdev support in legacy drivers +options EVDEV_DEBUG # enable event debug msgs +device uinput # install /dev/uinput cdev +options UINPUT_DEBUG # enable uinput debug msgs Modified: stable/11/sys/conf/options ============================================================================== --- stable/11/sys/conf/options Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/conf/options Sat Oct 22 15:26:32 2016 (r307775) @@ -988,6 +988,6 @@ BHND_LOGLEVEL opt_global.h GPIO_SPI_DEBUG opt_gpio.h # evdev protocol support -EVDEV opt_evdev.h +EVDEV_SUPPORT opt_evdev.h EVDEV_DEBUG opt_evdev.h UINPUT_DEBUG opt_evdev.h Modified: stable/11/sys/dev/evdev/evdev.c ============================================================================== --- stable/11/sys/dev/evdev/evdev.c Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/dev/evdev/evdev.c Sat Oct 22 15:26:32 2016 (r307775) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -916,3 +917,5 @@ evdev_stop_repeat(struct evdev_dev *evde evdev->ev_rep_key = KEY_RESERVED; } } + +MODULE_VERSION(evdev, 1); Modified: stable/11/sys/dev/evdev/uinput.c ============================================================================== --- stable/11/sys/dev/evdev/uinput.c Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/dev/evdev/uinput.c Sat Oct 22 15:26:32 2016 (r307775) @@ -708,3 +708,5 @@ uinput_modevent(module_t mod __unused, i } DEV_MODULE(uinput, uinput_modevent, NULL); +MODULE_VERSION(uinput, 1); +MODULE_DEPEND(uinput, evdev, 1, 1, 1); Modified: stable/11/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/11/sys/dev/usb/input/ukbd.c Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/dev/usb/input/ukbd.c Sat Oct 22 15:26:32 2016 (r307775) @@ -74,7 +74,7 @@ __FBSDID("$FreeBSD$"); #include -#ifdef EVDEV +#ifdef EVDEV_SUPPORT #include #include #endif @@ -168,7 +168,7 @@ struct ukbd_softc { struct usb_device *sc_udev; struct usb_interface *sc_iface; struct usb_xfer *sc_xfer[UKBD_N_TRANSFER]; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct evdev_dev *sc_evdev; #endif @@ -386,7 +386,7 @@ static device_attach_t ukbd_attach; static device_detach_t ukbd_detach; static device_resume_t ukbd_resume; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static struct evdev_methods ukbd_evdev_methods = { .ev_event = evdev_ev_kbd_event, }; @@ -420,7 +420,7 @@ ukbd_put_key(struct ukbd_softc *sc, uint DPRINTF("0x%02x (%d) %s\n", key, key, (key & KEY_RELEASE) ? "released" : "pressed"); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (evdev_rcpt_mask & EVDEV_RCPT_HW_KBD && sc->sc_evdev != NULL) { evdev_push_event(sc->sc_evdev, EV_KEY, evdev_hid2key(KEY_INDEX(key)), !(key & KEY_RELEASE)); @@ -941,7 +941,7 @@ ukbd_set_leds_callback(struct usb_xfer * if (!any) break; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evdev != NULL) evdev_push_leds(sc->sc_evdev, sc->sc_leds); #endif @@ -1221,7 +1221,7 @@ ukbd_attach(device_t dev) usb_error_t err; uint16_t n; uint16_t hid_len; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct evdev_dev *evdev; int i; #endif @@ -1340,7 +1340,7 @@ ukbd_attach(device_t dev) } #endif -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev = evdev_alloc(); evdev_set_name(evdev, device_get_desc(dev)); evdev_set_phys(evdev, device_get_nameunit(dev)); @@ -1441,7 +1441,7 @@ ukbd_detach(device_t dev) } #endif -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev_free(sc->sc_evdev); #endif @@ -1976,7 +1976,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_lon else kbd->kb_delay1 = ((int *)arg)[0]; kbd->kb_delay2 = ((int *)arg)[1]; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evdev != NULL) evdev_push_repeats(sc->sc_evdev, kbd); #endif @@ -2128,7 +2128,7 @@ ukbd_set_leds(struct ukbd_softc *sc, uin static int ukbd_set_typematic(keyboard_t *kbd, int code) { -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct ukbd_softc *sc = kbd->kb_data; #endif static const int delays[] = {250, 500, 750, 1000}; @@ -2142,7 +2142,7 @@ ukbd_set_typematic(keyboard_t *kbd, int } kbd->kb_delay1 = delays[(code >> 5) & 3]; kbd->kb_delay2 = rates[code & 0x1f]; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evdev != NULL) evdev_push_repeats(sc->sc_evdev, kbd); #endif @@ -2297,5 +2297,8 @@ static driver_t ukbd_driver = { DRIVER_MODULE(ukbd, uhub, ukbd_driver, ukbd_devclass, ukbd_driver_load, 0); MODULE_DEPEND(ukbd, usb, 1, 1, 1); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(ukbd, evdev, 1, 1, 1); +#endif MODULE_VERSION(ukbd, 1); USB_PNP_HOST_INFO(ukbd_devs); Modified: stable/11/sys/dev/usb/input/ums.c ============================================================================== --- stable/11/sys/dev/usb/input/ums.c Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/dev/usb/input/ums.c Sat Oct 22 15:26:32 2016 (r307775) @@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$"); #include -#ifdef EVDEV +#ifdef EVDEV_SUPPORT #include #include #endif @@ -142,7 +142,7 @@ struct ums_softc { int sc_pollrate; int sc_fflags; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT int sc_evflags; #define UMS_EVDEV_OPENED 1 #endif @@ -151,7 +151,7 @@ struct ums_softc { uint8_t sc_iid; uint8_t sc_temp[64]; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct evdev_dev *sc_evdev; #endif }; @@ -170,7 +170,7 @@ static usb_fifo_open_t ums_fifo_open; static usb_fifo_close_t ums_fifo_close; static usb_fifo_ioctl_t ums_fifo_ioctl; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static evdev_open_t ums_ev_open; static evdev_close_t ums_ev_close; #endif @@ -190,7 +190,7 @@ static struct usb_fifo_methods ums_fifo_ .basename[0] = "ums", }; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static struct evdev_methods ums_evdev_methods = { .ev_open = &ums_ev_open, .ev_close = &ums_ev_close, @@ -357,7 +357,7 @@ ums_intr_callback(struct usb_xfer *xfer, tr_setup: /* check if we can put more data into the FIFO */ if (usb_fifo_put_bytes_max(sc->sc_fifo.fp[USB_FIFO_RX]) == 0) { -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evflags == 0) break; #else @@ -690,7 +690,7 @@ ums_attach(device_t dev) if (err) goto detach; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT sc->sc_evdev = evdev_alloc(); evdev_set_name(sc->sc_evdev, device_get_desc(dev)); evdev_set_phys(sc->sc_evdev, device_get_nameunit(dev)); @@ -750,7 +750,7 @@ ums_detach(device_t self) usb_fifo_detach(&sc->sc_fifo); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev_free(sc->sc_evdev); #endif @@ -892,7 +892,7 @@ ums_put_queue(struct ums_softc *sc, int3 usb_fifo_put_data_linear(sc->sc_fifo.fp[USB_FIFO_RX], buf, sc->sc_mode.packetsize, 1); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE) { /* Push evdev event */ evdev_push_event(sc->sc_evdev, EV_REL, REL_X, dx); @@ -919,7 +919,7 @@ ums_reset_buf(struct ums_softc *sc) usb_fifo_reset(sc->sc_fifo.fp[USB_FIFO_RX]); } -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static int ums_ev_open(struct evdev_dev *evdev, void *ev_softc) { @@ -967,7 +967,7 @@ ums_fifo_open(struct usb_fifo *fifo, int return (EBUSY); /* check for first open */ -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_fflags == 0 && sc->sc_evflags == 0) ums_reset(sc); #else @@ -1199,5 +1199,8 @@ static driver_t ums_driver = { DRIVER_MODULE(ums, uhub, ums_driver, ums_devclass, NULL, 0); MODULE_DEPEND(ums, usb, 1, 1, 1); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(ums, evdev, 1, 1, 1); +#endif MODULE_VERSION(ums, 1); USB_PNP_HOST_INFO(ums_devs); Modified: stable/11/sys/modules/Makefile ============================================================================== --- stable/11/sys/modules/Makefile Sat Oct 22 14:37:13 2016 (r307774) +++ stable/11/sys/modules/Makefile Sat Oct 22 15:26:32 2016 (r307775) @@ -111,6 +111,7 @@ SUBDIR= \ ${_epic} \ esp \ ${_et} \ + evdev \ ${_ex} \ ${_exca} \ ext2fs \ @@ -373,6 +374,7 @@ SUBDIR= \ udf \ udf_iconv \ ufs \ + uinput \ unionfs \ urtwn \ ${_urtwnfw} \ From owner-svn-src-stable@freebsd.org Sat Oct 22 16:24:13 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D050FC1CC93; Sat, 22 Oct 2016 16:24:13 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B7B4D51; Sat, 22 Oct 2016 16:24:13 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MGOCUg011573; Sat, 22 Oct 2016 16:24:12 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MGOCnY011570; Sat, 22 Oct 2016 16:24:12 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610221624.u9MGOCnY011570@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 16:24:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307776 - in stable/11/sys: arm/broadcom/bcm2835 arm/conf modules/rpi_ft5406 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 16:24:13 -0000 Author: gonzo Date: Sat Oct 22 16:24:12 2016 New Revision: 307776 URL: https://svnweb.freebsd.org/changeset/base/307776 Log: MFC r306618, r306619 r306618: Fix attach/detach methods - Initialize lock before starting worker process - Do not hold lock when destroying evdev. By that time ther should be no other active code pathes that can access softc r306619: Add rpi_ft5406 module and add it to extra modules in Raspberry Pi configs Added: stable/11/sys/modules/rpi_ft5406/ - copied from r306619, head/sys/modules/rpi_ft5406/ Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c stable/11/sys/arm/conf/RPI-B stable/11/sys/arm/conf/RPI2 Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Sat Oct 22 15:26:32 2016 (r307775) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Sat Oct 22 16:24:12 2016 (r307776) @@ -288,13 +288,13 @@ ft5406ts_attach(device_t dev) sc->sc_init_hook.ich_func = ft5406ts_init; sc->sc_init_hook.ich_arg = sc; + FT5406_LOCK_INIT(sc); + if (config_intrhook_establish(&sc->sc_init_hook) != 0) { device_printf(dev, "config_intrhook_establish failed\n"); return (ENOMEM); } - FT5406_LOCK_INIT(sc); - return (0); } @@ -308,10 +308,11 @@ ft5406ts_detach(device_t dev) FT5406_LOCK(sc); if (sc->sc_worker) sc->sc_detaching = 1; + wakeup(sc); + FT5406_UNLOCK(sc); if (sc->sc_evdev) evdev_free(sc->sc_evdev); - FT5406_UNLOCK(sc); FT5406_LOCK_DESTROY(sc); Modified: stable/11/sys/arm/conf/RPI-B ============================================================================== --- stable/11/sys/arm/conf/RPI-B Sat Oct 22 15:26:32 2016 (r307775) +++ stable/11/sys/arm/conf/RPI-B Sat Oct 22 16:24:12 2016 (r307776) @@ -94,4 +94,4 @@ options FDT # Configure using FDT/DTB # handed to kernel via U-Boot and ubldr. #options FDT_DTB_STATIC #makeoptions FDT_DTS_FILE=rpi.dts -makeoptions MODULES_EXTRA=dtb/rpi +makeoptions MODULES_EXTRA="dtb/rpi rpi_ft5406" Modified: stable/11/sys/arm/conf/RPI2 ============================================================================== --- stable/11/sys/arm/conf/RPI2 Sat Oct 22 15:26:32 2016 (r307775) +++ stable/11/sys/arm/conf/RPI2 Sat Oct 22 16:24:12 2016 (r307776) @@ -98,4 +98,4 @@ options FDT # Configure using FDT/DTB # handed to kernel via U-Boot and ubldr. #options FDT_DTB_STATIC #makeoptions FDT_DTS_FILE=rpi2.dts -makeoptions MODULES_EXTRA=dtb/rpi +makeoptions MODULES_EXTRA="dtb/rpi rpi_ft5406" From owner-svn-src-stable@freebsd.org Sat Oct 22 16:38:41 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 75C96C1CFCC; Sat, 22 Oct 2016 16:38:41 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3638E3AF; Sat, 22 Oct 2016 16:38:41 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MGce7J015398; Sat, 22 Oct 2016 16:38:40 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MGcdXp015392; Sat, 22 Oct 2016 16:38:39 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610221638.u9MGcdXp015392@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 16:38:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307777 - in stable/11/sys/dev: evdev usb/input X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 16:38:41 -0000 Author: gonzo Date: Sat Oct 22 16:38:39 2016 New Revision: 307777 URL: https://svnweb.freebsd.org/changeset/base/307777 Log: MFC r306647, r306855, r306857 r306647: const-ify struct evdev_methods Submitted by: Vladimir Kondratiev Suggested by: hselasky r306855: Allow using of driver's mutex instead internal one for evdev locking. Add new API call: evdev_register_mtx which takes lock argument that should be used instead of internal one for evdev locking. Useful for cases if evdev_push_event() is always called with driver's lock taken and reduces amount of lock aquisitions. This allows to avoid LOR between ev_open/ev_close invocations and evdev_push_event() Such LOR can happen when ev_open/ev_close methods acquire driver lock and evdev_push_event() is called with this lock taken. Submitted by: Vladimir Kondratiev r306857: Implement EVDEV_FLAG_MT_AUTOREL flag (autorelease touchpoints) Automaticaly release (send ABS_MT_TRACKING_ID = -1) MT-slots that has not been listed in current MT protocol type B report. Slot is counted as listed if corresponding ABS_MT_SLOT event has been sent regardless of other MT events. Events are sent on SYN_REPORT event. Submitted by: Vladimir Kondratiev Modified: stable/11/sys/dev/evdev/evdev.c stable/11/sys/dev/evdev/evdev.h stable/11/sys/dev/evdev/evdev_mt.c stable/11/sys/dev/evdev/evdev_private.h stable/11/sys/dev/usb/input/ukbd.c stable/11/sys/dev/usb/input/ums.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/evdev/evdev.c ============================================================================== --- stable/11/sys/dev/evdev/evdev.c Sat Oct 22 16:24:12 2016 (r307776) +++ stable/11/sys/dev/evdev/evdev.c Sat Oct 22 16:38:39 2016 (r307777) @@ -187,8 +187,8 @@ evdev_estimate_report_size(struct evdev_ return (size); } -int -evdev_register(struct evdev_dev *evdev) +static int +evdev_register_common(struct evdev_dev *evdev) { int ret; @@ -196,7 +196,6 @@ evdev_register(struct evdev_dev *evdev) evdev->ev_shortname, evdev->ev_name, evdev->ev_serial); /* Initialize internal structures */ - mtx_init(&evdev->ev_mtx, "evmtx", NULL, MTX_DEF); LIST_INIT(&evdev->ev_clients); if (evdev_event_supported(evdev, EV_REP) && @@ -228,6 +227,19 @@ evdev_register(struct evdev_dev *evdev) /* Create char device node */ ret = evdev_cdev_create(evdev); bail_out: + return (ret); +} + +int +evdev_register(struct evdev_dev *evdev) +{ + int ret; + + evdev->ev_lock_type = EV_LOCK_INTERNAL; + evdev->ev_lock = &evdev->ev_mtx; + mtx_init(&evdev->ev_mtx, "evmtx", NULL, MTX_DEF); + + ret = evdev_register_common(evdev); if (ret != 0) mtx_destroy(&evdev->ev_mtx); @@ -235,6 +247,15 @@ bail_out: } int +evdev_register_mtx(struct evdev_dev *evdev, struct mtx *mtx) +{ + + evdev->ev_lock_type = EV_LOCK_MTX; + evdev->ev_lock = mtx; + return (evdev_register_common(evdev)); +} + +int evdev_unregister(struct evdev_dev *evdev) { struct evdev_client *client; @@ -257,7 +278,7 @@ evdev_unregister(struct evdev_dev *evdev /* destroy_dev can sleep so release lock */ ret = evdev_cdev_destroy(evdev); evdev->ev_cdev = NULL; - if (ret == 0) + if (ret == 0 && evdev->ev_lock_type == EV_LOCK_INTERNAL) mtx_destroy(&evdev->ev_mtx); evdev_free_absinfo(evdev->ev_absinfo); @@ -302,7 +323,7 @@ evdev_set_serial(struct evdev_dev *evdev inline void evdev_set_methods(struct evdev_dev *evdev, void *softc, - struct evdev_methods *methods) + const struct evdev_methods *methods) { evdev->ev_methods = methods; @@ -665,6 +686,8 @@ evdev_sparse_event(struct evdev_dev *evd case EV_SYN: if (code == SYN_REPORT) { + /* Count empty reports as well as non empty */ + evdev->ev_report_count++; /* Skip empty reports */ if (!evdev->ev_report_opened) return (EV_SKIP_EVENT); @@ -701,10 +724,7 @@ evdev_propagate_event(struct evdev_dev * EVDEV_CLIENT_UNLOCKQ(client); } - /* Update counters */ evdev->ev_event_count++; - if (type == EV_SYN && code == SYN_REPORT) - evdev->ev_report_count++; } void @@ -735,16 +755,24 @@ evdev_push_event(struct evdev_dev *evdev int32_t value) { + if (evdev->ev_lock_type != EV_LOCK_INTERNAL) + EVDEV_LOCK_ASSERT(evdev); + if (evdev_check_event(evdev, type, code, value) != 0) return (EINVAL); - EVDEV_LOCK(evdev); + if (evdev->ev_lock_type == EV_LOCK_INTERNAL) + EVDEV_LOCK(evdev); evdev_modify_event(evdev, type, code, &value); + if (type == EV_SYN && code == SYN_REPORT && + bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) + evdev_send_mt_autorel(evdev); if (type == EV_SYN && code == SYN_REPORT && evdev->ev_report_opened && bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_send_mt_compat(evdev); evdev_send_event(evdev, type, code, value); - EVDEV_UNLOCK(evdev); + if (evdev->ev_lock_type == EV_LOCK_INTERNAL) + EVDEV_UNLOCK(evdev); return (0); } Modified: stable/11/sys/dev/evdev/evdev.h ============================================================================== --- stable/11/sys/dev/evdev/evdev.h Sat Oct 22 16:24:12 2016 (r307776) +++ stable/11/sys/dev/evdev/evdev.h Sat Oct 22 16:38:39 2016 (r307777) @@ -70,6 +70,8 @@ extern int evdev_rcpt_mask; #define EVDEV_FLAG_SOFTREPEAT 0x00 /* use evdev to repeat keys */ #define EVDEV_FLAG_MT_STCOMPAT 0x01 /* autogenerate ST-compatible events * for MT protocol type B reports */ +#define EVDEV_FLAG_MT_AUTOREL 0x02 /* Autorelease MT-slots not listed in + * current MT protocol type B report */ #define EVDEV_FLAG_MAX 0x1F #define EVDEV_FLAG_CNT (EVDEV_FLAG_MAX + 1) @@ -89,8 +91,10 @@ void evdev_set_name(struct evdev_dev *, void evdev_set_id(struct evdev_dev *, uint16_t, uint16_t, uint16_t, uint16_t); void evdev_set_phys(struct evdev_dev *, const char *); void evdev_set_serial(struct evdev_dev *, const char *); -void evdev_set_methods(struct evdev_dev *, void *, struct evdev_methods *); +void evdev_set_methods(struct evdev_dev *, void *, + const struct evdev_methods *); int evdev_register(struct evdev_dev *); +int evdev_register_mtx(struct evdev_dev *, struct mtx *); int evdev_unregister(struct evdev_dev *); int evdev_push_event(struct evdev_dev *, uint16_t, uint16_t, int32_t); int evdev_sync(struct evdev_dev *); Modified: stable/11/sys/dev/evdev/evdev_mt.c ============================================================================== --- stable/11/sys/dev/evdev/evdev_mt.c Sat Oct 22 16:24:12 2016 (r307776) +++ stable/11/sys/dev/evdev/evdev_mt.c Sat Oct 22 16:38:39 2016 (r307777) @@ -112,6 +112,7 @@ void evdev_set_last_mt_slot(struct evdev_dev *evdev, int32_t slot) { + evdev->ev_mt->ev_mt_slots[slot].ev_report = evdev->ev_report_count; evdev->ev_mt->ev_mt_last_reported_slot = slot; } @@ -128,10 +129,6 @@ evdev_set_mt_value(struct evdev_dev *evd int32_t value) { - if (code == ABS_MT_TRACKING_ID && value == -1) - evdev->ev_mt->ev_mt_slots[slot].ev_report = - evdev->ev_report_count; - evdev->ev_mt->ev_mt_slots[slot].ev_mt_states[ABS_MT_INDEX(code)] = value; } @@ -227,9 +224,13 @@ void evdev_push_nfingers(struct evdev_dev *evdev, int32_t nfingers) { - EVDEV_LOCK(evdev); + if (evdev->ev_lock_type == EV_LOCK_INTERNAL) + EVDEV_LOCK(evdev); + else + EVDEV_LOCK_ASSERT(evdev); evdev_send_nfingers(evdev, nfingers); - EVDEV_UNLOCK(evdev); + if (evdev->ev_lock_type == EV_LOCK_INTERNAL) + EVDEV_UNLOCK(evdev); } void @@ -263,7 +264,29 @@ void evdev_push_mt_compat(struct evdev_dev *evdev) { - EVDEV_LOCK(evdev); + if (evdev->ev_lock_type == EV_LOCK_INTERNAL) + EVDEV_LOCK(evdev); + else + EVDEV_LOCK_ASSERT(evdev); evdev_send_mt_compat(evdev); - EVDEV_UNLOCK(evdev); + if (evdev->ev_lock_type == EV_LOCK_INTERNAL) + EVDEV_UNLOCK(evdev); +} + +void +evdev_send_mt_autorel(struct evdev_dev *evdev) +{ + int32_t slot; + + EVDEV_LOCK_ASSERT(evdev); + + for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { + if (evdev->ev_mt->ev_mt_slots[slot].ev_report != + evdev->ev_report_count && + evdev_get_mt_value(evdev, slot, ABS_MT_TRACKING_ID) != -1){ + evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); + evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, + -1); + } + } } Modified: stable/11/sys/dev/evdev/evdev_private.h ============================================================================== --- stable/11/sys/dev/evdev/evdev_private.h Sat Oct 22 16:24:12 2016 (r307776) +++ stable/11/sys/dev/evdev/evdev_private.h Sat Oct 22 16:38:39 2016 (r307777) @@ -71,6 +71,12 @@ enum evdev_clock_id EV_CLOCK_BOOTTIME /* monotonic, suspend-awared */ }; +enum evdev_lock_type +{ + EV_LOCK_INTERNAL = 0, /* Internal evdev mutex */ + EV_LOCK_MTX, /* Driver`s mutex */ +}; + struct evdev_dev { char ev_name[NAMELEN]; @@ -78,6 +84,8 @@ struct evdev_dev char ev_serial[NAMELEN]; struct cdev * ev_cdev; int ev_unit; + enum evdev_lock_type ev_lock_type; + struct mtx * ev_lock; struct mtx ev_mtx; struct input_id ev_id; struct evdev_client * ev_grabber; @@ -116,16 +124,16 @@ struct evdev_dev uint64_t ev_report_count; /* Parent driver callbacks: */ - struct evdev_methods * ev_methods; + const struct evdev_methods * ev_methods; void * ev_softc; LIST_ENTRY(evdev_dev) ev_link; LIST_HEAD(, evdev_client) ev_clients; }; -#define EVDEV_LOCK(evdev) mtx_lock(&(evdev)->ev_mtx) -#define EVDEV_UNLOCK(evdev) mtx_unlock(&(evdev)->ev_mtx) -#define EVDEV_LOCK_ASSERT(evdev) mtx_assert(&(evdev)->ev_mtx, MA_OWNED) +#define EVDEV_LOCK(evdev) mtx_lock((evdev)->ev_lock) +#define EVDEV_UNLOCK(evdev) mtx_unlock((evdev)->ev_lock) +#define EVDEV_LOCK_ASSERT(evdev) mtx_assert((evdev)->ev_lock, MA_OWNED) struct evdev_client { @@ -184,6 +192,7 @@ void evdev_set_last_mt_slot(struct evdev int32_t evdev_get_mt_value(struct evdev_dev *, int32_t, int16_t); void evdev_set_mt_value(struct evdev_dev *, int32_t, int16_t, int32_t); void evdev_send_mt_compat(struct evdev_dev *); +void evdev_send_mt_autorel(struct evdev_dev *); /* Utility functions: */ void evdev_client_dumpqueue(struct evdev_client *); Modified: stable/11/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/11/sys/dev/usb/input/ukbd.c Sat Oct 22 16:24:12 2016 (r307776) +++ stable/11/sys/dev/usb/input/ukbd.c Sat Oct 22 16:38:39 2016 (r307777) @@ -387,7 +387,7 @@ static device_detach_t ukbd_detach; static device_resume_t ukbd_resume; #ifdef EVDEV_SUPPORT -static struct evdev_methods ukbd_evdev_methods = { +static const struct evdev_methods ukbd_evdev_methods = { .ev_event = evdev_ev_kbd_event, }; #endif Modified: stable/11/sys/dev/usb/input/ums.c ============================================================================== --- stable/11/sys/dev/usb/input/ums.c Sat Oct 22 16:24:12 2016 (r307776) +++ stable/11/sys/dev/usb/input/ums.c Sat Oct 22 16:38:39 2016 (r307777) @@ -191,7 +191,7 @@ static struct usb_fifo_methods ums_fifo_ }; #ifdef EVDEV_SUPPORT -static struct evdev_methods ums_evdev_methods = { +static const struct evdev_methods ums_evdev_methods = { .ev_open = &ums_ev_open, .ev_close = &ums_ev_close, }; From owner-svn-src-stable@freebsd.org Sat Oct 22 16:42:50 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0190C1D1F5; Sat, 22 Oct 2016 16:42:50 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60557AB8; Sat, 22 Oct 2016 16:42:50 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MGgnDB019086; Sat, 22 Oct 2016 16:42:49 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MGgnQF019085; Sat, 22 Oct 2016 16:42:49 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610221642.u9MGgnQF019085@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sat, 22 Oct 2016 16:42:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307778 - stable/11/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 16:42:50 -0000 Author: gonzo Date: Sat Oct 22 16:42:49 2016 New Revision: 307778 URL: https://svnweb.freebsd.org/changeset/base/307778 Log: MFC r306860: Add multitouch support for RPi's FT5406 - Add multitouch support (protocol B) - Report physical size of the screen - Switch from using busy loop to callbacks - Enable callbacks only when there is active listener on /dev/input/eventX Submitted by: Vladimir Kondratiev Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Sat Oct 22 16:38:39 2016 (r307777) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Sat Oct 22 16:42:49 2016 (r307778) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -102,14 +101,20 @@ __FBSDID("$FreeBSD$"); (buf[FT5406_POINT_YL(n)])) #define GET_TOUCH_ID(buf, n) ((buf[FT5406_POINT_YH(n)] >> 4) & 0xf) -#define NO_POINTS 99 -#define SCREEN_WIDTH 800 -#define SCREEN_HEIGHT 480 +#define NO_POINTS 99 +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 480 +#define SCREEN_WIDTH_MM 155 +#define SCREEN_HEIGHT_MM 86 +#define SCREEN_RES_X (SCREEN_WIDTH / SCREEN_WIDTH_MM) +#define SCREEN_RES_Y (SCREEN_HEIGHT / SCREEN_HEIGHT_MM) +#define MAX_TOUCH_ID (10 - 1) struct ft5406ts_softc { device_t sc_dev; struct mtx sc_mtx; - struct proc *sc_worker; + int sc_tick; + struct callout sc_callout; /* mbox buffer (mapped to KVA) */ uint8_t *touch_buf; @@ -118,86 +123,76 @@ struct ft5406ts_softc { struct intr_config_hook sc_init_hook; struct evdev_dev *sc_evdev; - int sc_detaching; + + uint8_t sc_window[FT5406_WINDOW_SIZE]; +}; + +static evdev_open_t ft5406ts_ev_open; +static evdev_close_t ft5406ts_ev_close; + +static const struct evdev_methods ft5406ts_evdev_methods = { + .ev_open = &ft5406ts_ev_open, + .ev_close = &ft5406ts_ev_close, }; static void -ft5406ts_worker(void *data) +ft5406ts_callout(void *data) { struct ft5406ts_softc *sc = (struct ft5406ts_softc *)data; int points; - int id, new_x, new_y, i, new_pen_down, updated; - int x, y, pen_down; - uint8_t window[FT5406_WINDOW_SIZE]; - int tick; + int id, i, x, y; - /* 60Hz */ - tick = hz*17/1000; - if (tick == 0) - tick = 1; - - x = y = -1; - pen_down = 0; - - FT5406_LOCK(sc); - while(1) { - msleep(sc, &sc->sc_mtx, PCATCH | PZERO, "ft5406ts", tick); - - if (sc->sc_detaching) - break; - - memcpy(window, sc->touch_buf, sizeof(window)); - sc->touch_buf[FT5406_NUM_POINTS] = NO_POINTS; - - points = GET_NUM_POINTS(window); - /* - * No update from VC - do nothing - */ - if (points == NO_POINTS) - continue; + FT5406_LOCK_ASSERT(sc); - /* No points and pen is already up */ - if ((points == 0) && !pen_down) - continue; + memcpy(sc->sc_window, sc->touch_buf, FT5406_WINDOW_SIZE); + sc->touch_buf[FT5406_NUM_POINTS] = NO_POINTS; - new_pen_down = 0; - for (i = 0; i < points; i++) { - id = GET_TOUCH_ID(window, 0); - /* For now consider only touch 0 */ - if (id != 0) - continue; - new_pen_down = 1; - new_x = GET_X(window, 0); - new_y = GET_Y(window, 0); + points = GET_NUM_POINTS(sc->sc_window); + /* + * No update from VC - do nothing. + */ + if (points == NO_POINTS) + goto out; + + for (i = 0; i < points; i++) { + id = GET_TOUCH_ID(sc->sc_window, i); + x = GET_X(sc->sc_window, i); + y = GET_Y(sc->sc_window, i); + + if (id > MAX_TOUCH_ID) { + device_printf(sc->sc_dev, "bad touch id: %d", id); + continue; } + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_MT_SLOT, id); + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_MT_TRACKING_ID, id); + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_MT_POSITION_X, x); + evdev_push_event(sc->sc_evdev, EV_ABS, ABS_MT_POSITION_Y, y); + } + evdev_sync(sc->sc_evdev); +out: + callout_reset(&sc->sc_callout, sc->sc_tick, ft5406ts_callout, sc); +} - updated = 0; +static void +ft5406ts_ev_close(struct evdev_dev *evdev, void *data) +{ + struct ft5406ts_softc *sc = (struct ft5406ts_softc *)data; - if (new_x != x) { - x = new_x; - updated = 1; - } + FT5406_LOCK_ASSERT(sc); - if (new_y != y) { - y = new_y; - updated = 1; - } + callout_stop(&sc->sc_callout); +} - if (new_pen_down != pen_down) { - pen_down = new_pen_down; - updated = 1; - } +static int +ft5406ts_ev_open(struct evdev_dev *evdev, void *data) +{ + struct ft5406ts_softc *sc = (struct ft5406ts_softc *)data; - if (updated) { - evdev_push_event(sc->sc_evdev, EV_ABS, ABS_X, x); - evdev_push_event(sc->sc_evdev, EV_ABS, ABS_Y, y); - evdev_push_event(sc->sc_evdev, EV_KEY, BTN_TOUCH, pen_down); - evdev_sync(sc->sc_evdev); - } - } - FT5406_UNLOCK(sc); + FT5406_LOCK_ASSERT(sc); - kproc_exit(0); + callout_reset(&sc->sc_callout, sc->sc_tick, ft5406ts_callout, sc); + + return (0); } static void @@ -234,33 +229,40 @@ ft5406ts_init(void *arg) touchbuf = VCBUS_TO_PHYS(msg.body.resp.address); sc->touch_buf = (uint8_t*)pmap_mapdev(touchbuf, FT5406_WINDOW_SIZE); + /* 60Hz */ + sc->sc_tick = hz * 17 / 1000; + if (sc->sc_tick == 0) + sc->sc_tick = 1; + sc->sc_evdev = evdev_alloc(); evdev_set_name(sc->sc_evdev, device_get_desc(sc->sc_dev)); evdev_set_phys(sc->sc_evdev, device_get_nameunit(sc->sc_dev)); - evdev_set_id(sc->sc_evdev, BUS_VIRTUAL, 0, 0, 0); + evdev_set_id(sc->sc_evdev, BUS_HOST, 0, 0, 0); + evdev_set_methods(sc->sc_evdev, sc, &ft5406ts_evdev_methods); + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_STCOMPAT); + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_AUTOREL); evdev_support_prop(sc->sc_evdev, INPUT_PROP_DIRECT); evdev_support_event(sc->sc_evdev, EV_SYN); evdev_support_event(sc->sc_evdev, EV_ABS); - evdev_support_event(sc->sc_evdev, EV_KEY); - evdev_support_abs(sc->sc_evdev, ABS_X, 0, 0, - SCREEN_WIDTH, 0, 0, 0); - evdev_support_abs(sc->sc_evdev, ABS_Y, 0, 0, - SCREEN_HEIGHT, 0, 0, 0); + evdev_support_abs(sc->sc_evdev, ABS_MT_SLOT, 0, 0, + MAX_TOUCH_ID, 0, 0, 0); + evdev_support_abs(sc->sc_evdev, ABS_MT_TRACKING_ID, 0, -1, + MAX_TOUCH_ID, 0, 0, 0); + evdev_support_abs(sc->sc_evdev, ABS_MT_POSITION_X, 0, 0, + SCREEN_WIDTH, 0, 0, SCREEN_RES_X); + evdev_support_abs(sc->sc_evdev, ABS_MT_POSITION_Y, 0, 0, + SCREEN_HEIGHT, 0, 0, SCREEN_RES_Y); - evdev_support_key(sc->sc_evdev, BTN_TOUCH); - - err = evdev_register(sc->sc_evdev); + err = evdev_register_mtx(sc->sc_evdev, &sc->sc_mtx); if (err) { evdev_free(sc->sc_evdev); + sc->sc_evdev = NULL; /* Avoid double free */ return; } sc->touch_buf[FT5406_NUM_POINTS] = NO_POINTS; - if (kproc_create(ft5406ts_worker, (void*)sc, &sc->sc_worker, 0, 0, - "ft5406ts_worker") != 0) { - printf("failed to create ft5406ts_worker\n"); - } + callout_init_mtx(&sc->sc_callout, &sc->sc_mtx, 0); } static int @@ -292,6 +294,7 @@ ft5406ts_attach(device_t dev) if (config_intrhook_establish(&sc->sc_init_hook) != 0) { device_printf(dev, "config_intrhook_establish failed\n"); + FT5406_LOCK_DESTROY(sc); return (ENOMEM); } @@ -305,14 +308,7 @@ ft5406ts_detach(device_t dev) sc = device_get_softc(dev); - FT5406_LOCK(sc); - if (sc->sc_worker) - sc->sc_detaching = 1; - wakeup(sc); - FT5406_UNLOCK(sc); - - if (sc->sc_evdev) - evdev_free(sc->sc_evdev); + evdev_free(sc->sc_evdev); FT5406_LOCK_DESTROY(sc); From owner-svn-src-stable@freebsd.org Sat Oct 22 20:39:19 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D3280C1D4C5; Sat, 22 Oct 2016 20:39:19 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 90E4EE45; Sat, 22 Oct 2016 20:39:19 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKdIV6006766; Sat, 22 Oct 2016 20:39:18 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKdI1n006763; Sat, 22 Oct 2016 20:39:18 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222039.u9MKdI1n006763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:39:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307788 - in stable/11: tools/build/mk usr.sbin usr.sbin/etcupdate X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:39:19 -0000 Author: bapt Date: Sat Oct 22 20:39:18 2016 New Revision: 307788 URL: https://svnweb.freebsd.org/changeset/base/307788 Log: MFC r303784, r303785, r305620: r303784: etcupdate: directly use diff3(1) instead of merge(1) During the last attempt to rmeove GNU rcs, 2 blockers were spotted: We need an ident(1) and etcupdate(8) uses merge(1). Now nothing should prevent to remove rcs from base Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D7401 r303785: always install etcupdate Now that etcupdate does not depend on rcs anymore there is no need to conditionnally install it r305620: (by vangyzen ) etcupdate: preserve the metadata of the destination file When using diff3 to perform a three-way merge, etcupdate lost the destination file's metadata. The metadata from the temporary file were used instead. This was unpleasant for rc.d scripts, which require execute permission. Use "cat >" to overwrite the destination file's contents while preserving its metadata. Reviewed by: bapt Sponsored by: Dell Technologies Differential Revision: https://reviews.freebsd.org/D7817 Modified: stable/11/tools/build/mk/OptionalObsoleteFiles.inc stable/11/usr.sbin/Makefile stable/11/usr.sbin/etcupdate/etcupdate.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/11/tools/build/mk/OptionalObsoleteFiles.inc Sat Oct 22 20:00:39 2016 (r307787) +++ stable/11/tools/build/mk/OptionalObsoleteFiles.inc Sat Oct 22 20:39:18 2016 (r307788) @@ -6800,7 +6800,6 @@ OLD_FILES+=usr/bin/rcsdiff OLD_FILES+=usr/bin/rcsfreeze OLD_FILES+=usr/bin/rcsmerge OLD_FILES+=usr/bin/rlog -OLD_FILES+=usr/sbin/etcupdate OLD_FILES+=usr/share/man/man1/ci.1.gz OLD_FILES+=usr/share/man/man1/co.1.gz OLD_FILES+=usr/share/man/man1/merge.1.gz @@ -6812,16 +6811,6 @@ OLD_FILES+=usr/share/man/man1/rcsintro.1 OLD_FILES+=usr/share/man/man1/rcsmerge.1.gz OLD_FILES+=usr/share/man/man1/rlog.1.gz OLD_FILES+=usr/share/man/man5/rcsfile.5.gz -OLD_FILES+=usr/share/man/man8/etcupdate.8.gz -OLD_FILES+=usr/tests/usr.sbin/etcupdate/Kyuafile -OLD_FILES+=usr/tests/usr.sbin/etcupdate/always_test -OLD_FILES+=usr/tests/usr.sbin/etcupdate/conflicts_test -OLD_FILES+=usr/tests/usr.sbin/etcupdate/fbsdid_test -OLD_FILES+=usr/tests/usr.sbin/etcupdate/ignore_test -OLD_FILES+=usr/tests/usr.sbin/etcupdate/preworld_test -OLD_FILES+=usr/tests/usr.sbin/etcupdate/tests_test -OLD_FILES+=usr/tests/usr.sbin/etcupdate/tzsetup_test -OLD_DIRS+=usr/tests/usr.sbin/etcupdate .endif #.if ${MK_RESCUE} == no Modified: stable/11/usr.sbin/Makefile ============================================================================== --- stable/11/usr.sbin/Makefile Sat Oct 22 20:00:39 2016 (r307787) +++ stable/11/usr.sbin/Makefile Sat Oct 22 20:39:18 2016 (r307788) @@ -25,6 +25,7 @@ SUBDIR= adduser \ digictl \ diskinfo \ dumpcis \ + etcupdate \ extattr \ extattrctl \ fifolog \ @@ -188,7 +189,6 @@ SUBDIR.${MK_QUOTAS}+= edquota SUBDIR.${MK_QUOTAS}+= quotaon SUBDIR.${MK_QUOTAS}+= repquota SUBDIR.${MK_RCMDS}+= rwhod -SUBDIR.${MK_RCS}+= etcupdate SUBDIR.${MK_SENDMAIL}+= editmap SUBDIR.${MK_SENDMAIL}+= mailstats SUBDIR.${MK_SENDMAIL}+= makemap Modified: stable/11/usr.sbin/etcupdate/etcupdate.sh ============================================================================== --- stable/11/usr.sbin/etcupdate/etcupdate.sh Sat Oct 22 20:00:39 2016 (r307787) +++ stable/11/usr.sbin/etcupdate/etcupdate.sh Sat Oct 22 20:39:18 2016 (r307788) @@ -814,15 +814,19 @@ merge_file() local res # Try the merge to see if there is a conflict. - merge -q -p ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 >/dev/null 2>&3 + diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > /dev/null 2>&3 res=$? case $res in 0) # No conflicts, so just redo the merge to the # real file. - log "merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1" + log "diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1" if [ -z "$dryrun" ]; then - merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 + temp=$(mktemp -t etcupdate) + diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > ${temp} + # Use "cat >" to preserve metadata. + cat ${temp} > ${DESTDIR}$1 + rm -f ${temp} fi post_install_file $1 echo " M $1" @@ -832,10 +836,10 @@ merge_file() # the conflicts directory. if [ -z "$dryrun" ]; then install_dirs $NEWTREE $CONFLICTS $1 - log "cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1" - cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1 >&3 2>&1 - merge -A -q -L "yours" -L "original" -L "new" \ - ${CONFLICTS}$1 ${OLDTREE}$1 ${NEWTREE}$1 + log "diff3 -m -A ${DESTDIR}$1 ${CONFLICTS}$1" + diff3 -m -A -L "yours" -L "original" -L "new" \ + ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > \ + ${CONFLICTS}$1 fi echo " C $1" ;; From owner-svn-src-stable@freebsd.org Sat Oct 22 20:46:58 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A84F5C1D7AC; Sat, 22 Oct 2016 20:46:58 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7FCCD65F; Sat, 22 Oct 2016 20:46:58 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKkvC2010478; Sat, 22 Oct 2016 20:46:57 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKkvmW010477; Sat, 22 Oct 2016 20:46:57 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222046.u9MKkvmW010477@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:46:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307789 - stable/11/usr.bin/sdiff X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:46:58 -0000 Author: bapt Date: Sat Oct 22 20:46:57 2016 New Revision: 307789 URL: https://svnweb.freebsd.org/changeset/base/307789 Log: MFC r303783, r305927: r303783: sdiff: remove non finish/function code 2 extra options not available neither on other BSD nor in GNU sdiff: --diff-pid and --pipe-fd were present in the SoC code, none were usable Just remove it r305927: Remove reference of z(s)diff which was dropped before importing Modified: stable/11/usr.bin/sdiff/sdiff.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/sdiff/sdiff.c ============================================================================== --- stable/11/usr.bin/sdiff/sdiff.c Sat Oct 22 20:39:18 2016 (r307788) +++ stable/11/usr.bin/sdiff/sdiff.c Sat Oct 22 20:46:57 2016 (r307789) @@ -104,9 +104,6 @@ enum { HLINES_OPT, LFILES_OPT, DIFFPROG_OPT, - PIPE_FD, - /* pid from the diff parent (if applicable) */ - DIFF_PID, NOOP_OPT, }; @@ -120,8 +117,6 @@ static struct option longopts[] = { { "output", required_argument, NULL, 'o' }, { "diff-program", required_argument, NULL, DIFFPROG_OPT }, - { "pipe-fd", required_argument, NULL, PIPE_FD }, - { "diff-pid", required_argument, NULL, DIFF_PID }, /* Options processed by diff. */ { "ignore-file-name-case", no_argument, NULL, FCASE_IGNORE_OPT }, { "no-ignore-file-name-case", no_argument, NULL, FCASE_SENSITIVE_OPT }, @@ -237,7 +232,7 @@ main(int argc, char **argv) FILE *diffpipe=NULL, *file1, *file2; size_t diffargc = 0, wflag = WIDTH; int ch, fd[2] = {-1}, status; - pid_t pid=0; pid_t ppid =-1; + pid_t pid=0; const char *outfile = NULL; struct option *popt; char **diffargv, *diffprog = DIFF_PATH, *filename1, *filename2, @@ -320,11 +315,6 @@ main(int argc, char **argv) if (errstr) errx(2, "width is %s: %s", errstr, optarg); break; - case DIFF_PID: - ppid = strtonum(optarg, 0, INT_MAX, &errstr); - if (errstr) - errx(2, "diff pid value is %s: %s", errstr, optarg); - break; case HELP_OPT: for (i = 0; help_msg[i] != NULL; i++) printf("%s\n", help_msg[i]); @@ -393,35 +383,34 @@ main(int argc, char **argv) errx(2, "width is too large: %zu", width); line_width = width * 2 + 3; - if (ppid == -1 ) { - if (pipe(fd)) - err(2, "pipe"); - - switch (pid = fork()) { - case 0: - /* child */ - /* We don't read from the pipe. */ - close(fd[0]); - if (dup2(fd[1], STDOUT_FILENO) == -1) - err(2, "child could not duplicate descriptor"); - /* Free unused descriptor. */ - close(fd[1]); - execvp(diffprog, diffargv); - err(2, "could not execute diff: %s", diffprog); - break; - case -1: - err(2, "could not fork"); - break; - } + if (pipe(fd)) + err(2, "pipe"); - /* parent */ - /* We don't write to the pipe. */ + switch (pid = fork()) { + case 0: + /* child */ + /* We don't read from the pipe. */ + close(fd[0]); + if (dup2(fd[1], STDOUT_FILENO) == -1) + err(2, "child could not duplicate descriptor"); + /* Free unused descriptor. */ close(fd[1]); - - /* Open pipe to diff command. */ - if ((diffpipe = fdopen(fd[0], "r")) == NULL) - err(2, "could not open diff pipe"); + execvp(diffprog, diffargv); + err(2, "could not execute diff: %s", diffprog); + break; + case -1: + err(2, "could not fork"); + break; } + + /* parent */ + /* We don't write to the pipe. */ + close(fd[1]); + + /* Open pipe to diff command. */ + if ((diffpipe = fdopen(fd[0], "r")) == NULL) + err(2, "could not open diff pipe"); + if ((file1 = fopen(filename1, "r")) == NULL) err(2, "could not open %s", filename1); if ((file2 = fopen(filename2, "r")) == NULL) @@ -489,8 +478,8 @@ main(int argc, char **argv) } /* - * When sdiff/zsdiff detects a binary file as input, executes them with - * diff/zdiff to maintain the same behavior as GNU sdiff with binary input. + * When sdiff detects a binary file as input, executes them with + * diff to maintain the same behavior as GNU sdiff with binary input. */ static void binexec(char *diffprog, char *f1, char *f2) From owner-svn-src-stable@freebsd.org Sat Oct 22 20:49:09 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFE6EC1D915; Sat, 22 Oct 2016 20:49:09 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7BD9A916; Sat, 22 Oct 2016 20:49:09 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKn8MP010624; Sat, 22 Oct 2016 20:49:08 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKn7ow010611; Sat, 22 Oct 2016 20:49:07 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222049.u9MKn7ow010611@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:49:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307790 - in stable/11/contrib/libucl: . haskell include m4 python python/src python/tests src tests/schema X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:49:09 -0000 Author: bapt Date: Sat Oct 22 20:49:07 2016 New Revision: 307790 URL: https://svnweb.freebsd.org/changeset/base/307790 Log: MFC r306544: Import libucl 20160812 Added: stable/11/contrib/libucl/haskell/ - copied from r306544, head/contrib/libucl/haskell/ stable/11/contrib/libucl/m4/gcov.m4 - copied unchanged from r306544, head/contrib/libucl/m4/gcov.m4 stable/11/contrib/libucl/python/tests/ - copied from r306544, head/contrib/libucl/python/tests/ Deleted: stable/11/contrib/libucl/python/test.sh stable/11/contrib/libucl/python/test_uclmodule.py Modified: stable/11/contrib/libucl/CMakeLists.txt stable/11/contrib/libucl/Makefile.unix stable/11/contrib/libucl/Makefile.w32 stable/11/contrib/libucl/README.md stable/11/contrib/libucl/include/ucl++.h stable/11/contrib/libucl/include/ucl.h stable/11/contrib/libucl/python/setup.py stable/11/contrib/libucl/python/src/uclmodule.c stable/11/contrib/libucl/src/ucl_parser.c stable/11/contrib/libucl/src/ucl_schema.c stable/11/contrib/libucl/src/ucl_util.c stable/11/contrib/libucl/tests/schema/patternProperties.json stable/11/contrib/libucl/tests/schema/refRemote.json Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/libucl/CMakeLists.txt ============================================================================== --- stable/11/contrib/libucl/CMakeLists.txt Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/CMakeLists.txt Sat Oct 22 20:49:07 2016 (r307790) @@ -205,8 +205,7 @@ SET(UCLSRC src/ucl_util.c src/ucl_hash.c src/ucl_schema.c src/ucl_msgpack.c - src/ucl_sexp.c - src/xxhash.c) + src/ucl_sexp.c) SET (LIB_TYPE STATIC) Modified: stable/11/contrib/libucl/Makefile.unix ============================================================================== --- stable/11/contrib/libucl/Makefile.unix Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/Makefile.unix Sat Oct 22 20:49:07 2016 (r307790) @@ -1,7 +1,7 @@ CC ?= gcc DESTDIR ?= /usr/local LD ?= gcc -C_COMMON_FLAGS ?= -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./uthash -I./src +C_COMMON_FLAGS ?= -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./uthash -I./src -I./klib MAJOR_VERSION = 0 MINOR_VERSION = 2 PATCH_VERSION = 9 @@ -25,13 +25,12 @@ HDEPS = $(SRCDIR)/ucl_hash.h \ $(SRCDIR)/ucl_chartable.h \ $(SRCDIR)/ucl_internal.h \ $(INCLUDEDIR)/ucl.h \ - $(SRCDIR)/xxhash.h + $(SRCDIR)/mum.h OBJECTS = $(OBJDIR)/ucl_hash.o \ $(OBJDIR)/ucl_util.o \ $(OBJDIR)/ucl_parser.o \ $(OBJDIR)/ucl_emitter.o \ - $(OBJDIR)/ucl_schema.o \ - $(OBJDIR)/xxhash.o + $(OBJDIR)/ucl_schema.o all: $(OBJDIR) $(OBJDIR)/$(SONAME) @@ -55,8 +54,6 @@ $(OBJDIR)/ucl_hash.o: $(SRCDIR)/ucl_hash $(CC) -o $(OBJDIR)/ucl_hash.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_hash.c $(OBJDIR)/ucl_schema.o: $(SRCDIR)/ucl_schema.c $(HDEPS) $(CC) -o $(OBJDIR)/ucl_schema.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/ucl_schema.c -$(OBJDIR)/xxhash.o: $(SRCDIR)/xxhash.c $(HDEPS) - $(CC) -o $(OBJDIR)/xxhash.o $(CPPFLAGS) $(COPT_FLAGS) $(CFLAGS) $(C_COMMON_FLAGS) $(SSL_CFLAGS) $(FETCH_FLAGS) -c $(SRCDIR)/xxhash.c clean: $(RM) $(OBJDIR)/*.o $(OBJDIR)/$(SONAME_FULL) $(OBJDIR)/$(SONAME) $(OBJDIR)/chargen $(OBJDIR)/test_basic $(OBJDIR)/test_speed $(OBJDIR)/objdump $(OBJDIR)/test_generate $(OBJDIR)/test_schema || true Modified: stable/11/contrib/libucl/Makefile.w32 ============================================================================== --- stable/11/contrib/libucl/Makefile.w32 Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/Makefile.w32 Sat Oct 22 20:49:07 2016 (r307790) @@ -28,14 +28,13 @@ HDEPS = $(SRCDIR)/ucl_hash.h \ $(SRCDIR)/ucl_chartable.h \ $(SRCDIR)/ucl_internal.h \ $(INCLUDEDIR)/ucl.h \ - $(SRCDIR)/xxhash.h + $(SRCDIR)/mum.h OBJECTS = $(OBJDIR)/ucl_hash.o \ $(OBJDIR)/ucl_util.o \ $(OBJDIR)/ucl_parser.o \ $(OBJDIR)/ucl_emitter.o \ $(OBJDIR)/ucl_emitter_utils.o \ - $(OBJDIR)/ucl_schema.o \ - $(OBJDIR)/xxhash.o + $(OBJDIR)/ucl_schema.o all: $(OBJDIR) $(OBJDIR)/$(SONAME) Modified: stable/11/contrib/libucl/README.md ============================================================================== --- stable/11/contrib/libucl/README.md Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/README.md Sat Oct 22 20:49:07 2016 (r307790) @@ -12,7 +12,7 @@ - [Named keys hierarchy](#named-keys-hierarchy) - [Convenient numbers and booleans](#convenient-numbers-and-booleans) - [General improvements](#general-improvements) - - [Commments](#commments) + - [Comments](#comments) - [Macros support](#macros-support) - [Variables support](#variables-support) - [Multiline strings](#multiline-strings) @@ -21,7 +21,7 @@ - [Performance](#performance) - [Conclusion](#conclusion) -## Introduction +## Introduction This document describes the main features and principles of the configuration language called `UCL` - universal configuration language. @@ -47,7 +47,7 @@ section { string = "something"; subsection { host = { - host = "hostname"; + host = "hostname"; port = 900; } host = { @@ -163,9 +163,9 @@ section { } } ``` - + Plain definitions may be more complex and contain more than a single level of nested objects: - + ```nginx section "blah" "foo" { key = value; @@ -174,7 +174,7 @@ section "blah" "foo" { is presented as: -```nginx +```nginx section { blah { foo { @@ -196,17 +196,17 @@ section { ## General improvements -### Commments +### Comments UCL supports different style of comments: -* single line: `#` +* single line: `#` * multiline: `/* ... */` Multiline comments may be nested: ```c # Sample single line comment -/* +/* some comment /* nested comment */ end of comment @@ -263,7 +263,7 @@ all files that matches the specified pat for your operating system). This option is meaningless for URL includes. * `url` (default: **true**) - allow URL includes. * `path` (default: empty) - A UCL_ARRAY of directories to search for the include file. -Search ends after the first patch, unless `glob` is true, then all matches are included. +Search ends after the first match, unless `glob` is true, then all matches are included. * `prefix` (default false) - Put included contents inside an object, instead of loading them into the root. If no `key` is provided, one is automatically generated based on each files basename() * `key` (default: ) - Key to load contents of include into. If @@ -273,7 +273,7 @@ object or an array. * `priority` (default: 0) - specify priority for the include (see below). * `duplicate` (default: 'append') - specify policy of duplicates resolving: - `append` - default strategy, if we have new object of higher priority then it replaces old one, if we have new object with less priority it is ignored completely, and if we have two duplicate objects with the same priority then we have a multi-value key (implicit array) - - `merge` - if we have object or array, then new keys are merged inside, if we have a plain object then an implicit array is formed (regardeless of priorities) + - `merge` - if we have object or array, then new keys are merged inside, if we have a plain object then an implicit array is formed (regardless of priorities) - `error` - create error on duplicate keys and stop parsing - `rewrite` - always rewrite an old value with new one (ignoring priorities) @@ -320,7 +320,7 @@ Here are some rules for this syntax: * Multiline terminator must start just after `<<` symbols and it must consist of capital letters only (e.g. `< +#include +#include +#include #include #include @@ -100,6 +103,68 @@ private: return func; }; + static bool ucl_variable_getter(const unsigned char *data, size_t len, + unsigned char ** /*replace*/, size_t * /*replace_len*/, bool *need_free, void* ud) + { + *need_free = false; + + auto vars = reinterpret_cast *>(ud); + if (vars && data && len != 0) { + vars->emplace (data, data + len); + } + return false; + } + + static bool ucl_variable_replacer (const unsigned char *data, size_t len, + unsigned char **replace, size_t *replace_len, bool *need_free, void* ud) + { + *need_free = false; + + auto replacer = reinterpret_cast(ud); + if (!replacer) { + return false; + } + + std::string var_name (data, data + len); + if (!replacer->is_variable (var_name)) { + return false; + } + + std::string var_value = replacer->replace (var_name); + if (var_value.empty ()) { + return false; + } + + *replace = (unsigned char *)UCL_ALLOC (var_value.size ()); + memcpy (*replace, var_value.data (), var_value.size ()); + + *replace_len = var_value.size (); + *need_free = true; + + return true; + } + + template + static Ucl parse_with_strategy_function (C config_func, P parse_func, std::string &err) + { + auto parser = ucl_parser_new (UCL_PARSER_DEFAULT); + + config_func (parser); + + if (!parse_func (parser)) { + err.assign (ucl_parser_get_error (parser)); + ucl_parser_free (parser); + + return nullptr; + } + + auto obj = ucl_parser_get_object (parser); + ucl_parser_free (parser); + + // Obj will handle ownership + return Ucl (obj); + } + std::unique_ptr obj; public: @@ -117,9 +182,9 @@ public: const_iterator(const Ucl &obj) { it = std::shared_ptr(ucl_object_iterate_new (obj.obj.get()), - ucl_iter_deleter()); + ucl_iter_deleter()); cur.reset (new Ucl(ucl_object_iterate_safe (it.get(), true))); - if (!*cur) { + if (cur->type() == UCL_NULL) { it.reset (); cur.reset (); } @@ -153,7 +218,7 @@ public: cur.reset (new Ucl(ucl_object_iterate_safe (it.get(), true))); } - if (!*cur) { + if (cur && cur->type() == UCL_NULL) { it.reset (); cur.reset (); } @@ -171,6 +236,17 @@ public: } }; + struct variable_replacer { + virtual ~variable_replacer() {} + + virtual bool is_variable (const std::string &str) const + { + return !str.empty (); + } + + virtual std::string replace (const std::string &var) const = 0; + }; + // We grab ownership if get non-const ucl_object_t Ucl(ucl_object_t *other) { obj.reset (other); @@ -211,20 +287,20 @@ public: obj.reset (ucl_object_fromstring_common (value.data (), value.size (), UCL_STRING_RAW)); } - Ucl(const char * value) { + Ucl(const char *value) { obj.reset (ucl_object_fromstring_common (value, 0, UCL_STRING_RAW)); } // Implicit constructor: anything with a to_json() function. template - Ucl(const T & t) : Ucl(t.to_ucl()) {} + Ucl(const T &t) : Ucl(t.to_ucl()) {} // Implicit constructor: map-like objects (std::map, std::unordered_map, etc) template ::value && std::is_constructible::value, int>::type = 0> - Ucl(const M & m) { + Ucl(const M &m) { obj.reset (ucl_object_typed_new (UCL_OBJECT)); auto cobj = obj.get (); @@ -238,7 +314,7 @@ public: template ::value, int>::type = 0> - Ucl(const V & v) { + Ucl(const V &v) { obj.reset (ucl_object_typed_new (UCL_ARRAY)); auto cobj = obj.get (); @@ -356,46 +432,138 @@ public: return out; } - static Ucl parse (const std::string & in, std::string & err) + static Ucl parse (const std::string &in, std::string &err) { - auto parser = ucl_parser_new (UCL_PARSER_DEFAULT); + return parse (in, std::map(), err); + } - if (!ucl_parser_add_chunk (parser, (const unsigned char *)in.data (), - in.size ())) { - err.assign (ucl_parser_get_error (parser)); - ucl_parser_free (parser); + static Ucl parse (const std::string &in, const std::map &vars, std::string &err) + { + auto config_func = [&vars] (ucl_parser *parser) { + for (const auto & item : vars) { + ucl_parser_register_variable (parser, item.first.c_str (), item.second.c_str ()); + } + }; + + auto parse_func = [&in] (ucl_parser *parser) { + return ucl_parser_add_chunk (parser, (unsigned char *)in.data (), in.size ()); + }; + + return parse_with_strategy_function (config_func, parse_func, err); + } + static Ucl parse (const std::string &in, const variable_replacer &replacer, std::string &err) + { + auto config_func = [&replacer] (ucl_parser *parser) { + ucl_parser_set_variables_handler (parser, ucl_variable_replacer, + &const_cast(replacer)); + }; + + auto parse_func = [&in] (ucl_parser *parser) { + return ucl_parser_add_chunk (parser, (unsigned char *) in.data (), in.size ()); + }; + + return parse_with_strategy_function (config_func, parse_func, err); + } + + static Ucl parse (const char *in, std::string &err) + { + return parse (in, std::map(), err); + } + + static Ucl parse (const char *in, const std::map &vars, std::string &err) + { + if (!in) { + err = "null input"; return nullptr; } + return parse (std::string (in), vars, err); + } - auto obj = ucl_parser_get_object (parser); + static Ucl parse (const char *in, const variable_replacer &replacer, std::string &err) + { + if (!in) { + err = "null input"; + return nullptr; + } + return parse (std::string(in), replacer, err); + } + + static Ucl parse_from_file (const std::string &filename, std::string &err) + { + return parse_from_file (filename, std::map(), err); + } + + static Ucl parse_from_file (const std::string &filename, const std::map &vars, std::string &err) + { + auto config_func = [&vars] (ucl_parser *parser) { + for (const auto & item : vars) { + ucl_parser_register_variable (parser, item.first.c_str (), item.second.c_str ()); + } + }; + + auto parse_func = [&filename] (ucl_parser *parser) { + return ucl_parser_add_file (parser, filename.c_str ()); + }; + + return parse_with_strategy_function (config_func, parse_func, err); + } + + static Ucl parse_from_file (const std::string &filename, const variable_replacer &replacer, std::string &err) + { + auto config_func = [&replacer] (ucl_parser *parser) { + ucl_parser_set_variables_handler (parser, ucl_variable_replacer, + &const_cast(replacer)); + }; + + auto parse_func = [&filename] (ucl_parser *parser) { + return ucl_parser_add_file (parser, filename.c_str ()); + }; + + return parse_with_strategy_function (config_func, parse_func, err); + } + + static std::vector find_variable (const std::string &in) + { + auto parser = ucl_parser_new (UCL_PARSER_DEFAULT); + + std::set vars; + ucl_parser_set_variables_handler (parser, ucl_variable_getter, &vars); + ucl_parser_add_chunk (parser, (const unsigned char *)in.data (), in.size ()); ucl_parser_free (parser); - // Obj will handle ownership - return Ucl (obj); + std::vector result; + std::move (vars.begin (), vars.end (), std::back_inserter (result)); + return result; } - static Ucl parse (const char * in, std::string & err) + static std::vector find_variable (const char *in) { - if (in) { - return parse (std::string(in), err); - } else { - err = "null input"; - return nullptr; + if (!in) { + return std::vector(); } + return find_variable (std::string (in)); } - static Ucl parse (std::istream &ifs, std::string &err) + static std::vector find_variable_from_file (const std::string &filename) { - return Ucl::parse (std::string(std::istreambuf_iterator(ifs), - std::istreambuf_iterator()), err); + auto parser = ucl_parser_new (UCL_PARSER_DEFAULT); + + std::set vars; + ucl_parser_set_variables_handler (parser, ucl_variable_getter, &vars); + ucl_parser_add_file (parser, filename.c_str ()); + ucl_parser_free (parser); + + std::vector result; + std::move (vars.begin (), vars.end (), std::back_inserter (result)); + return std::move (result); } - Ucl& operator= (Ucl rhs) - { - obj.swap (rhs.obj); - return *this; - } + Ucl& operator= (Ucl rhs) + { + obj.swap (rhs.obj); + return *this; + } bool operator== (const Ucl &rhs) const { Modified: stable/11/contrib/libucl/include/ucl.h ============================================================================== --- stable/11/contrib/libucl/include/ucl.h Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/include/ucl.h Sat Oct 22 20:49:07 2016 (r307790) @@ -1016,7 +1016,6 @@ UCL_EXTERN bool ucl_parser_add_string_pr * Load and add data from a file * @param parser parser structure * @param filename the name of file - * @param err if *err is NULL it is set to parser error * @return true if chunk has been added and false in case of error */ UCL_EXTERN bool ucl_parser_add_file (struct ucl_parser *parser, @@ -1026,7 +1025,6 @@ UCL_EXTERN bool ucl_parser_add_file (str * Load and add data from a file * @param parser parser structure * @param filename the name of file - * @param err if *err is NULL it is set to parser error * @param priority the desired priority of a chunk (only 4 least significant bits * are considered for this parameter) * @return true if chunk has been added and false in case of error @@ -1035,6 +1033,20 @@ UCL_EXTERN bool ucl_parser_add_file_prio const char *filename, unsigned priority); /** + * Load and add data from a file + * @param parser parser structure + * @param filename the name of file + * @param priority the desired priority of a chunk (only 4 least significant bits + * are considered for this parameter) + * @param strat Merge strategy to use while parsing this file + * @param parse_type Parser type to use while parsing this file + * @return true if chunk has been added and false in case of error + */ +UCL_EXTERN bool ucl_parser_add_file_full (struct ucl_parser *parser, const char *filename, + unsigned priority, enum ucl_duplicate_strategy strat, + enum ucl_parse_type parse_type); + +/** * Load and add data from a file descriptor * @param parser parser structure * @param filename the name of file Copied: stable/11/contrib/libucl/m4/gcov.m4 (from r306544, head/contrib/libucl/m4/gcov.m4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/libucl/m4/gcov.m4 Sat Oct 22 20:49:07 2016 (r307790, copy of r306544, head/contrib/libucl/m4/gcov.m4) @@ -0,0 +1,89 @@ +# SYNOPSIS +# +# Add code coverage support with gcov/lcov. +# +# AX_CODE_COVERAGE() +# +# DESCRIPTION +# +# Provides a --enable-coverage option which checks for available +# gcov/lcov binaries and provides ENABLE_CODE_COVERAGE conditional. +# +# LAST MODIFICATION +# +# $Id: coverage.m4 40881 2013-08-20 17:54:39Z damon $ +# +# COPYLEFT +# +# Copyright (c) 2012 Roy H. Stogner +# Copyright (c) 2010 Karl W. Schulz +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. + +AC_DEFUN([AX_CODE_COVERAGE], +[ + +AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage],[configure code coverage analysis tools])) + +HAVE_GCOV_TOOLS=0 + +GCOV_FLAGS="" + +if test "x$enable_coverage" = "xyes"; then + + # ---------------------------- + # Check for gcov/lcov binaries + # ---------------------------- + + AC_ARG_VAR([GCOV], [Coverage testing command]) + if test "x$GCOV" = "x"; then + AC_PATH_PROG(GCOV, gcov, no) + else + AC_PATH_PROG(GCOV, $GCOV, no) + fi + + AC_PATH_PROG(LCOV, lcov, no) + AC_PATH_PROG(GENHTML, genhtml) + + # ---------------------------------- + # include coverage compiler options + # ---------------------------------- + AC_MSG_CHECKING([for clang]) + + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [[ + #ifndef __clang__ + not clang + #endif + ]])], + [CLANG=yes], [CLANG=no]) + + AC_MSG_RESULT([$CLANG]) + HAVE_GCOV_TOOLS=1 + COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage" + COVERAGE_LDFLAGS="--coverage -fprofile-arcs -ftest-coverage" + COVERAGE_OPTFLAGS="-O0" + + # Test for C... + CFLAGS="${GCOV_FLAGS} ${CFLAGS}" + CXXFLAGS="${GCOV_FLAGS} ${CXXFLAGS}" + if test "x$GCC" = "xyes" -a "x$CLANG" = "xno"; then + COVERAGE_LIBS="-lgcov" + else + COVERAGE_LIBS="" + fi +fi + +AC_SUBST([GCOV]) +AC_SUBST([LCOV]) +AC_SUBST([GENHTML]) +AC_SUBST([GENHTML_OPTIONS]) +AC_SUBST([COVERAGE_CFLAGS]) +AC_SUBST([COVERAGE_OPTFLAGS]) +AC_SUBST([COVERAGE_LDFLAGS]) +AC_SUBST([COVERAGE_LIBS]) +AM_CONDITIONAL(CODE_COVERAGE_ENABLED,test x$HAVE_GCOV_TOOLS = x1) + +]) Modified: stable/11/contrib/libucl/python/setup.py ============================================================================== --- stable/11/contrib/libucl/python/setup.py Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/python/setup.py Sat Oct 22 20:49:07 2016 (r307790) @@ -1,37 +1,43 @@ -import distutils.ccompiler -import distutils.sysconfig -from distutils.core import setup, Extension +try: + from setuptools import setup, Extension +except ImportError: + from distutils.core import setup, Extension + import os +import sys +tests_require = [] -compiler = distutils.ccompiler.new_compiler() -search_paths=[os.path.expanduser('~/{}'), '/opt/local/{}', '/usr/local/{}', '/usr/{}'] -lib_paths = [ a.format("lib") for a in search_paths] -inc_paths = [ a.format("include") for a in search_paths] +if sys.version < '2.7': + tests_require.append('unittest2') -uclmodule = Extension('ucl', - include_dirs = inc_paths, - library_dirs = lib_paths, - libraries = ['ucl'], - sources = ['src/uclmodule.c'], - runtime_library_dirs = lib_paths, - language='c') +uclmodule = Extension( + 'ucl', + libraries = ['ucl'], + sources = ['src/uclmodule.c'], + language = 'c' +) -setup(name='ucl', - version='1.0', - description='ucl parser and emmitter', +setup( + name = 'ucl', + version = '0.8', + description = 'ucl parser and emmitter', ext_modules = [uclmodule], - author="Eitan Adler", - author_email="lists@eitanadler.com", - url="https://github.com/vstakhov/libucl/", - license="MIT", - classifiers=["Development Status :: 3 - Alpha", + test_suite = 'tests', + tests_require = tests_require, + author = "Eitan Adler, Denis Volpato Martins", + author_email = "lists@eitanadler.com", + url = "https://github.com/vstakhov/libucl/", + license = "MIT", + classifiers = [ + "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: DFSG approved", "License :: OSI Approved :: MIT License", "Programming Language :: C", + "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries", - ] - ) + ] +) Modified: stable/11/contrib/libucl/python/src/uclmodule.c ============================================================================== --- stable/11/contrib/libucl/python/src/uclmodule.c Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/python/src/uclmodule.c Sat Oct 22 20:49:07 2016 (r307790) @@ -2,6 +2,8 @@ #include #include +static PyObject *SchemaError; + static PyObject * _basic_ucl_type (ucl_object_t const *obj) { @@ -13,9 +15,11 @@ _basic_ucl_type (ucl_object_t const *obj case UCL_STRING: return Py_BuildValue ("s", ucl_object_tostring (obj)); case UCL_BOOLEAN: - return ucl_object_toboolean (obj) ? Py_True : Py_False; + return PyBool_FromLong (ucl_object_toboolean (obj)); case UCL_TIME: return Py_BuildValue ("d", ucl_object_todouble (obj)); + case UCL_NULL: + Py_RETURN_NONE; } return NULL; } @@ -124,26 +128,60 @@ _iterate_python (PyObject *obj) { if (obj == Py_None) { return ucl_object_new(); - } else if (PyBool_Check (obj)) { + } + else if (PyBool_Check (obj)) { return ucl_object_frombool (obj == Py_True); - } else if (PyInt_Check (obj)) { + } +#if PY_MAJOR_VERSION < 3 + else if (PyInt_Check (obj)) { return ucl_object_fromint (PyInt_AsLong (obj)); - } else if (PyFloat_Check (obj)) { + } +#endif + else if (PyLong_Check (obj)) { + return ucl_object_fromint (PyLong_AsLong (obj)); + } + else if (PyFloat_Check (obj)) { return ucl_object_fromdouble (PyFloat_AsDouble (obj)); - } else if (PyString_Check (obj)) { + } + else if (PyUnicode_Check (obj)) { + ucl_object_t *ucl_str; + PyObject *str = PyUnicode_AsASCIIString(obj); + ucl_str = ucl_object_fromstring (PyBytes_AsString (str)); + Py_DECREF(str); + return ucl_str; + } +#if PY_MAJOR_VERSION < 3 + else if (PyString_Check (obj)) { return ucl_object_fromstring (PyString_AsString (obj)); - // } else if (PyDateTime_Check (obj)) { } +#endif else if (PyDict_Check(obj)) { PyObject *key, *value; Py_ssize_t pos = 0; ucl_object_t *top, *elm; + char *keystr = NULL; top = ucl_object_typed_new (UCL_OBJECT); while (PyDict_Next(obj, &pos, &key, &value)) { elm = _iterate_python(value); - ucl_object_insert_key (top, elm, PyString_AsString(key), 0, true); + + if (PyUnicode_Check(key)) { + PyObject *keyascii = PyUnicode_AsASCIIString(key); + keystr = PyBytes_AsString(keyascii); + Py_DECREF(keyascii); + } +#if PY_MAJOR_VERSION < 3 + else if (PyString_Check(key)) { + keystr = PyString_AsString(key); + } +#endif + else { + PyErr_SetString(PyExc_TypeError, "Unknown key type"); + return NULL; + } + + ucl_object_insert_key (top, elm, keystr, 0, true); } return top; @@ -195,11 +233,6 @@ ucl_dump (PyObject *self, PyObject *args Py_RETURN_NONE; } - if (!PyDict_Check(obj)) { - PyErr_SetString(PyExc_TypeError, "Argument must be dict"); - return NULL; - } - root = _iterate_python(obj); if (root) { PyObject *ret; @@ -207,7 +240,11 @@ ucl_dump (PyObject *self, PyObject *args buf = (char *) ucl_object_emit (root, emitter); ucl_object_unref (root); +#if PY_MAJOR_VERSION < 3 ret = PyString_FromString (buf); +#else + ret = PyUnicode_FromString (buf); +#endif free(buf); return ret; @@ -219,17 +256,35 @@ ucl_dump (PyObject *self, PyObject *args static PyObject * ucl_validate (PyObject *self, PyObject *args) { - char *uclstr, *schema; + PyObject *dataobj, *schemaobj; + ucl_object_t *data, *schema; + bool r; + struct ucl_schema_error err; - if (PyArg_ParseTuple(args, "zz", &uclstr, &schema)) { - if (!uclstr || !schema) { - Py_RETURN_NONE; - } + if (!PyArg_ParseTuple (args, "OO", &schemaobj, &dataobj)) { + PyErr_SetString (PyExc_TypeError, "Unhandled object type"); + return NULL; + } - PyErr_SetString(PyExc_NotImplementedError, "schema validation is not yet supported"); + schema = _iterate_python(schemaobj); + if (!schema) + return NULL; + + data = _iterate_python(dataobj); + if (!data) + return NULL; + + // validation + r = ucl_object_validate (schema, data, &err); + ucl_object_unref (schema); + ucl_object_unref (data); + + if (!r) { + PyErr_SetString (SchemaError, err.msg); + return NULL; } - return NULL; + Py_RETURN_TRUE; } static PyMethodDef uclMethods[] = { @@ -247,6 +302,10 @@ init_macros(PyObject *mod) PyModule_AddIntMacro(mod, UCL_EMIT_CONFIG); PyModule_AddIntMacro(mod, UCL_EMIT_YAML); PyModule_AddIntMacro(mod, UCL_EMIT_MSGPACK); + + SchemaError = PyErr_NewException("ucl.SchemaError", NULL, NULL); + Py_INCREF(SchemaError); + PyModule_AddObject(mod, "SchemaError", SchemaError); } #if PY_MAJOR_VERSION >= 3 Modified: stable/11/contrib/libucl/src/ucl_parser.c ============================================================================== --- stable/11/contrib/libucl/src/ucl_parser.c Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/src/ucl_parser.c Sat Oct 22 20:49:07 2016 (r307790) @@ -342,6 +342,7 @@ ucl_check_variable_safe (struct ucl_pars /* Call generic handler */ if (parser->var_handler (ptr, remain, &dst, &dstlen, &need_free, parser->var_data)) { + *out_len += dstlen; *found = true; if (need_free) { free (dst); @@ -458,11 +459,18 @@ ucl_expand_single_variable (struct ucl_p } if (!found) { if (strict && parser->var_handler != NULL) { - if (parser->var_handler (ptr, remain, &dst, &dstlen, &need_free, + size_t var_len = 0; + while (var_len < remain && p[var_len] != '}') + var_len ++; + + if (parser->var_handler (p, var_len, &dst, &dstlen, &need_free, parser->var_data)) { memcpy (d, dst, dstlen); - ret += dstlen; - d += remain; + ret += var_len; + d += dstlen; + if (need_free) { + free (dst); + } found = true; } } Modified: stable/11/contrib/libucl/src/ucl_schema.c ============================================================================== --- stable/11/contrib/libucl/src/ucl_schema.c Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/src/ucl_schema.c Sat Oct 22 20:49:07 2016 (r307790) @@ -69,7 +69,7 @@ ucl_schema_create_error (struct ucl_sche * Check whether we have a pattern specified */ static const ucl_object_t * -ucl_schema_test_pattern (const ucl_object_t *obj, const char *pattern) +ucl_schema_test_pattern (const ucl_object_t *obj, const char *pattern, bool recursive) { const ucl_object_t *res = NULL; #ifdef HAVE_REGEX_H @@ -78,11 +78,16 @@ ucl_schema_test_pattern (const ucl_objec ucl_object_iter_t iter = NULL; if (regcomp (®, pattern, REG_EXTENDED | REG_NOSUB) == 0) { - while ((elt = ucl_object_iterate (obj, &iter, true)) != NULL) { - if (regexec (®, ucl_object_key (elt), 0, NULL, 0) == 0) { - res = elt; - break; + if (recursive) { + while ((elt = ucl_object_iterate (obj, &iter, true)) != NULL) { + if (regexec (®, ucl_object_key (elt), 0, NULL, 0) == 0) { + res = elt; + break; + } } + } else { + if (regexec (®, ucl_object_key (obj), 0, NULL, 0) == 0) + res = obj; } regfree (®); } @@ -205,12 +210,17 @@ ucl_schema_validate_object (const ucl_ob } } else if (strcmp (ucl_object_key (elt), "patternProperties") == 0) { + const ucl_object_t *vobj; + ucl_object_iter_t viter; piter = NULL; while (ret && (prop = ucl_object_iterate (elt, &piter, true)) != NULL) { - found = ucl_schema_test_pattern (obj, ucl_object_key (prop)); - if (found) { - ret = ucl_schema_validate (prop, found, true, err, root, - ext_ref); + viter = NULL; + while (ret && (vobj = ucl_object_iterate (obj, &viter, true)) != NULL) { + found = ucl_schema_test_pattern (vobj, ucl_object_key (prop), false); + if (found) { + ret = ucl_schema_validate (prop, found, true, err, root, + ext_ref); + } } } } @@ -234,7 +244,7 @@ ucl_schema_validate_object (const ucl_ob piter = NULL; pat = ucl_object_lookup (schema, "patternProperties"); while ((pelt = ucl_object_iterate (pat, &piter, true)) != NULL) { - found = ucl_schema_test_pattern (obj, ucl_object_key (pelt)); + found = ucl_schema_test_pattern (obj, ucl_object_key (pelt), true); if (found != NULL) { break; } Modified: stable/11/contrib/libucl/src/ucl_util.c ============================================================================== --- stable/11/contrib/libucl/src/ucl_util.c Sat Oct 22 20:46:57 2016 (r307789) +++ stable/11/contrib/libucl/src/ucl_util.c Sat Oct 22 20:49:07 2016 (r307790) @@ -1795,8 +1795,9 @@ ucl_parser_set_filevars (struct ucl_pars } bool -ucl_parser_add_file_priority (struct ucl_parser *parser, const char *filename, - unsigned priority) +ucl_parser_add_file_full (struct ucl_parser *parser, const char *filename, + unsigned priority, enum ucl_duplicate_strategy strat, + enum ucl_parse_type parse_type) { unsigned char *buf; size_t len; @@ -1819,7 +1820,8 @@ ucl_parser_add_file_priority (struct ucl } parser->cur_file = strdup (realbuf); ucl_parser_set_filevars (parser, realbuf, false); - ret = ucl_parser_add_chunk_priority (parser, buf, len, priority); + ret = ucl_parser_add_chunk_full (parser, buf, len, priority, strat, + parse_type); if (len > 0) { ucl_munmap (buf, len); @@ -1829,14 +1831,27 @@ ucl_parser_add_file_priority (struct ucl } bool +ucl_parser_add_file_priority (struct ucl_parser *parser, const char *filename, + unsigned priority) +{ + if (parser == NULL) { + return false; + } + + return ucl_parser_add_file_full(parser, filename, priority, + UCL_DUPLICATE_APPEND, UCL_PARSE_UCL); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Sat Oct 22 20:49:45 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F07CDC1D9AC; Sat, 22 Oct 2016 20:49:45 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA64CA96; Sat, 22 Oct 2016 20:49:45 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKniqX010686; Sat, 22 Oct 2016 20:49:44 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKnirM010685; Sat, 22 Oct 2016 20:49:44 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222049.u9MKnirM010685@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:49:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307791 - stable/11/usr.sbin/bhyve X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:49:46 -0000 Author: bapt Date: Sat Oct 22 20:49:44 2016 New Revision: 307791 URL: https://svnweb.freebsd.org/changeset/base/307791 Log: MFC r306554: Use accept4 with O_NONBLOCK rather than accept + fcntl Modified: stable/11/usr.sbin/bhyve/dbgport.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/bhyve/dbgport.c ============================================================================== --- stable/11/usr.sbin/bhyve/dbgport.c Sat Oct 22 20:49:07 2016 (r307790) +++ stable/11/usr.sbin/bhyve/dbgport.c Sat Oct 22 20:49:44 2016 (r307791) @@ -73,10 +73,8 @@ again: printf("Waiting for connection from gdb\r\n"); printonce = 1; } - conn_fd = accept(listen_fd, NULL, NULL); - if (conn_fd >= 0) - fcntl(conn_fd, F_SETFL, O_NONBLOCK); - else if (errno != EINTR) + conn_fd = accept4(listen_fd, NULL, NULL, O_NONBLOCK); + if (conn_fd < 0 && errno != EINTR) perror("accept"); } From owner-svn-src-stable@freebsd.org Sat Oct 22 20:50:50 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0EF9C1DA42; Sat, 22 Oct 2016 20:50:50 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 90D6FC51; Sat, 22 Oct 2016 20:50:50 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKontS011565; Sat, 22 Oct 2016 20:50:49 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKonf8011564; Sat, 22 Oct 2016 20:50:49 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222050.u9MKonf8011564@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:50:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307792 - stable/11/lib/libdevdctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:50:50 -0000 Author: bapt Date: Sat Oct 22 20:50:49 2016 New Revision: 307792 URL: https://svnweb.freebsd.org/changeset/base/307792 Log: MFC r307364: directly create the socket with SOCK_NONBLOCK instead of calling fcntl(2) Modified: stable/11/lib/libdevdctl/consumer.cc Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libdevdctl/consumer.cc ============================================================================== --- stable/11/lib/libdevdctl/consumer.cc Sat Oct 22 20:49:44 2016 (r307791) +++ stable/11/lib/libdevdctl/consumer.cc Sat Oct 22 20:50:49 2016 (r307792) @@ -108,11 +108,9 @@ Consumer::ConnectToDevd() strlcpy(devdAddr.sun_path, s_devdSockPath, sizeof(devdAddr.sun_path)); sLen = SUN_LEN(&devdAddr); - m_devdSockFD = socket(AF_UNIX, SOCK_SEQPACKET, 0); + m_devdSockFD = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_NONBLOCK, 0); if (m_devdSockFD == -1) err(1, "Unable to create socket"); - if (fcntl(m_devdSockFD, F_SETFL, O_NONBLOCK) < 0) - err(1, "fcntl"); result = connect(m_devdSockFD, reinterpret_cast(&devdAddr), sLen); From owner-svn-src-stable@freebsd.org Sat Oct 22 20:52:59 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D248EC1DB82; Sat, 22 Oct 2016 20:52:59 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9DC56F97; Sat, 22 Oct 2016 20:52:59 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKqw8G014286; Sat, 22 Oct 2016 20:52:58 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKqwEU014285; Sat, 22 Oct 2016 20:52:58 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222052.u9MKqwEU014285@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:52:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307793 - stable/11/usr.bin/calendar X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:52:59 -0000 Author: bapt Date: Sat Oct 22 20:52:58 2016 New Revision: 307793 URL: https://svnweb.freebsd.org/changeset/base/307793 Log: MFC r303265: Remove reference cpp(1) which is not used anymore Modified: stable/11/usr.bin/calendar/calendar.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/calendar/calendar.1 ============================================================================== --- stable/11/usr.bin/calendar/calendar.1 Sat Oct 22 20:50:49 2016 (r307792) +++ stable/11/usr.bin/calendar/calendar.1 Sat Oct 22 20:52:58 2016 (r307793) @@ -28,7 +28,7 @@ .\" @(#)calendar.1 8.1 (Berkeley) 6/29/93 .\" $FreeBSD$ .\" -.Dd April 6, 2013 +.Dd July 24, 2016 .Dt CALENDAR 1 .Os .Sh NAME @@ -295,7 +295,6 @@ This is no longer true, the date is only at the beginning of a line. .Sh SEE ALSO .Xr at 1 , -.Xr cpp 1 , .Xr mail 1 , .Xr cron 8 .Sh HISTORY From owner-svn-src-stable@freebsd.org Sat Oct 22 20:54:55 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86EF8C1DC67; Sat, 22 Oct 2016 20:54:55 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3AF87177; Sat, 22 Oct 2016 20:54:55 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKsswr014390; Sat, 22 Oct 2016 20:54:54 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKssRl014388; Sat, 22 Oct 2016 20:54:54 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222054.u9MKssRl014388@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:54:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307794 - stable/11/usr.bin/mkcsmapper X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:54:55 -0000 Author: bapt Date: Sat Oct 22 20:54:54 2016 New Revision: 307794 URL: https://svnweb.freebsd.org/changeset/base/307794 Log: MFC r302471, r302473: r302471: Add RCS Id. Sort options in SYNOPSIS. Fix macro usage. Fix Dd. Submitted by: wiz@NetBSD.org Obtained from: NetBSD r302473: Sync usage between program and man page. Increase column width. [1] Simplifay the usage() function Replace errx/strerror with errc Submitted by: wiz@NetBSD.org [1] Obtained from: NetBSD Modified: stable/11/usr.bin/mkcsmapper/mkcsmapper.1 stable/11/usr.bin/mkcsmapper/yacc.y Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/mkcsmapper/mkcsmapper.1 ============================================================================== --- stable/11/usr.bin/mkcsmapper/mkcsmapper.1 Sat Oct 22 20:52:58 2016 (r307793) +++ stable/11/usr.bin/mkcsmapper/mkcsmapper.1 Sat Oct 22 20:54:54 2016 (r307794) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Sep 6, 2009 +.Dd July 9, 2016 .Dt MKCSMAPPER 1 .Os .Sh NAME @@ -43,10 +43,10 @@ .Xr iconv 3 .Sh SYNOPSIS .Nm -.Op Fl mpd -.Fl o -.Ar outfile -.Ar infile +.Op Fl d +.Op Fl m | Fl p +.Op Fl o Ar outfile +.Op Ar infile .Sh DESCRIPTION The .Nm @@ -60,7 +60,7 @@ A pivot file, which the possible source pairs or the set of mappings to use for a compound encoding. .Pp The following options are available: -.Bl -tag -width 0123 +.Bl -tag -width XoXoutfileXX .It Fl d Turns on debug mode. .It Fl m @@ -82,7 +82,8 @@ Generate pivot data from .Sh HISTORY .Nm first appeared in -.Nx 2.0 , and made its appearance in +.Nx 2.0 , +and made its appearance in .Fx 9.0 . .Sh AUTHORS This manual page was written by Modified: stable/11/usr.bin/mkcsmapper/yacc.y ============================================================================== --- stable/11/usr.bin/mkcsmapper/yacc.y Sat Oct 22 20:52:58 2016 (r307793) +++ stable/11/usr.bin/mkcsmapper/yacc.y Sat Oct 22 20:54:54 2016 (r307794) @@ -1,5 +1,5 @@ /* $FreeBSD$ */ -/* $NetBSD: yacc.y,v 1.7 2006/09/09 14:35:17 tnozaki Exp $ */ +/* $NetBSD: yacc.y,v 1.11 2016/06/28 09:22:16 wiz Exp $ */ %{ /*- @@ -664,18 +664,15 @@ do_mkpv(FILE *in) if (ret && output) unlink(output); /* dump failure */ if (ret) - errx(EXIT_FAILURE, "%s\n", strerror(ret)); + errc(EXIT_FAILURE, ret, ""); } static void usage(void) { - warnx("usage: \n" - "\t%s [-d] [-o outfile] [infile]\n" - "\t%s -m [-d] [-o outfile] [infile]\n" - "\t%s -p [-d] [-o outfile] [infile]\n", - getprogname(), getprogname(), getprogname()); - exit(1); + fprintf(stderr, "Usage: %s [-d] [-m|-p] [-o outfile] [infile]\n", + getprogname()); + exit(EXIT_FAILURE); } int From owner-svn-src-stable@freebsd.org Sat Oct 22 20:56:51 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEF91C1DCEE; Sat, 22 Oct 2016 20:56:51 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 493E3309; Sat, 22 Oct 2016 20:56:51 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKuook014546; Sat, 22 Oct 2016 20:56:50 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKun2o014539; Sat, 22 Oct 2016 20:56:49 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222056.u9MKun2o014539@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:56:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307795 - stable/11/contrib/mdocml X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:56:51 -0000 Author: bapt Date: Sat Oct 22 20:56:49 2016 New Revision: 307795 URL: https://svnweb.freebsd.org/changeset/base/307795 Log: MFC r303223: Update mandoc to 1.13.4 release Added: stable/11/contrib/mdocml/man.cgi.3 - copied unchanged from r303223, head/contrib/mdocml/man.cgi.3 Modified: stable/11/contrib/mdocml/INSTALL stable/11/contrib/mdocml/LICENSE stable/11/contrib/mdocml/Makefile stable/11/contrib/mdocml/NEWS stable/11/contrib/mdocml/TODO stable/11/contrib/mdocml/cgi.c stable/11/contrib/mdocml/cgi.h.example stable/11/contrib/mdocml/configure stable/11/contrib/mdocml/configure.local.example stable/11/contrib/mdocml/demandoc.c stable/11/contrib/mdocml/libmandoc.h stable/11/contrib/mdocml/main.c stable/11/contrib/mdocml/main.h stable/11/contrib/mdocml/man.1 stable/11/contrib/mdocml/man.cgi.8 stable/11/contrib/mdocml/mandoc.3 stable/11/contrib/mdocml/mandoc.css stable/11/contrib/mdocml/mandoc.db.5 stable/11/contrib/mdocml/mandoc_headers.3 stable/11/contrib/mdocml/mandoc_malloc.3 stable/11/contrib/mdocml/mandocdb.c stable/11/contrib/mdocml/manpage.c stable/11/contrib/mdocml/manpath.c stable/11/contrib/mdocml/mansearch.c stable/11/contrib/mdocml/mchars_alloc.3 stable/11/contrib/mdocml/read.c stable/11/contrib/mdocml/tag.c stable/11/contrib/mdocml/term.c stable/11/contrib/mdocml/term_ascii.c stable/11/contrib/mdocml/test-rewb-bsd.c stable/11/contrib/mdocml/test-rewb-sysv.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/mdocml/INSTALL ============================================================================== --- stable/11/contrib/mdocml/INSTALL Sat Oct 22 20:54:54 2016 (r307794) +++ stable/11/contrib/mdocml/INSTALL Sat Oct 22 20:56:49 2016 (r307795) @@ -1,4 +1,4 @@ -$Id: INSTALL,v 1.13 2015/11/07 14:01:16 schwarze Exp $ +$Id: INSTALL,v 1.15 2016/07/14 11:09:06 schwarze Exp $ About mdocml, the portable mandoc distribution ---------------------------------------------- @@ -16,7 +16,7 @@ tech@ mailing list, too. Enjoy using the mandoc toolset! -Ingo Schwarze, Karlsruhe, March 2015 +Ingo Schwarze, Karlsruhe, July 2016 Installation @@ -52,7 +52,7 @@ and go back to step 2. 4. Run "make -n install" and check whether everything will be installed to the intended places. Otherwise, put some *DIR or *NM* -variables into "configure.local" and go back to step 2. +variables into "configure.local" and go back to step 2. 5. Run "sudo make install". If you intend to build a binary package using some kind of fake root mechanism, you may need a @@ -63,7 +63,7 @@ in the "Makefile" to understand how DEST manpath(1), make sure it is configured correctly, in particular, it returns all directory trees where manual pages are installed. Otherwise, if your system uses man.conf(5), make sure it contains -a "_whatdb" line for each directory tree, and the order of these +a "manpath" line for each directory tree, and the order of these lines meets your wishes. 7. If you compiled with database support, run the command "sudo Modified: stable/11/contrib/mdocml/LICENSE ============================================================================== --- stable/11/contrib/mdocml/LICENSE Sat Oct 22 20:54:54 2016 (r307794) +++ stable/11/contrib/mdocml/LICENSE Sat Oct 22 20:56:49 2016 (r307795) @@ -1,11 +1,11 @@ -$Id: LICENSE,v 1.11 2015/11/07 17:58:55 schwarze Exp $ +$Id: LICENSE,v 1.12 2016/07/07 23:46:36 schwarze Exp $ With the exceptions noted below, all code and documentation contained in the mdocml toolkit is protected by the Copyright of the following developers: Copyright (c) 2008-2012, 2014 Kristaps Dzonsons -Copyright (c) 2010-2015 Ingo Schwarze +Copyright (c) 2010-2016 Ingo Schwarze Copyright (c) 2009, 2010, 2011, 2012 Joerg Sonnenberger Copyright (c) 2013 Franco Fichtner Copyright (c) 2014 Baptiste Daroussin Modified: stable/11/contrib/mdocml/Makefile ============================================================================== --- stable/11/contrib/mdocml/Makefile Sat Oct 22 20:54:54 2016 (r307794) +++ stable/11/contrib/mdocml/Makefile Sat Oct 22 20:56:49 2016 (r307795) @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.480 2015/11/07 21:53:14 schwarze Exp $ +# $Id: Makefile,v 1.488 2016/07/12 05:18:38 kristaps Exp $ # # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons -# Copyright (c) 2011, 2013, 2014, 2015 Ingo Schwarze +# Copyright (c) 2011, 2013-2016 Ingo Schwarze # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -VERSION = 1.13.3 +VERSION = 1.13.4 # === LIST OF FILES ==================================================== @@ -31,6 +31,9 @@ TESTSRCS = test-dirent-namlen.c \ test-pledge.c \ test-progname.c \ test-reallocarray.c \ + test-rewb-bsd.c \ + test-rewb-sysv.c \ + test-sandbox_init.c \ test-sqlite3.c \ test-sqlite3_errstr.c \ test-strcasestr.c \ @@ -138,6 +141,7 @@ DISTFILES = INSTALL \ makewhatis.8 \ man.1 \ man.7 \ + man.cgi.3 \ man.cgi.8 \ man.conf.5 \ man.h \ @@ -164,6 +168,7 @@ DISTFILES = INSTALL \ predefs.in \ roff.7 \ roff.h \ + roff_int.h \ soelim.1 \ st.in \ tag.h \ @@ -293,6 +298,7 @@ WWW_MANS = apropos.1.html \ roff.7.html \ tbl.7.html \ makewhatis.8.html \ + man.cgi.3.html \ man.cgi.8.html \ man.h.html \ manconf.h.html \ @@ -392,34 +398,30 @@ db-install: base-build cgi-install: cgi-build mkdir -p $(DESTDIR)$(CGIBINDIR) mkdir -p $(DESTDIR)$(HTDOCDIR) - mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1 - mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR) $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR) - $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/ - $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/ Makefile.local config.h: configure ${TESTSRCS} @echo "$@ is out of date; please run ./configure" @exit 1 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS) - $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS) + ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS) mandoc: $(MAIN_OBJS) libmandoc.a - $(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB) + $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD) manpage: $(MANPAGE_OBJS) libmandoc.a - $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB) + $(CC) -o $@ $(LDFLAGS) $(MANPAGE_OBJS) libmandoc.a $(LDADD) man.cgi: $(CGI_OBJS) libmandoc.a - $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB) + $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD) demandoc: $(DEMANDOC_OBJS) libmandoc.a - $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a $(DBLIB) + $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD) soelim: $(SOELIM_OBJS) - $(CC) $(LDFLAGS) -o $@ $(SOELIM_OBJS) + $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS) # --- maintainer targets --- @@ -439,6 +441,8 @@ depend: config.h Makefile.depend > Makefile.tmp mv Makefile.tmp Makefile.depend +dist: mdocml.sha256 + mdocml.sha256: mdocml.tar.gz sha256 mdocml.tar.gz > $@ Modified: stable/11/contrib/mdocml/NEWS ============================================================================== --- stable/11/contrib/mdocml/NEWS Sat Oct 22 20:54:54 2016 (r307794) +++ stable/11/contrib/mdocml/NEWS Sat Oct 22 20:56:49 2016 (r307795) @@ -1,7 +1,140 @@ -$Id: NEWS,v 1.10 2015/11/05 16:58:20 schwarze Exp $ +$Id: NEWS,v 1.12 2016/07/14 11:09:06 schwarze Exp $ This file lists the most important changes in the mdocml.bsd.lv distribution. +Changes in version 1.13.4, released on July 14, 2016 + + --- MAJOR NEW FEATURES --- + * man.conf(5): Design and implement a simpler configuration file format. + * man(1): Leverage less(1) -T and :t in a way resembling ctags(1) + to jump to the definitions of various terms inside manual pages. + * soelim(1): New implementation by Baptiste Daroussin. + * privilege limitation: Use OpenBSD pledge(2) or OS X sandbox_init(3) + when available. + * man.cgi(8): Support short URIs like http://man.openbsd.org/mdoc . + * mandoc.css: Use one unified stylesheet rather than three different ones. + --- MAJOR FUNCTIONALLY RELEVANT BUGFIXES --- + * mdoc(7): Fix multiple aspects of SYNOPSIS .Nm formatting. + * man(1): Fix process group handling, avoiding unclean shutdowns. + --- PORTABILITY IMPROVEMENTS --- + * Correctly use the ohash(3) compatibility implementation + even when building without SQLite support. + * Add compat glue for building on Solaris 9 and 10. + * Let ./configure select a supported RE syntax for word boundaries. + * Support LDFLAGS, to be used for example for hardening options. + * Avoid mixing putchar(3) and putwchar(3) on the same file descriptor, + it resulted in output corruption on some platforms. + * Avoid reusing va_lists, use va_copy(3) for better portability. + * Do not hardcode the path to the more(1) program. + --- MINOR NEW FEATURES --- + * roff(7): Implement \n(.$ (number of macro arguments). + * roff(7): Fully implement \z (do not advance cursor). + * roff(7): Implement the `r' conditional (register exists). + * roff(7): Implement \\$* (interpolate all arguments). + * roff(7): Parse and ignore \, and \/ (italic corrections). + * When there is no -m, no -M, no MANPATH and no /etc/man.conf, + fall back to /usr/share/man:/usr/X11R6/man:/usr/local/man. + * man(1): Give manuals in purely numerical sections priority over + manuals of the same name in sections with an alphabetical suffix. + * man.cgi(8): Support "header.html" and "footer.html". + * man.cgi(8): Set the "autofocus" attribute on the query text box. + * man.cgi(8): Simplify the search form, drop two useless buttons. + * man.cgi(8): Delete the pseudo-manpath "mandoc", assume that + apropos(1) and man.cgi(8) are installed in the default manpath. + --- RELIABILITY BUGFIXES --- + * mdoc(7): Avoid a use after free and an assertion failure when nodes + are deleted during validation. + * mdoc(7): Avoid a NULL pointer access when .Bd has no arguments. + * mdoc(7): Avoid a NULL pointer access triggered by mismatching end macros. + * mdoc(7): Avoid an assertion when .Fo has no argument. + * mdoc(7): Avoid an assertion when .Ta occurs in .Bl -column. + * mdoc(7): Avoid an assertion when a body gets broken and has a tail. + * roff(7): Avoid an assertion caused by blanks inside \o. + * roff(7): Make .so links to gziped manuals work without mandoc.db(5). + * tbl(7): Avoid a use after free when the last line of a layout is empty. + * eqn(7): Avoid an infinite loop caused by recursive "define". + * makewhatis(8): Avoid a segfault caused by unusual directory structures. + * Fix handling of leading, trailing, and double colons in MANPATH and -m. + --- MINOR BUGFIXES --- + * mdoc(7): Put arguments to end macros of broken partial explicit blocks + inside the breaking block. + * mdoc(7): Let .Dv force normal font. + * mdoc(7): Make trailing whitespace significant in .Bl -tag widths. + * mdoc(7): Fix macro interpretation around tabs in .Bl -column. + * man(7): Use the default width for .RS without arguments. + * man(7): On a new RS nesting level, the saved width starts from + the default width, not from the saved width of the previous level. + * man(7): Allow .PD in next-line scope. + * man(7): Improve handling of empty .HP. + * man(7): Improve formatting of .br and .sp inside .HP. + * man(7): Do not mistreat empty arguments to font alternating + macros as vertical spacing requests. + * man(7): Allow fill mode changes in tagged paragraph next-line scope. + * man(7): Fix minor bugs in block rewinding and simplify the related code. + * man(7): Add missing line breaks before subsection headers. + * man(7): Give section and subsection headers hanging indentation. + * man(7): Make trailing whitespace significant in .TP widths. + * roff(7): Don't allow breaking the output line after hyphens + that immediately follow escape sequences. + * roff(7): Ignore blank characters at the beginning of conditional blocks. + * roff(7): Escape breakable hyphens only after handling input line traps. + * roff(7): Reject \[uD800] to \[uDFFF] (surrogates) in the parser. + * tbl(7): Allow more than one data field after T} on the same input line. + * terminal output: Apply bold and italic to non-ASCII Unicode codepoints. + * terminal output: Improve rounding rules for horizontal scaling widths. + * HTML output: Render ASCII_NBRSP as " ", not "-". + * man(1): Do not match the first part of a name if it continues with a dot. + * man(1): Keep working even if the current directory is unusable. + * man(1): Better error message when $PAGER is invalid. + * makewhatis(8): Improve handling of .Va and .Vt macros. + * apropos(1): Print "nothing appropriate" to stderr when appropriate. + * apropos(1): Abort with a useful error message when elementary + database operations like preparing queries or binding variables fail. + --- STRUCTURAL CHANGES, no functional change --- + * mdoc(7) and man(7): Unified data structures struct roff_node etc. + * mdoc(7) and man(7): Unified node handling library in roff.c. + * mdoc(7) and man(7): Seperate validation phase from parsing. + * roff(7): Major character table cleanup. + * Link with libz rather than forking gunzip(1). + --- THANKS TO --- + * Baptiste Daroussin (FreeBSD) for the new soelim(1) + and for release testing. + * Anthony Bentley (OpenBSD) for unifying mandoc.css, two nice + patches for man.cgi(8), some documentation patches, some bug + reports, and various useful discussions. + * Todd Miller (OpenBSD) for lots of help with process group and + signal handling, a few patches, some bug reports and some useful + discussions. + * Jonathan Gray (OpenBSD) for yet more testing with afl(1) + again resulting in more than half a dozen important bug reports. + * Svyatoslav Mishyn (Crux Linux) for some patches, several bug + reports, and extensive release testing. + * Christian Neukirchen (void Linux) for a number of compatibility + patches and suggestions and several bug reports. + * Christos Zoulas (NetBSD) for a bug fix patch and some useful + suggestions for cleanup. + * Florian Obser (OpenBSD) for a bugfix patch and some bug reports. + * Sevan Janiyan for help with Solaris compatibility and release + testing on many platforms. + * Jan Holzhueter and OpenCSW in general for help with Solaris + compatibility, and for providing me with a Solaris 9/10/11 testing + environment. + * Michael McConville (OpenBSD) for some simple cleanup patches. + * Thomas Klausner (NetBSD) for some bug reports and release testing. + * Christian Weisgerber, Dmitrij Czarkoff, Igor Sobrado, + Ken Westerback, Marc Espie, Mike Belopuhov, Rafael Neves, + Ted Unangst, Tim van der Molen, Theo Buehler, Theo de Raadt + (OpenBSD), Kurt Jaeger, Dag Erling Smoergrav (FreeBSD), + Joerg Sonnenberger (NetBSD), Carsten Kunze (Heirloom troff), + Daniel Levai, Fabian Raetz, Jan Stary, Jean-Yves Migeon, + Lorenzo Beretta, Markus Waldeck, Maxim Belooussov, Michael Reed, + Peter Bray, and Serguey Parkhomovsky for bug reports and feature + suggestions. + * Alexander Hall, Andrew Fresh, Antoine Jacoutot, Doug Hogan, + Jason McIntyre, Jasper Lievisse Adriaanse, Kent Spillner, + Nicholas Marriott, Peter Hessler, Sebastien Marie, Stefan Sperling, + and Theo de Raadt (OpenBSD) for helpful discussions and feedback. + Changes in version 1.13.3, released on March 13, 2015 --- MAJOR NEW FEATURES --- Modified: stable/11/contrib/mdocml/TODO ============================================================================== --- stable/11/contrib/mdocml/TODO Sat Oct 22 20:54:54 2016 (r307794) +++ stable/11/contrib/mdocml/TODO Sat Oct 22 20:56:49 2016 (r307795) @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.216 2016/01/08 01:37:32 schwarze Exp $ +* $Id: TODO,v 1.218 2016/06/05 21:06:04 schwarze Exp $ ************************************************************************ Many issues are annotated for difficulty as follows: @@ -416,6 +416,11 @@ are mere guesses, and some may be wrong. see also matthew@ Fri, 18 Jul 2014 19:25:12 -0700 loc * exist * algo ** size * imp *** +- In -man -Thtml, .nf does not preserve indentation. + It should either convert blanks to   + or use
 rather than 
(like .Bd -literal does). + Reported by afresh1@ 12 Apr 2016 14:35:45 -0700 + - .Bf at the beginning of a paragraph inserts a bogus 1ex horizontal space, see for example random(3). Introduced in http://mdocml.bsd.lv/cgi-bin/cvsweb/mdoc_html.c.diff?r1=1.91&r2=1.92 @@ -583,8 +588,6 @@ are mere guesses, and some may be wrong. to tech@mdocml, naddy@ Wed, 28 Sep 2011 11:21:46 +0200 wait! kristaps@ Sun, 02 Oct 2011 17:12:52 +0200 -- for system errors, use errno/strerror/warn/err - ************************************************************************ * documentation issues ************************************************************************ @@ -628,9 +631,6 @@ Several areas can be cleaned up to make * structural issues ************************************************************************ -- Use libz directly instead of forking gunzip(1). - Suggested by bapt at FreeBSD among others. - - We use the input line number at several places to distinguish same-line from different-line input. That plainly doesn't work with user-defined macros, leading to random breakage. Modified: stable/11/contrib/mdocml/cgi.c ============================================================================== --- stable/11/contrib/mdocml/cgi.c Sat Oct 22 20:54:54 2016 (r307794) +++ stable/11/contrib/mdocml/cgi.c Sat Oct 22 20:56:49 2016 (r307795) @@ -1,7 +1,7 @@ -/* $Id: cgi.c,v 1.116 2016/01/04 12:36:26 schwarze Exp $ */ +/* $Id: cgi.c,v 1.135 2016/07/11 22:48:37 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons - * Copyright (c) 2014, 2015 Ingo Schwarze + * Copyright (c) 2014, 2015, 2016 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -55,15 +56,20 @@ struct req { struct query q; char **p; /* array of available manpaths */ size_t psz; /* number of available manpaths */ + int isquery; /* QUERY_STRING used, not PATH_INFO */ +}; + +enum focus { + FOCUS_NONE = 0, + FOCUS_QUERY }; -static void catman(const struct req *, const char *); -static void format(const struct req *, const char *); static void html_print(const char *); static void html_putchar(char); static int http_decode(char *); -static void http_parse(struct req *, const char *); -static void pathgen(struct req *); +static void parse_manpath_conf(struct req *); +static void parse_path_info(struct req *req, const char *path); +static void parse_query_string(struct req *, const char *); static void pg_error_badrequest(const char *); static void pg_error_internal(void); static void pg_index(const struct req *); @@ -74,16 +80,18 @@ static void pg_searchres(const struct static void pg_show(struct req *, const char *); static void resp_begin_html(int, const char *); static void resp_begin_http(int, const char *); +static void resp_catman(const struct req *, const char *); static void resp_copy(const char *); static void resp_end_html(void); -static void resp_searchform(const struct req *); +static void resp_format(const struct req *, const char *); +static void resp_searchform(const struct req *, enum focus); static void resp_show(const struct req *, const char *); static void set_query_attr(char **, char **); static int validate_filename(const char *); static int validate_manpath(const struct req *, const char *); static int validate_urifrag(const char *); -static const char *scriptname; /* CGI script name */ +static const char *scriptname = SCRIPT_NAME; static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9}; static const char *const sec_numbers[] = { @@ -106,16 +114,16 @@ static const int sec_MAX = sizeof(sec_na static const char *const arch_names[] = { "amd64", "alpha", "armish", "armv7", - "aviion", "hppa", "hppa64", "i386", - "ia64", "landisk", "loongson", "luna88k", - "macppc", "mips64", "octeon", "sgi", - "socppc", "solbourne", "sparc", "sparc64", - "vax", "zaurus", + "hppa", "hppa64", "i386", "landisk", + "loongson", "luna88k", "macppc", "mips64", + "octeon", "sgi", "socppc", "sparc", + "sparc64", "zaurus", "amiga", "arc", "arm32", "atari", - "beagle", "cats", "hp300", "mac68k", - "mvme68k", "mvme88k", "mvmeppc", "palm", - "pc532", "pegasos", "pmax", "powerpc", - "sun3", "wgrisc", "x68k" + "aviion", "beagle", "cats", "hp300", + "ia64", "mac68k", "mvme68k", "mvme88k", + "mvmeppc", "palm", "pc532", "pegasos", + "pmax", "powerpc", "solbourne", "sun3", + "vax", "wgrisc", "x68k" }; static const int arch_MAX = sizeof(arch_names) / sizeof(char *); @@ -182,11 +190,12 @@ set_query_attr(char **attr, char **val) * and store the values into the query structure. */ static void -http_parse(struct req *req, const char *qs) +parse_query_string(struct req *req, const char *qs) { char *key, *val; size_t keysz, valsz; + req->isquery = 1; req->q.manpath = NULL; req->q.arch = NULL; req->q.sec = NULL; @@ -338,14 +347,14 @@ resp_begin_html(int code, const char *ms resp_begin_http(code, msg); printf("\n" - "\n" - "\n" - "\n" - "\n" - "%s\n" - "\n" - "\n" + "\n" + "\n" + "\n" + "\n" + "%s\n" + "\n" + "\n" "\n", CSS_DIR, CUSTOMIZE_TITLE); @@ -358,103 +367,87 @@ resp_end_html(void) resp_copy(MAN_DIR "/footer.html"); - puts("\n" - ""); + puts("\n" + ""); } static void -resp_searchform(const struct req *req) +resp_searchform(const struct req *req, enum focus focus) { int i; puts(""); - printf("
\n" - "
\n" - "
\n" - "Manual Page Search Parameters\n", + printf("
\n" + "\n" + "
\n" + "Manual Page Search Parameters\n", scriptname); /* Write query input box. */ - printf( "
\n" - "q.query) + printf("q.query != NULL) html_print(req->q.query); - puts("\" SIZE=\"40\">"); - - /* Write submission and reset buttons. */ - - printf( "\n" - "\n"); - - /* Write show radio button */ - - printf( "\n" - "q.equal) - printf("CHECKED=\"checked\" "); - printf( "NAME=\"apropos\" ID=\"show\" VALUE=\"0\">\n" - "\n"); + printf( "\" size=\"40\""); + if (focus == FOCUS_QUERY) + printf(" autofocus"); + puts(">"); + + /* Write submission buttons. */ + + printf( "\n" + "\n
\n"); /* Write section selector. */ - puts( "
\n" - ""); for (i = 0; i < sec_MAX; i++) { - printf("\n", sec_names[i]); + printf(" selected=\"selected\""); + printf(">%s\n", sec_names[i]); } - puts(""); + puts(""); /* Write architecture selector. */ - printf( ""); + puts(""); /* Write manpath selector. */ if (req->psz > 1) { - puts(""); for (i = 0; i < (int)req->psz; i++) { - printf(""); + puts(""); } - puts(""); + puts(""); } - /* Write search radio button */ - - printf( "\n" - "q.equal) - printf("CHECKED=\"checked\" "); - printf( "NAME=\"apropos\" ID=\"search\" VALUE=\"1\">\n" - "\n"); - - puts("
\n" - "
\n" - "\n" - "
"); + puts("
\n" + "\n" + "
"); puts(""); } @@ -477,9 +470,6 @@ validate_manpath(const struct req *req, { size_t i; - if ( ! strcmp(manpath, "mandoc")) - return 1; - for (i = 0; i < req->psz; i++) if ( ! strcmp(manpath, req->p[i])) return 1; @@ -503,15 +493,16 @@ pg_index(const struct req *req) { resp_begin_html(200, NULL); - resp_searchform(req); - printf("

\n" + resp_searchform(req, FOCUS_QUERY); + printf("

\n" "This web interface is documented in the\n" - "man.cgi\n" + "man.cgi(8)\n" "manual, and the\n" - "apropos\n" + "apropos(1)\n" "manual explains the query syntax.\n" - "

\n", - scriptname, scriptname); + "

\n", + scriptname, *scriptname == '\0' ? "" : "/", + scriptname, *scriptname == '\0' ? "" : "/"); resp_end_html(); } @@ -519,10 +510,10 @@ static void pg_noresult(const struct req *req, const char *msg) { resp_begin_html(200, NULL); - resp_searchform(req); - puts("

"); + resp_searchform(req, FOCUS_QUERY); + puts("

"); puts(msg); - puts("

"); + puts("

"); resp_end_html(); } @@ -531,12 +522,12 @@ pg_error_badrequest(const char *msg) { resp_begin_html(400, "Bad Request"); - puts("

Bad Request

\n" - "

\n"); + puts("

Bad Request

\n" + "

\n"); puts(msg); printf("Try again from the\n" - "main page.\n" - "

", scriptname); + "main page.\n" + "

", scriptname); resp_end_html(); } @@ -544,7 +535,7 @@ static void pg_error_internal(void) { resp_begin_html(500, "Internal Server Error"); - puts("

Internal Server Error

"); + puts("

Internal Server Error

"); resp_end_html(); } @@ -552,28 +543,30 @@ static void pg_searchres(const struct req *req, struct manpage *r, size_t sz) { char *arch, *archend; - size_t i, iuse, isec; + const char *sec; + size_t i, iuse; int archprio, archpriouse; int prio, priouse; - char sec; for (i = 0; i < sz; i++) { if (validate_filename(r[i].file)) continue; - fprintf(stderr, "invalid filename %s in %s database\n", + warnx("invalid filename %s in %s database", r[i].file, req->q.manpath); pg_error_internal(); return; } - if (1 == sz) { + if (req->isquery && sz == 1) { /* * If we have just one result, then jump there now * without any delay. */ printf("Status: 303 See Other\r\n"); - printf("Location: http://%s%s/%s/%s", - HTTP_HOST, scriptname, req->q.manpath, r[0].file); + printf("Location: http://%s/%s%s%s/%s", + HTTP_HOST, scriptname, + *scriptname == '\0' ? "" : "/", + req->q.manpath, r[0].file); printf("\r\n" "Content-Type: text/html; charset=utf-8\r\n" "\r\n"); @@ -581,50 +574,57 @@ pg_searchres(const struct req *req, stru } resp_begin_html(200, NULL); - resp_searchform(req); - puts("
"); - puts(""); + resp_searchform(req, + req->q.equal || sz == 1 ? FOCUS_NONE : FOCUS_QUERY); - for (i = 0; i < sz; i++) { - printf("\n" - "\n" - "\n" - ""); - } + if (sz > 1) { + puts("
"); + puts("
\n" - "q.manpath, r[i].file); - printf("\">"); - html_print(r[i].names); - printf("\n" - ""); - html_print(r[i].output); - puts("
"); - puts("
\n" - "
"); + for (i = 0; i < sz; i++) { + printf("\n" + "\n" + "q.manpath, r[i].file); + printf("\">"); + html_print(r[i].names); + printf("\n" + "\n" + ""); + html_print(r[i].output); + puts("\n" + ""); + } + + puts("\n" + "
"); + } /* * In man(1) mode, show one of the pages * even if more than one is found. */ - if (req->q.equal) { - puts("
"); + if (req->q.equal || sz == 1) { + puts("
"); iuse = 0; - priouse = 10; + priouse = 20; archpriouse = 3; for (i = 0; i < sz; i++) { - isec = strcspn(r[i].file, "123456789"); - sec = r[i].file[isec]; - if ('\0' == sec) + sec = r[i].file; + sec += strcspn(sec, "123456789"); + if (sec[0] == '\0') continue; - prio = sec_prios[sec - '1']; - if (NULL == req->q.arch) { + prio = sec_prios[sec[0] - '1']; + if (sec[1] != '/') + prio += 10; + if (req->q.arch == NULL) { archprio = - (NULL == (arch = strchr( - r[i].file + isec, '/'))) ? 3 : - (NULL == (archend = strchr( - arch + 1, '/'))) ? 0 : + ((arch = strchr(sec + 1, '/')) + == NULL) ? 3 : + ((archend = strchr(arch + 1, '/')) + == NULL) ? 0 : strncmp(arch, "amd64/", archend - arch) ? 2 : 1; if (archprio < archpriouse) { @@ -648,7 +648,7 @@ pg_searchres(const struct req *req, stru } static void -catman(const struct req *req, const char *file) +resp_catman(const struct req *req, const char *file) { FILE *f; char *p; @@ -658,12 +658,12 @@ catman(const struct req *req, const char int italic, bold; if ((f = fopen(file, "r")) == NULL) { - puts("

You specified an invalid manual file.

"); + puts("

You specified an invalid manual file.

"); return; } - puts("
\n" - "
");
+	puts("
\n" + "
");
 
 	p = NULL;
 	sz = 0;
@@ -689,9 +689,9 @@ catman(const struct req *req, const char
 
 			if ('\b' != p[i + 1]) {
 				if (italic)
-					printf("");
+					printf("");
 				if (bold)
-					printf("");
+					printf("");
 				italic = bold = 0;
 				html_putchar(p[i]);
 				continue;
@@ -702,9 +702,9 @@ catman(const struct req *req, const char
 
 			if ('_' == p[i]) {
 				if (bold)
-					printf("");
+					printf("");
 				if ( ! italic)
-					printf("");
+					printf("");
 				bold = 0;
 				italic = 1;
 				i += 2;
@@ -726,9 +726,9 @@ catman(const struct req *req, const char
 					('*' == p[i] && '|' == p[i + 2]) ||
 					('|' == p[i] && '*' == p[i + 2]))  {
 				if (italic)
-					printf("");
+					printf("");
 				if (bold)
-					printf("");
+					printf("");
 				italic = bold = 0;
 				putchar('*');
 				i += 2;
@@ -740,9 +740,9 @@ catman(const struct req *req, const char
 					('+' == p[i] && '|' == p[i + 1]) ||
 					('|' == p[i] && '+' == p[i + 1]))  {
 				if (italic)
-					printf("");
+					printf("");
 				if (bold)
-					printf("");
+					printf("");
 				italic = bold = 0;
 				putchar('+');
 				i += 2;
@@ -752,9 +752,9 @@ catman(const struct req *req, const char
 			/* Bold mode. */
 
 			if (italic)
-				printf("");
+				printf("");
 			if ( ! bold)
-				printf("");
+				printf("");
 			bold = 1;
 			italic = 0;
 			i += 2;
@@ -767,9 +767,9 @@ catman(const struct req *req, const char
 		 */
 
 		if (italic)
-			printf("");
+			printf("");
 		if (bold)
-			printf("");
+			printf("");
 
 		if (i == len - 1 && p[i] != '\n')
 			html_putchar(p[i]);
@@ -778,14 +778,14 @@ catman(const struct req *req, const char
 	}
 	free(p);
 
-	puts("
\n" - "
"); + puts("
\n" + "
"); fclose(f); } static void -format(const struct req *req, const char *file) +resp_format(const struct req *req, const char *file) { struct manoutput conf; struct mparse *mp; @@ -795,7 +795,7 @@ format(const struct req *req, const char int usepath; if (-1 == (fd = open(file, O_RDONLY, 0))) { - puts("

You specified an invalid manual file.

"); + puts("

You specified an invalid manual file.

"); return; } @@ -807,17 +807,12 @@ format(const struct req *req, const char memset(&conf, 0, sizeof(conf)); conf.fragment = 1; usepath = strcmp(req->q.manpath, req->p[0]); - mandoc_asprintf(&conf.man, "%s?query=%%N&sec=%%S%s%s%s%s", - scriptname, - req->q.arch ? "&arch=" : "", - req->q.arch ? req->q.arch : "", - usepath ? "&manpath=" : "", - usepath ? req->q.manpath : ""); + mandoc_asprintf(&conf.man, "/%s%s%%N.%%S", + usepath ? req->q.manpath : "", usepath ? "/" : ""); mparse_result(mp, &man, NULL); if (man == NULL) { - fprintf(stderr, "fatal mandoc error: %s/%s\n", - req->q.manpath, file); + warnx("fatal mandoc error: %s/%s", req->q.manpath, file); pg_error_internal(); mparse_free(mp); mchars_free(); @@ -848,9 +843,9 @@ resp_show(const struct req *req, const c file += 2; if ('c' == *file) - catman(req, file); + resp_catman(req, file); else - format(req, file); + resp_format(req, file); } static void @@ -881,18 +876,12 @@ pg_show(struct req *req, const char *ful */ if (chdir(manpath) == -1) { - fprintf(stderr, "chdir %s: %s\n", - manpath, strerror(errno)); + warn("chdir %s", manpath); pg_error_internal(); free(manpath); return; } - - if (strcmp(manpath, "mandoc")) { - free(req->q.manpath); - req->q.manpath = manpath; - } else - free(manpath); + free(manpath); if ( ! validate_filename(file)) { pg_error_badrequest( @@ -901,7 +890,7 @@ pg_show(struct req *req, const char *ful } resp_begin_html(200, NULL); - resp_searchform(req); + resp_searchform(req, FOCUS_NONE); resp_show(req, file); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Sat Oct 22 20:57:53 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 123CAC1DD6D; Sat, 22 Oct 2016 20:57:53 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D2DBD6B8; Sat, 22 Oct 2016 20:57:52 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MKvpse014621; Sat, 22 Oct 2016 20:57:51 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MKvpAm014620; Sat, 22 Oct 2016 20:57:51 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610222057.u9MKvpAm014620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 22 Oct 2016 20:57:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307796 - stable/11/usr.sbin/syslogd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 20:57:53 -0000 Author: bapt Date: Sat Oct 22 20:57:51 2016 New Revision: 307796 URL: https://svnweb.freebsd.org/changeset/base/307796 Log: MFC r305707: Directly set the O_NONBLOCK flags via open(2) Modified: stable/11/usr.sbin/syslogd/syslogd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/syslogd/syslogd.c ============================================================================== --- stable/11/usr.sbin/syslogd/syslogd.c Sat Oct 22 20:56:49 2016 (r307795) +++ stable/11/usr.sbin/syslogd/syslogd.c Sat Oct 22 20:57:51 2016 (r307796) @@ -621,10 +621,7 @@ main(int argc, char *argv[]) dprintf("sending on inet and/or inet6 socket\n"); } - if ((fklog = open(_PATH_KLOG, O_RDONLY, 0)) >= 0) - if (fcntl(fklog, F_SETFL, O_NONBLOCK) < 0) - fklog = -1; - if (fklog < 0) + if ((fklog = open(_PATH_KLOG, O_RDONLY|O_NONBLOCK, 0)) < 0) dprintf("can't open %s (%d)\n", _PATH_KLOG, errno); /* tuck my process id away */ From owner-svn-src-stable@freebsd.org Sat Oct 22 21:28:15 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9E6BC1D480 for ; Sat, 22 Oct 2016 21:28:15 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yb0-x234.google.com (mail-yb0-x234.google.com [IPv6:2607:f8b0:4002:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 92BFA7C1 for ; Sat, 22 Oct 2016 21:28:15 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yb0-x234.google.com with SMTP id f97so49677248ybi.1 for ; Sat, 22 Oct 2016 14:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qG04PVtvioxAkWpHFmcx6Ye6hDPn8EJucIUw+S9yrRU=; b=NiA13JQD8iw50MSgwgQU6+nDJnNgJq/DTJ5RZ2gFVD3P2Pu7PwaqrCVeQfiRaeuOhO y0pxHDIs0KMA32I34769tUYDE1WYxQaoXQB1Fpd/A4lTib4ahRCffgFtA/ZUs1R4ThIH 5uDq8daHtvNaH5uIBWFgnVay/wfeZ2M1T2+b+4B8PWtMCSO3rLi/KlZ1B4dkWMNsxj1v 6LtSgX59RpIgLRezXbWPA6PXwwf2v35MSWjnKAJ2frtwhMZm2xHtvTSqbbQod/I6taoq E4yaOyUIbQFeO67m5PHPOSh+bH+z8JAUssXNwliRE+a8KIHhbcTnXMu8p76nIXABXvtp B6nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qG04PVtvioxAkWpHFmcx6Ye6hDPn8EJucIUw+S9yrRU=; b=jDwCB9qYSDTYDrnWfZ3qTkyEjOJ4P87LeoKEehVGOZFCOuva0TS86Q3DNjRTeR9BVJ HwkZK19xTISMkF8pEUfwkpOdsxRNohd7TGPcLXtGL4mXY0coKUBqgpylL3UA3R5mf9Eb L4Djf0hAkl42ejX0eNQnJ/CTQ9nfWsrFUX60HZsQcz5zqtkcu65/8kynZl9bFDJHwzaz T5m8HgcwZd7BXYNQDrjRsuKaaTEe+6rbIVjQIFOtkTCtBIwOFjjcbAXqcS+wUf+Jw1ct cZV11APXETylZPXN9uGRXg+tH0DUu9MlwMoBhLURz7mjx7bZPTJs6OA3W/tdao5zaaxl X35g== X-Gm-Message-State: ABUngvc3aLJvp513z1JjgBduCHg2qe/jH1A0b26pCa50Q6Zbko4JI3cH3/a/LarBY1FFQRThNYCNdfLmAZM+Ig== X-Received: by 10.37.84.7 with SMTP id i7mr8449906ybb.92.1477171694079; Sat, 22 Oct 2016 14:28:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.246.129 with HTTP; Sat, 22 Oct 2016 14:27:43 -0700 (PDT) In-Reply-To: <201610222049.u9MKnirM010685@repo.freebsd.org> References: <201610222049.u9MKnirM010685@repo.freebsd.org> From: Ed Schouten Date: Sat, 22 Oct 2016 23:27:43 +0200 Message-ID: Subject: Re: svn commit: r307791 - stable/11/usr.sbin/bhyve To: Baptiste Daroussin Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 21:28:15 -0000 Hi Baptiste, 2016-10-22 22:49 GMT+02:00 Baptiste Daroussin : > Use accept4 with O_NONBLOCK rather than accept + fcntl Keep in mind that changes like these do reduce the portability of the code. accept4(), SOCK_NONBLOCK, etc. are not part of POSIX. -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands KvK-nr.: 62051717 From owner-svn-src-stable@freebsd.org Sat Oct 22 21:30:21 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31978C1D515; Sat, 22 Oct 2016 21:30:21 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B6E7E952; Sat, 22 Oct 2016 21:30:20 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: by mail-wm0-x22d.google.com with SMTP id f193so47183400wmg.0; Sat, 22 Oct 2016 14:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=E6UcQDge/OZBQ/vRRH/PBp8djgmEdv2B6fT3M0rWfAk=; b=FeWO1aEsFdBTMWzfOc1HAK6Gy7JkcjlswN/oNfkHave3JzGPVZ2NEJx0VCB18rXwd9 uvjMpVQCjtyvqm+ZtGmQM6LFGXCV6g7u0Rw/dMZ57hp+3uNdl+7HnTWxWG1m4gfgA2T/ KumtYXy+5vJ4wQ6y3j2LvWFiLSZCfT/4AaSO4m+fJZvv+3Ocv9V9Se2jSVN/K4W9hl5m LNwa1gHQJz4P8yOdEZ2n9BNzWIzP4lw/i7kimx1qrM1sNsTz7njcwgz3AFxxHmym8S7n gm+ph5k1jPap43w7uxENeBjAcm6s+o46dIgNAWR2MQJayEwiA4lCX83hK2Pzk6SWP6oc ZE5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=E6UcQDge/OZBQ/vRRH/PBp8djgmEdv2B6fT3M0rWfAk=; b=LPQHOdyC3zZ3vmd22r7yIEHQml2t9YH20ecV2rN315nM0DWkCMG4QMdbo3sY/4yVFy 3HmTZqaOPuixFEvXCmgwT9ryenidWmAePhhW/d3rHFBhabKfI4n6xnFvR4S/1IZ2uHiP TnswVBkfbCgTL6pJZfOsbwUf5VtOI7V6QhgV7YBFd2RJ+IR50LNeghqsVecXbiLmjEzu GrN5OVIZC7Nl7PjY/UIVEeERde7AP5nVHt4YnKDXWQ0b6xAtBgxLbRFw6kI7zECiXwgE E6Plc5pJQANQ02NjMbImsYgPIJGITWghc0JaSocjvEFTyQBFcK5+2lpniq3MH1vneUrF HtMw== X-Gm-Message-State: ABUngvdBkplJXnCXNSAqnC7Nqz06EZaFtFR8hyYhGetv4dpBk4+tJvoJDRgELeFISgjLOA== X-Received: by 10.28.109.24 with SMTP id i24mr8064138wmc.111.1477171818762; Sat, 22 Oct 2016 14:30:18 -0700 (PDT) Received: from ivaldir.etoilebsd.net ([2001:41d0:8:db4c::1]) by smtp.gmail.com with ESMTPSA id f194sm3319526wmg.12.2016.10.22.14.30.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Oct 2016 14:30:18 -0700 (PDT) Sender: Baptiste Daroussin Date: Sat, 22 Oct 2016 23:30:17 +0200 From: Baptiste Daroussin To: Ed Schouten Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r307791 - stable/11/usr.sbin/bhyve Message-ID: <20161022213017.d6h2wji75r2huqqv@ivaldir.etoilebsd.net> References: <201610222049.u9MKnirM010685@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jhyhs2fzwdblxaob" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20161014 (1.7.1) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 21:30:21 -0000 --jhyhs2fzwdblxaob Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 22, 2016 at 11:27:43PM +0200, Ed Schouten wrote: > Hi Baptiste, >=20 > 2016-10-22 22:49 GMT+02:00 Baptiste Daroussin : > > Use accept4 with O_NONBLOCK rather than accept + fcntl >=20 > Keep in mind that changes like these do reduce the portability of the > code. accept4(), SOCK_NONBLOCK, etc. are not part of POSIX. >=20 I entirely forgot that! Thanks for the heads up, I'll be carefull Best regards, Bapt --jhyhs2fzwdblxaob Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJYC9pmAAoJEGOJi9zxtz5aSEQQAIK5qOyEg0MQVi6MpyWVsQlO d0a38Cnfn04w2dMW2vXrtrSsWLw4vqtueVrAqN1sNEBIe/TTkoHyJHiIpA5CHlog Dr02RSfWnwAvsmIAMQWWInCmtpCdVKO4a4udE02vw3RaYFNecoFj0wDgqmIkKhAY 6yD9rMn1tA5/+3F1bh1mq7sBGiVmoCgI9MzyPdNSdEQrISfEcWI8r34cP5WmIzAx r2QGlym1oSsryEctGH1wcq8ACMd9HvrlJMmXa5CZpQma5Gno531X2CknjerO3JCI IXFkEpBTelYzF+gYRW+k0SjFgPd/CbU/dFmmQImQuqgyTH5jjovr8A3rHtcJ1TOp O8ZDl+r7pw/IrIhADyyJfYGFBoW6uRzv9cTJqeQ0uRnV6FcJYXfxUWVilyJW4k+g ACEP/bnRP04i06W2+WK/P0ZMVXAKsfNPWxY4c81NE4JYRsWm6UMs9urDqwA0sxGV 2Hff5LCcxAP6In8MvB9c7+k1W/B5/UuYR+hbu/jojZVrmmD1jYkUaE8l5exMTbeF pJaduv4mFnVQzYh4IjOd5xbXLeCr/eJ7UKcByfo0RPFgNyyUOv8aNB3cWdgI01tO +kch1O0l0nhcdmobbqyAkjf8ymcJrm0eWiOH/urjcI046o1rk4DplYNenBW1Nzjk pexHt+wgZIre6jzo8Mtp =4GlP -----END PGP SIGNATURE----- --jhyhs2fzwdblxaob-- From owner-svn-src-stable@freebsd.org Sat Oct 22 21:41:02 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73193C1D92E; Sat, 22 Oct 2016 21:41:02 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 37DC5F30; Sat, 22 Oct 2016 21:41:02 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MLf1Fc032546; Sat, 22 Oct 2016 21:41:01 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MLf0Ih032536; Sat, 22 Oct 2016 21:41:00 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201610222141.u9MLf0Ih032536@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Sat, 22 Oct 2016 21:41:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307797 - in stable/11/contrib/libarchive: cpio/test libarchive libarchive/test tar/test X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 21:41:02 -0000 Author: mm Date: Sat Oct 22 21:41:00 2016 New Revision: 307797 URL: https://svnweb.freebsd.org/changeset/base/307797 Log: MFC r307215: Sync libarchive with vendor. Style and tests fixes. Important vendor bugfixes (relevant to FreeBSD): #801: FreeBSD Coverity report: resource leak in libarchive/tar/test/main.c Modified: stable/11/contrib/libarchive/cpio/test/main.c stable/11/contrib/libarchive/cpio/test/test.h stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c stable/11/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c stable/11/contrib/libarchive/libarchive/test/main.c stable/11/contrib/libarchive/libarchive/test/test.h stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c stable/11/contrib/libarchive/tar/test/main.c stable/11/contrib/libarchive/tar/test/test.h stable/11/contrib/libarchive/tar/test/test_missing_file.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/libarchive/cpio/test/main.c ============================================================================== --- stable/11/contrib/libarchive/cpio/test/main.c Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/cpio/test/main.c Sat Oct 22 21:41:00 2016 (r307797) @@ -130,6 +130,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1294,6 +1301,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1425,7 +1437,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1661,6 +1673,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1675,6 +1688,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: stable/11/contrib/libarchive/cpio/test/test.h ============================================================================== --- stable/11/contrib/libarchive/cpio/test/test.h Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/cpio/test/test.h Sat Oct 22 21:41:00 2016 (r307797) @@ -182,6 +182,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -327,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Sat Oct 22 21:41:00 2016 (r307797) @@ -627,7 +627,6 @@ translate_acl(struct archive_read_disk * archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unknown ACL brand"); return (ARCHIVE_WARN); - break; } #endif Modified: stable/11/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c Sat Oct 22 21:41:00 2016 (r307797) @@ -232,6 +232,7 @@ static const char * lookup_uname_helper(struct name_cache *cache, id_t id) { struct passwd *result; + (void)cache; /* UNUSED */ result = getpwuid((uid_t)id); @@ -298,6 +299,7 @@ static const char * lookup_gname_helper(struct name_cache *cache, id_t id) { struct group *result; + (void)cache; /* UNUSED */ result = getgrgid((gid_t)id); Modified: stable/11/contrib/libarchive/libarchive/test/main.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/test/main.c Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/libarchive/test/main.c Sat Oct 22 21:41:00 2016 (r307797) @@ -128,6 +128,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1364,6 +1371,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1403,7 +1435,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1440,31 +1472,6 @@ assertion_file_size(const char *file, in return (0); } -/* Verify mode of 'pathname'. */ -int -assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) -{ - int mode; - int r; - - assertion_count(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) - failure_start(file, line, "assertFileMode not yet implemented for Windows"); -#else - { - struct stat st; - r = lstat(pathname, &st); - mode = (int)(st.st_mode & 0777); - } - if (r == 0 && mode == expected_mode) - return (1); - failure_start(file, line, "File %s has mode %o, expected %o", - pathname, mode, expected_mode); -#endif - failure_finish(NULL); - return (0); -} - /* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */ int assertion_is_dir(const char *file, int line, const char *pathname, int mode) @@ -1664,6 +1671,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1678,6 +1686,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: stable/11/contrib/libarchive/libarchive/test/test.h ============================================================================== --- stable/11/contrib/libarchive/libarchive/test/test.h Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/libarchive/test/test.h Sat Oct 22 21:41:00 2016 (r307797) @@ -243,12 +243,12 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); int assertion_file_not_exists(const char *, int, const char *); int assertion_file_size(const char *, int, const char *, long); -int assertion_file_mode(const char *, int, const char *, int); int assertion_is_dir(const char *, int, const char *, int); int assertion_is_hardlink(const char *, int, const char *, const char *); int assertion_is_not_hardlink(const char *, int, const char *, const char *); @@ -329,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c Sat Oct 22 21:41:00 2016 (r307797) @@ -200,6 +200,8 @@ DEFINE_TEST(test_read_append_filter_wron { struct archive_entry *ae; struct archive *a; + int fd; + fpos_t pos; /* * If we have "bunzip2 -q", try using that. @@ -208,6 +210,13 @@ DEFINE_TEST(test_read_append_filter_wron skipping("Can't run bunzip2 program on this platform"); return; } + + /* bunzip2 will write to stderr, redirect it to a file */ + fflush(stderr); + fgetpos(stderr, &pos); + fd = dup(fileno(stderr)); + freopen("stderr1", "w", stderr); + assert((a = archive_read_new()) != NULL); assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR)); assertEqualIntA(a, ARCHIVE_OK, @@ -217,4 +226,13 @@ DEFINE_TEST(test_read_append_filter_wron assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN)); assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + /* restore stderr */ + fflush(stderr); + dup2(fd, fileno(stderr)); + close(fd); + clearerr(stderr); + fsetpos(stderr, &pos); + + assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1"); } Modified: stable/11/contrib/libarchive/tar/test/main.c ============================================================================== --- stable/11/contrib/libarchive/tar/test/main.c Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/tar/test/main.c Sat Oct 22 21:41:00 2016 (r307797) @@ -1164,6 +1164,35 @@ assertion_file_contains_lines_any_order( return (0); } +/* Verify that a text file does not contains the specified strings */ +int +assertion_file_contains_no_invalid_strings(const char *file, int line, + const char *pathname, const char *strings[]) +{ + char *buff; + int i; + + buff = slurpfile(NULL, "%s", pathname); + if (buff == NULL) { + failure_start(file, line, "Can't read file: %s", pathname); + failure_finish(NULL); + return (0); + } + + for (i = 0; strings[i] != NULL; ++i) { + if (strstr(buff, strings[i]) != NULL) { + failure_start(file, line, "Invalid string in %s: %s", pathname, + strings[i]); + failure_finish(NULL); + free(buff); + return(0); + } + } + + free(buff); + return (0); +} + /* Test that two paths point to the same file. */ /* As a side-effect, asserts that both files exist. */ static int @@ -1301,6 +1330,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1432,7 +1466,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1668,6 +1702,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1682,6 +1717,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: stable/11/contrib/libarchive/tar/test/test.h ============================================================================== --- stable/11/contrib/libarchive/tar/test/test.h Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/tar/test/test.h Sat Oct 22 21:41:00 2016 (r307797) @@ -174,6 +174,9 @@ /* Assert that file contents match a string. */ #define assertFileContents(data, data_size, pathname) \ assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname) +/* Verify that a file does not contain invalid strings */ +#define assertFileContainsNoInvalidStrings(pathname, strings) \ + assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings) #define assertFileMtime(pathname, sec, nsec) \ assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec) #define assertFileMtimeRecent(pathname) \ @@ -182,6 +185,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -239,6 +244,7 @@ int assertion_file_atime_recent(const ch int assertion_file_birthtime(const char *, int, const char *, long, long); int assertion_file_birthtime_recent(const char *, int, const char *); int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); +int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); int assertion_file_mode(const char *, int, const char *, int); Modified: stable/11/contrib/libarchive/tar/test/test_missing_file.c ============================================================================== --- stable/11/contrib/libarchive/tar/test/test_missing_file.c Sat Oct 22 20:57:51 2016 (r307796) +++ stable/11/contrib/libarchive/tar/test/test_missing_file.c Sat Oct 22 21:41:00 2016 (r307797) @@ -27,11 +27,15 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_missing_file) { + const char * invalid_stderr[] = { "INTERNAL ERROR", NULL }; assertMakeFile("file1", 0644, "file1"); assertMakeFile("file2", 0644, "file2"); assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog)); assertEmptyFile("stderr1"); assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog)); + assertFileContainsNoInvalidStrings("stderr2", invalid_stderr); assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog)); - assert(0 != systemf("%s -cf archive.tar file3 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr3", invalid_stderr); + assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr4", invalid_stderr); } From owner-svn-src-stable@freebsd.org Sat Oct 22 21:41:30 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38F45C1D99B; Sat, 22 Oct 2016 21:41:30 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 027CB10E3; Sat, 22 Oct 2016 21:41:29 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MLfTOq033401; Sat, 22 Oct 2016 21:41:29 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MLfSQm033391; Sat, 22 Oct 2016 21:41:28 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201610222141.u9MLfSQm033391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Sat, 22 Oct 2016 21:41:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307798 - in stable/10/contrib/libarchive: cpio/test libarchive libarchive/test tar/test X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 21:41:30 -0000 Author: mm Date: Sat Oct 22 21:41:28 2016 New Revision: 307798 URL: https://svnweb.freebsd.org/changeset/base/307798 Log: MFC r307215: Sync libarchive with vendor. Style and tests fixes. Important vendor bugfixes (relevant to FreeBSD): #801: FreeBSD Coverity report: resource leak in libarchive/tar/test/main.c Modified: stable/10/contrib/libarchive/cpio/test/main.c stable/10/contrib/libarchive/cpio/test/test.h stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c stable/10/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c stable/10/contrib/libarchive/libarchive/test/main.c stable/10/contrib/libarchive/libarchive/test/test.h stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c stable/10/contrib/libarchive/tar/test/main.c stable/10/contrib/libarchive/tar/test/test.h stable/10/contrib/libarchive/tar/test/test_missing_file.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/libarchive/cpio/test/main.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/main.c Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/cpio/test/main.c Sat Oct 22 21:41:28 2016 (r307798) @@ -130,6 +130,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1294,6 +1301,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1425,7 +1437,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1661,6 +1673,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1675,6 +1688,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: stable/10/contrib/libarchive/cpio/test/test.h ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test.h Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/cpio/test/test.h Sat Oct 22 21:41:28 2016 (r307798) @@ -182,6 +182,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -327,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Sat Oct 22 21:41:28 2016 (r307798) @@ -627,7 +627,6 @@ translate_acl(struct archive_read_disk * archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unknown ACL brand"); return (ARCHIVE_WARN); - break; } #endif Modified: stable/10/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c Sat Oct 22 21:41:28 2016 (r307798) @@ -232,6 +232,7 @@ static const char * lookup_uname_helper(struct name_cache *cache, id_t id) { struct passwd *result; + (void)cache; /* UNUSED */ result = getpwuid((uid_t)id); @@ -298,6 +299,7 @@ static const char * lookup_gname_helper(struct name_cache *cache, id_t id) { struct group *result; + (void)cache; /* UNUSED */ result = getgrgid((gid_t)id); Modified: stable/10/contrib/libarchive/libarchive/test/main.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/main.c Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/libarchive/test/main.c Sat Oct 22 21:41:28 2016 (r307798) @@ -128,6 +128,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1364,6 +1371,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1403,7 +1435,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1440,31 +1472,6 @@ assertion_file_size(const char *file, in return (0); } -/* Verify mode of 'pathname'. */ -int -assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) -{ - int mode; - int r; - - assertion_count(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) - failure_start(file, line, "assertFileMode not yet implemented for Windows"); -#else - { - struct stat st; - r = lstat(pathname, &st); - mode = (int)(st.st_mode & 0777); - } - if (r == 0 && mode == expected_mode) - return (1); - failure_start(file, line, "File %s has mode %o, expected %o", - pathname, mode, expected_mode); -#endif - failure_finish(NULL); - return (0); -} - /* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */ int assertion_is_dir(const char *file, int line, const char *pathname, int mode) @@ -1664,6 +1671,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1678,6 +1686,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: stable/10/contrib/libarchive/libarchive/test/test.h ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/test.h Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/libarchive/test/test.h Sat Oct 22 21:41:28 2016 (r307798) @@ -243,12 +243,12 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); int assertion_file_not_exists(const char *, int, const char *); int assertion_file_size(const char *, int, const char *, long); -int assertion_file_mode(const char *, int, const char *, int); int assertion_is_dir(const char *, int, const char *, int); int assertion_is_hardlink(const char *, int, const char *, const char *); int assertion_is_not_hardlink(const char *, int, const char *, const char *); @@ -329,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c Sat Oct 22 21:41:28 2016 (r307798) @@ -200,6 +200,8 @@ DEFINE_TEST(test_read_append_filter_wron { struct archive_entry *ae; struct archive *a; + int fd; + fpos_t pos; /* * If we have "bunzip2 -q", try using that. @@ -208,6 +210,13 @@ DEFINE_TEST(test_read_append_filter_wron skipping("Can't run bunzip2 program on this platform"); return; } + + /* bunzip2 will write to stderr, redirect it to a file */ + fflush(stderr); + fgetpos(stderr, &pos); + fd = dup(fileno(stderr)); + freopen("stderr1", "w", stderr); + assert((a = archive_read_new()) != NULL); assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR)); assertEqualIntA(a, ARCHIVE_OK, @@ -217,4 +226,13 @@ DEFINE_TEST(test_read_append_filter_wron assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN)); assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + /* restore stderr */ + fflush(stderr); + dup2(fd, fileno(stderr)); + close(fd); + clearerr(stderr); + fsetpos(stderr, &pos); + + assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1"); } Modified: stable/10/contrib/libarchive/tar/test/main.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/main.c Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/tar/test/main.c Sat Oct 22 21:41:28 2016 (r307798) @@ -1164,6 +1164,35 @@ assertion_file_contains_lines_any_order( return (0); } +/* Verify that a text file does not contains the specified strings */ +int +assertion_file_contains_no_invalid_strings(const char *file, int line, + const char *pathname, const char *strings[]) +{ + char *buff; + int i; + + buff = slurpfile(NULL, "%s", pathname); + if (buff == NULL) { + failure_start(file, line, "Can't read file: %s", pathname); + failure_finish(NULL); + return (0); + } + + for (i = 0; strings[i] != NULL; ++i) { + if (strstr(buff, strings[i]) != NULL) { + failure_start(file, line, "Invalid string in %s: %s", pathname, + strings[i]); + failure_finish(NULL); + free(buff); + return(0); + } + } + + free(buff); + return (0); +} + /* Test that two paths point to the same file. */ /* As a side-effect, asserts that both files exist. */ static int @@ -1301,6 +1330,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1432,7 +1466,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1668,6 +1702,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1682,6 +1717,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: stable/10/contrib/libarchive/tar/test/test.h ============================================================================== --- stable/10/contrib/libarchive/tar/test/test.h Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/tar/test/test.h Sat Oct 22 21:41:28 2016 (r307798) @@ -174,6 +174,9 @@ /* Assert that file contents match a string. */ #define assertFileContents(data, data_size, pathname) \ assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname) +/* Verify that a file does not contain invalid strings */ +#define assertFileContainsNoInvalidStrings(pathname, strings) \ + assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings) #define assertFileMtime(pathname, sec, nsec) \ assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec) #define assertFileMtimeRecent(pathname) \ @@ -182,6 +185,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -239,6 +244,7 @@ int assertion_file_atime_recent(const ch int assertion_file_birthtime(const char *, int, const char *, long, long); int assertion_file_birthtime_recent(const char *, int, const char *); int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); +int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); int assertion_file_mode(const char *, int, const char *, int); Modified: stable/10/contrib/libarchive/tar/test/test_missing_file.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_missing_file.c Sat Oct 22 21:41:00 2016 (r307797) +++ stable/10/contrib/libarchive/tar/test/test_missing_file.c Sat Oct 22 21:41:28 2016 (r307798) @@ -27,11 +27,15 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_missing_file) { + const char * invalid_stderr[] = { "INTERNAL ERROR", NULL }; assertMakeFile("file1", 0644, "file1"); assertMakeFile("file2", 0644, "file2"); assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog)); assertEmptyFile("stderr1"); assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog)); + assertFileContainsNoInvalidStrings("stderr2", invalid_stderr); assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog)); - assert(0 != systemf("%s -cf archive.tar file3 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr3", invalid_stderr); + assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr4", invalid_stderr); } From owner-svn-src-stable@freebsd.org Sat Oct 22 22:36:33 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A24FC1DA8D; Sat, 22 Oct 2016 22:36:33 +0000 (UTC) (envelope-from grog@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B8458EA; Sat, 22 Oct 2016 22:36:33 +0000 (UTC) (envelope-from grog@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9MMaW7u052339; Sat, 22 Oct 2016 22:36:32 GMT (envelope-from grog@FreeBSD.org) Received: (from grog@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9MMaWg7052338; Sat, 22 Oct 2016 22:36:32 GMT (envelope-from grog@FreeBSD.org) Message-Id: <201610222236.u9MMaWg7052338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grog set sender to grog@FreeBSD.org using -f From: Greg Lehey Date: Sat, 22 Oct 2016 22:36:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307803 - stable/10/usr.bin/calendar/calendars X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 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, 22 Oct 2016 22:36:33 -0000 Author: grog Date: Sat Oct 22 22:36:32 2016 New Revision: 307803 URL: https://svnweb.freebsd.org/changeset/base/307803 Log: Spelling, title. Modified: stable/10/usr.bin/calendar/calendars/calendar.holiday Modified: stable/10/usr.bin/calendar/calendars/calendar.holiday ============================================================================== --- stable/10/usr.bin/calendar/calendars/calendar.holiday Sat Oct 22 22:35:39 2016 (r307802) +++ stable/10/usr.bin/calendar/calendars/calendar.holiday Sat Oct 22 22:36:32 2016 (r307803) @@ -447,7 +447,7 @@ 10/20 Kenyatta Day in Kenya 10/21 Armed Forces Day in Honduras 10/21 Revolution Days (2 days) in Somalia -10/23 Chulalongkron's Day in Thailand +10/23 King Chulalongkorn Day in Thailand 10/24 Independence Day in Zambia 10/24 United Nations Day 10/25 Taiwan Restoration Day in Taiwan