Re: svn commit: r214303 - in head/sys: conf netinet

2010-10-24 Thread Garrett Cooper
On Oct 24, 2010, at 4:36 PM, Julian Elischer  wrote:

> On 10/24/10 3:02 PM, Bjoern A. Zeeb wrote:
>> Author: bz
>> Date: Sun Oct 24 22:02:36 2010
>> New Revision: 214303
>> URL: http://svn.freebsd.org/changeset/base/214303
>> 
>> Log:
>>   Add initial inet DDB support for show in_ifaddr and show sin commands which
>>   proved to be useful while debugging address list problems.
> 
> sin commands?  really?   "Covet thy neighbor's wife!"
>> 
>> 

As long as DDB doesn't hold false WITNESS (LOR), we should be ok 
:)...___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214303 - in head/sys: conf netinet

2010-10-24 Thread Julian Elischer

On 10/24/10 3:02 PM, Bjoern A. Zeeb wrote:

Author: bz
Date: Sun Oct 24 22:02:36 2010
New Revision: 214303
URL: http://svn.freebsd.org/changeset/base/214303

Log:
   Add initial inet DDB support for show in_ifaddr and show sin commands which
   proved to be useful while debugging address list problems.


sin commands?  really?   "Covet thy neighbor's wife!"






___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214309 - head/share/examples

2010-10-24 Thread Julian Elischer
Author: julian
Date: Sun Oct 24 23:25:14 2010
New Revision: 214309
URL: http://svn.freebsd.org/changeset/base/214309

Log:
  Add Makefile entry to install two new example files.
  
  MFC after:2 weeks

Modified:
  head/share/examples/Makefile

Modified: head/share/examples/Makefile
==
--- head/share/examples/MakefileSun Oct 24 23:19:11 2010
(r214308)
+++ head/share/examples/MakefileSun Oct 24 23:25:14 2010
(r214309)
@@ -17,6 +17,7 @@ LDIRS=BSD_daemon \
ibcs2 \
indent \
ipfw \
+   jails \
kld \
libvgl \
mdoc \
@@ -80,6 +81,7 @@ XFILES=   BSD_daemon/FreeBSD.pfa \
ibcs2/hello.uu \
indent/indent.pro \
ipfw/change_rules.sh \
+   jails/README \
kld/Makefile \
kld/cdev/Makefile \
kld/cdev/README \
@@ -116,6 +118,8 @@ XFILES= BSD_daemon/FreeBSD.pfa \
netgraph/ngctl \
netgraph/raw \
netgraph/udp.tunnel \
+   netgraph/virtual.chain \
+   netgraph/virtual.lan \
nwclient/dot.nwfsrc \
nwclient/nwfs.sh.sample \
perfmon/Makefile \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214308 - head/etc/mtree

2010-10-24 Thread Julian Elischer
Author: julian
Date: Sun Oct 24 23:19:11 2010
New Revision: 214308
URL: http://svn.freebsd.org/changeset/base/214308

Log:
  Add a jails directory in the examples section
  
  MFC after:2 weeks

Modified:
  head/etc/mtree/BSD.usr.dist

Modified: head/etc/mtree/BSD.usr.dist
==
--- head/etc/mtree/BSD.usr.dist Sun Oct 24 23:09:00 2010(r214307)
+++ head/etc/mtree/BSD.usr.dist Sun Oct 24 23:19:11 2010(r214308)
@@ -227,6 +227,8 @@
 ..
 iscsi
 ..
+jails
+..
 kld
 cdev
 module
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214306 - in head/share/examples: jails netgraph

2010-10-24 Thread Julian Elischer
Author: julian
Date: Sun Oct 24 22:59:38 2010
New Revision: 214306
URL: http://svn.freebsd.org/changeset/base/214306

Log:
  Add two scripts that demonstrate how to make and
  hook together jails using teh vortual networking feature.
  
  Submitted by: Yavuz Gokirmak
  MFC after:2 weeks

Added:
  head/share/examples/jails/
  head/share/examples/jails/README   (contents, props changed)
  head/share/examples/netgraph/virtual.chain   (contents, props changed)
  head/share/examples/netgraph/virtual.lan   (contents, props changed)

Added: head/share/examples/jails/README
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/examples/jails/READMESun Oct 24 22:59:38 2010
(r214306)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+See under share/examples/netgraph for some examples of
+making and hooking together jails using netgraph as the
+virtual networking fabric.

Added: head/share/examples/netgraph/virtual.chain
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/examples/netgraph/virtual.chain  Sun Oct 24 22:59:38 2010
(r214306)
@@ -0,0 +1,373 @@
+#!/bin/sh
+#
+# Copyright (c) 2010, Yavuz Gokirmak 
+#
+# All rights reserved.
+#
+# This source code may be used, modified, copied, distributed, and
+# sold, in both source and binary form provided that the above
+# copyright and these terms are retained, verbatim, as the first
+# lines of this file.  Under no circumstances is the author
+# responsible for the proper functioning of the software nor does
+# the author assume any responsibility for damages incurred with
+# its use.
+#
+# $FreeBSD$
+#
+#
+# This script creates and connects n router like nodes. Complex wide
+# area topologies can be created with the help of script.
+#
+# Virtual nodes are generated via jails and network connections are
+# established using ng_eiface(4) node types.
+#
+# To use this script:
+#
+# 0. Make your own copy of this example script.
+#
+# 1. Edit the definition of ${TARGET_TOPOLOGY} to define your virtual 
+#nodes. Virtual topology definition includes node names and their
+#IP address. Target top. sytax: ( name|ip<->name|ip ... )
+#Example 1: ( n1|10.0.2.1/30<->n2|10.0.2.2/30 ...)
+#Example 2: ( n1|2001:b90::14a/125<->n1|2001:b90::14b/125 ...)
+#
+# 2. Run this script with "start" as the command line argument.
+#
+# 3. Add necessary static route commands for each virtual node. For
+#example assume you have three virtual nodes connected each other
+#llike a chain ( n1 is connected to n2, n2 is connecte to n3 ). 
+#In order to estabklish connectivity among these virtual nodes,
+#you have to add default routes to node n1 and node n3. Example
+#static route command is:
+#  STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" 
+#  STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" 
+#After defining default routes with above format you have to set 
+#the total number of static route commands as:
+#  STATIC_ROUTE_CNT=2
+#
+# 4. Stop bridging by running this script with "stop" as the
+#command line argument.
+# 
+# 5. This cript uses a template file in order to carry information 
+#between start and stop calls. 
+#  In the start call, the netgraph interfaces and jails are created.
+#  At the stop phase, all created objects should be removed.
+#DO NOT delete the temporary file between the start and stop phases.
+#
+# Target Topology:
+#
+# +---+  +-+
+# |  n1 (vimage)  |  | n2 (vimage) |
+# |   |  | |
+# | +---+ |  | +---+  +---+  +---+ |
+# | |  ngeth0   | |  | |  ngeth1   |  |  ngeth2   |  |  ngeth4   | |
+# | |(ng_eiface)| |  | |(ng_eiface)|  |(ng_eiface)|  |(ng_eiface)| |
+# | +--+-+--+ |  | +--+-+--+  +--+-+--+  +--+-+--+ |
+# ||ether||  ||ether||ether||ether||
+# |+-X---+|  |+--X--++--X--++--X--+|
+# +---X---+  +--X--X---X---+
+# XX  XX
+#  X   X XX
+#   XXXX  X
+#XX
+#  +X--+ +X--+
+#  |   -+--X--+-   | |   -+--X--+-   |
+#  ||ether|| ||ether||
+#  | +--+-+--+ | | +--+-+--+ |
+#  | |  ngeth3   | | | |  ngeth5   | |
+#  | |(ng_eiface)| | | |(ng_eiface)| |
+#   

svn commit: r214305 - head/bin/sh

2010-10-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun Oct 24 22:25:38 2010
New Revision: 214305
URL: http://svn.freebsd.org/changeset/base/214305

Log:
  sh: Ignore double-quotes in arithmetic rather than treating them as quotes.
  
  This provides similar behaviour, but allows a simpler parser.
  
  This changes r206473.
  
  Exp-run done by:  pav (with some other sh(1) changes)

Modified:
  head/bin/sh/mksyntax.c
  head/bin/sh/parser.c

Modified: head/bin/sh/mksyntax.c
==
--- head/bin/sh/mksyntax.c  Sun Oct 24 22:03:21 2010(r214304)
+++ head/bin/sh/mksyntax.c  Sun Oct 24 22:25:38 2010(r214305)
@@ -75,6 +75,7 @@ struct synclass synclass[] = {
{ "CEOF",   "end of file" },
{ "CCTL",   "like CWORD, except it must be escaped" },
{ "CSPCL",  "these terminate a word" },
+   { "CIGN",   "character should be ignored" },
{ NULL, NULL }
 };
 
