Re: svn commit: r349231 - in head/sys: kern sys ufs/ufs

2019-06-28 Thread Conrad Meyer
To this end, __result_use_check can help ensure no unchecked callers are
missed when panics are downgraded to errors. (In OneFS, the macro has the
imo more memorable name “__must_check”.

Cheers,
Conrad

On Thu, Jun 27, 2019 at 23:48 Scott Long  wrote:

>
>
> > On Jun 27, 2019, at 3:09 PM, Konstantin Belousov 
> wrote:
> >
> > On Thu, Jun 27, 2019 at 02:01:11PM -0600, Alan Somers wrote:
> >> On Thu, Jun 27, 2019 at 1:18 PM Konstantin Belousov <
> kostik...@gmail.com> wrote:
> >>>
> >>> On Thu, Jun 20, 2019 at 02:13:11PM +, Alan Somers wrote:
>  Author: asomers
>  Date: Thu Jun 20 14:13:10 2019
>  New Revision: 349231
>  URL: https://svnweb.freebsd.org/changeset/base/349231
> 
>  Log:
>   Add FIOBMAP2 ioctl
> >>>
> 
>   This ioctl exposes VOP_BMAP information to userland. It can be used
> by
>   programs like fragmentation analyzers and optimized cp
> implementations. But
>   I'm using it to test fusefs's VOP_BMAP implementation. The "2" in
> the name
>   distinguishes it from the similar but incompatible FIBMAP ioctls in
> NetBSD
>   and Linux.  FIOBMAP2 differs from FIBMAP in that it uses a 64-bit
> block
>   number instead of 32-bit, and it also returns runp and runb.
> 
>   Reviewed by:mckusick
>   MFC after:  2 weeks
>   Sponsored by:   The FreeBSD Foundation
>   Differential Revision:  https://reviews.freebsd.org/D20705
> 
>  Modified:
>   head/sys/kern/vfs_vnops.c
>   head/sys/sys/filio.h
>   head/sys/ufs/ufs/ufs_bmap.c
> 
>  Modified: head/sys/kern/vfs_vnops.c
> 
> ==
>  --- head/sys/kern/vfs_vnops.c Thu Jun 20 13:59:46 2019
> (r349230)
>  +++ head/sys/kern/vfs_vnops.c Thu Jun 20 14:13:10 2019
> (r349231)
>  @@ -1458,6 +1458,25 @@ vn_stat(struct vnode *vp, struct stat *sb,
> struct ucre
>   return (0);
>  }
> 
>  +/* generic FIOBMAP2 implementation */
>  +static int
>  +vn_ioc_bmap2(struct file *fp, struct fiobmap2_arg *arg, struct ucred
> *cred)
> >>> I do not like the fact that internal kernel function takes the
> >>> user-visible structure which results in the mix of ABI and KBI.
> >>> Traditionally we pass explicit arguments to kern_XXX, vn_XXX and
> similar
> >>> internal implementations.
> >>
> >> Ok.  It will increase the number of function arguments, which is ugly,
> >> but I can do it if you prefer.
> >>
> >>>
>  +{
>  + struct vnode *vp = fp->f_vnode;
> >>> Why do you pass fp to the function that
> >>> 1. Has vn_ namespace, i.e. operating on vnode.
> >>> 2. Only needs vnode to operate on.
> >>> Please change the argument from fp to vp.  You would need to pass
> f_cred
> >>> as additional argument, or move mac check to vn_ioctl (I think this is
> >>> a better approach).
> >>
> >> Ok.
> >>
> >>>
>  + daddr_t lbn = arg->bn;
> >>> Style: initialization in declaration.
> >>>
>  + int error;
>  +
>  + vn_lock(vp, LK_SHARED | LK_RETRY);
>  +#ifdef MAC
>  + error = mac_vnode_check_read(cred, fp->f_cred, vp);
>  + if (error == 0)
>  +#endif
>  + error = VOP_BMAP(vp, lbn, NULL, &arg->bn, &arg->runp,
>  + &arg->runb);
> >>> Wrong indent for continuation line.
> >>>
>  + VOP_UNLOCK(vp, 0);
>  + return (error);
>  +}
>  +
>  /*
>   * File table vnode ioctl routine.
>   */
>  @@ -1481,6 +1500,9 @@ vn_ioctl(struct file *fp, u_long com, void
> *data, stru
>   if (error == 0)
>   *(int *)data = vattr.va_size -
> fp->f_offset;
>   return (error);
>  + case FIOBMAP2:
>  + return (vn_ioc_bmap2(fp, (struct
> fiobmap2_arg*)data,
> >>> Need space between fiobmap2_arg and '*'.
>  + active_cred));
> >>> Wrong indent.
> >>>
>   case FIONBIO:
>   case FIOASYNC:
>   return (0);
> 
>  Modified: head/sys/sys/filio.h
> 
> ==
>  --- head/sys/sys/filio.h  Thu Jun 20 13:59:46 2019
> (r349230)
>  +++ head/sys/sys/filio.h  Thu Jun 20 14:13:10 2019
> (r349231)
>  @@ -62,6 +62,13 @@ struct fiodgname_arg {
>  /* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */
>  #define  FIOSEEKDATA _IOWR('f', 97, off_t)   /* SEEK_DATA */
>  #define  FIOSEEKHOLE _IOWR('f', 98, off_t)   /* SEEK_HOLE */
>  +struct fiobmap2_arg {
>  + int64_t bn;
>  + int runp;
>  + int runb;
>  +};
> >>> This structure has different layout for LP64 and ILP32, and you did not
> >>> provided the compat shims.
> >>
> >> Really?  How so?  All of the fields have the same width on 64 and 32
> >

Re: svn commit: r349459 - head/sys/sys

2019-06-28 Thread Bruce Evans

On Thu, 27 Jun 2019, Andriy Gapon wrote:


On 27/06/2019 20:37, Bruce Evans wrote:

On Thu, 27 Jun 2019, Andriy Gapon wrote:


On 27/06/2019 18:47, Bruce Evans wrote:

On Thu, 27 Jun 2019, Andriy Gapon wrote:


Log:
??upgrade the warning printf-s in bus accessors to KASSERT-s

??After this change sys/bus.h includes sys/systm.h.


This is further namespace pollution.?? sys/systm.h is a prerequiste for
all kernel headers except sys/param.h and the headers that that includes,
since any kernel header (except sys/param.hm etc.) may have inlines which
use features in systm.h, e.g., KASSERT() or an inline function.


what do you think about amending style(9) to require that if sys/systm.h is to
be included, then it must be included before any other header except for
sys/param.h (and possibly sys/cdefs.h) ?


It is not a style matter.


I know... but style(9) documents sys/param.h for similar reasons.


sys/systm.h is just a prerequisite for almost
all kernel code.?? Perhaps this can be enforced using #ifdef magic even
for headers that don't currently use it.?? If it is to be included nested,
then sys/param.h is the place to include it, but I don't like that since
it is even less related to parameters than sys/param.h, and this would be
a regression from minor depollution of sys/param.h.

sys/systm.h is also kernel-only, and as you found, including it nested
tends to break applications, so other headers that have the bug of
including it tend to have _KERNEL ifdefs to avoid including it in
applications.?? This is so fundamental that it doesn't have a "No
user-serviceable parts inside" ifdef.


I think that there is a trivial fix to my commit: moving the sys/systm.h include
to the _KERNEL section of sys/bus.h.  That's where its definitions are actually
used.
But I agree that there should be a better approach.


I did a quick check of how many .c files are missing includes of sys/systm.h.
In an old version of FreeBSD, my normal kernel has about 1100 object files,
and about 89 of these broke when a KASSERT() was added to sys/bus.h without
adding the pollution.  That is many more than I expected.

Many of these errors are in automatically generated bus if.c files.  E.g.,
the include list in acpi_if.c is:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include "acpi_if.h"

Here sys/bus.h and sys/types.h and the contrib include are in the .m file,
and the others are automatically generated.  Including sys/types.h is
nonsense since sys/param.h already included it and sys/bus.h already used
typedefs in it.  The generation also misorders sys/queue.h and mangles
the formatting of the contrib include (in the .m file, it is separated
by spaces).

Here the .m file should know sys/bus.h's prerequisites and add them all
except sys/param.h and sys/systm.h, or maybe the include of sys/bus.h
should be auto-generated too (my test kernel has 25 foo_if.c files and
21 of these include sys/bus.c).

Most of the generated if.c files include sys/systm.h by nested pollution
anyway.  Just not early enough to actually work.  E.g., in acpi_if.c,
the above 8 includes expand to 45 lines, 144 words and 2679 chars in
.depend.acpi_if.o according to wc.  The word count of 144 is
approximately the number of includes.  sys/systm.h is first included
deeply nested in contrib//acpi.h.

11 of the 25 generated foo_if.c end up never including sys/systm.h.

Of the remaining 64 files that fail to compile, all except 7 including
1 maintained by me (cy_pci.c) *blush* end up including sys/systm.h.
The other 57 apparently include it either misordered in the .c file
or via nested pollution.

After removing all nested includes of sys/systm.h in  headers, only
another 50 object files fail to build.  most of the extras are for
libkern functions (20 for str*() alone).  libkern was polluted.h relatively
recently as part of unimproving the implementation of bcd conversion APIs
from macros to inlines with KASSERT()s.  The KASSERT()s were a bad fix for
missing sanity checks of bcd data in callers.

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


svn commit: r349506 - in head: share/man/man9 sys/kern sys/sys

2019-06-28 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jun 28 10:38:56 2019
New Revision: 349506
URL: https://svnweb.freebsd.org/changeset/base/349506

Log:
  Implement API for draining EPOCH(9) callbacks.
  
  The epoch_drain_callbacks() function is used to drain all pending
  callbacks which have been invoked by prior epoch_call() function calls
  on the same epoch. This function is useful when there are shared
  memory structure(s) referred to by the epoch callback(s) which are not
  refcounted and are rarely freed. The typical place for calling this
  function is right before freeing or invalidating the shared
  resource(s) used by the epoch callback(s). This function can sleep and
  is not optimized for performance.
  
  Differential Revision: https://reviews.freebsd.org/D20109
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/epoch.9
  head/sys/kern/subr_epoch.c
  head/sys/sys/epoch.h

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileFri Jun 28 05:11:02 2019
(r349505)
+++ head/share/man/man9/MakefileFri Jun 28 10:38:56 2019
(r349506)
@@ -945,6 +945,15 @@ MLINKS+=drbr.9 drbr_free.9 \
 MLINKS+=DRIVER_MODULE.9 DRIVER_MODULE_ORDERED.9 \
DRIVER_MODULE.9 EARLY_DRIVER_MODULE.9 \
DRIVER_MODULE.9 EARLY_DRIVER_MODULE_ORDERED.9
+MLINKS+=epoch.9 epoch_context.9 \
+   epoch.9 epoch_alloc.9 \
+   epoch.9 epoch_free.9 \
+   epoch.9 epoch_enter.9 \
+   epoch.9 epoch_exit.9 \
+   epoch.9 epoch_wait.9 \
+   epoch.9 epoch_call.9 \
+   epoch.9 epoch_drain_callbacks.9 \
+   epoch.9 in_epoch.9
 MLINKS+=EVENTHANDLER.9 EVENTHANDLER_DECLARE.9 \
EVENTHANDLER.9 EVENTHANDLER_DEFINE.9 \
EVENTHANDLER.9 EVENTHANDLER_DEREGISTER.9 \

Modified: head/share/man/man9/epoch.9
==
--- head/share/man/man9/epoch.9 Fri Jun 28 05:11:02 2019(r349505)
+++ head/share/man/man9/epoch.9 Fri Jun 28 10:38:56 2019(r349506)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 25, 2018
+.Dd June 28, 2019
 .Dt EPOCH 9
 .Os
 .Sh NAME
@@ -38,6 +38,7 @@
 .Nm epoch_exit ,
 .Nm epoch_wait ,
 .Nm epoch_call ,
+.Nm epoch_drain_callbacks ,
 .Nm in_epoch ,
 .Nd kernel epoch based reclamation
 .Sh SYNOPSIS
@@ -60,6 +61,8 @@
 .Fn epoch_wait_preempt "epoch_t epoch"
 .Ft void
 .Fn epoch_call "epoch_t epoch" "epoch_context_t ctx" "void (*callback) 
(epoch_context_t)"
+.Ft void
+.Fn epoch_drain_callbacks "epoch_t epoch"
 .Ft int
 .Fn in_epoch "epoch_t epoch"
 .Sh DESCRIPTION
@@ -120,6 +123,18 @@ routines must be used and the caller can no longer mod
 in place.
 An item to be modified must be handled with copy on write
 and frees must be deferred until after a grace period has elapsed.
+.Pp
+The
+.Fn epoch_drain_callbacks
+function is used to drain all pending callbacks which have been invoked by 
prior
+.Fn epoch_call
+function calls on the same epoch.
+This function is useful when there are shared memory structure(s)
+referred to by the epoch callback(s) which are not refcounted and are
+rarely freed.
+The typical place for calling this function is right before freeing or
+invalidating the shared resource(s) used by the epoch callback(s).
+This function can sleep and is not optimized for performance.
 .Sh RETURN VALUES
 .Fn in_epoch curepoch
 will return 1 if curthread is in curepoch, 0 otherwise.

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Fri Jun 28 05:11:02 2019(r349505)
+++ head/sys/kern/subr_epoch.c  Fri Jun 28 10:38:56 2019(r349506)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -64,6 +65,8 @@ static MALLOC_DEFINE(M_EPOCH, "epoch", "epoch based re
 TAILQ_HEAD (epoch_tdlist, epoch_tracker);
 typedef struct epoch_record {
ck_epoch_record_t er_record;
+   struct epoch_context er_drain_ctx;
+   struct epoch *er_parent;
volatile struct epoch_tdlist er_tdlist;
volatile uint32_t er_gen;
uint32_t er_cpuid;
@@ -74,6 +77,9 @@ struct epoch {
epoch_record_t e_pcpu_record;
int e_idx;
int e_flags;
+   struct sx e_drain_sx;
+   struct mtx e_drain_mtx;
+   volatile int e_drain_count;
 };
 
 /* arbitrary --- needs benchmarking */
@@ -178,6 +184,7 @@ epoch_ctor(epoch_t epoch)
ck_epoch_register(&epoch->e_epoch, &er->er_record, NULL);
TAILQ_INIT((struct threadlist *)(uintptr_t)&er->er_tdlist);
er->er_cpuid = cpu;
+   er->er_parent = epoch;
}
 }
 
@@ -203,6 +210,8 @@ epoch_alloc(int flags)
MPASS(epoch_count < MAX_EPOCHS - 2);
epoch->e_flags = flags;
epoch->e_idx = epoch_count;
+   sx_in

svn commit: r349507 - head/sys/net

2019-06-28 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jun 28 10:49:04 2019
New Revision: 349507
URL: https://svnweb.freebsd.org/changeset/base/349507

Log:
  Need to wait for epoch callbacks to complete before detaching a
  network interface.
  
  This particularly manifests itself when an INP has multicast options
  attached during a network interface detach. Then the IPv4 and IPv6
  leave group call which results from freeing the multicast address, may
  access a freed ifnet structure. These are the steps to reproduce:
  
  service mdnsd onestart # installed from ports
  
  ifconfig epair create
  ifconfig epair0a 0/24 up
  ifconfig epair0a destroy
  
  Tested by:pho @
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Fri Jun 28 10:38:56 2019(r349506)
+++ head/sys/net/if.c   Fri Jun 28 10:49:04 2019(r349507)
@@ -1127,6 +1127,15 @@ if_detach_internal(struct ifnet *ifp, int vmove, struc
curvnet->vnet_ifcnt--;
 #endif
epoch_wait_preempt(net_epoch_preempt);
+
+   /*
+* Ensure all pending EPOCH(9) callbacks have been executed. This
+* fixes issues about late destruction of multicast options
+* which lead to leave group calls, which in turn access the
+* belonging ifnet structure:
+*/
+   epoch_drain_callbacks(net_epoch_preempt);
+
/*
 * In any case (destroy or vmove) detach us from the groups
 * and remove/wait for pending events on the taskq.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r349503 - head/contrib/ipfilter/man

2019-06-28 Thread Bruce Evans

On Fri, 28 Jun 2019, Cy Schubert wrote:


Log:
 Document the -B, binary logfile, and the -C config file options.
 Reference the ipmon.5 man page and ipmon.conf.

 PR:238816
 MFC after: 1 week

Modified:
 head/contrib/ipfilter/man/ipmon.8

Modified: head/contrib/ipfilter/man/ipmon.8
==
--- head/contrib/ipfilter/man/ipmon.8   Fri Jun 28 04:18:10 2019
(r349502)
+++ head/contrib/ipfilter/man/ipmon.8   Fri Jun 28 04:28:32 2019
(r349503)
@@ -7,6 +7,10 @@ ipmon \- monitors /dev/ipl for logged packets
[
.B \-abBDFhnpstvxX


-B was misdocumented as a flag here, and still is.


] [
+.B "\-B "
+] [


This file isn't written in mdoc.  This gives errors starting with
misformatting the SYNOPIS.  The most obvious ones are:
- split lines are not properly indented
- splitting is done in bad places (after '[' for [  ]
- unusual quoting.  mdoc would not put angle brackets and spaces around
  'filename.  These brackets and spaces seem to be mostly hard-coded
  using .B and literals.
- bad rendering or for square brackets around NSI.  These square brackets
  mean optional options as usual, but are not rendered normally.  The .B
  macro apparently gives normal rendering for outer square brackets, but
  the inner square brackets around NSI use the same rendering as the letters.
- various misorderings: -N before -L, -f after -[NLoOPS; NSI randomly
  ordered.

The recent fixes to the usage message have the correct order for [-NLf],
and different misformatting for split lines, so are hard to compare with
the man page.

This commit makes the usage message out of date again.

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


Re: svn commit: r349503 - head/contrib/ipfilter/man

2019-06-28 Thread Cy Schubert
In message <20190628202903.j1...@besplex.bde.org>, Bruce Evans writes:
> On Fri, 28 Jun 2019, Cy Schubert wrote:
>
> > Log:
> >  Document the -B, binary logfile, and the -C config file options.
> >  Reference the ipmon.5 man page and ipmon.conf.
> >
> >  PR:238816
> >  MFC after: 1 week
> >
> > Modified:
> >  head/contrib/ipfilter/man/ipmon.8
> >
> > Modified: head/contrib/ipfilter/man/ipmon.8
> > ===
> ===
> > --- head/contrib/ipfilter/man/ipmon.8   Fri Jun 28 04:18:10 2019
>   (r349502)
> > +++ head/contrib/ipfilter/man/ipmon.8   Fri Jun 28 04:28:32 2019
>   (r349503)
> > @@ -7,6 +7,10 @@ ipmon \- monitors /dev/ipl for logged packets
> > [
> > .B \-abBDFhnpstvxX
>
> -B was misdocumented as a flag here, and still is.
>
> > ] [
> > +.B "\-B "
> > +] [
>
> This file isn't written in mdoc.  This gives errors starting with
> misformatting the SYNOPIS.  The most obvious ones are:
> - split lines are not properly indented
> - splitting is done in bad places (after '[' for [  ]
> - unusual quoting.  mdoc would not put angle brackets and spaces around
>'filename.  These brackets and spaces seem to be mostly hard-coded
>using .B and literals.
> - bad rendering or for square brackets around NSI.  These square brackets
>mean optional options as usual, but are not rendered normally.  The .B
>macro apparently gives normal rendering for outer square brackets, but
>the inner square brackets around NSI use the same rendering as the letters
> .
> - various misorderings: -N before -L, -f after -[NLoOPS; NSI randomly
>ordered.
>
> The recent fixes to the usage message have the correct order for [-NLf],
> and different misformatting for split lines, so are hard to compare with
> the man page.
>
> This commit makes the usage message out of date again.

Agreed, the ipfilter man pages should be rewritten into mandoc and 
synced with usage(). I considered doing that but as PR grew and no one 
suggested it, rewriting the man page is out of scope for the PR. It is 
something I considered but best left for after more important bugs are 
fixed. So yes, these issues are in my queue.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


>
> Bruce


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


svn commit: r349508 - head/share/mk

2019-06-28 Thread Leandro Lupori
Author: luporl
Date: Fri Jun 28 15:49:14 2019
New Revision: 349508
URL: https://svnweb.freebsd.org/changeset/base/349508

Log:
  Fix missing powerpc64 in _LLVM_TARGET_FILT
  
  This change was originally in D20378. Making it in a new diff since it's a
  bugfix.
  
  Submitted by: alfredo.junior_eldorado.org.br
  Reviewed by:  emaste, luporl
  Differential Revision:https://reviews.freebsd.org/D20756

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Fri Jun 28 10:49:04 2019(r349507)
+++ head/share/mk/src.opts.mk   Fri Jun 28 15:49:14 2019(r349508)
@@ -269,7 +269,7 @@ __LLVM_TARGETS= \
powerpc \
sparc \
x86
-__LLVM_TARGET_FILT=C/(amd64|i386)/x86/:S/sparc64/sparc/:S/arm64/aarch64/
+__LLVM_TARGET_FILT=
C/(amd64|i386)/x86/:S/sparc64/sparc/:S/arm64/aarch64/:S/powerpc64/powerpc/
 .for __llt in ${__LLVM_TARGETS}
 # Default the given TARGET's LLVM_TARGET support to the value of MK_CLANG.
 .if ${__TT:${__LLVM_TARGET_FILT}} == ${__llt}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349509 - head/contrib/file/magic/Magdir

2019-06-28 Thread Leandro Lupori
Author: luporl
Date: Fri Jun 28 15:52:40 2019
New Revision: 349509
URL: https://svnweb.freebsd.org/changeset/base/349509

Log:
  [PowerPC64] Add ABI flags to 'file' magic
  
  The distinction between ELF header version and OpenPOWER ELF ABI version is
  confusing for most of people, so this adds text to "file" output to make it
  clear about which OpenPOWER ELF ABI version binary was built for.
  
  The strings used in this change are based on "64-Bit ELF V2 ABI
  Specification/3.1. ELF Header" document available at
  
http://openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655241_97607.html
  
  Example:
  
  $ file t1-Flag2 -m -m contrib/file/magic/Magdir/elf t1-Flag2: ELF 64-bit MSB
  executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1
  (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD
  13.0 (1300033), FreeBSD-style, not stripped
  
  Submitted by: alfredo.junior_eldorado.org.br
  Reviewed by:  luporl
  Differential Revision:https://reviews.freebsd.org/D20771

Modified:
  head/contrib/file/magic/Magdir/elf

Modified: head/contrib/file/magic/Magdir/elf
==
--- head/contrib/file/magic/Magdir/elf  Fri Jun 28 15:49:14 2019
(r349508)
+++ head/contrib/file/magic/Magdir/elf  Fri Jun 28 15:52:40 2019
(r349509)
@@ -108,6 +108,9 @@
 >18leshort 19  Intel 80960,
 >18leshort 20  PowerPC or cisco 4500,
 >18leshort 21  64-bit PowerPC or cisco 7500,
+>>48   lelong  0   Unspecified or Power ELF V1 ABI,
+>>48   lelong  1   Power ELF V1 ABI,
+>>48   lelong  2   OpenPOWER ELF V2 ABI,
 >18leshort 22  IBM S/390,
 >18leshort 23  Cell SPU,
 >18leshort 24  cisco SVIP,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349510 - head/contrib/elftoolchain/readelf

2019-06-28 Thread Leandro Lupori
Author: luporl
Date: Fri Jun 28 16:00:55 2019
New Revision: 349510
URL: https://svnweb.freebsd.org/changeset/base/349510

Log:
  [PowerPC64] readelf: print description for 'e_flags' in ELF header (ABI type)
  
  This prints out description text with the meaning of 'Flags' value in 
PowerPC64.
  
  Example:
  
  $ readelf -h ~/tmp/t1-Flag2
  ELF Header:
  
  Magic:   7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
  Class: ELF64
  Data:  2's complement, big endian
  Version:   1 (current)
  OS/ABI:FreeBSD
  ABI Version:   0
  Type:  EXEC (Executable file)
  Machine:   PowerPC 64-bit
  Version:   0x1
  Entry point address:   0x1001
  Start of program headers:  64 (bytes into file)
  Start of section headers:  209368 (bytes into file)
  Flags: 0x2, OpenPOWER ELF V2 ABI
  Size of this header:   64 (bytes)
  Size of program headers:   56 (bytes)
  Number of program headers: 10
  Size of section headers:   64 (bytes)
  Number of section headers: 34
  Section header string table index: 31
  
  Submitted by:  alfredo.junior_eldorado.org.br
  Reviewed by:  luporl
  Differential Revision:https://reviews.freebsd.org/D20782

Modified:
  head/contrib/elftoolchain/readelf/readelf.c

Modified: head/contrib/elftoolchain/readelf/readelf.c
==
--- head/contrib/elftoolchain/readelf/readelf.c Fri Jun 28 15:52:40 2019
(r349509)
+++ head/contrib/elftoolchain/readelf/readelf.c Fri Jun 28 16:00:55 2019
(r349510)
@@ -2297,8 +2297,15 @@ dump_eflags(struct readelf *re, uint64_t e_flags)
}
edesc = mips_eflags_desc;
break;
-   case EM_PPC:
case EM_PPC64:
+   switch (e_flags) {
+   case 0: printf(", Unspecified or Power ELF V1 ABI"); break;
+   case 1: printf(", Power ELF V1 ABI"); break;
+   case 2: printf(", OpenPOWER ELF V2 ABI"); break;
+   default: break;
+   }
+   /* explicit fall through*/
+   case EM_PPC:
edesc = powerpc_eflags_desc;
break;
case EM_RISCV:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349511 - head/lib/libc/sys

2019-06-28 Thread Konstantin Belousov
Author: kib
Date: Fri Jun 28 16:42:44 2019
New Revision: 349511
URL: https://svnweb.freebsd.org/changeset/base/349511

Log:
  Typo.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/lib/libc/sys/procctl.2

Modified: head/lib/libc/sys/procctl.2
==
--- head/lib/libc/sys/procctl.2 Fri Jun 28 16:00:55 2019(r349510)
+++ head/lib/libc/sys/procctl.2 Fri Jun 28 16:42:44 2019(r349511)
@@ -91,7 +91,7 @@ The image flag and set-uid might prevent ASLR enableme
 .It Dv PROC_ASLR_FORCE_DISABLE
 Request that ASLR is disabled after execution.
 Same notes as for
-.Dv PROC_ASKR_FORCE_ENABLE
+.Dv PROC_ASLR_FORCE_ENABLE
 apply.
 .It Dv PROC_ASLR_NOFORCE
 Use system-wide configured policy for ASLR.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r349482 - in head/contrib/elftoolchain: common readelf

2019-06-28 Thread John Baldwin
On 6/27/19 5:10 PM, Mitchell Horne wrote:
> Author: mhorne
> Date: Fri Jun 28 00:10:26 2019
> New Revision: 349482
> URL: https://svnweb.freebsd.org/changeset/base/349482
> 
> Log:
>   readelf: Add support for RISC-V specific e_flags
>   
>   Reviewed by:markj
>   Approved by:markj (mentor)
>   MFC after:  3 days
>   Differential Revision:  https://reviews.freebsd.org/D20767
> 
> Modified:
>   head/contrib/elftoolchain/common/elfdefinitions.h
>   head/contrib/elftoolchain/readelf/readelf.c
> 
> Modified: head/contrib/elftoolchain/common/elfdefinitions.h
> ==
> --- head/contrib/elftoolchain/common/elfdefinitions.h Fri Jun 28 00:03:29 
> 2019(r349481)
> +++ head/contrib/elftoolchain/common/elfdefinitions.h Fri Jun 28 00:10:26 
> 2019(r349482)
> @@ -426,6 +426,22 @@ _ELF_DEFINE_EF(EF_PPC_RELOCATABLE,  0x0001UL,
> \
>   "-mrelocatable flag")   \
>  _ELF_DEFINE_EF(EF_PPC_RELOCATABLE_LIB, 0x8000UL, \
>   "-mrelocatable-lib flag")   \
> +_ELF_DEFINE_EF(EF_RISCV_RVE, 0x0008UL,   \
> + "Compressed instruction ABI")   \

I don't think this description for RVE is quite right.  RVE is for RV32E which
is not using compressed ('C') instructions, but using a smaller register file
(16 GPRs instead of 32) which is in theory intended for embedded / 
microprocessor
variants.  The riscv-elf-psabi-doc describes it as:

EF_RISCV_RVE (0x0008): This bit is set when the binary targets the E ABI.

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


svn commit: r349512 - head/usr.bin/proccontrol

2019-06-28 Thread Konstantin Belousov
Author: kib
Date: Fri Jun 28 18:03:13 2019
New Revision: 349512
URL: https://svnweb.freebsd.org/changeset/base/349512

Log:
  Mention proccontrol(1) -m kpti.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/usr.bin/proccontrol/proccontrol.1

Modified: head/usr.bin/proccontrol/proccontrol.1
==
--- head/usr.bin/proccontrol/proccontrol.1  Fri Jun 28 16:42:44 2019
(r349511)
+++ head/usr.bin/proccontrol/proccontrol.1  Fri Jun 28 18:03:13 2019
(r349512)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 13, 2019
+.Dd June 28, 2019
 .Dt PROCCONTROL 1
 .Os
 .Sh NAME
@@ -66,6 +66,8 @@ Note that process is only allowed to enable tracing fo
 not for any other process.
 .It Ar trapcap
 Controls the signalling of capability mode access violations.
+.It Ar kpti
+Controls the KPTI enable, AMD64 only.
 .El
 .Pp
 The
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349514 - head/sys/dev/cxgbe/tom

2019-06-28 Thread Navdeep Parhar
Author: np
Date: Fri Jun 28 19:27:45 2019
New Revision: 349514
URL: https://svnweb.freebsd.org/changeset/base/349514

Log:
  cxgbe/t4_tom: the AIO tx job queue must be empty by the time the driver
  releases the offload resources associated with the tid.
  
  Reviewed by:  jhb@
  MFC after:1 week
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D20798

Modified:
  head/sys/dev/cxgbe/tom/t4_tom.c

Modified: head/sys/dev/cxgbe/tom/t4_tom.c
==
--- head/sys/dev/cxgbe/tom/t4_tom.c Fri Jun 28 18:48:02 2019
(r349513)
+++ head/sys/dev/cxgbe/tom/t4_tom.c Fri Jun 28 19:27:45 2019
(r349514)
@@ -294,6 +294,7 @@ release_offload_resources(struct toepcb *toep)
if (toep->ulp_mode == ULP_MODE_TCPDDP)
ddp_assert_empty(toep);
 #endif
+   MPASS(TAILQ_EMPTY(&toep->aiotx_jobq));
 
if (toep->l2te)
t4_l2t_release(toep->l2te);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2019-06-28 Thread John Baldwin
Author: jhb
Date: Fri Jun 28 19:37:48 2019
New Revision: 349515
URL: https://svnweb.freebsd.org/changeset/base/349515

Log:
  Use a tab after #define for EXT_* constants.
  
  This matches other #define's in this manpage as well as .
  
  Sponsored by: Netflix

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

Modified: head/share/man/man9/mbuf.9
==
--- head/share/man/man9/mbuf.9  Fri Jun 28 19:27:45 2019(r349514)
+++ head/share/man/man9/mbuf.9  Fri Jun 28 19:37:48 2019(r349515)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 27, 2017
+.Dd June 28, 2019
 .Dt MBUF 9
 .Os
 .\"
@@ -247,17 +247,17 @@ types are defined as follows:
 The available external buffer types are defined as follows:
 .Bd -literal
 /* external buffer types */
-#define EXT_CLUSTER1   /* mbuf cluster */
-#define EXT_SFBUF  2   /* sendfile(2)'s sf_bufs */
-#define EXT_JUMBOP 3   /* jumbo cluster 4096 bytes */
-#define EXT_JUMBO9 4   /* jumbo cluster 9216 bytes */
-#define EXT_JUMBO165   /* jumbo cluster 16184 bytes */
-#define EXT_PACKET 6   /* mbuf+cluster from packet zone */
-#define EXT_MBUF   7   /* external mbuf reference */
-#define EXT_NET_DRV252 /* custom ext_buf provided by net driver(s) */
-#define EXT_MOD_TYPE   253 /* custom module's ext_buf type */
-#define EXT_DISPOSABLE 254 /* can throw this buffer away w/page flipping */
-#define EXT_EXTREF 255 /* has externally maintained ref_cnt ptr */
+#defineEXT_CLUSTER 1   /* mbuf cluster */
+#defineEXT_SFBUF   2   /* sendfile(2)'s sf_bufs */
+#defineEXT_JUMBOP  3   /* jumbo cluster 4096 bytes */
+#defineEXT_JUMBO9  4   /* jumbo cluster 9216 bytes */
+#defineEXT_JUMBO16 5   /* jumbo cluster 16184 bytes */
+#defineEXT_PACKET  6   /* mbuf+cluster from packet zone */
+#defineEXT_MBUF7   /* external mbuf reference */
+#defineEXT_NET_DRV 252 /* custom ext_buf provided by net 
driver(s) */
+#defineEXT_MOD_TYPE253 /* custom module's ext_buf type */
+#defineEXT_DISPOSABLE  254 /* can throw this buffer away w/page 
flipping */
+#defineEXT_EXTREF  255 /* has externally maintained ref_cnt 
ptr */
 .Ed
 .Pp
 If the
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2019-06-28 Thread John Baldwin
Author: jhb
Date: Fri Jun 28 19:49:47 2019
New Revision: 349516
URL: https://svnweb.freebsd.org/changeset/base/349516

Log:
  Sync mbuf flags, types, and external buffer types with .
  
  Sponsored by: Netflix

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

Modified: head/share/man/man9/mbuf.9
==
--- head/share/man/man9/mbuf.9  Fri Jun 28 19:37:48 2019(r349515)
+++ head/share/man/man9/mbuf.9  Fri Jun 28 19:49:47 2019(r349516)
@@ -209,11 +209,21 @@ The
 .Vt mbuf
 flag bits are defined as follows:
 .Bd -literal
-/* mbuf flags */
 #defineM_EXT   0x0001 /* has associated external storage */
 #defineM_PKTHDR0x0002 /* start of record */
 #defineM_EOR   0x0004 /* end of record */
 #defineM_RDONLY0x0008 /* associated data marked read-only 
*/
+#defineM_NOMAP 0x0100 /* mbuf data is unmapped (soon from 
Drew) */
+#defineM_NOFREE0x0200 /* do not free mbuf, embedded in 
cluster */
+#defineM_BCAST 0x0010 /* send/received as link-level 
broadcast */
+#defineM_MCAST 0x0020 /* send/received as link-level 
multicast */
+#defineM_PROMISC   0x0040 /* packet was not for us */
+#defineM_VLANTAG   0x0080 /* ether_vtag is valid */
+#defineM_TSTMP 0x0400 /* rcv_tstmp field is valid */
+#defineM_TSTMP_HPREC   0x0800 /* rcv_tstmp is high-prec, typically
+ hw-stamped on port (useful for IEEE 1588
+ and 802.1AS) */
+
 #defineM_PROTO10x1000 /* protocol-specific */
 #defineM_PROTO20x2000 /* protocol-specific */
 #defineM_PROTO30x4000 /* protocol-specific */
@@ -226,27 +236,34 @@ flag bits are defined as follows:
 #defineM_PROTO10   0x0020 /* protocol-specific */
 #defineM_PROTO11   0x0040 /* protocol-specific */
 #defineM_PROTO12   0x0080 /* protocol-specific */
-
-/* mbuf pkthdr flags (also stored in m_flags) */
-#defineM_BCAST 0x0010 /* send/received as link-level 
broadcast */
-#defineM_MCAST 0x0020 /* send/received as link-level 
multicast */
 .Ed
 .Pp
 The available
 .Vt mbuf
 types are defined as follows:
 .Bd -literal
-/* mbuf types */
 #defineMT_DATA 1   /* dynamic (data) allocation */
 #defineMT_HEADER   MT_DATA /* packet header */
+
+#defineMT_VENDOR1  4   /* for vendor-internal use */
+#defineMT_VENDOR2  5   /* for vendor-internal use */
+#defineMT_VENDOR3  6   /* for vendor-internal use */
+#defineMT_VENDOR4  7   /* for vendor-internal use */
+
 #defineMT_SONAME   8   /* socket name */
+
+#defineMT_EXP1 9   /* for experimental use */
+#defineMT_EXP2 10  /* for experimental use */
+#defineMT_EXP3 11  /* for experimental use */
+#defineMT_EXP4 12  /* for experimental use */
+
 #defineMT_CONTROL  14  /* extra-data protocol message */
-#defineMT_OOBDATA  15  /* expedited data */
+#defineMT_EXTCONTROL   15  /* control message with externalized 
contents */
+#defineMT_OOBDATA  16  /* expedited data  */
 .Ed
 .Pp
 The available external buffer types are defined as follows:
 .Bd -literal
-/* external buffer types */
 #defineEXT_CLUSTER 1   /* mbuf cluster */
 #defineEXT_SFBUF   2   /* sendfile(2)'s sf_bufs */
 #defineEXT_JUMBOP  3   /* jumbo cluster 4096 bytes */
@@ -254,6 +271,18 @@ The available external buffer types are defined as fol
 #defineEXT_JUMBO16 5   /* jumbo cluster 16184 bytes */
 #defineEXT_PACKET  6   /* mbuf+cluster from packet zone */
 #defineEXT_MBUF7   /* external mbuf reference */
+#defineEXT_RXRING  8   /* data in NIC receive ring */
+
+#defineEXT_VENDOR1 224 /* for vendor-internal use */
+#defineEXT_VENDOR2 225 /* for vendor-internal use */
+#defineEXT_VENDOR3 226 /* for vendor-internal use */
+#defineEXT_VENDOR4 227 /* for vendor-internal use */
+
+#defineEXT_EXP1244 /* for experimental use */
+#defineEXT_EXP2245 /* for experimental use */
+#defineEXT_EXP3246 /* for experimental use */
+#defineEXT_EXP4247 /* for experimental use */
+
 #defineEXT_NET_DRV 252 /* custom ext_buf provided by net 
driver(s) */
 #defineEXT_MOD_TYPE253 /* custom module's ext_buf type */
 #defineEXT_DISPOSABLE  254 /* can throw this buffer away w/page 
flipping */
__

svn commit: r349517 - head/sys/dev/cxgbe/tom

2019-06-28 Thread Navdeep Parhar
Author: np
Date: Fri Jun 28 19:57:42 2019
New Revision: 349517
URL: https://svnweb.freebsd.org/changeset/base/349517

Log:
  cxgbe/t4_tom: Tweaks to some of the AIO related CTRs.
  
  Reviewed by:  jhb@
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_ddp.c

Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c  Fri Jun 28 19:49:47 2019
(r349516)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Fri Jun 28 19:57:42 2019
(r349517)
@@ -724,8 +724,8 @@ t4_push_frames(struct adapter *sc, struct toepcb *toep
("%s: ulp_mode %u for toep %p", __func__, toep->ulp_mode, toep));
 
 #ifdef VERBOSE_TRACES
-   CTR4(KTR_CXGBE, "%s: tid %d toep flags %#x tp flags %#x drop %d",
-   __func__, toep->tid, toep->flags, tp->t_flags);
+   CTR5(KTR_CXGBE, "%s: tid %d toep flags %#x tp flags %#x drop %d",
+   __func__, toep->tid, toep->flags, tp->t_flags, drop);
 #endif
if (__predict_false(toep->flags & TPF_ABORT_SHUTDOWN))
return;
@@ -1244,8 +1244,10 @@ do_peer_close(struct sge_iq *iq, const struct rss_head
INP_WLOCK(inp);
tp = intotcpcb(inp);
 
-   CTR5(KTR_CXGBE, "%s: tid %u (%s), toep_flags 0x%x, inp %p", __func__,
-   tid, tp ? tcpstates[tp->t_state] : "no tp", toep->flags, inp);
+   CTR6(KTR_CXGBE,
+   "%s: tid %u (%s), toep_flags 0x%x, ddp_flags 0x%x, inp %p",
+   __func__, tid, tp ? tcpstates[tp->t_state] : "no tp", toep->flags,
+   toep->ddp.flags, inp);
 
if (toep->flags & TPF_ABORT_SHUTDOWN)
goto done;
@@ -2227,7 +2229,7 @@ t4_aiotx_queue_toep(struct socket *so, struct toepcb *
SOCKBUF_LOCK_ASSERT(&toep->inp->inp_socket->so_snd);
 #ifdef VERBOSE_TRACES
CTR3(KTR_CXGBE, "%s: queueing aiotx task for tid %d, active = %s",
-   __func__, toep->tid, toep->aiotx_task_active ? "true" : "false");
+   __func__, toep->tid, toep->aiotx_so != NULL ? "true" : "false");
 #endif
if (toep->aiotx_so != NULL)
return;
@@ -2283,7 +2285,7 @@ t4_aio_queue_aiotx(struct socket *so, struct kaiocb *j
 
SOCKBUF_LOCK(&so->so_snd);
 #ifdef VERBOSE_TRACES
-   CTR2(KTR_CXGBE, "%s: queueing %p", __func__, job);
+   CTR3(KTR_CXGBE, "%s: queueing %p for tid %u", __func__, job, toep->tid);
 #endif
if (!aio_set_cancel_function(job, t4_aiotx_cancel))
panic("new job was cancelled");

Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
==
--- head/sys/dev/cxgbe/tom/t4_ddp.c Fri Jun 28 19:49:47 2019
(r349516)
+++ head/sys/dev/cxgbe/tom/t4_ddp.c Fri Jun 28 19:57:42 2019
(r349517)
@@ -263,8 +263,8 @@ complete_ddp_buffer(struct toepcb *toep, struct ddp_bu
} else
toep->ddp.active_id ^= 1;
 #ifdef VERBOSE_TRACES
-   CTR2(KTR_CXGBE, "%s: ddp_active_id = %d", __func__,
-   toep->ddp.active_id);
+   CTR3(KTR_CXGBE, "%s: tid %u, ddp_active_id = %d", __func__,
+   toep->tid, toep->ddp.active_id);
 #endif
} else {
KASSERT(toep->ddp.active_count != 0 &&
@@ -534,8 +534,8 @@ handle_ddp_data(struct toepcb *toep, __be32 ddp_report
tp->rcv_wnd -= len;
 #endif
 #ifdef VERBOSE_TRACES
-   CTR4(KTR_CXGBE, "%s: DDP[%d] placed %d bytes (%#x)", __func__, db_idx,
-   len, report);
+   CTR5(KTR_CXGBE, "%s: tid %u, DDP[%d] placed %d bytes (%#x)", __func__,
+   toep->tid, db_idx, len, report);
 #endif
 
/* receive buffer autosize */
@@ -574,8 +574,9 @@ handle_ddp_data(struct toepcb *toep, __be32 ddp_report
} else {
copied = job->aio_received;
 #ifdef VERBOSE_TRACES
-   CTR4(KTR_CXGBE, "%s: completing %p (copied %ld, placed %d)",
-   __func__, job, copied, len);
+   CTR5(KTR_CXGBE,
+   "%s: tid %u, completing %p (copied %ld, placed %d)",
+   __func__, toep->tid, job, copied, len);
 #endif
aio_complete(job, copied + len, 0);
t4_rcvd(&toep->td->tod, tp);
@@ -1792,8 +1793,9 @@ sbcopy:
}
 
 #ifdef VERBOSE_TRACES
-   CTR5(KTR_CXGBE, "%s: scheduling %p for DDP[%d] (flags %#lx/%#lx)",
-   __func__, job, db_idx, ddp_flags, ddp_flags_mask);
+   CTR6(KTR_CXGBE,
+   "%s: tid %u, scheduling %p for DDP[%d] (flags %#lx/%#lx)", __func__,
+   toep->tid, job, db_idx, ddp_flags, ddp_flags_mask);
 #endif
/* Give the chip the go-ahead. */
t4_wrq_tx(sc, wr);
@@ -1919,7 +1921,7 @@ t4_aio_queue_ddp(struct socket *so, struct kaiocb *job
 */
 
 #ifdef VERBOSE_TRACES
-   CTR2(KTR_CXGBE, "%s: queueing %p", __func__, job);
+   CTR3(KTR_CXGBE, "

svn commit: r349519 - head/sys/kern

2019-06-28 Thread Konstantin Belousov
Author: kib
Date: Fri Jun 28 20:40:54 2019
New Revision: 349519
URL: https://svnweb.freebsd.org/changeset/base/349519

Log:
  Style.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/sys/kern/kern_umtx.c

Modified: head/sys/kern/kern_umtx.c
==
--- head/sys/kern/kern_umtx.c   Fri Jun 28 20:28:20 2019(r349518)
+++ head/sys/kern/kern_umtx.c   Fri Jun 28 20:40:54 2019(r349519)
@@ -2624,7 +2624,8 @@ do_cv_broadcast(struct thread *td, struct ucond *cv)
 }
 
 static int
-do_rw_rdlock(struct thread *td, struct urwlock *rwlock, long fflag, struct 
_umtx_time *timeout)
+do_rw_rdlock(struct thread *td, struct urwlock *rwlock, long fflag,
+struct _umtx_time *timeout)
 {
struct abs_timeout timo;
struct umtx_q *uq;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349520 - in head: sbin/etherswitchcfg sys/dev/etherswitch

2019-06-28 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jun 28 22:12:43 2019
New Revision: 349520
URL: https://svnweb.freebsd.org/changeset/base/349520

Log:
  Add the 'drop tagged' flag support for ethernet switch ports.
  
  This is intended to drop all 802.1q tagged packets on a port.
  
  Sponsored by:  Rubicon Communications, LLC (Netgate)

Modified:
  head/sbin/etherswitchcfg/etherswitchcfg.8
  head/sbin/etherswitchcfg/etherswitchcfg.c
  head/sys/dev/etherswitch/etherswitch.h

Modified: head/sbin/etherswitchcfg/etherswitchcfg.8
==
--- head/sbin/etherswitchcfg/etherswitchcfg.8   Fri Jun 28 20:40:54 2019
(r349519)
+++ head/sbin/etherswitchcfg/etherswitchcfg.8   Fri Jun 28 22:12:43 2019
(r349520)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 2, 2016
+.Dd June 28, 2019
 .Dt ETHERSWITCHCFG 8
 .Os
 .Sh NAME
@@ -147,6 +147,10 @@ MAC addresses.
 Disable the first lock option.
 Note that sometimes you need to reset the
 switch to really disable this option.
+.It Cm droptagged
+Drop packets with a VLAN tag.
+.It Fl droptagged
+Disable the drop tagged packets option.
 .It Cm dropuntagged
 Drop packets without a VLAN tag.
 .It Fl dropuntagged

Modified: head/sbin/etherswitchcfg/etherswitchcfg.c
==
--- head/sbin/etherswitchcfg/etherswitchcfg.c   Fri Jun 28 20:40:54 2019
(r349519)
+++ head/sbin/etherswitchcfg/etherswitchcfg.c   Fri Jun 28 22:12:43 2019
(r349520)
@@ -215,6 +215,8 @@ set_port_flag(struct cfg *cfg, int argc, char *argv[])
f = ETHERSWITCH_PORT_ADDTAG;
else if (strcasecmp(flag, "firstlock") == 0)
f = ETHERSWITCH_PORT_FIRSTLOCK;
+   else if (strcasecmp(flag, "droptagged") == 0)
+   f = ETHERSWITCH_PORT_DROPTAGGED;
else if (strcasecmp(flag, "dropuntagged") == 0)
f = ETHERSWITCH_PORT_DROPUNTAGGED;
else if (strcasecmp(flag, "doubletag") == 0)
@@ -871,6 +873,8 @@ static struct cmds cmds[] = {
{ MODE_PORT, "-doubletag", 0, set_port_flag },
{ MODE_PORT, "firstlock", 0, set_port_flag },
{ MODE_PORT, "-firstlock", 0, set_port_flag },
+   { MODE_PORT, "droptagged", 0, set_port_flag },
+   { MODE_PORT, "-droptagged", 0, set_port_flag },
{ MODE_PORT, "dropuntagged", 0, set_port_flag },
{ MODE_PORT, "-dropuntagged", 0, set_port_flag },
{ MODE_CONFIG, "vlan_mode", 1, set_vlan_mode },

Modified: head/sys/dev/etherswitch/etherswitch.h
==
--- head/sys/dev/etherswitch/etherswitch.h  Fri Jun 28 20:40:54 2019
(r349519)
+++ head/sys/dev/etherswitch/etherswitch.h  Fri Jun 28 22:12:43 2019
(r349520)
@@ -64,8 +64,10 @@ typedef struct etherswitch_conf etherswitch_conf_t;
 #defineETHERSWITCH_PORT_DROPUNTAGGED   (1 << 4)
 #defineETHERSWITCH_PORT_DOUBLE_TAG (1 << 5)
 #defineETHERSWITCH_PORT_INGRESS(1 << 6)
+#defineETHERSWITCH_PORT_DROPTAGGED (1 << 7)
 #defineETHERSWITCH_PORT_FLAGS_BITS \
-"\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS"
+"\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS" \
+"\10DROPTAGGED"
 
 #define ETHERSWITCH_PORT_MAX_LEDS 3
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349521 - head/sys/dev/etherswitch/e6000sw

2019-06-28 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jun 28 22:19:50 2019
New Revision: 349521
URL: https://svnweb.freebsd.org/changeset/base/349521

Log:
  Add the 802.1q support for the Marvell e6000 series of ethernet switches.
  
  Tested on:espressobin, Clearfog, SG-3100 and others
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/etherswitch/e6000sw/e6000sw.c
  head/sys/dev/etherswitch/e6000sw/e6000swreg.h

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Fri Jun 28 22:12:43 2019
(r349520)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Fri Jun 28 22:19:50 2019
(r349521)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2015 Semihalf
  * Copyright (c) 2015 Stormshield
+ * Copyright (c) 2018-2019, Rubicon Communications, LLC (Netgate)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -60,7 +61,16 @@ MALLOC_DEFINE(M_E6000SW, "e6000sw", "e6000sw switch");
 #defineE6000SW_UNLOCK(_sc) sx_unlock(&(_sc)->sx)
 #defineE6000SW_LOCK_ASSERT(_sc, _what) sx_assert(&(_sc)->sx, (_what))
 #defineE6000SW_TRYLOCK(_sc)sx_tryxlock(&(_sc)->sx)
+#defineE6000SW_WAITREADY(_sc, _reg, _bit)  
\
+e6000sw_waitready((_sc), REG_GLOBAL, (_reg), (_bit))
+#defineE6000SW_WAITREADY2(_sc, _reg, _bit) 
\
+e6000sw_waitready((_sc), REG_GLOBAL2, (_reg), (_bit))
+#defineMDIO_READ(dev, addr, reg)   
\
+MDIO_READREG(device_get_parent(dev), (addr), (reg))
+#defineMDIO_WRITE(dev, addr, reg, val) 
\
+MDIO_WRITEREG(device_get_parent(dev), (addr), (reg), (val))
 
+
 typedef struct e6000sw_softc {
device_tdev;
phandle_t   node;
@@ -71,6 +81,7 @@ typedef struct e6000sw_softc {
device_tmiibus[E6000SW_MAX_PORTS];
struct proc *kproc;
 
+   int vlans[E6000SW_NUM_VLANS];
uint32_tswid;
uint32_tvlan_mode;
uint32_tcpuports_mask;
@@ -80,13 +91,12 @@ typedef struct e6000sw_softc {
int phy_base;
int sw_addr;
int num_ports;
-   boolean_t   multi_chip;
 } e6000sw_softc_t;
 
 static etherswitch_info_t etherswitch_info = {
.es_nports =0,
.es_nvlangroups =   0,
-   .es_vlan_caps = ETHERSWITCH_VLAN_PORT,
+   .es_vlan_caps = ETHERSWITCH_VLAN_PORT | ETHERSWITCH_VLAN_DOT1Q,
.es_name =  "Marvell 6000 series switch"
 };
 
@@ -100,10 +110,12 @@ static int e6000sw_readphy(device_t, int, int);
 static int e6000sw_writephy(device_t, int, int, int);
 static etherswitch_info_t* e6000sw_getinfo(device_t);
 static int e6000sw_getconf(device_t, etherswitch_conf_t *);
+static int e6000sw_setconf(device_t, etherswitch_conf_t *);
 static void e6000sw_lock(device_t);
 static void e6000sw_unlock(device_t);
 static int e6000sw_getport(device_t, etherswitch_port_t *);
 static int e6000sw_setport(device_t, etherswitch_port_t *);
+static int e6000sw_set_vlan_mode(e6000sw_softc_t *, uint32_t);
 static int e6000sw_readreg_wrapper(device_t, int);
 static int e6000sw_writereg_wrapper(device_t, int, int);
 static int e6000sw_readphy_wrapper(device_t, int, int);
@@ -113,10 +125,11 @@ static int e6000sw_setvgroup_wrapper(device_t, ethersw
 static int e6000sw_setvgroup(device_t, etherswitch_vlangroup_t *);
 static int e6000sw_getvgroup(device_t, etherswitch_vlangroup_t *);
 static void e6000sw_setup(device_t, e6000sw_softc_t *);
-static void e6000sw_port_vlan_conf(e6000sw_softc_t *);
 static void e6000sw_tick(void *);
 static void e6000sw_set_atustat(device_t, e6000sw_softc_t *, int, int);
 static int e6000sw_atu_flush(device_t, e6000sw_softc_t *, int);
+static int e6000sw_vtu_flush(e6000sw_softc_t *);
+static int e6000sw_vtu_update(e6000sw_softc_t *, int, int, int, int, int);
 static __inline void e6000sw_writereg(e6000sw_softc_t *, int, int, int);
 static __inline uint32_t e6000sw_readreg(e6000sw_softc_t *, int, int);
 static int e6000sw_ifmedia_upd(struct ifnet *);
@@ -124,7 +137,7 @@ static void e6000sw_ifmedia_sts(struct ifnet *, struct
 static int e6000sw_atu_mac_table(device_t, e6000sw_softc_t *, struct atu_opt *,
 int);
 static int e6000sw_get_pvid(e6000sw_softc_t *, int, int *);
-static int e6000sw_set_pvid(e6000sw_softc_t *, int, int);
+static void e6000sw_set_pvid(e6000sw_softc_t *, int, int);
 static __inline bool e6000sw_is_cpuport(e6000sw_softc_t *, int);
 static __inline bool e6000sw_is_fixedport(e6000sw_softc_t *, int);
 static __inline bool e6000sw_is_fixed25port(e6000sw_softc_t *, int);
@@ -150,6 +163,7 @@ static devi

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

2019-06-28 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jun 28 22:28:51 2019
New Revision: 349522
URL: https://svnweb.freebsd.org/changeset/base/349522

Log:
  Need to apply the PCIM_BAR_MEM_BASE mask to the physical memory
  address before returning it to the user. Some of the least significant
  bits have special meaning and should be masked away.
  
  Discussed with:   kib@
  MFC after:3 days
  Sponsored by: Mellanox Technologies

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

Modified: head/sys/dev/pci/pci_user.c
==
--- head/sys/dev/pci/pci_user.c Fri Jun 28 22:19:50 2019(r349521)
+++ head/sys/dev/pci/pci_user.c Fri Jun 28 22:28:51 2019(r349522)
@@ -855,6 +855,7 @@ pci_bar_mmap(device_t pcidev, struct pci_bar_mmap *pbm
struct thread *td;
struct sglist *sg;
struct pci_map *pm;
+   vm_paddr_t membase;
vm_paddr_t pbase;
vm_size_t plen;
vm_offset_t addr;
@@ -877,8 +878,9 @@ pci_bar_mmap(device_t pcidev, struct pci_bar_mmap *pbm
return (EBUSY); /* XXXKIB enable if _ACTIVATE */
if (!PCI_BAR_MEM(pm->pm_value))
return (EIO);
-   pbase = trunc_page(pm->pm_value);
-   plen = round_page(pm->pm_value + ((pci_addr_t)1 << pm->pm_size)) -
+   membase = pm->pm_value & PCIM_BAR_MEM_BASE;
+   pbase = trunc_page(membase);
+   plen = round_page(membase + ((pci_addr_t)1 << pm->pm_size)) -
pbase;
prot = VM_PROT_READ | (((pbm->pbm_flags & PCIIO_BAR_MMAP_RW) != 0) ?
VM_PROT_WRITE : 0);
@@ -910,7 +912,7 @@ pci_bar_mmap(device_t pcidev, struct pci_bar_mmap *pbm
}
pbm->pbm_map_base = (void *)addr;
pbm->pbm_map_length = plen;
-   pbm->pbm_bar_off = pm->pm_value - pbase;
+   pbm->pbm_bar_off = membase - pbase;
pbm->pbm_bar_length = (pci_addr_t)1 << pm->pm_size;
 
 out:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349527 - in head/contrib/libarchive/libarchive: . test

2019-06-28 Thread Martin Matuska
Author: mm
Date: Fri Jun 28 22:41:17 2019
New Revision: 349527
URL: https://svnweb.freebsd.org/changeset/base/349527

Log:
  MFV r349454:
  Sync libarchive with vendor.
  
  Relevant vendor changes:
PR #1217: RAR5 reader - fix ARM filter going beyond window buffer boundary
  (OSS-Fuzz 15431)
PR #1218: Fixes to sparse file handling
  
  MFC after:1 week

Added:
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
 - copied unchanged from r349454, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
Modified:
  head/contrib/libarchive/libarchive/archive_read.c
  head/contrib/libarchive/libarchive/archive_read_disk_posix.c
  head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c
  head/contrib/libarchive/libarchive/test/test_read_format_rar5.c
Directory Properties:
  head/contrib/libarchive/   (props changed)

Modified: head/contrib/libarchive/libarchive/archive_read.c
==
--- head/contrib/libarchive/libarchive/archive_read.c   Fri Jun 28 22:40:34 
2019(r349526)
+++ head/contrib/libarchive/libarchive/archive_read.c   Fri Jun 28 22:41:17 
2019(r349527)
@@ -844,7 +844,8 @@ archive_read_data(struct archive *_a, void *buff, size
dest = (char *)buff;
 
while (s > 0) {
-   if (a->read_data_remaining == 0) {
+   if (a->read_data_offset == a->read_data_output_offset &&
+   a->read_data_remaining == 0) {
read_buf = a->read_data_block;
a->read_data_is_posix_read = 1;
a->read_data_requested = s;

Modified: head/contrib/libarchive/libarchive/archive_read_disk_posix.c
==
--- head/contrib/libarchive/libarchive/archive_read_disk_posix.cFri Jun 
28 22:40:34 2019(r349526)
+++ head/contrib/libarchive/libarchive/archive_read_disk_posix.cFri Jun 
28 22:41:17 2019(r349527)
@@ -1143,6 +1143,8 @@ _archive_read_next_header2(struct archive *_a, struct 
t->entry_fd = -1;
}
 
+   archive_entry_clear(entry);
+
for (;;) {
r = next_entry(a, t, entry);
if (t->entry_fd >= 0) {

Modified: head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c
==
--- head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c   
Fri Jun 28 22:40:34 2019(r349526)
+++ head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c   
Fri Jun 28 22:41:17 2019(r349527)
@@ -623,9 +623,9 @@ static int run_arm_filter(struct rar5* rar, struct fil
for(i = 0; i < flt->block_length - 3; i += 4) {
uint8_t* b = &rar->cstate.window_buf[
(rar->cstate.solid_offset +
-   flt->block_start + i) & rar->cstate.window_mask];
+   flt->block_start + i + 3) & rar->cstate.window_mask];
 
-   if(b[3] == 0xEB) {
+   if(*b == 0xEB) {
/* 0xEB = ARM's BL (branch + link) instruction. */
offset = read_filter_data(rar,
(rar->cstate.solid_offset + flt->block_start + i) &

Modified: head/contrib/libarchive/libarchive/test/test_read_format_rar5.c
==
--- head/contrib/libarchive/libarchive/test/test_read_format_rar5.c Fri Jun 
28 22:40:34 2019(r349526)
+++ head/contrib/libarchive/libarchive/test/test_read_format_rar5.c Fri Jun 
28 22:41:17 2019(r349527)
@@ -1215,3 +1215,18 @@ DEFINE_TEST(test_read_format_rar5_different_window_siz
 
EPILOGUE();
 }
+
+DEFINE_TEST(test_read_format_rar5_arm_filter_on_window_boundary)
+{
+   char buf[4096];
+   PROLOGUE("test_read_format_rar5_arm_filter_on_window_boundary.rar");
+
+   /* Return codes of those calls are ignored, because this sample file
+* is invalid. However, the unpacker shouldn't produce any SIGSEGV
+* errors during processing. */
+
+   (void) archive_read_next_header(a, &ae);
+   while(0 != archive_read_data(a, buf, sizeof(buf))) {}
+
+   EPILOGUE();
+}

Copied: 
head/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
 (from r349454, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
head/contrib/libarchive/libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
  Fri Jun 28 22:41:17 2019(r349527, copy of r349454,

svn commit: r349526 - in head/sys: amd64/amd64 i386/i386

2019-06-28 Thread Alan Cox
Author: alc
Date: Fri Jun 28 22:40:34 2019
New Revision: 349526
URL: https://svnweb.freebsd.org/changeset/base/349526

Log:
  When we protect PTEs (as opposed to PDEs), we only call vm_page_dirty()
  when, in fact, we are write protecting the page and the PTE has PG_M set.
  However, pmap_protect_pde() was always calling vm_page_dirty() when the PDE
  has PG_M set.  So, adding PG_NX to a writeable PDE could result in
  unnecessary (but harmless) calls to vm_page_dirty().
  
  Simplify the loop calling vm_page_dirty() in pmap_protect_pde().
  
  Reviewed by:  kib, markj
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20793

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Fri Jun 28 22:36:27 2019(r349525)
+++ head/sys/amd64/amd64/pmap.c Fri Jun 28 22:40:34 2019(r349526)
@@ -5202,8 +5202,7 @@ static boolean_t
 pmap_protect_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t sva, vm_prot_t prot)
 {
pd_entry_t newpde, oldpde;
-   vm_offset_t eva, va;
-   vm_page_t m;
+   vm_page_t m, mt;
boolean_t anychanged;
pt_entry_t PG_G, PG_M, PG_RW;
 
@@ -5217,15 +5216,15 @@ pmap_protect_pde(pmap_t pmap, pd_entry_t *pde, vm_offs
anychanged = FALSE;
 retry:
oldpde = newpde = *pde;
-   if ((oldpde & (PG_MANAGED | PG_M | PG_RW)) ==
-   (PG_MANAGED | PG_M | PG_RW)) {
-   eva = sva + NBPDR;
-   for (va = sva, m = PHYS_TO_VM_PAGE(oldpde & PG_PS_FRAME);
-   va < eva; va += PAGE_SIZE, m++)
-   vm_page_dirty(m);
-   }
-   if ((prot & VM_PROT_WRITE) == 0)
+   if ((prot & VM_PROT_WRITE) == 0) {
+   if ((oldpde & (PG_MANAGED | PG_M | PG_RW)) ==
+   (PG_MANAGED | PG_M | PG_RW)) {
+   m = PHYS_TO_VM_PAGE(oldpde & PG_PS_FRAME);
+   for (mt = m; mt < &m[NBPDR / PAGE_SIZE]; mt++)
+   vm_page_dirty(mt);
+   }
newpde &= ~(PG_RW | PG_M);
+   }
if ((prot & VM_PROT_EXECUTE) == 0)
newpde |= pg_nx;
if (newpde != oldpde) {

Modified: head/sys/i386/i386/pmap.c
==
--- head/sys/i386/i386/pmap.c   Fri Jun 28 22:36:27 2019(r349525)
+++ head/sys/i386/i386/pmap.c   Fri Jun 28 22:40:34 2019(r349526)
@@ -3251,8 +3251,7 @@ static boolean_t
 pmap_protect_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t sva, vm_prot_t prot)
 {
pd_entry_t newpde, oldpde;
-   vm_offset_t eva, va;
-   vm_page_t m;
+   vm_page_t m, mt;
boolean_t anychanged;
 
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
@@ -3261,15 +3260,15 @@ pmap_protect_pde(pmap_t pmap, pd_entry_t *pde, vm_offs
anychanged = FALSE;
 retry:
oldpde = newpde = *pde;
-   if ((oldpde & (PG_MANAGED | PG_M | PG_RW)) ==
-   (PG_MANAGED | PG_M | PG_RW)) {
-   eva = sva + NBPDR;
-   for (va = sva, m = PHYS_TO_VM_PAGE(oldpde & PG_PS_FRAME);
-   va < eva; va += PAGE_SIZE, m++)
-   vm_page_dirty(m);
-   }
-   if ((prot & VM_PROT_WRITE) == 0)
+   if ((prot & VM_PROT_WRITE) == 0) {
+   if ((oldpde & (PG_MANAGED | PG_M | PG_RW)) ==
+   (PG_MANAGED | PG_M | PG_RW)) {
+   m = PHYS_TO_VM_PAGE(oldpde & PG_PS_FRAME);
+   for (mt = m; mt < &m[NBPDR / PAGE_SIZE]; mt++)
+   vm_page_dirty(mt);
+   }
newpde &= ~(PG_RW | PG_M);
+   }
 #ifdef PMAP_PAE_COMP
if ((prot & VM_PROT_EXECUTE) == 0 && !i386_read_exec)
newpde |= pg_nx;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r349482 - in head/contrib/elftoolchain: common readelf

2019-06-28 Thread Mitchell Horne
On Fri, Jun 28, 2019 at 12:45 PM John Baldwin  wrote:
>
> On 6/27/19 5:10 PM, Mitchell Horne wrote:
> > Author: mhorne
> > Date: Fri Jun 28 00:10:26 2019
> > New Revision: 349482
> > URL: https://svnweb.freebsd.org/changeset/base/349482
> >
> > Log:
> >   readelf: Add support for RISC-V specific e_flags
> >
> >   Reviewed by:markj
> >   Approved by:markj (mentor)
> >   MFC after:  3 days
> >   Differential Revision:  https://reviews.freebsd.org/D20767
> >
> > Modified:
> >   head/contrib/elftoolchain/common/elfdefinitions.h
> >   head/contrib/elftoolchain/readelf/readelf.c
> >
> > Modified: head/contrib/elftoolchain/common/elfdefinitions.h
> > ==
> > --- head/contrib/elftoolchain/common/elfdefinitions.h Fri Jun 28 00:03:29 
> > 2019(r349481)
> > +++ head/contrib/elftoolchain/common/elfdefinitions.h Fri Jun 28 00:10:26 
> > 2019(r349482)
> > @@ -426,6 +426,22 @@ _ELF_DEFINE_EF(EF_PPC_RELOCATABLE,  0x0001UL,  
> >   \
> >   "-mrelocatable flag")   \
> >  _ELF_DEFINE_EF(EF_PPC_RELOCATABLE_LIB, 0x8000UL, \
> >   "-mrelocatable-lib flag")   \
> > +_ELF_DEFINE_EF(EF_RISCV_RVE, 0x0008UL,   \
> > + "Compressed instruction ABI")   \
>
> I don't think this description for RVE is quite right.  RVE is for RV32E which
> is not using compressed ('C') instructions, but using a smaller register file
> (16 GPRs instead of 32) which is in theory intended for embedded / 
> microprocessor
> variants.  The riscv-elf-psabi-doc describes it as:
>
> EF_RISCV_RVE (0x0008): This bit is set when the binary targets the E ABI.
>

Yep, good catch. This got duplicated from the RVC entry and slipped by during
review. I'll adjust it.

Mitchell

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


svn commit: r349529 - in head: sbin/ifconfig share/man/man9 sys/conf sys/kern sys/net sys/netinet sys/netinet6 sys/sys

2019-06-28 Thread John Baldwin
Author: jhb
Date: Sat Jun 29 00:48:33 2019
New Revision: 349529
URL: https://svnweb.freebsd.org/changeset/base/349529

Log:
  Add an external mbuf buffer type that holds multiple unmapped pages.
  
  Unmapped mbufs allow sendfile to carry multiple pages of data in a
  single mbuf, without mapping those pages.  It is a requirement for
  Netflix's in-kernel TLS, and provides a 5-10% CPU savings on heavy web
  serving workloads when used by sendfile, due to effectively
  compressing socket buffers by an order of magnitude, and hence
  reducing cache misses.
  
  For this new external mbuf buffer type (EXT_PGS), the ext_buf pointer
  now points to a struct mbuf_ext_pgs structure instead of a data
  buffer.  This structure contains an array of physical addresses (this
  reduces cache misses compared to an earlier version that stored an
  array of vm_page_t pointers).  It also stores additional fields needed
  for in-kernel TLS such as the TLS header and trailer data that are
  currently unused.  To more easily detect these mbufs, the M_NOMAP flag
  is set in m_flags in addition to M_EXT.
  
  Various functions like m_copydata() have been updated to safely access
  packet contents (using uiomove_fromphys()), to make things like BPF
  safe.
  
  NIC drivers advertise support for unmapped mbufs on transmit via a new
  IFCAP_NOMAP capability.  This capability can be toggled via the new
  'nomap' and '-nomap' ifconfig(8) commands.  For NIC drivers that only
  transmit packet contents via DMA and use bus_dma, adding the
  capability to if_capabilities and if_capenable should be all that is
  required.
  
  If a NIC does not support unmapped mbufs, they are converted to a
  chain of mapped mbufs (using sf_bufs to provide the mapping) in
  ip_output or ip6_output.  If an unmapped mbuf requires software
  checksums, it is also converted to a chain of mapped mbufs before
  computing the checksum.
  
  Submitted by: gallatin (earlier version)
  Reviewed by:  gallatin, hselasky, rrs
  Discussed with:   ae, kp (firewalls)
  Relnotes: yes
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20616

Modified:
  head/sbin/ifconfig/ifconfig.8
  head/sbin/ifconfig/ifconfig.c
  head/share/man/man9/Makefile
  head/share/man/man9/mbuf.9
  head/share/man/man9/sglist.9
  head/sys/conf/files
  head/sys/conf/kern.mk
  head/sys/kern/kern_mbuf.c
  head/sys/kern/subr_bus_dma.c
  head/sys/kern/subr_sglist.c
  head/sys/kern/uipc_mbuf.c
  head/sys/kern/uipc_sockbuf.c
  head/sys/kern/uipc_socket.c
  head/sys/net/bpf.c
  head/sys/net/bpf_buffer.c
  head/sys/net/if.h
  head/sys/netinet/ip_output.c
  head/sys/netinet/tcp_pcap.c
  head/sys/netinet/tcp_usrreq.c
  head/sys/netinet6/ip6_output.c
  head/sys/sys/mbuf.h
  head/sys/sys/sglist.h

Modified: head/sbin/ifconfig/ifconfig.8
==
--- head/sbin/ifconfig/ifconfig.8   Fri Jun 28 23:40:58 2019
(r349528)
+++ head/sbin/ifconfig/ifconfig.8   Sat Jun 29 00:48:33 2019
(r349529)
@@ -28,7 +28,7 @@
 .\" From: @(#)ifconfig.8   8.3 (Berkeley) 1/5/94
 .\" $FreeBSD$
 .\"
-.Dd May 18, 2019
+.Dd June 28, 2019
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -538,6 +538,12 @@ large receive offloading, enable LRO on the interface.
 If the driver supports
 .Xr tcp 4
 large receive offloading, disable LRO on the interface.
+.It Cm nomap
+If the driver supports unmapped network buffers,
+enable them on the interface.
+.It Fl nomap
+If the driver supports unmapped network buffers,
+disable them on the interface.
 .It Cm wol , wol_ucast , wol_mcast , wol_magic
 Enable Wake On Lan (WOL) support, if available.
 WOL is a facility whereby a machine in a low power state may be woken

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Fri Jun 28 23:40:58 2019
(r349528)
+++ head/sbin/ifconfig/ifconfig.c   Sat Jun 29 00:48:33 2019
(r349529)
@@ -1257,7 +1257,7 @@ unsetifdescr(const char *val, int value, int s, const 
 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
 "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
 "\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
-"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP"
+"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP\33NOMAP"
 
 /*
  * Print the status of the interface.  If an address family was
@@ -1557,6 +1557,8 @@ static struct cmd basic_cmds[] = {
DEF_CMD("-link2",   -IFF_LINK2, setifflags),
DEF_CMD("monitor",  IFF_MONITOR,setifflags),
DEF_CMD("-monitor", -IFF_MONITOR,   setifflags),
+   DEF_CMD("nomap",IFCAP_NOMAP,setifcap),
+   DEF_CMD("-nomap",   -IFCAP_NOMAP,   setifcap),
DEF_CMD("staticarp",IFF_STATICARP,  setifflags),
DEF_CMD("-staticarp",   -IFF_STATICA

svn commit: r349530 - in head/sys: kern sys

2019-06-28 Thread John Baldwin
Author: jhb
Date: Sat Jun 29 00:49:35 2019
New Revision: 349530
URL: https://svnweb.freebsd.org/changeset/base/349530

Log:
  Add support for using unmapped mbufs with sendfile(2).
  
  This can be enabled at runtime via the kern.ipc.mb_use_ext_pgs sysctl.
  It is disabled by default.
  
  Submitted by: gallatin (earlier version)
  Reviewed by:  gallatin, hselasky, rrs
  Relnotes: yes
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20616

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/kern/kern_sendfile.c
  head/sys/sys/mbuf.h

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Sat Jun 29 00:48:33 2019(r349529)
+++ head/sys/kern/kern_mbuf.c   Sat Jun 29 00:49:35 2019(r349530)
@@ -112,6 +112,11 @@ int nmbjumbop; /* limits number of 
page size jumbo c
 int nmbjumbo9; /* limits number of 9k jumbo clusters */
 int nmbjumbo16;/* limits number of 16k jumbo clusters 
*/
 
+bool mb_use_ext_pgs;   /* use EXT_PGS mbufs for sendfile */
+SYSCTL_BOOL(_kern_ipc, OID_AUTO, mb_use_ext_pgs, CTLFLAG_RWTUN,
+&mb_use_ext_pgs, 0,
+"Use unmapped mbufs for sendfile(2)");
+
 static quad_t maxmbufmem;  /* overall real memory limit for all mbufs */
 
 SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, 
&maxmbufmem, 0,

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Sat Jun 29 00:48:33 2019
(r349529)
+++ head/sys/kern/kern_sendfile.c   Sat Jun 29 00:49:35 2019
(r349530)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -62,6 +63,7 @@ __FBSDID("$FreeBSD$");
 
 #defineEXT_FLAG_SYNC   EXT_FLAG_VENDOR1
 #defineEXT_FLAG_NOCACHEEXT_FLAG_VENDOR2
+#defineEXT_FLAG_CACHE_LAST EXT_FLAG_VENDOR3
 
 /*
  * Structure describing a single sendfile(2) I/O, which may consist of
@@ -201,6 +203,39 @@ sendfile_free_mext(struct mbuf *m)
}
 }
 
+static void
+sendfile_free_mext_pg(struct mbuf *m)
+{
+   struct mbuf_ext_pgs *ext_pgs;
+   vm_page_t pg;
+   int i;
+   bool nocache, cache_last;
+
+   KASSERT(m->m_flags & M_EXT && m->m_ext.ext_type == EXT_PGS,
+   ("%s: m %p !M_EXT or !EXT_PGS", __func__, m));
+
+   nocache = m->m_ext.ext_flags & EXT_FLAG_NOCACHE;
+   cache_last = m->m_ext.ext_flags & EXT_FLAG_CACHE_LAST;
+   ext_pgs = m->m_ext.ext_pgs;
+
+   for (i = 0; i < ext_pgs->npgs; i++) {
+   if (cache_last && i == ext_pgs->npgs - 1)
+   nocache = false;
+   pg = PHYS_TO_VM_PAGE(ext_pgs->pa[i]);
+   sendfile_free_page(pg, nocache);
+   }
+
+   if (m->m_ext.ext_flags & EXT_FLAG_SYNC) {
+   struct sendfile_sync *sfs = m->m_ext.ext_arg2;
+
+   mtx_lock(&sfs->mtx);
+   KASSERT(sfs->count > 0, ("Sendfile sync botchup count == 0"));
+   if (--sfs->count == 0)
+   cv_signal(&sfs->cv);
+   mtx_unlock(&sfs->mtx);
+   }
+}
+
 /*
  * Helper function to calculate how much data to put into page i of n.
  * Only first and last pages are special.
@@ -283,8 +318,6 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i
 
CURVNET_SET(so->so_vnet);
if (sfio->error) {
-   struct mbuf *m;
-
/*
 * I/O operation failed.  The state of data in the socket
 * is now inconsistent, and all what we can do is to tear
@@ -299,9 +332,7 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i
so->so_proto->pr_usrreqs->pru_abort(so);
so->so_error = EIO;
 
-   m = sfio->m;
-   for (int i = 0; i < sfio->npages; i++)
-   m = m_free(m);
+   mb_free_notready(sfio->m, sfio->npages);
} else
(void)(so->so_proto->pr_usrreqs->pru_ready)(so, sfio->m,
sfio->npages);
@@ -540,13 +571,15 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *h
struct vnode *vp;
struct vm_object *obj;
struct socket *so;
+   struct mbuf_ext_pgs *ext_pgs;
struct mbuf *m, *mh, *mhtail;
struct sf_buf *sf;
struct shmfd *shmfd;
struct sendfile_sync *sfs;
struct vattr va;
off_t off, sbytes, rem, obj_size;
-   int error, softerr, bsize, hdrlen;
+   int bsize, error, ext_pgs_idx, hdrlen, max_pgs, softerr;
+   bool use_ext_pgs;
 
obj = NULL;
so = NULL;
@@ -554,6 +587,7 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *h
sfs = NULL;
hdrlen = sbytes = 0;
softerr = 0;
+   use_ext_pgs = false;
 

svn commit: r349531 - head/sys/kern

2019-06-28 Thread John Baldwin
Author: jhb
Date: Sat Jun 29 00:50:25 2019
New Revision: 349531
URL: https://svnweb.freebsd.org/changeset/base/349531

Log:
  Compress pending socket buffer data once it is marked ready.
  
  Apply similar logic from sbcompress to pending data in the socket
  buffer once it is marked ready via sbready.  Normally sbcompress
  merges small mbufs to reduce the length of mbuf chains in the socket
  buffer.  However, sbcompress cannot do this for mbufs marked
  M_NOTREADY.  sbcompress_ready is now called from sbready when mbufs
  are marked ready to merge small mbuf chains once the data is available
  to copy.
  
  Submitted by: gallatin (earlier version)
  Reviewed by:  gallatin, hselasky, rrs
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20616

Modified:
  head/sys/kern/uipc_sockbuf.c

Modified: head/sys/kern/uipc_sockbuf.c
==
--- head/sys/kern/uipc_sockbuf.cSat Jun 29 00:49:35 2019
(r349530)
+++ head/sys/kern/uipc_sockbuf.cSat Jun 29 00:50:25 2019
(r349531)
@@ -89,6 +89,78 @@ sbm_clrprotoflags(struct mbuf *m, int flags)
 }
 
 /*
+ * Compress M_NOTREADY mbufs after they have been readied by sbready().
+ *
+ * sbcompress() skips M_NOTREADY mbufs since the data is not available to
+ * be copied at the time of sbcompress().  This function combines small
+ * mbufs similar to sbcompress() once mbufs are ready.  'm0' is the first
+ * mbuf sbready() marked ready, and 'end' is the first mbuf still not
+ * ready.
+ */
+static void
+sbready_compress(struct sockbuf *sb, struct mbuf *m0, struct mbuf *end)
+{
+   struct mbuf *m, *n;
+   int ext_size;
+
+   SOCKBUF_LOCK_ASSERT(sb);
+
+   if ((sb->sb_flags & SB_NOCOALESCE) != 0)
+   return;
+
+   for (m = m0; m != end; m = m->m_next) {
+   MPASS((m->m_flags & M_NOTREADY) == 0);
+
+   /* Compress small unmapped mbufs into plain mbufs. */
+   if ((m->m_flags & M_NOMAP) && m->m_len <= MLEN) {
+   MPASS(m->m_flags & M_EXT);
+   ext_size = m->m_ext.ext_size;
+   if (mb_unmapped_compress(m) == 0) {
+   sb->sb_mbcnt -= ext_size;
+   sb->sb_ccnt -= 1;
+   }
+   }
+
+   /*
+* NB: In sbcompress(), 'n' is the last mbuf in the
+* socket buffer and 'm' is the new mbuf being copied
+* into the trailing space of 'n'.  Here, the roles
+* are reversed and 'n' is the next mbuf after 'm'
+* that is being copied into the trailing space of
+* 'm'.
+*/
+   n = m->m_next;
+   while ((n != NULL) && (n != end) && (m->m_flags & M_EOR) == 0 &&
+   M_WRITABLE(m) &&
+   (m->m_flags & M_NOMAP) == 0 &&
+   n->m_len <= MCLBYTES / 4 && /* XXX: Don't copy too much */
+   n->m_len <= M_TRAILINGSPACE(m) &&
+   m->m_type == n->m_type) {
+   KASSERT(sb->sb_lastrecord != n,
+   ("%s: merging start of record (%p) into previous mbuf (%p)",
+   __func__, n, m));
+   m_copydata(n, 0, n->m_len, mtodo(m, m->m_len));
+   m->m_len += n->m_len;
+   m->m_next = n->m_next;
+   m->m_flags |= n->m_flags & M_EOR;
+   if (sb->sb_mbtail == n)
+   sb->sb_mbtail = m;
+
+   sb->sb_mbcnt -= MSIZE;
+   sb->sb_mcnt -= 1;
+   if (n->m_flags & M_EXT) {
+   sb->sb_mbcnt -= n->m_ext.ext_size;
+   sb->sb_ccnt -= 1;
+   }
+   m_free(n);
+   n = m->m_next;
+   }
+   }
+   SBLASTRECORDCHK(sb);
+   SBLASTMBUFCHK(sb);
+}
+
+/*
  * Mark ready "count" units of I/O starting with "m".  Most mbufs
  * count as a single unit of I/O except for EXT_PGS-backed mbufs which
  * can be backed by multiple pages.
@@ -138,6 +210,7 @@ sbready(struct sockbuf *sb, struct mbuf *m0, int count
}
 
if (!blocker) {
+   sbready_compress(sb, m0, m);
return (EINPROGRESS);
}
 
@@ -150,6 +223,7 @@ sbready(struct sockbuf *sb, struct mbuf *m0, int count
}
 
sb->sb_fnrdy = m;
+   sbready_compress(sb, m0, m);
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349532 - head/sys/net

2019-06-28 Thread John Baldwin
Author: jhb
Date: Sat Jun 29 00:51:38 2019
New Revision: 349532
URL: https://svnweb.freebsd.org/changeset/base/349532

Log:
  Support IFCAP_NOMAP in vlan(4).
  
  Enable IFCAP_NOMAP for a vlan interface if it is supported by the
  underlying trunk device.
  
  Reviewed by:  gallatin, hselasky, rrs
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20616

Modified:
  head/sys/net/if_vlan.c

Modified: head/sys/net/if_vlan.c
==
--- head/sys/net/if_vlan.c  Sat Jun 29 00:50:25 2019(r349531)
+++ head/sys/net/if_vlan.c  Sat Jun 29 00:51:38 2019(r349532)
@@ -1731,6 +1731,16 @@ vlan_capabilities(struct ifvlan *ifv)
ena |= (mena & IFCAP_TXRTLMT);
 #endif
 
+   /*
+* If the parent interface supports unmapped mbufs, so does
+* the VLAN interface.  Note that this should be fine even for
+* interfaces that don't support hardware tagging as headers
+* are prepended in normal mbufs to unmapped mbufs holding
+* payload data.
+*/
+   cap |= (p->if_capabilities & IFCAP_NOMAP);
+   ena |= (mena & IFCAP_NOMAP);
+
ifp->if_capabilities = cap;
ifp->if_capenable = ena;
ifp->if_hwassist = hwa;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349533 - in head/sys/dev/cxgbe: . tom

2019-06-28 Thread John Baldwin
Author: jhb
Date: Sat Jun 29 00:52:21 2019
New Revision: 349533
URL: https://svnweb.freebsd.org/changeset/base/349533

Log:
  Add support for IFCAP_NOMAP to cxgbe(4).
  
  Since cxgbe(4) uses sglist instead of bus_dma, this required updates
  to the code that generates scatter/gather lists for packets.  Also,
  unmapped mbufs are always sent via DMA and never as immediate data in
  the payload of a work request.
  
  Submitted by: gallatin (earlier version)
  Reviewed by:  gallatin, hselasky, rrs
  Discussed with:   np
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20616

Modified:
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cSat Jun 29 00:51:38 2019
(r349532)
+++ head/sys/dev/cxgbe/t4_main.cSat Jun 29 00:52:21 2019
(r349533)
@@ -1623,7 +1623,7 @@ cxgbe_probe(device_t dev)
 #define T4_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | \
 IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO | \
 IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6 | IFCAP_HWSTATS | \
-IFCAP_HWRXTSTMP)
+IFCAP_HWRXTSTMP | IFCAP_NOMAP)
 #define T4_CAP_ENABLE (T4_CAP)
 
 static int
@@ -1986,6 +1986,8 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, cadd
rxq->iq.flags &= ~IQ_RX_TIMESTAMP;
}
}
+   if (mask & IFCAP_NOMAP)
+   ifp->if_capenable ^= IFCAP_NOMAP;
 
 #ifdef VLAN_CAPABILITIES
VLAN_CAPABILITIES(ifp);

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Sat Jun 29 00:51:38 2019(r349532)
+++ head/sys/dev/cxgbe/t4_sge.c Sat Jun 29 00:52:21 2019(r349533)
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 /* Internal mbuf flags stored in PH_loc.eight[1]. */
+#defineMC_NOMAP0x01
 #defineMC_RAW_WR   0x02
 
 /*
@@ -2434,15 +2435,78 @@ m_advance(struct mbuf **pm, int *poffset, int len)
return ((void *)p);
 }
 
+static inline int
+count_mbuf_ext_pgs(struct mbuf *m, int skip, vm_paddr_t *nextaddr)
+{
+   struct mbuf_ext_pgs *ext_pgs;
+   vm_paddr_t paddr;
+   int i, len, off, pglen, pgoff, seglen, segoff;
+   int nsegs = 0;
+
+   MBUF_EXT_PGS_ASSERT(m);
+   ext_pgs = m->m_ext.ext_pgs;
+   off = mtod(m, vm_offset_t);
+   len = m->m_len;
+   off += skip;
+   len -= skip;
+
+   if (ext_pgs->hdr_len != 0) {
+   if (off >= ext_pgs->hdr_len) {
+   off -= ext_pgs->hdr_len;
+   } else {
+   seglen = ext_pgs->hdr_len - off;
+   segoff = off;
+   seglen = min(seglen, len);
+   off = 0;
+   len -= seglen;
+   paddr = pmap_kextract(
+   (vm_offset_t)&ext_pgs->hdr[segoff]);
+   if (*nextaddr != paddr)
+   nsegs++;
+   *nextaddr = paddr + seglen;
+   }
+   }
+   pgoff = ext_pgs->first_pg_off;
+   for (i = 0; i < ext_pgs->npgs && len > 0; i++) {
+   pglen = mbuf_ext_pg_len(ext_pgs, i, pgoff);
+   if (off >= pglen) {
+   off -= pglen;
+   pgoff = 0;
+   continue;
+   }
+   seglen = pglen - off;
+   segoff = pgoff + off;
+   off = 0;
+   seglen = min(seglen, len);
+   len -= seglen;
+   paddr = ext_pgs->pa[i] + segoff;
+   if (*nextaddr != paddr)
+   nsegs++;
+   *nextaddr = paddr + seglen;
+   pgoff = 0;
+   };
+   if (len != 0) {
+   seglen = min(len, ext_pgs->trail_len - off);
+   len -= seglen;
+   paddr = pmap_kextract((vm_offset_t)&ext_pgs->trail[off]);
+   if (*nextaddr != paddr)
+   nsegs++;
+   *nextaddr = paddr + seglen;
+   }
+
+   return (nsegs);
+}
+
+
 /*
  * Can deal with empty mbufs in the chain that have m_len = 0, but the chain
  * must have at least one mbuf that's not empty.  It is possible for this
  * routine to return 0 if skip accounts for all the contents of the mbuf chain.
  */
 static inline int
-count_mbuf_nsegs(struct mbuf *m, int skip)
+count_mbuf_nsegs(struct mbuf *m, int skip, uint8_t *cflags)
 {
-   vm_paddr_t lastb, next;
+   vm_paddr_t nextaddr, paddr;
vm_offset_t va;
int len, nsegs;
 
@@ -2451,9 +2515,8 @@ count_mbuf_nsegs(struct mbuf *m, int skip)
MPA

svn commit: r349534 - head/sys/dev/mlx5/mlx5_en

2019-06-28 Thread John Baldwin
Author: jhb
Date: Sat Jun 29 00:53:07 2019
New Revision: 349534
URL: https://svnweb.freebsd.org/changeset/base/349534

Log:
  Add support for IFCAP_NOMAP to mlx5(4).
  
  Since mlx5 uses bus_dma, this only required adding the capability
  flag.
  
  Submitted by: gallatin
  Reviewed by:  gallatin, hselasky, rrs
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20616

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cSat Jun 29 00:52:21 2019
(r349533)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cSat Jun 29 00:53:07 2019
(r349534)
@@ -3281,6 +3281,8 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t
"tso6 disabled due to -txcsum6.\n");
}
}
+   if (mask & IFCAP_NOMAP)
+   ifp->if_capenable ^= IFCAP_NOMAP;
if (mask & IFCAP_RXCSUM)
ifp->if_capenable ^= IFCAP_RXCSUM;
if (mask & IFCAP_RXCSUM_IPV6)
@@ -4147,6 +4149,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
ifp->if_capabilities |= IFCAP_LRO;
ifp->if_capabilities |= IFCAP_TSO | IFCAP_VLAN_HWTSO;
ifp->if_capabilities |= IFCAP_HWSTATS | IFCAP_HWRXTSTMP;
+   ifp->if_capabilities |= IFCAP_NOMAP;
ifp->if_capabilities |= IFCAP_TXRTLMT;
ifp->if_snd_tag_alloc = mlx5e_snd_tag_alloc;
ifp->if_snd_tag_free = mlx5e_snd_tag_free;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"