svn commit: r279392 - head/usr.sbin/ctld

2015-02-28 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Feb 28 12:02:32 2015
New Revision: 279392
URL: https://svnweb.freebsd.org/changeset/base/279392

Log:
  Move the "offload" clause from the target section to portal-group
  section; it makes more sense there.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/ctld/ctl.conf.5
  head/usr.sbin/ctld/ctld.c
  head/usr.sbin/ctld/ctld.h
  head/usr.sbin/ctld/kernel.c
  head/usr.sbin/ctld/login.c
  head/usr.sbin/ctld/parse.y

Modified: head/usr.sbin/ctld/ctl.conf.5
==
--- head/usr.sbin/ctld/ctl.conf.5   Sat Feb 28 05:14:42 2015
(r279391)
+++ head/usr.sbin/ctld/ctl.conf.5   Sat Feb 28 12:02:32 2015
(r279392)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 11, 2015
+.Dd February 27, 2015
 .Dt CTL.CONF 5
 .Os
 .Sh NAME
@@ -228,6 +228,9 @@ An IPv4 or IPv6 address and port to list
 .\".It Ic listen-iser Ar address
 .\"An IPv4 or IPv6 address and port to listen on for incoming connections
 .\"using iSER (iSCSI over RDMA) protocol.
+.It Ic offload Ar driver
+Define iSCSI hardware offload driver to use for this
+.Sy portal-group .
 .It Ic redirect Ar address
 IPv4 or IPv6 address to redirect initiators to.
 When configured, all initiators attempting to connect to portal
@@ -311,8 +314,6 @@ This clause is mutually exclusive with
 .Sy auth-group ;
 one cannot use
 both in a single target.
-.It Ic offload Ar driver
-Define iSCSI hardware offload driver to use for this target.
 .It Ic portal-group Ar name Op Ar agname
 Assign a previously defined portal group to the target.
 The default portal group is

Modified: head/usr.sbin/ctld/ctld.c
==
--- head/usr.sbin/ctld/ctld.c   Sat Feb 28 05:14:42 2015(r279391)
+++ head/usr.sbin/ctld/ctld.c   Sat Feb 28 12:02:32 2015(r279392)
@@ -637,6 +637,7 @@ portal_group_delete(struct portal_group 
TAILQ_FOREACH_SAFE(portal, &pg->pg_portals, p_next, tmp)
portal_delete(portal);
free(pg->pg_name);
+   free(pg->pg_offload);
free(pg->pg_redirection);
free(pg);
 }
@@ -1023,6 +1024,22 @@ portal_group_set_filter(struct portal_gr
 }
 
 int
+portal_group_set_offload(struct portal_group *pg, const char *offload)
+{
+
+   if (pg->pg_offload != NULL) {
+   log_warnx("cannot set offload to \"%s\" for "
+   "portal-group \"%s\"; already defined",
+   offload, pg->pg_name);
+   return (1);
+   }
+
+   pg->pg_offload = checked_strdup(offload);
+
+   return (0);
+}
+
+int
 portal_group_set_redirection(struct portal_group *pg, const char *addr)
 {
 
@@ -1361,22 +1378,6 @@ target_set_redirection(struct target *ta
return (0);
 }
 
-int
-target_set_offload(struct target *target, const char *offload)
-{
-
-   if (target->t_offload != NULL) {
-   log_warnx("cannot set offload to \"%s\" for "
-   "target \"%s\"; already defined",
-   offload, target->t_name);
-   return (1);
-   }
-
-   target->t_offload = checked_strdup(offload);
-
-   return (0);
-}
-
 struct lun *
 lun_new(struct conf *conf, const char *name)
 {
@@ -1619,8 +1620,6 @@ conf_print(struct conf *conf)
fprintf(stderr, "target %s {\n", targ->t_name);
if (targ->t_alias != NULL)
fprintf(stderr, "\t alias %s\n", targ->t_alias);
-   if (targ->t_offload != NULL)
-   fprintf(stderr, "\t offload %s\n", targ->t_offload);
fprintf(stderr, "}\n");
}
 }