@@ -232,7 +233,7 @@ main(int argc __unused, char **argv __un
add("\n", "CNL");
add("\\", "CBACK");
add("`", "CBQUOTE");
-   add("\"", "CDQUOTE");
+   add("\"", "CIGN");
add("$", "CVAR");
add("}", "CENDVAR");
add("(", "CLP");

Modified: head/bin/sh/parser.c
==
--- head/bin/sh/parser.cSun Oct 24 22:03:21 2010(r214304)
+++ head/bin/sh/parser.cSun Oct 24 22:25:38 2010(r214305)
@@ -1224,10 +1224,7 @@ readtoken1(int firstc, char const *initi
if (eofmark != NULL && newvarnest == 0)
USTPUTC(c, out);
else {
-   if (state[level].category == 
TSTATE_ARITH)
-   state[level].syntax = ARISYNTAX;
-   else
-   state[level].syntax = 
BASESYNTAX;
+   state[level].syntax = BASESYNTAX;
quotef++;
}
break;
@@ -1282,6 +1279,8 @@ readtoken1(int firstc, char const *initi
break;
case CEOF:
goto endword;   /* exit outer loop */
+   case CIGN:
+   break;
default:
if (level == 0)
goto endword;   /* exit outer loop */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214304 - in head: bin/sh tools/regression/bin/sh/execution

2010-10-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun Oct 24 22:03:21 2010
New Revision: 214304
URL: http://svn.freebsd.org/changeset/base/214304

Log:
  sh: Do not allow overriding a special builtin with a function.
  This is a syntax error.
  
  POSIX does not say explicitly whether defining a function with the same name
  as a special builtin is allowed, but it does say that it is impossible to
  call such a function.
  
  A special builtin can still be overridden with an alias.
  
  This commit is part of a set of changes that will ensure that when
  something looks like a special builtin to the parser, it is one. (Not the
  other way around, as it remains possible to call a special builtin named
  by a variable or other substitution.)
  
  Exp-run done by:  pav (with some other sh(1) changes)

Added:
  head/tools/regression/bin/sh/execution/func3.0   (contents, props changed)
Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==
--- head/bin/sh/parser.cSun Oct 24 22:02:36 2010(r214303)
+++ head/bin/sh/parser.cSun Oct 24 22:03:21 2010(r214304)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include "alias.h"
 #include "show.h"
 #include "eval.h"
+#include "exec.h"  /* to check for special builtins */
 #ifndef NO_HISTORY
 #include "myhistedit.h"
 #endif
@@ -606,6 +607,7 @@ simplecmd(union node **rpp, union node *
union node *args, **app;
union node **orig_rpp = rpp;
union node *n = NULL;
+   int special;
 
/* If we don't have any redirections already, then we must reset */
/* rpp to be the address of the local redir variable.  */
@@ -647,6 +649,9 @@ simplecmd(union node **rpp, union node *
strchr(n->narg.text, '/'))
synerror("Bad function name");
rmescapes(n->narg.text);
+   if (find_builtin(n->narg.text, &special) >= 0 &&
+   special)
+   synerror("Cannot override a special builtin 
with a function");
n->type = NDEFUN;
n->narg.next = command();
funclinno = 0;

Added: head/tools/regression/bin/sh/execution/func3.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/func3.0  Sun Oct 24 22:03:21 
2010(r214304)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+# This may fail when parsing or when defining the function, or the definition
+# may silently do nothing. In no event may the function be executed.
+
+sh -c 'unset() { echo overriding function executed, bad; }; v=1; unset v; exit 
"${v-0}"' 2>/dev/null
+:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214303 - in head/sys: conf netinet

2010-10-24 Thread Bjoern A. Zeeb
Author: bz
Date: Sun Oct 24 22:02:36 2010
New Revision: 214303
URL: http://svn.freebsd.org/changeset/base/214303

Log:
  Add initial inet DDB support for show in_ifaddr and show sin commands which
  proved to be useful while debugging address list problems.
  
  MFC after:6 days

Added:
  head/sys/netinet/in_debug.c   (contents, props changed)
Modified:
  head/sys/conf/files

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sun Oct 24 21:59:51 2010(r214302)
+++ head/sys/conf/files Sun Oct 24 22:02:36 2010(r214303)
@@ -2559,6 +2559,7 @@ netinet/if_atm.c  optional atm
 netinet/if_ether.c optional inet ether
 netinet/igmp.c optional inet
 netinet/in.c   optional inet
+netinet/in_debug.c optional inet ddb
 netinet/ip_carp.c  optional inet carp | inet6 carp
 netinet/in_gif.c   optional gif inet | netgraph_gif inet
 netinet/ip_gre.c   optional gre inet

Added: head/sys/netinet/in_debug.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/netinet/in_debug.c Sun Oct 24 22:02:36 2010(r214303)
@@ -0,0 +1,120 @@
+/*-
+ * Copyright (c) 2010 Bjoern A. Zeeb 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include "opt_ddb.h"
+
+#include 
+#include 
+#include 
+
+#ifdef DDB
+#include 
+#endif
+
+#include 
+#include 
+
+#include 
+#include 
+
+#ifdef DDB
+static void
+in_show_sockaddr_in(struct sockaddr_in *sin)
+{
+
+#defineSIN_DB_RPINTF(f, e) db_printf("\t   %s = " f "\n", #e, 
sin->e);
+   db_printf("\tsockaddr_in = %p\n", sin);
+   SIN_DB_RPINTF("%u", sin_len);
+   SIN_DB_RPINTF("%u", sin_family);
+   SIN_DB_RPINTF("%u", sin_port);
+   SIN_DB_RPINTF("0x%08x", sin_addr.s_addr);
+   db_printf("\t   %s = %02x%02x%02x%02x%02x%02x%02x%02x\n",
+   "sin_zero[8]",
+   sin->sin_zero[0], sin->sin_zero[1],
+   sin->sin_zero[2], sin->sin_zero[3],
+   sin->sin_zero[4], sin->sin_zero[5],
+   sin->sin_zero[6], sin->sin_zero[7]);
+#undef SIN_DB_RPINTF
+}
+
+DB_SHOW_COMMAND(sin, db_show_sin)
+{
+   struct sockaddr_in *sin;
+
+   sin = (struct sockaddr_in *)addr;
+   if (sin == NULL) {
+   /* usage: No need to confess if you didn't sin. */
+   db_printf("usage: show sin \n");
+   return;
+   }
+
+   in_show_sockaddr_in(sin);
+}
+
+static void
+in_show_in_ifaddr(struct in_ifaddr *ia)
+{
+
+#defineIA_DB_RPINTF(f, e)  db_printf("\t   %s = " f "\n", #e, 
ia->e);
+#defineIA_DB_RPINTF_PTR(f, e)  db_printf("\t   %s = " f "\n", #e, 
&ia->e);
+#defineIA_DB_RPINTF_DPTR(f, e) db_printf("\t  *%s = " f "\n", #e, 
*ia->e);
+   db_printf("\tin_ifaddr = %p\n", ia);
+   IA_DB_RPINTF_PTR("%p", ia_ifa);
+   IA_DB_RPINTF("0x%08lx", ia_net);
+   IA_DB_RPINTF("0x%08lx", ia_netmask);
+   IA_DB_RPINTF("0x%08lx", ia_subnet);
+   IA_DB_RPINTF("0x%08lx", ia_subnetmask);
+   IA_DB_RPINTF("0x%08x", ia_netbroadcast.s_addr);
+   IA_DB_RPINTF("%p", ia_hash.le_next);
+   IA_DB_RPINTF("%p", ia_hash.le_prev);
+   IA_DB_RPINTF_DPTR("%p", ia_hash.le_prev);
+   IA_DB_RPINTF("%p", ia_link.tqe_next);
+   IA_DB_RPINTF("%p", ia_link.tqe_prev);
+   IA_DB_RPINTF_DPTR("%p", ia_link.tqe_prev);
+   IA_DB_RPINTF_PTR("%p", ia_addr);
+   IA_DB_RPINTF_PTR("%p", ia_dstaddr);
+   IA_DB_RPINTF_PTR("%p", ia_sockmask);
+#undef IA_DB_RPINTF_DPTR
+#unde

svn commit: r214302 - head/sys/dev/fxp

2010-10-24 Thread Pyun YongHyeon
Author: yongari
Date: Sun Oct 24 21:59:51 2010
New Revision: 214302
URL: http://svn.freebsd.org/changeset/base/214302

Log:
  Add TSO support over VLAN for i82550/i82551. Controller requires
  VLAN hardware tagging to make TSO work over VLAN. So if VLAN
  hardware tagging is disabled explicitly clear TSO over VLAN. While
  I'm here allow disabling VLAN TX checksum offloading.
  
  Tested by:Liudas < liudasb <> centras dot lt >
  MFC after:10 days

Modified:
  head/sys/dev/fxp/if_fxp.c

Modified: head/sys/dev/fxp/if_fxp.c
==
--- head/sys/dev/fxp/if_fxp.c   Sun Oct 24 21:28:58 2010(r214301)
+++ head/sys/dev/fxp/if_fxp.c   Sun Oct 24 21:59:51 2010(r214302)
@@ -862,9 +862,9 @@ fxp_attach(device_t dev)
ifp->if_capenable |= IFCAP_VLAN_MTU; /* the hw bits already set */
if ((sc->flags & FXP_FLAG_EXT_RFA) != 0) {
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING |
-   IFCAP_VLAN_HWCSUM;
+   IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
ifp->if_capenable |= IFCAP_VLAN_HWTAGGING |
-   IFCAP_VLAN_HWCSUM;
+   IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
}
 
/*
@@ -2866,10 +2866,19 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
if (ifp->if_flags & IFF_UP)
reinit++;
}
+   if ((mask & IFCAP_VLAN_HWCSUM) != 0 &&
+   (ifp->if_capabilities & IFCAP_VLAN_HWCSUM) != 0)
+   ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
+   if ((mask & IFCAP_VLAN_HWTSO) != 0 &&
+   (ifp->if_capabilities & IFCAP_VLAN_HWTSO) != 0)
+   ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
if ((mask & IFCAP_VLAN_HWTAGGING) != 0 &&
(ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) {
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
-   reinit++;
+   if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0)
+   ifp->if_capenable &=
+   ~(IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM);
+   reinit++;
}
if (reinit > 0 && ifp->if_flags & IFF_UP)
fxp_init_body(sc);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214292 - head/sys/dev/bge

2010-10-24 Thread Pyun YongHyeon
Author: yongari
Date: Sun Oct 24 20:54:46 2010
New Revision: 214292
URL: http://svn.freebsd.org/changeset/base/214292

Log:
  Use bge_chipid to compare controller ids. r214251 incorrectly used
  bge_chiprev.
  
  Reported by:  Buganini  gmail dot com >

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Sun Oct 24 20:45:13 2010(r214291)
+++ head/sys/dev/bge/if_bge.c   Sun Oct 24 20:54:46 2010(r214292)
@@ -1695,9 +1695,9 @@ bge_blockinit(struct bge_softc *sc)
 
/* Choose de-pipeline mode for BCM5906 A0, A1 and A2. */
if (sc->bge_asicrev == BGE_ASICREV_BCM5906) {
-   if (sc->bge_chiprev == BGE_CHIPID_BCM5906_A0 ||
-   sc->bge_chiprev == BGE_CHIPID_BCM5906_A1 ||
-   sc->bge_chiprev == BGE_CHIPID_BCM5906_A2)
+   if (sc->bge_chipid == BGE_CHIPID_BCM5906_A0 ||
+   sc->bge_chipid == BGE_CHIPID_BCM5906_A1 ||
+   sc->bge_chipid == BGE_CHIPID_BCM5906_A2)
CSR_WRITE_4(sc, BGE_ISO_PKT_TX,
(CSR_READ_4(sc, BGE_ISO_PKT_TX) & ~3) | 2);
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214291 - in head: bin/sh tools/regression/bin/sh/parser

2010-10-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun Oct 24 20:45:13 2010
New Revision: 214291
URL: http://svn.freebsd.org/changeset/base/214291

Log:
  sh: Make sure defined functions can actually be called.
  
  Add some conservative checks on function names:
  - Disallow expansions or quoting characters; these can only be called via
strange control characters
  - Disallow '/'; these functions cannot be called anyway, as exec.c assumes
they are pathnames
  - Make the CTL* bytes work properly in function names.
  
  These are syntax errors.
  
  POSIX does not require us to support more than names (letters, digits and
  underscores, not starting with a digit), but I do not want to restrict it
  that much at this time.
  
  Exp-run done by:  pav (with some other sh(1) changes)

Added:
  head/tools/regression/bin/sh/parser/func1.0   (contents, props changed)
Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==
--- head/bin/sh/parser.cSun Oct 24 20:09:49 2010(r214290)
+++ head/bin/sh/parser.cSun Oct 24 20:45:13 2010(r214291)
@@ -639,10 +639,14 @@ simplecmd(union node **rpp, union node *
if (readtoken() != TRP)
synexpect(TRP);
funclinno = plinno;
-#ifdef notdef
-   if (! goodname(n->narg.text))
+   /*
+* - Require plain text.
+* - Functions with '/' cannot be called.
+*/
+   if (!noexpand(n->narg.text) || quoteflag ||
+   strchr(n->narg.text, '/'))
synerror("Bad function name");
-#endif
+   rmescapes(n->narg.text);
n->type = NDEFUN;
n->narg.next = command();
funclinno = 0;

Added: head/tools/regression/bin/sh/parser/func1.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/func1.0 Sun Oct 24 20:45:13 2010
(r214291)
@@ -0,0 +1,25 @@
+# $FreeBSD$
+# POSIX does not require these bytes to work in function names,
+# but making them all work seems a good goal.
+
+failures=0
+unset LC_ALL
+export LC_CTYPE=en_US.ISO8859-1
+i=128
+set -f
+while [ "$i" -le 255 ]; do
+   c=$(printf \\"$(printf %o "$i")")
+   ok=0
+   eval "$c() { ok=1; }"
+   $c
+   ok1=$ok
+   ok=0
+   "$c"
+   if [ "$ok" != 1 ] || [ "$ok1" != 1 ]; then
+   echo "Bad results for character $i" >&2
+   : $((failures += 1))
+   fi
+   unset -f $c
+   i=$((i+1))
+done
+exit $((failures > 0))
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214290 - in head: bin/sh tools/regression/bin/sh/execution

2010-10-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun Oct 24 20:09:49 2010
New Revision: 214290
URL: http://svn.freebsd.org/changeset/base/214290

Log:
  sh: Check whether dup2 was successful for >&FD and <&FD.
  
  A failure (usually caused by FD not being open) is a redirection error.
  
  Exp-run done by:  pav (with some other sh(1) changes)

Added:
  head/tools/regression/bin/sh/execution/redir4.0   (contents, props changed)
Modified:
  head/bin/sh/redir.c

Modified: head/bin/sh/redir.c
==
--- head/bin/sh/redir.c Sun Oct 24 19:56:34 2010(r214289)
+++ head/bin/sh/redir.c Sun Oct 24 20:09:49 2010(r214290)
@@ -217,8 +217,11 @@ movefd:
if (redir->ndup.dupfd >= 0) {   /* if not ">&-" */
if (memory[redir->ndup.dupfd])
memory[fd] = 1;
-   else
-   dup2(redir->ndup.dupfd, fd);
+   else {
+   if (dup2(redir->ndup.dupfd, fd) < 0)
+   error("%d: %s", redir->ndup.dupfd,
+   strerror(errno));
+   }
} else {
close(fd);
}

Added: head/tools/regression/bin/sh/execution/redir4.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/redir4.0 Sun Oct 24 20:09:49 
2010(r214290)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+{ echo bad 0>&3; } 2>/dev/null 3>/dev/null 3>&-
+exit 0
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214289 - head/tools/regression/bin/sh/execution

2010-10-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun Oct 24 19:56:34 2010
New Revision: 214289
URL: http://svn.freebsd.org/changeset/base/214289

Log:
  sh: Add a test trying to close a descriptor that is not open.
  
  In stable/8 and older, this fails. Some of the redirection changes in head
  have fixed it.

Added:
  head/tools/regression/bin/sh/execution/redir3.0   (contents, props changed)

Added: head/tools/regression/bin/sh/execution/redir3.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/redir3.0 Sun Oct 24 19:56:34 
2010(r214289)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+3>&- 3>&-
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r212803 - head/sys/netinet

2010-10-24 Thread Bjoern A. Zeeb

On Sat, 23 Oct 2010, Bjoern A. Zeeb wrote:


On Fri, 17 Sep 2010, Andre Oppermann wrote:


Author: andre
Date: Fri Sep 17 22:05:27 2010
New Revision: 212803
URL: http://svn.freebsd.org/changeset/base/212803

Log:
 Rearrange the TSO code to make it more readable and to clearly
 separate the decision logic, of whether we can do TSO, and the
 calculation of the burst length into two distinct parts.

 Change the way the TSO burst length calculation is done. While
 TSO could do bursts of 65535 bytes that can't be represented in
 ip_len together with the IP and TCP header. Account for that and
 use IP_MAXPACKET instead of TCP_MAXWIN as base constant (both
 have the same value of 64K). When more data is available prevent
 less than MSS sized segments from being sent during the current
 TSO burst.

 Add two more KASSERTs to ensure the integrity of the packets.



I changed the order for simplicity of explanations.


@@ -1068,6 +1081,9 @@ send:
m->m_pkthdr.tso_segsz = tp->t_maxopd - optlen;
}

+   KASSERT(len + hdrlen + ipoptlen == m_length(m, NULL),
+   ("%s: mbuf chain shorter than expected", __func__));
+


I have hit this KASSERT() and it was unhelpful to figure out what
was wrong in first place.  I had hit it with a TCP6 connect initially.

Adter I changed it I realized that it was due to IPSEC and not due to IPv6.
So I have two local changes now, neither of which I particularly like
but I didn't want to revert ipoptlen in the IPSEC case though it might
be the better option if INVARIANTS is on, as it's not used anymore
further on but it would obviously confusing as well.

+#ifdef IPSEC
+   KASSERT(len + hdrlen + ipoptlen - ipsec_optlen == m_length(m, NULL),
+   ("%s: mbuf chain shorter than expected: %ld + %u + %u - %u != %u",
+   __func__, len, hdrlen, ipoptlen, ipsec_optlen, m_length(m, NULL)));
+#else
KASSERT(len + hdrlen + ipoptlen == m_length(m, NULL),
-   ("%s: mbuf chain shorter than expected", __func__));
+   ("%s: mbuf chain shorter than expected: %ld + %u + %u != %u",
+   __func__, len, hdrlen, ipoptlen, m_length(m, NULL)));
+#endif


/*
 * In transmit state, time the transmission and arrange for
 * the retransmit.  In persist state, just set snd_max.




The second worry I have is ...





Modified:
 head/sys/netinet/tcp_output.c

Modified: head/sys/netinet/tcp_output.c
==
--- head/sys/netinet/tcp_output.c	Fri Sep 17 21:53:56 2010 
(r212802)
+++ head/sys/netinet/tcp_output.c	Fri Sep 17 22:05:27 2010 
(r212803)

@@ -465,9 +465,8 @@ after_sack_rexmit:
}

/*
-* Truncate to the maximum segment length or enable TCP Segmentation
-	 * Offloading (if supported by hardware) and ensure that FIN is 
removed

-* if the length no longer contains the last data byte.
+* Decide if we can use TCP Segmentation Offloading (if supported by
+* hardware).
 *
 * TSO may only be used if we are in a pure bulk sending state.  The
 * presence of TCP-MD5, SACK retransmits, SACK advertizements and
@@ -475,10 +474,6 @@ after_sack_rexmit:
 * (except for the sequence number) for all generated packets.  This
	 * makes it impossible to transmit any options which vary per 
generated

 * segment or packet.
-*
-* The length of TSO bursts is limited to TCP_MAXWIN.  That limit and
-	 * removal of FIN (if not already catched here) are handled later 
after

-* the exact length of the TCP options are known.
 */
#ifdef IPSEC
/*
@@ -487,22 +482,15 @@ after_sack_rexmit:
 */
ipsec_optlen = ipsec_hdrsiz_tcp(tp);
#endif
-   if (len > tp->t_maxseg) {
-   if ((tp->t_flags & TF_TSO) && V_tcp_do_tso &&
-   ((tp->t_flags & TF_SIGNATURE) == 0) &&
-   tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
-   tp->t_inpcb->inp_options == NULL &&
-   tp->t_inpcb->in6p_options == NULL
+   if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg &&
+   ((tp->t_flags & TF_SIGNATURE) == 0) &&
+   tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
#ifdef IPSEC
-   && ipsec_optlen == 0
+   ipsec_optlen == 0 &&
#endif
-   ) {
-   tso = 1;
-   } else {
-   len = tp->t_maxseg;
-   sendalot = 1;
-   }
-   }
+   tp->t_inpcb->inp_options == NULL &&
+   tp->t_inpcb->in6p_options == NULL)
+   tso = 1;


Given the fact that in the TSO case we still check for
len > tp->t_maxseg
there is the assumption that it can happen.

Unfortunately in the non-TSO we no longer adjust len in that case
anymore, even though len is just used the second next line and all
further on for various calculations and com

svn commit: r214288 - head/sys/cam/scsi

2010-10-24 Thread Alexander Motin
Author: mav
Date: Sun Oct 24 18:53:16 2010
New Revision: 214288
URL: http://svn.freebsd.org/changeset/base/214288

Log:
  Make da driver to handle some probably broken Android devices, returning
  zero media and sector size instead of "Medium not present" error,
  until some confirmation button is tapped on device.

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Sun Oct 24 18:12:11 2010(r214287)
+++ head/sys/cam/scsi/scsi_da.c Sun Oct 24 18:53:16 2010(r214288)
@@ -1667,7 +1667,10 @@ dadone(struct cam_periph *periph, union 
 * give them an 'illegal' value we'll avoid that
 * here.
 */
-   if (block_size >= MAXPHYS || block_size == 0) {
+   if (block_size == 0 && maxsector == 0) {
+   snprintf(announce_buf, sizeof(announce_buf),
+   "0MB (no media?)");
+   } else if (block_size >= MAXPHYS || block_size == 0) {
xpt_print(periph->path,
"unsupportable block size %ju\n",
(uintmax_t) block_size);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214279 - in head: share/man/man4 sys/cam sys/cam/ata sys/kern

2010-10-24 Thread Garrett Cooper
On Sun, Oct 24, 2010 at 10:55 AM, Alexander Motin  wrote:
> Garrett Cooper wrote:
>> On Sun, Oct 24, 2010 at 10:03 AM, Alexander Motin  wrote:
>>> Bruce Cran wrote:
 On Sunday 24 October 2010 17:31:58 Bruce Cran wrote:

> Log:
>   Mostly revert r203420, and add similar functionality into ada(4) since
> the existing code caused problems with some SCSI controllers.
>>> Proper way would be IMHO to fix polling in aac driver.
>>>
>   A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
>   whether or not to spin-down disks when shutting down.
>   Spinning down the disks unloads/parks the heads - this is
>   much better than removing power when the disk is still
>   spinning because otherwise an Emergency Unload occurs which may cause
> damage to the actuator.
 The FLUSH CACHE + STANDBY IMMEDIATE commands are issued (instead of just
 SLEEP) following the procedure documented in Fujitsu's MHW series product
 documentation under section 1.10.1, "Recommended power-off sequence".
>>> Not instead of "just SLEEP", but instead of FLUSH CACHE (by respective
>>> peripheral driver) + SLEEP (by xpt). It should probably be the same.
>>>
>>> Just for the note, SCSI specification states that STOP automatically
>>> implies FLUSH CACHE. ATA - doesn't.
>>
>>     I could be wrong, but I think the ANSI ATA<->SCSI spec states
>> otherwise (taken from ANSI INCITS 431-2007 page 62 -- see steps 1-4):
>>
>> 9.11.3 START STOP UNIT START bit LOEJ bit combinations
>> The SATL shall perform the actions shown in table 40 in response to a
>> START STOP UNIT command.
>> Table 40 — Definition of START and LOEJ bits in the START STOP UNIT CDB
>> START LOEJ Definition
>> 0 0 The SATL shall:
>> 1) If the IMMED bit is set to one, then return GOOD status;
>> 2) Issue an ATA flush command (see 3.1.11) to the ATA device;
>> 3) If the ATA flush command completes with any error, then process ending 
>> status
>> according to the IMMED bit (see 9.11.2) with the additional sense code set to
>> COMMAND SEQUENCE ERROR;
>> 4) If the ATA flush command completes without error, then issue an ATA 
>> STANDBY
>> IMMEDIATE command to the ATA Sector Count set to zero;
>> 5) If the ATA STANDBY IMMEDIATE command completes with any error, then
>> process ending status according to the IMMED bit (see 9.11.2) with the
>> additional
>> sense code set to COMMAND SEQUENCE ERROR; and
>> 6) If the ATA STANDBY IMMEDIATE command completes without error and the
>> IMMED bit is set to zero, then return GOOD status (see 9.11.2) a.
>>
>>     Not sure about the ATA spec standalone... might be present in the ATA8 
>> spec.
>
> As I understand, this just confirms what I have said:
> SCSI STOP == ATA FLUSH CACHE + STANDBY IMMEDIATE.
> So SCSI STOP implies flush, while ATA STANDBY IMMEDIATE doesn't.

Looking at it from that perspective, I agree.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214279 - in head: share/man/man4 sys/cam sys/cam/ata sys/kern

2010-10-24 Thread Alexander Motin
Garrett Cooper wrote:
> On Sun, Oct 24, 2010 at 10:03 AM, Alexander Motin  wrote:
>> Bruce Cran wrote:
>>> On Sunday 24 October 2010 17:31:58 Bruce Cran wrote:
>>>
 Log:
   Mostly revert r203420, and add similar functionality into ada(4) since
 the existing code caused problems with some SCSI controllers.
>> Proper way would be IMHO to fix polling in aac driver.
>>
   A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
   whether or not to spin-down disks when shutting down.
   Spinning down the disks unloads/parks the heads - this is
   much better than removing power when the disk is still
   spinning because otherwise an Emergency Unload occurs which may cause
 damage to the actuator.
>>> The FLUSH CACHE + STANDBY IMMEDIATE commands are issued (instead of just
>>> SLEEP) following the procedure documented in Fujitsu's MHW series product
>>> documentation under section 1.10.1, "Recommended power-off sequence".
>> Not instead of "just SLEEP", but instead of FLUSH CACHE (by respective
>> peripheral driver) + SLEEP (by xpt). It should probably be the same.
>>
>> Just for the note, SCSI specification states that STOP automatically
>> implies FLUSH CACHE. ATA - doesn't.
> 
> I could be wrong, but I think the ANSI ATA<->SCSI spec states
> otherwise (taken from ANSI INCITS 431-2007 page 62 -- see steps 1-4):
> 
> 9.11.3 START STOP UNIT START bit LOEJ bit combinations
> The SATL shall perform the actions shown in table 40 in response to a
> START STOP UNIT command.
> Table 40 — Definition of START and LOEJ bits in the START STOP UNIT CDB
> START LOEJ Definition
> 0 0 The SATL shall:
> 1) If the IMMED bit is set to one, then return GOOD status;
> 2) Issue an ATA flush command (see 3.1.11) to the ATA device;
> 3) If the ATA flush command completes with any error, then process ending 
> status
> according to the IMMED bit (see 9.11.2) with the additional sense code set to
> COMMAND SEQUENCE ERROR;
> 4) If the ATA flush command completes without error, then issue an ATA STANDBY
> IMMEDIATE command to the ATA Sector Count set to zero;
> 5) If the ATA STANDBY IMMEDIATE command completes with any error, then
> process ending status according to the IMMED bit (see 9.11.2) with the
> additional
> sense code set to COMMAND SEQUENCE ERROR; and
> 6) If the ATA STANDBY IMMEDIATE command completes without error and the
> IMMED bit is set to zero, then return GOOD status (see 9.11.2) a.
> 
> Not sure about the ATA spec standalone... might be present in the ATA8 
> spec.

As I understand, this just confirms what I have said:
SCSI STOP == ATA FLUSH CACHE + STANDBY IMMEDIATE.
So SCSI STOP implies flush, while ATA STANDBY IMMEDIATE doesn't.

-- 
Alexander Motin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214279 - in head: share/man/man4 sys/cam sys/cam/ata sys/kern

2010-10-24 Thread Garrett Cooper
On Sun, Oct 24, 2010 at 10:03 AM, Alexander Motin  wrote:
> Bruce Cran wrote:
>> On Sunday 24 October 2010 17:31:58 Bruce Cran wrote:
>>
>>> Log:
>>>   Mostly revert r203420, and add similar functionality into ada(4) since
>>> the existing code caused problems with some SCSI controllers.
>
> Proper way would be IMHO to fix polling in aac driver.
>
>>>   A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
>>>   whether or not to spin-down disks when shutting down.
>>>   Spinning down the disks unloads/parks the heads - this is
>>>   much better than removing power when the disk is still
>>>   spinning because otherwise an Emergency Unload occurs which may cause
>>> damage to the actuator.
>>
>> The FLUSH CACHE + STANDBY IMMEDIATE commands are issued (instead of just
>> SLEEP) following the procedure documented in Fujitsu's MHW series product
>> documentation under section 1.10.1, "Recommended power-off sequence".
>
> Not instead of "just SLEEP", but instead of FLUSH CACHE (by respective
> peripheral driver) + SLEEP (by xpt). It should probably be the same.
>
> Just for the note, SCSI specification states that STOP automatically
> implies FLUSH CACHE. ATA - doesn't.