Modified: head/usr.sbin/ctld/ctld.h
==
--- head/usr.sbin/ctld/ctld.h   Sat Feb 28 05:14:42 2015(r279391)
+++ head/usr.sbin/ctld/ctld.h   Sat Feb 28 12:02:32 2015(r279392)
@@ -120,6 +120,7 @@ struct portal_group {
boolpg_unassigned;
TAILQ_HEAD(, portal)pg_portals;
TAILQ_HEAD(, port)  pg_ports;
+   char*pg_offload;
char*pg_redirection;
 
uint16_tpg_tag;
@@ -180,7 +181,6 @@ struct target {
TAILQ_HEAD(, port)  t_ports;
char*t_name;
char*t_alias;
-   char*t_offload;
char*t_redirection;
 };
 
@@ -336,6 +336,8 @@ int portal_group_add_listen(struct por
const char *listen, bool iser);
 intportal_group_set_filter(struct portal_group *pg,
const char *filter);
+intportal_group_set_offload(struct portal_group *pg,
+  

Re: svn commit: r279338 - head/sys/arm/include

2015-02-28 Thread John Baldwin
On Saturday, February 28, 2015 12:38:00 PM Bruce Evans wrote:
> On Fri, 27 Feb 2015, Ian Lepore wrote:
> > ::sigh::  As usual, thousands of words, maybe there's actionable info in
> > 
> > there, but I sure don't have time to ferret it out.
> > 
> > If there's something simple you'd like me to do, please say so. Simply.
> 
> Just back out the change.  For extra credit, back it out for i386 too.
> For too much work, fix the 17 calls with bogus casts.

Yes.  For better or for worse, atomic_*_ptr operate on uintptr_t objects, not 
void * objects.  Bruce explained this to DES before but DES ignored him.  If 
you really want to use explicit atomic ops on void * objects, then the 
suggestion back then was to add a new 'atomic_*_intptr' or the like and 
convert all existing uintptr objects (like all the lock cookies) to use those 
and then change atomic_*_ptr to operate on void * objects.  However, that's a 
fair bit of work.

-- 
John Baldwin
___
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: r279381 - head/sys/boot/amd64/efi

2015-02-28 Thread John Baldwin
On Friday, February 27, 2015 10:22:06 PM David E. O'Brien wrote:
> Author: obrien
> Date: Fri Feb 27 22:22:05 2015
> New Revision: 279381
> URL: https://svnweb.freebsd.org/changeset/base/279381
> 
> Log:
>   Use sys/boot/userboot/libstand/ and not /usr/lib/libstand.a.
> 
> Modified:
>   head/sys/boot/amd64/efi/Makefile

Ugh, this is wrong, please revert.  For one, I just ran into a bug where the 
EFI bits are prone to random corruption because the EFI ABI doesn't use a 
redzone like the System V amd64 ABI.  userboot is a C program though and will 
use the System V ABI, so it can't share libstand with loader.efi.  Locally I 
have changed /usr/lib/libstand on amd64 to use -mno-red-zone as loader.efi is 
the only thing on amd64 that uses it (so this avoids mixing the ABIs).

Also, if anything this should be using the lib/libstand from OBJDIR as that is
what other loader binaries do.

-- 
John Baldwin
___
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: r279393 - head/sys/dev/ixgbe

2015-02-28 Thread Garrett Cooper
Author: ngie
Date: Sat Feb 28 14:57:57 2015
New Revision: 279393
URL: https://svnweb.freebsd.org/changeset/base/279393

Log:
  Pad RX copy alignment calculation to avoid illegal memory accesses
  
  The optimization made in r239940 is valid for struct mbuf's current structure
  and size in FreeBSD, but hardcodes assumptions about sizes of struct mbuf,
  which are unfortunately broken if additional data is added to the beginning of
  struct mbuf
  
  X-MFC note (discussed with rwatson):
  
  This change requires the MPKTHSIZE definition, which is only available after
  head@r277203 and will not be MFCed as it breaks mbuf(9) KPI.
  
  A direct commit to stable/10 and merges to other branches to add the necessary
  definitions to work with the code as-is will be done to facilitate this MFC
  
  PR: 194314
  MFC after: 2 weeks
  Approved/Reviewed by: erj, jfv
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/dev/ixgbe/ixgbe.h

Modified: head/sys/dev/ixgbe/ixgbe.h
==
--- head/sys/dev/ixgbe/ixgbe.h  Sat Feb 28 12:02:32 2015(r279392)
+++ head/sys/dev/ixgbe/ixgbe.h  Sat Feb 28 14:57:57 2015(r279393)
@@ -162,8 +162,9 @@
  * modern Intel CPUs, results in 40 bytes wasted and a significant drop
  * in observed efficiency of the optimization, 97.9% -> 81.8%.
  */
-#define IXGBE_RX_COPY_LEN  160
-#define IXGBE_RX_COPY_ALIGN(MHLEN - IXGBE_RX_COPY_LEN)
+#define IXGBE_RX_COPY_HDR_PADDED   MPKTHSIZE - 1) / 32) + 1) * 32)
+#define IXGBE_RX_COPY_LEN  (MSIZE - IXGBE_RX_COPY_HDR_PADDED)
+#define IXGBE_RX_COPY_ALIGN(IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE)
 
 /* Keep older OS drivers building... */
 #if !defined(SYSCTL_ADD_UQUAD)
___
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: r279393 - head/sys/dev/ixgbe

2015-02-28 Thread Garrett Cooper
On Feb 28, 2015, at 6:57, Garrett Cooper  wrote:

> Author: ngie
> Date: Sat Feb 28 14:57:57 2015
> New Revision: 279393
> URL: https://svnweb.freebsd.org/changeset/base/279393
> 
> Log:
>  Pad RX copy alignment calculation to avoid illegal memory accesses
> 
>  The optimization made in r239940 is valid for struct mbuf's current structure
>  and size in FreeBSD, but hardcodes assumptions about sizes of struct mbuf,
>  which are unfortunately broken if additional data is added to the beginning 
> of
>  struct mbuf
> 
>  X-MFC note (discussed with rwatson):
> 
>  This change requires the MPKTHSIZE definition, which is only available after
>  head@r277203 and will not be MFCed as it breaks mbuf(9) KPI.
> 
>  A direct commit to stable/10 and merges to other branches to add the 
> necessary
>  definitions to work with the code as-is will be done to facilitate this MFC
> 
>  PR: 194314
>  MFC after: 2 weeks
>  Approved/Reviewed by: erj, jfv
>  Sponsored by: EMC / Isilon Storage Division

I forgot to note that the fix was submitted by erj in the PR. I’ll fix that in 
the MFC message.

Thank you very much for the help Eric and Jack!


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r279361 - in head: sys/kern sys/sys usr.sbin/jail

2015-02-28 Thread Dmitry Morozovsky
Ian,

On Fri, 27 Feb 2015, Ian Lepore wrote:

> Author: ian
> Date: Fri Feb 27 16:28:55 2015
> New Revision: 279361
> URL: https://svnweb.freebsd.org/changeset/base/279361
> 
> Log:
>   Allow the kern.osrelease and kern.osreldate sysctl values to be set in a
>   jail's creation parameters.  This allows the kernel version to be reliably
>   spoofed within the jail whether examined directly with sysctl or
>   indirectly with the uname -r and -K options.
>   
>   The values can only be set at jail creation time, to eliminate the need
>   for any locking when accessing the values via sysctl.
>   
>   The overridden values are inherited by nested jails (unless the config for
>   the nested jails also overrides the values).
>   
>   There is no sanity or range checking, other than disallowing an empty
>   release string or a zero release date, by design.  The system
>   administrator is trusted to set sane values.  Setting values that are
>   newer than the actual running kernel will likely cause compatibility
>   problems.
>   
>   Differential Revision:  https://reviews.freebsd.org/D1948
>   Relnotes:   yes

Thanks, very useful feature.  Just one question: no MFC planned?

[diff snipped]

-- 
Sincerely,
D.Marck [DM5020, MCK-RIPE, DM3-RIPN]
[ FreeBSD committer: ma...@freebsd.org ]

*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- ma...@rinet.ru ***

___
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: r279394 - head/sys/dev/xen/netback

2015-02-28 Thread Roger Pau Monné
Author: royger
Date: Sat Feb 28 15:21:06 2015
New Revision: 279394
URL: https://svnweb.freebsd.org/changeset/base/279394

Log:
  netback: disable GSO
  
  The current GSO implementation in netback is broken and causes errors on the
  guest tx path. While this is fixed disable GSO in order to have a working
  netback.
  
  Sponsored by: Citrix Systems R&D
  Discussed with: gibbs

Modified:
  head/sys/dev/xen/netback/netback.c

Modified: head/sys/dev/xen/netback/netback.c
==
--- head/sys/dev/xen/netback/netback.c  Sat Feb 28 14:57:57 2015
(r279393)
+++ head/sys/dev/xen/netback/netback.c  Sat Feb 28 15:21:06 2015
(r279394)
@@ -98,7 +98,7 @@ __FBSDID("$FreeBSD$");
 static MALLOC_DEFINE(M_XENNETBACK, "xnb", "Xen Net Back Driver Data");
 
 #defineXNB_SG  1   /* netback driver supports feature-sg */
-#defineXNB_GSO_TCPV4 1 /* netback driver supports feature-gso-tcpv4 */
+#defineXNB_GSO_TCPV4 0 /* netback driver supports feature-gso-tcpv4 */
 #defineXNB_RX_COPY 1   /* netback driver supports feature-rx-copy */
 #defineXNB_RX_FLIP 0   /* netback driver does not support 
feature-rx-flip */
 
___
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: r279361 - in head: sys/kern sys/sys usr.sbin/jail

2015-02-28 Thread Ian Lepore
On Sat, 2015-02-28 at 18:03 +0300, Dmitry Morozovsky wrote:
> Ian,
> 
> On Fri, 27 Feb 2015, Ian Lepore wrote:
> 
> > Author: ian
> > Date: Fri Feb 27 16:28:55 2015
> > New Revision: 279361
> > URL: https://svnweb.freebsd.org/changeset/base/279361
> > 
> > Log:
> >   Allow the kern.osrelease and kern.osreldate sysctl values to be set in a
> >   jail's creation parameters.  This allows the kernel version to be reliably
> >   spoofed within the jail whether examined directly with sysctl or
> >   indirectly with the uname -r and -K options.
> >   
> >   The values can only be set at jail creation time, to eliminate the need
> >   for any locking when accessing the values via sysctl.
> >   
> >   The overridden values are inherited by nested jails (unless the config for
> >   the nested jails also overrides the values).
> >   
> >   There is no sanity or range checking, other than disallowing an empty
> >   release string or a zero release date, by design.  The system
> >   administrator is trusted to set sane values.  Setting values that are
> >   newer than the actual running kernel will likely cause compatibility
> >   problems.
> >   
> >   Differential Revision:https://reviews.freebsd.org/D1948
> >   Relnotes: yes
> 
> Thanks, very useful feature.  Just one question: no MFC planned?
> 
> [diff snipped]
> 
> -- 
> Sincerely,
> D.Marck [DM5020, MCK-RIPE, DM3-RIPN]
> [ FreeBSD committer: ma...@freebsd.org ]
> 
> *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- ma...@rinet.ru ***
> 

I will definitely mfc (we need this on 10-stable at $work), but I hate
being spammed and/or nagged by robots so I don't use MFC: tags.

-- ian


___
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: r279361 - in head: sys/kern sys/sys usr.sbin/jail

2015-02-28 Thread Dmitry Morozovsky
On Sat, 28 Feb 2015, Ian Lepore wrote:

> > Thanks, very useful feature.  Just one question: no MFC planned?
> > 
> > [diff snipped]
> 
> I will definitely mfc (we need this on 10-stable at $work), but I hate
> being spammed and/or nagged by robots so I don't use MFC: tags.

X-MFC-in: $period

would suffice both your and others needs I suppose then...

-- 
Sincerely,
D.Marck [DM5020, MCK-RIPE, DM3-RIPN]
[ FreeBSD committer: ma...@freebsd.org ]

*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- ma...@rinet.ru ***

___
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: r279395 - head/sys/kern

2015-02-28 Thread Ian Lepore
Author: ian
Date: Sat Feb 28 17:32:31 2015
New Revision: 279395
URL: https://svnweb.freebsd.org/changeset/base/279395

Log:
  Export the new osreldate and osrelease jail parms in jail_get(2).

Modified:
  head/sys/kern/kern_jail.c

Modified: head/sys/kern/kern_jail.c
==
--- head/sys/kern/kern_jail.c   Sat Feb 28 15:21:06 2015(r279394)
+++ head/sys/kern/kern_jail.c   Sat Feb 28 17:32:31 2015(r279395)
@@ -2180,6 +2180,12 @@ kern_jail_get(struct thread *td, struct 
error = vfs_setopt(opts, "nodying", &i, sizeof(i));
if (error != 0 && error != ENOENT)
goto done_deref;
+   error = vfs_setopt(opts, "osreldate", &pr->pr_osreldate, 
sizeof(pr->pr_osreldate));
+   if (error != 0 && error != ENOENT)
+   goto done_deref;
+   error = vfs_setopts(opts, "osrelease", pr->pr_osrelease);
+   if (error != 0 && error != ENOENT)
+   goto done_deref;
 
/* Get the module parameters. */
mtx_unlock(&pr->pr_mtx);
___
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: r279361 - in head: sys/kern sys/sys usr.sbin/jail

2015-02-28 Thread Ian Lepore
On Fri, 2015-02-27 at 17:41 -0800, Garrett Cooper wrote:
> > On Feb 27, 2015, at 08:28, Ian Lepore  wrote:
> > 
> > Author: ian
> > Date: Fri Feb 27 16:28:55 2015
> > New Revision: 279361
> > URL: https://svnweb.freebsd.org/changeset/base/279361
> 
> This change broke the pgrep/pkill tests because the jail commands are 
> currently broken, with the message:
> 
> unknown parameter: osreldate
> 
> Please fix this ASAP.
> 
> https://jenkins.freebsd.org/job/FreeBSD_HEAD-tests2/780/
> 
> Thanks,

Should be fixed in r279395; sorry about that.

-- Ian


___
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: r279396 - head/sys/kern

2015-02-28 Thread Ian Lepore
Author: ian
Date: Sat Feb 28 17:44:31 2015
New Revision: 279396
URL: https://svnweb.freebsd.org/changeset/base/279396

Log:
  Format the line properly (wrap before column 80).

Modified:
  head/sys/kern/kern_jail.c

Modified: head/sys/kern/kern_jail.c
==
--- head/sys/kern/kern_jail.c   Sat Feb 28 17:32:31 2015(r279395)
+++ head/sys/kern/kern_jail.c   Sat Feb 28 17:44:31 2015(r279396)
@@ -2180,7 +2180,8 @@ kern_jail_get(struct thread *td, struct 
error = vfs_setopt(opts, "nodying", &i, sizeof(i));
if (error != 0 && error != ENOENT)
goto done_deref;
-   error = vfs_setopt(opts, "osreldate", &pr->pr_osreldate, 
sizeof(pr->pr_osreldate));
+   error = vfs_setopt(opts, "osreldate", &pr->pr_osreldate,
+   sizeof(pr->pr_osreldate));
if (error != 0 && error != ENOENT)
goto done_deref;
error = vfs_setopts(opts, "osrelease", pr->pr_osrelease);
___
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: r279397 - in head: contrib/netbsd-tests/lib/libc/gen lib/libc/gen

2015-02-28 Thread Jilles Tjoelker
Author: jilles
Date: Sat Feb 28 18:22:10 2015
New Revision: 279397
URL: https://svnweb.freebsd.org/changeset/base/279397

Log:
  nice(): Put back old return value, keeping [EPERM] error.
  
  Commit r279154 changed the API and ABI significantly, and {NZERO} is still
  wrong.
  
  Also, preserve errno on success instead of setting it to 0.
  
  PR:   189821
  Reported by:  bde
  Relnotes: yes

Modified:
  head/contrib/netbsd-tests/lib/libc/gen/t_nice.c
  head/lib/libc/gen/nice.3
  head/lib/libc/gen/nice.c

Modified: head/contrib/netbsd-tests/lib/libc/gen/t_nice.c
==
--- head/contrib/netbsd-tests/lib/libc/gen/t_nice.c Sat Feb 28 17:44:31 
2015(r279396)
+++ head/contrib/netbsd-tests/lib/libc/gen/t_nice.c Sat Feb 28 18:22:10 
2015(r279397)
@@ -93,7 +93,11 @@ ATF_TC_HEAD(nice_priority, tc)
 
 ATF_TC_BODY(nice_priority, tc)
 {
+#ifdef __FreeBSD__
+   int i, pri, pri2, nic;
+#else
int i, pri, nic;
+#endif
pid_t pid;
int sta;
 
@@ -106,8 +110,10 @@ ATF_TC_BODY(nice_priority, tc)
pri = getpriority(PRIO_PROCESS, 0);
ATF_REQUIRE(errno == 0);
 
+#ifdef __NetBSD__
if (nic != pri)
atf_tc_fail("nice(3) and getpriority(2) conflict");
+#endif
 
/*
 * Also verify that the nice(3) values
@@ -119,10 +125,18 @@ ATF_TC_BODY(nice_priority, tc)
if (pid == 0) {
 
errno = 0;
+#ifdef __FreeBSD__
pri = getpriority(PRIO_PROCESS, 0);
+#else
+   pri2 = getpriority(PRIO_PROCESS, 0);
+#endif
ATF_REQUIRE(errno == 0);
 
+#ifdef __FreeBSD__
+   if (pri != pri2)
+#else
if (nic != pri)
+#endif
_exit(EXIT_FAILURE);
 
_exit(EXIT_SUCCESS);
@@ -161,7 +175,11 @@ ATF_TC_HEAD(nice_thread, tc)
 ATF_TC_BODY(nice_thread, tc)
 {
pthread_t tid[5];
+#ifdef __FreeBSD__
+   int pri, rv, val;
+#else
int rv, val;
+#endif
size_t i;
 
/*
@@ -173,7 +191,12 @@ ATF_TC_BODY(nice_thread, tc)
val = nice(i);
ATF_REQUIRE(val != -1);
 
+#ifdef __FreeBSD__
+   pri = getpriority(PRIO_PROCESS, 0);
+   rv = pthread_create(&tid[i], NULL, threadfunc, &pri);
+#else
rv = pthread_create(&tid[i], NULL, threadfunc, &val);
+#endif
ATF_REQUIRE(rv == 0);
 
rv = pthread_join(tid[i], NULL);

Modified: head/lib/libc/gen/nice.3
==
--- head/lib/libc/gen/nice.3Sat Feb 28 17:44:31 2015(r279396)
+++ head/lib/libc/gen/nice.3Sat Feb 28 18:22:10 2015(r279397)
@@ -28,7 +28,7 @@
 .\" @(#)nice.3 8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd February 22, 2015
+.Dd February 28, 2015
 .Dt NICE 3
 .Os
 .Sh NAME
@@ -48,9 +48,9 @@ This interface is obsoleted by
 .Pp
 The
 .Fn nice
-function obtains the scheduling priority of the process
-from the system and sets it to the priority value specified in
-.Fa incr .
+function adds
+.Fa incr
+to the scheduling priority of the process.
 The priority is a value in the range -20 to 20.
 The default priority is 0; lower priorities cause more favorable scheduling.
 Only the super-user may lower priorities.
@@ -60,8 +60,9 @@ Children inherit the priority of their p
 .Sh RETURN VALUES
 Upon successful completion,
 .Fn nice
-returns the new nice value minus
-.Dv NZERO .
+returns 0, and
+.Va errno
+is unchanged.
 Otherwise, \-1 is returned, the process' nice value is not changed, and
 .Va errno
 is set to indicate the error.
@@ -84,7 +85,11 @@ argument is negative and the caller does
 The
 .Fn nice
 function conforms to
-.St -xpg4.2 .
+.St -p1003.1-2008
+except for the return value.
+This implementation returns 0 upon successful completion but 
+the standard requires returning the new nice value,
+which could be \-1.
 .Sh HISTORY
 A
 .Fn nice

Modified: head/lib/libc/gen/nice.c
==
--- head/lib/libc/gen/nice.cSat Feb 28 17:44:31 2015(r279396)
+++ head/lib/libc/gen/nice.cSat Feb 28 18:22:10 2015(r279397)
@@ -45,16 +45,18 @@ __FBSDID("$FreeBSD$");
 int
 nice(int incr)
 {
-   int prio;
+   int saverrno, prio;
 
+   saverrno = errno;
errno = 0;
prio = getpriority(PRIO_PROCESS, 0);
-   if (prio == -1 && errno)
-   return -1;
+   if (prio == -1 && errno != 0)
+   return (-1);
if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) {
if (errno == EACCES)
errno = EPERM;
-   return -1;
+   return (-1);
}
-   return getpriority(PRIO_PROCESS, 0);
+   er

svn commit: r279398 - in head/sys: dev/sfxge modules/sfxge

2015-02-28 Thread Andrew Rybchenko
Author: arybchik
Date: Sat Feb 28 19:01:43 2015
New Revision: 279398
URL: https://svnweb.freebsd.org/changeset/base/279398

Log:
  sfxge: compile out LRO if kernel is compiled without IPv4 and IPv6
  
  Sponsored by:   Solarflare Communications, Inc.
  Approved by:gnn (mentor)

Modified:
  head/sys/dev/sfxge/sfxge_rx.c
  head/sys/dev/sfxge/sfxge_rx.h
  head/sys/modules/sfxge/Makefile

Modified: head/sys/dev/sfxge/sfxge_rx.c
==
--- head/sys/dev/sfxge/sfxge_rx.c   Sat Feb 28 18:22:10 2015
(r279397)
+++ head/sys/dev/sfxge/sfxge_rx.c   Sat Feb 28 19:01:43 2015
(r279398)
@@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$");
 
 #defineRX_REFILL_THRESHOLD(_entries)   (EFX_RXQ_LIMIT(_entries) * 9 / 
10)
 
+#ifdef SFXGE_LRO
+
 /* Size of the LRO hash table.  Must be a power of 2.  A larger table
  * means we can accelerate a larger number of streams.
  */
@@ -107,6 +109,8 @@ static unsigned long ipv6_addr_cmp(const
 #endif
 }
 
+#endif /* SFXGE_LRO */
+
 void
 sfxge_rx_qflush_done(struct sfxge_rxq *rxq)
 {
@@ -315,6 +319,8 @@ sfxge_rx_deliver(struct sfxge_softc *sc,
rx_desc->mbuf = NULL;
 }
 
+#ifdef SFXGE_LRO
+
 static void
 sfxge_lro_deliver(struct sfxge_lro_state *st, struct sfxge_lro_conn *c)
 {
@@ -734,6 +740,20 @@ static void sfxge_lro_end_of_burst(struc
sfxge_lro_purge_idle(rxq, t);
 }
 
+#else  /* !SFXGE_LRO */
+
+static void
+sfxge_lro(struct sfxge_rxq *rxq, struct sfxge_rx_sw_desc *rx_buf)
+{
+}
+
+static void
+sfxge_lro_end_of_burst(struct sfxge_rxq *rxq)
+{
+}
+
+#endif /* SFXGE_LRO */
+
 void
 sfxge_rx_qcomplete(struct sfxge_rxq *rxq, boolean_t eop)
 {
@@ -1014,6 +1034,8 @@ fail:
return (rc);
 }
 
+#ifdef SFXGE_LRO
+
 static void sfxge_lro_init(struct sfxge_rxq *rxq)
 {
struct sfxge_lro_state *st = &rxq->lro;
@@ -1066,6 +1088,20 @@ static void sfxge_lro_fini(struct sfxge_
st->conns = NULL;
 }
 
+#else
+
+static void
+sfxge_lro_init(struct sfxge_rxq *rxq)
+{
+}
+
+static void
+sfxge_lro_fini(struct sfxge_rxq *rxq)
+{
+}
+
+#endif /* SFXGE_LRO */
+
 static void
 sfxge_rx_qfini(struct sfxge_softc *sc, unsigned int index)
 {
@@ -1136,6 +1172,7 @@ static const struct {
 } sfxge_rx_stats[] = {
 #defineSFXGE_RX_STAT(name, member) \
{ #name, offsetof(struct sfxge_rxq, member) }
+#ifdef SFXGE_LRO
SFXGE_RX_STAT(lro_merges, lro.n_merges),
SFXGE_RX_STAT(lro_bursts, lro.n_bursts),
SFXGE_RX_STAT(lro_slow_start, lro.n_slow_start),
@@ -1144,6 +1181,7 @@ static const struct {
SFXGE_RX_STAT(lro_new_stream, lro.n_new_stream),
SFXGE_RX_STAT(lro_drop_idle, lro.n_drop_idle),
SFXGE_RX_STAT(lro_drop_closed, lro.n_drop_closed)
+#endif
 };
 
 static int
@@ -1200,8 +1238,10 @@ sfxge_rx_init(struct sfxge_softc *sc)
int index;
int rc;
 
+#ifdef SFXGE_LRO
if (lro_idle_ticks == 0)
lro_idle_ticks = hz / 10 + 1; /* 100 ms */
+#endif
 
intr = &sc->intr;
 

Modified: head/sys/dev/sfxge/sfxge_rx.h
==
--- head/sys/dev/sfxge/sfxge_rx.h   Sat Feb 28 18:22:10 2015
(r279397)
+++ head/sys/dev/sfxge/sfxge_rx.h   Sat Feb 28 19:01:43 2015
(r279398)
@@ -32,6 +32,14 @@
 #ifndef _SFXGE_RX_H
 #define_SFXGE_RX_H
 
+#include "opt_inet.h"
+#include "opt_inet6.h"
+
+#if defined(INET) || defined(INET6)
+#error LRO
+#defineSFXGE_LRO   1
+#endif
+
 #defineSFXGE_MAGIC_RESERVED0x8000
 
 #defineSFXGE_MAGIC_DMAQ_LABEL_WIDTH6
@@ -59,6 +67,8 @@ struct sfxge_rx_sw_desc {
int size;
 };
 
+#ifdef SFXGE_LRO
+
 /**
  * struct sfxge_lro_conn - Connection state for software LRO
  * @link: Link for hash table and free list.
@@ -139,6 +149,8 @@ struct sfxge_lro_state {
unsigned n_drop_closed;
 };
 
+#endif /* SFXGE_LRO */
+
 enum sfxge_flush_state {
SFXGE_FLUSH_DONE = 0,
SFXGE_FLUSH_PENDING,
@@ -167,7 +179,9 @@ struct sfxge_rxq {
unsigned intpending;
unsigned intcompleted;
unsigned intloopback;
+#ifdef SFXGE_LRO
struct sfxge_lro_state  lro;
+#endif
unsigned intrefill_threshold;
struct callout  refill_callout;
unsigned intrefill_delay;

Modified: head/sys/modules/sfxge/Makefile
==
--- head/sys/modules/sfxge/Makefile Sat Feb 28 18:22:10 2015
(r279397)
+++ head/sys/modules/sfxge/Makefile Sat Feb 28 19:01:43 2015
(r279398)
@@ -5,7 +5,7 @@ KMOD=   sfxge
 SFXGE= ${.CURDIR}/../../dev/sfxge
 
 SRCS=  device_if.h bus_if.h pci_if.h
-SRCS+= opt_inet.h opt_sched.h
+SRCS+= opt_inet.h opt_inet6.h opt_sched.h
 
 .PATH: ${.CURDIR}/../../dev/sfxge
 SRCS+= sfxge.c sfxge_dma.c 

svn commit: r279399 - in head: share/man/man4 sys/conf sys/dev/iicbus

2015-02-28 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Feb 28 19:02:44 2015
New Revision: 279399
URL: https://svnweb.freebsd.org/changeset/base/279399

Log:
  Add a driver for the Maxim DS3231 a low-cost, extremely accurate (+-2PPM)
  I2C real-time clock (RTC).
  
  The DS3231 has an integrated temperature-compensated crystal oscillator
  (TXCO) and crystal.
  
  DS3231 has a temperature sensor, an independent 32kHz output (which can be
  turned on and off by the driver) and another output that can be used as
  interrupt for alarms or as a second square-wave output, which frequency and
  operation mode can be set by driver sysctl(8) knobs.
  
  Differential Revision:https://reviews.freebsd.org/D1016
  Reviewed by:  ian, rpaulo
  Tested on:Raspberry pi model B

Added:
  head/share/man/man4/ds3231.4   (contents, props changed)
  head/sys/dev/iicbus/ds3231.c   (contents, props changed)
  head/sys/dev/iicbus/ds3231reg.h   (contents, props changed)
Modified:
  head/sys/conf/files

Added: head/share/man/man4/ds3231.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/ds3231.4Sat Feb 28 19:02:44 2015
(r279399)
@@ -0,0 +1,145 @@
+.\"
+.\" Copyright (c) 2014 Luiz Otavio O Souza 
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd October 26, 2014
+.Dt DS3231 4
+.Os
+.Sh NAME
+.Nm ds3231
+.Nd Extremely Accurate i2c-integrated RTC/TCXO/Crystal
+.Sh SYNOPSIS
+.Cd "device iic"
+.Cd "device iicbus"
+.Cd "device ds3231"
+.Sh DESCRIPTION
+The
+.Nm
+is a low-cost, extremely accurate I2C realtime clock (RTC) with an
+integrated temperature-compensated crystal oscillator (TCXO) and crystal.
+.Pp
+The device incorporates a battery input and maintains accurate timekeeping
+when main power to the device is interrupted.
+.Pp
+Access to
+.Nm
+data is made with the
+.Xr sysctl 8
+interface:
+.Bd -literal
+dev.ds3231.0.%desc: Maxim DS3231 RTC
+dev.ds3231.0.%driver: ds3231
+dev.ds3231.0.%location: addr=0xd0
+dev.ds3231.0.%pnpinfo: name=rtc compat=maxim,ds3231
+dev.ds3231.0.%parent: iicbus1
+dev.ds3231.0.temperature: 23.2C
+dev.ds3231.0.temp_conv: 0
+dev.ds3231.0.bbsqw: 0
+dev.ds3231.0.sqw_freq: 8192
+dev.ds3231.0.sqw_mode: interrupt
+dev.ds3231.0.32khz_enable: 1
+.Ed
+.Bl -tag -width ".Va dev.ds3231.%d.temperature"
+.It Va dev.ds3231.%d.temperature
+The read-only value of the current temperature read by the RTC.
+.It Va dev.ds3231.%d.temp_conv
+Start a new temperature convertion.
+When read as 1, a temperature conversion is in progress.
+When read as 0 and then set to 1, a temperature convertion is started.
+The temperature conversion runs automatically on power up and once every 64
+seconds afterward.
+.It Va dev.ds3231.%d.bbsqw
+If set to 1 and
+.Va dev.ds3231.%d.sqw_mode
+is set to square-wave, battery-backed square-wave output is enabled.
+If set to 0, the SQW pin will be set to high impendance when the RTC is
+being powered by battery.
+.It Va dev.ds3231.%d.sqw_freq
+Select the frequency of the SQW pin when the square-wave output is enabled on
+.Va dev.ds3231.%d.sqw_mode .
+It can be set to 1, 1024, 4096, and 8192.
+.It Va dev.ds3231.%d.sqw_mode
+Set the operation mode for the SQW pin.
+It can be set to 'interrupt' (default) or 'square-wave'.
+In interrupt mode, the SQW pin is used to generate interrupts for the RTC
+alarms.
+In square-wave mode, the SQW pin drives a square-wave of
+.Va dev.ds3231.%d.sqw_freq
+frequency.
+.It Va dev.ds3231.%d.32khz_enable
+Enable the 32kHz output.
+.El
+.Pp
+Please check the
+.Nm
+datasheet for more details.
+.Pp
+On a
+.Xr device.hints 5
+based system, such as
+.Li MIPS ,
+these values are configurable for
+.N

svn commit: r279400 - head/sys/vm

2015-02-28 Thread Alan Cox
Author: alc
Date: Sat Feb 28 19:11:37 2015
New Revision: 279400
URL: https://svnweb.freebsd.org/changeset/base/279400

Log:
  Eliminate a variable that became unused when VFS_LOCK_GIANT() was
  eliminated.
  
  MFC after:3 days

Modified:
  head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_mmap.c
==
--- head/sys/vm/vm_mmap.c   Sat Feb 28 19:02:44 2015(r279399)
+++ head/sys/vm/vm_mmap.c   Sat Feb 28 19:11:37 2015(r279400)
@@ -1317,11 +1317,9 @@ vm_mmap_vnode(struct thread *td, vm_size
struct vattr va;
vm_object_t obj;
vm_offset_t foff;
-   struct mount *mp;
struct ucred *cred;
int error, flags, locktype;
 
-   mp = vp->v_mount;
cred = td->td_ucred;
if ((*maxprotp & VM_PROT_WRITE) && (*flagsp & MAP_SHARED))
locktype = LK_EXCLUSIVE;
___
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: r279401 - head/sys/fs/fdescfs

2015-02-28 Thread Konstantin Belousov
Author: kib
Date: Sat Feb 28 19:57:22 2015
New Revision: 279401
URL: https://svnweb.freebsd.org/changeset/base/279401

Log:
  Some fixes for fdescfs lookup code.
  
  Do not ever return doomed vnode from lookup.  This could happen, if
  not checked, since dvp is relocked in the 'looking up ourselves' case.
  
  In the other case, since dvp is relocked, mount point might go away
  while fdesc_allocvp() is called.  Prevent the situation by doing
  vfs_busy() before unlocking dvp.  Reuse the vn_vget_ino_gen() helper.
  
  Reported and tested by:   pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vnops.c

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==
--- head/sys/fs/fdescfs/fdesc_vnops.c   Sat Feb 28 19:11:37 2015
(r279400)
+++ head/sys/fs/fdescfs/fdesc_vnops.c   Sat Feb 28 19:57:22 2015
(r279401)
@@ -247,6 +247,28 @@ loop:
return (0);
 }
 
+struct fdesc_get_ino_args {
+   fdntype ftype;
+   unsigned fd_fd;
+   int ix;
+   struct file *fp;
+   struct thread *td;
+};
+
+static int
+fdesc_get_ino_alloc(struct mount *mp, void *arg, int lkflags,
+struct vnode **rvp)
+{
+   struct fdesc_get_ino_args *a;
+   int error;
+
+   a = arg;
+   error = fdesc_allocvp(a->ftype, a->fd_fd, a->ix, mp, rvp);
+   fdrop(a->fp, a->td);
+   return (error);
+}
+
+
 /*
  * vp is the current namei directory
  * ndp is the name to locate in that directory...
@@ -265,6 +287,7 @@ fdesc_lookup(ap)
char *pname = cnp->cn_nameptr;
struct thread *td = cnp->cn_thread;
struct file *fp;
+   struct fdesc_get_ino_args arg;
int nlen = cnp->cn_namelen;
u_int fd, fd1;
int error;
@@ -326,6 +349,8 @@ fdesc_lookup(ap)
vn_lock(dvp, LK_RETRY | LK_EXCLUSIVE);
vdrop(dvp);
fvp = dvp;
+   if ((dvp->v_iflag & VI_DOOMED) != 0)
+   error = ENOENT;
} else {
/*
 * Unlock our root node (dvp) when doing this, since we might
@@ -335,16 +360,13 @@ fdesc_lookup(ap)
 * opposite lock order. Vhold the root vnode first so we don't
 * lose it.
 */
-   vhold(dvp);
-   VOP_UNLOCK(dvp, 0);
-   error = fdesc_allocvp(Fdesc, fd, FD_DESC + fd, dvp->v_mount,
-   &fvp);
-   fdrop(fp, td);
-   /*
-* The root vnode must be locked last to prevent deadlock 
condition.
-*/
-   vn_lock(dvp, LK_RETRY | LK_EXCLUSIVE);
-   vdrop(dvp);
+   arg.ftype = Fdesc;
+   arg.fd_fd = fd;
+   arg.ix = FD_DESC + fd;
+   arg.fp = fp;
+   arg.td = td;
+   error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg,
+   LK_EXCLUSIVE, &fvp);
}

if (error)
___
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: r279402 - head/sys/dev/gpio

2015-02-28 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Feb 28 20:02:41 2015
New Revision: 279402
URL: https://svnweb.freebsd.org/changeset/base/279402

Log:
  Rename and move gpiobus_alloc_ivars() and gpiobus_free_ivars() so they can
  be used on non FDT systems.
  
  This prevents access to uninitialized memory on drivers that try to access
  pin flags on non FDT systems.

Modified:
  head/sys/dev/gpio/gpiobus.c
  head/sys/dev/gpio/gpiobusvar.h
  head/sys/dev/gpio/ofw_gpiobus.c

Modified: head/sys/dev/gpio/gpiobus.c
==
--- head/sys/dev/gpio/gpiobus.c Sat Feb 28 19:57:22 2015(r279401)
+++ head/sys/dev/gpio/gpiobus.c Sat Feb 28 20:02:41 2015(r279402)
@@ -195,6 +195,39 @@ gpiobus_init_softc(device_t dev)
return (0);
 }
 
+int
+gpiobus_alloc_ivars(struct gpiobus_ivar *devi)
+{
+
+   /* Allocate pins and flags memory. */
+   devi->pins = malloc(sizeof(uint32_t) * devi->npins, M_DEVBUF,
+   M_NOWAIT | M_ZERO);
+   if (devi->pins == NULL)
+   return (ENOMEM);
+   devi->flags = malloc(sizeof(uint32_t) * devi->npins, M_DEVBUF,
+   M_NOWAIT | M_ZERO);
+   if (devi->flags == NULL) {
+   free(devi->pins, M_DEVBUF);
+   return (ENOMEM);
+   }
+
+   return (0);
+}
+
+void
+gpiobus_free_ivars(struct gpiobus_ivar *devi)
+{
+
+   if (devi->flags) {
+   free(devi->flags, M_DEVBUF);
+   devi->flags = NULL;
+   }
+   if (devi->pins) {
+   free(devi->pins, M_DEVBUF);
+   devi->pins = NULL;
+   }
+}
+
 static int
 gpiobus_parse_pins(struct gpiobus_softc *sc, device_t child, int mask)
 {
@@ -206,29 +239,23 @@ gpiobus_parse_pins(struct gpiobus_softc 
if (mask & (1 << i))
npins++;
}
-
if (npins == 0) {
device_printf(child, "empty pin mask\n");
return (EINVAL);
}
-
devi->npins = npins;
-   devi->pins = malloc(sizeof(uint32_t) * devi->npins, M_DEVBUF, 
-   M_NOWAIT | M_ZERO);
-
-   if (!devi->pins)
-   return (ENOMEM);
-
+   if (gpiobus_alloc_ivars(devi) != 0) {
+   device_printf(child, "cannot allocate device ivars\n");
+   return (EINVAL);
+   }
npins = 0;
for (i = 0; i < 32; i++) {
-
if ((mask & (1 << i)) == 0)
continue;
-
if (i >= sc->sc_npins) {
device_printf(child, 
"invalid pin %d, max: %d\n", i, sc->sc_npins - 1);
-   free(devi->pins, M_DEVBUF);
+   gpiobus_free_ivars(devi);
return (EINVAL);
}
 
@@ -239,7 +266,7 @@ gpiobus_parse_pins(struct gpiobus_softc 
if (sc->sc_pins_mapped[i]) {
device_printf(child, 
"warning: pin %d is already mapped\n", i);
-   free(devi->pins, M_DEVBUF);
+   gpiobus_free_ivars(devi);
return (EINVAL);
}
sc->sc_pins_mapped[i] = 1;
@@ -299,10 +326,7 @@ gpiobus_detach(device_t dev)
for (i = 0; i < ndevs; i++) {
device_delete_child(dev, devlist[i]);
devi = GPIOBUS_IVAR(devlist[i]);
-   if (devi->pins) {
-   free(devi->pins, M_DEVBUF);
-   devi->pins = NULL;
-   }
+   gpiobus_free_ivars(devi);
}
free(devlist, M_TEMP);
 

Modified: head/sys/dev/gpio/gpiobusvar.h
==
--- head/sys/dev/gpio/gpiobusvar.h  Sat Feb 28 19:57:22 2015
(r279401)
+++ head/sys/dev/gpio/gpiobusvar.h  Sat Feb 28 20:02:41 2015
(r279402)
@@ -100,6 +100,8 @@ int gpio_check_flags(uint32_t, uint32_t)
 device_t gpiobus_attach_bus(device_t);
 int gpiobus_detach_bus(device_t);
 int gpiobus_init_softc(device_t);
+int gpiobus_alloc_ivars(struct gpiobus_ivar *);
+void gpiobus_free_ivars(struct gpiobus_ivar *);
 
 extern driver_t gpiobus_driver;
 

Modified: head/sys/dev/gpio/ofw_gpiobus.c
==
--- head/sys/dev/gpio/ofw_gpiobus.c Sat Feb 28 19:57:22 2015
(r279401)
+++ head/sys/dev/gpio/ofw_gpiobus.c Sat Feb 28 20:02:41 2015
(r279402)
@@ -70,33 +70,6 @@ ofw_gpiobus_add_fdt_child(device_t bus, 
 }
 
 static int
-ofw_gpiobus_alloc_ivars(struct gpiobus_ivar *dinfo)
-{
-
-   /* Allocate pins and flags memory. */
-   dinfo->pins = malloc(sizeof(uint32_t) * dinfo->npins, M_DEVBUF,
-   M_NOWAIT | M_ZERO);
-   if (dinfo->pins == NULL)
-   return (ENOMEM);
-   dinfo->flags = malloc(sizeof(uint32_t) * dinfo->npins, M_DEVBUF,
-   M_NOWAIT | M_ZERO);
-   if (din

svn commit: r279404 - head/lib/libc/iconv

2015-02-28 Thread Alexander Kabaev
Author: kan
Date: Sat Feb 28 20:30:25 2015
New Revision: 279404
URL: https://svnweb.freebsd.org/changeset/base/279404

Log:
  Avoid lookup of CODESET aliases using uninitialized path
  
  We do not use iconv.alias file, so avoid using the vestiges
  of the code that do.
  
  Differential Revision:https://reviews.freebsd.org/D1729
  Reviewed by: emaste
  MFC after: 2 weeks

Modified:
  head/lib/libc/iconv/citrus_iconv.c

Modified: head/lib/libc/iconv/citrus_iconv.c
==
--- head/lib/libc/iconv/citrus_iconv.c  Sat Feb 28 20:03:52 2015
(r279403)
+++ head/lib/libc/iconv/citrus_iconv.c  Sat Feb 28 20:30:25 2015
(r279404)
@@ -278,7 +278,9 @@ _citrus_iconv_open(struct _citrus_iconv 
struct _citrus_iconv *cv = NULL;
struct _citrus_iconv_shared *ci = NULL;
char realdst[PATH_MAX], realsrc[PATH_MAX];
+#ifdef _PATH_ICONV
char buf[PATH_MAX], path[PATH_MAX];
+#endif
int ret;
 
init_cache();
@@ -290,10 +292,16 @@ _citrus_iconv_open(struct _citrus_iconv 
dst = nl_langinfo(CODESET);
 
/* resolve codeset name aliases */
+#ifdef _PATH_ICONV
+   snprintf(path, sizeof(path), "%s/%s", _PATH_ICONV, _CITRUS_ICONV_ALIAS);
strlcpy(realsrc, _lookup_alias(path, src, buf, (size_t)PATH_MAX,
_LOOKUP_CASE_IGNORE), (size_t)PATH_MAX);
strlcpy(realdst, _lookup_alias(path, dst, buf, (size_t)PATH_MAX,
_LOOKUP_CASE_IGNORE), (size_t)PATH_MAX);
+#else
+   strlcpy(realsrc, src, (size_t)PATH_MAX);
+   strlcpy(realdst, dst, (size_t)PATH_MAX);
+#endif
 
/* sanity check */
if (strchr(realsrc, '/') != NULL || strchr(realdst, '/'))
___
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: r279405 - head/sys/nfs

2015-02-28 Thread Alexander Kabaev
Author: kan
Date: Sat Feb 28 20:30:29 2015
New Revision: 279405
URL: https://svnweb.freebsd.org/changeset/base/279405

Log:
  Avoid closing unallocated socket in case socreate fails.
  
  Found by: Brainy Code Scanner
  Reported by: Maxime Villard 
  MFC after: 2 weeks

Modified:
  head/sys/nfs/krpc_subr.c

Modified: head/sys/nfs/krpc_subr.c
==
--- head/sys/nfs/krpc_subr.cSat Feb 28 20:30:25 2015(r279404)
+++ head/sys/nfs/krpc_subr.cSat Feb 28 20:30:29 2015(r279405)
@@ -220,7 +220,7 @@ krpc_call(struct sockaddr_in *sa, u_int 
 * Create socket and set its recieve timeout.
 */
if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0, td->td_ucred, td)))
-   goto out;
+   return error;
 
tv.tv_sec = 1;
tv.tv_usec = 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: r279406 - in head/sys: amd64/amd64 i386/i386

2015-02-28 Thread Konstantin Belousov
Author: kib
Date: Sat Feb 28 20:37:38 2015
New Revision: 279406
URL: https://svnweb.freebsd.org/changeset/base/279406

Log:
  Supposed fix for some SandyBridge mobile CPUs hang on AP startup when
  x2APIC mode is detected and enabled.  Current theory is that switching
  the APIC mode while an IPI is in flight might be the issue.
  
  Postpone switching to x2APIC mode until we are guaranteed that all
  starting IPIs are already send and aknowledged.  Use aps_ready signal
  as an indication that the BSP is done with us.
  
  Tested by:adrian
  Sponsored by: The FreeBSD Foundation
  MFC after:2 months

Modified:
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/i386/i386/mp_machdep.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Sat Feb 28 20:30:29 2015
(r279405)
+++ head/sys/amd64/amd64/mp_machdep.c   Sat Feb 28 20:37:38 2015
(r279406)
@@ -705,12 +705,6 @@ init_secondary(void)
wrmsr(MSR_STAR, msr);
wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
 
-   /*
-* On real hardware, switch to x2apic mode if possible.
-* Disable local APIC until BSP directed APs to run.
-*/
-   lapic_xapic_mode();
-
/* signal our startup to the BSP. */
mp_naps++;
 
@@ -718,6 +712,14 @@ init_secondary(void)
while (!aps_ready)
ia32_pause();
 
+   /*
+* On real hardware, switch to x2apic mode if possible.  Do it
+* after aps_ready was signalled, to avoid manipulating the
+* mode while BSP might still want to send some IPI to us
+* (second startup IPI is ignored on modern hardware etc).
+*/
+   lapic_xapic_mode();
+
/* Initialize the PAT MSR. */
pmap_init_pat();
 

Modified: head/sys/i386/i386/mp_machdep.c
==
--- head/sys/i386/i386/mp_machdep.c Sat Feb 28 20:30:29 2015
(r279405)
+++ head/sys/i386/i386/mp_machdep.c Sat Feb 28 20:37:38 2015
(r279406)
@@ -719,12 +719,6 @@ init_secondary(void)
load_cr0(cr0);
CHECK_WRITE(0x38, 5);

-   /*
-* On real hardware, switch to x2apic mode if possible.
-* Disable local APIC until BSP directed APs to run.
-*/
-   lapic_xapic_mode();
-
/* signal our startup to the BSP. */
mp_naps++;
CHECK_WRITE(0x39, 6);
@@ -742,6 +736,14 @@ init_secondary(void)
lidt(&r_idt);
 #endif
 
+   /*
+* On real hardware, switch to x2apic mode if possible.  Do it
+* after aps_ready was signalled, to avoid manipulating the
+* mode while BSP might still want to send some IPI to us
+* (second startup IPI is ignored on modern hardware etc).
+*/
+   lapic_xapic_mode();
+
/* Initialize the PAT MSR if present. */
pmap_init_pat();
 
___
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: r279408 - head/sys/dev/gpio

2015-02-28 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Feb 28 21:01:01 2015
New Revision: 279408
URL: https://svnweb.freebsd.org/changeset/base/279408

Log:
  Add ofw_gpiobus_parse_gpios(), a new public function, to parse the gpios
  property for devices that doesn't descend directly from gpiobus.
  
  The parser supports multiple pins, different GPIO controllers and can use
  arbitrary names for the property (to match the many linux variants:
  cd-gpios, power-gpios, wp-gpios, etc.).
  
  Pass the driver name on ofw_gpiobus_add_fdt_child().  Update gpioled to
  match.
  
  An usage example of ofw_gpiobus_parse_gpios() will follow soon.

Modified:
  head/sys/dev/gpio/gpiobusvar.h
  head/sys/dev/gpio/gpioled.c
  head/sys/dev/gpio/ofw_gpiobus.c

Modified: head/sys/dev/gpio/gpiobusvar.h
==
--- head/sys/dev/gpio/gpiobusvar.h  Sat Feb 28 20:57:03 2015
(r279407)
+++ head/sys/dev/gpio/gpiobusvar.h  Sat Feb 28 21:01:01 2015
(r279408)
@@ -71,6 +71,13 @@ struct gpiobus_softc
int *sc_pins_mapped; /* mark mapped pins */
 };
 
+struct gpiobus_pin
+{
+   device_tdev;/* gpio device */
+   uint32_tflags;  /* pin flags */
+   uint32_tpin;/* pin number */
+};
+
 struct gpiobus_ivar
 {
struct resource_listrl; /* isr resource list */
@@ -92,7 +99,8 @@ gpio_map_gpios(device_t bus, phandle_t d
return (GPIO_MAP_GPIOS(bus, dev, gparent, gcells, gpios, pin, flags));
 }
 
-device_t ofw_gpiobus_add_fdt_child(device_t, phandle_t);
+device_t ofw_gpiobus_add_fdt_child(device_t, const char *, phandle_t);
+int ofw_gpiobus_parse_gpios(device_t, char *, struct gpiobus_pin **);
 void ofw_gpiobus_register_provider(device_t);
 void ofw_gpiobus_unregister_provider(device_t);
 #endif

Modified: head/sys/dev/gpio/gpioled.c
==
--- head/sys/dev/gpio/gpioled.c Sat Feb 28 20:57:03 2015(r279407)
+++ head/sys/dev/gpio/gpioled.c Sat Feb 28 21:01:01 2015(r279408)
@@ -109,11 +109,13 @@ gpioled_identify(driver_t *driver, devic
leds = fdt_find_compatible(root, "gpio-leds", 1);
if (leds == 0)
return;
-
/* Traverse the 'gpio-leds' node and add its children. */
-   for (child = OF_child(leds); child != 0; child = OF_peer(child))
-   if (ofw_gpiobus_add_fdt_child(bus, child) == NULL)
+   for (child = OF_child(leds); child != 0; child = OF_peer(child)) {
+   if (!OF_hasprop(child, "gpios"))
+   continue;
+   if (ofw_gpiobus_add_fdt_child(bus, driver->name, child) == NULL)
continue;
+   }
 }
 #endif
 

Modified: head/sys/dev/gpio/ofw_gpiobus.c
==
--- head/sys/dev/gpio/ofw_gpiobus.c Sat Feb 28 20:57:03 2015
(r279407)
+++ head/sys/dev/gpio/ofw_gpiobus.c Sat Feb 28 21:01:01 2015
(r279408)
@@ -39,155 +39,45 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-static int ofw_gpiobus_parse_gpios(struct gpiobus_softc *,
-struct gpiobus_ivar *, phandle_t);
 static struct ofw_gpiobus_devinfo *ofw_gpiobus_setup_devinfo(device_t,
-phandle_t);
+   device_t, phandle_t);
 static void ofw_gpiobus_destroy_devinfo(struct ofw_gpiobus_devinfo *);
+static int ofw_gpiobus_parse_gpios_impl(device_t, phandle_t, char *,
+   struct gpiobus_softc *, struct gpiobus_pin **);
 
 device_t
-ofw_gpiobus_add_fdt_child(device_t bus, phandle_t child)
+ofw_gpiobus_add_fdt_child(device_t bus, const char *drvname, phandle_t child)
 {
-   struct ofw_gpiobus_devinfo *dinfo;
device_t childdev;
+   struct ofw_gpiobus_devinfo *dinfo;
 
/*
 * Set up the GPIO child and OFW bus layer devinfo and add it to bus.
 */
-   dinfo = ofw_gpiobus_setup_devinfo(bus, child);
-   if (dinfo == NULL)
+   childdev = device_add_child(bus, drvname, -1);
+   if (childdev == NULL)
+   return (NULL);
+   dinfo = ofw_gpiobus_setup_devinfo(bus, childdev, child);
+   if (dinfo == NULL) {
+   device_delete_child(bus, childdev);
return (NULL);
-   childdev = device_add_child(bus, NULL, -1);
-   if (childdev == NULL) {
-   device_printf(bus, "could not add child: %s\n",
-   dinfo->opd_obdinfo.obd_name);
+   }
+   if (device_probe_and_attach(childdev) != 0) {
ofw_gpiobus_destroy_devinfo(dinfo);
+   device_delete_child(bus, childdev);
return (NULL);
}
-   device_set_ivars(childdev, dinfo);
 
return (childdev);
 }
 
-static int
-ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo,
-   phandle_t child)
+int
+ofw_gpiobus_parse_gpios(device_t consumer, char *pname,
+   struct gpiobus_pin **pins)
 {
-   int cel

Re: svn commit: r279398 - in head/sys: dev/sfxge modules/sfxge

2015-02-28 Thread Ryan Stone
On Sat, Feb 28, 2015 at 2:01 PM, Andrew Rybchenko  wrote:
> +#if defined(INET) || defined(INET6)
> +#error LRO
> +#defineSFXGE_LRO   1
> +#endif

Pretty sure you didn't mean the leave the #error in here
___
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: r279410 - head/sys/kern

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sat Feb 28 21:49:59 2015
New Revision: 279410
URL: https://svnweb.freebsd.org/changeset/base/279410

Log:
  Correct the use of an unitialized variable in sendfind_getobj()
  
  When sendfile_getobj() is called on a DTYPE_SHM file, it never
  initializes error, which is eventually returned to the caller.
  
  Differential Revision:https://reviews.freebsd.org/D1989
  Reviewed by:  kib
  Reported by:  Brainy Code Scanner, by Maxime Villard.

Modified:
  head/sys/kern/uipc_syscalls.c

Modified: head/sys/kern/uipc_syscalls.c
==
--- head/sys/kern/uipc_syscalls.c   Sat Feb 28 21:20:46 2015
(r279409)
+++ head/sys/kern/uipc_syscalls.c   Sat Feb 28 21:49:59 2015
(r279410)
@@ -2108,6 +2108,7 @@ sendfile_getobj(struct thread *td, struc
goto out;
}
} else if (fp->f_type == DTYPE_SHM) {
+   error = 0;
shmfd = fp->f_data;
obj = shmfd->shm_object;
*obj_size = shmfd->shm_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"


svn commit: r279411 - head/sys/dev/sfxge

2015-02-28 Thread Garrett Cooper
Author: ngie
Date: Sat Feb 28 21:50:04 2015
New Revision: 279411
URL: https://svnweb.freebsd.org/changeset/base/279411

Log:
  Unbreak 'make depend' with sfxge by removing debugging code activated in the
  INET || INET6 case
  
  X-MFC with: r279398
  Pointyhat to: arybchik

Modified:
  head/sys/dev/sfxge/sfxge_rx.h

Modified: head/sys/dev/sfxge/sfxge_rx.h
==
--- head/sys/dev/sfxge/sfxge_rx.h   Sat Feb 28 21:49:59 2015
(r279410)
+++ head/sys/dev/sfxge/sfxge_rx.h   Sat Feb 28 21:50:04 2015
(r279411)
@@ -36,7 +36,6 @@
 #include "opt_inet6.h"
 
 #if defined(INET) || defined(INET6)
-#error LRO
 #defineSFXGE_LRO   1
 #endif
 
___
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: r279398 - in head/sys: dev/sfxge modules/sfxge

2015-02-28 Thread Garrett Cooper
On Feb 28, 2015, at 13:48, Ryan Stone  wrote:

> On Sat, Feb 28, 2015 at 2:01 PM, Andrew Rybchenko  
> wrote:
>> +#if defined(INET) || defined(INET6)
>> +#error LRO
>> +#defineSFXGE_LRO   1
>> +#endif
> 
> Pretty sure you didn't mean the leave the #error in here

Fixed in r279411.


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r279406 - in head/sys: amd64/amd64 i386/i386

2015-02-28 Thread Adrian Chadd
Thanks for promptly finding/fixing this!

For the record, the CPU I have in this zenbook:

CPU: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz (1596.41-MHz K8-class CPU)



On 28 February 2015 at 12:37, Konstantin Belousov  wrote:
> Author: kib
> Date: Sat Feb 28 20:37:38 2015
> New Revision: 279406
> URL: https://svnweb.freebsd.org/changeset/base/279406
>
> Log:
>   Supposed fix for some SandyBridge mobile CPUs hang on AP startup when
>   x2APIC mode is detected and enabled.  Current theory is that switching
>   the APIC mode while an IPI is in flight might be the issue.
>
>   Postpone switching to x2APIC mode until we are guaranteed that all
>   starting IPIs are already send and aknowledged.  Use aps_ready signal
>   as an indication that the BSP is done with us.
>
>   Tested by:adrian
>   Sponsored by: The FreeBSD Foundation
>   MFC after:2 months
>
> Modified:
>   head/sys/amd64/amd64/mp_machdep.c
>   head/sys/i386/i386/mp_machdep.c
>
> Modified: head/sys/amd64/amd64/mp_machdep.c
> ==
> --- head/sys/amd64/amd64/mp_machdep.c   Sat Feb 28 20:30:29 2015
> (r279405)
> +++ head/sys/amd64/amd64/mp_machdep.c   Sat Feb 28 20:37:38 2015
> (r279406)
> @@ -705,12 +705,6 @@ init_secondary(void)
> wrmsr(MSR_STAR, msr);
> wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
>
> -   /*
> -* On real hardware, switch to x2apic mode if possible.
> -* Disable local APIC until BSP directed APs to run.
> -*/
> -   lapic_xapic_mode();
> -
> /* signal our startup to the BSP. */
> mp_naps++;
>
> @@ -718,6 +712,14 @@ init_secondary(void)
> while (!aps_ready)
> ia32_pause();
>
> +   /*
> +* On real hardware, switch to x2apic mode if possible.  Do it
> +* after aps_ready was signalled, to avoid manipulating the
> +* mode while BSP might still want to send some IPI to us
> +* (second startup IPI is ignored on modern hardware etc).
> +*/
> +   lapic_xapic_mode();
> +
> /* Initialize the PAT MSR. */
> pmap_init_pat();
>
>
> Modified: head/sys/i386/i386/mp_machdep.c
> ==
> --- head/sys/i386/i386/mp_machdep.c Sat Feb 28 20:30:29 2015
> (r279405)
> +++ head/sys/i386/i386/mp_machdep.c Sat Feb 28 20:37:38 2015
> (r279406)
> @@ -719,12 +719,6 @@ init_secondary(void)
> load_cr0(cr0);
> CHECK_WRITE(0x38, 5);
>
> -   /*
> -* On real hardware, switch to x2apic mode if possible.
> -* Disable local APIC until BSP directed APs to run.
> -*/
> -   lapic_xapic_mode();
> -
> /* signal our startup to the BSP. */
> mp_naps++;
> CHECK_WRITE(0x39, 6);
> @@ -742,6 +736,14 @@ init_secondary(void)
> lidt(&r_idt);
>  #endif
>
> +   /*
> +* On real hardware, switch to x2apic mode if possible.  Do it
> +* after aps_ready was signalled, to avoid manipulating the
> +* mode while BSP might still want to send some IPI to us
> +* (second startup IPI is ignored on modern hardware etc).
> +*/
> +   lapic_xapic_mode();
> +
> /* Initialize the PAT MSR if present. */
> pmap_init_pat();
>
>
___
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: r279412 - head/sys/fs/nandfs

2015-02-28 Thread Alexander Kabaev
Author: kan
Date: Sat Feb 28 22:24:45 2015
New Revision: 279412
URL: https://svnweb.freebsd.org/changeset/base/279412

Log:
  Do not leak 'copy' buffer if bmap_truncate_indirect fails.
  
  Reported by: Brainy Code Scanner, by Maxime Villard.
  MFC after: 2 weeks

Modified:
  head/sys/fs/nandfs/bmap.c

Modified: head/sys/fs/nandfs/bmap.c
==
--- head/sys/fs/nandfs/bmap.c   Sat Feb 28 21:50:04 2015(r279411)
+++ head/sys/fs/nandfs/bmap.c   Sat Feb 28 22:24:45 2015(r279412)
@@ -460,6 +460,7 @@ bmap_truncate_mapping(struct nandfs_node
error = bmap_truncate_indirect(node, level, &left,
&cleaned, ap, f, copy);
if (error) {
+   free(copy, M_NANDFSTEMP);
nandfs_error("%s: error %d when truncate "
"at level %d\n", __func__, error, level);
return (error);
___
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: r279413 - head/sys/dev/watchdog

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sat Feb 28 22:37:48 2015
New Revision: 279413
URL: https://svnweb.freebsd.org/changeset/base/279413

Log:
  Add a missing include of an options header.
  
  watchdog.c does an #ifdef DDB but does not #include "opt_ddb.h".
  Fixing this turned up a missing include file.
  
  MFC after:1 week
  X-MFC-With:   r261495, r279410

Modified:
  head/sys/dev/watchdog/watchdog.c

Modified: head/sys/dev/watchdog/watchdog.c
==
--- head/sys/dev/watchdog/watchdog.cSat Feb 28 22:24:45 2015
(r279412)
+++ head/sys/dev/watchdog/watchdog.cSat Feb 28 22:37:48 2015
(r279413)
@@ -28,6 +28,8 @@
  *
  */
 
+#include "opt_ddb.h"
+
 #include 
 __FBSDID("$FreeBSD$");
 
@@ -37,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
___
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: r279414 - head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt

2015-02-28 Thread Mark Johnston
Author: markj
Date: Sat Feb 28 23:09:01 2015
New Revision: 279414
URL: https://svnweb.freebsd.org/changeset/base/279414

Log:
  Stop hard-coding an incorrect path to rm(1).
  
  MFC after:1 week

Modified:
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noprobes.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh 
Sat Feb 28 22:37:48 2015(r279413)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh 
Sat Feb 28 23:09:01 2015(r279414)
@@ -102,5 +102,5 @@ if [ $? -ne 0 ]; then
 fi
 
 cd /
-/usr/bin/rm -rf $DIR
+rm -rf $DIR
 exit 0

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noprobes.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noprobes.ksh  
Sat Feb 28 22:37:48 2015(r279413)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noprobes.ksh  
Sat Feb 28 23:09:01 2015(r279414)
@@ -55,5 +55,5 @@ if [ $? -eq 0 ]; then
 fi
 
 cd /
-/usr/bin/rm -rf $DIR
+rm -rf $DIR
 exit 0

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh
Sat Feb 28 22:37:48 2015(r279413)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreap.ksh
Sat Feb 28 23:09:01 2015(r279414)
@@ -123,6 +123,6 @@ else
 fi
 
 cd /
-/usr/bin/rm -rf $DIR
+rm -rf $DIR
 
 exit $status

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh
Sat Feb 28 22:37:48 2015(r279413)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.noreapring.ksh
Sat Feb 28 23:09:01 2015(r279414)
@@ -119,6 +119,6 @@ fi
 
 kill $background
 cd /
-/usr/bin/rm -rf $DIR
+rm -rf $DIR
 
 exit $status

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh
==
--- head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh  
Sat Feb 28 22:37:48 2015(r279413)
+++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.reap.ksh  
Sat Feb 28 23:09:01 2015(r279414)
@@ -110,6 +110,6 @@ grep D_PDESC_INVAL test.out 2> /dev/null
 status=$?
 
 cd /
-/usr/bin/rm -rf $DIR
+rm -rf $DIR
 
 exit $status
___
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: r279415 - head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid

2015-02-28 Thread Mark Johnston
Author: markj
Date: Sat Feb 28 23:10:26 2015
New Revision: 279415
URL: https://svnweb.freebsd.org/changeset/base/279415

Log:
  Only kill sleep processes that were forked from the test script.
  
  MFC after:1 week

Modified:
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh   
Sat Feb 28 23:09:01 2015(r279414)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.manypids.ksh   
Sat Feb 28 23:10:26 2015(r279415)
@@ -66,5 +66,5 @@ $dtrace -s $tmpfile
 status=$?
 
 rm $tmpfile
-pkill sleep
+pkill -P $$ sleep
 exit $status
___
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: r279416 - head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid

2015-02-28 Thread Mark Johnston
Author: markj
Date: Sat Feb 28 23:11:18 2015
New Revision: 279416
URL: https://svnweb.freebsd.org/changeset/base/279416

Log:
  Remove a leading tab that causes a make(1) error when running the test.
  
  MFC after:1 week

Modified:
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh 
Sat Feb 28 23:10:26 2015(r279415)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh 
Sat Feb 28 23:11:18 2015(r279416)
@@ -44,7 +44,7 @@ mkdir $DIR
 cd $DIR
 
 cat > Makefile 

svn commit: r279417 - in head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common: pid usdt

2015-02-28 Thread Mark Johnston
Author: markj
Date: Sat Feb 28 23:14:35 2015
New Revision: 279417
URL: https://svnweb.freebsd.org/changeset/base/279417

Log:
  Use the -shared option to create a shared library.
  
  MFC after:1 week

Modified:
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh 
Sat Feb 28 23:11:18 2015(r279416)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex2.ksh 
Sat Feb 28 23:14:35 2015(r279417)
@@ -52,7 +52,7 @@ main.o: main.c
cc -c main.c
 
 altlib.so: altlib.o
-   cc -z defs -G -o altlib.so altlib.o -lc
+   cc -shared -o altlib.so altlib.o -lc
 
 altlib.o: altlib.c
cc -c altlib.c

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh 
Sat Feb 28 23:11:18 2015(r279416)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.provregex4.ksh 
Sat Feb 28 23:14:35 2015(r279417)
@@ -59,7 +59,7 @@ provmain.o: prov.d main.o
$dtrace -G -32 -o provmain.o -s prov.d main.o
 
 altlib.so: altlib.o provalt.o
-   cc -z defs -G -o altlib.so altlib.o provalt.o -lc
+   cc -shared -o altlib.so altlib.o provalt.o -lc
 
 altlib.o: altlib.c prov.h
cc -c altlib.c

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh  
Sat Feb 28 23:11:18 2015(r279416)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh  
Sat Feb 28 23:14:35 2015(r279417)
@@ -53,7 +53,7 @@ main.o: main.c
 
 
 livelib.so: livelib.o prov.o
-   cc -z defs -G -o livelib.so livelib.o prov.o -lc
+   cc -shared -o livelib.so livelib.o prov.o -lc
 
 livelib.o: livelib.c prov.h
cc -c livelib.c
@@ -66,7 +66,7 @@ prov.h: prov.d
 
 
 deadlib.so: deadlib.o
-   cc -z defs -G -o deadlib.so deadlib.o -lc
+   cc -shared -o deadlib.so deadlib.o -lc
 
 deadlib.o: deadlib.c
cc -c deadlib.c

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh  
Sat Feb 28 23:11:18 2015(r279416)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh  
Sat Feb 28 23:14:35 2015(r279417)
@@ -48,7 +48,7 @@ main.o: main.c
 
 
 livelib.so: livelib.o prov.o
-   cc -z defs -G -o livelib.so livelib.o prov.o -lc
+   cc -shared -o livelib.so livelib.o prov.o -lc
 
 livelib.o: livelib.c prov.h
cc -c livelib.c
@@ -61,7 +61,7 @@ prov.h: prov.d
 
 
 deadlib.so: deadlib.o
-   cc -z defs -G -o deadlib.so deadlib.o -lc
+   cc -shared -o deadlib.so deadlib.o -lc
 
 deadlib.o: deadlib.c
cc -c deadlib.c

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh  
Sat Feb 28 23:11:18 2015(r279416)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh  
Sat Feb 28 23:14:35 2015(r279417)
@@ -53,7 +53,7 @@ main.o: main.c
 
 
 livelib.so: livelib.o prov.o
-   cc -z defs -G -o livelib.so livelib.o prov.o -lc
+   cc -shared -o livelib.so livelib.o prov.o -lc
 
 livelib.o: livelib.c prov.h
cc -c livelib.c
@@ -66,7 +66,7 @@ prov.h: prov.d
 
 
 deadlib.so: deadlib.o
-   cc -z defs -G -o deadlib.so deadlib.o -lc
+   cc -shared -o deadlib.so deadlib.o -lc
 
 deadlib.o: deadlib.c
cc -c deadlib.c
___
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: r279418 - in head: cddl/usr.sbin/dtrace/tests cddl/usr.sbin/dtrace/tests/common cddl/usr.sbin/dtrace/tests/common/aggs cddl/usr.sbin/dtrace/tests/common/arithmetic cddl/usr.sbin/dtrace/...

2015-02-28 Thread Mark Johnston
Author: markj
Date: Sat Feb 28 23:30:06 2015
New Revision: 279418
URL: https://svnweb.freebsd.org/changeset/base/279418

Log:
  Add infrastructure to integrate the DTrace test suite with Kyua.
  
  For each test category, we generate a script containing ATF test cases for
  the tests under that category. Each test case simply runs dtest.pl (the
  upstream test harness) with the corresponding test files. The exclude.sh
  script is used to record info about tests which should be skipped or are
  expected to fail; it is used to generate atf_skip and atf_expect_fail calls.
  The genmakefiles.sh script can be used to regenerate the test makefiles when
  new tests are brought it from upstream.
  
  The test suite is currently not connected to the build as there is a small
  number of lingering test issues which still need to be worked out. In the
  meantime however, the test suite can be easily built and installed
  manually from cddl/usr.sbin/dtrace/tests.
  
  Reviewed by:  ngie
  Sponsored by: EMC / Isilon Storage Division

Added:
  head/cddl/usr.sbin/dtrace/tests/
  head/cddl/usr.sbin/dtrace/tests/Makefile   (contents, props changed)
  head/cddl/usr.sbin/dtrace/tests/Makefile.inc1   (contents, props changed)
  head/cddl/usr.sbin/dtrace/tests/common/
  head/cddl/usr.sbin/dtrace/tests/common/Makefile   (contents, props changed)
  head/cddl/usr.sbin/dtrace/tests/common/aggs/
  head/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/arithmetic/
  head/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/arrays/
  head/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/assocs/
  head/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/begin/
  head/cddl/usr.sbin/dtrace/tests/common/begin/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/bitfields/
  head/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/buffering/
  head/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/builtinvar/
  head/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/cg/
  head/cddl/usr.sbin/dtrace/tests/common/cg/Makefile   (contents, props changed)
  head/cddl/usr.sbin/dtrace/tests/common/clauses/
  head/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/cpc/
  head/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/decls/
  head/cddl/usr.sbin/dtrace/tests/common/decls/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/docsExamples/
  head/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile   (contents, 
props changed)
  head/cddl/usr.sbin/dtrace/tests/common/drops/
  head/cddl/usr.sbin/dtrace/tests/common/drops/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/
  head/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/end/
  head/cddl/usr.sbin/dtrace/tests/common/end/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/enum/
  head/cddl/usr.sbin/dtrace/tests/common/enum/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/error/
  head/cddl/usr.sbin/dtrace/tests/common/error/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/exit/
  head/cddl/usr.sbin/dtrace/tests/common/exit/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/fbtprovider/
  head/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile   (contents, 
props changed)
  head/cddl/usr.sbin/dtrace/tests/common/funcs/
  head/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/grammar/
  head/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/include/
  head/cddl/usr.sbin/dtrace/tests/common/include/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/inline/
  head/cddl/usr.sbin/dtrace/tests/common/inline/Makefile   (contents, props 
changed)
  head/cddl/usr.sbin/dtrace/tests/common/io/
  head/cddl/usr.sbin/dtrace/tests/common/io/Makefile   (contents, props changed)
  head/cddl/usr.sbin/dtrace/tests/common/ip/
  head/cddl/usr.sbin/dtrace/tests/common/ip/Makefile   (contents, props changed)
  head/cddl/usr.sbin/dtrace/tests/common/java_api/
  head/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile   (contents, props 
changed)
 

svn commit: r279419 - in head/tools/test: . dtrace

2015-02-28 Thread Mark Johnston
Author: markj
Date: Sat Feb 28 23:35:29 2015
New Revision: 279419
URL: https://svnweb.freebsd.org/changeset/base/279419

Log:
  Remove the old DTrace test suite makefile - it was somewhat primitive and
  mostly unmaintained, and it has been superseded by the infrastructure added
  in r279418.
  
  Reviewed by:  ngie
  Sponsored by: EMC / Isilon Storage Divison

Deleted:
  head/tools/test/dtrace/
Modified:
  head/tools/test/README

Modified: head/tools/test/README
==
--- head/tools/test/README  Sat Feb 28 23:30:06 2015(r279418)
+++ head/tools/test/README  Sat Feb 28 23:35:29 2015(r279419)
@@ -8,7 +8,6 @@ and try to break it and/or measuring per
 Please make a subdir per program, and add a brief description to this file.
 
 devrandom  Programs to test /dev/*random.
-dtrace DTrace test suite
 malloc A program to test and benchmark malloc().
 netfibsPrograms to test multi-FIB network stacks.
 posixshm   A program to test POSIX shared memory.
___
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: r279420 - head/sys/dev/etherswitch/arswitch

2015-02-28 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 28 23:59:29 2015
New Revision: 279420
URL: https://svnweb.freebsd.org/changeset/base/279420

Log:
  Add another register definition for the AR8327.
  
  Obtained from:OpenWRT

Modified:
  head/sys/dev/etherswitch/arswitch/arswitchreg.h

Modified: head/sys/dev/etherswitch/arswitch/arswitchreg.h
==
--- head/sys/dev/etherswitch/arswitch/arswitchreg.h Sat Feb 28 23:35:29 
2015(r279419)
+++ head/sys/dev/etherswitch/arswitch/arswitchreg.h Sat Feb 28 23:59:29 
2015(r279420)
@@ -443,6 +443,9 @@
 #defineAR8327_SGMII_CTRL_EN_RX (1 << 2)
 #defineAR8327_SGMII_CTRL_EN_TX (1 << 3)
 
+#defineAR8327_REG_EEE_CTRL 0x100
+#defineAR8327_EEE_CTRL_DISABLE_PHY(_i) BIT(4 + (_i) * 2)
+
 #defineAR8327_REG_PORT_VLAN0(_i)   (0x420 + (_i) * 0x8)
 #defineAR8327_PORT_VLAN0_DEF_SVID  BITS(0, 12)
 #defineAR8327_PORT_VLAN0_DEF_SVID_S0
___
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: r279421 - head/lib/libnv

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:01:36 2015
New Revision: 279421
URL: https://svnweb.freebsd.org/changeset/base/279421

Log:
  Make libnv headers includable from C++
  
  Differential Revision:https://reviews.freebsd.org/D1868
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/dnv.h
  head/lib/libnv/nv.h

Modified: head/lib/libnv/dnv.h
==
--- head/lib/libnv/dnv.hSat Feb 28 23:59:29 2015(r279420)
+++ head/lib/libnv/dnv.hSun Mar  1 00:01:36 2015(r279421)
@@ -45,6 +45,8 @@ struct nvlist;
 typedef struct nvlist nvlist_t;
 #endif
 
+__BEGIN_DECLS
+
 /*
  * The dnvlist_get functions returns value associated with the given name.
  * If it returns a pointer, the pointer represents internal buffer and should
@@ -103,4 +105,6 @@ nvlist_t *dnvlist_takev_nvlist(nvlist_t 
 int dnvlist_takev_descriptor(nvlist_t *nvl, int defval, const char *namefmt, 
va_list nameap) __printflike(3, 0);
 void *dnvlist_takev_binary(nvlist_t *nvl, size_t *sizep, void *defval, size_t 
defsize, const char *namefmt, va_list nameap) __printflike(5, 0);
 
+__END_DECLS
+
 #endif /* !_DNV_H_ */

Modified: head/lib/libnv/nv.h
==
--- head/lib/libnv/nv.h Sat Feb 28 23:59:29 2015(r279420)
+++ head/lib/libnv/nv.h Sun Mar  1 00:01:36 2015(r279421)
@@ -63,6 +63,8 @@ typedef struct nvlist nvlist_t;
  */
 #defineNV_FLAG_IGNORE_CASE 0x01
 
+__BEGIN_DECLS
+
 nvlist_t   *nvlist_create(int flags);
 voidnvlist_destroy(nvlist_t *nvl);
 int nvlist_error(const nvlist_t *nvl);
@@ -272,4 +274,6 @@ void nvlist_freev_nvlist(nvlist_t *nvl, 
 void nvlist_freev_descriptor(nvlist_t *nvl, const char *namefmt, va_list 
nameap) __printflike(2, 0);
 void nvlist_freev_binary(nvlist_t *nvl, const char *namefmt, va_list nameap) 
__printflike(2, 0);
 
+__END_DECLS
+
 #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: r279422 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:01:44 2015
New Revision: 279422
URL: https://svnweb.freebsd.org/changeset/base/279422

Log:
  Tests of basic nvlist add functions
  
  Differential Revision:https://reviews.freebsd.org/D1869
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/tests/Makefile

Modified: head/lib/libnv/tests/Makefile
==
--- head/lib/libnv/tests/Makefile   Sun Mar  1 00:01:36 2015
(r279421)
+++ head/lib/libnv/tests/Makefile   Sun Mar  1 00:01:44 2015
(r279422)
@@ -2,6 +2,8 @@
 
 TESTSDIR=  ${TESTSBASE}/lib/libnv
 
+ATF_TESTS_CXX= nv_tests
+
 TAP_TESTS_C+=  nvlist_add_test
 TAP_TESTS_C+=  nvlist_exists_test
 TAP_TESTS_C+=  nvlist_free_test
@@ -11,6 +13,6 @@ TAP_TESTS_C+= nvlist_send_recv_test
 
 LIBADD+=   nv
 
-WARNS?=6
+WARNS?=3
 
 .include 
___
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: r279423 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:05:45 2015
New Revision: 279423
URL: https://svnweb.freebsd.org/changeset/base/279423

Log:
  Revert r279422.  My "apply patch and commit" script wasn't adding
  new files properly.
  
  Pointy hat to: rstone

Modified:
  head/lib/libnv/tests/Makefile

Modified: head/lib/libnv/tests/Makefile
==
--- head/lib/libnv/tests/Makefile   Sun Mar  1 00:01:44 2015
(r279422)
+++ head/lib/libnv/tests/Makefile   Sun Mar  1 00:05:45 2015
(r279423)
@@ -2,8 +2,6 @@
 
 TESTSDIR=  ${TESTSBASE}/lib/libnv
 
-ATF_TESTS_CXX= nv_tests
-
 TAP_TESTS_C+=  nvlist_add_test
 TAP_TESTS_C+=  nvlist_exists_test
 TAP_TESTS_C+=  nvlist_free_test
@@ -13,6 +11,6 @@ TAP_TESTS_C+= nvlist_send_recv_test
 
 LIBADD+=   nv
 
-WARNS?=3
+WARNS?=6
 
 .include 
___
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: r279338 - head/sys/arm/include

2015-02-28 Thread Alexey Dokuchaev
On Sat, Feb 28, 2015 at 12:38:00PM +1100, Bruce Evans wrote:
> On Fri, 27 Feb 2015, Ian Lepore wrote:
> > ::sigh::  As usual, thousands of words, maybe there's actionable info in
> > there, but I sure don't have time to ferret it out.
> >
> > If there's something simple you'd like me to do, please say so. Simply.
> 
> Just back out the change.  For extra credit, back it out for i386 too.
> For too much work, fix the 17 calls with bogus casts.

Bruce, just for the record (I'm pretty sure there're other folks wondering
of the same): why won't you step in with your commit bit and help fix many
of these issues you point out by yourself?

./danfe
___
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: r279428 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:21:43 2015
New Revision: 279428
URL: https://svnweb.freebsd.org/changeset/base/279428

Log:
  Add tests for nvlist_take_*
  
  Differential Revision:https://reviews.freebsd.org/D1873
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:37 2015
(r279427)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:43 2015
(r279428)
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -662,6 +663,286 @@ ATF_TEST_CASE_BODY(nvlist_move_binary__s
nvlist_destroy(nvl);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_take_bool__single_remove);
+ATF_TEST_CASE_BODY(nvlist_take_bool__single_remove)
+{
+   nvlist_t *nvl;
+   const char *testkey;
+   bool testval;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   testkey = "boolkey";
+   testval = false;
+   nvlist_add_bool(nvl, testkey, testval);
+
+   ATF_REQUIRE_EQ(nvlist_take_bool(nvl, testkey), testval);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_take_bool__other_keys_unchanged);
+ATF_TEST_CASE_BODY(nvlist_take_bool__other_keys_unchanged)
+{
+   nvlist_t *nvl;
+   const char *testkey, *otherkey1, *otherkey2;
+   bool testval, otherval1;
+   nvlist_t *otherval2;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   testkey = "boolkey";
+   testval = true;
+   nvlist_add_bool(nvl, testkey, testval);
+
+   otherkey1 = "key1";
+   otherval1 = false;
+   nvlist_add_bool(nvl, otherkey1, otherval1);
+
+   otherkey2 = "key2";
+   otherval2 = create_test_nvlist();
+   nvlist_move_nvlist(nvl, otherkey2, otherval2);
+
+   ATF_REQUIRE_EQ(nvlist_take_bool(nvl, testkey), testval);
+
+   ATF_REQUIRE(nvlist_exists_bool(nvl, otherkey1));
+   ATF_REQUIRE_EQ(nvlist_get_bool(nvl, otherkey1), otherval1);
+
+   ATF_REQUIRE(nvlist_exists_nvlist(nvl, otherkey2));
+   verify_test_nvlist(nvlist_get_nvlist(nvl, otherkey2));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_take_number__single_remove);
+ATF_TEST_CASE_BODY(nvlist_take_number__single_remove)
+{
+   nvlist_t *nvl;
+   const char *testkey;
+   uint64_t testval;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   testkey = "numkey";
+   testval = std::numeric_limits::max();
+   nvlist_add_number(nvl, testkey, testval);
+
+   ATF_REQUIRE_EQ(nvlist_take_number(nvl, testkey), testval);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_take_number__other_keys_unchanged);
+ATF_TEST_CASE_BODY(nvlist_take_number__other_keys_unchanged)
+{
+   nvlist_t *nvl;
+   const char *testkey, *otherkey1, *otherkey2;
+   uint64_t testval, otherval1;
+   const char *otherval2;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   otherkey1 = "key1";
+   otherval1 = 5;
+   nvlist_add_number(nvl, otherkey1, otherval1);
+
+   testkey = "numkey";
+   testval = 1654;
+   nvlist_add_number(nvl, testkey, testval);
+
+   otherkey2 = "key2";
+   otherval2 = "string";
+   nvlist_add_string(nvl, otherkey2, otherval2);
+
+   ATF_REQUIRE_EQ(nvlist_take_number(nvl, testkey), testval);
+
+   ATF_REQUIRE(nvlist_exists_number(nvl, otherkey1));
+   ATF_REQUIRE_EQ(nvlist_get_number(nvl, otherkey1), otherval1);
+
+   ATF_REQUIRE(nvlist_exists_string(nvl, otherkey2));
+   ATF_REQUIRE_EQ(strcmp(nvlist_get_string(nvl, otherkey2), otherval2), 0);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_take_string__single_remove);
+ATF_TEST_CASE_BODY(nvlist_take_string__single_remove)
+{
+   nvlist_t *nvl;
+   const char *testkey;
+   const char *testval;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   testkey = "numkey";
+   testval = "nvlist";
+   nvlist_add_string(nvl, testkey, testval);
+
+   ATF_REQUIRE_EQ(strcmp(nvlist_take_string(nvl, testkey), testval), 0);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_take_string__other_keys_unchanged);
+ATF_TEST_CASE_BODY(nvlist_take_string__other_keys_unchanged)
+{
+   nvlist_t *nvl;
+   const char *testkey, *otherkey1, *otherkey2;
+   const char *testval, *otherval1;
+   bool otherval2;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   otherkey1 = "key1";
+   otherval1 = "fjdifjdk";
+   nvlist_add_string(n

svn commit: r279426 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:21:30 2015
New Revision: 279426
URL: https://svnweb.freebsd.org/changeset/base/279426

Log:
  Add tests for nvlist_pack/unpack
  
  Differential Revision:https://reviews.freebsd.org/D1871
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:24 2015
(r279425)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:30 2015
(r279426)
@@ -31,6 +31,10 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
+#include 
+#include 
+
 /*
  * Test that a newly created nvlist has no errors, and is empty.
  */
@@ -404,6 +408,183 @@ ATF_TEST_CASE_BODY(nvlist_clone__nested_
nvlist_destroy(nvl);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_pack__empty_nvlist);
+ATF_TEST_CASE_BODY(nvlist_pack__empty_nvlist)
+{
+   nvlist_t *nvl, *unpacked;
+   void *packed;
+   size_t packed_size;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   packed = nvlist_pack(nvl, &packed_size);
+   ATF_REQUIRE(packed != NULL);
+
+   unpacked = nvlist_unpack(packed, packed_size);
+   ATF_REQUIRE(unpacked != NULL);
+   ATF_REQUIRE(unpacked != nvl);
+   ATF_REQUIRE(nvlist_empty(unpacked));
+
+   nvlist_destroy(unpacked);
+   nvlist_destroy(nvl);
+   free(packed);
+}
+
+static void
+verify_null(const nvlist_t *nvl, int type)
+{
+
+   ATF_REQUIRE_EQ(type, NV_TYPE_NULL);
+}
+
+static void
+verify_number(const nvlist_t *nvl, const char *name, int type, uint64_t value)
+{
+
+   ATF_REQUIRE_EQ(type, NV_TYPE_NUMBER);
+   ATF_REQUIRE_EQ(nvlist_get_number(nvl, name), value);
+}
+
+static void
+verify_string(const nvlist_t *nvl, const char *name, int type,
+const char * value)
+{
+
+   ATF_REQUIRE_EQ(type, NV_TYPE_STRING);
+   ATF_REQUIRE_EQ(strcmp(nvlist_get_string(nvl, name), value), 0);
+}
+
+static void
+verify_nvlist(const nvlist_t *nvl, const char *name, int type)
+{
+
+   ATF_REQUIRE_EQ(type, NV_TYPE_NVLIST);
+   verify_test_nvlist(nvlist_get_nvlist(nvl, name));
+}
+
+static void
+verify_binary(const nvlist_t *nvl, const char *name, int type,
+const void * value, size_t size)
+{
+   const void *actual_value;
+   size_t actual_size;
+
+   ATF_REQUIRE_EQ(type, NV_TYPE_BINARY);
+   actual_value = nvlist_get_binary(nvl, name, &actual_size);
+   ATF_REQUIRE_EQ(size, actual_size);
+   ATF_REQUIRE_EQ(memcmp(value, actual_value, size), 0);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_pack__multiple_values);
+ATF_TEST_CASE_BODY(nvlist_pack__multiple_values)
+{
+   std::ostringstream msg;
+   std::set keys_seen;
+   nvlist_t *nvl, *unpacked, *nvvalue;
+   const char *nullkey, *numkey, *strkey, *nvkey, *binkey, *name;
+   int numvalue;
+   const char * strvalue;
+   void *binvalue, *packed, *it;
+   size_t binsize, packed_size;
+   int type;
+
+   nvl = nvlist_create(0);
+
+   nullkey = "null";
+   nvlist_add_null(nvl, nullkey);
+
+   numkey = "number";
+   numvalue = 939853984;
+   nvlist_add_number(nvl, numkey, numvalue);
+
+   strkey = "string";
+   strvalue = "jfieutijf";
+   nvlist_add_string(nvl, strkey, strvalue);
+
+   nvkey = "nvlist";
+   nvvalue = create_test_nvlist();
+   nvlist_move_nvlist(nvl, nvkey, nvvalue);
+
+   binkey = "binary";
+   binsize = 4;
+   binvalue = malloc(binsize);
+   memset(binvalue, 'b', binsize);
+   nvlist_move_binary(nvl, binkey, binvalue, binsize);
+
+   packed = nvlist_pack(nvl, &packed_size);
+   ATF_REQUIRE(packed != NULL);
+
+   unpacked = nvlist_unpack(packed, packed_size);
+   ATF_REQUIRE(unpacked != 0);
+
+   it = NULL;
+   while ((name = nvlist_next(unpacked, &type, &it)) != NULL) {
+   /* Ensure that we see every key only once. */
+   ATF_REQUIRE_EQ(keys_seen.count(name), 0);
+
+   if (strcmp(name, nullkey) == 0)
+   verify_null(unpacked, type);
+   else if (strcmp(name, numkey) == 0)
+   verify_number(unpacked, name, type, numvalue);
+   else if (strcmp(name, strkey) == 0)
+   verify_string(unpacked, name, type, strvalue);
+   else if (strcmp(name, nvkey) == 0)
+   verify_nvlist(unpacked, name, type);
+   else if (strcmp(name, binkey) == 0)
+   verify_binary(unpacked, name, type, binvalue, binsize);
+   else {
+   msg << "Unexpected key :'" << name << "'";
+   ATF_FAIL(msg.str().c_str());
+   }
+
+   keys_seen.insert(name);
+   }
+
+

svn commit: r279427 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:21:37 2015
New Revision: 279427
URL: https://svnweb.freebsd.org/changeset/base/279427

Log:
  Add test cases for nvlist_move_*
  
  Differential Revision:https://reviews.freebsd.org/D1872
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:30 2015
(r279426)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:37 2015
(r279427)
@@ -585,6 +585,83 @@ ATF_TEST_CASE_BODY(nvlist_unpack__duplic
nvlist_destroy(unpacked);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_string__single_insert);
+ATF_TEST_CASE_BODY(nvlist_move_string__single_insert)
+{
+   nvlist_t *nvl;
+   const char *key;
+   char *value;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   key = "testkey";
+   value = strdup("testval");
+   ATF_REQUIRE(value != NULL);
+
+   nvlist_move_string(nvl, key, value);
+   ATF_REQUIRE_EQ(nvlist_get_string(nvl, key), value);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_nvlist__null_child);
+ATF_TEST_CASE_BODY(nvlist_move_nvlist__null_child)
+{
+   nvlist_t *parent;
+
+   parent = nvlist_create(0);
+
+   nvlist_move_nvlist(parent, "test", NULL);
+
+   ATF_REQUIRE(nvlist_error(parent) != 0);
+
+   nvlist_destroy(parent);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_nvlist__single_insert);
+ATF_TEST_CASE_BODY(nvlist_move_nvlist__single_insert)
+{
+   nvlist_t *nvl;
+   const char *key;
+   nvlist_t *value;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   key = "testkey";
+   value = nvlist_create(0);
+   ATF_REQUIRE(value != NULL);
+
+   nvlist_move_nvlist(nvl, key, value);
+   ATF_REQUIRE_EQ(nvlist_get_nvlist(nvl, key), value);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_binary__single_insert);
+ATF_TEST_CASE_BODY(nvlist_move_binary__single_insert)
+{
+   nvlist_t *nvl;
+   const char *key;
+   void *value;
+   size_t size, actual_size;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   key = "testkey";
+   size = 73;
+   value = malloc(size);
+   ATF_REQUIRE(value != NULL);
+
+   nvlist_move_binary(nvl, key, value, size);
+   ATF_REQUIRE_EQ(nvlist_get_binary(nvl, key, &actual_size), value);
+   ATF_REQUIRE_EQ(size, actual_size);
+
+   nvlist_destroy(nvl);
+}
+
 ATF_INIT_TEST_CASES(tp)
 {
ATF_ADD_TEST_CASE(tp, nvlist_create__is_empty);
@@ -602,6 +679,11 @@ ATF_INIT_TEST_CASES(tp)
ATF_ADD_TEST_CASE(tp, nvlist_pack__empty_nvlist);
ATF_ADD_TEST_CASE(tp, nvlist_pack__multiple_values);
ATF_ADD_TEST_CASE(tp, nvlist_unpack__duplicate_key);
+
+   ATF_ADD_TEST_CASE(tp, nvlist_move_string__single_insert);
+   ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__single_insert);
+   ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__null_child);
+   ATF_ADD_TEST_CASE(tp, nvlist_move_binary__single_insert);
 }
 /*-
  * Copyright (c) 2014-2015 Sandvine Inc.  All rights reserved.
___
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: r279424 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:20:57 2015
New Revision: 279424
URL: https://svnweb.freebsd.org/changeset/base/279424

Log:
  Tests of basic nvlist add functions
  
  Differential Revision:https://reviews.freebsd.org/D1869
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/lib/libnv/tests/nv_tests.cc   (contents, props changed)
Modified:
  head/lib/libnv/tests/Makefile

Modified: head/lib/libnv/tests/Makefile
==
--- head/lib/libnv/tests/Makefile   Sun Mar  1 00:05:45 2015
(r279423)
+++ head/lib/libnv/tests/Makefile   Sun Mar  1 00:20:57 2015
(r279424)
@@ -2,6 +2,8 @@
 
 TESTSDIR=  ${TESTSBASE}/lib/libnv
 
+ATF_TESTS_CXX= nv_tests
+
 TAP_TESTS_C+=  nvlist_add_test
 TAP_TESTS_C+=  nvlist_exists_test
 TAP_TESTS_C+=  nvlist_free_test
@@ -11,6 +13,6 @@ TAP_TESTS_C+= nvlist_send_recv_test
 
 LIBADD+=   nv
 
-WARNS?=6
+WARNS?=3
 
 .include 

Added: head/lib/libnv/tests/nv_tests.cc
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:20:57 2015
(r279424)
@@ -0,0 +1,2076 @@
+/*-
+ * Copyright (c) 2014-2015 Sandvine Inc.  All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+/*
+ * Test that a newly created nvlist has no errors, and is empty.
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_create__is_empty);
+ATF_TEST_CASE_BODY(nvlist_create__is_empty)
+{
+   nvlist_t *nvl;
+   int type;
+   void *it;
+
+   nvl = nvlist_create(0);
+
+   ATF_REQUIRE(nvl != NULL);
+
+   ATF_REQUIRE_EQ(nvlist_error(nvl), 0);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   it = NULL;
+   ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &it), NULL);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_null__single_insert);
+ATF_TEST_CASE_BODY(nvlist_add_null__single_insert)
+{
+   nvlist_t *nvl;
+   void *it;
+   const char *key;
+   int type;
+
+   key = "key";
+   nvl = nvlist_create(0);
+
+   ATF_REQUIRE(nvl != NULL);
+   ATF_REQUIRE(!nvlist_exists(nvl, key));
+
+   nvlist_add_null(nvl, key);
+
+   ATF_REQUIRE(!nvlist_empty(nvl));
+   ATF_REQUIRE(nvlist_exists(nvl, key));
+   ATF_REQUIRE(nvlist_existsf(nvl, "%s", key));
+   ATF_REQUIRE(nvlist_exists_null(nvl, key));
+   ATF_REQUIRE(nvlist_existsf_null(nvl, "key"));
+
+   /* Iterate over the nvlist; ensure that it has only our one key. */
+   it = NULL;
+   ATF_REQUIRE_EQ(strcmp(nvlist_next(nvl, &type, &it), key), 0);
+   ATF_REQUIRE_EQ(type, NV_TYPE_NULL);
+   ATF_REQUIRE_EQ(nvlist_next(nvl, &type,&it), NULL);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_bool__single_insert);
+ATF_TEST_CASE_BODY(nvlist_add_bool__single_insert)
+{
+   nvlist_t *nvl;
+   void *it;
+   const char *key;
+   int type;
+
+   key = "name";
+   nvl = nvlist_create(0);
+
+   ATF_REQUIRE(nvl != NULL);
+   ATF_REQUIRE(!nvlist_exists(nvl, key));
+
+   nvlist_add_bool(nvl, key, true);
+
+   ATF_REQUIRE(!nvlist_empty(nvl));
+   ATF_REQUIRE(nvlist_exists(nvl, key));
+   ATF_REQUIRE(nvlist_existsf(nvl, "%s%s", "na", "me"));
+   ATF_REQUIRE(nvlist_exists_bool(nvl, key));
+   ATF_REQUIRE(nvlist_existsf_bool(nvl, "%s%c", "nam", 'e'));
+   ATF_REQUIRE_EQ(nvlist_get_bool(nv

svn commit: r279430 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:21:56 2015
New Revision: 279430
URL: https://svnweb.freebsd.org/changeset/base/279430

Log:
  Add tests for dnv_get_*
  
  Differential Revision:https://reviews.freebsd.org/D1875
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/lib/libnv/tests/dnv_tests.cc   (contents, props changed)
Modified:
  head/lib/libnv/tests/Makefile

Modified: head/lib/libnv/tests/Makefile
==
--- head/lib/libnv/tests/Makefile   Sun Mar  1 00:21:50 2015
(r279429)
+++ head/lib/libnv/tests/Makefile   Sun Mar  1 00:21:56 2015
(r279430)
@@ -2,7 +2,9 @@
 
 TESTSDIR=  ${TESTSBASE}/lib/libnv
 
-ATF_TESTS_CXX= nv_tests
+ATF_TESTS_CXX= \
+   dnv_tests \
+   nv_tests \
 
 TAP_TESTS_C+=  nvlist_add_test
 TAP_TESTS_C+=  nvlist_exists_test

Added: head/lib/libnv/tests/dnv_tests.cc
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libnv/tests/dnv_tests.cc   Sun Mar  1 00:21:56 2015
(r279430)
@@ -0,0 +1,289 @@
+/*-
+ * Copyright (c) 2014-2015 Sandvine Inc.  All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_get_bool__present);
+ATF_TEST_CASE_BODY(dnvlist_get_bool__present)
+{
+   nvlist_t *nvl;
+   const char *key;
+   bool value;
+
+   nvl = nvlist_create(0);
+
+   key = "name";
+   value = true;
+   nvlist_add_bool(nvl, key, value);
+
+   ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, key, false), value);
+   ATF_REQUIRE_EQ(dnvlist_getf_bool(nvl, false, "%c%s", 'n', "ame"), 
value);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_get_bool__default_value);
+ATF_TEST_CASE_BODY(dnvlist_get_bool__default_value)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   key = "123";
+   nvl = nvlist_create(0);
+
+   ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, key, false), false);
+   ATF_REQUIRE_EQ(dnvlist_getf_bool(nvl, true, "%d", 123), true);
+
+   nvlist_add_bool(nvl, key, true);
+
+   ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, "otherkey", true), true);
+   ATF_REQUIRE_EQ(dnvlist_getf_bool(nvl, false, "%d%c", 12, 'c'), false);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_get_number__present);
+ATF_TEST_CASE_BODY(dnvlist_get_number__present)
+{
+   nvlist_t *nvl;
+   const char *key;
+   uint64_t value;
+
+   nvl = nvlist_create(0);
+
+   key = "key";
+   value = 48952;
+   nvlist_add_number(nvl, key, value);
+
+   ATF_REQUIRE_EQ(dnvlist_get_number(nvl, key, 19), value);
+   ATF_REQUIRE_EQ(dnvlist_getf_number(nvl, 65, "key"), value);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_get_number__default_value);
+ATF_TEST_CASE_BODY(dnvlist_get_number__default_value)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   key = "123";
+   nvl = nvlist_create(0);
+
+   ATF_REQUIRE_EQ(dnvlist_get_number(nvl, key, 5), 5);
+   ATF_REQUIRE_EQ(dnvlist_getf_number(nvl, 12, "%s", key), 12);
+
+   nvlist_add_number(nvl, key, 24841);
+
+   ATF_REQUIRE_EQ(dnvlist_get_number(nvl, "hthth", 184), 184);
+   ATF_REQUIRE_EQ(dnvlist_getf_number(nvl, 5641, "%d", 1234), 5641);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_get_string__present);
+ATF_TEST_CASE_BODY(dnvlist_get_string__present)
+{
+   nvlist_t 

svn commit: r279425 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:21:24 2015
New Revision: 279425
URL: https://svnweb.freebsd.org/changeset/base/279425

Log:
  Add tests for nvlist_clone
  
  Differential Revision:https://reviews.freebsd.org/D1870
  Reviewed by:  pjd, jfv
  MFC after:1 month
  Sponsored by: Sandvine Inc

Modified:
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:20:57 2015
(r279424)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:24 2015
(r279425)
@@ -288,6 +288,122 @@ ATF_TEST_CASE_BODY(nvlist_add_binary__si
free(value);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_clone__empty_nvlist);
+ATF_TEST_CASE_BODY(nvlist_clone__empty_nvlist)
+{
+   nvlist_t *nvl, *clone;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   clone = nvlist_clone(nvl);
+   ATF_REQUIRE(clone != NULL);
+   ATF_REQUIRE(clone != nvl);
+   ATF_REQUIRE(nvlist_empty(clone));
+
+   nvlist_destroy(clone);
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_clone__nonempty_nvlist);
+ATF_TEST_CASE_BODY(nvlist_clone__nonempty_nvlist)
+{
+   nvlist_t *nvl, *clone;
+   const char *key;
+   void *it;
+   uint64_t value;
+   int type;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   key = "testkey";
+   value = 684874;
+   nvlist_add_number(nvl, key, value);
+
+   clone = nvlist_clone(nvl);
+   ATF_REQUIRE(clone != NULL);
+   ATF_REQUIRE(clone != nvl);
+   ATF_REQUIRE(nvlist_exists_number(clone, key));
+   ATF_REQUIRE_EQ(nvlist_get_number(clone, key), value);
+
+   /* Iterate over the nvlist; ensure that it has only our one key. */
+   it = NULL;
+   ATF_REQUIRE_EQ(strcmp(nvlist_next(clone, &type, &it), key), 0);
+   ATF_REQUIRE_EQ(type, NV_TYPE_NUMBER);
+   ATF_REQUIRE_EQ(nvlist_next(clone, &type, &it), NULL);
+
+   nvlist_destroy(clone);
+   nvlist_destroy(nvl);
+}
+
+static const char * const test_subnvlist_key = "nvlist";
+
+static const char * const test_string_key = "string";
+static const char * const test_string_val = "59525";
+
+static nvlist_t*
+create_test_nvlist(void)
+{
+   nvlist_t *nvl, *sublist;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   sublist = nvlist_create(0);
+   ATF_REQUIRE(sublist != NULL);
+
+   nvlist_add_string(sublist, test_string_key, test_string_val);
+   nvlist_move_nvlist(nvl, test_subnvlist_key, sublist);
+
+   return (nvl);
+}
+
+static void
+verify_test_nvlist(const nvlist_t *nvl)
+{
+   void *it;
+   const nvlist_t *value;
+   int type;
+
+   ATF_REQUIRE(nvlist_exists_nvlist(nvl, test_subnvlist_key));
+
+   value = nvlist_get_nvlist(nvl, test_subnvlist_key);
+
+   ATF_REQUIRE(nvlist_exists_string(value, test_string_key));
+   ATF_REQUIRE_EQ(strcmp(nvlist_get_string(value, test_string_key), 
test_string_val), 0);
+   ATF_REQUIRE(nvlist_get_string(value, test_string_key) != 
test_string_val);
+
+   /* Iterate over both nvlists; ensure that each has only the one key. */
+   it = NULL;
+   ATF_REQUIRE_EQ(strcmp(nvlist_next(value, &type, &it),
+   test_string_key), 0);
+   ATF_REQUIRE_EQ(type, NV_TYPE_STRING);
+   ATF_REQUIRE_EQ(nvlist_next(value, &type, &it), NULL);
+
+   it = NULL;
+   ATF_REQUIRE_EQ(strcmp(nvlist_next(nvl, &type, &it),
+   test_subnvlist_key), 0);
+   ATF_REQUIRE_EQ(type, NV_TYPE_NVLIST);
+   ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &it), NULL);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_clone__nested_nvlist);
+ATF_TEST_CASE_BODY(nvlist_clone__nested_nvlist)
+{
+   nvlist_t *nvl, *clone;
+
+   nvl = create_test_nvlist();
+   clone = nvlist_clone(nvl);
+
+   ATF_REQUIRE(clone != NULL);
+   ATF_REQUIRE(clone != nvl);
+   verify_test_nvlist(clone);
+
+   nvlist_destroy(clone);
+   nvlist_destroy(nvl);
+}
+
 ATF_INIT_TEST_CASES(tp)
 {
ATF_ADD_TEST_CASE(tp, nvlist_create__is_empty);
@@ -297,6 +413,10 @@ ATF_INIT_TEST_CASES(tp)
ATF_ADD_TEST_CASE(tp, nvlist_add_string__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_add_nvlist__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_add_binary__single_insert);
+
+   ATF_ADD_TEST_CASE(tp, nvlist_clone__empty_nvlist);
+   ATF_ADD_TEST_CASE(tp, nvlist_clone__nonempty_nvlist);
+   ATF_ADD_TEST_CASE(tp, nvlist_clone__nested_nvlist);
 }
 /*-
  * Copyright (c) 2014-2015 Sandvine Inc.  All rights reserved.
___
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: r279429 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:21:50 2015
New Revision: 279429
URL: https://svnweb.freebsd.org/changeset/base/279429

Log:
  Add tests for nvlist_free* functions
  
  Differential Revision:https://reviews.freebsd.org/D1874
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:43 2015
(r279428)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:21:50 2015
(r279429)
@@ -943,6 +943,198 @@ ATF_TEST_CASE_BODY(nvlist_take_binary__o
nvlist_destroy(nvl);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free__single_null);
+ATF_TEST_CASE_BODY(nvlist_free__single_null)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_null(nvl, key);
+
+   nvlist_free(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free__single_bool);
+ATF_TEST_CASE_BODY(nvlist_free__single_bool)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_bool(nvl, key, true);
+
+   nvlist_free(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free__single_number);
+ATF_TEST_CASE_BODY(nvlist_free__single_number)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_number(nvl, key, 584);
+
+   nvlist_free(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free__single_string);
+ATF_TEST_CASE_BODY(nvlist_free__single_string)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_string(nvl, key, "gjkfkjd");
+
+   nvlist_free(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free__single_nvlist);
+ATF_TEST_CASE_BODY(nvlist_free__single_nvlist)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_nvlist(nvl, key, nvlist_create(0));
+
+   nvlist_free(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free__single_binary);
+ATF_TEST_CASE_BODY(nvlist_free__single_binary)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_binary(nvl, key, "jgjgfd", 6);
+
+   nvlist_free(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free_null__single_null);
+ATF_TEST_CASE_BODY(nvlist_free_null__single_null)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_null(nvl, key);
+
+   nvlist_free_null(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free_bool__single_bool);
+ATF_TEST_CASE_BODY(nvlist_free_bool__single_bool)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_bool(nvl, key, true);
+
+   nvlist_free_bool(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free_number__single_number);
+ATF_TEST_CASE_BODY(nvlist_free_number__single_number)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_number(nvl, key, 584);
+
+   nvlist_free_number(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free_string__single_string);
+ATF_TEST_CASE_BODY(nvlist_free_string__single_string)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_string(nvl, key, "gjkfkjd");
+
+   nvlist_free_string(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free_nvlist__single_nvlist);
+ATF_TEST_CASE_BODY(nvlist_free_nvlist__single_nvlist)
+{
+   nvlist_t *nvl;
+   const char *key;
+
+   nvl = nvlist_create(0);
+   key = "test";
+   nvlist_add_nvlist(nvl, key, nvlist_create(0));
+
+   nvlist_free_nvlist(nvl, key);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_free_binary__single_binary);
+ATF_TEST_CASE_BODY(nvlist_free_b

svn commit: r279433 - in head/sys: conf libkern sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:16 2015
New Revision: 279433
URL: https://svnweb.freebsd.org/changeset/base/279433

Log:
  Implement asprintf in libkern
  
  Differential Revision:https://reviews.freebsd.org/D1877
  Reviewed by:  pjd, jfv
  MFC After:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/sys/libkern/asprintf.c   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/sys/systm.h

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sun Mar  1 00:22:09 2015(r279432)
+++ head/sys/conf/files Sun Mar  1 00:22:16 2015(r279433)
@@ -3216,6 +3216,7 @@ kgssapi/gsstest.c optional kgssapi_debu
 # the file should be moved to conf/files. from here.
 #
 libkern/arc4random.c   standard
+libkern/asprintf.c standard
 libkern/bcd.c  standard
 libkern/bsearch.c  standard
 libkern/crc32.cstandard

Added: head/sys/libkern/asprintf.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/libkern/asprintf.c Sun Mar  1 00:22:16 2015(r279433)
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2013-2015 Sandvine Inc.  All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+
+int
+vasprintf(char **buf, struct malloc_type *mtp, const char *format, va_list va)
+{
+   int len, ret;
+   va_list tmp_va;
+   char dummy;
+
+   va_copy(tmp_va, va);
+   len = vsnprintf(&dummy, 0, format, tmp_va);
+   va_end(tmp_va);
+   if (len < 0) {
+   *buf = NULL;
+   return (len);
+   }
+
+   /* Account for null terminator. */
+   len += 1;
+   *buf = malloc(len, mtp, M_NOWAIT);
+   if (*buf == NULL)
+   return (-1);
+
+   ret = vsnprintf(*buf, len, format, va);
+   if (ret < 0) {
+   free(*buf, mtp);
+   *buf = NULL;
+   }
+
+   return (ret);
+}
+
+int
+asprintf(char **buf, struct malloc_type *mtp, const char *format, ...)
+{
+   int ret;
+   va_list va;
+
+   va_start(va, format);
+   ret = vasprintf(buf, mtp, format, va);
+   va_end(va);
+
+   return (ret);
+}

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hSun Mar  1 00:22:09 2015(r279432)
+++ head/sys/sys/systm.hSun Mar  1 00:22:16 2015(r279433)
@@ -205,11 +205,15 @@ int   kvprintf(char const *, void (*)(int,
__va_list) __printflike(1, 0);
 void   log(int, const char *, ...) __printflike(2, 3);
 void   log_console(struct uio *);
+intasprintf(char **ret, struct malloc_type *mtp, const char *format, 
+   ...) __printflike(3, 4);
 intprintf(const char *, ...) __printflike(1, 2);
 intsnprintf(char *, size_t, const char *, ...) __printflike(3, 4);
 intsprintf(char *buf, const char *, ...) __printflike(2, 3);
 intuprintf(const char *, ...) __printflike(1, 2);
 intvprintf(const char *, __va_list) __printflike(1, 0);
+intvasprintf(char **ret, struct malloc_type *mtp, const char *format,
+   __va_list ap) __printflike(3, 0);
 intvsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0);
 intvsnrprintf(char *, size_t, int, const char *, __va_list) 
__printflike(4, 0);
 intvsprintf(char *buf, const char *, __va_list) __printflike

svn commit: r279432 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:09 2015
New Revision: 279432
URL: https://svnweb.freebsd.org/changeset/base/279432

Log:
  Extend the unit test to fix the bug caught in r277925
  
  Differential Revision:https://reviews.freebsd.org/D1888
  MFC After:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/tests/nvlist_send_recv_test.c

Modified: head/lib/libnv/tests/nvlist_send_recv_test.c
==
--- head/lib/libnv/tests/nvlist_send_recv_test.cSun Mar  1 00:22:03 
2015(r279431)
+++ head/lib/libnv/tests/nvlist_send_recv_test.cSun Mar  1 00:22:09 
2015(r279432)
@@ -58,8 +58,10 @@ static void
 child(int sock)
 {
nvlist_t *nvl;
+   nvlist_t *empty;
 
nvl = nvlist_create(0);
+   empty = nvlist_create(0);
 
nvlist_add_bool(nvl, "nvlist/bool/true", true);
nvlist_add_bool(nvl, "nvlist/bool/false", false);
@@ -75,6 +77,7 @@ child(int sock)
nvlist_add_descriptor(nvl, "nvlist/descriptor/STDERR_FILENO", 
STDERR_FILENO);
nvlist_add_binary(nvl, "nvlist/binary/x", "x", 1);
nvlist_add_binary(nvl, "nvlist/binary/abcdefghijklmnopqrstuvwxyz", 
"abcdefghijklmnopqrstuvwxyz", sizeof("abcdefghijklmnopqrstuvwxyz"));
+   nvlist_move_nvlist(nvl, "nvlist/nvlist/empty", empty);
nvlist_add_nvlist(nvl, "nvlist/nvlist", nvl);
 
nvlist_send(sock, nvl);
@@ -86,7 +89,7 @@ static void
 parent(int sock)
 {
nvlist_t *nvl;
-   const nvlist_t *cnvl;
+   const nvlist_t *cnvl, *empty;
const char *name, *cname;
void *cookie, *ccookie;
int type, ctype;
@@ -190,6 +193,13 @@ parent(int sock)
name = nvlist_next(nvl, &type, &cookie);
CHECK(name != NULL);
CHECK(type == NV_TYPE_NVLIST);
+   CHECK(strcmp(name, "nvlist/nvlist/empty") == 0);
+   cnvl = nvlist_get_nvlist(nvl, name);
+   CHECK(nvlist_empty(cnvl));
+
+   name = nvlist_next(nvl, &type, &cookie);
+   CHECK(name != NULL);
+   CHECK(type == NV_TYPE_NVLIST);
CHECK(strcmp(name, "nvlist/nvlist") == 0);
cnvl = nvlist_get_nvlist(nvl, name);
 
@@ -284,6 +294,13 @@ parent(int sock)
CHECK(size == sizeof("abcdefghijklmnopqrstuvwxyz"));
 
cname = nvlist_next(cnvl, &ctype, &ccookie);
+   CHECK(cname != NULL);
+   CHECK(ctype == NV_TYPE_NVLIST);
+   CHECK(strcmp(cname, "nvlist/nvlist/empty") == 0);
+   empty = nvlist_get_nvlist(cnvl, cname);
+   CHECK(nvlist_empty(empty));
+
+   cname = nvlist_next(cnvl, &ctype, &ccookie);
CHECK(cname == NULL);
 
name = nvlist_next(nvl, &type, &cookie);
@@ -296,7 +313,7 @@ main(void)
int status, socks[2];
pid_t pid;
 
-   printf("1..126\n");
+   printf("1..134\n");
fflush(stdout);
 
if (socketpair(PF_UNIX, SOCK_STREAM, 0, socks) < 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: r279431 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:03 2015
New Revision: 279431
URL: https://svnweb.freebsd.org/changeset/base/279431

Log:
  Add tests for dnvlist_take_*
  
  Differential Revision:https://reviews.freebsd.org/D1876
  Reviewed by:  jfv, pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/tests/dnv_tests.cc

Modified: head/lib/libnv/tests/dnv_tests.cc
==
--- head/lib/libnv/tests/dnv_tests.cc   Sun Mar  1 00:21:56 2015
(r279430)
+++ head/lib/libnv/tests/dnv_tests.cc   Sun Mar  1 00:22:03 2015
(r279431)
@@ -274,6 +274,278 @@ ATF_TEST_CASE_BODY(dnvlist_get_binary__d
nvlist_destroy(nvl);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_bool__present);
+ATF_TEST_CASE_BODY(dnvlist_take_bool__present)
+{
+   nvlist_t *nvl;
+   const char *key;
+   bool value;
+
+   nvl = nvlist_create(0);
+
+   key = "name";
+   value = true;
+   nvlist_add_bool(nvl, key, value);
+
+   ATF_REQUIRE_EQ(dnvlist_take_bool(nvl, key, false), value);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_bool__empty);
+ATF_TEST_CASE_BODY(dnvlist_take_bool__empty)
+{
+   nvlist_t *nvl;
+
+   nvl = nvlist_create(0);
+
+   ATF_REQUIRE_EQ(dnvlist_take_bool(nvl, "123", false), false);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_bool__default_value);
+ATF_TEST_CASE_BODY(dnvlist_take_bool__default_value)
+{
+   nvlist_t *nvl;
+
+   nvl = nvlist_create(0);
+   nvlist_add_bool(nvl, "key", true);
+
+   ATF_REQUIRE_EQ(dnvlist_take_bool(nvl, "otherkey", true), true);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_number__present);
+ATF_TEST_CASE_BODY(dnvlist_take_number__present)
+{
+   nvlist_t *nvl;
+   const char *key;
+   uint64_t value;
+
+   nvl = nvlist_create(0);
+
+   key = "name";
+   value = 194154;
+   nvlist_add_number(nvl, key, value);
+
+   ATF_REQUIRE_EQ(dnvlist_take_number(nvl, key, 2), value);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_number__empty);
+ATF_TEST_CASE_BODY(dnvlist_take_number__empty)
+{
+   nvlist_t *nvl;
+
+   nvl = nvlist_create(0);
+
+   ATF_REQUIRE_EQ(dnvlist_take_number(nvl, "123", 126484), 126484);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_number__default_value);
+ATF_TEST_CASE_BODY(dnvlist_take_number__default_value)
+{
+   nvlist_t *nvl;
+
+   nvl = nvlist_create(0);
+   nvlist_add_number(nvl, "key", 12);
+
+   ATF_REQUIRE_EQ(dnvlist_take_number(nvl, "otherkey", 13), 13);
+
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_string__present);
+ATF_TEST_CASE_BODY(dnvlist_take_string__present)
+{
+   nvlist_t *nvl;
+   const char *key;
+   const char *value;
+   char *default_val, *actual_val;
+
+   nvl = nvlist_create(0);
+
+   key = "name";
+   value = "wrowm";
+   default_val = strdup("default");
+   nvlist_add_string(nvl, key, value);
+
+   actual_val = dnvlist_take_string(nvl, key, default_val);
+   ATF_REQUIRE_EQ(strcmp(actual_val, value), 0);
+   ATF_REQUIRE(nvlist_empty(nvl));
+
+   free(actual_val);
+   free(default_val);
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_string__empty);
+ATF_TEST_CASE_BODY(dnvlist_take_string__empty)
+{
+   nvlist_t *nvl;
+   char *default_val, *actual_val;
+
+   nvl = nvlist_create(0);
+   default_val = strdup("");
+
+   actual_val = dnvlist_take_string(nvl, "123", default_val);
+   ATF_REQUIRE_EQ(strcmp(actual_val, default_val), 0);
+
+   free(actual_val);
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_string__default_value);
+ATF_TEST_CASE_BODY(dnvlist_take_string__default_value)
+{
+   nvlist_t *nvl;
+   char *default_val, *actual_val;
+
+   nvl = nvlist_create(0);
+   nvlist_add_string(nvl, "key", "foobar");
+   default_val = strdup("other");
+
+   actual_val = dnvlist_take_string(nvl, "otherkey", default_val);
+   ATF_REQUIRE_EQ(strcmp(actual_val, default_val), 0);
+
+   free(actual_val);
+   nvlist_destroy(nvl);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_take_nvlist__present);
+ATF_TEST_CASE_BODY(dnvlist_take_nvlist__present)
+{
+   nvlist_t *nvl;
+   const char *key;
+   nvlist_t *value, *default_val, *actual_val;
+
+   nvl = nvlist_create(0);
+
+   key = "name";
+   value = nvlist_create(0);
+   default_val = nvlist_create(0);
+   nvlist_move_nvlist(nvl, key, value);
+
+   actual_val = dnvlist_take_nvlist(nvl, key, default_val);
+   ATF_REQUIRE_EQ(actual_val, value);
+   ATF_REQUIRE(nv

svn commit: r279435 - head/lib/libnv

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:31 2015
New Revision: 279435
URL: https://svnweb.freebsd.org/changeset/base/279435

Log:
  Don't allocate memory for operations that do not insert
  
  Almost every operation performed on an nvlist was allocating a
  new string to hold the key name.  The nvlist_exists* family of
  functions would always return false if they failed to allocate
  the string.  The rest of the functions would outright abort().
  Fix the non-varargs variants of the functions to perform the
  requested operations directly and the varargs versions to
  allocate the string and call into the non-varargs versions.
  The varargs versions are still broken and really can't be fixed,
  so we might consider axing them entirely.  However, now the non-
  varargs functions are always safe to call.
  
  Differential Revision:https://reviews.freebsd.org/D1879
  Reviewed by:  pjd, jfv
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/dnvlist.c
  head/lib/libnv/nv_impl.h
  head/lib/libnv/nvlist.c

Modified: head/lib/libnv/dnvlist.c
==
--- head/lib/libnv/dnvlist.cSun Mar  1 00:22:23 2015(r279434)
+++ head/lib/libnv/dnvlist.cSun Mar  1 00:22:31 2015(r279435)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include "nv.h"
 #include "nv_impl.h"
@@ -44,7 +45,10 @@ ftype
\
 dnvlist_get_##type(const nvlist_t *nvl, const char *name, ftype defval)
\
 {  \
\
-   return (dnvlist_getf_##type(nvl, defval, "%s", name));  \
+   if (nvlist_exists_##type(nvl, name))\
+   return (nvlist_get_##type(nvl, name));  \
+   else\
+   return (defval);\
 }
 
 DNVLIST_GET(bool, bool)
@@ -59,8 +63,16 @@ const void *
 dnvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep,
 const void *defval, size_t defsize)
 {
+   const void *value;
 
-   return (dnvlist_getf_binary(nvl, sizep, defval, defsize, "%s", name));
+   if (nvlist_exists_binary(nvl, name))
+   value = nvlist_get_binary(nvl, name, sizep);
+   else {
+   if (sizep != NULL)
+   *sizep = defsize;
+   value = defval;
+   }
+   return (value);
 }
 
 #defineDNVLIST_GETF(ftype, type)   
\
@@ -106,15 +118,14 @@ ftype 
\
 dnvlist_getv_##type(const nvlist_t *nvl, ftype defval, \
 const char *namefmt, va_list nameap)   \
 {  \
-   va_list cnameap;\
+   char *name; \
ftype value;\
\
-   va_copy(cnameap, nameap);   \
-   if (nvlist_existsv_##type(nvl, namefmt, cnameap))   \
-   value = nvlist_getv_##type(nvl, namefmt, nameap);   \
-   else\
-   value = defval; \
-   va_end(cnameap);\
+   vasprintf(&name, namefmt, nameap);  \
+   if (name == NULL)   \
+   return (defval);\
+   value = dnvlist_get_##type(nvl, name, defval);  \
+   free(name); \
return (value); \
 }
 
@@ -130,18 +141,18 @@ const void *
 dnvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const void *defval,
 size_t defsize, const char *namefmt, va_list nameap)
 {
-   va_list cnameap;
+   char *name;
const void *value;
 
-   va_copy(cnameap, nameap);
-   if (nvlist_existsv_binary(nvl, namefmt, cnameap)) {
-   value = nvlist_getv_binary(nvl, sizep, namefmt, nameap);
+   vasprintf(&name, namefmt, nameap);
+   if (name != NULL) {
+   value = dnvlist_get_binary(nvl, name, sizep, defval, defsize);
+   free(name);
} else {
if (sizep != NULL)
 

svn commit: r279437 - head/sys/cddl/compat/opensolaris/sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:45 2015
New Revision: 279437
URL: https://svnweb.freebsd.org/changeset/base/279437

Log:
  Allow Illumos code to co-exist with nv(9)
  
  Differential Revision:https://reviews.freebsd.org/D1881
  Reviewed by:  jfv, will
  Suggested by: pjd
  MFC after:1 month
  Sponsored by: Sandvine Inc

Added:
  head/sys/cddl/compat/opensolaris/sys/nvpair.h   (contents, props changed)

Added: head/sys/cddl/compat/opensolaris/sys/nvpair.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/cddl/compat/opensolaris/sys/nvpair.h   Sun Mar  1 00:22:45 
2015(r279437)
@@ -0,0 +1,259 @@
+/*-
+ * Copyright (c) 2014 Sandvine Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _OPENSOLARIS_SYS_NVPAIR_H_
+#define _OPENSOLARIS_SYS_NVPAIR_H_
+
+/*
+ * Some of the symbols in the Illumos nvpair library conflict with symbols
+ * provided by nv(9), so we use this preprocessor hack to avoid the conflict.
+ *
+ * This list was generated by:
+ *   cat nv.h nv_impl.h nvlist_* nvpair_impl.h | \
+ * sed -nE 's/^[[:alnum:]_][[:alnum:]_ 
]*[[:space:]]+[*]*([[:alnum:]_]+)\(.*$/#define \1 illumos_\1/p' | \
+ * sort -u
+ */
+#define nvlist_add_binary illumos_nvlist_add_binary
+#define nvlist_add_bool illumos_nvlist_add_bool
+#define nvlist_add_descriptor illumos_nvlist_add_descriptor
+#define nvlist_add_null illumos_nvlist_add_null
+#define nvlist_add_number illumos_nvlist_add_number
+#define nvlist_add_nvlist illumos_nvlist_add_nvlist
+#define nvlist_add_nvpair illumos_nvlist_add_nvpair
+#define nvlist_add_string illumos_nvlist_add_string
+#define nvlist_add_stringf illumos_nvlist_add_stringf
+#define nvlist_add_stringv illumos_nvlist_add_stringv
+#define nvlist_addf_binary illumos_nvlist_addf_binary
+#define nvlist_addf_bool illumos_nvlist_addf_bool
+#define nvlist_addf_descriptor illumos_nvlist_addf_descriptor
+#define nvlist_addf_null illumos_nvlist_addf_null
+#define nvlist_addf_number illumos_nvlist_addf_number
+#define nvlist_addf_nvlist illumos_nvlist_addf_nvlist
+#define nvlist_addf_string illumos_nvlist_addf_string
+#define nvlist_addv_binary illumos_nvlist_addv_binary
+#define nvlist_addv_bool illumos_nvlist_addv_bool
+#define nvlist_addv_descriptor illumos_nvlist_addv_descriptor
+#define nvlist_addv_null illumos_nvlist_addv_null
+#define nvlist_addv_number illumos_nvlist_addv_number
+#define nvlist_addv_nvlist illumos_nvlist_addv_nvlist
+#define nvlist_addv_string illumos_nvlist_addv_string
+#define nvlist_check_header illumos_nvlist_check_header
+#define nvlist_clone illumos_nvlist_clone
+#define nvlist_create illumos_nvlist_create
+#define nvlist_descriptors illumos_nvlist_descriptors
+#define nvlist_destroy illumos_nvlist_destroy
+#define nvlist_dump illumos_nvlist_dump
+#define nvlist_empty illumos_nvlist_empty
+#define nvlist_error illumos_nvlist_error
+#define nvlist_exists illumos_nvlist_exists
+#define nvlist_exists_binary illumos_nvlist_exists_binary
+#define nvlist_exists_bool illumos_nvlist_exists_bool
+#define nvlist_exists_descriptor illumos_nvlist_exists_descriptor
+#define nvlist_exists_null illumos_nvlist_exists_null
+#define nvlist_exists_number illumos_nvlist_exists_number
+#define nvlist_exists_nvlist illumos_nvlist_exists_nvlist
+#define nvlist_exists_string illumos_nvlist_exists_string
+#define nvlist_exists_type illumos_nvlist_exists_type
+#define nvlist_existsf illumos_nvlist_existsf
+#define nvlist_existsf_binary illumos_nvlist_existsf_binary
+#define nvlist_existsf_bool 

svn commit: r279434 - in head/lib/libnv: . tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:23 2015
New Revision: 279434
URL: https://svnweb.freebsd.org/changeset/base/279434

Log:
  Add function to force an nvlist into the error state
  
  Add an nvlist_set_error() function that can be used to force an
  nvlist into the error state.  This is useful both for writing
  tests and for writing APIs that use nvlists internally.
  
  Differential Revision:https://reviews.freebsd.org/D1878
  Reviewed by:  pjd, jfv
  MFC After:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/lib/libnv/Makefile
  head/lib/libnv/nv.3
  head/lib/libnv/nv.h
  head/lib/libnv/nvlist.c
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/Makefile
==
--- head/lib/libnv/Makefile Sun Mar  1 00:22:16 2015(r279433)
+++ head/lib/libnv/Makefile Sun Mar  1 00:22:23 2015(r279434)
@@ -22,6 +22,7 @@ MLINKS+=nv.3 libnv.3 \
 MLINKS+=nv.3 nvlist_create.3 \
nv.3 nvlist_destroy.3 \
nv.3 nvlist_error.3 \
+   nv.3 nvlist_set_error.3 \
nv.3 nvlist_empty.3 \
nv.3 nvlist_clone.3 \
nv.3 nvlist_dump.3 \

Modified: head/lib/libnv/nv.3
==
--- head/lib/libnv/nv.3 Sun Mar  1 00:22:16 2015(r279433)
+++ head/lib/libnv/nv.3 Sun Mar  1 00:22:23 2015(r279434)
@@ -35,6 +35,7 @@
 .Nm nvlist_create ,
 .Nm nvlist_destroy ,
 .Nm nvlist_error ,
+.Nm nvlist_set_error ,
 .Nm nvlist_empty ,
 .Nm nvlist_exists ,
 .Nm nvlist_free ,
@@ -63,6 +64,8 @@
 .Fn nvlist_destroy "nvlist_t *nvl"
 .Ft int
 .Fn nvlist_error "const nvlist_t *nvl"
+.Ft void
+.Fn nvlist_set_error "nvlist_t *nvl, int error"
 .Ft bool
 .Fn nvlist_empty "const nvlist_t *nvl"
 .\"
@@ -248,8 +251,17 @@ the
 error will be returned.
 .Pp
 The
+.Fn nvlist_set_error
+function sets an nvlist to be in the error state.
+Subsequent calls to
+.Fn nvlist_error
+will return the given error value.
+This function cannot be used to clear the error state from an nvlist.
+This function does nothing if the nvlist is already in the error state.
+.Pp
+The
 .Fn nvlist_empty
-functions returns
+function returns
 .Dv true
 if the given nvlist is empty and
 .Dv false

Modified: head/lib/libnv/nv.h
==
--- head/lib/libnv/nv.h Sun Mar  1 00:22:16 2015(r279433)
+++ head/lib/libnv/nv.h Sun Mar  1 00:22:23 2015(r279434)
@@ -69,6 +69,7 @@ nvlist_t  *nvlist_create(int flags);
 voidnvlist_destroy(nvlist_t *nvl);
 int nvlist_error(const nvlist_t *nvl);
 boolnvlist_empty(const nvlist_t *nvl);
+voidnvlist_set_error(nvlist_t *nvl, int error);
 
 nvlist_t *nvlist_clone(const nvlist_t *nvl);
 

Modified: head/lib/libnv/nvlist.c
==
--- head/lib/libnv/nvlist.c Sun Mar  1 00:22:16 2015(r279433)
+++ head/lib/libnv/nvlist.c Sun Mar  1 00:22:23 2015(r279434)
@@ -137,6 +137,20 @@ nvlist_destroy(nvlist_t *nvl)
errno = serrno;
 }
 
+void
+nvlist_set_error(nvlist_t *nvl, int error)
+{
+
+   PJDLOG_ASSERT(error != 0);
+
+   /*
+* Check for error != 0 so that we don't do the wrong thing if somebody
+* tries to abuse this API when asserts are disabled.
+*/
+   if (nvl != NULL && error != 0 && nvl->nvl_error == 0)
+   nvl->nvl_error = error;
+}
+
 int
 nvlist_error(const nvlist_t *nvl)
 {

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:22:16 2015
(r279433)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:22:23 2015
(r279434)
@@ -409,6 +409,22 @@ ATF_TEST_CASE_BODY(nvlist_clone__nested_
nvlist_destroy(nvl);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_clone__error_nvlist);
+ATF_TEST_CASE_BODY(nvlist_clone__error_nvlist)
+{
+   nvlist_t *nvl, *clone;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   nvlist_set_error(nvl, ENOMEM);
+
+   clone = nvlist_clone(nvl);
+   ATF_REQUIRE(clone == NULL);
+
+   nvlist_destroy(nvl);
+}
+
 ATF_TEST_CASE_WITHOUT_HEAD(nvlist_pack__empty_nvlist);
 ATF_TEST_CASE_BODY(nvlist_pack__empty_nvlist)
 {
@@ -550,6 +566,24 @@ ATF_TEST_CASE_BODY(nvlist_pack__multiple
free(packed);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_pack__error_nvlist);
+ATF_TEST_CASE_BODY(nvlist_pack__error_nvlist)
+{
+   nvlist_t *nvl;
+   void *packed;
+   size_t size;
+
+   nvl = nvlist_create(0);
+   ATF_REQUIRE(nvl != NULL);
+
+   nvlist_set_error(nvl, ENOMEM);
+
+   packed = nvlist_pack(nvl, &size);
+   ATF_REQUIRE(packed == NULL);
+
+   nvlist_destroy(nvl);
+}
+
 ATF_TEST_CASE_W

svn commit: r279438 - head/lib/libnv

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:53 2015
New Revision: 279438
URL: https://svnweb.freebsd.org/changeset/base/279438

Log:
  Add macros to make code compile in kernel
  
  Make it possible to compile libnv in the kernel.  Mostly this
  involves wrapping functions that have a different signature in
  the kernel and in userland (e.g. malloc()) in a macro that will
  conditionally expand to the right API depending on whether the
  code is being compiled for the kernel or not.
  
  I have also #ifdef'ed out all of file descriptor-handling code,
  as well as the unsafe varargs functions.
  
  Differential Revision:https://reviews.freebsd.org/D1882
  Reviewed by:  jfv
  MFC after:1 month
  Sponsored by: Sandvine Inc

Modified:
  head/lib/libnv/dnv.h
  head/lib/libnv/dnvlist.c
  head/lib/libnv/nv.h
  head/lib/libnv/nv_impl.h
  head/lib/libnv/nvlist.c
  head/lib/libnv/nvlist_impl.h
  head/lib/libnv/nvpair.c
  head/lib/libnv/nvpair_impl.h

Modified: head/lib/libnv/dnv.h
==
--- head/lib/libnv/dnv.hSun Mar  1 00:22:45 2015(r279437)
+++ head/lib/libnv/dnv.hSun Mar  1 00:22:53 2015(r279438)
@@ -34,9 +34,11 @@
 
 #include 
 
+#ifndef _KERNEL
 #include 
 #include 
 #include 
+#endif
 
 #ifndef_NVLIST_T_DECLARED
 #define_NVLIST_T_DECLARED
@@ -62,6 +64,7 @@ const nvlist_t *dnvlist_get_nvlist(const
 int dnvlist_get_descriptor(const nvlist_t *nvl, const char *name, int defval);
 const void *dnvlist_get_binary(const nvlist_t *nvl, const char *name, size_t 
*sizep, const void *defval, size_t defsize);
 
+#ifndef _KERNEL
 bool dnvlist_getf_bool(const nvlist_t *nvl, bool defval, const char *namefmt, 
...) __printflike(3, 4);
 uint64_t dnvlist_getf_number(const nvlist_t *nvl, uint64_t defval, const char 
*namefmt, ...) __printflike(3, 4);
 const char *dnvlist_getf_string(const nvlist_t *nvl, const char *defval, const 
char *namefmt, ...) __printflike(3, 4);
@@ -75,6 +78,7 @@ const char *dnvlist_getv_string(const nv
 const nvlist_t *dnvlist_getv_nvlist(const nvlist_t *nvl, const nvlist_t 
*defval, const char *namefmt, va_list nameap) __printflike(3, 0);
 int dnvlist_getv_descriptor(const nvlist_t *nvl, int defval, const char 
*namefmt, va_list nameap) __printflike(3, 0);
 const void *dnvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const void 
*defval, size_t defsize, const char *namefmt, va_list nameap) __printflike(5, 
0);
+#endif
 
 /*
  * The dnvlist_take functions returns value associated with the given name and
@@ -91,6 +95,7 @@ nvlist_t *dnvlist_take_nvlist(nvlist_t *
 int dnvlist_take_descriptor(nvlist_t *nvl, const char *name, int defval);
 void *dnvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep, void 
*defval, size_t defsize);
 
+#ifndef _KERNEL
 bool dnvlist_takef_bool(nvlist_t *nvl, bool defval, const char *namefmt, ...) 
__printflike(3, 4);
 uint64_t dnvlist_takef_number(nvlist_t *nvl, uint64_t defval, const char 
*namefmt, ...) __printflike(3, 4);
 char *dnvlist_takef_string(nvlist_t *nvl, char *defval, const char *namefmt, 
...) __printflike(3, 4);
@@ -104,6 +109,7 @@ char *dnvlist_takev_string(nvlist_t *nvl
 nvlist_t *dnvlist_takev_nvlist(nvlist_t *nvl, nvlist_t *defval, const char 
*namefmt, va_list nameap) __printflike(3, 0);
 int dnvlist_takev_descriptor(nvlist_t *nvl, int defval, const char *namefmt, 
va_list nameap) __printflike(3, 0);
 void *dnvlist_takev_binary(nvlist_t *nvl, size_t *sizep, void *defval, size_t 
defsize, const char *namefmt, va_list nameap) __printflike(5, 0);
+#endif
 
 __END_DECLS
 

Modified: head/lib/libnv/dnvlist.c
==
--- head/lib/libnv/dnvlist.cSun Mar  1 00:22:45 2015(r279437)
+++ head/lib/libnv/dnvlist.cSun Mar  1 00:22:53 2015(r279438)
@@ -30,10 +30,22 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#ifdef _KERNEL
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#else
 #include 
 #include 
 #include 
 #include 
+#endif
 
 #include "nv.h"
 #include "nv_impl.h"
@@ -55,7 +67,9 @@ DNVLIST_GET(bool, bool)
 DNVLIST_GET(uint64_t, number)
 DNVLIST_GET(const char *, string)
 DNVLIST_GET(const nvlist_t *, nvlist)
+#ifndef _KERNEL
 DNVLIST_GET(int, descriptor)
+#endif
 
 #undef DNVLIST_GET
 
@@ -75,6 +89,7 @@ dnvlist_get_binary(const nvlist_t *nvl, 
return (value);
 }
 
+#ifndef _KERNEL
 #defineDNVLIST_GETF(ftype, type)   
\
 ftype  \
 dnvlist_getf_##type(const nvlist_t *nvl, ftype defval, \
@@ -144,10 +159,10 @@ dnvlist_getv_binary(const nvlist_t *nvl,
char *name;
const void *value;
 
-   vasprintf(&name, namefmt, nameap);
+   nv_vasprintf(&name, namefmt, nameap);
if (name != NULL) {
v

svn commit: r279436 - in head/lib/libnv: . tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:22:38 2015
New Revision: 279436
URL: https://svnweb.freebsd.org/changeset/base/279436

Log:
  Prevent creation of an invalid nvlist
  
  If an nvlist is set as a child of another nvlist with
  nvlist_move_nvlist then fail the operation and set the parent
  nvlist to the error state.
  
  Differential Revision:https://reviews.freebsd.org/D1880
  Reviewers:jfv
  MFC after:1 month
  Sponsored by: Sandvine Inc

Modified:
  head/lib/libnv/nvpair.c
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/nvpair.c
==
--- head/lib/libnv/nvpair.c Sun Mar  1 00:22:31 2015(r279435)
+++ head/lib/libnv/nvpair.c Sun Mar  1 00:22:38 2015(r279436)
@@ -1128,6 +1128,12 @@ nvpair_movev_nvlist(nvlist_t *value, con
return (NULL);
}
 
+   if (nvlist_error(value) != 0) {
+   errno = nvlist_error(value);
+   nvlist_destroy(value);
+   return (NULL);
+   }
+
nvp = nvpair_allocv(NV_TYPE_NVLIST, (uint64_t)(uintptr_t)value, 0,
namefmt, nameap);
if (nvp == NULL)

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:22:31 2015
(r279435)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:22:38 2015
(r279436)
@@ -243,6 +243,22 @@ ATF_TEST_CASE_BODY(nvlist_add_nvlist__si
nvlist_destroy(nvl);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_nvlist__child_with_error);
+ATF_TEST_CASE_BODY(nvlist_add_nvlist__child_with_error)
+{
+   nvlist_t *nvl, *parent;
+
+   nvl = nvlist_create(0);
+   parent = nvlist_create(0);
+
+   nvlist_set_error(nvl, EBADF);
+   nvlist_add_nvlist(parent, "test", nvl);
+   ATF_REQUIRE_EQ(nvlist_error(parent), EBADF);
+
+   nvlist_destroy(nvl);
+   nvlist_destroy(parent);
+}
+
 ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_binary__single_insert);
 ATF_TEST_CASE_BODY(nvlist_add_binary__single_insert)
 {
@@ -654,6 +670,21 @@ ATF_TEST_CASE_BODY(nvlist_move_nvlist__n
nvlist_destroy(parent);
 }
 
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_nvlist__child_with_error);
+ATF_TEST_CASE_BODY(nvlist_move_nvlist__child_with_error)
+{
+   nvlist_t *nvl, *parent;
+
+   nvl = nvlist_create(0);
+   parent = nvlist_create(0);
+
+   nvlist_set_error(nvl, EBADF);
+   nvlist_move_nvlist(parent, "test", nvl);
+   ATF_REQUIRE_EQ(nvlist_error(parent), EBADF);
+
+   nvlist_destroy(parent);
+}
+
 ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_nvlist__single_insert);
 ATF_TEST_CASE_BODY(nvlist_move_nvlist__single_insert)
 {
@@ -1177,6 +1208,7 @@ ATF_INIT_TEST_CASES(tp)
ATF_ADD_TEST_CASE(tp, nvlist_add_number__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_add_string__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_add_nvlist__single_insert);
+   ATF_ADD_TEST_CASE(tp, nvlist_add_nvlist__child_with_error);
ATF_ADD_TEST_CASE(tp, nvlist_add_binary__single_insert);
 
ATF_ADD_TEST_CASE(tp, nvlist_clone__empty_nvlist);
@@ -1192,6 +1224,7 @@ ATF_INIT_TEST_CASES(tp)
ATF_ADD_TEST_CASE(tp, nvlist_move_string__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__null_child);
+   ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__child_with_error);
ATF_ADD_TEST_CASE(tp, nvlist_move_binary__single_insert);
 
ATF_ADD_TEST_CASE(tp, nvlist_take_bool__single_remove);
___
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: r279439 - in head: lib/libnv sys/conf sys/kern sys/sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:34:27 2015
New Revision: 279439
URL: https://svnweb.freebsd.org/changeset/base/279439

Log:
  Move libnv into the kernel and hook it into the kernel build
  
  Differential Revision:https://reviews.freebsd.org/D1883
  Reviewed by:  jfv
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/sys/kern/subr_dnvlist.c
 - copied, changed from r279438, head/lib/libnv/dnvlist.c
  head/sys/kern/subr_nvlist.c
 - copied, changed from r279438, head/lib/libnv/nvlist.c
  head/sys/kern/subr_nvpair.c
 - copied, changed from r279438, head/lib/libnv/nvpair.c
  head/sys/sys/dnv.h
 - copied unchanged from r279438, head/lib/libnv/dnv.h
  head/sys/sys/nv.h
 - copied unchanged from r279438, head/lib/libnv/nv.h
  head/sys/sys/nv_impl.h
 - copied unchanged from r279438, head/lib/libnv/nv_impl.h
  head/sys/sys/nvlist_impl.h
 - copied unchanged from r279438, head/lib/libnv/nvlist_impl.h
  head/sys/sys/nvpair_impl.h
 - copied unchanged from r279438, head/lib/libnv/nvpair_impl.h
Deleted:
  head/lib/libnv/dnv.h
  head/lib/libnv/dnvlist.c
  head/lib/libnv/nv.h
  head/lib/libnv/nv_impl.h
  head/lib/libnv/nvlist.c
  head/lib/libnv/nvlist_impl.h
  head/lib/libnv/nvpair.c
  head/lib/libnv/nvpair_impl.h
Modified:
  head/lib/libnv/Makefile
  head/sys/conf/files

Modified: head/lib/libnv/Makefile
==
--- head/lib/libnv/Makefile Sun Mar  1 00:22:53 2015(r279438)
+++ head/lib/libnv/Makefile Sun Mar  1 00:34:27 2015(r279439)
@@ -7,10 +7,13 @@ SHLIBDIR?= /lib
 LIB=   nv
 SHLIB_MAJOR= 0
 
-SRCS=  dnvlist.c
+.PATH: ${.CURDIR}/../../sys/kern ${.CURDIR}/../../sys/sys
+CFLAGS+=-I${.CURDIR}/../../sys -I${.CURDIR}
+
+SRCS=  subr_dnvlist.c
 SRCS+= msgio.c
-SRCS+= nvlist.c
-SRCS+= nvpair.c
+SRCS+= subr_nvlist.c
+SRCS+= subr_nvpair.c
 
 INCS=  dnv.h
 INCS+= nv.h

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sun Mar  1 00:22:53 2015(r279438)
+++ head/sys/conf/files Sun Mar  1 00:34:27 2015(r279439)
@@ -3076,6 +3076,7 @@ kern/subr_clock.c standard
 kern/subr_counter.cstandard
 kern/subr_devstat.cstandard
 kern/subr_disk.c   standard
+kern/subr_dnvlist.cstandard
 kern/subr_eventhandler.c   standard
 kern/subr_fattime.cstandard
 kern/subr_firmware.c   optional firmware
@@ -3089,6 +3090,8 @@ kern/subr_mbpool.coptional libmbpool
 kern/subr_mchain.c optional libmchain
 kern/subr_module.c standard
 kern/subr_msgbuf.c standard
+kern/subr_nvlist.c standard
+kern/subr_nvpair.c standard
 kern/subr_param.c  standard
 kern/subr_pcpu.c   standard
 kern/subr_pctrie.c standard

Copied and modified: head/sys/kern/subr_dnvlist.c (from r279438, 
head/lib/libnv/dnvlist.c)
==
--- head/lib/libnv/dnvlist.cSun Mar  1 00:22:53 2015(r279438, copy 
source)
+++ head/sys/kern/subr_dnvlist.cSun Mar  1 00:34:27 2015
(r279439)
@@ -47,10 +47,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
-#include "nv.h"
-#include "nv_impl.h"
+#include 
+#include 
 
-#include "dnv.h"
+#include 
 
 #defineDNVLIST_GET(ftype, type)
\
 ftype  \

Copied and modified: head/sys/kern/subr_nvlist.c (from r279438, 
head/lib/libnv/nvlist.c)
==
--- head/lib/libnv/nvlist.c Sun Mar  1 00:22:53 2015(r279438, copy 
source)
+++ head/sys/kern/subr_nvlist.c Sun Mar  1 00:34:27 2015(r279439)
@@ -56,17 +56,18 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+
+#include "msgio.h"
 #endif
 
 #ifdef HAVE_PJDLOG
 #include 
 #endif
 
-#include "msgio.h"
-#include "nv.h"
-#include "nv_impl.h"
-#include "nvlist_impl.h"
-#include "nvpair_impl.h"
+#include 
+#include 
+#include 
+#include 
 
 #ifndefHAVE_PJDLOG
 #ifdef _KERNEL

Copied and modified: head/sys/kern/subr_nvpair.c (from r279438, 
head/lib/libnv/nvpair.c)
==
--- head/lib/libnv/nvpair.c Sun Mar  1 00:22:53 2015(r279438, copy 
source)
+++ head/sys/kern/subr_nvpair.c Sun Mar  1 00:34:27 2015(r279439)
@@ -52,17 +52,18 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+
+#include "common_impl.h"
 #endif
 
 #ifdef HAVE_PJDLOG
 #include 
 #endif
 
-#include "common_impl.h"
-#include "nv.h"
-#include "nv_impl.h"
-#include "nvlist_impl.h"
-#include "nvpair_impl.h"
+#include 
+#include 
+#include 
+#include 
 
 #ifndef

svn commit: r279440 - head/lib/libnv/tests

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:37:23 2015
New Revision: 279440
URL: https://svnweb.freebsd.org/changeset/base/279440

Log:
  Fix build of nv_tests.cc
  
  nv_tests.cc managed to get two copies of several functions due to me
  applying a patch in an unclean working tree.  My kingdom for an
  "svn clean" command.
  
  MFC after:1 month
  X-MFC-With:   r279424

Modified:
  head/lib/libnv/tests/nv_tests.cc

Modified: head/lib/libnv/tests/nv_tests.cc
==
--- head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:34:27 2015
(r279439)
+++ head/lib/libnv/tests/nv_tests.ccSun Mar  1 00:37:23 2015
(r279440)
@@ -1252,1779 +1252,3 @@ ATF_INIT_TEST_CASES(tp)
ATF_ADD_TEST_CASE(tp, nvlist_free_nvlist__single_nvlist);
ATF_ADD_TEST_CASE(tp, nvlist_free_binary__single_binary);
 }
-/*-
- * Copyright (c) 2014-2015 Sandvine Inc.  All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * 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 
-#include 
-
-#include 
-/*
- * Test that a newly created nvlist has no errors, and is empty.
- */
-ATF_TEST_CASE_WITHOUT_HEAD(nvlist_create__is_empty);
-ATF_TEST_CASE_BODY(nvlist_create__is_empty)
-{
-   nvlist_t *nvl;
-   int type;
-   void *it;
-
-   nvl = nvlist_create(0);
-
-   ATF_REQUIRE(nvl != NULL);
-
-   ATF_REQUIRE_EQ(nvlist_error(nvl), 0);
-   ATF_REQUIRE(nvlist_empty(nvl));
-
-   it = NULL;
-   ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &it), NULL);
-
-   nvlist_destroy(nvl);
-}
-
-ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_null__single_insert);
-ATF_TEST_CASE_BODY(nvlist_add_null__single_insert)
-{
-   nvlist_t *nvl;
-   void *it;
-   const char *key;
-   int type;
-
-   key = "key";
-   nvl = nvlist_create(0);
-
-   ATF_REQUIRE(nvl != NULL);
-   ATF_REQUIRE(!nvlist_exists(nvl, key));
-
-   nvlist_add_null(nvl, key);
-
-   ATF_REQUIRE(!nvlist_empty(nvl));
-   ATF_REQUIRE(nvlist_exists(nvl, key));
-   ATF_REQUIRE(nvlist_existsf(nvl, "%s", key));
-   ATF_REQUIRE(nvlist_exists_null(nvl, key));
-   ATF_REQUIRE(nvlist_existsf_null(nvl, "key"));
-
-   /* Iterate over the nvlist; ensure that it has only our one key. */
-   it = NULL;
-   ATF_REQUIRE_EQ(strcmp(nvlist_next(nvl, &type, &it), key), 0);
-   ATF_REQUIRE_EQ(type, NV_TYPE_NULL);
-   ATF_REQUIRE_EQ(nvlist_next(nvl, &type,&it), NULL);
-
-   nvlist_destroy(nvl);
-}
-
-ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_bool__single_insert);
-ATF_TEST_CASE_BODY(nvlist_add_bool__single_insert)
-{
-   nvlist_t *nvl;
-   void *it;
-   const char *key;
-   int type;
-
-   key = "name";
-   nvl = nvlist_create(0);
-
-   ATF_REQUIRE(nvl != NULL);
-   ATF_REQUIRE(!nvlist_exists(nvl, key));
-
-   nvlist_add_bool(nvl, key, true);
-
-   ATF_REQUIRE(!nvlist_empty(nvl));
-   ATF_REQUIRE(nvlist_exists(nvl, key));
-   ATF_REQUIRE(nvlist_existsf(nvl, "%s%s", "na", "me"));
-   ATF_REQUIRE(nvlist_exists_bool(nvl, key));
-   ATF_REQUIRE(nvlist_existsf_bool(nvl, "%s%c", "nam", 'e'));
-   ATF_REQUIRE_EQ(nvlist_get_bool(nvl, key), true);
-   ATF_REQUIRE_EQ(nvlist_getf_bool(nvl, "%c%s", 'n', "ame"), true);
-
-   /* Iterate over the nvlist; ensure that it has only our one key. */
-   it = NULL;
-   ATF_REQUIRE_EQ(strcmp(nvlist_next(nvl, &type, &it), key), 0);
-   ATF_REQUIRE_EQ(type, NV_TYPE_BOOL);
-   ATF_REQUIRE_EQ(nvlist_next(nvl, &type,&it), NULL);
-
-   nvlist_destroy(nvl);
-}
-
-ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_number__single_insert);
-ATF_TEST_CASE_BODY(nvlist_add_number__single_insert)
-{
-   nvlist_t *nvl;

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

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:39:55 2015
New Revision: 279445
URL: https://svnweb.freebsd.org/changeset/base/279445

Log:
  Document pci_iov_attach/detach in pci.9
  
  Differential Revision:https://reviews.freebsd.org/D74
  Reviewed by:  bcr, wblock, emaste
  MFC after:1 month
  Sponsored by: Sandvine Inc.

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

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileSun Mar  1 00:39:48 2015
(r279444)
+++ head/share/man/man9/MakefileSun Mar  1 00:39:55 2015
(r279445)
@@ -1159,6 +1159,8 @@ MLINKS+=pci.9 pci_alloc_msi.9 \
pci.9 pci_get_powerstate.9 \
pci.9 pci_get_vpd_ident.9 \
pci.9 pci_get_vpd_readonly.9 \
+   pci.9 pci_iov_attach.9 \
+   pci.9 pci_iov_detach.9 \
pci.9 pci_msi_count.9 \
pci.9 pci_msix_count.9 \
pci.9 pci_pending_msix.9 \

Modified: head/share/man/man9/pci.9
==
--- head/share/man/man9/pci.9   Sun Mar  1 00:39:48 2015(r279444)
+++ head/share/man/man9/pci.9   Sun Mar  1 00:39:55 2015(r279445)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 5, 2012
+.Dd May 24, 2014
 .Dt PCI 9
 .Os
 .Sh NAME
@@ -46,6 +46,8 @@
 .Nm pci_get_powerstate ,
 .Nm pci_get_vpd_ident ,
 .Nm pci_get_vpd_readonly ,
+.Nm pci_iov_attach ,
+.Nm pci_iov_detach ,
 .Nm pci_msi_count ,
 .Nm pci_msix_count ,
 .Nm pci_pending_msix ,
@@ -95,6 +97,10 @@
 .Ft int
 .Fn pci_get_vpd_readonly "device_t dev" "const char *kw" "const char **vptr"
 .Ft int
+.Fn pci_iov_attach "device_t dev" "nvlist_t *pf_schema" "nvlist_t *vf_schema"
+.Ft int
+.Fn pci_iov_detach "device_t dev"
+.Ft int
 .Fn pci_msi_count "device_t dev"
 .Ft int
 .Fn pci_msix_count "device_t dev"
@@ -434,6 +440,75 @@ then the function will fail with
 .Er EOPNOTSUPP .
 .Pp
 The
+.Fn pci_iov_attach
+function is used to advertise that the given device
+.Pq and associated device driver
+supports PCI Single-Root I/O Virtualization
+.Po SR-IOV Pc .
+A driver that supports SR-IOV must implement the
+.Xr PCI_INIT_IOV 9 ,
+.Xr PCI_ADD_VF 9
+and
+.Xr PCI_UNIT_IOV 9
+methods.
+This function should be called during the
+.Xr DEVICE_ATTACH 9
+method.
+If this function returns an error, it is recommended that the device driver
+still successfully attaches, but runs with SR-IOV disabled.
+The
+.Fa pf_schema
+and
+.Fa vf_schema
+parameters are used to define what device-specific configuration parameters the
+device driver accepts when SR-IOV is enabled for the Physical Function
+.Pq PF
+and for individual Virtual Functions
+.Pq VFs
+respectively.
+See
+.Xr pci_iov_schema 9
+for details on how to construct the schema.
+If either the
+.Pa pf_schema
+or
+.Pa vf_schema
+is invalid or specifies parameter names that conflict with parameter names that
+are already in use,
+.Fn pci_iov_attach
+will return an error and SR-IOV will not be available on the PF device.
+If a driver does not accept configuration parameters for either the PF device
+or the VF devices, the driver must pass an empty schema for that device.
+The SR-IOV infrastructure takes ownership of the
+.Fa pf_schema
+and
+.Fa vf_schema
+and is responsible for freeing them.
+The driver must never free the schemas itself.
+.Pp
+The
+.Fn pci_iov_detach
+function is used to advise the SR-IOV infrastructure that the driver for the
+given device is attempting to detach and that all SR-IOV resources for the
+device must be released.
+This function must be called during the
+.Xr DEVICE_DETACH 9
+method if
+.Fn pci_iov_attach
+was successfully called on the device and
+.Fn pci_iov_detach
+has not subsequently been called on the device and returned no error.
+If this function returns an error, the
+.Xr DEVICE_DETACH 9
+method must fail and return an error, as detaching the PF driver while VF
+devices are active would cause system instability.
+This function is safe to call and will always succeed if
+.Fn pci_iov_attach
+previously failed with an error on the given device, or if
+.Fn pci_iov_attach
+was never called on the device.
+.Pp
+The
 .Fn pci_save_state
 and
 .Fn pci_restore_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"


svn commit: r279441 - head/sys/dev/pci

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:39:26 2015
New Revision: 279441
URL: https://svnweb.freebsd.org/changeset/base/279441

Log:
  Refactor PCI device creation
  
  Refactor creation of PCI devices into helper methods that can be
  used by the VF creation code.
  
  Differential Revision:https://reviews.freebsd.org/D67
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci.c

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Sun Mar  1 00:37:23 2015(r279440)
+++ head/sys/dev/pci/pci.c  Sun Mar  1 00:39:26 2015(r279441)
@@ -122,6 +122,9 @@ static int  pci_remap_intr_method(device
 
 static uint16_tpci_get_rid_method(device_t dev, device_t 
child);
 
+static struct pci_devinfo * pci_fill_devinfo(device_t pcib, int d, int b, int 
s,
+int f, uint16_t vid, uint16_t did, size_t size);
+
 static device_method_t pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pci_probe),
@@ -595,74 +598,82 @@ struct pci_devinfo *
 pci_read_device(device_t pcib, int d, int b, int s, int f, size_t size)
 {
 #defineREG(n, w)   PCIB_READ_CONFIG(pcib, b, s, f, n, w)
-   pcicfgregs *cfg = NULL;
-   struct pci_devinfo *devlist_entry;
-   struct devlist *devlist_head;
+   uint16_t vid, did;
 
-   devlist_head = &pci_devq;
+   vid = REG(PCIR_VENDOR, 2);
+   did = REG(PCIR_DEVICE, 2);
+   if (vid != 0x)
+   return (pci_fill_devinfo(pcib, d, b, s, f, vid, did, size));
+
+   return (NULL);
+}
+
+static struct pci_devinfo *
+pci_fill_devinfo(device_t pcib, int d, int b, int s, int f, uint16_t vid,
+uint16_t did, size_t size)
+{
+   struct pci_devinfo *devlist_entry;
+   pcicfgregs *cfg;
 
-   devlist_entry = NULL;
+   devlist_entry = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
 
-   if (REG(PCIR_DEVVENDOR, 4) != 0xul) {
-   devlist_entry = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
+   cfg = &devlist_entry->cfg;
 
-   cfg = &devlist_entry->cfg;
+   cfg->domain = d;
+   cfg->bus= b;
+   cfg->slot   = s;
+   cfg->func   = f;
+   cfg->vendor = vid;
+   cfg->device = did;
+   cfg->cmdreg = REG(PCIR_COMMAND, 2);
+   cfg->statreg= REG(PCIR_STATUS, 2);
+   cfg->baseclass  = REG(PCIR_CLASS, 1);
+   cfg->subclass   = REG(PCIR_SUBCLASS, 1);
+   cfg->progif = REG(PCIR_PROGIF, 1);
+   cfg->revid  = REG(PCIR_REVID, 1);
+   cfg->hdrtype= REG(PCIR_HDRTYPE, 1);
+   cfg->cachelnsz  = REG(PCIR_CACHELNSZ, 1);
+   cfg->lattimer   = REG(PCIR_LATTIMER, 1);
+   cfg->intpin = REG(PCIR_INTPIN, 1);
+   cfg->intline= REG(PCIR_INTLINE, 1);
+
+   cfg->mingnt = REG(PCIR_MINGNT, 1);
+   cfg->maxlat = REG(PCIR_MAXLAT, 1);
+
+   cfg->mfdev  = (cfg->hdrtype & PCIM_MFDEV) != 0;
+   cfg->hdrtype&= ~PCIM_MFDEV;
+   STAILQ_INIT(&cfg->maps);
+
+   pci_fixancient(cfg);
+   pci_hdrtypedata(pcib, b, s, f, cfg);
+
+   if (REG(PCIR_STATUS, 2) & PCIM_STATUS_CAPPRESENT)
+   pci_read_cap(pcib, cfg);
+
+   STAILQ_INSERT_TAIL(&pci_devq, devlist_entry, pci_links);
+
+   devlist_entry->conf.pc_sel.pc_domain = cfg->domain;
+   devlist_entry->conf.pc_sel.pc_bus = cfg->bus;
+   devlist_entry->conf.pc_sel.pc_dev = cfg->slot;
+   devlist_entry->conf.pc_sel.pc_func = cfg->func;
+   devlist_entry->conf.pc_hdr = cfg->hdrtype;
+
+   devlist_entry->conf.pc_subvendor = cfg->subvendor;
+   devlist_entry->conf.pc_subdevice = cfg->subdevice;
+   devlist_entry->conf.pc_vendor = cfg->vendor;
+   devlist_entry->conf.pc_device = cfg->device;
+
+   devlist_entry->conf.pc_class = cfg->baseclass;
+   devlist_entry->conf.pc_subclass = cfg->subclass;
+   devlist_entry->conf.pc_progif = cfg->progif;
+   devlist_entry->conf.pc_revid = cfg->revid;
 
-   cfg->domain = d;
-   cfg->bus= b;
-   cfg->slot   = s;
-   cfg->func   = f;
-   cfg->vendor = REG(PCIR_VENDOR, 2);
-   cfg->device = REG(PCIR_DEVICE, 2);
-   cfg->cmdreg = REG(PCIR_COMMAND, 2);
-   cfg->statreg= REG(PCIR_STATUS, 2);
-   cfg->baseclass  = REG(PCIR_CLASS, 1);
-   cfg->subclass   = REG(PCIR_SUBCLASS, 1);
-   cfg->progif = REG(PCIR_PROGIF, 1);
-   cfg->revid  = REG(PCIR_REVID, 1);
-   

svn commit: r279443 - head/sys/dev/pci

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:39:40 2015
New Revision: 279443
URL: https://svnweb.freebsd.org/changeset/base/279443

Log:
  Add some pcib methods to get ARI-related information
  
  Differential Revision:https://reviews.freebsd.org/D72
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci_pci.c
  head/sys/dev/pci/pcib_if.m
  head/sys/dev/pci/pcib_private.h
  head/sys/dev/pci/pcib_support.c
  head/sys/dev/pci/pcireg.h

Modified: head/sys/dev/pci/pci_pci.c
==
--- head/sys/dev/pci/pci_pci.c  Sun Mar  1 00:39:33 2015(r279442)
+++ head/sys/dev/pci/pci_pci.c  Sun Mar  1 00:39:40 2015(r279443)
@@ -64,6 +64,9 @@ static void   pcib_write_config(device_t 
 static int pcib_ari_maxslots(device_t dev);
 static int pcib_ari_maxfuncs(device_t dev);
 static int pcib_try_enable_ari(device_t pcib, device_t dev);
+static int pcib_ari_enabled(device_t pcib);
+static voidpcib_ari_decode_rid(device_t pcib, uint16_t rid,
+   int *bus, int *slot, int *func);
 
 static device_method_t pcib_methods[] = {
 /* Device interface */
@@ -104,6 +107,8 @@ static device_method_t pcib_methods[] = 
 DEVMETHOD(pcib_power_for_sleep,pcib_power_for_sleep),
 DEVMETHOD(pcib_get_rid,pcib_ari_get_rid),
 DEVMETHOD(pcib_try_enable_ari, pcib_try_enable_ari),
+DEVMETHOD(pcib_ari_enabled,pcib_ari_enabled),
+DEVMETHOD(pcib_decode_rid, pcib_ari_decode_rid),
 
 DEVMETHOD_END
 };
@@ -1883,6 +1888,24 @@ pcib_ari_maxfuncs(device_t dev)
return (PCI_FUNCMAX);
 }
 
+static void
+pcib_ari_decode_rid(device_t pcib, uint16_t rid, int *bus, int *slot,
+int *func)
+{
+   struct pcib_softc *sc;
+
+   sc = device_get_softc(pcib);
+
+   *bus = PCI_RID2BUS(rid);
+   if (sc->flags & PCIB_ENABLE_ARI) {
+   *slot = PCIE_ARI_RID2SLOT(rid);
+   *func = PCIE_ARI_RID2FUNC(rid);
+   } else {
+   *slot = PCI_RID2SLOT(rid);
+   *func = PCI_RID2FUNC(rid);
+   }
+}
+
 /*
  * Since we are a child of a PCI bus, its parent must support the pcib 
interface.
  */
@@ -2014,6 +2037,16 @@ pcib_power_for_sleep(device_t pcib, devi
return (PCIB_POWER_FOR_SLEEP(bus, dev, pstate));
 }
 
+static int
+pcib_ari_enabled(device_t pcib)
+{
+   struct pcib_softc *sc;
+
+   sc = device_get_softc(pcib);
+
+   return ((sc->flags & PCIB_ENABLE_ARI) != 0);
+}
+
 static uint16_t
 pcib_ari_get_rid(device_t pcib, device_t dev)
 {

Modified: head/sys/dev/pci/pcib_if.m
==
--- head/sys/dev/pci/pcib_if.m  Sun Mar  1 00:39:33 2015(r279442)
+++ head/sys/dev/pci/pcib_if.m  Sun Mar  1 00:39:40 2015(r279443)
@@ -39,6 +39,13 @@ CODE {
{
return (PCI_INVALID_IRQ);
}
+
+   static int
+   pcib_null_ari_enabled(device_t pcib)
+   {
+
+   return (0);
+   }
 };
 
 #
@@ -182,3 +189,21 @@ METHOD int try_enable_ari {
device_tdev;
 };
 
+#
+# Return non-zero if PCI ARI is enabled, or zero otherwise
+#
+METHOD int ari_enabled {
+   device_tpcib;
+} DEFAULT pcib_null_ari_enabled;
+
+#
+# Decode a PCI Routing Identifier (RID) into PCI bus/slot/function
+#
+METHOD void decode_rid {
+   device_tpcib;
+   uint16_trid;
+   int *bus;
+   int *slot;
+   int *func;
+} DEFAULT pcib_decode_rid;
+

Modified: head/sys/dev/pci/pcib_private.h
==
--- head/sys/dev/pci/pcib_private.h Sun Mar  1 00:39:33 2015
(r279442)
+++ head/sys/dev/pci/pcib_private.h Sun Mar  1 00:39:40 2015
(r279443)
@@ -170,5 +170,7 @@ int pcib_alloc_msix(device_t pcib, devi
 intpcib_release_msix(device_t pcib, device_t dev, int irq);
 intpcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t 
*addr, uint32_t *data);
 uint16_t   pcib_get_rid(device_t pcib, device_t dev);
+void   pcib_decode_rid(device_t pcib, uint16_t rid, int *bus, 
+   int *slot, int *func);
 
 #endif

Modified: head/sys/dev/pci/pcib_support.c
==
--- head/sys/dev/pci/pcib_support.c Sun Mar  1 00:39:33 2015
(r279442)
+++ head/sys/dev/pci/pcib_support.c Sun Mar  1 00:39:40 2015
(r279443)
@@ -66,3 +66,13 @@ pcib_get_rid(device_t pcib, device_t dev
return (PCI_RID(bus, slot, func));
 }
 
+void
+pcib_decode_rid(device_t pcib, uint16_t rid, int *bus, int *slot,
+int *func)
+{
+
+   *bus = PCI_RID2BUS(rid);
+   *slot = PCI_RID2SLOT(rid);
+  

svn commit: r279444 - in head/sys/amd64/vmm: . io

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:39:48 2015
New Revision: 279444
URL: https://svnweb.freebsd.org/changeset/base/279444

Log:
  Allow passthrough devices to be hinted.
  
  Allow the ppt driver to attach to devices that were hinted to be
  passthrough devices by the PCI code creating them with a driver
  name of "ppt".
  
  Add a tunable that allows the IOMMU to be forced to be used.  With
  SR-IOV passthrough devices the VFs may be created after vmm.ko is
  loaded.  The current code will not initialize the IOMMU in that
  case, meaning that the passthrough devices can't actually be used.
  
  Differential Revision:https://reviews.freebsd.org/D73
  Reviewed by:  neel
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/amd64/vmm/io/ppt.c
  head/sys/amd64/vmm/vmm.c

Modified: head/sys/amd64/vmm/io/ppt.c
==
--- head/sys/amd64/vmm/io/ppt.c Sun Mar  1 00:39:40 2015(r279443)
+++ head/sys/amd64/vmm/io/ppt.c Sun Mar  1 00:39:48 2015(r279444)
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
 
 /* XXX locking */
 
-#defineMAX_PPTDEVS (sizeof(pptdevs) / sizeof(pptdevs[0]))
 #defineMAX_MSIMSGS 32
 
 /*
@@ -77,9 +76,10 @@ struct pptintr_arg { /* pptintr(pptin
uint64_tmsg_data;
 };
 
-static struct pptdev {
+struct pptdev {
device_tdev;
struct vm   *vm;/* owner of this device */
+   TAILQ_ENTRY(pptdev) next;
struct vm_memory_segment mmio[MAX_MMIOSEGS];
struct {
int num_msgs;   /* guest state */
@@ -99,7 +99,7 @@ static struct pptdev {
void **cookie;
struct pptintr_arg *arg;
} msix;
-} pptdevs[64];
+};
 
 SYSCTL_DECL(_hw_vmm);
 SYSCTL_NODE(_hw_vmm, OID_AUTO, ppt, CTLFLAG_RW, 0, "bhyve passthru devices");
@@ -108,6 +108,8 @@ static int num_pptdevs;
 SYSCTL_INT(_hw_vmm_ppt, OID_AUTO, devices, CTLFLAG_RD, &num_pptdevs, 0,
 "number of pci passthru devices");
 
+static TAILQ_HEAD(, pptdev) pptdev_list = TAILQ_HEAD_INITIALIZER(pptdev_list);
+
 static int
 ppt_probe(device_t dev)
 {
@@ -125,26 +127,30 @@ ppt_probe(device_t dev)
 * - be allowed by administrator to be used in this role
 * - be an endpoint device
 */
-   if (vmm_is_pptdev(bus, slot, func) &&
-   (dinfo->cfg.hdrtype & PCIM_HDRTYPE) == PCIM_HDRTYPE_NORMAL)
+   if ((dinfo->cfg.hdrtype & PCIM_HDRTYPE) != PCIM_HDRTYPE_NORMAL)
+   return (ENXIO);
+   else if (vmm_is_pptdev(bus, slot, func))
return (0);
else
-   return (ENXIO);
+   /*
+* Returning BUS_PROBE_NOWILDCARD here matches devices that the
+* SR-IOV infrastructure specified as "ppt" passthrough devices.
+* All normal devices that did not have "ppt" specified as their
+* driver will not be matched by this.
+*/
+   return (BUS_PROBE_NOWILDCARD);
 }
 
 static int
 ppt_attach(device_t dev)
 {
-   int n;
+   struct pptdev *ppt;
 
-   if (num_pptdevs >= MAX_PPTDEVS) {
-   printf("ppt_attach: maximum number of pci passthrough devices "
-  "exceeded\n");
-   return (ENXIO);
-   }
+   ppt = device_get_softc(dev);
 
-   n = num_pptdevs++;
-   pptdevs[n].dev = dev;
+   num_pptdevs++;
+   TAILQ_INSERT_TAIL(&pptdev_list, ppt, next);
+   ppt->dev = dev;
 
if (bootverbose)
device_printf(dev, "attached\n");
@@ -155,10 +161,14 @@ ppt_attach(device_t dev)
 static int
 ppt_detach(device_t dev)
 {
-   /*
-* XXX check whether there are any pci passthrough devices assigned
-* to guests before we allow this driver to detach.
-*/
+   struct pptdev *ppt;
+
+   ppt = device_get_softc(dev);
+
+   if (ppt->vm != NULL)
+   return (EBUSY);
+   num_pptdevs--;
+   TAILQ_REMOVE(&pptdev_list, ppt, next);
 
return (0);
 }
@@ -172,22 +182,23 @@ static device_method_t ppt_methods[] = {
 };
 
 static devclass_t ppt_devclass;
-DEFINE_CLASS_0(ppt, ppt_driver, ppt_methods, 0);
+DEFINE_CLASS_0(ppt, ppt_driver, ppt_methods, sizeof(struct pptdev));
 DRIVER_MODULE(ppt, pci, ppt_driver, ppt_devclass, NULL, NULL);
 
 static struct pptdev *
 ppt_find(int bus, int slot, int func)
 {
device_t dev;
-   int i, b, s, f;
+   struct pptdev *ppt;
+   int b, s, f;
 
-   for (i = 0; i < num_pptdevs; i++) {
-   dev = pptdevs[i].dev;
+   TAILQ_FOREACH(ppt, &pptdev_list, next) {
+   dev = ppt->dev;
b = pci_get_bus(dev);
s = pci_get_slot(dev);
f = pci_get_function(dev);
if (bus == b && slot == s && func == f)
-   return (&pptdevs

svn commit: r279442 - head/sys/dev/pci

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:39:33 2015
New Revision: 279442
URL: https://svnweb.freebsd.org/changeset/base/279442

Log:
  Refactor PCI resource allocation
  
  Refactor PCI resource allocation code to allow a request for a
  memory-mapped I/O window that is a multiple of a requested size.
  This is needed by the SR-IOV code because the VF BARs are all
  allocated contiguously.  We can't just allocate a resource that is
  a multiple of a single VF BAR because the size of an allocation
  implies its alignment requirement.
  
  Differential Revision:https://reviews.freebsd.org/D71
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci.c
  head/sys/dev/pci/pci_private.h

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Sun Mar  1 00:39:26 2015(r279441)
+++ head/sys/dev/pci/pci.c  Sun Mar  1 00:39:33 2015(r279442)
@@ -78,7 +78,6 @@ __FBSDID("$FreeBSD$");
 static int pci_has_quirk(uint32_t devid, int quirk);
 static pci_addr_t  pci_mapbase(uint64_t mapreg);
 static const char  *pci_maptype(uint64_t mapreg);
-static int pci_mapsize(uint64_t testval);
 static int pci_maprange(uint64_t mapreg);
 static pci_addr_t  pci_rombase(uint64_t mapreg);
 static int pci_romsize(uint64_t testval);
@@ -487,7 +486,7 @@ pci_maptype(uint64_t mapreg)
 
 /* return log2 of map size decoded for memory or port map */
 
-static int
+int
 pci_mapsize(uint64_t testval)
 {
int ln2size;
@@ -2620,8 +2619,9 @@ pci_memen(device_t dev)
return (pci_read_config(dev, PCIR_COMMAND, 2) & PCIM_CMD_MEMEN) != 0;
 }
 
-static void
-pci_read_bar(device_t dev, int reg, pci_addr_t *mapp, pci_addr_t *testvalp)
+void
+pci_read_bar(device_t dev, int reg, pci_addr_t *mapp, pci_addr_t *testvalp,
+int *bar64)
 {
struct pci_devinfo *dinfo;
pci_addr_t map, testval;
@@ -2641,6 +2641,8 @@ pci_read_bar(device_t dev, int reg, pci_
pci_write_config(dev, reg, map, 4);
*mapp = map;
*testvalp = testval;
+   if (bar64 != NULL)
+   *bar64 = 0;
return;
}
 
@@ -2682,6 +2684,8 @@ pci_read_bar(device_t dev, int reg, pci_
 
*mapp = map;
*testvalp = testval;
+   if (bar64 != NULL)
+   *bar64 = (ln2range == 64);
 }
 
 static void
@@ -2736,7 +2740,7 @@ pci_bar_enabled(device_t dev, struct pci
return ((cmd & PCIM_CMD_PORTEN) != 0);
 }
 
-static struct pci_map *
+struct pci_map *
 pci_add_bar(device_t dev, int reg, pci_addr_t value, pci_addr_t size)
 {
struct pci_devinfo *dinfo;
@@ -2807,7 +2811,7 @@ pci_add_map(device_t bus, device_t dev, 
return (barlen);
}
 
-   pci_read_bar(dev, reg, &map, &testval);
+   pci_read_bar(dev, reg, &map, &testval, NULL);
if (PCI_BAR_MEM(map)) {
type = SYS_RES_MEMORY;
if (map & PCIM_BAR_MEM_PREFETCH)
@@ -4463,7 +4467,7 @@ DB_SHOW_COMMAND(pciregs, db_pci_dump)
 
 static struct resource *
 pci_reserve_map(device_t dev, device_t child, int type, int *rid,
-u_long start, u_long end, u_long count, u_int flags)
+u_long start, u_long end, u_long count, u_int num, u_int flags)
 {
struct pci_devinfo *dinfo = device_get_ivars(child);
struct resource_list *rl = &dinfo->resources;
@@ -4487,7 +4491,7 @@ pci_reserve_map(device_t dev, device_t c
 * have a atapci device in legacy mode and it fails
 * here, that other code is broken.
 */
-   pci_read_bar(child, *rid, &map, &testval);
+   pci_read_bar(child, *rid, &map, &testval, NULL);
 
/*
 * Determine the size of the BAR and ignore BARs with a size
@@ -4529,7 +4533,7 @@ pci_reserve_map(device_t dev, device_t c
 * situation where we might allocate the excess to
 * another driver, which won't work.
 */
-   count = (pci_addr_t)1 << mapsize;
+   count = ((pci_addr_t)1 << mapsize) * num;
if (RF_ALIGNMENT(flags) < mapsize)
flags = (flags & ~RF_ALIGNMENT_MASK) | 
RF_ALIGNMENT_LOG2(mapsize);
if (PCI_BAR_MEM(map) && (map & PCIM_BAR_MEM_PREFETCH))
@@ -4560,8 +4564,8 @@ out:
 }
 
 struct resource *
-pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
-  u_long start, u_long end, u_long count, u_int flags)
+pci_alloc_multi_resource(device_t dev, device_t child, int type, int *rid,
+u_long start, u_long end, u_long count, u_long num, u_int flags)
 {
struct pci_devinfo *dinfo;
struct resource_list *rl;
@@ -4569,10 +4573,6 @@ pci_alloc_resource(device_t dev, device_
struct resource *res;
pcicfgregs *cfg;
 
-   if (device_get_parent(child) != dev)

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

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:01 2015
New Revision: 279446
URL: https://svnweb.freebsd.org/changeset/base/279446

Log:
  Add manpages for SR-IOV enable/disable driver interface
  
  Differential Revision:https://reviews.freebsd.org/D75
  Reviewed by:  wblock
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/share/man/man9/PCI_ADD_VF.9   (contents, props changed)
  head/share/man/man9/PCI_INIT_IOV.9   (contents, props changed)
  head/share/man/man9/PCI_UNINIT_IOV.9   (contents, props changed)
Modified:
  head/share/man/man9/Makefile

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileSun Mar  1 00:39:55 2015
(r279445)
+++ head/share/man/man9/MakefileSun Mar  1 00:40:01 2015
(r279446)
@@ -195,6 +195,9 @@ MAN=accept_filter.9 \
p_candebug.9 \
p_cansee.9 \
pci.9 \
+   PCI_ADD_VF.9 \
+   PCI_INIT_IOV.9 \
+   PCI_UNINIT_IOV.9 \
pfil.9 \
pfind.9 \
pget.9 \

Added: head/share/man/man9/PCI_ADD_VF.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/PCI_ADD_VF.9Sun Mar  1 00:40:01 2015
(r279446)
@@ -0,0 +1,113 @@
+.\"
+.\" Copyright (c) 2014 Sandvine Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 24, 2014
+.Dt PCI_ADD_VF 9
+.Os
+.Sh NAME
+.Nm PCI_ADD_VF
+.Nd inform a PF driver that a VF is being created
+.Sh SYNOPSIS
+.In sys/bus.h
+.In machine/stdarg.h
+.In sys/nv.h
+.In dev/pci/pcireg.h
+.In dev/pci/pcivar.h
+.Ft int
+.Fn PCI_ADD_VF "device_t dev" "uint16_t vfnum" "const nvlist_t *vf_config"
+.Sh DESCRIPTION
+The
+.Fn PCI_ADD_VF
+method is called by the PCI Single-Root I/O Virtualization
+.Pq SR-IOV
+infrastructure when it is initializating a new Virtual Function (VF) as a child
+of the given Physical Function (PF) device.
+This method will not be called until a successful call to
+.Xr PCI_INIT_IOV 9
+has been made.
+It is not guaranteed that this method will be called following a successful 
call
+to
+.Xr PCI_INIT_IOV 9 .
+If the infrastructure encounters a failure to allocate resources following the
+call to
+.Xr PCI_INIT_IOV 9 ,
+the VF creation will be aborted and
+.Xr PCI_UNINIT_IOV 9
+will be called immediately without any preceding calls to
+.Nm .
+.Pp
+The index of the VF being initialized is passed in the
+.Fa vfnum
+argument.
+VFs are always numbered sequentially starting at 0.
+.Pp
+If the driver requested device-specific configuration parameters via a VF 
schema
+in its call to
+.Xr pci_iov_attach 9 ,
+those parameters will be contained in the
+.Pa vf_config
+argument.
+All configuration parameters that were either set as required parameters or 
that
+had a default value set in the VF schema are guaranteed to be present in
+.Fa vf_config .
+Configuration parameters that were neither set as required nor were given a
+default value are optional and may or may not be present in
+.Fa vf_config .
+.Fa vf_config
+will not contain any configuration parameters that were not specified in the VF
+schema.
+All configuration parameters will have the correct type and will be in the 
range
+of valid values specified in the schema.
+.Pp
+Note that it is possible for the user to set different configuration values on
+different VF devices that are children of the same PF.
+The PF driver must not cache configuration parameters passed in previous calls
+to
+.Fn PCI_ADD_VF
+for other VFs and apply those parameters to t

svn commit: r279449 - head/sys/dev/pci

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:26 2015
New Revision: 279449
URL: https://svnweb.freebsd.org/changeset/base/279449

Log:
  Allocate PCI I/O memory spaces for VFs
  
  When creating VFs, we must size each SR-IOV BAR on the PF and
  allocate a configuous I/O memory window large enough for every VF.
  However, the window only needs to be aligned to a boundary equal
  to the size of the window for a single VF.
  
  When a VF attempts to allocate an I/O memory resource, we must
  intercept the request in the pci driver and pass it off to the
  SR-IOV code, which will allocate the correct window from the
  pre-allocated memory space for the PF.
  
  Inform the pci driver about the size and address of the BARs on
  the VF when the VF is created.  This is required by pciconf -b and
  bhyve.
  
  Differential Revision:https://reviews.freebsd.org/D78
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci.c
  head/sys/dev/pci/pci_iov.c
  head/sys/dev/pci/pci_iov_private.h
  head/sys/dev/pci/pci_private.h
  head/sys/dev/pci/pcivar.h

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Sun Mar  1 00:40:19 2015(r279448)
+++ head/sys/dev/pci/pci.c  Sun Mar  1 00:40:26 2015(r279449)
@@ -4695,11 +4695,30 @@ struct resource *
 pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
 u_long start, u_long end, u_long count, u_int flags)
 {
+#ifdef PCI_IOV
+   struct pci_devinfo *dinfo;
+#endif
 
if (device_get_parent(child) != dev)
return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
type, rid, start, end, count, flags));
 
+#ifdef PCI_IOV
+   dinfo = device_get_ivars(child);
+   if (dinfo->cfg.flags & PCICFG_VF) {
+   switch (type) {
+   /* VFs can't have I/O BARs. */
+   case SYS_RES_IOPORT:
+   return (NULL);
+   case SYS_RES_MEMORY:
+   return (pci_vf_alloc_mem_resource(dev, child, rid,
+   start, end, count, flags));
+   }
+
+   /* Fall through for other types of resource allocations. */
+   }
+#endif
+
return (pci_alloc_multi_resource(dev, child, type, rid, start, end,
count, 1, flags));
 }
@@ -4718,6 +4737,22 @@ pci_release_resource(device_t dev, devic
 
dinfo = device_get_ivars(child);
cfg = &dinfo->cfg;
+
+#ifdef PCI_IOV
+   if (dinfo->cfg.flags & PCICFG_VF) {
+   switch (type) {
+   /* VFs can't have I/O BARs. */
+   case SYS_RES_IOPORT:
+   return (EDOOFUS);
+   case SYS_RES_MEMORY:
+   return (pci_vf_release_mem_resource(dev, child, rid,
+   r));
+   }
+
+   /* Fall through for other types of resource allocations. */
+   }
+#endif
+
 #ifdef NEW_PCIB
/*
 * PCI-PCI bridge I/O window resources are not BARs.  For

Modified: head/sys/dev/pci/pci_iov.c
==
--- head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:19 2015(r279448)
+++ head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:26 2015(r279449)
@@ -106,7 +106,6 @@ pci_iov_attach_method(device_t bus, devi
error = EBUSY;
goto cleanup;
}
-
iov->iov_pos = iov_pos;
 
iov->iov_cdev = make_dev(&iov_cdevsw, device_get_unit(dev),
@@ -162,6 +161,56 @@ pci_iov_detach_method(device_t bus, devi
return (0);
 }
 
+static int
+pci_iov_alloc_bar(struct pci_devinfo *dinfo, int bar, pci_addr_t bar_shift)
+{
+   struct resource *res;
+   struct pcicfg_iov *iov;
+   device_t dev, bus;
+   u_long start, end;
+   pci_addr_t bar_size;
+   int rid;
+
+   iov = dinfo->cfg.iov;
+   dev = dinfo->cfg.dev;
+   bus = device_get_parent(dev);
+   rid = iov->iov_pos + PCIR_SRIOV_BAR(bar);
+   bar_size = 1 << bar_shift;
+
+   res = pci_alloc_multi_resource(bus, dev, SYS_RES_MEMORY, &rid, 0ul,
+   ~0ul, 1, iov->iov_num_vfs, RF_ACTIVE);
+
+   if (res == NULL)
+   return (ENXIO);
+
+   iov->iov_bar[bar].res = res;
+   iov->iov_bar[bar].bar_size = bar_size;
+   iov->iov_bar[bar].bar_shift = bar_shift;
+
+   start = rman_get_start(res);
+   end = rman_get_end(res);
+   return (rman_manage_region(&iov->rman, start, end));
+}
+
+static void
+pci_iov_add_bars(struct pcicfg_iov *iov, struct pci_devinfo *dinfo)
+{
+   struct pci_iov_bar *bar;
+   uint64_t bar_start;
+   int i;
+
+   for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
+   bar = &iov->iov_bar[i];
+   if (bar->res != NULL) {
+   bar_start = rman_get_start(bar->

svn commit: r279447 - in head/sys: amd64/conf conf dev/acpica dev/pci i386/conf sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:09 2015
New Revision: 279447
URL: https://svnweb.freebsd.org/changeset/base/279447

Log:
  Implement interface to create SR-IOV Virtual Functions
  
  Implement the interace to create SR-IOV Virtual Functions (VFs).
  When a driver registers that they support SR-IOV by calling
  pci_setup_iov(), the SR-IOV code creates a new node in /dev/iov
  for that device.  An ioctl can be invoked on that device to
  create VFs and have the driver initialize them.
  
  At this point, allocating memory I/O windows (BARs) is not
  supported.
  
  Differential Revision:https://reviews.freebsd.org/D76
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/sys/dev/pci/pci_iov.c   (contents, props changed)
  head/sys/dev/pci/pci_iov_private.h   (contents, props changed)
  head/sys/sys/iov.h   (contents, props changed)
Modified:
  head/sys/amd64/conf/GENERIC
  head/sys/conf/files
  head/sys/conf/options
  head/sys/dev/acpica/acpi_pci.c
  head/sys/dev/pci/pci.c
  head/sys/dev/pci/pci_if.m
  head/sys/dev/pci/pci_private.h
  head/sys/dev/pci/pcireg.h
  head/sys/dev/pci/pcivar.h
  head/sys/i386/conf/GENERIC

Modified: head/sys/amd64/conf/GENERIC
==
--- head/sys/amd64/conf/GENERIC Sun Mar  1 00:40:01 2015(r279446)
+++ head/sys/amd64/conf/GENERIC Sun Mar  1 00:40:09 2015(r279447)
@@ -97,6 +97,7 @@ devicecpufreq
 device acpi
 optionsACPI_DMAR
 device pci
+optionsPCI_IOV # PCI SR-IOV support
 
 # Floppy drives
 device fdc

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sun Mar  1 00:40:01 2015(r279446)
+++ head/sys/conf/files Sun Mar  1 00:40:09 2015(r279447)
@@ -2031,6 +2031,7 @@ dev/pci/ignore_pci.c  optional pci
 dev/pci/isa_pci.c  optional pci isa
 dev/pci/pci.c  optional pci
 dev/pci/pci_if.m   standard
+dev/pci/pci_iov.c  optional pci pci_iov
 dev/pci/pci_pci.c  optional pci
 dev/pci/pci_subr.c optional pci
 dev/pci/pci_user.c optional pci

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Sun Mar  1 00:40:01 2015(r279446)
+++ head/sys/conf/options   Sun Mar  1 00:40:09 2015(r279447)
@@ -173,6 +173,7 @@ NO_SYSCTL_DESCR opt_global.h
 NSWBUF_MIN opt_swap.h
 MBUF_PACKET_ZONE_DISABLE   opt_global.h
 PANIC_REBOOT_WAIT_TIME opt_panic.h
+PCI_IOVopt_global.h
 PPC_DEBUG  opt_ppc.h
 PPC_PROBE_CHIPSET  opt_ppc.h
 PPS_SYNC   opt_ntp.h

Modified: head/sys/dev/acpica/acpi_pci.c
==
--- head/sys/dev/acpica/acpi_pci.c  Sun Mar  1 00:40:01 2015
(r279446)
+++ head/sys/dev/acpica/acpi_pci.c  Sun Mar  1 00:40:09 2015
(r279447)
@@ -84,6 +84,11 @@ static int   acpi_pci_set_powerstate_metho
 static voidacpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child);
 static bus_dma_tag_t acpi_pci_get_dma_tag(device_t bus, device_t child);
 
+#ifdef PCI_IOV
+static device_tacpi_pci_create_iov_child(device_t bus, device_t pf,
+   uint16_t rid, uint16_t vid, uint16_t did);
+#endif
+
 static device_method_t acpi_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, acpi_pci_probe),
@@ -98,6 +103,9 @@ static device_method_t acpi_pci_methods[
 
/* PCI interface */
DEVMETHOD(pci_set_powerstate,   acpi_pci_set_powerstate_method),
+#ifdef PCI_IOV
+   DEVMETHOD(pci_create_iov_child, acpi_pci_create_iov_child),
+#endif
 
DEVMETHOD_END
 };
@@ -345,3 +353,23 @@ acpi_pci_get_dma_tag(device_t bus, devic
return (pci_get_dma_tag(bus, child));
 }
 #endif
+
+#ifdef PCI_IOV
+static device_t
+acpi_pci_create_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t 
vid,
+uint16_t did)
+{
+   struct acpi_pci_devinfo *dinfo;
+   device_t vf;
+
+   vf = pci_add_iov_child(bus, pf, sizeof(struct acpi_pci_devinfo), rid,
+   vid, did);
+   if (vf == NULL)
+   return (NULL);
+
+   dinfo = device_get_ivars(vf);
+   dinfo->ap_handle = NULL;
+   return (vf);
+}
+#endif
+

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Sun Mar  1 00:40:01 2015(r279446)
+++ head/sys/dev/pci/pci.c  Sun Mar  1 00:40:09 2015(r279447)
@@ -189,6 +189,11 @@ static device_method_t pci_methods[] = {
DEVMETHOD(pci_msix_count,   pci_msix_count_method),
DEVMETHOD(pci_get_rid,  pci_get_rid_method),
 

svn commit: r279451 - in head/sys: conf dev/pci sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:42 2015
New Revision: 279451
URL: https://svnweb.freebsd.org/changeset/base/279451

Log:
  Add infrastructure for exporting config schema from PF drivers
  
  Differential Revision:https://reviews.freebsd.org/D80
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/sys/dev/pci/pci_iov_schema.c   (contents, props changed)
  head/sys/dev/pci/schema_private.h   (contents, props changed)
  head/sys/sys/iov_schema.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/pci/pci_if.m
  head/sys/dev/pci/pci_iov.c
  head/sys/dev/pci/pci_iov_private.h
  head/sys/dev/pci/pci_private.h
  head/sys/dev/pci/pcivar.h
  head/sys/sys/iov.h

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sun Mar  1 00:40:34 2015(r279450)
+++ head/sys/conf/files Sun Mar  1 00:40:42 2015(r279451)
@@ -2032,6 +2032,7 @@ dev/pci/isa_pci.c optional pci isa
 dev/pci/pci.c  optional pci
 dev/pci/pci_if.m   standard
 dev/pci/pci_iov.c  optional pci pci_iov
+dev/pci/pci_iov_schema.c   optional pci pci_iov
 dev/pci/pci_pci.c  optional pci
 dev/pci/pci_subr.c optional pci
 dev/pci/pci_user.c optional pci

Modified: head/sys/dev/pci/pci_if.m
==
--- head/sys/dev/pci/pci_if.m   Sun Mar  1 00:40:34 2015(r279450)
+++ head/sys/dev/pci/pci_if.m   Sun Mar  1 00:40:42 2015(r279451)
@@ -46,6 +46,10 @@ CODE {
}
 };
 
+HEADER {
+   struct nvlist;
+}
+
 
 METHOD u_int32_t read_config {
device_tdev;
@@ -201,6 +205,8 @@ METHOD void child_added {
 METHOD int iov_attach {
device_tdev;
device_tchild;
+   struct nvlist   *pf_schema;
+   struct nvlist   *vf_schema;
 };
 
 METHOD int iov_detach {

Modified: head/sys/dev/pci/pci_iov.c
==
--- head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:34 2015(r279450)
+++ head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:42 2015(r279451)
@@ -46,11 +46,16 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
+
+#include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "pci_if.h"
 #include "pcib_if.h"
@@ -71,18 +76,30 @@ static struct cdevsw iov_cdevsw = {
 #define IOV_WRITE(d, r, v, w) \
pci_write_config((d)->cfg.dev, (d)->cfg.iov->iov_pos + r, v, w)
 
+static nvlist_t*pci_iov_build_schema(nvlist_t **pf_schema,
+   nvlist_t **vf_schema);
+static voidpci_iov_build_pf_schema(nvlist_t *schema,
+   nvlist_t **driver_schema);
+static voidpci_iov_build_vf_schema(nvlist_t *schema,
+   nvlist_t **driver_schema);
+static nvlist_t*pci_iov_get_pf_subsystem_schema(void);
+static nvlist_t*pci_iov_get_vf_subsystem_schema(void);
+
 int
-pci_iov_attach_method(device_t bus, device_t dev)
+pci_iov_attach_method(device_t bus, device_t dev, nvlist_t *pf_schema,
+nvlist_t *vf_schema)
 {
device_t pcib;
struct pci_devinfo *dinfo;
struct pcicfg_iov *iov;
+   nvlist_t *schema;
uint32_t version;
int error;
int iov_pos;
 
dinfo = device_get_ivars(dev);
pcib = device_get_parent(bus);
+   schema = NULL;

error = pci_find_extcap(dev, PCIZ_SRIOV, &iov_pos);
 
@@ -108,6 +125,13 @@ pci_iov_attach_method(device_t bus, devi
}
iov->iov_pos = iov_pos;
 
+   schema = pci_iov_build_schema(&pf_schema, &vf_schema);
+   if (schema == NULL) {
+   error = ENOMEM;
+   goto cleanup;
+   }
+   iov->iov_schema = schema;
+
iov->iov_cdev = make_dev(&iov_cdevsw, device_get_unit(dev),
UID_ROOT, GID_WHEEL, 0600, "iov/%s", device_get_nameunit(dev));
 
@@ -123,6 +147,9 @@ pci_iov_attach_method(device_t bus, devi
return (0);
 
 cleanup:
+   nvlist_destroy(schema);
+   nvlist_destroy(pf_schema);
+   nvlist_destroy(vf_schema);
free(iov, M_SRIOV);
mtx_unlock(&Giant);
return (error);
@@ -154,6 +181,7 @@ pci_iov_detach_method(device_t bus, devi
destroy_dev(iov->iov_cdev);
iov->iov_cdev = NULL;
}
+   nvlist_destroy(iov->iov_schema);
 
free(iov, M_SRIOV);
mtx_unlock(&Giant);
@@ -161,6 +189,115 @@ pci_iov_detach_method(device_t bus, devi
return (0);
 }
 
+static nvlist_t *
+pci_iov_build_schema(nvlist_t **pf, nvlist_t **vf)
+{
+   nvlist_t *schema, *pf_driver, *vf_driver;
+
+   /* We always take ownership of the schemas. */
+   pf_driver = *pf;
+   *pf = NULL;
+   vf_driver = *vf;
+   *vf = NULL;
+
+   schema = pci_iov_schema_alloc_node();
+   if (

svn commit: r279452 - in head/sys: dev/pci sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:51 2015
New Revision: 279452
URL: https://svnweb.freebsd.org/changeset/base/279452

Log:
  Add function to validate the consistency of SR-IOV config
  
  Add a function that validates that the user-provided SR-IOV
  configuration is valid.  This includes basic checks that the
  structure of the configuration is correct (e.g. all required
  configuration nodes are present) as well as validating against
  a configuration schema.
  
  The schema validation consists of:
   - Ensuring that all required config parameters are present.
   - If the schema defines a default value for a parameter,
 adding the default value if the parameter is not set.
   - Ensuring that no parameters are specified in the config
 that are not defined in the schema.
   - Ensuring that have the correct type defined in the schema.
   - Ensuring that no configuration nodes are present for devices
 that do not exist.  For example, if 2 VFs are configured,
 then we validate that a node called VF-5 does not exist.
  
  Differential Revision:https://reviews.freebsd.org/D81
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci_iov_schema.c
  head/sys/sys/iov.h

Modified: head/sys/dev/pci/pci_iov_schema.c
==
--- head/sys/dev/pci/pci_iov_schema.c   Sun Mar  1 00:40:42 2015
(r279451)
+++ head/sys/dev/pci/pci_iov_schema.c   Sun Mar  1 00:40:51 2015
(r279452)
@@ -29,47 +29,72 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
 #include 
 
+#include 
 #include 
 #include 
 
+#include 
+
 #include 
 
-static const char *pci_iov_schema_valid_types[] = {
-   "bool",
-   "string",
-   "uint8_t",
-   "uint16_t",
-   "uint32_t",
-   "uint64_t",
-   "unicast-mac",
+struct config_type_validator;
+typedef int (validate_func)(const struct config_type_validator *,
+   const nvlist_t *, const char *name);
+
+static validate_func pci_iov_schema_validate_bool;
+static validate_func pci_iov_schema_validate_string;
+static validate_func pci_iov_schema_validate_uint;
+static validate_func pci_iov_schema_validate_unicast_mac;
+
+struct config_type_validator {
+   const char *type_name;
+   validate_func *validate;
+   uintmax_t limit;
 };
 
-static void
-pci_iov_schema_add_type(nvlist_t *entry, const char *type)
+static struct config_type_validator pci_iov_schema_validators[] = {
+   { "bool", pci_iov_schema_validate_bool },
+   { "string", pci_iov_schema_validate_string },
+   { "uint8_t", pci_iov_schema_validate_uint, UINT8_MAX },
+   { "uint16_t", pci_iov_schema_validate_uint, UINT16_MAX },
+   { "uint32_t", pci_iov_schema_validate_uint, UINT32_MAX },
+   { "uint64_t", pci_iov_schema_validate_uint, UINT64_MAX },
+   { "unicast-mac", pci_iov_schema_validate_unicast_mac },
+};
+
+static const struct config_type_validator *
+pci_iov_schema_find_validator(const char *type)
 {
-   int i, error;
+   struct config_type_validator *validator;
+   int i;
 
-   error = EINVAL;
-   for (i = 0; i < nitems(pci_iov_schema_valid_types); i++) {
-   if (strcmp(type, pci_iov_schema_valid_types[i]) == 0) {
-   error = 0;
-   break;
-   }
+   for (i = 0; i < nitems(pci_iov_schema_validators); i++) {
+   validator = &pci_iov_schema_validators[i];
+   if (strcmp(type, validator->type_name) == 0)
+   return (validator);
}
 
-   if (error != 0) {
-   nvlist_set_error(entry, error);
+   return (NULL);
+}
+
+static void
+pci_iov_schema_add_type(nvlist_t *entry, const char *type)
+{
+
+   if (pci_iov_schema_find_validator(type) == NULL) {
+   nvlist_set_error(entry, EINVAL);
return;
}
-
nvlist_add_string(entry, "type", type);
 }
 
@@ -199,10 +224,385 @@ pci_iov_schema_add_unicast_mac(nvlist_t 
nvlist_move_nvlist(schema, name, entry);
 }
 
+static int
+pci_iov_schema_validate_bool(const struct config_type_validator * validator,
+   const nvlist_t *config, const char *name)
+{
+
+   if (!nvlist_exists_bool(config, name))
+   return (EINVAL);
+   return (0);
+}
+
+static int
+pci_iov_schema_validate_string(const struct config_type_validator * validator,
+   const nvlist_t *config, const char *name)
+{
+
+   if (!nvlist_exists_string(config, name))
+   return (EINVAL);
+   return (0);
+}
+
+static int
+pci_iov_schema_validate_uint(const struct config_type_validator * validator,
+   const nvlist_t *config, const char *name)
+{
+   uint64_t value;
+
+   if (!nvlist_exists_number(config, name))
+   return (EINVAL);
+
+   value = nvlist_get_number(config

svn commit: r279448 - head/sys/dev/pci

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:19 2015
New Revision: 279448
URL: https://svnweb.freebsd.org/changeset/base/279448

Log:
  Emulate the Device ID and Vendor ID registers for VFs
  
  The SR-IOV standard requires VFs to read all-ones when the VID
  and DID registers are read.  The VMM (hypervisor) is required to
  emulate them instead.  Make pci_read_config() do this emulation.
  
  Change pci_user.c to use pci_read_config() to read config space
  registers instead of going directly to the pcib so that the
  emulated VID/DID registers work correctly on VFs.  This is
  required both for pciconf and bhyve PCI passthrough.
  
  Differential Revision:https://reviews.freebsd.org/D77
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci.c
  head/sys/dev/pci/pci_user.c

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Sun Mar  1 00:40:09 2015(r279447)
+++ head/sys/dev/pci/pci.c  Sun Mar  1 00:40:19 2015(r279448)
@@ -4880,6 +4880,37 @@ pci_read_config_method(device_t dev, dev
struct pci_devinfo *dinfo = device_get_ivars(child);
pcicfgregs *cfg = &dinfo->cfg;
 
+#ifdef PCI_IOV
+   /*
+* SR-IOV VFs don't implement the VID or DID registers, so we have to
+* emulate them here.
+*/
+   if (cfg->flags & PCICFG_VF) {
+   if (reg == PCIR_VENDOR) {
+   switch (width) {
+   case 4:
+   return (cfg->device << 16 | cfg->vendor);
+   case 2:
+   return (cfg->vendor);
+   case 1:
+   return (cfg->vendor & 0xff);
+   default:
+   return (0x);
+   }
+   } else if (reg == PCIR_DEVICE) {
+   switch (width) {
+   /* Note that an unaligned 4-byte read is an error. */
+   case 2:
+   return (cfg->device);
+   case 1:
+   return (cfg->device & 0xff);
+   default:
+   return (0x);
+   }
+   }
+   }
+#endif
+
return (PCIB_READ_CONFIG(device_get_parent(dev),
cfg->bus, cfg->slot, cfg->func, reg, width));
 }

Modified: head/sys/dev/pci/pci_user.c
==
--- head/sys/dev/pci/pci_user.c Sun Mar  1 00:40:09 2015(r279447)
+++ head/sys/dev/pci/pci_user.c Sun Mar  1 00:40:19 2015(r279448)
@@ -492,7 +492,7 @@ pci_list_vpd(device_t dev, struct pci_li
 static int
 pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread 
*td)
 {
-   device_t pcidev, brdev;
+   device_t pcidev;
void *confdata;
const char *name;
struct devlist *devlist_head;
@@ -922,37 +922,25 @@ getconfexit:
io->pi_sel.pc_bus, io->pi_sel.pc_dev,
io->pi_sel.pc_func);
if (pcidev) {
-   brdev = device_get_parent(
-   device_get_parent(pcidev));
-
 #ifdef PRE7_COMPAT
if (cmd == PCIOCWRITE || cmd == PCIOCWRITE_OLD)
 #else
if (cmd == PCIOCWRITE)
 #endif
-   PCIB_WRITE_CONFIG(brdev,
- io->pi_sel.pc_bus,
- io->pi_sel.pc_dev,
- io->pi_sel.pc_func,
+   pci_write_config(pcidev,
  io->pi_reg,
  io->pi_data,
  io->pi_width);
 #ifdef PRE7_COMPAT
else if (cmd == PCIOCREAD_OLD)
io_old->pi_data =
-   PCIB_READ_CONFIG(brdev,
- io->pi_sel.pc_bus,
- io->pi_sel.pc_dev,
- io->pi_sel.pc_func,
+   pci_read_config(pcidev,
  io->pi_reg,
  io->pi_width);
 #endif
else
io->pi_data =
-  

svn commit: r279453 - in head/sys: dev/pci sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:57 2015
New Revision: 279453
URL: https://svnweb.freebsd.org/changeset/base/279453

Log:
  Pass SR-IOV configuration to kernel using an nvlist
  
  Pass all SR-IOV configuration to the kernel using an nvlist.  The
  main benefit that this offers is flexibility.  It allows a driver
  to accept any number of parameters of any type supported by the
  SR-IOV configuration infrastructure with having to make any
  changes outside of the driver.
  
  It also offers the user very fine-grained control over the
  configuration of the VFs -- if they want, they can have different
  configuration applied to every VF.
  
  Differential Revision:https://reviews.freebsd.org/D82
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci_if.m
  head/sys/dev/pci/pci_iov.c
  head/sys/sys/iov.h

Modified: head/sys/dev/pci/pci_if.m
==
--- head/sys/dev/pci/pci_if.m   Sun Mar  1 00:40:51 2015(r279452)
+++ head/sys/dev/pci/pci_if.m   Sun Mar  1 00:40:57 2015(r279453)
@@ -217,6 +217,7 @@ METHOD int iov_detach {
 METHOD int init_iov {
device_tdev;
uint16_tnum_vfs;
+   const struct nvlist *config;
 };
 
 METHOD void uninit_iov {
@@ -226,6 +227,7 @@ METHOD void uninit_iov {
 METHOD int add_vf {
device_tdev;
uint16_tvfnum;
+   const struct nvlist *config;
 };
 
 METHOD device_t create_iov_child {

Modified: head/sys/dev/pci/pci_iov.c
==
--- head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:51 2015(r279452)
+++ head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:57 2015(r279453)
@@ -70,6 +70,18 @@ static struct cdevsw iov_cdevsw = {
.d_ioctl = pci_iov_ioctl
 };
 
+SYSCTL_DECL(_hw_pci);
+
+/*
+ * The maximum amount of memory we will allocate for user configuration of an
+ * SR-IOV device.  1MB ought to be enough for anyone, but leave this 
+ * configurable just in case.
+ */
+static u_long pci_iov_max_config = 1024 * 1024;
+SYSCTL_ULONG(_hw_pci, OID_AUTO, iov_max_config, CTLFLAG_RWTUN,
+&pci_iov_max_config, 0, "Maximum allowed size of SR-IOV configuration.");
+
+
 #define IOV_READ(d, r, w) \
pci_read_config((d)->cfg.dev, (d)->cfg.iov->iov_pos + r, w)
 
@@ -348,6 +360,51 @@ pci_iov_add_bars(struct pcicfg_iov *iov,
}
 }
 
+static int
+pci_iov_parse_config(struct pcicfg_iov *iov, struct pci_iov_arg *arg,
+nvlist_t **ret)
+{
+   void *packed_config;
+   nvlist_t *config;
+   int error;
+
+   config = NULL;
+   packed_config = NULL;
+
+   if (arg->len > pci_iov_max_config) {
+   error = EMSGSIZE;
+   goto out;
+   }
+
+   packed_config = malloc(arg->len, M_SRIOV, M_WAITOK);
+
+   error = copyin(arg->config, packed_config, arg->len);
+   if (error != 0)
+   goto out;
+
+   config = nvlist_unpack(packed_config, arg->len);
+   if (config == NULL) {
+   error = EINVAL;
+   goto out;
+   }
+
+   error = pci_iov_schema_validate_config(iov->iov_schema, config);
+   if (error != 0)
+   goto out;
+
+   error = nvlist_error(config);
+   if (error != 0)
+   goto out;
+
+   *ret = config;
+   config = NULL;
+
+out:
+   nvlist_destroy(config);
+   free(packed_config, M_SRIOV);
+   return (error);
+}
+
 /*
  * Set the ARI_EN bit in the lowest-numbered PCI function with the SR-IOV
  * capability.  This bit is only writeable on the lowest-numbered PF but
@@ -422,6 +479,16 @@ pci_iov_config_page_size(struct pci_devi
 }
 
 static int
+pci_init_iov(device_t dev, uint16_t num_vfs, const nvlist_t *config)
+{
+   const nvlist_t *device, *driver_config;
+
+   device = nvlist_get_nvlist(config, PF_CONFIG_NAME);
+   driver_config = nvlist_get_nvlist(device, DRIVER_CONFIG_NAME);
+   return (PCI_INIT_IOV(dev, num_vfs, driver_config));
+}
+
+static int
 pci_iov_init_rman(device_t pf, struct pcicfg_iov *iov)
 {
int error;
@@ -479,9 +546,11 @@ pci_iov_setup_bars(struct pci_devinfo *d
 }
 
 static void
-pci_iov_enumerate_vfs(struct pci_devinfo *dinfo, const char *driver,
+pci_iov_enumerate_vfs(struct pci_devinfo *dinfo, const nvlist_t *config,
 uint16_t first_rid, uint16_t rid_stride)
 {
+   char device_name[VF_MAX_NAME];
+   const nvlist_t *device, *driver_config, *iov_config;
device_t bus, dev, vf;
struct pcicfg_iov *iov;
struct pci_devinfo *vfinfo;
@@ -498,12 +567,23 @@ pci_iov_enumerate_vfs(struct pci_devinfo
did = IOV_READ(dinfo, PCIR_SRIOV_VF_DID, 2);
 
for (i = 0; i < iov->iov_num_vfs; i++, next_rid += rid_stride) {
-
+   snprintf(device_name, sizeof(device_name), VF_PREFIX"%d", i);
+

svn commit: r279450 - in head/sys: dev/pci sys

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:40:34 2015
New Revision: 279450
URL: https://svnweb.freebsd.org/changeset/base/279450

Log:
  Add interface to destroy SR-IOV VFs
  
  Differential Revision:https://reviews.freebsd.org/D79
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci_iov.c
  head/sys/dev/pci/pci_iov_private.h
  head/sys/sys/iov.h

Modified: head/sys/dev/pci/pci_iov.c
==
--- head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:26 2015(r279449)
+++ head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:40:34 2015(r279450)
@@ -143,7 +143,7 @@ pci_iov_detach_method(device_t bus, devi
return (0);
}
 
-   if (iov->iov_num_vfs != 0) {
+   if (iov->iov_num_vfs != 0 || iov->iov_flags & IOV_BUSY) {
mtx_unlock(&Giant);
return (EBUSY);
}
@@ -405,10 +405,11 @@ pci_iov_config(struct cdev *cdev, struct
bus = device_get_parent(dev);
iov_inited = 0;
 
-   if (iov->iov_num_vfs != 0) {
+   if ((iov->iov_flags & IOV_BUSY) || iov->iov_num_vfs != 0) {
mtx_unlock(&Giant);
return (EBUSY);
}
+   iov->iov_flags |= IOV_BUSY;
 
total_vfs = IOV_READ(dinfo, PCIR_SRIOV_TOTAL_VFS, 2);
 
@@ -498,10 +499,113 @@ out:
iov->iov_flags &= ~IOV_RMAN_INITED;
}
iov->iov_num_vfs = 0;
+   iov->iov_flags &= ~IOV_BUSY;
mtx_unlock(&Giant);
return (error);
 }
 
+/* Return true if child is a VF of the given PF. */
+static int
+pci_iov_is_child_vf(struct pcicfg_iov *pf, device_t child)
+{
+   struct pci_devinfo *vfinfo;
+
+   vfinfo = device_get_ivars(child);
+
+   if (!(vfinfo->cfg.flags & PCICFG_VF))
+   return (0);
+
+   return (pf == vfinfo->cfg.iov);
+}
+
+static int
+pci_iov_delete(struct cdev *cdev)
+{
+   device_t bus, dev, vf, *devlist;
+   struct pci_devinfo *dinfo;
+   struct pcicfg_iov *iov;
+   int i, error, devcount;
+   uint32_t iov_ctl;
+
+   mtx_lock(&Giant);
+   dinfo = cdev->si_drv1;
+   iov = dinfo->cfg.iov;
+   dev = dinfo->cfg.dev;
+   bus = device_get_parent(dev);
+   devlist = NULL;
+
+   if (iov->iov_flags & IOV_BUSY) {
+   mtx_unlock(&Giant);
+   return (EBUSY);
+   }
+
+   if (iov->iov_num_vfs == 0) {
+   mtx_unlock(&Giant);
+   return (ECHILD);
+   }
+
+   iov->iov_flags |= IOV_BUSY;
+
+   error = device_get_children(bus, &devlist, &devcount);
+
+   if (error != 0)
+   goto out;
+
+   for (i = 0; i < devcount; i++) {
+   vf = devlist[i];
+
+   if (!pci_iov_is_child_vf(iov, vf))
+   continue;
+
+   error = device_detach(vf);
+   if (error != 0) {
+   device_printf(dev,
+  "Could not disable SR-IOV: failed to detach VF %s\n",
+   device_get_nameunit(vf));
+   goto out;
+   }
+   }
+
+   for (i = 0; i < devcount; i++) {
+   vf = devlist[i];
+
+   if (pci_iov_is_child_vf(iov, vf))
+   pci_delete_child(bus, vf);
+   }
+   PCI_UNINIT_IOV(dev);
+
+   iov_ctl = IOV_READ(dinfo, PCIR_SRIOV_CTL, 2);
+   iov_ctl &= ~(PCIM_SRIOV_VF_EN | PCIM_SRIOV_VF_MSE);
+   IOV_WRITE(dinfo, PCIR_SRIOV_CTL, iov_ctl, 2);
+   IOV_WRITE(dinfo, PCIR_SRIOV_NUM_VFS, 0, 2);
+
+   iov->iov_num_vfs = 0;
+
+   for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
+   if (iov->iov_bar[i].res != NULL) {
+   pci_release_resource(bus, dev, SYS_RES_MEMORY,
+   iov->iov_pos + PCIR_SRIOV_BAR(i),
+   iov->iov_bar[i].res);
+   pci_delete_resource(bus, dev, SYS_RES_MEMORY,
+   iov->iov_pos + PCIR_SRIOV_BAR(i));
+   iov->iov_bar[i].res = NULL;
+   }
+   }
+
+   if (iov->iov_flags & IOV_RMAN_INITED) {
+   rman_fini(&iov->rman);
+   iov->iov_flags &= ~IOV_RMAN_INITED;
+   }
+
+   error = 0;
+out:
+   free(devlist, M_TEMP);
+   iov->iov_flags &= ~IOV_BUSY;
+   mtx_unlock(&Giant);
+   return (error);
+}
+
+
 static int
 pci_iov_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
 struct thread *td)
@@ -510,6 +614,8 @@ pci_iov_ioctl(struct cdev *dev, u_long c
switch (cmd) {
case IOV_CONFIG:
return (pci_iov_config(dev, (struct pci_iov_arg *)data));
+   case IOV_DELETE:
+   return (pci_iov_delete(dev));
default:
return (EINVAL);
}

Modified: head/sys/dev/pci/pci_iov_private.h
==

svn commit: r279454 - head/usr.sbin

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:41:17 2015
New Revision: 279454
URL: https://svnweb.freebsd.org/changeset/base/279454

Log:
  Add main() for iovctl and hook iovctl into build
  
  Differential Revision:https://reviews.freebsd.org/D87
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/usr.sbin/Makefile

Modified: head/usr.sbin/Makefile
==
--- head/usr.sbin/Makefile  Sun Mar  1 00:40:57 2015(r279453)
+++ head/usr.sbin/Makefile  Sun Mar  1 00:41:17 2015(r279454)
@@ -35,6 +35,7 @@ SUBDIR=   adduser \
i2c \
ifmcstat \
iostat \
+   iovctl \
kldxref \
mailwrapper \
makefs \
___
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: r279455 - head/usr.sbin

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:44:15 2015
New Revision: 279455
URL: https://svnweb.freebsd.org/changeset/base/279455

Log:
  Revert r279454.  The new directory didn't get added to svn properly.
  
  Pointy hat to: rstone

Modified:
  head/usr.sbin/Makefile

Modified: head/usr.sbin/Makefile
==
--- head/usr.sbin/Makefile  Sun Mar  1 00:41:17 2015(r279454)
+++ head/usr.sbin/Makefile  Sun Mar  1 00:44:15 2015(r279455)
@@ -35,7 +35,6 @@ SUBDIR=   adduser \
i2c \
ifmcstat \
iostat \
-   iovctl \
kldxref \
mailwrapper \
makefs \
___
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: r279457 - head/usr.sbin/iovctl

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:52:15 2015
New Revision: 279457
URL: https://svnweb.freebsd.org/changeset/base/279457

Log:
  Add a manpage for iovctl(8)
  
  Differential Revision:https://reviews.freebsd.org/D83
  Reviewed by:  wblock
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/usr.sbin/iovctl/
  head/usr.sbin/iovctl/iovctl.8   (contents, props changed)

Added: head/usr.sbin/iovctl/iovctl.8
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/iovctl/iovctl.8   Sun Mar  1 00:52:15 2015
(r279457)
@@ -0,0 +1,123 @@
+.\"
+.\" Copyright (c) 2014 Sandvine Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 21, 2014
+.Dt IOVCTL 8
+.Os
+.Sh NAME
+.Nm iovctl
+.Nd "PCI SR-IOV configuration utility"
+.Sh SYNOPSIS
+.Nm
+.Fl C
+.Op Fl f Ar config-file
+.Op Fl n
+.Nm
+.Fl D
+.Op Fl f Ar config-file | Fl d Ar device
+.Op Fl n
+.Nm
+.Fl S
+.Op Fl f Ar config-file | Fl d Ar device
+.Sh DESCRIPTION
+The
+.Nm
+utility creates or destroys PCI Single-Root I/O Virtualization
+.Pq SR-IOV
+Virtual Functions
+.Po VFs Pc .
+When invoked with the
+.Fl C
+flag,
+.Nm
+creates VFs as children of the Physical Function
+.Pq PF
+configured in the specified configuration file.
+When invoked with the
+.Fl D
+flag,
+.Nm
+destroys all VFs that are children of the specified device.
+Available PF devices can be seen in
+.Pa /dev/iov/ .
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl C
+Enable SR-IOV on the specified PF device and create VF children.
+This operation will fail if the PF already has VF children.
+This option must be used in conjunction with the
+.Fl f
+option.
+.It Fl d Ar device
+Specify the PF device to use for the given operation.
+.Ar device
+may either be the name of a PF device, or a full path name to a node in
+.Pa /dev/iov/ .
+This option may not be used with the
+.Fl C
+option.
+.It Fl D
+Delete all VF children of the specified PF device.
+This operation will fail if SR-IOV is not currently enabled on the specified
+device.
+.It Fl f Ar config-file
+Specify the pathname of the configuration file.
+For the
+.Fl C
+option, this file will be used to specify all configuration values.
+For the
+.Fl D
+and
+.Fl S
+options, this file will only be used to specify the name of the PF device.
+.Pp
+See
+.Xr iovctl.conf
+for a description of the config file format and documentation of the
+configuration parameters that apply to all PF drivers.
+See the PF driver manual page for configuration parameters specific to
+particular hardware.
+.It Fl n
+Perform a dry-run.
+Perform all validation of the specified action and print what would be done,
+but do not perform the actual creation or destruction of VFs.
+This option may not be used with the
+.Fl S
+flag.
+.It Fl S
+Read the configuration schema from the specified device and print its contents
+to stdout.
+This action may be used to discover the configuration parameters supported on
+a given PF device.
+.El
+.Sh SEE ALSO
+.Xr iovctl.conf 5 ,
+.Xr rc.conf 5
+.Sh AUTHORS
+This manual page was written by
+.An Ryan Stone Aq Mt rst...@freebsd.org .
___
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: r279459 - head/usr.sbin/iovctl

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:52:28 2015
New Revision: 279459
URL: https://svnweb.freebsd.org/changeset/base/279459

Log:
  Add iovctl functions for validating config
  
  Add an function to iovctl that validates the configuration against
  a schema.  This function is able to assume that the parser has
  done most of the validation already and it's only responsible for
  applying default VF values specified in the config file, confirming
  that all required parameters have been set and that no invalid VF
  numbers have been specified.
  
  Differential Revision:https://reviews.freebsd.org/D85
  Reviewed by:  bcr
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/usr.sbin/iovctl/validate.c   (contents, props changed)

Added: head/usr.sbin/iovctl/validate.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/iovctl/validate.c Sun Mar  1 00:52:28 2015
(r279459)
@@ -0,0 +1,274 @@
+/*-
+ * Copyright (c) 2014-2015 Sandvine Inc.  All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "iovctl.h"
+
+/*
+ * Returns a writeable pointer to the configuration for the given device.
+ * If no configuration exists, a new nvlist with empty driver and iov
+ * sections is allocated and returned.
+ *
+ * Returning a writeable pointer requires removing the configuration from 
config
+ * using nvlist_take.  It is the responsibility of the caller to re-insert the
+ * nvlist in config with nvlist_move_nvlist.
+ */
+static nvlist_t *
+find_config(nvlist_t *config, const char * device)
+{
+   nvlist_t *subsystem, *empty_driver, *empty_iov;
+
+   subsystem = dnvlist_take_nvlist(config, device, NULL);
+
+   if (subsystem != NULL)
+   return (subsystem);
+
+   empty_driver = nvlist_create(NV_FLAG_IGNORE_CASE);
+   if (empty_driver == NULL)
+   err(1, "Could not allocate config nvlist");
+
+   empty_iov = nvlist_create(NV_FLAG_IGNORE_CASE);
+   if (empty_iov == NULL)
+   err(1, "Could not allocate config nvlist");
+
+   subsystem = nvlist_create(NV_FLAG_IGNORE_CASE);
+   if (subsystem == NULL)
+   err(1, "Could not allocate config nvlist");
+
+   nvlist_move_nvlist(subsystem, DRIVER_CONFIG_NAME, empty_driver);
+   nvlist_move_nvlist(subsystem, IOV_CONFIG_NAME, empty_iov);
+
+   return (subsystem);
+}
+
+static uint16_t
+parse_vf_num(const char *key, regmatch_t *matches)
+{
+   u_long vf_num;
+
+   vf_num = strtoul(key + matches[1].rm_so, NULL, 10);
+
+   if (vf_num > UINT16_MAX)
+   errx(1, "VF number %lu is too large to be valid",
+   vf_num);
+
+   return (vf_num);
+}
+
+/*
+ * Apply the default values specified in device_defaults to the specified
+ * subsystem in the given device_config.
+ *
+ * This function assumes that the values specified in device_defaults have
+ * already been validated.
+ */
+static void
+apply_subsystem_defaults(nvlist_t *device_config, const char *subsystem,
+const nvlist_t *device_defaults)
+{
+   nvlist_t *config;
+   const nvlist_t *defaults;
+   const char *name;
+   void *cookie;
+   size_t len;
+   const void *bin;
+   int type;
+
+   config = nvlist_take_nvlist(device_config, subsystem);
+   defaults = nvlist_get_nvlist(device_defaults, subsystem);
+
+   cookie = NULL;
+   while ((name = nvlist_next(defaults, &type, &cookie)) != NULL

svn commit: r279458 - head/usr.sbin/iovctl

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:52:21 2015
New Revision: 279458
URL: https://svnweb.freebsd.org/changeset/base/279458

Log:
  Add manpage documenting iovctl config file format.
  
  Differential Revision:https://reviews.freebsd.org/D84
  Reviewed by:  emaste, bcr, wblock
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/usr.sbin/iovctl/iovctl.conf.5   (contents, props changed)

Added: head/usr.sbin/iovctl/iovctl.conf.5
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/iovctl/iovctl.conf.5  Sun Mar  1 00:52:21 2015
(r279458)
@@ -0,0 +1,167 @@
+.\"
+.\" Copyright (c) 2014 Sandvine Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 21, 2014
+.Dt IOVCTL.CONF 5
+.Os
+.Sh NAME
+.Nm iovctl.conf
+.Nd IOVCTL configuration file
+.Sh DESCRIPTION
+The
+.Nm
+file is the configuration file for the
+.Xr iovctl 8
+program.
+This file specifies configuration parameters for a single Physical Function
+.Pq PF
+device.
+To configure SR-IOV on multiple PF devices, use one configuration file for each
+PF.
+The locations of all
+.Xr iovctl 9
+configuration files are specified in
+.Xr rc.conf 5 .
+.Pp
+The
+.Nm
+file uses UCL format.
+UCL syntax is documented at the official UCL website:
+http://github.com/vstakhov/libucl.
+.Pp
+There are three types of sections in the
+.Nm
+file.
+A section is a key at the top level of the file with a list as its value.
+The list may contain the keys specified in the
+.Sx OPTIONS
+section of this manual page.
+Individual PF driver implementations may specify additional device-specific
+configuration keys that they will accept.
+The order in which sections appear in
+.Nm
+is ignored.
+No two sections may have the same key.
+For example, two sections for VF-1 must not be defined.
+.Pp
+The first section type is the PF section.
+This section always has the key "PF"; therefore, only one such section may be
+defined.
+This section defines configuration parameters that apply to the PF as a whole.
+.Pp
+The second section type is the VF section.
+This section has the key "VF-" followed by a VF index.
+VF indices start at 0 and always increment by 1.
+Valid VF indices are in the range of 0 to
+.Po num_vfs - 1 Pc .
+The VF index must be given as a decimal integer with no leading zeros.
+This section defines configuration parameters that apply to a single VF.
+.Pp
+The third section type is the default section.
+This section always has the key "DEFAULT"; therefore, only one such section may
+be specified.
+This section defines default configuration parameters that apply to all VFs.
+All configuration keys that are valid to be applied to a VF are valid in this
+section.
+An individual VF section may override a default specified in this section by
+providing a different value for the configuration parameter.
+Note that the default section applies to ALL VFs.
+The default section must appear before any VF sections.
+The default may appear before or after the PF section.
+.Pp
+The following option types are supported:
+.Bl -tag -width indent
+.It boolean
+Accepts a boolean value of true or false.
+.It mac-addr
+Accepts a unicast MAC address specified as a string of the form
+xx:xx:xx:xx:xx:xx, where xx is one or two hexadecimal digits.
+.It string
+Accepts any string value.
+.It uint8_t
+Accepts any integer in the range 0-255, inclusive.
+.It uint16_t
+Accepts any integer in the range 0-65535, inclusive.
+.It uint32_t
+Accepts any integer in the range 0-2**32, inclusive.
+.It uint64_t
+Accepts any integer in the range

svn commit: r279461 - in head/usr.sbin: . iovctl

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:52:41 2015
New Revision: 279461
URL: https://svnweb.freebsd.org/changeset/base/279461

Log:
  Add main() for iovctl and hook iovctl into build
  
  Differential Revision:https://reviews.freebsd.org/D87
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/usr.sbin/iovctl/Makefile   (contents, props changed)
  head/usr.sbin/iovctl/iovctl.c   (contents, props changed)
  head/usr.sbin/iovctl/iovctl.h   (contents, props changed)
Modified:
  head/usr.sbin/Makefile

Modified: head/usr.sbin/Makefile
==
--- head/usr.sbin/Makefile  Sun Mar  1 00:52:34 2015(r279460)
+++ head/usr.sbin/Makefile  Sun Mar  1 00:52:41 2015(r279461)
@@ -35,6 +35,7 @@ SUBDIR=   adduser \
i2c \
ifmcstat \
iostat \
+   iovctl \
kldxref \
mailwrapper \
makefs \

Added: head/usr.sbin/iovctl/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/iovctl/Makefile   Sun Mar  1 00:52:41 2015
(r279461)
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+PROG=  iovctl
+SRCS=  iovctl.c parse.c validate.c
+LIBADD=nv ucl m
+
+CFLAGS+=-I${.CURDIR}/../../contrib/libucl/include
+
+WARNS?=6
+
+MAN=   \
+   iovctl.8 \
+   iovctl.conf.5 \
+
+.include 
+.include 
+

Added: head/usr.sbin/iovctl/iovctl.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/iovctl/iovctl.c   Sun Mar  1 00:52:41 2015
(r279461)
@@ -0,0 +1,403 @@
+/*-
+ * Copyright (c) 2013-2015 Sandvine Inc.  All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "iovctl.h"
+
+static voidconfig_action(const char *filename, int dryrun);
+static voiddelete_action(const char *device, int dryrun);
+static voidprint_schema(const char *device);
+
+/*
+ * Fetch the config schema from the kernel via ioctl.  This function has to
+ * call the ioctl twice: the first returns the amount of memory that we need
+ * to allocate for the schema, and the second actually fetches the schema.
+ */
+static nvlist_t *
+get_schema(int fd)
+{
+   struct pci_iov_schema arg;
+   nvlist_t *schema;
+   int error;
+
+   /* Do the ioctl() once to fetch the size of the schema. */
+   arg.schema = NULL;
+   arg.len = 0;
+   arg.error = 0;
+   error = ioctl(fd, IOV_GET_SCHEMA, &arg);
+   if (error != 0)
+   err(1, "Could not fetch size of config schema");
+
+   arg.schema = malloc(arg.len);
+   if (arg.schema == NULL)
+   err(1, "Could not allocate %zu bytes for schema",
+   arg.len);
+
+   /* Now do the ioctl() for real to get the schema. */
+   error = ioctl(fd, IOV_GET_SCHEMA, &arg);
+   if (error != 0 || arg.error != 0) {
+   if (arg.error != 0)
+   errno = arg.error;
+   err(1, "Could not fetch config schema");
+   }
+
+   schema = nvlist_unpack(arg.schema, arg.len);
+   if (schema == NULL)
+   err(1, "Could not unpack schema");
+
+   free(arg.schema);
+   return (schema);
+}
+
+/*
+ * Call the ioctl that activates SR-IOV and creates the VFs.
+ */
+static void
+config_iov(int fd, const

svn commit: r279460 - head/usr.sbin/iovctl

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:52:34 2015
New Revision: 279460
URL: https://svnweb.freebsd.org/changeset/base/279460

Log:
  Add functions for parsing the iovctl config file
  
  Add two functions for parsing the iovctl config file.  The config
  file is parsed using libucl[1], which accepts most YAML files and
  a superset of JSON.  The first function is an ad-hoc parser that
  searches the file for the PF.DEVICE configuration value.  We need
  to know that value in order to fetch the schema from the kernel,
  and we need the schema in order to be able to fully parse the file.
  
  The second function parses the config file and validates it
  against a schema.  This function will exit with an error message
  if any validation error occurs.  If it succeeds, the configuration
  is returned as an nvlist suitable for passing to the kernel.
  
  [1] https://github.com/vstakhov/libucl
  
  Differential Revision:https://reviews.freebsd.org/D86
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/usr.sbin/iovctl/parse.c   (contents, props changed)

Added: head/usr.sbin/iovctl/parse.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/iovctl/parse.cSun Mar  1 00:52:34 2015
(r279460)
@@ -0,0 +1,416 @@
+/*-
+ * Copyright (c) 2014-2015 Sandvine Inc.  All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "iovctl.h"
+
+static void
+report_config_error(const char *key, const ucl_object_t *obj, const char *type)
+{
+
+   errx(1, "Value '%s' of key '%s' is not of type %s",
+   ucl_object_tostring(obj), key, type);
+}
+
+/*
+ * Verifies that the value specified in the config file is a boolean value, and
+ * then adds the value to the configuration.
+ */
+static void
+add_bool_config(const char *key, const ucl_object_t *obj, nvlist_t *config)
+{
+   bool val;
+
+   if (!ucl_object_toboolean_safe(obj, &val))
+   report_config_error(key, obj, "bool");
+
+   nvlist_add_bool(config, key, val);
+}
+
+/*
+ * Verifies that the value specified in the config file is a string, and then
+ * adds the value to the configuration.
+ */
+static void
+add_string_config(const char *key, const ucl_object_t *obj, nvlist_t *config)
+{
+   const char *val;
+
+   if (!ucl_object_tostring_safe(obj, &val))
+   report_config_error(key, obj, "string");
+
+   nvlist_add_string(config, key, val);
+}
+
+/*
+ * Verifies that the value specified in the config file is a integer value
+ * within the specified range, and then adds the value to the configuration.
+ */
+static void
+add_uint_config(const char *key, const ucl_object_t *obj, nvlist_t *config,
+const char *type, uint64_t max)
+{
+   int64_t val;
+   uint64_t uval;
+
+   /* I must use a signed type here as libucl doesn't provide unsigned. */
+   if (!ucl_object_toint_safe(obj, &val))
+   report_config_error(key, obj, type);
+
+   if (val < 0)
+   report_config_error(key, obj, type);
+
+   uval = val;
+   if (uval > max)
+   report_config_error(key, obj, type);
+
+   nvlist_add_number(config, key, uval);
+}
+
+/*
+ * Verifies that the value specified in the config file is a unicast MAC
+ * address, and then adds the value to the configuration.
+ */
+static void
+add_unicast_mac_config(co

svn commit: r279463 - in head: etc/defaults etc/rc.d share/man/man5

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:58:23 2015
New Revision: 279463
URL: https://svnweb.freebsd.org/changeset/base/279463

Log:
  Add an rc.d script to invoke iovctl(8) during boot
  
  Differential Revision:https://reviews.freebsd.org/D88
  Reviewed by:  wblock, emaste, allanjude
  MFC after:1 month
  Relnotes: yes
  Sponsored by: Sandvine Inc.

Added:
  head/etc/rc.d/iovctl   (contents, props changed)
Modified:
  head/etc/defaults/rc.conf
  head/etc/rc.d/Makefile
  head/etc/rc.d/netif
  head/share/man/man5/rc.conf.5

Modified: head/etc/defaults/rc.conf
==
--- head/etc/defaults/rc.conf   Sun Mar  1 00:57:01 2015(r279462)
+++ head/etc/defaults/rc.conf   Sun Mar  1 00:58:23 2015(r279463)
@@ -667,6 +667,8 @@ casperd_enable="YES"# casperd(8) daemon
 rctl_enable="NO"   # Load rctl(8) rules on boot
 rctl_rules="/etc/rctl.conf"# rctl(8) ruleset. See rctl.conf(5).
 
+iovctl_files=""# Config files for iovctl(8)
+
 ##
 ### Jail Configuration (see rc.conf(5) manual page) ##
 ##

Modified: head/etc/rc.d/Makefile
==
--- head/etc/rc.d/Makefile  Sun Mar  1 00:57:01 2015(r279462)
+++ head/etc/rc.d/Makefile  Sun Mar  1 00:58:23 2015(r279463)
@@ -44,6 +44,7 @@ FILES=DAEMON \
hostid \
hostid_save \
hostname \
+   iovctl \
ip6addrctl \
ipfilter \
ipfs \

Added: head/etc/rc.d/iovctl
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/etc/rc.d/iovctlSun Mar  1 00:58:23 2015(r279463)
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: iovctl
+# REQUIRE: FILESYSTEMS sysctl
+
+. /etc/rc.subr
+
+name="iovctl"
+command="/usr/sbin/iovctl"
+start_cmd="iovctl_start"
+stop_cmd="iovctl_stop"
+
+run_iovctl()
+{
+   local _f flag
+
+   flag=$1
+   for _f in ${iovctl_files} ; do
+   if [ -r ${_f} ]; then
+   ${command} ${flag} -f ${_f} > /dev/null
+   fi
+   done
+}
+
+iovctl_start()
+{
+   run_iovctl -E
+}
+
+iovctl_stop()
+{
+   run_iovctl -D
+}
+
+load_rc_config $name
+run_rc_command "$1"

Modified: head/etc/rc.d/netif
==
--- head/etc/rc.d/netif Sun Mar  1 00:57:01 2015(r279462)
+++ head/etc/rc.d/netif Sun Mar  1 00:58:23 2015(r279463)
@@ -26,7 +26,7 @@
 #
 
 # PROVIDE: netif
-# REQUIRE: atm1 FILESYSTEMS serial sppp sysctl
+# REQUIRE: atm1 FILESYSTEMS iovctl serial sppp sysctl
 # REQUIRE: ipfilter ipfs
 # KEYWORD: nojailvnet
 

Modified: head/share/man/man5/rc.conf.5
==
--- head/share/man/man5/rc.conf.5   Sun Mar  1 00:57:01 2015
(r279462)
+++ head/share/man/man5/rc.conf.5   Sun Mar  1 00:58:23 2015
(r279463)
@@ -4447,6 +4447,11 @@ This variables contains the
 .Xr rctl.conf 5
 ruleset to load for
 .Xr rctl 8 .
+.It Va iovctl_files
+.Pq Vt str
+A space-separated list of configuration files used by
+.Xr iovctl 8 .
+The default value is an empty string.
 .El
 .Sh FILES
 .Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact
@@ -4500,6 +4505,7 @@ ruleset to load for
 .Xr hcsecd 8 ,
 .Xr ifconfig 8 ,
 .Xr inetd 8 ,
+.Xr iovctl 8 ,
 .Xr ipf 8 ,
 .Xr ipfw 8 ,
 .Xr ipnat 8 ,
___
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: r279464 - head/share/man/man9

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:59:21 2015
New Revision: 279464
URL: https://svnweb.freebsd.org/changeset/base/279464

Log:
  Document the interface for defining a configuration schema
  
  Differential Revision:https://reviews.freebsd.org/D89
  Reviewed by:  wblock, emaste, allanjude
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Added:
  head/share/man/man9/pci_iov_schema.9   (contents, props changed)
Modified:
  head/share/man/man9/Makefile

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileSun Mar  1 00:58:23 2015
(r279463)
+++ head/share/man/man9/MakefileSun Mar  1 00:59:21 2015
(r279464)
@@ -197,6 +197,7 @@ MAN=accept_filter.9 \
pci.9 \
PCI_ADD_VF.9 \
PCI_INIT_IOV.9 \
+   pci_iov_schema.9 \
PCI_UNINIT_IOV.9 \
pfil.9 \
pfind.9 \
@@ -1175,6 +1176,14 @@ MLINKS+=pci.9 pci_alloc_msi.9 \
pci.9 pci_set_powerstate.9 \
pci.9 pci_set_max_read_req.9 \
pci.9 pci_write_config.9
+MLINKS+=pci_iov_schema.9 pci_iov_schema_alloc_node.9 \
+   pci_iov_schema.9 pci_iov_schema_add_bool.9 \
+   pci_iov_schema.9 pci_iov_schema_add_string.9 \
+   pci_iov_schema.9 pci_iov_schema_add_uint8.9 \
+   pci_iov_schema.9 pci_iov_schema_add_uint16.9 \
+   pci_iov_schema.9 pci_iov_schema_add_uint32.9 \
+   pci_iov_schema.9 pci_iov_schema_add_uint64.9 \
+   pci_iov_schema.9 pci_iov_schema_add_unicast_mac.9
 MLINKS+=pfil.9 pfil_add_hook.9 \
pfil.9 pfil_head_register.9 \
pfil.9 pfil_head_unregister.9 \

Added: head/share/man/man9/pci_iov_schema.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/pci_iov_schema.9Sun Mar  1 00:59:21 2015
(r279464)
@@ -0,0 +1,265 @@
+.\"
+.\" Copyright (c) 2014 Sandvine Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 25, 2014
+.Dt pci_iov_schema 9
+.Os
+.Sh NAME
+.Nm pci_iov_schema ,
+.Nm pci_iov_schema_alloc_node ,
+.Nm pci_iov_schema_add_bool ,
+.Nm pci_iov_schema_add_string ,
+.Nm pci_iov_schema_add_uint8 ,
+.Nm pci_iov_schema_add_uint16 ,
+.Nm pci_iov_schema_add_uint32 ,
+.Nm pci_iov_schema_add_uint64 ,
+.Nm pci_iov_schema_add_unicast_mac
+.Nd PCI SR-IOV config schema interface
+.Sh SYNOPSIS
+.In machine/stdarg.h
+.In sys/nv.h
+.In sys/iov_schema.h
+.Ft nvlist_t *
+.Fn pci_iov_schema_alloc_node "void"
+.Ft void
+.Fn pci_iov_schema_add_bool "nvlist_t *schema" "const char *name" \
+"uint32_t flags" "int defaultVal"
+.Ft void
+.Fn pci_iov_schema_add_string "nvlist_t *schema" "const char *name" \
+"uint32_t flags" "const char *defaultVal"
+.Ft void
+.Fn pci_iov_schema_add_uint8 "nvlist_t *schema" "const char *name" \
+"uint32_t flags" "uint8_t defaultVal"
+.Ft void
+.Fn pci_iov_schema_add_uint16 "nvlist_t *schema" "const char *name" \
+"uint32_t flags" "uint16_t defaultVal"
+.Ft void
+.Fn pci_iov_schema_add_uint32 "nvlist_t *schema" "const char *name" \
+"uint32_t flags" "uint32_t defaultVal"
+.Ft void
+.Fn pci_iov_schema_add_uint64 "nvlist_t *schema" "const char *name" \
+"uint32_t flags" "uint64_t defaultVal"
+.Ft void
+.Fn pci_iov_schema_add_unicast_mac "nvlist_t *schema" "const char *name" \
+"uint32_t flags" "const uint8_t *defaultVal"
+.Sh DESCRIPTION
+The PCI Single-Root I/O Virtualization 
+.Pq SR-IOV
+configuration schema is a data
+structure that describes the device-specific configuration parameters that a PF
+driver will accept when SR-IOV is e

svn commit: r279466 - head/usr.sbin/pciconf

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:59:35 2015
New Revision: 279466
URL: https://svnweb.freebsd.org/changeset/base/279466

Log:
  Teach pciconf how to dump out SR-IOV capability
  
  Differential Revision:https://reviews.freebsd.org/D1639
  Reviewed by:  jhb
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/usr.sbin/pciconf/cap.c
  head/usr.sbin/pciconf/pciconf.c
  head/usr.sbin/pciconf/pciconf.h

Modified: head/usr.sbin/pciconf/cap.c
==
--- head/usr.sbin/pciconf/cap.c Sun Mar  1 00:59:28 2015(r279465)
+++ head/usr.sbin/pciconf/cap.c Sun Mar  1 00:59:35 2015(r279466)
@@ -37,6 +37,7 @@ static const char rcsid[] =
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -636,7 +637,7 @@ ecap_aer(int fd, struct pci_conf *p, uin
printf(" %d fatal", bitcount32(sta & mask));
printf(" %d non-fatal", bitcount32(sta & ~mask));
sta = read_config(fd, &p->pc_sel, ptr + PCIR_AER_COR_STATUS, 4);
-   printf(" %d corrected", bitcount32(sta));
+   printf(" %d corrected\n", bitcount32(sta));
 }
 
 static void
@@ -652,6 +653,7 @@ ecap_vc(int fd, struct pci_conf *p, uint
if ((cap1 & PCIM_VC_CAP1_LOWPRI_EXT_COUNT) != 0)
printf(" lowpri VC0-VC%d",
(cap1 & PCIM_VC_CAP1_LOWPRI_EXT_COUNT) >> 4);
+   printf("\n");
 }
 
 static void
@@ -664,7 +666,7 @@ ecap_sernum(int fd, struct pci_conf *p, 
return;
low = read_config(fd, &p->pc_sel, ptr + PCIR_SERIAL_LOW, 4);
high = read_config(fd, &p->pc_sel, ptr + PCIR_SERIAL_HIGH, 4);
-   printf(" %08x%08x", high, low);
+   printf(" %08x%08x\n", high, low);
 }
 
 static void
@@ -676,7 +678,7 @@ ecap_vendor(int fd, struct pci_conf *p, 
if (ver < 1)
return;
val = read_config(fd, &p->pc_sel, ptr + 4, 4);
-   printf(" ID %d", val & 0x);
+   printf(" ID %d\n", val & 0x);
 }
 
 static void
@@ -688,7 +690,69 @@ ecap_sec_pcie(int fd, struct pci_conf *p
if (ver < 1)
return;
val = read_config(fd, &p->pc_sel, ptr + 8, 4);
-   printf(" lane errors %#x", val);
+   printf(" lane errors %#x\n", val);
+}
+
+static const char *
+check_enabled(int value)
+{
+
+   return (value ? "enabled" : "disabled");
+}
+
+static void
+ecap_sriov(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
+{
+   const char *comma, *enabled;
+   uint16_t iov_ctl, total_vfs, num_vfs, vf_offset, vf_stride, vf_did;
+   uint32_t page_caps, page_size, page_shift, size;
+   int i;
+
+   printf("SR-IOV %d ", ver);
+
+   iov_ctl = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_CTL, 2);
+   printf("IOV %s, Memory Space %s, ARI %s\n",
+   check_enabled(iov_ctl & PCIM_SRIOV_VF_EN),
+   check_enabled(iov_ctl & PCIM_SRIOV_VF_MSE),
+   check_enabled(iov_ctl & PCIM_SRIOV_ARI_EN));
+
+   total_vfs = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_TOTAL_VFS, 2);
+   num_vfs = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_NUM_VFS, 2);
+   printf(" ");
+   printf("%d VFs configured out of %d supported\n", num_vfs, total_vfs);
+
+   vf_offset = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_VF_OFF, 2);
+   vf_stride = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_VF_STRIDE, 2);
+   printf(" ");
+   printf("First VF RID Offset 0x%04x, VF RID Stride 0x%04x\n", vf_offset,
+   vf_stride);
+
+   vf_did = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_VF_DID, 2);
+   printf(" VF Device ID 0x%04x\n", vf_did);
+
+   page_caps = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_PAGE_CAP, 4);
+   page_size = read_config(fd, &p->pc_sel, ptr + PCIR_SRIOV_PAGE_SIZE, 4);
+   printf(" ");
+   printf("Page Sizes: ");
+   comma = "";
+   while (page_caps != 0) {
+   page_shift = ffs(page_caps) - 1;
+
+   if (page_caps & page_size)
+   enabled = " (enabled)";
+   else
+   enabled = "";
+
+   size = (1 << (page_shift + PCI_SRIOV_BASE_PAGE_SHIFT));
+   printf("%s%d%s", comma, size, enabled);
+   comma = ", ";
+
+   page_caps &= ~(1 << page_shift);
+   }
+   printf("\n");
+
+   for (i = 0; i <= PCIR_MAX_BAR_0; i++)
+   print_bar(fd, p, "iov bar  ", ptr + PCIR_SRIOV_BAR(i));
 }
 
 struct {
@@ -704,7 +768,6 @@ struct {
{ PCIZ_ACS, "ACS" },
{ PCIZ_ARI, "ARI" },
{ PCIZ_ATS, "ATS" },
-   { PCIZ_SRIOV, "SRIOV" },
{ PCIZ_MULTICAST, "Multicast" },
{ PCIZ_RESIZE_BAR, "Resizable BAR" },
{ PCIZ_DPA, "DPA" },
@@ -743,6 +806,9 @@ list_ecaps(int fd, struct pci_conf *p)
case PCIZ_SEC_PCIE:
ecap_sec_pcie(fd, p, pt

svn commit: r279465 - head/sys/dev/pci

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 00:59:28 2015
New Revision: 279465
URL: https://svnweb.freebsd.org/changeset/base/279465

Log:
  Validate the schema that the PF driver passed to us
  
  Differential Revision:https://reviews.freebsd.org/D90
  Reviewed by:  emaste
  MFC after:1 month
  Sponsored by: Sandvine Inc.

Modified:
  head/sys/dev/pci/pci_iov.c
  head/sys/dev/pci/pci_iov_schema.c
  head/sys/dev/pci/schema_private.h

Modified: head/sys/dev/pci/pci_iov.c
==
--- head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:59:21 2015(r279464)
+++ head/sys/dev/pci/pci_iov.c  Sun Mar  1 00:59:28 2015(r279465)
@@ -142,6 +142,10 @@ pci_iov_attach_method(device_t bus, devi
error = ENOMEM;
goto cleanup;
}
+
+   error = pci_iov_validate_schema(schema);
+   if (error != 0)
+   goto cleanup;
iov->iov_schema = schema;
 
iov->iov_cdev = make_dev(&iov_cdevsw, device_get_unit(dev),

Modified: head/sys/dev/pci/pci_iov_schema.c
==
--- head/sys/dev/pci/pci_iov_schema.c   Sun Mar  1 00:59:21 2015
(r279464)
+++ head/sys/dev/pci/pci_iov_schema.c   Sun Mar  1 00:59:28 2015
(r279465)
@@ -50,26 +50,66 @@ __FBSDID("$FreeBSD$");
 struct config_type_validator;
 typedef int (validate_func)(const struct config_type_validator *,
const nvlist_t *, const char *name);
+typedef int (default_validate_t)(const struct config_type_validator *,
+   const nvlist_t *);
 
 static validate_func pci_iov_schema_validate_bool;
 static validate_func pci_iov_schema_validate_string;
 static validate_func pci_iov_schema_validate_uint;
 static validate_func pci_iov_schema_validate_unicast_mac;
 
+static default_validate_t pci_iov_validate_bool_default;
+static default_validate_t pci_iov_validate_string_default;
+static default_validate_t pci_iov_validate_uint_default;
+static default_validate_t pci_iov_validate_unicast_mac_default;
+
 struct config_type_validator {
const char *type_name;
validate_func *validate;
+   default_validate_t *default_validate;
uintmax_t limit;
 };
 
 static struct config_type_validator pci_iov_schema_validators[] = {
-   { "bool", pci_iov_schema_validate_bool },
-   { "string", pci_iov_schema_validate_string },
-   { "uint8_t", pci_iov_schema_validate_uint, UINT8_MAX },
-   { "uint16_t", pci_iov_schema_validate_uint, UINT16_MAX },
-   { "uint32_t", pci_iov_schema_validate_uint, UINT32_MAX },
-   { "uint64_t", pci_iov_schema_validate_uint, UINT64_MAX },
-   { "unicast-mac", pci_iov_schema_validate_unicast_mac },
+   {
+   .type_name = "bool",
+   .validate = pci_iov_schema_validate_bool,
+   .default_validate = pci_iov_validate_bool_default
+   },
+   {
+   .type_name = "string",
+   .validate = pci_iov_schema_validate_string,
+   .default_validate = pci_iov_validate_string_default
+   },
+   {
+   .type_name = "uint8_t",
+   .validate = pci_iov_schema_validate_uint,
+   .default_validate = pci_iov_validate_uint_default,
+   .limit = UINT8_MAX
+   },
+   {
+   .type_name = "uint16_t",
+   .validate = pci_iov_schema_validate_uint,
+   .default_validate = pci_iov_validate_uint_default,
+   .limit = UINT16_MAX
+   },
+   {
+   .type_name = "uint32_t",
+   .validate = pci_iov_schema_validate_uint,
+   .default_validate = pci_iov_validate_uint_default,
+   .limit = UINT32_MAX
+   },
+   {
+   .type_name = "uint64_t",
+   .validate = pci_iov_schema_validate_uint,
+   .default_validate = pci_iov_validate_uint_default,
+   .limit = UINT64_MAX
+   },
+   {
+   .type_name = "unicast-mac",
+   .validate = pci_iov_schema_validate_unicast_mac,
+   .default_validate = pci_iov_validate_unicast_mac_default,
+   },
 };
 
 static const struct config_type_validator *
@@ -309,6 +349,227 @@ pci_iov_config_add_default(const nvlist_
panic("Unexpected nvlist type");
 }
 
+static int
+pci_iov_validate_bool_default(const struct config_type_validator * validator,
+   const nvlist_t *param)
+{
+
+   if (!nvlist_exists_bool(param, DEFAULT_SCHEMA_NAME))
+   return (EINVAL);
+   return (0);
+}
+
+static int
+pci_iov_validate_string_default(const struct config_type_validator * validator,
+   const nvlist_t *param)
+{
+
+   if (!nvlist_exists_string(param, DEFAULT_SCHEMA_NAME))
+   return (EINVAL);
+   return (0);
+}
+
+static int
+pci_iov_validate_uint_default(const struct config_type_validator * validator,
+   const nvlist

Re: svn commit: r279466 - head/usr.sbin/pciconf

2015-02-28 Thread Ryan Stone
Here's some sample output for the capability:

ecap 0010[160] = SR-IOV 1 IOV enabled, Memory Space enabled, ARI enabled
 4 VFs configured out of 128 supported
 First VF RID Offset 0x0010, VF RID Stride 0x0001
 VF Device ID 0x154c
 Page Sizes: 4096 (enabled), 8192, 65536, 262144,
1048576, 4194304

Please note that this looks at the standard PCIe capability in the
device, and so it
cannot be used to check whether a device driver supports SR-IOV in
FreeBSD.  To see
what devices have SR-IOV supported enabled on your machine, check for
device nodes in
/dev/iov.
___
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: r279468 - head/sys/x86/include

2015-02-28 Thread Neel Natu
Author: neel
Date: Sun Mar  1 02:31:27 2015
New Revision: 279468
URL: https://svnweb.freebsd.org/changeset/base/279468

Log:
  Free up the IPI slot used by IPI_STOP_HARD.
  
  Change the numeric value of IPI_STOP_HARD so it doesn't occupy a valid IPI
  slot. This can be done because IPI_STOP_HARD is actually delivered via NMI.
  
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D1983

Modified:
  head/sys/x86/include/apicvar.h

Modified: head/sys/x86/include/apicvar.h
==
--- head/sys/x86/include/apicvar.h  Sun Mar  1 01:08:14 2015
(r279467)
+++ head/sys/x86/include/apicvar.h  Sun Mar  1 02:31:27 2015
(r279468)
@@ -126,7 +126,12 @@
 
 #defineIPI_STOP(APIC_IPI_INTS + 7) /* Stop CPU until 
restarted. */
 #defineIPI_SUSPEND (APIC_IPI_INTS + 8) /* Suspend CPU until 
restarted. */
-#defineIPI_STOP_HARD   (APIC_IPI_INTS + 9) /* Stop CPU with a NMI. 
*/
+
+/*
+ * IPI_STOP_HARD does not need to occupy a slot in the IPI vector space since
+ * it is delivered using an NMI anyways.
+ */
+#defineIPI_STOP_HARD   255 /* Stop CPU with a NMI. 
*/
 
 /*
  * The spurious interrupt can share the priority class with the IPIs since
___
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: r279469 - head/usr.sbin/iovctl

2015-02-28 Thread Ryan Stone
Author: rstone
Date: Sun Mar  1 02:45:46 2015
New Revision: 279469
URL: https://svnweb.freebsd.org/changeset/base/279469

Log:
  Correct a typo.
  
  X-MFC-With:   r279458

Modified:
  head/usr.sbin/iovctl/iovctl.conf.5

Modified: head/usr.sbin/iovctl/iovctl.conf.5
==
--- head/usr.sbin/iovctl/iovctl.conf.5  Sun Mar  1 02:31:27 2015
(r279468)
+++ head/usr.sbin/iovctl/iovctl.conf.5  Sun Mar  1 02:45:46 2015
(r279469)
@@ -91,7 +91,7 @@ An individual VF section may override a 
 providing a different value for the configuration parameter.
 Note that the default section applies to ALL VFs.
 The default section must appear before any VF sections.
-The default may appear before or after the PF section.
+The default section may appear before or after the PF section.
 .Pp
 The following option types are supported:
 .Bl -tag -width indent
___
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: r272284 - head/usr.bin/systat

2015-02-28 Thread Ryan Stone
On Sun, Feb 22, 2015 at 7:06 AM, Slawa Olhovchenkov  wrote:
> No NFC yet.

Thanks for the reminder.  This was MFC'ed to stable/10 in r279473
___
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: r279475 - head/sys/vm

2015-02-28 Thread Alan Cox
Author: alc
Date: Sun Mar  1 05:18:02 2015
New Revision: 279475
URL: https://svnweb.freebsd.org/changeset/base/279475

Log:
  Use RW_NEW rather than calling bzero().

Modified:
  head/sys/vm/vm_object.c

Modified: head/sys/vm/vm_object.c
==
--- head/sys/vm/vm_object.c Sun Mar  1 04:39:07 2015(r279474)
+++ head/sys/vm/vm_object.c Sun Mar  1 05:18:02 2015(r279475)
@@ -196,8 +196,7 @@ vm_object_zinit(void *mem, int size, int
vm_object_t object;
 
object = (vm_object_t)mem;
-   bzero(&object->lock, sizeof(object->lock));
-   rw_init_flags(&object->lock, "vm object", RW_DUPOK);
+   rw_init_flags(&object->lock, "vm object", RW_DUPOK | RW_NEW);
 
/* These are true for any object that has been freed */
object->rtree.rt_root = 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: r279476 - head/sys/mips/atheros

2015-02-28 Thread Adrian Chadd
Author: adrian
Date: Sun Mar  1 06:05:01 2015
New Revision: 279476
URL: https://svnweb.freebsd.org/changeset/base/279476

Log:
  Add QCA955x support to the EHCI setup path.
  
  Tested:
  
  * QCA AP135 development board, USB rootfs.

Modified:
  head/sys/mips/atheros/ar71xx_ehci.c

Modified: head/sys/mips/atheros/ar71xx_ehci.c
==
--- head/sys/mips/atheros/ar71xx_ehci.c Sun Mar  1 05:18:02 2015
(r279475)
+++ head/sys/mips/atheros/ar71xx_ehci.c Sun Mar  1 06:05:01 2015
(r279476)
@@ -162,6 +162,8 @@ ar71xx_ehci_attach(device_t self)
case AR71XX_SOC_AR9341:
case AR71XX_SOC_AR9342:
case AR71XX_SOC_AR9344:
+   case AR71XX_SOC_QCA9556:
+   case AR71XX_SOC_QCA9558:
sc->sc_flags |= EHCI_SCFLG_TT | EHCI_SCFLG_NORESTERM;
break;
default:
@@ -258,4 +260,6 @@ static driver_t ehci_driver = {
 static devclass_t ehci_devclass;
 
 DRIVER_MODULE(ehci, nexus, ehci_driver, ehci_devclass, 0, 0);
+DRIVER_MODULE(ehci, apb, ehci_driver, ehci_devclass, 0, 0);
+
 MODULE_DEPEND(ehci, usb, 1, 1, 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"


svn commit: r279479 - head/sys/mips/atheros

2015-02-28 Thread Adrian Chadd
Author: adrian
Date: Sun Mar  1 06:59:32 2015
New Revision: 279479
URL: https://svnweb.freebsd.org/changeset/base/279479

Log:
  Flesh out some more QCA955x ethernet PLL setup.

Modified:
  head/sys/mips/atheros/qca955x_chip.c

Modified: head/sys/mips/atheros/qca955x_chip.c
==
--- head/sys/mips/atheros/qca955x_chip.cSun Mar  1 06:54:59 2015
(r279478)
+++ head/sys/mips/atheros/qca955x_chip.cSun Mar  1 06:59:32 2015
(r279479)
@@ -189,26 +189,21 @@ qca955x_chip_set_mii_speed(uint32_t unit
return;
 }
 
-/*
- * XXX TODO !!
- */
 static void
 qca955x_chip_set_pll_ge(int unit, int speed, uint32_t pll)
 {
-#if 0
switch (unit) {
case 0:
-   ATH_WRITE_REG(AR934X_PLL_ETH_XMII_CONTROL_REG, pll);
+   ATH_WRITE_REG(QCA955X_PLL_ETH_XMII_CONTROL_REG, pll);
break;
case 1:
-   /* XXX nothing */
+   ATH_WRITE_REG(QCA955X_PLL_ETH_SGMII_CONTROL_REG, pll);
break;
default:
printf("%s: invalid PLL set for arge unit: %d\n",
__func__, unit);
return;
}
-#endif
 }
 
 static void
@@ -241,27 +236,23 @@ qca955x_chip_ddr_flush_ip2(void)
 static uint32_t
 qca955x_chip_get_eth_pll(unsigned int mac, int speed)
 {
-#if 0
uint32_t pll;
 
switch (speed) {
case 10:
-   pll = AR934X_PLL_VAL_10;
+   pll = QCA955X_PLL_VAL_10;
break;
case 100:
-   pll = AR934X_PLL_VAL_100;
+   pll = QCA955X_PLL_VAL_100;
break;
case 1000:
-   pll = AR934X_PLL_VAL_1000;
+   pll = QCA955X_PLL_VAL_1000;
break;
default:
printf("%s%d: invalid speed %d\n", __func__, mac, speed);
pll = 0;
}
return (pll);
-#else
-   return (0);
-#endif
 }
 
 static void
@@ -275,24 +266,17 @@ qca955x_chip_reset_ethernet_switch(void)
 #endif
 }
 
-#if 0
 static void
 qca955x_configure_gmac(uint32_t gmac_cfg)
 {
uint32_t reg;
 
-   reg = ATH_READ_REG(AR934X_GMAC_REG_ETH_CFG);
+   reg = ATH_READ_REG(QCA955X_GMAC_REG_ETH_CFG);
printf("%s: ETH_CFG=0x%08x\n", __func__, reg);
-
-   reg &= ~(AR934X_ETH_CFG_RGMII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0 |
-   AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_SW_ONLY_MODE |
-   AR934X_ETH_CFG_SW_PHY_SWAP);
-
+   reg &= ~(QCA955X_ETH_CFG_RGMII_EN | QCA955X_ETH_CFG_GE0_SGMII);
reg |= gmac_cfg;
-
-   ATH_WRITE_REG(AR934X_GMAC_REG_ETH_CFG, reg);
+   ATH_WRITE_REG(QCA955X_GMAC_REG_ETH_CFG, reg);
 }
-#endif
 
 static void
 qca955x_chip_init_usb_peripheral(void)
@@ -326,17 +310,15 @@ qca955x_chip_reset_wmac(void)
 static void
 qca955x_chip_init_gmac(void)
 {
-#if 0
long gmac_cfg;
 
-   if (resource_long_value("ar934x_gmac", 0, "gmac_cfg",
+   if (resource_long_value("qca955x_gmac", 0, "gmac_cfg",
&gmac_cfg) == 0) {
printf("%s: gmac_cfg=0x%08lx\n",
__func__,
(long) gmac_cfg);
-   ar934x_configure_gmac((uint32_t) gmac_cfg);
+   qca955x_configure_gmac((uint32_t) gmac_cfg);
}
-#endif
 }
 
 /*
___
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: r279477 - head/sys/mips/atheros

2015-02-28 Thread Adrian Chadd
Author: adrian
Date: Sun Mar  1 06:52:23 2015
New Revision: 279477
URL: https://svnweb.freebsd.org/changeset/base/279477

Log:
  Make QCA955X_GMAC_REG_ETH_CFG defined like most other registers like this.

Modified:
  head/sys/mips/atheros/qca955xreg.h

Modified: head/sys/mips/atheros/qca955xreg.h
==
--- head/sys/mips/atheros/qca955xreg.h  Sun Mar  1 06:05:01 2015
(r279476)
+++ head/sys/mips/atheros/qca955xreg.h  Sun Mar  1 06:52:23 2015
(r279477)
@@ -188,7 +188,7 @@
 
 
 /* GMAC Interface */
-#defineQCA955X_GMAC_REG_ETH_CFG0x00/* XXX register base? */
+#defineQCA955X_GMAC_REG_ETH_CFG(QCA955X_GMAC_BASE + 0x00)
 
 #defineQCA955X_ETH_CFG_RGMII_ENBIT(0)
 #defineQCA955X_ETH_CFG_GE0_SGMII   BIT(6)
___
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: r279478 - head/sys/mips/atheros

2015-02-28 Thread Adrian Chadd
Author: adrian
Date: Sun Mar  1 06:54:59 2015
New Revision: 279478
URL: https://svnweb.freebsd.org/changeset/base/279478

Log:
  Add Ethernet PLL values for the QCA955x.
  
  These are the same as the AR934x.
  
  Obtained from:Linux openwrt

Modified:
  head/sys/mips/atheros/qca955xreg.h

Modified: head/sys/mips/atheros/qca955xreg.h
==
--- head/sys/mips/atheros/qca955xreg.h  Sun Mar  1 06:52:23 2015
(r279477)
+++ head/sys/mips/atheros/qca955xreg.h  Sun Mar  1 06:54:59 2015
(r279478)
@@ -193,4 +193,9 @@
 #defineQCA955X_ETH_CFG_RGMII_ENBIT(0)
 #defineQCA955X_ETH_CFG_GE0_SGMII   BIT(6)
 
+/* XXX Same as AR934x values */
+#defineQCA955X_PLL_VAL_10000x1600
+#defineQCA955X_PLL_VAL_100 0x0101
+#defineQCA955X_PLL_VAL_10  0x1616
+
 #endif /* __QCA955XREG_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: r279480 - head/sys/mips/atheros

2015-02-28 Thread Adrian Chadd
Author: adrian
Date: Sun Mar  1 07:00:34 2015
New Revision: 279480
URL: https://svnweb.freebsd.org/changeset/base/279480

Log:
  Add very initial QCA955x awareness to the GPIO code.
  
  There's a lot more to come - the QCA955x has a bunch more GPIO MUX
  configuration, reminiscent of what the ARM chips let you do - but
  it'll have to come later.

Modified:
  head/sys/mips/atheros/ar71xx_gpio.c

Modified: head/sys/mips/atheros/ar71xx_gpio.c
==
--- head/sys/mips/atheros/ar71xx_gpio.c Sun Mar  1 06:59:32 2015
(r279479)
+++ head/sys/mips/atheros/ar71xx_gpio.c Sun Mar  1 07:00:34 2015
(r279480)
@@ -50,9 +50,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
-#include 
+#include 
 
 #include "gpio_if.h"
 
@@ -96,7 +97,9 @@ ar71xx_gpio_function_enable(struct ar71x
 {
if (ar71xx_soc == AR71XX_SOC_AR9341 ||
ar71xx_soc == AR71XX_SOC_AR9342 ||
-   ar71xx_soc == AR71XX_SOC_AR9344)
+   ar71xx_soc == AR71XX_SOC_AR9344 ||
+   ar71xx_soc == AR71XX_SOC_QCA9556 ||
+   ar71xx_soc == AR71XX_SOC_QCA9558)
GPIO_SET_BITS(sc, AR934X_GPIO_REG_FUNC, mask);
else
GPIO_SET_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
@@ -107,7 +110,9 @@ ar71xx_gpio_function_disable(struct ar71
 {
if (ar71xx_soc == AR71XX_SOC_AR9341 ||
ar71xx_soc == AR71XX_SOC_AR9342 ||
-   ar71xx_soc == AR71XX_SOC_AR9344)
+   ar71xx_soc == AR71XX_SOC_AR9344 ||
+   ar71xx_soc == AR71XX_SOC_QCA9556 ||
+   ar71xx_soc == AR71XX_SOC_QCA9558)
GPIO_CLEAR_BITS(sc, AR934X_GPIO_REG_FUNC, mask);
else
GPIO_CLEAR_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
@@ -169,6 +174,9 @@ ar71xx_gpio_pin_max(device_t dev, int *m
case AR71XX_SOC_AR9342:
case AR71XX_SOC_AR9344:
*maxpin = AR934X_GPIO_COUNT - 1;
+   case AR71XX_SOC_QCA9556:
+   case AR71XX_SOC_QCA9558:
+   *maxpin = QCA955X_GPIO_COUNT - 1;
break;
default:
*maxpin = AR71XX_GPIO_PINS - 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"