I could be wrong, but I think the ANSI ATA<->SCSI spec states
otherwise (taken from ANSI INCITS 431-2007 page 62 -- see steps 1-4):

9.11.3 START STOP UNIT START bit LOEJ bit combinations
The SATL shall perform the actions shown in table 40 in response to a
START STOP UNIT command.
Table 40 — Definition of START and LOEJ bits in the START STOP UNIT CDB
START LOEJ Definition
0 0 The SATL shall:
1) If the IMMED bit is set to one, then return GOOD status;
2) Issue an ATA flush command (see 3.1.11) to the ATA device;
3) If the ATA flush command completes with any error, then process ending status
according to the IMMED bit (see 9.11.2) with the additional sense code set to
COMMAND SEQUENCE ERROR;
4) If the ATA flush command completes without error, then issue an ATA STANDBY
IMMEDIATE command to the ATA Sector Count set to zero;
5) If the ATA STANDBY IMMEDIATE command completes with any error, then
process ending status according to the IMMED bit (see 9.11.2) with the
additional
sense code set to COMMAND SEQUENCE ERROR; and
6) If the ATA STANDBY IMMEDIATE command completes without error and the
IMMED bit is set to zero, then return GOOD status (see 9.11.2) a.

Not sure about the ATA spec standalone... might be present in the ATA8 spec.
Thanks!
-Garrett
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214284 - head/sbin/hastd

2010-10-24 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Oct 24 17:28:25 2010
New Revision: 214284
URL: http://svn.freebsd.org/changeset/base/214284

Log:
  Before this change on first connect between primary and secondary we
  initialize all the data. This is huge waste of time and resources if
  there were no writes yet, as there is no real data to synchronize.
  
  Optimize this by sending "virgin" argument to secondary, which gives it a hint
  that synchronization is not needed.
  
  In the common case (where noth nodes are configured at the same time) instead
  of synchronizing everything, we don't synchronize at all.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Sun Oct 24 17:24:08 2010(r214283)
+++ head/sbin/hastd/primary.c   Sun Oct 24 17:28:25 2010(r214284)
@@ -417,6 +417,24 @@ init_environment(struct hast_resource *r
}
 }
 
+static bool
+init_resuid(struct hast_resource *res)
+{
+
+   mtx_lock(&metadata_lock);
+   if (res->hr_resuid != 0) {
+   mtx_unlock(&metadata_lock);
+   return (false);
+   } else {
+   /* Initialize unique resource identifier. */
+   arc4random_buf(&res->hr_resuid, sizeof(res->hr_resuid));
+   mtx_unlock(&metadata_lock);
+   if (metadata_write(res) < 0)
+   exit(EX_NOINPUT);
+   return (true);
+   }
+}
+
 static void
 init_local(struct hast_resource *res)
 {
@@ -452,10 +470,12 @@ init_local(struct hast_resource *res)
if (res->hr_resuid != 0)
return;
/*
-* We're using provider for the first time, so we have to generate
-* resource unique identifier and initialize local and remote counts.
+* We're using provider for the first time. Initialize local and remote
+* counters. We don't initialize resuid here, as we want to do it just
+* in time. The reason for this is that we want to inform secondary
+* that there were no writes yet, so there is no need to synchronize
+* anything.
 */
-   arc4random_buf(&res->hr_resuid, sizeof(res->hr_resuid));
res->hr_primary_localcnt = 1;
res->hr_primary_remotecnt = 0;
if (metadata_write(res) < 0)
@@ -566,6 +586,19 @@ init_remote(struct hast_resource *res, s
nv_add_string(nvout, res->hr_name, "resource");
nv_add_uint8_array(nvout, res->hr_token, sizeof(res->hr_token),
"token");
+   if (res->hr_resuid == 0) {
+   /*
+* The resuid field was not yet initialized.
+* Because we do synchronization inside init_resuid(), it is
+* possible that someone already initialized it, the function
+* will return false then, but if we successfully initialized
+* it, we will get true. True means that there were no writes
+* to this resource yet and we want to inform secondary that
+* synchronization is not needed by sending "virgin" argument.
+*/
+   if (init_resuid(res))
+   nv_add_int8(nvout, 1, "virgin");
+   }
nv_add_uint64(nvout, res->hr_resuid, "resuid");
nv_add_uint64(nvout, res->hr_primary_localcnt, "localcnt");
nv_add_uint64(nvout, res->hr_primary_remotecnt, "remotecnt");
@@ -1006,6 +1039,10 @@ ggate_recv_thread(void *arg)
QUEUE_INSERT1(hio, send, ncomp);
break;
case BIO_WRITE:
+   if (res->hr_resuid == 0) {
+   /* This is first write, initialize resuid. */
+   (void)init_resuid(res);
+   }
for (;;) {
mtx_lock(&range_lock);
if (rangelock_islocked(range_sync,

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Sun Oct 24 17:24:08 2010(r214283)
+++ head/sbin/hastd/secondary.c Sun Oct 24 17:28:25 2010(r214284)
@@ -243,13 +243,22 @@ init_remote(struct hast_resource *res, s
 */
if (res->hr_resuid == 0) {
/*
-* Provider is used for the first time. Initialize everything.
+* Provider is used for the first time. If primary node done no
+* writes yet as well (we will find "virgin" argument) then
+* there is no need to synchronize anything. If primary node
+* done any writes already we have to synchronize everything.
 */
assert(res->hr_secondary_localcnt == 0);
res->hr_resuid = resuid;
if (

svn commit: r214283 - head/sbin/hastd

2010-10-24 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Oct 24 17:24:08 2010
New Revision: 214283
URL: http://svn.freebsd.org/changeset/base/214283

Log:
  Implement nv_exists() function that returns true if argument of the given
  name exists.
  
  MFC after:3 days

Modified:
  head/sbin/hastd/nv.c
  head/sbin/hastd/nv.h

Modified: head/sbin/hastd/nv.c
==
--- head/sbin/hastd/nv.cSun Oct 24 17:22:34 2010(r214282)
+++ head/sbin/hastd/nv.cSun Oct 24 17:24:08 2010(r214283)
@@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#defineNV_TYPE_NONE0
+
 #defineNV_TYPE_INT81
 #defineNV_TYPE_UINT8   2
 #defineNV_TYPE_INT16   3
@@ -561,6 +563,29 @@ nv_get_string(struct nv *nv, const char 
return (str);
 }
 
+bool
+nv_exists(struct nv *nv, const char *namefmt, ...)
+{
+   struct nvhdr *nvh;
+   va_list nameap;
+   int snverror, serrno;
+
+   if (nv == NULL)
+   return (false);
+
+   serrno = errno;
+   snverror = nv->nv_error;
+
+   va_start(nameap, namefmt);
+   nvh = nv_find(nv, NV_TYPE_NONE, namefmt, nameap);
+   va_end(nameap);
+
+   errno = serrno;
+   nv->nv_error = snverror;
+
+   return (nvh != NULL);
+}
+
 /*
  * Dump content of the nv structure.
  */
@@ -797,7 +822,8 @@ nv_find(struct nv *nv, int type, const c
assert(size >= NVH_SIZE(nvh));
nv_swap(nvh, true);
if (strcmp(nvh->nvh_name, name) == 0) {
-   if ((nvh->nvh_type & NV_TYPE_MASK) != type) {
+   if (type != NV_TYPE_NONE &&
+   (nvh->nvh_type & NV_TYPE_MASK) != type) {
errno = EINVAL;
if (nv->nv_error == 0)
nv->nv_error = EINVAL;

Modified: head/sbin/hastd/nv.h
==
--- head/sbin/hastd/nv.hSun Oct 24 17:22:34 2010(r214282)
+++ head/sbin/hastd/nv.hSun Oct 24 17:24:08 2010(r214283)
@@ -126,6 +126,7 @@ const uint64_t *nv_get_uint64_array(stru
 const char *nv_get_string(struct nv *nv, const char *namefmt, ...)
 __printflike(2, 3);
 
+bool nv_exists(struct nv *nv, const char *namefmt, ...) __printflike(2, 3);
 void nv_dump(struct nv *nv);
 
 #endif /* !_NV_H_ */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214282 - head/sbin/hastd

2010-10-24 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Oct 24 17:22:34 2010
New Revision: 214282
URL: http://svn.freebsd.org/changeset/base/214282

Log:
  Move all NV defines into nv.c, they are not used externally thus there is
  no need to make then visible from outside.
  
  MFC after:3 days

Modified:
  head/sbin/hastd/nv.c
  head/sbin/hastd/nv.h

Modified: head/sbin/hastd/nv.c
==
--- head/sbin/hastd/nv.cSun Oct 24 17:06:49 2010(r214281)
+++ head/sbin/hastd/nv.cSun Oct 24 17:22:34 2010(r214282)
@@ -46,6 +46,33 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#defineNV_TYPE_INT81
+#defineNV_TYPE_UINT8   2
+#defineNV_TYPE_INT16   3
+#defineNV_TYPE_UINT16  4
+#defineNV_TYPE_INT32   5
+#defineNV_TYPE_UINT32  6
+#defineNV_TYPE_INT64   7
+#defineNV_TYPE_UINT64  8
+#defineNV_TYPE_INT8_ARRAY  9
+#defineNV_TYPE_UINT8_ARRAY 10
+#defineNV_TYPE_INT16_ARRAY 11
+#defineNV_TYPE_UINT16_ARRAY12
+#defineNV_TYPE_INT32_ARRAY 13
+#defineNV_TYPE_UINT32_ARRAY14
+#defineNV_TYPE_INT64_ARRAY 15
+#defineNV_TYPE_UINT64_ARRAY16
+#defineNV_TYPE_STRING  17
+
+#defineNV_TYPE_MASK0x7f
+#defineNV_TYPE_FIRST   NV_TYPE_INT8
+#defineNV_TYPE_LASTNV_TYPE_STRING
+
+#defineNV_ORDER_NETWORK0x00
+#defineNV_ORDER_HOST   0x80
+
+#defineNV_ORDER_MASK   0x80
+
 #defineNV_MAGIC0xaea1e
 struct nv {
int nv_magic;

Modified: head/sbin/hastd/nv.h
==
--- head/sbin/hastd/nv.hSun Oct 24 17:06:49 2010(r214281)
+++ head/sbin/hastd/nv.hSun Oct 24 17:22:34 2010(r214282)
@@ -41,33 +41,6 @@
 
 #include 
 
-#defineNV_TYPE_INT81
-#defineNV_TYPE_UINT8   2
-#defineNV_TYPE_INT16   3
-#defineNV_TYPE_UINT16  4
-#defineNV_TYPE_INT32   5
-#defineNV_TYPE_UINT32  6
-#defineNV_TYPE_INT64   7
-#defineNV_TYPE_UINT64  8
-#defineNV_TYPE_INT8_ARRAY  9
-#defineNV_TYPE_UINT8_ARRAY 10
-#defineNV_TYPE_INT16_ARRAY 11
-#defineNV_TYPE_UINT16_ARRAY12
-#defineNV_TYPE_INT32_ARRAY 13
-#defineNV_TYPE_UINT32_ARRAY14
-#defineNV_TYPE_INT64_ARRAY 15
-#defineNV_TYPE_UINT64_ARRAY16
-#defineNV_TYPE_STRING  17
-
-#defineNV_TYPE_MASK0x7f
-#defineNV_TYPE_FIRST   NV_TYPE_INT8
-#defineNV_TYPE_LASTNV_TYPE_STRING
-
-#defineNV_ORDER_NETWORK0x00
-#defineNV_ORDER_HOST   0x80
-
-#defineNV_ORDER_MASK   0x80
-
 struct nv;
 
 struct nv *nv_alloc(void);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214281 - in head: bin/sh tools/regression/bin/sh/parser

2010-10-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun Oct 24 17:06:49 2010
New Revision: 214281
URL: http://svn.freebsd.org/changeset/base/214281

Log:
  sh: Change ! within a pipeline to start a new pipeline instead.
  
  This is how ksh93 treats ! within a pipeline and makes the ! in
a | ! b | c
  negate the exit status of the pipeline, as if it were
a | { ! b | c; }
  
  Side effect: something like
f() ! a
  is now a syntax error, because a function definition takes a command,
  not a pipeline.
  
  Exp-run done by:  pav (with some other sh(1) changes)

Added:
  head/tools/regression/bin/sh/parser/pipe-not1.0   (contents, props changed)
Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==
--- head/bin/sh/parser.cSun Oct 24 16:55:17 2010(r214280)
+++ head/bin/sh/parser.cSun Oct 24 17:06:49 2010(r214281)
@@ -328,7 +328,7 @@ pipeline(void)
 {
union node *n1, *n2, *pipenode;
struct nodelist *lp, *prev;
-   int negate;
+   int negate, t;
 
negate = 0;
checkkwd = 2;
@@ -347,7 +347,13 @@ pipeline(void)
do {
prev = lp;
lp = (struct nodelist *)stalloc(sizeof (struct 
nodelist));
-   lp->n = command();
+   checkkwd = 2;
+   t = readtoken();
+   tokpushback++;
+   if (t == TNOT)
+   lp->n = pipeline();
+   else
+   lp->n = command();
prev->next = lp;
} while (readtoken() == TPIPE);
lp->next = NULL;
@@ -372,7 +378,7 @@ command(void)
union node *ap, **app;
union node *cp, **cpp;
union node *redir, **rpp;
-   int t, negate = 0;
+   int t;
 
checkkwd = 2;
redir = NULL;
@@ -387,12 +393,6 @@ command(void)
}
tokpushback++;
 
-   while (readtoken() == TNOT) {
-   TRACE(("command: TNOT recognized\n"));
-   negate = !negate;
-   }
-   tokpushback++;
-
switch (readtoken()) {
case TIF:
n1 = (union node *)stalloc(sizeof (struct nif));
@@ -573,7 +573,7 @@ TRACE(("expecting DO got %s %s\n", tokna
case TRP:
tokpushback++;
n1 = simplecmd(rpp, redir);
-   goto checkneg;
+   return n1;
default:
synexpect(-1);
}
@@ -596,15 +596,7 @@ TRACE(("expecting DO got %s %s\n", tokna
n1->nredir.redirect = redir;
}
 
-checkneg:
-   if (negate) {
-   n2 = (union node *)stalloc(sizeof (struct nnot));
-   n2->type = NNOT;
-   n2->nnot.com = n1;
-   return n2;
-   }
-   else
-   return n1;
+   return n1;
 }
 
 

Added: head/tools/regression/bin/sh/parser/pipe-not1.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/pipe-not1.0 Sun Oct 24 17:06:49 
2010(r214281)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+: | ! : | false
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214279 - in head: share/man/man4 sys/cam sys/cam/ata sys/kern

2010-10-24 Thread Alexander Motin
Bruce Cran wrote:
> On Sunday 24 October 2010 17:31:58 Bruce Cran wrote:
> 
>> Log:
>>   Mostly revert r203420, and add similar functionality into ada(4) since
>> the existing code caused problems with some SCSI controllers.

Proper way would be IMHO to fix polling in aac driver.

>>   A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
>>   whether or not to spin-down disks when shutting down.
>>   Spinning down the disks unloads/parks the heads - this is
>>   much better than removing power when the disk is still
>>   spinning because otherwise an Emergency Unload occurs which may cause
>> damage to the actuator.
> 
> The FLUSH CACHE + STANDBY IMMEDIATE commands are issued (instead of just 
> SLEEP) following the procedure documented in Fujitsu's MHW series product 
> documentation under section 1.10.1, "Recommended power-off sequence".

Not instead of "just SLEEP", but instead of FLUSH CACHE (by respective
peripheral driver) + SLEEP (by xpt). It should probably be the same.

Just for the note, SCSI specification states that STOP automatically
implies FLUSH CACHE. ATA - doesn't.

-- 
Alexander Motin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214280 - head/tools/regression/bin/sh/parser

2010-10-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun Oct 24 16:55:17 2010
New Revision: 214280
URL: http://svn.freebsd.org/changeset/base/214280

Log:
  sh: Add some testcases for alias expansion.

Added:
  head/tools/regression/bin/sh/parser/alias1.0   (contents, props changed)
  head/tools/regression/bin/sh/parser/alias2.0   (contents, props changed)

Added: head/tools/regression/bin/sh/parser/alias1.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/alias1.0Sun Oct 24 16:55:17 
2010(r214280)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+alias alias0=exit
+eval 'alias0 0'
+exit 1

Added: head/tools/regression/bin/sh/parser/alias2.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/alias2.0Sun Oct 24 16:55:17 
2010(r214280)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+alias alias0=exit
+x=alias0
+eval 'case $x in alias0) exit 0;; esac'
+exit 1
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214279 - in head: share/man/man4 sys/cam sys/cam/ata sys/kern

2010-10-24 Thread Bruce Cran
On Sunday 24 October 2010 17:31:58 Bruce Cran wrote:

> Log:
>   Mostly revert r203420, and add similar functionality into ada(4) since
> the existing code caused problems with some SCSI controllers.
> 
>   A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
>   whether or not to spin-down disks when shutting down.
>   Spinning down the disks unloads/parks the heads - this is
>   much better than removing power when the disk is still
>   spinning because otherwise an Emergency Unload occurs which may cause
> damage to the actuator.

The FLUSH CACHE + STANDBY IMMEDIATE commands are issued (instead of just 
SLEEP) following the procedure documented in Fujitsu's MHW series product 
documentation under section 1.10.1, "Recommended power-off sequence".

-- 
Bruce Cran
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214279 - in head: share/man/man4 sys/cam sys/cam/ata sys/kern

2010-10-24 Thread Bruce Cran
Author: brucec
Date: Sun Oct 24 16:31:57 2010
New Revision: 214279
URL: http://svn.freebsd.org/changeset/base/214279

Log:
  Mostly revert r203420, and add similar functionality into ada(4) since the
  existing code caused problems with some SCSI controllers.
  
  A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
  whether or not to spin-down disks when shutting down.
  Spinning down the disks unloads/parks the heads - this is
  much better than removing power when the disk is still
  spinning because otherwise an Emergency Unload occurs which may cause damage
  to the actuator.
  
  PR:   kern/140752
  Submitted by:   olli
  Reviewed by:  arundel
  Discussed with: mav
  MFC after:2 weeks

Modified:
  head/share/man/man4/ada.4
  head/sys/cam/ata/ata_da.c
  head/sys/cam/cam_xpt.c
  head/sys/kern/kern_shutdown.c

Modified: head/share/man/man4/ada.4
==
--- head/share/man/man4/ada.4   Sun Oct 24 16:10:32 2010(r214278)
+++ head/share/man/man4/ada.4   Sun Oct 24 16:31:57 2010(r214279)
@@ -118,6 +118,9 @@ This variable determines how long the
 driver will wait before timing out an outstanding command.
 The units for this value are seconds, and the default is currently 30
 seconds.
+.It kern.cam.ada.spindown_shutdown
+.Pp
+This variable determines whether to spin-down disks when shutting down.
 .El
 .Sh FILES
 .Bl -tag -width ".Pa /dev/ada*" -compact

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Sun Oct 24 16:10:32 2010(r214278)
+++ head/sys/cam/ata/ata_da.c   Sun Oct 24 16:31:57 2010(r214279)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #endif /* _KERNEL */
 
@@ -79,7 +80,8 @@ typedef enum {
ADA_FLAG_CAN_TRIM   = 0x080,
ADA_FLAG_OPEN   = 0x100,
ADA_FLAG_SCTX_INIT  = 0x200,
-   ADA_FLAG_CAN_CFA= 0x400
+   ADA_FLAG_CAN_CFA= 0x400,
+   ADA_FLAG_CAN_POWERMGT   = 0x800
 } ada_flags;
 
 typedef enum {
@@ -180,6 +182,10 @@ static voidadashutdown(void *arg, int 
 #defineADA_DEFAULT_SEND_ORDERED1
 #endif
 
+#ifndefADA_DEFAULT_SPINDOWN_SHUTDOWN
+#defineADA_DEFAULT_SPINDOWN_SHUTDOWN   1
+#endif
+
 /*
  * Most platforms map firmware geometry to actual, but some don't.  If
  * not overridden, default to nothing.
@@ -191,6 +197,7 @@ static void adashutdown(void *arg, int 
 static int ada_retry_count = ADA_DEFAULT_RETRY;
 static int ada_default_timeout = ADA_DEFAULT_TIMEOUT;
 static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED;
+static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN;
 
 SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0,
 "CAM Direct Access Disk driver");
@@ -203,6 +210,9 @@ TUNABLE_INT("kern.cam.ada.default_timeou
 SYSCTL_INT(_kern_cam_ada, OID_AUTO, ada_send_ordered, CTLFLAG_RW,
&ada_send_ordered, 0, "Send Ordered Tags");
 TUNABLE_INT("kern.cam.ada.ada_send_ordered", &ada_send_ordered);
+SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW,
+   &ada_spindown_shutdown, 0, "Spin down upon shutdown");
+TUNABLE_INT("kern.cam.ada.spindown_shutdown", &ada_spindown_shutdown);
 
 /*
  * ADA_ORDEREDTAG_INTERVAL determines how often, relative
@@ -665,6 +675,8 @@ adaregister(struct cam_periph *periph, v
softc->flags |= ADA_FLAG_CAN_48BIT;
if (cgd->ident_data.support.command2 & ATA_SUPPORT_FLUSHCACHE)
softc->flags |= ADA_FLAG_CAN_FLUSHCACHE;
+   if (cgd->ident_data.support.command1 & ATA_SUPPORT_POWERMGT)
+   softc->flags |= ADA_FLAG_CAN_POWERMGT;
if (cgd->ident_data.satacapabilities & ATA_SUPPORT_NCQ &&
cgd->inq_flags & SID_CmdQue)
softc->flags |= ADA_FLAG_CAN_NCQ;
@@ -1227,6 +1239,56 @@ adashutdown(void * arg, int howto)
 /*getcount_only*/0);
cam_periph_unlock(periph);
}
+
+   if (ada_spindown_shutdown == 0 ||
+   (howto & (RB_HALT | RB_POWEROFF)) == 0)
+   return;
+
+   TAILQ_FOREACH(periph, &adadriver.units, unit_links) {
+   union ccb ccb;
+
+   /* If we paniced with lock held - not recurse here. */
+   if (cam_periph_owned(periph))
+   continue;
+   cam_periph_lock(periph);
+   softc = (struct ada_softc *)periph->softc;
+   /*
+* We only spin-down the drive if it is capable of it..
+*/
+   if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) {
+   cam_periph_unlock(periph);
+   continue;
+   }
+
+   if (bootverbose)
+   xpt_print(periph->path, "spin-down\n");

svn commit: r214278 - head/share/man/man9

2010-10-24 Thread Jaakko Heinonen
Author: jh
Date: Sun Oct 24 16:10:32 2010
New Revision: 214278
URL: http://svn.freebsd.org/changeset/base/214278

Log:
  Use .Dv with NULL.

Modified:
  head/share/man/man9/make_dev.9

Modified: head/share/man/man9/make_dev.9
==
--- head/share/man/man9/make_dev.9  Sun Oct 24 15:56:21 2010
(r214277)
+++ head/share/man/man9/make_dev.9  Sun Oct 24 16:10:32 2010
(r214278)
@@ -271,7 +271,9 @@ After
 .Fn destroy_dev
 is finished, and if the supplied
 .Fa cb
-is not NULL, the callback
+is not
+.Dv NULL ,
+the callback
 .Fa cb
 is called, with argument
 .Fa arg .
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214277 - head/share/man/man9

2010-10-24 Thread Jaakko Heinonen
Author: jh
Date: Sun Oct 24 15:56:21 2010
New Revision: 214277
URL: http://svn.freebsd.org/changeset/base/214277

Log:
  Document make_dev_p(9).
  
  Reviewed by:  brueffer, kib

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/make_dev.9

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileSun Oct 24 15:44:23 2010
(r214276)
+++ head/share/man/man9/MakefileSun Oct 24 15:56:21 2010
(r214277)
@@ -775,7 +775,8 @@ MLINKS+=make_dev.9 destroy_dev.9 \
make_dev.9 dev_depends.9 \
make_dev.9 make_dev_alias.9 \
make_dev.9 make_dev_cred.9 \
-   make_dev.9 make_dev_credf.9
+   make_dev.9 make_dev_credf.9 \
+   make_dev.9 make_dev_p.9
 MLINKS+=malloc.9 free.9 \
malloc.9 MALLOC_DECLARE.9 \
malloc.9 MALLOC_DEFINE.9 \

Modified: head/share/man/man9/make_dev.9
==
--- head/share/man/man9/make_dev.9  Sun Oct 24 15:44:23 2010
(r214276)
+++ head/share/man/man9/make_dev.9  Sun Oct 24 15:56:21 2010
(r214277)
@@ -24,13 +24,14 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 7, 2010
+.Dd October 24, 2010
 .Dt MAKE_DEV 9
 .Os
 .Sh NAME
 .Nm make_dev ,
 .Nm make_dev_cred ,
 .Nm make_dev_credf ,
+.Nm make_dev_p ,
 .Nm make_dev_alias ,
 .Nm destroy_dev ,
 .Nm destroy_dev_sched ,
@@ -49,6 +50,8 @@ and DEVFS registration for devices
 .Fn make_dev_cred "struct cdevsw *cdevsw" "int unit" "struct ucred *cr" "uid_t 
uid" "gid_t gid" "int perms" "const char *fmt" ...
 .Ft struct cdev *
 .Fn make_dev_credf "int flags" "struct cdevsw *cdevsw" "int unit" "struct 
ucred *cr" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ...
+.Ft int
+.Fn make_dev_p "int flags" "struct cdev **cdev" "struct cdevsw *devsw" "struct 
ucred *cr" "uid_t uid" "gid_t gid" "int mode" "const char *fmt" ...
 .Ft struct cdev *
 .Fn make_dev_alias "struct cdev *pdev" "const char *fmt" ...
 .Ft void
@@ -128,20 +131,22 @@ member of the initialized
 The
 .Va flags
 argument alters the operation of
-.Fn make_dev_credf .
+.Fn make_dev_credf
+or
+.Fn make_dev_p .
 The following values are currently accepted:
 .Pp
 .Bl -tag -width "MAKEDEV_CHECKNAME" -compact -offset indent
 .It MAKEDEV_REF
 reference the created device
 .It MAKEDEV_NOWAIT
-do not sleep, may return NULL
+do not sleep, the call may fail
 .It MAKEDEV_WAITOK
 allow the function to sleep to satisfy malloc
 .It MAKEDEV_ETERNAL
 created device will be never destroyed
 .It MAKEDEV_CHECKNAME
-return NULL if the device name is invalid or already exists
+return an error if the device name is invalid or already exists
 .El
 .Pp
 The
@@ -190,6 +195,14 @@ make_dev_credf(0, cdevsw, unit, NULL, ui
 .Ed
 .Pp
 The
+.Fn make_dev_p
+function is similar to
+.Fn make_dev_credf
+but it may return an error number and takes a pointer to the resulting
+.Ft *cdev
+as an argument.
+.Pp
+The
 .Fn make_dev_alias
 function takes the returned
 .Ft cdev
@@ -293,6 +306,44 @@ is called for all instantiated devices, 
 unload until
 .Fn destroy_dev
 is actually finished for all of them.
+.Sh RETURN VALUES
+If successful,
+.Fn make_dev_p
+will return 0, otherwise it will return an error.
+If successful,
+.Fn make_dev_credf
+will return a valid
+.Fa cdev
+pointer, otherwise it will return
+.Dv NULL .
+.Sh ERRORS
+The
+.Fn make_dev_p
+call will fail and the device will be not registered if:
+.Bl -tag -width Er
+.It Bq Er ENOMEM
+The
+.Dv MAKEDEV_NOWAIT
+flags was specified and a memory allocation request could not be satisfied.
+.It Bq Er ENAMETOOLONG
+The
+.Dv MAKEDEV_CHECKNAME
+flags was specified and the provided device name is longer than
+.Dv SPECNAMELEN .
+.It Bq Er EINVAL
+The
+.Dv MAKEDEV_CHECKNAME
+flags was specified and the provided device name is empty, contains a
+.Qq \&.
+or
+.Qq ..
+path component or ends with
+.Ql / .
+.It Bq Er EEXIST
+The
+.Dv MAKEDEV_CHECKNAME
+flags was specified and the provided device name already exists.
+.El
 .Pp
 .Sh SEE ALSO
 .Xr devctl 4 ,
@@ -320,3 +371,7 @@ The functions
 .Fn destroy_dev_sched_cb
 first appeared in
 .Fx 7.0 .
+The function
+.Fn make_dev_p
+first appeared in
+.Fx 8.2 .
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214276 - head/sbin/hastd

2010-10-24 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Oct 24 15:44:23 2010
New Revision: 214276
URL: http://svn.freebsd.org/changeset/base/214276

Log:
  Simplify code a bit.
  
  MFC after:3 days

Modified:
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Sun Oct 24 15:42:16 2010(r214275)
+++ head/sbin/hastd/secondary.c Sun Oct 24 15:44:23 2010(r214276)
@@ -318,10 +318,8 @@ init_remote(struct hast_resource *res, s
(uintmax_t)res->hr_secondary_remotecnt);
}
if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) {
-   pjdlog_errno(LOG_WARNING, "Unable to send activemap to %s",
+   pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s",
res->hr_remoteaddr);
-   nv_free(nvout);
-   exit(EX_TEMPFAIL);
}
if (map != NULL)
free(map);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214275 - head/sbin/hastd

2010-10-24 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Oct 24 15:42:16 2010
New Revision: 214275
URL: http://svn.freebsd.org/changeset/base/214275

Log:
  Plug memory leak.
  
  MFC after:3 days

Modified:
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Sun Oct 24 15:41:23 2010(r214274)
+++ head/sbin/hastd/secondary.c Sun Oct 24 15:42:16 2010(r214275)
@@ -323,6 +323,8 @@ init_remote(struct hast_resource *res, s
nv_free(nvout);
exit(EX_TEMPFAIL);
}
+   if (map != NULL)
+   free(map);
nv_free(nvout);
if (res->hr_secondary_localcnt > res->hr_primary_remotecnt &&
 res->hr_primary_localcnt > res->hr_secondary_remotecnt) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214274 - head/sbin/hastd

2010-10-24 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Oct 24 15:41:23 2010
New Revision: 214274
URL: http://svn.freebsd.org/changeset/base/214274

Log:
  Plug memory leaks.
  
  Found with:   valgrind
  MFC after:3 days

Modified:
  head/sbin/hastd/parse.y
  head/sbin/hastd/primary.c
  head/sbin/hastd/synch.h

Modified: head/sbin/hastd/parse.y
==
--- head/sbin/hastd/parse.y Sun Oct 24 15:38:58 2010(r214273)
+++ head/sbin/hastd/parse.y Sun Oct 24 15:41:23 2010(r214274)
@@ -264,6 +264,7 @@ control_statement:  CONTROL STR
sizeof(depth0_control)) >=
sizeof(depth0_control)) {
pjdlog_error("control argument is too long.");
+   free($2);
return (1);
}
break;
@@ -274,12 +275,14 @@ control_statement:CONTROL STR
sizeof(lconfig->hc_controladdr)) >=
sizeof(lconfig->hc_controladdr)) {
pjdlog_error("control argument is too long.");
+   free($2);
return (1);
}
break;
default:
assert(!"control at wrong depth level");
}
+   free($2);
}
;
 
@@ -291,6 +294,7 @@ listen_statement:   LISTEN STR
sizeof(depth0_listen)) >=
sizeof(depth0_listen)) {
pjdlog_error("listen argument is too long.");
+   free($2);
return (1);
}
break;
@@ -301,12 +305,14 @@ listen_statement: LISTEN STR
sizeof(lconfig->hc_listenaddr)) >=
sizeof(lconfig->hc_listenaddr)) {
pjdlog_error("listen argument is too long.");
+   free($2);
return (1);
}
break;
default:
assert(!"listen at wrong depth level");
}
+   free($2);
}
;
 
@@ -357,6 +363,7 @@ exec_statement: EXEC STR
if (strlcpy(depth0_exec, $2, sizeof(depth0_exec)) >=
sizeof(depth0_exec)) {
pjdlog_error("Exec path is too long.");
+   free($2);
return (1);
}
break;
@@ -367,12 +374,14 @@ exec_statement:   EXEC STR
sizeof(curres->hr_exec)) >=
sizeof(curres->hr_exec)) {
pjdlog_error("Exec path is too long.");
+   free($2);
return (1);
}
break;
default:
assert(!"exec at wrong depth level");
}
+   free($2);
}
;
 
@@ -386,6 +395,7 @@ node_start: STR
{
switch (isitme($1)) {
case -1:
+   free($1);
return (1);
case 0:
break;
@@ -395,6 +405,7 @@ node_start: STR
default:
assert(!"invalid isitme() return value");
}
+   free($1);
}
;
 
@@ -482,14 +493,17 @@ resource_start:   STR
curres = calloc(1, sizeof(*curres));
if (curres == NULL) {
pjdlog_error("Unable to allocate memory for resource.");
+   free($1);
return (1);
}
if (strlcpy(curres->hr_name, $1,
sizeof(curres->hr_name)) >=
sizeof(curres->hr_name)) {
pjdlog_error("Resource name is too long.");
+   free($1);
return (1);
}
+   free($1);
curres->hr_role = HAST_ROLE_INIT;
curres->hr_previous_role = HAST_ROLE_INIT;
curres->hr_replication = -1;
@@ -530,6 +544,7 @@ name_statement: NAME STR
sizeof(depth1_provname)) >=
sizeof(depth1_provname)) {
pjdlog_error("name argument is too long.");
+   free($2);
return (1);
}
break;
@@ -541,12 +556,14 @@ name_statement:

svn commit: r214273 - head/sbin/hastd

2010-10-24 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Oct 24 15:38:58 2010
New Revision: 214273
URL: http://svn.freebsd.org/changeset/base/214273

Log:
  Load geom_gate.ko module after parsing arguments.
  
  MFC after:3 days

Modified:
  head/sbin/hastd/hastd.c

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Sun Oct 24 15:31:41 2010(r214272)
+++ head/sbin/hastd/hastd.c Sun Oct 24 15:38:58 2010(r214273)
@@ -701,8 +701,6 @@ main(int argc, char *argv[])
int debuglevel;
sigset_t mask;
 
-   g_gate_load();
-
foreground = false;
debuglevel = 0;
pidfile = HASTD_PIDFILE;
@@ -736,6 +734,8 @@ main(int argc, char *argv[])
 
pjdlog_debug_set(debuglevel);
 
+   g_gate_load();
+
pfh = pidfile_open(pidfile, 0600, &otherpid);
if (pfh == NULL) {
if (errno == EEXIST) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214272 - head/usr.bin/lex

2010-10-24 Thread Ulrich Spoerlein
Author: uqs
Date: Sun Oct 24 15:31:41 2010
New Revision: 214272
URL: http://svn.freebsd.org/changeset/base/214272

Log:
  flex: add missing ifdef magic to create/hide prototypes
  
  This unbreaks build for some software with higher WARNS flags.
  
  Reviewed by:  rpaulo
  PR:   bin/139319 (parts already committed in previous revision)

Modified:
  head/usr.bin/lex/flex.skl

Modified: head/usr.bin/lex/flex.skl
==
--- head/usr.bin/lex/flex.skl   Sun Oct 24 13:48:11 2010(r214271)
+++ head/usr.bin/lex/flex.skl   Sun Oct 24 15:31:41 2010(r214272)
@@ -747,7 +747,11 @@ void yyFlexLexer::LexerOutput( const cha
  */
 
 %-
+#ifdef YY_USE_PROTOS
 static int yy_get_next_buffer(void)
+#else
+static int yy_get_next_buffer()
+#endif
 %+
 int yyFlexLexer::yy_get_next_buffer()
 %*
@@ -883,7 +887,11 @@ int yyFlexLexer::yy_get_next_buffer()
 /* yy_get_previous_state - get the state just before the EOB char was reached 
*/
 
 %-
+#ifdef YY_USE_PROTOS
 static yy_state_type yy_get_previous_state(void)
+#else
+static yy_state_type yy_get_previous_state()
+#endif
 %+
 yy_state_type yyFlexLexer::yy_get_previous_state()
 %*
@@ -983,7 +991,11 @@ void yyFlexLexer::yyunput( int c, char* 
 #ifdef __cplusplus
 static int yyinput()
 #else
+#ifdef YY_USE_PROTOS
 static int input(void)
+#else
+static int input()
+#endif
 #endif
 %+
 int yyFlexLexer::yyinput()
@@ -1055,7 +1067,9 @@ int yyFlexLexer::yyinput()
 
return c;
}
-#endif /* ifndef YY_NO_INPUT */
+%-
+#endif /* ifndef YY_NO_INPUT */
+%*
 
 
 %-
@@ -1404,7 +1418,11 @@ void yyFlexLexer::yy_push_state( int new
 
 #ifndef YY_NO_POP_STATE
 %-
+#ifdef YY_USE_PROTOS
+static void yy_pop_state(void)
+#else
 static void yy_pop_state()
+#endif
 %+
 void yyFlexLexer::yy_pop_state()
 %*
@@ -1419,7 +1437,11 @@ void yyFlexLexer::yy_pop_state()
 
 #ifndef YY_NO_TOP_STATE
 %-
+#ifdef YY_USE_PROTOS
+static int yy_top_state(void)
+#else
 static int yy_top_state()
+#endif
 %+
 int yyFlexLexer::yy_top_state()
 %*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214261 - head/tools/tools/syscall_timing

2010-10-24 Thread Robert N. M. Watson
On 24 Oct 2010, at 14:20, Alexander Best  wrote:

> On Sun Oct 24 10, Robert Watson wrote:
>> Author: rwatson
>> Date: Sun Oct 24 09:14:21 2010
>> New Revision: 214261
>> URL: http://svn.freebsd.org/changeset/base/214261
>> 
>> Log:
>>  Add microbenchmark for create/unlink of a zero-byte file.
> 
> clang still complaining:
> 
> syscall_timing.c:766:24: warning: conversion specifies type 'int' but the 
> argument has type 'uintmax_t' (aka 'unsigned long') [-Wformat]
>printf("%ju.%09ju\t%d\t", (uintmax_t)ts_end.tv_sec,
>   ~^
>   %lu
> 1 warning generated.

Hi Alexander:

I also have detail feedback pending from Bruce on the uses of types in this 
tool, which I hope to get to later this week! Since doing so is sure to change 
the warnings, I'll revisit them then. In the mean time, however, I'll keep 
updating to tool to finish up this chapter... :-)

Thanks,

Robert ___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214271 - head/usr.sbin/usbconfig

2010-10-24 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Oct 24 13:48:11 2010
New Revision: 214271
URL: http://svn.freebsd.org/changeset/base/214271

Log:
  Remove stray semicolon.
  
  Submitted by: arundel

Modified:
  head/usr.sbin/usbconfig/usbconfig.c

Modified: head/usr.sbin/usbconfig/usbconfig.c
==
--- head/usr.sbin/usbconfig/usbconfig.c Sun Oct 24 13:43:45 2010
(r214270)
+++ head/usr.sbin/usbconfig/usbconfig.c Sun Oct 24 13:48:11 2010
(r214271)
@@ -640,7 +640,7 @@ main(int argc, char **argv)
opt->bus = unit;
opt->addr = addr;
opt->got_bus = 1;
-;  opt->got_addr = 1;
+   opt->got_addr = 1;
n++;
break;
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r214261 - head/tools/tools/syscall_timing

2010-10-24 Thread Alexander Best
On Sun Oct 24 10, Robert Watson wrote:
> Author: rwatson
> Date: Sun Oct 24 09:14:21 2010
> New Revision: 214261
> URL: http://svn.freebsd.org/changeset/base/214261
> 
> Log:
>   Add microbenchmark for create/unlink of a zero-byte file.

clang still complaining:

syscall_timing.c:766:24: warning: conversion specifies type 'int' but the 
argument has type 'uintmax_t' (aka 'unsigned long') [-Wformat]
printf("%ju.%09ju\t%d\t", (uintmax_t)ts_end.tv_sec,
   ~^
   %lu
1 warning generated.

cheers.
alex

>   
>   Sponsored by:   Google, Inc.
>   MFC after:  2 weeks
> 
> Modified:
>   head/tools/tools/syscall_timing/syscall_timing.c
> 
> Modified: head/tools/tools/syscall_timing/syscall_timing.c
> ==
> --- head/tools/tools/syscall_timing/syscall_timing.c  Sun Oct 24 05:22:07 
> 2010(r214260)
> +++ head/tools/tools/syscall_timing/syscall_timing.c  Sun Oct 24 09:14:21 
> 2010(r214261)
> @@ -260,6 +260,34 @@ test_socketpair_dgram(uintmax_t num, uin
>  }
>  
>  uintmax_t
> +test_create_unlink(uintmax_t num, uintmax_t int_arg, const char *path)
> +{
> + uintmax_t i;
> + int fd;
> +
> + (void)unlink(path);
> + fd = open(path, O_RDWR | O_CREAT, 0600);
> + if (fd < 0)
> + err(-1, "test_create_unlink: create: %s", path);
> + close(fd);
> + if (unlink(path) < 0)
> + err(-1, "test_create_unlink: unlink: %s", path);
> + benchmark_start();
> + for (i = 0; i < num; i++) {
> + if (alarm_fired)
> + break;
> + fd = open(path, O_RDWR | O_CREAT, 0600);
> + if (fd < 0)
> + err(-1, "test_create_unlink: create: %s", path);
> + close(fd);
> + if (unlink(path) < 0)
> + err(-1, "test_create_unlink: unlink: %s", path);
> + }
> + benchmark_stop();
> + return (i);
> +}
> +
> +uintmax_t
>  test_open_close(uintmax_t num, uintmax_t int_arg, const char *path)
>  {
>   uintmax_t i;
> @@ -292,7 +320,7 @@ test_read(uintmax_t num, uintmax_t int_a
>  
>   fd = open(path, O_RDONLY);
>   if (fd < 0)
> - err(-1, "test_open_close: %s", path);
> + err(-1, "test_open_read: %s", path);
>   (void)pread(fd, buf, int_arg, 0);
>  
>   benchmark_start();
> @@ -315,7 +343,7 @@ test_open_read_close(uintmax_t num, uint
>  
>   fd = open(path, O_RDONLY);
>   if (fd < 0)
> - err(-1, "test_open_close: %s", path);
> + err(-1, "test_open_read_close: %s", path);
>   (void)read(fd, buf, int_arg);
>   close(fd);
>  
> @@ -325,7 +353,7 @@ test_open_read_close(uintmax_t num, uint
>   break;
>   fd = open(path, O_RDONLY);
>   if (fd < 0)
> - err(-1, "test_open_close: %s", path);
> + err(-1, "test_open_read_close: %s", path);
>   (void)read(fd, buf, int_arg);
>   close(fd);
>   }
> @@ -587,6 +615,7 @@ static const struct test tests[] = {
>   { "socketpair_dgram", test_socketpair_dgram },
>   { "socket_tcp", test_socket_stream, .t_int = PF_INET },
>   { "socket_udp", test_socket_dgram, .t_int = PF_INET },
> + { "create_unlink", test_create_unlink, .t_flags = FLAG_PATH },
>   { "open_close", test_open_close, .t_flags = FLAG_PATH },
>   { "open_read_close_1", test_open_read_close, .t_flags = FLAG_PATH,
>   .t_int = 1 },

-- 
a13x
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214265 - head/sys/dev/mii

2010-10-24 Thread Marius Strobl
Author: marius
Date: Sun Oct 24 12:59:43 2010
New Revision: 214265
URL: http://svn.freebsd.org/changeset/base/214265

Log:
  - Given that as of r214264 all PHY drivers using mii(4) finally have been
converted to use the mii_phy_add_media()/mii_phy_setmedia() pair instead
of mii_add_media()/mii_anar() remove the latter.
  - Declare mii_media mii_media_table static as it shouldn't be used outside
of mii_physubr.c.
  
  MFC after:never

Modified:
  head/sys/dev/mii/mii_physubr.c
  head/sys/dev/mii/miivar.h

Modified: head/sys/dev/mii/mii_physubr.c
==
--- head/sys/dev/mii/mii_physubr.c  Sun Oct 24 12:51:02 2010
(r214264)
+++ head/sys/dev/mii/mii_physubr.c  Sun Oct 24 12:59:43 2010
(r214265)
@@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
 /*
  * Media to register setting conversion table.  Order matters.
  */
-const struct mii_media mii_media_table[MII_NMEDIA] = {
+static const struct mii_media mii_media_table[MII_NMEDIA] = {
/* None */
{ BMCR_ISO, ANAR_CSMA,
  0, },
@@ -287,99 +287,6 @@ mii_phy_update(struct mii_softc *sc, int
 }
 
 /*
- * Given an ifmedia word, return the corresponding ANAR value.
- */
-int
-mii_anar(int media)
-{
-   int rv;
-
-   switch (media & (IFM_TMASK|IFM_NMASK|IFM_FDX)) {
-   case IFM_ETHER|IFM_10_T:
-   rv = ANAR_10|ANAR_CSMA;
-   break;
-   case IFM_ETHER|IFM_10_T|IFM_FDX:
-   rv = ANAR_10_FD|ANAR_CSMA;
-   break;
-   case IFM_ETHER|IFM_100_TX:
-   rv = ANAR_TX|ANAR_CSMA;
-   break;
-   case IFM_ETHER|IFM_100_TX|IFM_FDX:
-   rv = ANAR_TX_FD|ANAR_CSMA;
-   break;
-   case IFM_ETHER|IFM_100_T4:
-   rv = ANAR_T4|ANAR_CSMA;
-   break;
-   default:
-   rv = 0;
-   break;
-   }
-
-   return (rv);
-}
-
-/*
- * Initialize generic PHY media based on BMSR, called when a PHY is
- * attached.  We expect to be set up to print a comma-separated list
- * of media names.  Does not print a newline.
- */
-void
-mii_add_media(struct mii_softc *sc)
-{
-   struct mii_data *mii = sc->mii_pdata;
-   const char *sep = "";
-
-   if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) {
-   printf("no media present");
-   return;
-   }
-
-#defineADD(m, c)   ifmedia_add(&mii->mii_media, (m), (c), NULL)
-#definePRINT(s)printf("%s%s", sep, s); sep = ", "
-
-   if (sc->mii_capabilities & BMSR_10THDX) {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst), 0);
-   PRINT("10baseT");
-   }
-   if (sc->mii_capabilities & BMSR_10TFDX) {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst),
-   BMCR_FDX);
-   PRINT("10baseT-FDX");
-   }
-   if (sc->mii_capabilities & BMSR_100TXHDX) {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst),
-   BMCR_S100);
-   PRINT("100baseTX");
-   }
-   if (sc->mii_capabilities & BMSR_100TXFDX) {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst),
-   BMCR_S100|BMCR_FDX);
-   PRINT("100baseTX-FDX");
-   }
-   if (sc->mii_capabilities & BMSR_100T4) {
-   /*
-* XXX How do you enable 100baseT4?  I assume we set
-* XXX BMCR_S100 and then assume the PHYs will take
-* XXX watever action is necessary to switch themselves
-* XXX into T4 mode.
-*/
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_T4, 0, sc->mii_inst),
-   BMCR_S100);
-   PRINT("100baseT4");
-   }
-   if (sc->mii_capabilities & BMSR_ANEG) {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst),
-   BMCR_AUTOEN);
-   PRINT("auto");
-   }
-
-
-
-#undef ADD
-#undef PRINT
-}
-
-/*
  * Initialize generic PHY media based on BMSR, called when a PHY is
  * attached.  We expect to be set up to print a comma-separated list
  * of media names.  Does not print a newline.

Modified: head/sys/dev/mii/miivar.h
==
--- head/sys/dev/mii/miivar.h   Sun Oct 24 12:51:02 2010(r214264)
+++ head/sys/dev/mii/miivar.h   Sun Oct 24 12:59:43 2010(r214265)
@@ -227,12 +227,10 @@ int   miibus_detach(device_t);
 
 intmii_attach(device_t, device_t *, struct ifnet *, ifm_change_cb_t,
ifm_stat_cb_t, int, int, int, int);
-intmii_anar(int);
 void   mii_down(struct mii_data *);
 intmii_mediachg(struct mii_data *);
 void   mii_tick(struct mii_data *);
 void   mii_pollstat(struct mii_data *);
-void   mii_add_media(struct mii_softc *);
 void   mii_phy_add_media(struct mii_s

svn commit: r214264 - in head/sys/dev: mii tl

2010-10-24 Thread Marius Strobl
Author: marius
Date: Sun Oct 24 12:51:02 2010
New Revision: 214264
URL: http://svn.freebsd.org/changeset/base/214264

Log:
  - Add IFM_10_2 and IFM_10_5 media via tlphy(4) only in case the respective
interface also has such connectors.
  - In tl_attach() unify three different ways of obtaining the device and
vendor IDs and remove the now obsolete tl_dinfo from tl_softc.
  - Given that tlphy(4) only handles the integrated PHYs of NICs driven by
tl(4) make it only probe on the latter.
  - Switch mlphy(4) and tlphy(4) to use mii_phy_add_media()/mii_phy_setmedia().
  - Simplify looking for the respective companion PHY in mlphy(4) and tlphy(4)
by ignoring the native one by just comparing the device_t's directly rather
than the device name.

Modified:
  head/sys/dev/mii/mlphy.c
  head/sys/dev/mii/tlphy.c
  head/sys/dev/tl/if_tl.c
  head/sys/dev/tl/if_tlreg.h

Modified: head/sys/dev/mii/mlphy.c
==
--- head/sys/dev/mii/mlphy.cSun Oct 24 11:38:25 2010(r214263)
+++ head/sys/dev/mii/mlphy.cSun Oct 24 12:51:02 2010(r214264)
@@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
 
 struct mlphy_softc {
struct mii_softcml_mii;
+   device_tml_dev;
int ml_state;
int ml_linked;
 };
@@ -96,6 +97,7 @@ static driver_t mlphy_driver = {
 
 DRIVER_MODULE(mlphy, miibus, mlphy_driver, mlphy_devclass, 0, 0);
 
+static struct mii_softc *mlphy_find_other(struct mlphy_softc *);
 static int mlphy_service(struct mii_softc *, struct mii_data *, int);
 static voidmlphy_reset(struct mii_softc *);
 static voidmlphy_status(struct mii_softc *);
@@ -105,10 +107,8 @@ mlphy_probe(dev)
device_tdev;
 {
struct mii_attach_args  *ma;
-   device_tparent;
 
ma = device_get_ivars(dev);
-   parent = device_get_parent(device_get_parent(dev));
 
/*
 * Micro Linear PHY reports oui == 0 model == 0
@@ -122,7 +122,8 @@ mlphy_probe(dev)
 * encountered the 6692 on an Olicom card with a ThunderLAN
 * controller chip.
 */
-   if (strcmp(device_get_name(parent), "tl") != 0)
+   if (strcmp(device_get_name(device_get_parent(device_get_parent(dev))),
+   "tl") != 0)
return (ENXIO);
 
device_set_desc(dev, "Micro Linear 6692 media interface");
@@ -141,6 +142,7 @@ mlphy_attach(dev)
 
msc = device_get_softc(dev);
sc = &msc->ml_mii;
+   msc->ml_dev = dev;
ma = device_get_ivars(dev);
sc->mii_dev = device_get_parent(dev);
mii = ma->mii_data;
@@ -155,14 +157,15 @@ mlphy_attach(dev)
 #defineADD(m, c)   ifmedia_add(&mii->mii_media, (m), (c), NULL)
 
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
-   BMCR_LOOP|BMCR_S100);
+   MII_MEDIA_100_TX);
 
mii_phy_reset(sc);
 
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+   /* Let the companion PHY (if any) only handle the media we don't. */
ma->mii_capmask = ~sc->mii_capabilities;
device_printf(dev, " ");
-   mii_add_media(sc);
+   mii_phy_add_media(sc);
printf("\n");
 #undef ADD
MIIBUS_MEDIAINIT(sc->mii_dev);
@@ -170,20 +173,21 @@ mlphy_attach(dev)
 }
 
 static struct mii_softc *
-mlphy_find_other(device_t mii)
+mlphy_find_other(struct mlphy_softc *msc)
 {
device_t*devlist;
struct mii_softc *retval;
int i, devs;
 
retval = NULL;
-   if (device_get_children(mii, &devlist, &devs))
+   if (device_get_children(msc->ml_mii.mii_dev, &devlist, &devs) != 0)
return (NULL);
-   for (i = 0; i < devs; i++)
-   if (strcmp(device_get_name(devlist[i]), "mlphy")) {
+   for (i = 0; i < devs; i++) {
+   if (devlist[i] != msc->ml_dev) {
retval = device_get_softc(devlist[i]);
break;
}
+   }
free(devlist, M_TEMP);
return (retval);
 }
@@ -204,7 +208,7 @@ mlphy_service(xsc, mii, cmd)
 * See if there's another PHY on this bus with us.
 * If so, we may need it for 10Mbps modes.
 */
-   other = mlphy_find_other(msc->ml_mii.mii_dev);
+   other = mlphy_find_other(msc);
 
switch (cmd) {
case MII_POLLSTAT:
@@ -229,7 +233,7 @@ mlphy_service(xsc, mii, cmd)
mii_phy_reset(other);
PHY_WRITE(other, MII_BMCR, BMCR_ISO);
}
-   (void) mii_phy_auto(sc);
+   (void)mii_phy_auto(sc);
msc->ml_linked = 0;
return (0);
case IFM_10_T:
@@ -246,8 +250,7 @@ mlphy_service(xsc, mii, cmd)
mii_phy_reset(other);
 

svn commit: r214263 - head/sys/dev/mii

2010-10-24 Thread Marius Strobl
Author: marius
Date: Sun Oct 24 11:38:25 2010
New Revision: 214263
URL: http://svn.freebsd.org/changeset/base/214263

Log:
  Take advantage of mii_phy_add_media()/mii_phy_setmedia().

Modified:
  head/sys/dev/mii/pnaphy.c

Modified: head/sys/dev/mii/pnaphy.c
==
--- head/sys/dev/mii/pnaphy.c   Sun Oct 24 11:37:01 2010(r214262)
+++ head/sys/dev/mii/pnaphy.c   Sun Oct 24 11:38:25 2010(r214263)
@@ -102,7 +102,6 @@ pnaphy_attach(device_t dev)
struct mii_softc *sc;
struct mii_attach_args *ma;
struct mii_data *mii;
-   const char *sep = "";
 
sc = device_get_softc(dev);
ma = device_get_ivars(dev);
@@ -116,29 +115,16 @@ pnaphy_attach(device_t dev)
sc->mii_service = pnaphy_service;
sc->mii_pdata = mii;
 
-   sc->mii_flags |= MIIF_NOISOLATE;
-
-#defineADD(m, c)   ifmedia_add(&mii->mii_media, (m), (c), NULL)
-#define PRINT(s)   printf("%s%s", sep, s); sep = ", "
+   sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP | MIIF_IS_HPNA;
 
mii_phy_reset(sc);
 
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
device_printf(dev, " ");
-   if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
-   printf("no media present");
-   else {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_HPNA_1, 0, sc->mii_inst), 0);
-   PRINT("HomePNA");
-   }
-
+   mii_phy_add_media(sc);
printf("\n");
 
-#undef ADD
-#undef PRINT
-
MIIBUS_MEDIAINIT(sc->mii_dev);
-
return (0);
 }
 
@@ -159,17 +145,11 @@ pnaphy_service(struct mii_softc *sc, str
break;
 
switch (IFM_SUBTYPE(ife->ifm_media)) {
-   case IFM_AUTO:
-   case IFM_10_T:
-   case IFM_100_TX:
-   case IFM_100_T4:
-   return (EINVAL);
+   case IFM_HPNA_1:
+   mii_phy_setmedia(sc);
+   break;
default:
-   /*
-* BMCR data is stored in the ifmedia entry.
-*/
-   PHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media));
-   PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
+   return (EINVAL);
}
break;
 
@@ -182,7 +162,7 @@ pnaphy_service(struct mii_softc *sc, str
/* Update the media status. */
ukphy_status(sc);
if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T)
-   mii->mii_media_active = IFM_ETHER|IFM_HPNA_1;
+   mii->mii_media_active = IFM_ETHER | IFM_HPNA_1;
 
/* Callback if something changed. */
mii_phy_update(sc, cmd);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214262 - head/sys/dev/mii

2010-10-24 Thread Marius Strobl
Author: marius
Date: Sun Oct 24 11:37:01 2010
New Revision: 214262
URL: http://svn.freebsd.org/changeset/base/214262

Log:
  - Take advantage of mii_phy_dev_probe().
  - Use mii_phy_add_media() instead of mii_add_media(). I'm not sure how
this driver actually managed to work before as mii_add_media() is
intended to be used to gether with mii_anar() while mii_phy_add_media()
is intended to be used with mii_phy_setmedia(), however this driver
mii_add_media() along with mii_phy_setmedia().

Modified:
  head/sys/dev/mii/smcphy.c

Modified: head/sys/dev/mii/smcphy.c
==
--- head/sys/dev/mii/smcphy.c   Sun Oct 24 09:14:21 2010(r214261)
+++ head/sys/dev/mii/smcphy.c   Sun Oct 24 11:37:01 2010(r214262)
@@ -76,20 +76,16 @@ static driver_t smcphy_driver = {
 
 DRIVER_MODULE(smcphy, miibus, smcphy_driver, smcphy_devclass, 0, 0);
 
+static const struct mii_phydesc smcphys[] = {
+   MII_PHY_DESC(SMSC, LAN83C183),
+   MII_PHY_END
+};
+
 static int
 smcphy_probe(device_t dev)
 {
-   struct  mii_attach_args *ma;
-
-   ma = device_get_ivars(dev);
 
-   if (MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_SMSC ||
-   MII_MODEL(ma->mii_id2) != MII_MODEL_SMSC_LAN83C183)
-   return (ENXIO);
-
-   device_set_desc(dev, MII_STR_SMSC_LAN83C183);
-
-   return (0);
+   return (mii_phy_dev_probe(dev, smcphys, BUS_PROBE_DEFAULT));
 }
 
 static int
@@ -111,7 +107,7 @@ smcphy_attach(device_t dev)
sc->mii_service = smcphy_service;
sc->mii_pdata = mii;
 
-   sc->mii_flags |= MIIF_NOISOLATE;
+   sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
 
if (smcphy_reset(sc) != 0) {
device_printf(dev, "reset failed\n");
@@ -122,7 +118,7 @@ smcphy_attach(device_t dev)
 
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
device_printf(dev, " ");
-   mii_add_media(sc);
+   mii_phy_add_media(sc);
printf("\n");
 
MIIBUS_MEDIAINIT(sc->mii_dev);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r214261 - head/tools/tools/syscall_timing

2010-10-24 Thread Robert Watson
Author: rwatson
Date: Sun Oct 24 09:14:21 2010
New Revision: 214261
URL: http://svn.freebsd.org/changeset/base/214261

Log:
  Add microbenchmark for create/unlink of a zero-byte file.
  
  Sponsored by: Google, Inc.
  MFC after:2 weeks

Modified:
  head/tools/tools/syscall_timing/syscall_timing.c

Modified: head/tools/tools/syscall_timing/syscall_timing.c
==
--- head/tools/tools/syscall_timing/syscall_timing.cSun Oct 24 05:22:07 
2010(r214260)
+++ head/tools/tools/syscall_timing/syscall_timing.cSun Oct 24 09:14:21 
2010(r214261)
@@ -260,6 +260,34 @@ test_socketpair_dgram(uintmax_t num, uin
 }
 
 uintmax_t
+test_create_unlink(uintmax_t num, uintmax_t int_arg, const char *path)
+{
+   uintmax_t i;
+   int fd;
+
+   (void)unlink(path);
+   fd = open(path, O_RDWR | O_CREAT, 0600);
+   if (fd < 0)
+   err(-1, "test_create_unlink: create: %s", path);
+   close(fd);
+   if (unlink(path) < 0)
+   err(-1, "test_create_unlink: unlink: %s", path);
+   benchmark_start();
+   for (i = 0; i < num; i++) {
+   if (alarm_fired)
+   break;
+   fd = open(path, O_RDWR | O_CREAT, 0600);
+   if (fd < 0)
+   err(-1, "test_create_unlink: create: %s", path);
+   close(fd);
+   if (unlink(path) < 0)
+   err(-1, "test_create_unlink: unlink: %s", path);
+   }
+   benchmark_stop();
+   return (i);
+}
+
+uintmax_t
 test_open_close(uintmax_t num, uintmax_t int_arg, const char *path)
 {
uintmax_t i;
@@ -292,7 +320,7 @@ test_read(uintmax_t num, uintmax_t int_a
 
fd = open(path, O_RDONLY);
if (fd < 0)
-   err(-1, "test_open_close: %s", path);
+   err(-1, "test_open_read: %s", path);
(void)pread(fd, buf, int_arg, 0);
 
benchmark_start();
@@ -315,7 +343,7 @@ test_open_read_close(uintmax_t num, uint
 
fd = open(path, O_RDONLY);
if (fd < 0)
-   err(-1, "test_open_close: %s", path);
+   err(-1, "test_open_read_close: %s", path);
(void)read(fd, buf, int_arg);
close(fd);
 
@@ -325,7 +353,7 @@ test_open_read_close(uintmax_t num, uint
break;
fd = open(path, O_RDONLY);
if (fd < 0)
-   err(-1, "test_open_close: %s", path);
+   err(-1, "test_open_read_close: %s", path);
(void)read(fd, buf, int_arg);
close(fd);
}
@@ -587,6 +615,7 @@ static const struct test tests[] = {
{ "socketpair_dgram", test_socketpair_dgram },
{ "socket_tcp", test_socket_stream, .t_int = PF_INET },
{ "socket_udp", test_socket_dgram, .t_int = PF_INET },
+   { "create_unlink", test_create_unlink, .t_flags = FLAG_PATH },
{ "open_close", test_open_close, .t_flags = FLAG_PATH },
{ "open_read_close_1", test_open_read_close, .t_flags = FLAG_PATH,
.t_int = 1 },
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"