svn commit: r368052 - head/sys/dev/superio

2020-11-25 Thread Poul-Henning Kamp
Author: phk
Date: Thu Nov 26 07:34:20 2020
New Revision: 368052
URL: https://svnweb.freebsd.org/changeset/base/368052

Log:
  Add support for Fintek F81803 SuperIO chip
  
  Reviewed by:  avg

Modified:
  head/sys/dev/superio/superio.c
  head/sys/dev/superio/superio.h

Modified: head/sys/dev/superio/superio.c
==
--- head/sys/dev/superio/superio.c  Thu Nov 26 07:31:30 2020
(r368051)
+++ head/sys/dev/superio/superio.c  Thu Nov 26 07:34:20 2020
(r368052)
@@ -233,9 +233,29 @@ static const struct sio_conf_methods nvt_conf_methods 
.vendor = SUPERIO_VENDOR_NUVOTON
 };
 
+static void
+fintek_conf_enter(struct resource* res, uint16_t port)
+{
+   bus_write_1(res, 0, 0x87);
+   bus_write_1(res, 0, 0x87);
+}
+
+static void
+fintek_conf_exit(struct resource* res, uint16_t port)
+{
+   bus_write_1(res, 0, 0xaa);
+}
+
+static const struct sio_conf_methods fintek_conf_methods = {
+   .enter = fintek_conf_enter,
+   .exit = fintek_conf_exit,
+   .vendor = SUPERIO_VENDOR_FINTEK
+};
+
 static const struct sio_conf_methods * const methods_table[] = {
_conf_methods,
_conf_methods,
+   _conf_methods,
NULL
 };
 
@@ -261,6 +281,11 @@ const struct sio_device nct5104_devices[] = {
{ .type = SUPERIO_DEV_NONE },
 };
 
+const struct sio_device fintek_devices[] = {
+   { .ldn = 7, .type = SUPERIO_DEV_WDT },
+   { .type = SUPERIO_DEV_NONE },
+};
+
 static const struct {
superio_vendor_tvendor;
uint16_tdevid;
@@ -410,6 +435,11 @@ static const struct {
.descr = "Nuvoton NCT6795",
.devices = nvt_devices,
},
+   {
+   .vendor = SUPERIO_VENDOR_FINTEK, .devid = 0x1210, .mask = 0xff,
+   .descr = "Fintek F81803",
+   .devices = fintek_devices,
+   },
{ 0, 0 }
 };
 
@@ -472,6 +502,10 @@ superio_detect(device_t dev, bool claim, struct siosc 
devid = sio_readw(res, 0x20);
revid = sio_read(res, 0x22);
} else if (methods_table[m]->vendor == SUPERIO_VENDOR_NUVOTON) {
+   devid = sio_read(res, 0x20);
+   revid = sio_read(res, 0x21);
+   devid = (devid << 8) | revid;
+   } else if (methods_table[m]->vendor == SUPERIO_VENDOR_FINTEK) {
devid = sio_read(res, 0x20);
revid = sio_read(res, 0x21);
devid = (devid << 8) | revid;

Modified: head/sys/dev/superio/superio.h
==
--- head/sys/dev/superio/superio.h  Thu Nov 26 07:31:30 2020
(r368051)
+++ head/sys/dev/superio/superio.h  Thu Nov 26 07:34:20 2020
(r368052)
@@ -34,6 +34,7 @@ typedef enum superio_vendor {
SUPERIO_VENDOR_NONE,
SUPERIO_VENDOR_ITE,
SUPERIO_VENDOR_NUVOTON,
+   SUPERIO_VENDOR_FINTEK,
SUPERIO_VENDOR_MAX
 } superio_vendor_t;
 
@@ -58,7 +59,7 @@ device_t superio_find_dev(device_t superio, superio_de
 int ldn);
 
 enum superio_ivars {
-   SUPERIO_IVAR_LDN =  10600,
+   SUPERIO_IVAR_LDN =  10600,
SUPERIO_IVAR_TYPE,
SUPERIO_IVAR_IOBASE,
SUPERIO_IVAR_IOBASE2,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368051 - stable/12/usr.sbin/bhyve

2020-11-25 Thread Konstantin Belousov
Author: kib
Date: Thu Nov 26 07:31:30 2020
New Revision: 368051
URL: https://svnweb.freebsd.org/changeset/base/368051

Log:
  MFC r367613:
  bhyve: remove a hack to map all 8G BARs 1:1

Modified:
  stable/12/usr.sbin/bhyve/pci_emul.c
  stable/12/usr.sbin/bhyve/pci_emul.h
  stable/12/usr.sbin/bhyve/pci_passthru.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bhyve/pci_emul.c
==
--- stable/12/usr.sbin/bhyve/pci_emul.c Thu Nov 26 07:30:29 2020
(r368050)
+++ stable/12/usr.sbin/bhyve/pci_emul.c Thu Nov 26 07:31:30 2020
(r368051)
@@ -453,14 +453,6 @@ pci_emul_alloc_resource(uint64_t *baseptr, uint64_t li
return (-1);
 }
 
-int
-pci_emul_alloc_bar(struct pci_devinst *pdi, int idx, enum pcibar_type type,
-  uint64_t size)
-{
-
-   return (pci_emul_alloc_pbar(pdi, idx, 0, type, size));
-}
-
 /*
  * Register (or unregister) the MMIO or I/O region associated with the BAR
  * register 'idx' of an emulated pci device.
@@ -585,8 +577,8 @@ update_bar_address(struct pci_devinst *pi, uint64_t ad
 }
 
 int
-pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, uint64_t hostbase,
-   enum pcibar_type type, uint64_t size)
+pci_emul_alloc_bar(struct pci_devinst *pdi, int idx, enum pcibar_type type,
+uint64_t size)
 {
int error;
uint64_t *baseptr, limit, addr, mask, lobits, bar;
@@ -627,13 +619,7 @@ pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, 
 * number (128MB currently).
 */
if (size > 128 * 1024 * 1024) {
-   /*
-* XXX special case for device requiring peer-peer DMA
-*/
-   if (size == 0x1UL)
-   baseptr = 
-   else
-   baseptr = _emul_membase64;
+   baseptr = _emul_membase64;
limit = pci_emul_memlim64;
mask = PCIM_BAR_MEM_BASE;
lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_64 |

Modified: stable/12/usr.sbin/bhyve/pci_emul.h
==
--- stable/12/usr.sbin/bhyve/pci_emul.h Thu Nov 26 07:30:29 2020
(r368050)
+++ stable/12/usr.sbin/bhyve/pci_emul.h Thu Nov 26 07:31:30 2020
(r368051)
@@ -215,8 +215,6 @@ int init_pci(struct vmctx *ctx);
 void   pci_callback(void);
 intpci_emul_alloc_bar(struct pci_devinst *pdi, int idx,
enum pcibar_type type, uint64_t size);
-intpci_emul_alloc_pbar(struct pci_devinst *pdi, int idx,
-   uint64_t hostbase, enum pcibar_type type, uint64_t size);
 intpci_emul_add_msicap(struct pci_devinst *pi, int msgnum);
 intpci_emul_add_pciecap(struct pci_devinst *pi, int pcie_device_type);
 void   pci_emul_capwrite(struct pci_devinst *pi, int offset, int bytes,

Modified: stable/12/usr.sbin/bhyve/pci_passthru.c
==
--- stable/12/usr.sbin/bhyve/pci_passthru.c Thu Nov 26 07:30:29 2020
(r368050)
+++ stable/12/usr.sbin/bhyve/pci_passthru.c Thu Nov 26 07:31:30 2020
(r368051)
@@ -583,7 +583,7 @@ cfginitbar(struct vmctx *ctx, struct passthru_softc *s
sc->psc_bar[i].addr = base;
 
/* Allocate the BAR in the guest I/O or MMIO space */
-   error = pci_emul_alloc_pbar(pi, i, base, bartype, size);
+   error = pci_emul_alloc_bar(pi, i, bartype, size);
if (error)
return (-1);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368050 - stable/12/usr.sbin/bhyve

2020-11-25 Thread Konstantin Belousov
Author: kib
Date: Thu Nov 26 07:30:29 2020
New Revision: 368050
URL: https://svnweb.freebsd.org/changeset/base/368050

Log:
  MFC r367607:
  bhyve: increase allowed size for 64bit BAR allocation below 4G from 32 to 128 
MB.

Modified:
  stable/12/usr.sbin/bhyve/pci_emul.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bhyve/pci_emul.c
==
--- stable/12/usr.sbin/bhyve/pci_emul.c Thu Nov 26 07:29:28 2020
(r368049)
+++ stable/12/usr.sbin/bhyve/pci_emul.c Thu Nov 26 07:30:29 2020
(r368050)
@@ -624,9 +624,9 @@ pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, 
 * Some drivers do not work well if the 64-bit BAR is allocated
 * above 4GB. Allow for this by allocating small requests under
 * 4GB unless then allocation size is larger than some arbitrary
-* number (32MB currently).
+* number (128MB currently).
 */
-   if (size > 32 * 1024 * 1024) {
+   if (size > 128 * 1024 * 1024) {
/*
 * XXX special case for device requiring peer-peer DMA
 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368049 - stable/12/usr.sbin/bhyve

2020-11-25 Thread Konstantin Belousov
Author: kib
Date: Thu Nov 26 07:29:28 2020
New Revision: 368049
URL: https://svnweb.freebsd.org/changeset/base/368049

Log:
  MFC r367606:
  bhyve: avoid allocating BARs above the end of supported physical addresses.

Modified:
  stable/12/usr.sbin/bhyve/pci_emul.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bhyve/pci_emul.c
==
--- stable/12/usr.sbin/bhyve/pci_emul.c Thu Nov 26 06:59:27 2020
(r368048)
+++ stable/12/usr.sbin/bhyve/pci_emul.c Thu Nov 26 07:29:28 2020
(r368049)
@@ -33,6 +33,9 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -45,6 +48,8 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
+#include 
 #include 
 
 #include "acpi.h"
@@ -97,6 +102,7 @@ SET_DECLARE(pci_devemu_set, struct pci_devemu);
 static uint64_t pci_emul_iobase;
 static uint64_t pci_emul_membase32;
 static uint64_t pci_emul_membase64;
+static uint64_t pci_emul_memlim64;
 
 #definePCI_EMUL_IOBASE 0x2000
 #definePCI_EMUL_IOLIMIT0x1
@@ -107,9 +113,6 @@ SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE);
 
 #definePCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE
 
-#definePCI_EMUL_MEMBASE64  0xD0UL
-#definePCI_EMUL_MEMLIMIT64 0xFDUL
-
 static struct pci_devemu *pci_emul_finddev(char *name);
 static void pci_lintr_route(struct pci_devinst *pi);
 static void pci_lintr_update(struct pci_devinst *pi);
@@ -631,7 +634,7 @@ pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, 
baseptr = 
else
baseptr = _emul_membase64;
-   limit = PCI_EMUL_MEMLIMIT64;
+   limit = pci_emul_memlim64;
mask = PCIM_BAR_MEM_BASE;
lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_64 |
 PCIM_BAR_MEM_PREFETCH;
@@ -1100,12 +1103,25 @@ init_pci(struct vmctx *ctx)
struct slotinfo *si;
struct funcinfo *fi;
size_t lowmem;
-   int bus, slot, func;
-   int error;
+   uint64_t cpu_maxphysaddr, pci_emul_memresv64;
+   u_int regs[4];
+   int bus, slot, func, error;
 
pci_emul_iobase = PCI_EMUL_IOBASE;
pci_emul_membase32 = vm_get_lowmem_limit(ctx);
-   pci_emul_membase64 = PCI_EMUL_MEMBASE64;
+
+   do_cpuid(0x8008, regs);
+   cpu_maxphysaddr = 1ULL << (regs[0] & 0xff);
+   if (cpu_maxphysaddr > VM_MAXUSER_ADDRESS)
+   cpu_maxphysaddr = VM_MAXUSER_ADDRESS;
+   pci_emul_memresv64 = cpu_maxphysaddr / 4;
+   /*
+* Max power of 2 that is less then
+* cpu_maxphysaddr - pci_emul_memresv64.
+*/
+   pci_emul_membase64 = 1ULL << (flsl(cpu_maxphysaddr -
+   pci_emul_memresv64) - 1);
+   pci_emul_memlim64 = cpu_maxphysaddr;
 
for (bus = 0; bus < MAXBUSES; bus++) {
if ((bi = pci_businfo[bus]) == NULL)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-11-25 Thread Mateusz Guzik
Author: mjg
Date: Thu Nov 26 06:59:27 2020
New Revision: 368048
URL: https://svnweb.freebsd.org/changeset/base/368048

Log:
  thread: staticize thread_reap and move td_allocdomain
  
  thread_init is a much better fit as the the value is constant after
  initialization.

Modified:
  head/sys/kern/kern_thread.c
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_thread.c
==
--- head/sys/kern/kern_thread.c Thu Nov 26 05:58:55 2020(r368047)
+++ head/sys/kern/kern_thread.c Thu Nov 26 06:59:27 2020(r368048)
@@ -143,6 +143,7 @@ static struct task  thread_reap_task;
 static struct callout  thread_reap_callout;
 
 static void thread_zombie(struct thread *);
+static void thread_reap(void);
 static void thread_reap_all(void);
 static void thread_reap_task_cb(void *, int);
 static void thread_reap_callout_cb(void *);
@@ -347,7 +348,6 @@ thread_ctor(void *mem, int size, void *arg, int flags)
td = (struct thread *)mem;
td->td_state = TDS_INACTIVE;
td->td_lastcpu = td->td_oncpu = NOCPU;
-   td->td_allocdomain = vm_phys_domain(vtophys(td));
 
/*
 * Note that td_critnest begins life as 1 because the thread is not
@@ -420,6 +420,7 @@ thread_init(void *mem, int size, int flags)
 
td = (struct thread *)mem;
 
+   td->td_allocdomain = vm_phys_domain(vtophys(td));
td->td_sleepqueue = sleepq_alloc();
td->td_turnstile = turnstile_alloc();
td->td_rlqe = NULL;
@@ -663,7 +664,7 @@ thread_reap_all(void)
 /*
  * Reap zombies from local domain.
  */
-void
+static void
 thread_reap(void)
 {
struct thread_domain_data *tdd;

Modified: head/sys/sys/proc.h
==
--- head/sys/sys/proc.h Thu Nov 26 05:58:55 2020(r368047)
+++ head/sys/sys/proc.h Thu Nov 26 06:59:27 2020(r368048)
@@ -1142,7 +1142,6 @@ int   thread_create(struct thread *td, struct rtprio 
*rt
 void   thread_exit(void) __dead2;
 void   thread_free(struct thread *td);
 void   thread_link(struct thread *td, struct proc *p);
-void   thread_reap(void);
 intthread_single(struct proc *p, int how);
 void   thread_single_end(struct proc *p, int how);
 void   thread_stash(struct thread *td);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368047 - head/sys/amd64/vmm/amd

2020-11-25 Thread Peter Grehan
Author: grehan
Date: Thu Nov 26 05:58:55 2020
New Revision: 368047
URL: https://svnweb.freebsd.org/changeset/base/368047

Log:
  Remove manual instruction encodings for   VMLOAD, VMRUN, and VMSAVE.
  
  This is   a relic from when these instructions weren't supported by the 
toolchain.
  No functional change.
  
  Submitted by: adam_fenn.io
  Reviewed by:  grehan
  Approved by:  grehan (bhyve)
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D27130

Modified:
  head/sys/amd64/vmm/amd/svm_support.S

Modified: head/sys/amd64/vmm/amd/svm_support.S
==
--- head/sys/amd64/vmm/amd/svm_support.SThu Nov 26 04:55:02 2020
(r368046)
+++ head/sys/amd64/vmm/amd/svm_support.SThu Nov 26 05:58:55 2020
(r368047)
@@ -39,10 +39,6 @@
 #defineVENTER  push %rbp ; mov %rsp,%rbp
 #defineVLEAVE  pop %rbp
 
-#defineVMLOAD  .byte 0x0f, 0x01, 0xda
-#defineVMRUN   .byte 0x0f, 0x01, 0xd8
-#defineVMSAVE  .byte 0x0f, 0x01, 0xdb
-
 /*
  * svm_launch(uint64_t vmcb, struct svm_regctx *gctx, struct pcpu *pcpu)
  * %rdi: physical address of VMCB
@@ -91,9 +87,9 @@ ENTRY(svm_launch)
movq SCTX_RDI(%rsi), %rdi
movq SCTX_RSI(%rsi), %rsi   /* %rsi must be restored last */
 
-   VMLOAD
-   VMRUN
-   VMSAVE
+   vmload %rax
+   vmrun %rax
+   vmsave %rax
 
pop %rax/* pop guest context pointer from the stack */
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368046 - in head: contrib/traceroute share/man/man4 tests/sys/netinet tests/sys/netinet6 tests/sys/netipsec/tunnel tests/sys/netpfil/common tests/sys/netpfil/pf usr.sbin/traceroute6

2020-11-25 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 04:55:02 2020
New Revision: 368046
URL: https://svnweb.freebsd.org/changeset/base/368046

Log:
  ping: fix some man pages and tests after r368045
  
  MFC-with: r368045

Modified:
  head/contrib/traceroute/traceroute.8
  head/share/man/man4/inet6.4
  head/tests/sys/netinet/carp.sh
  head/tests/sys/netinet6/exthdr.sh
  head/tests/sys/netinet6/lpm6.sh
  head/tests/sys/netinet6/output6.sh
  head/tests/sys/netipsec/tunnel/utils.subr
  head/tests/sys/netpfil/common/pass_block.sh
  head/tests/sys/netpfil/pf/fragmentation.sh
  head/tests/sys/netpfil/pf/pass_block.sh
  head/tests/sys/netpfil/pf/table.sh
  head/usr.sbin/traceroute6/traceroute6.8

Modified: head/contrib/traceroute/traceroute.8
==
--- head/contrib/traceroute/traceroute.8Thu Nov 26 04:29:30 2020
(r368045)
+++ head/contrib/traceroute/traceroute.8Thu Nov 26 04:55:02 2020
(r368046)
@@ -16,7 +16,7 @@
 .\"$Id: traceroute.8,v 1.19 2000/09/21 08:44:19 leres Exp $
 .\"$FreeBSD$
 .\"
-.Dd June 20, 2019
+.Dd November 25, 2020
 .Dt TRACEROUTE 8
 .Os
 .Sh NAME
@@ -377,7 +377,6 @@ during normal operations or from automated scripts.
 .Sh SEE ALSO
 .Xr netstat 1 ,
 .Xr ping 8 ,
-.Xr ping6 8 ,
 .Xr traceroute6 8 .
 .Sh AUTHORS
 Implemented by Van Jacobson from a suggestion by Steve Deering.  Debugged

Modified: head/share/man/man4/inet6.4
==
--- head/share/man/man4/inet6.4 Thu Nov 26 04:29:30 2020(r368045)
+++ head/share/man/man4/inet6.4 Thu Nov 26 04:55:02 2020(r368046)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 14, 2018
+.Dd November 25, 2020
 .Dt INET6 4
 .Os
 .Sh NAME
@@ -130,7 +130,7 @@ or
 are able to use this notation.
 With special programs
 like
-.Xr ping6 8 ,
+.Xr ping 8 ,
 you can specify the outgoing interface by an extra command line option
 to disambiguate scoped addresses.
 .Pp

Modified: head/tests/sys/netinet/carp.sh
==
--- head/tests/sys/netinet/carp.sh  Thu Nov 26 04:29:30 2020
(r368045)
+++ head/tests/sys/netinet/carp.sh  Thu Nov 26 04:55:02 2020
(r368046)
@@ -137,7 +137,7 @@ basic_v6_body()
carp_basic_v6_three ${epair_two}b
 
atf_check -s exit:0 -o ignore jexec carp_basic_v6_one \
-   ping6 -c 3 2001:db8::0:1
+   ping -6 -c 3 2001:db8::0:1
 }
 
 basic_v6_cleanup()

Modified: head/tests/sys/netinet6/exthdr.sh
==
--- head/tests/sys/netinet6/exthdr.sh   Thu Nov 26 04:29:30 2020
(r368045)
+++ head/tests/sys/netinet6/exthdr.sh   Thu Nov 26 04:55:02 2020
(r368046)
@@ -74,7 +74,7 @@ exthdr_body() {
pyname=$(atf_get ident)
pyname=${pyname%*_[0-9]}
 
-   atf_check -o ignore -s exit:0 ping6 -c 3 -q -o ${ip6b}
+   atf_check -o ignore -s exit:0 ping -6 -c 3 -q -o ${ip6b}
 
atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \
--sendif ${epair}a --recvif ${epair}a \

Modified: head/tests/sys/netinet6/lpm6.sh
==
--- head/tests/sys/netinet6/lpm6.sh Thu Nov 26 04:29:30 2020
(r368045)
+++ head/tests/sys/netinet6/lpm6.sh Thu Nov 26 04:55:02 2020
(r368046)
@@ -100,7 +100,7 @@ lpm6_test1_success_body()
valid_message="${count} packets transmitted, ${count} packets received"

# Check that ${net_dst}:2:0 goes via epair0
-   atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f 
-nc${count} ${net_dst}:2:0
+   atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f 
-nc${count} ${net_dst}:2:0
pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk 
'$1!~/^Name/{print$8}'`
pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk 
'$1!~/^Name/{print$8}'`
if [ ${pkt_0} -le ${count} ]; then
@@ -109,7 +109,7 @@ lpm6_test1_success_body()
fi
 
# Check that ${net_dst}:2:1 goes via epair1
-   atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f 
-nc${count} ${net_dst}:2:1
+   atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f 
-nc${count} ${net_dst}:2:1
pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk 
'$1!~/^Name/{print$8}'`
pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk 
'$1!~/^Name/{print$8}'`
if [ ${pkt_1} -le ${count} ]; then
@@ -163,7 +163,7 @@ lpm6_test2_success_body()
valid_message="${count} packets transmitted, ${count} packets received"

# Check that ${net_dst}:2:0 goes via epair1
-   atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f 
-nc${count} ${net_dst}:2:0
+   atf_check -o match:"${valid_message}" 

svn commit: r368045 - in head: . etc/mtree rescue/rescue sbin sbin/ping sbin/ping/tests sbin/ping6 sbin/ping6/tests tools/build/mk

2020-11-25 Thread Alan Somers
Author: asomers
Date: Thu Nov 26 04:29:30 2020
New Revision: 368045
URL: https://svnweb.freebsd.org/changeset/base/368045

Log:
  Merge ping6 to ping
  
  There is now a single ping binary, which chooses to use ICMP or ICMPv4
  based on the -4 and -6 options, and the format of the address.
  
  Submitted by: Ján Sučan 
  Sponsored by: Google LLC (Google Summer of Code 2019)
  MFC after:Never
  Differential Revision:https://reviews.freebsd.org/D21377

Added:
  head/sbin/ping/main.c   (contents, props changed)
  head/sbin/ping/main.h   (contents, props changed)
  head/sbin/ping/ping.h   (contents, props changed)
  head/sbin/ping/ping6.c
 - copied, changed from r368010, head/sbin/ping6/ping6.c
  head/sbin/ping/ping6.h   (contents, props changed)
  head/sbin/ping/tests/ping_6_c1_s8_t1.out
 - copied unchanged from r368010, head/sbin/ping6/tests/ping6_c1_s8_t1.out
Deleted:
  head/sbin/ping6/Makefile
  head/sbin/ping6/Makefile.depend
  head/sbin/ping6/ping6.8
  head/sbin/ping6/ping6.c
  head/sbin/ping6/tests/Makefile
  head/sbin/ping6/tests/ping6_c1_s8_t1.out
  head/sbin/ping6/tests/ping6_test.sh
Modified:
  head/ObsoleteFiles.inc
  head/UPDATING
  head/etc/mtree/BSD.tests.dist
  head/rescue/rescue/Makefile
  head/sbin/Makefile
  head/sbin/ping/Makefile
  head/sbin/ping/ping.8
  head/sbin/ping/ping.c
  head/sbin/ping/tests/Makefile
  head/sbin/ping/tests/ping_test.sh
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Nov 26 02:14:52 2020(r368044)
+++ head/ObsoleteFiles.inc  Thu Nov 26 04:29:30 2020(r368045)
@@ -36,6 +36,16 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20201124: ping6(8) was merged into ping(8)
+OLD_FILES+=sbin/ping6
+OLD_FILES+=rescue/ping6
+OLD_FILES+=usr/lib/debug/sbin/ping6.debug
+OLD_FILES+=usr/share/man/man8/ping6.8.gz
+OLD_FILES+=usr/tests/sbin/ping6/Kyuafile
+OLD_FILES+=usr/tests/sbin/ping6/ping6_c1_s8_t1.out
+OLD_FILES+=usr/tests/sbin/ping6/ping6_test
+OLD_DIRS+=usr/tests/sbin/ping6
+
 # 20201025: Remove cal data files
 OLD_FILES+=usr/share/calendar/calendar.all
 OLD_FILES+=usr/share/calendar/calendar.australia

Modified: head/UPDATING
==
--- head/UPDATING   Thu Nov 26 02:14:52 2020(r368044)
+++ head/UPDATING   Thu Nov 26 04:29:30 2020(r368045)
@@ -26,6 +26,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
world, or to merely disable the most expensive debugging functionality
at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20201124:
+   ping6 has been merged into ping.  It can now be called as "ping -6".
+   See ping(8) for details.
+
 20201108:
Default value of net.add_addr_allfibs has been changed to 0.
If you have multi-fib configuration and rely on existence of all

Modified: head/etc/mtree/BSD.tests.dist
==
--- head/etc/mtree/BSD.tests.dist   Thu Nov 26 02:14:52 2020
(r368044)
+++ head/etc/mtree/BSD.tests.dist   Thu Nov 26 04:29:30 2020
(r368045)
@@ -448,8 +448,6 @@
 ..
 ping
 ..
-ping6
-..
 route
 ..
 ..

Modified: head/rescue/rescue/Makefile
==
--- head/rescue/rescue/Makefile Thu Nov 26 02:14:52 2020(r368044)
+++ head/rescue/rescue/Makefile Thu Nov 26 04:29:30 2020(r368045)
@@ -103,7 +103,6 @@ CRUNCH_PROGS_sbin+= ccdconfig
 .endif
 
 .if ${MK_INET6_SUPPORT} != "no"
-CRUNCH_PROGS_sbin+= ping6
 CRUNCH_PROGS_sbin+= rtsol
 .endif
 

Modified: head/sbin/Makefile
==
--- head/sbin/Makefile  Thu Nov 26 02:14:52 2020(r368044)
+++ head/sbin/Makefile  Thu Nov 26 04:29:30 2020(r368045)
@@ -73,7 +73,6 @@ SUBDIR.${MK_CCD}+=ccdconfig
 SUBDIR.${MK_CXX}+= devd
 SUBDIR.${MK_HAST}+=hastctl
 SUBDIR.${MK_HAST}+=hastd
-SUBDIR.${MK_INET6}+=   ping6
 SUBDIR.${MK_INET6}+=   rtsol
 SUBDIR.${MK_IPFILTER}+=ipf
 SUBDIR.${MK_IPFW}+=ipfw

Modified: head/sbin/ping/Makefile
==
--- head/sbin/ping/Makefile Thu Nov 26 02:14:52 2020(r368044)
+++ head/sbin/ping/Makefile Thu Nov 26 04:29:30 2020(r368045)
@@ -5,11 +5,17 @@
 
 PACKAGE=runtime
 PROG=  ping
-SRCS=  ping.c utils.c
+SRCS=  main.c ping.c utils.c
 MAN=   ping.8
 BINOWN=root
 BINMODE=4555
 LIBADD=m
+
+.if ${MK_INET6_SUPPORT} != "no"
+CFLAGS+= -DINET6 -DKAME_SCOPEID
+SRCS+= ping6.c
+LIBADD+= md
+.endif
 
 .if ${MK_DYNAMICROOT} == "no"
 .warning ${PROG} built without libcasper support

Added: head/sbin/ping/main.c

svn commit: r368044 - head/sys/dev/isp

2020-11-25 Thread Alexander Motin
Author: mav
Date: Thu Nov 26 02:14:52 2020
New Revision: 368044
URL: https://svnweb.freebsd.org/changeset/base/368044

Log:
  Some minor FCoE bits I had lying around.

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_library.c
  head/sys/dev/isp/ispmbox.h

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Thu Nov 26 01:59:44 2020(r368043)
+++ head/sys/dev/isp/isp.c  Thu Nov 26 02:14:52 2020(r368044)
@@ -3696,12 +3696,24 @@ isp_intr_async(ispsoftc_t *isp, uint16_t mbox)
isp_prt(isp, ISP_LOGERR, "Temperature alert (subcode 0x%x)",
ISP_READ(isp, OUTMAILBOX1));
break;
+   case ASYNC_INTER_DRIVER_COMP:
+   isp_prt(isp, ISP_LOGDEBUG0, "Inter-driver communication 
complete");
+   break;
+   case ASYNC_INTER_DRIVER_NOTIFY:
+   isp_prt(isp, ISP_LOGDEBUG0, "Inter-driver communication 
notification");
+   break;
+   case ASYNC_INTER_DRIVER_TIME_EXT:
+   isp_prt(isp, ISP_LOGDEBUG0, "Inter-driver communication time 
extended");
+   break;
case ASYNC_TRANSCEIVER_INSERTION:
isp_prt(isp, ISP_LOGDEBUG0, "Transceiver insertion (0x%x)",
ISP_READ(isp, OUTMAILBOX1));
break;
case ASYNC_TRANSCEIVER_REMOVAL:
isp_prt(isp, ISP_LOGDEBUG0, "Transceiver removal");
+   break;
+   case ASYNC_NIC_FW_STATE_CHANGE:
+   isp_prt(isp, ISP_LOGDEBUG0, "NIC Firmware State Change");
break;
case ASYNC_AUTOLOAD_FW_COMPLETE:
isp_prt(isp, ISP_LOGDEBUG0, "Autoload FW init complete");

Modified: head/sys/dev/isp/isp_library.c
==
--- head/sys/dev/isp/isp_library.c  Thu Nov 26 01:59:44 2020
(r368043)
+++ head/sys/dev/isp/isp_library.c  Thu Nov 26 02:14:52 2020
(r368044)
@@ -782,8 +782,8 @@ isp_put_icb_2400(ispsoftc_t *isp, isp_icb_2400_t *src,
ISP_IOXPUT_16(isp, src->icb_qos, >icb_qos);
for (i = 0; i < 3; i++)
ISP_IOXPUT_16(isp, src->icb_reserved2[i], 
>icb_reserved2[i]);
-   for (i = 0; i < 3; i++)
-   ISP_IOXPUT_16(isp, src->icb_enodemac[i], >icb_enodemac[i]);
+   for (i = 0; i < 6; i++)
+   ISP_IOXPUT_8(isp, src->icb_enodemac[i], >icb_enodemac[i]);
ISP_IOXPUT_16(isp, src->icb_disctime, >icb_disctime);
for (i = 0; i < 4; i++)
ISP_IOXPUT_16(isp, src->icb_reserved3[i], 
>icb_reserved3[i]);

Modified: head/sys/dev/isp/ispmbox.h
==
--- head/sys/dev/isp/ispmbox.h  Thu Nov 26 01:59:44 2020(r368043)
+++ head/sys/dev/isp/ispmbox.h  Thu Nov 26 02:14:52 2020(r368044)
@@ -805,7 +805,7 @@ typedef struct {
uint32_ticb_fwoptions3;
uint16_ticb_qos;
uint16_ticb_reserved2[3];
-   uint16_ticb_enodemac[3];
+   uint8_t icb_enodemac[6];
uint16_ticb_disctime;
uint16_ticb_reserved3[4];
 } isp_icb_2400_t;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368043 - head/sys/dev/isp

2020-11-25 Thread Alexander Motin
Author: mav
Date: Thu Nov 26 01:59:44 2020
New Revision: 368043
URL: https://svnweb.freebsd.org/changeset/base/368043

Log:
  Remove some more dead code from pre-24xx.

Modified:
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/isp_library.c
  head/sys/dev/isp/isp_library.h
  head/sys/dev/isp/isp_target.c
  head/sys/dev/isp/isp_target.h
  head/sys/dev/isp/ispvar.h

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Thu Nov 26 01:40:04 2020
(r368042)
+++ head/sys/dev/isp/isp_freebsd.c  Thu Nov 26 01:59:44 2020
(r368043)
@@ -1794,16 +1794,6 @@ isp_handle_platform_target_notify_ack(ispsoftc_t *isp,
}
 
/*
-* Handle logout cases here
-*/
-   if (mp->nt_ncode == NT_GLOBAL_LOGOUT) {
-   isp_del_all_wwn_entries(isp, mp->nt_channel);
-   }
-
-   if (mp->nt_ncode == NT_LOGOUT)
-   isp_del_wwn_entries(isp, mp);
-
-   /*
 * General purpose acknowledgement
 */
if (mp->nt_need_ack) {
@@ -2889,15 +2879,6 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
va_list ap;
 
switch (cmd) {
-   case ISPASYNC_BUS_RESET:
-   {
-   va_start(ap, cmd);
-   bus = va_arg(ap, int);
-   va_end(ap);
-   isp_prt(isp, ISP_LOGINFO, "SCSI bus reset on bus %d detected", 
bus);
-   xpt_async(AC_BUS_RESET, ISP_FC_PC(isp, bus)->path, NULL);
-   break;
-   }
case ISPASYNC_LOOP_RESET:
{
uint16_t lipp;
@@ -3141,7 +3122,6 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
 */
isp_handle_platform_target_tmf(isp, notify);
break;
-   case NT_BUS_RESET:
case NT_LIP_RESET:
case NT_LINK_UP:
case NT_LINK_DOWN:
@@ -3149,13 +3129,6 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
/*
 * No action need be taken here.
 */
-   break;
-   case NT_GLOBAL_LOGOUT:
-   case NT_LOGOUT:
-   /*
-* This is device arrival/departure notification
-*/
-   isp_handle_platform_target_notify_ack(isp, notify, 0);
break;
case NT_SRR:
isp_handle_platform_srr(isp, notify);

Modified: head/sys/dev/isp/isp_library.c
==
--- head/sys/dev/isp/isp_library.c  Thu Nov 26 01:40:04 2020
(r368042)
+++ head/sys/dev/isp/isp_library.c  Thu Nov 26 01:59:44 2020
(r368043)
@@ -1656,82 +1656,6 @@ isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t 
 }
 
 void
-isp_del_all_wwn_entries(ispsoftc_t *isp, int chan)
-{
-   fcparam *fcp;
-   int i;
-
-   /*
-* Handle iterations over all channels via recursion
-*/
-   if (chan == ISP_NOCHAN) {
-   for (chan = 0; chan < isp->isp_nchan; chan++) {
-   isp_del_all_wwn_entries(isp, chan);
-   }
-   return;
-   }
-
-   if (chan > isp->isp_nchan) {
-   return;
-   }
-
-   fcp = FCPARAM(isp, chan);
-   if (fcp == NULL) {
-   return;
-   }
-   for (i = 0; i < MAX_FC_TARG; i++) {
-   fcportdb_t *lp = >portdb[i];
-
-   if (lp->state != FC_PORTDB_STATE_NIL)
-   isp_del_wwn_entry(isp, chan, lp->port_wwn, lp->handle, 
lp->portid);
-   }
-}
-
-void
-isp_del_wwn_entries(ispsoftc_t *isp, isp_notify_t *mp)
-{
-   fcportdb_t *lp;
-
-   /*
-* Handle iterations over all channels via recursion
-*/
-   if (mp->nt_channel == ISP_NOCHAN) {
-   for (mp->nt_channel = 0; mp->nt_channel < isp->isp_nchan; 
mp->nt_channel++) {
-   isp_del_wwn_entries(isp, mp);
-   }
-   mp->nt_channel = ISP_NOCHAN;
-   return;
-   }
-
-   /*
-* We have an entry which is only partially identified.
-*
-* It's only known by WWN, N-Port handle, or Port ID.
-* We need to find the actual entry so we can delete it.
-*/
-   if (mp->nt_nphdl != NIL_HANDLE) {
-   if (isp_find_pdb_by_handle(isp, mp->nt_channel, mp->nt_nphdl, 
)) {
-   isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, 
lp->handle, lp->portid);
-   return;
-   }
-   }
-   if (VALID_INI(mp->nt_wwn)) {
-   if (isp_find_pdb_by_wwpn(isp, mp->nt_channel, mp->nt_wwn, )) 
{
-   isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, 
lp->handle, lp->portid);
-   

svn commit: r368042 - in head: share/doc/legal share/doc/legal/imx sys/arm/freescale/imx sys/contrib/dev/imx

2020-11-25 Thread Ian Lepore
Author: ian
Date: Thu Nov 26 01:40:04 2020
New Revision: 368042
URL: https://svnweb.freebsd.org/changeset/base/368042

Log:
  Add the firmware blob required to use the sdma hardware in the imx6
  processor, and its associated license text (which is similar to a
  bsd-3-clause, but with a prohibition against decompiling).  Install a copy
  of the license in /usr/share/doc/legal/imx, to comply with the license terms
  that requires a copy of the license to be delivered along with the firmware.
  
  Obtained from:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/imx/sdma/sdma-imx6q.bin
 
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENSE.sdma_firmware

Added:
  head/share/doc/legal/Makefile.armv7   (contents, props changed)
  head/share/doc/legal/imx/
  head/share/doc/legal/imx/Makefile   (contents, props changed)
  head/sys/contrib/dev/imx/
  head/sys/contrib/dev/imx/LICENSE
  head/sys/contrib/dev/imx/sdma-imx6q.bin.uu
Modified:
  head/share/doc/legal/Makefile
  head/sys/arm/freescale/imx/files.imx6
  head/sys/arm/freescale/imx/imx6_sdma.c

Modified: head/share/doc/legal/Makefile
==
--- head/share/doc/legal/Makefile   Wed Nov 25 23:19:01 2020
(r368041)
+++ head/share/doc/legal/Makefile   Thu Nov 26 01:40:04 2020
(r368042)
@@ -8,4 +8,5 @@ SUBDIR= intel_ipw \
 
 SUBDIR_PARALLEL=
 
+.include 
 .include 

Added: head/share/doc/legal/Makefile.armv7
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/doc/legal/Makefile.armv7 Thu Nov 26 01:40:04 2020
(r368042)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+SUBDIR += imx

Added: head/share/doc/legal/imx/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/doc/legal/imx/Makefile   Thu Nov 26 01:40:04 2020
(r368042)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+FILES= ${SRCTOP}/sys/contrib/dev/imx/LICENSE
+FILESDIR=  ${SHAREDIR}/doc/legal
+FILESNAME= sdma-imx6q.LICENSE
+
+.include 

Modified: head/sys/arm/freescale/imx/files.imx6
==
--- head/sys/arm/freescale/imx/files.imx6   Wed Nov 25 23:19:01 2020
(r368041)
+++ head/sys/arm/freescale/imx/files.imx6   Thu Nov 26 01:40:04 2020
(r368042)
@@ -20,7 +20,7 @@ arm/freescale/imx/imx_i2c.c   optional fsliic
 arm/freescale/imx/imx_spi.coptional imx_spi
 arm/freescale/imx/imx6_sdma.c  optional fslsdma
 arm/freescale/imx/imx6_audmux.coptional sound
-arm/freescale/imx/imx6_ssi.c   optional sound
+arm/freescale/imx/imx6_ssi.c   optional sound fslsdma
 arm/freescale/imx/imx6_ahci.c  optional ahci
 
 dev/hdmi/dwc_hdmi.coptional hdmi
@@ -47,23 +47,18 @@ arm/freescale/imx/imx6_usbphy.c optional ehci
 #
 #arm/freescale/imx/imx_console.c   standard
 
-#
-# Not ready yet...
-#
-#arm/freescale/imx/imx51_ipuv3.c   optional sc
-
-# SDMA firmware
-sdma_fw.c  optional sdma_fw\
-   compile-with"${AWK} -f $S/tools/fw_stub.awk 
sdma-imx6q-to1.bin:sdma_fw -msdma -c${.TARGET}" \
+# SDMA firmware.
+sdma-imx6q.c   optional fslsdma\
+   compile-with"${AWK} -f $S/tools/fw_stub.awk 
sdma-imx6q.bin:sdma-imx6q -msdma -c${.TARGET}" \
no-implicit-rule before-depend local\
-   clean   "sdma_fw.c"
-sdma-imx6q-to1.fwo optional sdma_fw\
-   dependency  "sdma-imx6q-to1.bin"\
-   compile-with"${LD} -m ${LD_EMULATION} -b binary -d -warn-common -r 
-d -o ${.TARGET} sdma-imx6q-to1.bin" \
+   clean   "sdma-imx6q.c"
+sdma-imx6q.fwo optional fslsdma\
+   dependency  "sdma-imx6q.bin"\
+   compile-with"${LD} -m ${LD_EMULATION} -b binary -d -warn-common -r 
-d -o ${.TARGET} sdma-imx6q.bin" \
no-implicit-rule\
-   clean   "sdma-imx6q-to1.fwo"
-sdma-imx6q-to1.bin optional sdma_fw\
-   dependency  "$S/contrib/dev/imx/sdma-imx6q-to1.bin.uu"  \
-   compile-with"uudecode < $S/contrib/dev/imx/sdma-imx6q-to1.bin.uu" \
+   clean   "sdma-imx6q.fwo"
+sdma-imx6q.bin optional fslsdma\
+   dependency  "$S/contrib/dev/imx/sdma-imx6q.bin.uu"  \
+   compile-with"uudecode < $S/contrib/dev/imx/sdma-imx6q.bin.uu"   \
no-obj no-implicit-rule 

svn commit: r368041 - in head: stand/efi/loader sys/amd64/amd64 sys/amd64/include sys/conf

2020-11-25 Thread Maxim Sobolev
Author: sobomax
Date: Wed Nov 25 23:19:01 2020
New Revision: 368041
URL: https://svnweb.freebsd.org/changeset/base/368041

Log:
  Unobfuscate "KERNLOAD" parameter on amd64. This change lines-up amd64 with the
  i386 and the rest of supported architectures by defining KERNLOAD in the
  vmparam.h and getting rid of magic constant in the linker script, which albeit
  documented via comment but isn't programmatically accessible at a compile 
time.
  
  Use KERNLOAD to eliminate another (matching) magic constant 100 lines down
  inside unremarkable TU "copy.c" 3 levels deep in the EFI loader tree.
  
  Reviewed by:  markj
  Approved by:  markj
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D27355

Modified:
  head/stand/efi/loader/copy.c
  head/sys/amd64/amd64/genassym.c
  head/sys/amd64/amd64/locore.S
  head/sys/amd64/include/vmparam.h
  head/sys/conf/ldscript.amd64

Modified: head/stand/efi/loader/copy.c
==
--- head/stand/efi/loader/copy.cWed Nov 25 23:17:23 2020
(r368040)
+++ head/stand/efi/loader/copy.cWed Nov 25 23:19:01 2020
(r368041)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #if defined(__i386__) || defined(__amd64__)
 #include 
 #include 
+#include 
 
 /*
  * The code is excerpted from sys/x86/x86/identcpu.c: identify_cpu(),
@@ -89,8 +90,6 @@ running_on_hyperv(void)
return (1);
 }
 
-#define KERNEL_PHYSICAL_BASE (2*1024*1024)
-
 static void
 efi_verify_staging_size(unsigned long *nr_pages)
 {
@@ -134,12 +133,11 @@ efi_verify_staging_size(unsigned long *nr_pages)
start = p->PhysicalStart;
end = start + p->NumberOfPages * EFI_PAGE_SIZE;
 
-   if (KERNEL_PHYSICAL_BASE < start ||
-   KERNEL_PHYSICAL_BASE >= end)
+   if (KERNLOAD < start || KERNLOAD >= end)
continue;
 
available_pages = p->NumberOfPages -
-   ((KERNEL_PHYSICAL_BASE - start) >> EFI_PAGE_SHIFT);
+   ((KERNLOAD - start) >> EFI_PAGE_SHIFT);
break;
}
 

Modified: head/sys/amd64/amd64/genassym.c
==
--- head/sys/amd64/amd64/genassym.c Wed Nov 25 23:17:23 2020
(r368040)
+++ head/sys/amd64/amd64/genassym.c Wed Nov 25 23:19:01 2020
(r368041)
@@ -115,6 +115,7 @@ ASSYM(val_KPML4I, KPML4I);
 ASSYM(val_PML4PML4I, PML4PML4I);
 ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
 ASSYM(KERNBASE, KERNBASE);
+ASSYM(KERNLOAD, KERNLOAD);
 ASSYM(DMAP_MIN_ADDRESS, DMAP_MIN_ADDRESS);
 ASSYM(DMAP_MAX_ADDRESS, DMAP_MAX_ADDRESS);
 

Modified: head/sys/amd64/amd64/locore.S
==
--- head/sys/amd64/amd64/locore.S   Wed Nov 25 23:17:23 2020
(r368040)
+++ head/sys/amd64/amd64/locore.S   Wed Nov 25 23:19:01 2020
(r368041)
@@ -36,8 +36,9 @@
 /*
  * Compiled KERNBASE location
  */
-   .globl  kernbase, loc_PTmap, loc_PDmap, loc_PDPmap, dmapbase, dmapend
+   .globl  kernbase, kernload, loc_PTmap, loc_PDmap, loc_PDPmap, dmapbase, 
dmapend
.setkernbase,KERNBASE
+   .setkernload,KERNLOAD
.setdmapbase,DMAP_MIN_ADDRESS
.setdmapend,DMAP_MAX_ADDRESS
 

Modified: head/sys/amd64/include/vmparam.h
==
--- head/sys/amd64/include/vmparam.hWed Nov 25 23:17:23 2020
(r368040)
+++ head/sys/amd64/include/vmparam.hWed Nov 25 23:19:01 2020
(r368041)
@@ -149,6 +149,14 @@
 #endif
 
 /*
+ * Kernel physical load address. Needs to be aligned at 2MB superpage
+ * boundary.
+ */
+#ifndef KERNLOAD
+#defineKERNLOAD0x20
+#endif
+
+/*
  * Virtual addresses of things.  Derived from the page directory and
  * page table indexes from pmap.h for precision.
  *

Modified: head/sys/conf/ldscript.amd64
==
--- head/sys/conf/ldscript.amd64Wed Nov 25 23:17:23 2020
(r368040)
+++ head/sys/conf/ldscript.amd64Wed Nov 25 23:19:01 2020
(r368041)
@@ -5,8 +5,8 @@ ENTRY(btext)
 SEARCH_DIR("/usr/lib");
 SECTIONS
 {
+  kernphys = kernload;
   /* Read-only sections, merged into text segment: */
-  kernphys = 0x20; /* 2MB superpage size */
   . = kernbase + kernphys + SIZEOF_HEADERS;
   /*
* Use the AT keyword in order to set the right LMA that contains
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368040 - head/share/man/man4

2020-11-25 Thread John Baldwin
Author: jhb
Date: Wed Nov 25 23:17:23 2020
New Revision: 368040
URL: https://svnweb.freebsd.org/changeset/base/368040

Log:
  Add a manpage for kernel TLS.
  
  This subsumes some of the content from tcp(4) describing the socket
  options but also adds additional notes.
  
  Reviewed by:  gallatin, hselasky
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D27272

Added:
  head/share/man/man4/ktls.4   (contents, props changed)
Modified:
  head/share/man/man4/Makefile
  head/share/man/man4/tcp.4

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileWed Nov 25 22:53:21 2020
(r368039)
+++ head/share/man/man4/MakefileWed Nov 25 23:17:23 2020
(r368040)
@@ -250,6 +250,7 @@ MAN=aac.4 \
kld.4 \
ksyms.4 \
ksz8995ma.4 \
+   ktls.4 \
ktr.4 \
kue.4 \
lagg.4 \

Added: head/share/man/man4/ktls.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/ktls.4  Wed Nov 25 23:17:23 2020(r368040)
@@ -0,0 +1,264 @@
+.\" Copyright (c) 2020, Chelsio 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.
+.\"
+.\" 3. Neither the name of the Chelsio Inc nor the names of its
+.\"contributors may be used to endorse or promote products derived from
+.\"this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" * Other names and brands may be claimed as the property of others.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd November 25, 2020
+.Dt KTLS 4
+.Os
+.Sh NAME
+.Nm ktls
+.Nd kernel Transport Layer Security
+.Sh SYNOPSIS
+.Cd options KERN_TLS
+.Sh DESCRIPTION
+The
+.Nm
+facility allows the kernel to perform Transport Layer Security (TLS)
+framing on TCP sockets.
+With
+.Nm ,
+the initial handshake for a socket using TLS is performed in userland.
+Once the session keys are negotiated,
+they are provided to the kernel via the
+.Dv TCP_TXTLS_ENABLE
+and
+.Dv TCP_RXTLS_ENABLE
+socket options.
+Both socket options accept a
+.Vt struct tls_so_enable
+structure as their argument.
+The members of this structure describe the cipher suite used for the
+TLS session and provide the session keys used for the respective
+direction.
+.Pp
+.Nm
+only permits the session keys to be set once in each direction.
+As a result,
+applications must disable rekeying when using
+.Nm .
+.Ss Modes
+.Nm
+can operate in different modes.
+A given socket may use different modes for transmit and receive,
+or a socket may only offload a single direction.
+The available modes are:
+.Bl -tag -width "Dv TCP_TLS_MODE_IFNET"
+.It Dv TCP_TLS_MODE_NONE
+.Nm
+is not enabled.
+.It Dv TCP_TLS_MODE_SW
+TLS records are encrypted or decrypted in the kernel in the socket
+layer.
+Typically the encryption or decryption is performred in software,
+but it may also be performed by co-processors via
+.Xr crypto 9 .
+.It Dv TCP_TLS_MODE_IFNET
+TLS records are encrypted or decrypted by the network interface card (NIC).
+In this mode, the network stack does not work with encrypted data.
+Instead, the NIC is encrypts TLS records as they are being transmitted,
+or decrypts received TLS records before providing them to the host.
+.Pp
+Network interfaces which support this feature will advertise the
+.Dv TXTLS4
+(for IPv4)
+and/or
+.Dv TXTLS6
+(for IPv6)
+capabilities as reported by
+.Xr ifconfig 8 .
+These capabilities can also be controlled by
+.Xr ifconfig 8 .
+.Pp
+If a network interface supports rate limiting
+(also known as 

svn commit: r368039 - head/sys/kern

2020-11-25 Thread Mateusz Guzik
Author: mjg
Date: Wed Nov 25 22:53:21 2020
New Revision: 368039
URL: https://svnweb.freebsd.org/changeset/base/368039

Log:
  pipe: follow up cleanup to previous
  
  The commited patch was incomplete.
  
  - add back missing goto retry, noted by jhb
  - 'if (error)'  -> 'if (error != 0)'
  - consistently do:
  
  if (error != 0)
  break;
  continue;
  
  instead of:
  
  if (error != 0)
  break;
  else
  continue;
  
  This adds some 'continue' uses which are not needed, but line up with the
  rest of pipe_write.

Modified:
  head/sys/kern/sys_pipe.c

Modified: head/sys/kern/sys_pipe.c
==
--- head/sys/kern/sys_pipe.cWed Nov 25 21:41:23 2020(r368038)
+++ head/sys/kern/sys_pipe.cWed Nov 25 22:53:21 2020(r368039)
@@ -994,8 +994,9 @@ retry:
error = msleep(wpipe, PIPE_MTX(wpipe),
PRIBIO | PCATCH, "pipdww", 0);
pipelock(wpipe, 0);
-   if (error)
+   if (error != 0)
goto error1;
+   goto retry;
}
if (wpipe->pipe_buffer.cnt > 0) {
if (wpipe->pipe_state & PIPE_WANTR) {
@@ -1008,10 +1009,9 @@ retry:
error = msleep(wpipe, PIPE_MTX(wpipe),
PRIBIO | PCATCH, "pipdwc", 0);
pipelock(wpipe, 0);
-   if (error)
+   if (error != 0)
goto error1;
-   else
-   goto retry;
+   goto retry;
}
 
error = pipe_build_write_buffer(wpipe, uio);
@@ -1142,7 +1142,7 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
wpipe->pipe_buffer.size >= PIPE_MINDIRECT &&
(fp->f_flag & FNONBLOCK) == 0) {
error = pipe_direct_write(wpipe, uio);
-   if (error)
+   if (error != 0)
break;
continue;
}
@@ -1166,10 +1166,9 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
error = msleep(wpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH,
"pipbww", 0);
pipelock(wpipe, 0);
-   if (error)
+   if (error != 0)
break;
-   else
-   continue;
+   continue;
}
 
space = wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt;
@@ -1243,6 +1242,7 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
}
if (error != 0)
break;
+   continue;
} else {
/*
 * If the "read-side" has been blocked, wake it up now.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r368038 - head/sys/kern

2020-11-25 Thread John Baldwin
On 11/25/20 1:41 PM, Mateusz Guzik wrote:
> Author: mjg
> Date: Wed Nov 25 21:41:23 2020
> New Revision: 368038
> URL: https://svnweb.freebsd.org/changeset/base/368038
> 
> Log:
>   pipe: drop spurious pipeunlock/pipelock cycle on write
> 
> Modified:
>   head/sys/kern/sys_pipe.c
> 
> Modified: head/sys/kern/sys_pipe.c
> ==
> --- head/sys/kern/sys_pipe.c  Wed Nov 25 21:25:17 2020(r368037)
> +++ head/sys/kern/sys_pipe.c  Wed Nov 25 21:41:23 2020(r368038)
> @@ -997,10 +993,9 @@ retry:
>   pipeunlock(wpipe);
>   error = msleep(wpipe, PIPE_MTX(wpipe),
>   PRIBIO | PCATCH, "pipdww", 0);
> + pipelock(wpipe, 0);
>   if (error)
>   goto error1;
> - else
> - goto retry;
>   }

Hmm, what ensures that PIPE_EOF and PIPE_DIRECTW aren't still
set once awakened that would permit removing the 'goto retry'?
The goto is still present in the other case in this function, it
was only removed from this one?

> @@ -1282,12 +1270,13 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
>   pipeunlock(wpipe);
>   error = msleep(wpipe, PIPE_MTX(rpipe),
>   PRIBIO | PCATCH, "pipewr", 0);
> + pipelock(wpipe, 0);
>   if (error != 0)
>   break;
> + continue;

A continue as the last line of a while() loop seems spurious?

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


Re: svn commit: r368022 - head/lib/libsysdecode

2020-11-25 Thread John Baldwin
On 11/25/20 8:30 AM, Pawel Biernacki wrote:
> Author: kaktus
> Date: Wed Nov 25 16:30:57 2020
> New Revision: 368022
> URL: https://svnweb.freebsd.org/changeset/base/368022
> 
> Log:
>   libsysdecode: correctly decode mmap flags
>   
>   r352913 added decoding of mmap PROT_MAX()'d flags but didn’t account for the
>   case where different values were specified for PROT_MAX and regular flags.
>   Fix it.
>   
>   Submitted by:   sigsys_gmail.com
>   Reported by:sigsys_gmail.com
>   MFC after:  7 days
>   Differential Revision:  https://reviews.freebsd.org/D27312
> 
> Modified:
>   head/lib/libsysdecode/flags.c
> 
> Modified: head/lib/libsysdecode/flags.c
> ==
> --- head/lib/libsysdecode/flags.c Wed Nov 25 15:45:20 2020
> (r368021)
> +++ head/lib/libsysdecode/flags.c Wed Nov 25 16:30:57 2020
> (r368022)
> @@ -662,11 +662,11 @@ sysdecode_mmap_prot(FILE *fp, int prot, int *rem)
>  
>   printed = false;
>   protm = PROT_MAX_EXTRACT(prot);
> + prot = PROT_EXTRACT(prot);
>   if (protm != 0) {
>   fputs("PROT_MAX(", fp);
>   printed = print_mask_int(fp, mmapprot, protm, rem);
>   fputs(")|", fp);
> - prot = protm;

This was probably meant to be something more like 'prot &= ~PROT_MAX(protm);'.

As it is, if there are any invalid bits set, those are now lost.  The change
to mask off only the PROT_MAX bits would preserve any invalid/unknown bits.
(To test, try passing -1 or the like as a prot value and comparing the
decoded output for kdump or truss.)

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


svn commit: r368038 - head/sys/kern

2020-11-25 Thread Mateusz Guzik
Author: mjg
Date: Wed Nov 25 21:41:23 2020
New Revision: 368038
URL: https://svnweb.freebsd.org/changeset/base/368038

Log:
  pipe: drop spurious pipeunlock/pipelock cycle on write

Modified:
  head/sys/kern/sys_pipe.c

Modified: head/sys/kern/sys_pipe.c
==
--- head/sys/kern/sys_pipe.cWed Nov 25 21:25:17 2020(r368037)
+++ head/sys/kern/sys_pipe.cWed Nov 25 21:41:23 2020(r368038)
@@ -979,12 +979,8 @@ pipe_direct_write(struct pipe *wpipe, struct uio *uio)
 
 retry:
PIPE_LOCK_ASSERT(wpipe, MA_OWNED);
-   error = pipelock(wpipe, 1);
-   if (error != 0)
-   goto error1;
if ((wpipe->pipe_state & PIPE_EOF) != 0) {
error = EPIPE;
-   pipeunlock(wpipe);
goto error1;
}
if (wpipe->pipe_state & PIPE_DIRECTW) {
@@ -997,10 +993,9 @@ retry:
pipeunlock(wpipe);
error = msleep(wpipe, PIPE_MTX(wpipe),
PRIBIO | PCATCH, "pipdww", 0);
+   pipelock(wpipe, 0);
if (error)
goto error1;
-   else
-   goto retry;
}
if (wpipe->pipe_buffer.cnt > 0) {
if (wpipe->pipe_state & PIPE_WANTR) {
@@ -1012,6 +1007,7 @@ retry:
pipeunlock(wpipe);
error = msleep(wpipe, PIPE_MTX(wpipe),
PRIBIO | PCATCH, "pipdwc", 0);
+   pipelock(wpipe, 0);
if (error)
goto error1;
else
@@ -1020,7 +1016,6 @@ retry:
 
error = pipe_build_write_buffer(wpipe, uio);
if (error) {
-   pipeunlock(wpipe);
goto error1;
}
 
@@ -1050,7 +1045,6 @@ retry:
} else {
pipe_destroy_write_buffer(wpipe);
}
-   pipeunlock(wpipe);
KASSERT((wpipe->pipe_state & PIPE_DIRECTW) == 0,
("pipe %p leaked PIPE_DIRECTW", wpipe));
return (error);
@@ -1124,16 +1118,12 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
}
MPASS(wpipe->pipe_buffer.size != 0);
 
-   pipeunlock(wpipe);
-
orig_resid = uio->uio_resid;
 
while (uio->uio_resid) {
int space;
 
-   pipelock(wpipe, 0);
if (wpipe->pipe_state & PIPE_EOF) {
-   pipeunlock(wpipe);
error = EPIPE;
break;
}
@@ -1151,7 +1141,6 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
uio->uio_iov->iov_len >= PIPE_MINDIRECT &&
wpipe->pipe_buffer.size >= PIPE_MINDIRECT &&
(fp->f_flag & FNONBLOCK) == 0) {
-   pipeunlock(wpipe);
error = pipe_direct_write(wpipe, uio);
if (error)
break;
@@ -1176,6 +1165,7 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
pipeunlock(wpipe);
error = msleep(wpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH,
"pipbww", 0);
+   pipelock(wpipe, 0);
if (error)
break;
else
@@ -1251,7 +1241,6 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
wpipe->pipe_buffer.size,
("Pipe buffer overflow"));
}
-   pipeunlock(wpipe);
if (error != 0)
break;
} else {
@@ -1268,7 +1257,6 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
 */
if (fp->f_flag & FNONBLOCK) {
error = EAGAIN;
-   pipeunlock(wpipe);
break;
}
 
@@ -1282,12 +1270,13 @@ pipe_write(struct file *fp, struct uio *uio, struct uc
pipeunlock(wpipe);
error = msleep(wpipe, PIPE_MTX(rpipe),
PRIBIO | PCATCH, "pipewr", 0);
+   pipelock(wpipe, 0);
if (error != 0)
break;
+   continue;
}
}
 
-   pipelock(wpipe, 0);
--wpipe->pipe_busy;
 
if ((wpipe->pipe_busy == 0) && (wpipe->pipe_state & PIPE_WANT)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368037 - stable/12/tools/tools/netmap

2020-11-25 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Nov 25 21:25:17 2020
New Revision: 368037
URL: https://svnweb.freebsd.org/changeset/base/368037

Log:
  MFC r367936
  
  netmap: bridge: improve readability
  
  Multiple cosmetic changes, plus a fix to a verbose print
  (indicating wrong net->host/host->net direction).

Modified:
  stable/12/tools/tools/netmap/bridge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tools/tools/netmap/bridge.c
==
--- stable/12/tools/tools/netmap/bridge.c   Wed Nov 25 21:24:39 2020
(r368036)
+++ stable/12/tools/tools/netmap/bridge.c   Wed Nov 25 21:25:17 2020
(r368037)
@@ -3,19 +3,19 @@
  *
  * BSD license
  *
- * A netmap client to bridge two network interfaces
- * (or one interface and the host stack).
+ * A netmap application to bridge two network interfaces,
+ * or one interface and the host stack.
  *
  * $FreeBSD$
  */
 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
-#include 
 
 static int verbose = 0;
 
@@ -32,30 +32,39 @@ sigint_h(int sig)
 
 
 /*
- * how many packets on this set of queues ?
+ * How many slots do we (user application) have on this
+ * set of queues ?
  */
 static int
-pkt_queued(struct nmport_d *d, int tx)
+rx_slots_avail(struct nmport_d *d)
 {
u_int i, tot = 0;
 
-   if (tx) {
-   for (i = d->first_tx_ring; i <= d->last_tx_ring; i++) {
-   tot += nm_ring_space(NETMAP_TXRING(d->nifp, i));
-   }
-   } else {
-   for (i = d->first_rx_ring; i <= d->last_rx_ring; i++) {
-   tot += nm_ring_space(NETMAP_RXRING(d->nifp, i));
-   }
+   for (i = d->first_rx_ring; i <= d->last_rx_ring; i++) {
+   tot += nm_ring_space(NETMAP_RXRING(d->nifp, i));
}
+
return tot;
 }
 
+static int
+tx_slots_avail(struct nmport_d *d)
+{
+   u_int i, tot = 0;
+
+   for (i = d->first_tx_ring; i <= d->last_tx_ring; i++) {
+   tot += nm_ring_space(NETMAP_TXRING(d->nifp, i));
+   }
+
+   return tot;
+}
+
 /*
- * move up to 'limit' pkts from rxring to txring swapping buffers.
+ * Move up to 'limit' pkts from rxring to txring, swapping buffers
+ * if zerocopy is possible. Otherwise fall back on packet copying.
  */
 static int
-process_rings(struct netmap_ring *rxring, struct netmap_ring *txring,
+rings_move(struct netmap_ring *rxring, struct netmap_ring *txring,
  u_int limit, const char *msg)
 {
u_int j, k, m = 0;
@@ -63,7 +72,7 @@ process_rings(struct netmap_ring *rxring, struct netma
/* print a warning if any of the ring flags is set (e.g. NM_REINIT) */
if (rxring->flags || txring->flags)
D("%s rxflags %x txflags %x",
-   msg, rxring->flags, txring->flags);
+   msg, rxring->flags, txring->flags);
j = rxring->head; /* RX */
k = txring->head; /* TX */
m = nm_ring_space(rxring);
@@ -79,16 +88,18 @@ process_rings(struct netmap_ring *rxring, struct netma
 
/* swap packets */
if (ts->buf_idx < 2 || rs->buf_idx < 2) {
-   RD(5, "wrong index rx[%d] = %d  -> tx[%d] = %d",
-   j, rs->buf_idx, k, ts->buf_idx);
+   RD(2, "wrong index rxr[%d] = %d  -> txr[%d] = %d",
+   j, rs->buf_idx, k, ts->buf_idx);
sleep(2);
}
/* copy the packet length. */
if (rs->len > rxring->nr_buf_size) {
-   RD(5, "wrong len %d rx[%d] -> tx[%d]", rs->len, j, k);
+   RD(2,  "%s: invalid len %u, rxr[%d] -> txr[%d]",
+   msg, rs->len, j, k);
rs->len = 0;
} else if (verbose > 1) {
-   D("%s send len %d rx[%d] -> tx[%d]", msg, rs->len, j, 
k);
+   D("%s: fwd len %u, rx[%d] -> tx[%d]",
+   msg, rs->len, j, k);
}
ts->len = rs->len;
if (zerocopy) {
@@ -111,24 +122,23 @@ process_rings(struct netmap_ring *rxring, struct netma
rxring->head = rxring->cur = j;
txring->head = txring->cur = k;
if (verbose && m > 0)
-   D("%s sent %d packets to %p", msg, m, txring);
+   D("%s fwd %d packets: rxring %u --> txring %u",
+   msg, m, rxring->ringid, txring->ringid);
 
return (m);
 }
 
-/* move packts from src to destination */
+/* Move packets from source port to destination port. */
 static int
-move(struct nmport_d *src, struct nmport_d *dst, u_int limit)
+ports_move(struct nmport_d *src, struct nmport_d *dst, u_int limit,
+   const char *msg)
 {
struct netmap_ring *txring, *rxring;
u_int m = 0, si = src->first_rx_ring, di = 

svn commit: r368036 - stable/12/usr.sbin/valectl

2020-11-25 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Nov 25 21:24:39 2020
New Revision: 368036
URL: https://svnweb.freebsd.org/changeset/base/368036

Log:
  MFC r367935
  
  netmap: valectl: switch to libnetmap
  
  Use the newer libnetmap (included in base) rather than the older
  nm_open()/nm_close() defined in netmap_user.h

Modified:
  stable/12/usr.sbin/valectl/Makefile
  stable/12/usr.sbin/valectl/valectl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/valectl/Makefile
==
--- stable/12/usr.sbin/valectl/Makefile Wed Nov 25 21:23:58 2020
(r368035)
+++ stable/12/usr.sbin/valectl/Makefile Wed Nov 25 21:24:39 2020
(r368036)
@@ -5,4 +5,6 @@ MAN=valectl.8
 
 WARNS?=3
 
+LIBADD=netmap
+
 .include 

Modified: stable/12/usr.sbin/valectl/valectl.c
==
--- stable/12/usr.sbin/valectl/valectl.cWed Nov 25 21:23:58 2020
(r368035)
+++ stable/12/usr.sbin/valectl/valectl.cWed Nov 25 21:24:39 2020
(r368036)
@@ -25,9 +25,8 @@
 
 /* $FreeBSD$ */
 
-#define NETMAP_WITH_LIBS
-#include 
-#include 
+#define LIBNETMAP_NOTHREADSAFE
+#include 
 
 #include 
 #include 
@@ -42,14 +41,58 @@
 #include /* basename */
 #include /* atoi, free */
 
+int verbose;
+
+struct args {
+   const char *name;
+   const char *config;
+   const char *mem_id;
+
+   uint16_t nr_reqtype;
+   uint32_t nr_mode;
+};
+
 static void
-parse_nmr_config(const char* conf, struct nmreq *nmr)
+dump_port_info(struct nmreq_port_info_get *v)
 {
+   printf("memsize:%"PRIu64"\n", v->nr_memsize);
+   printf("tx_slots:   %"PRIu32"\n", v->nr_tx_slots);
+   printf("rx_slots:   %"PRIu32"\n", v->nr_rx_slots);
+   printf("tx_rings:   %"PRIu16"\n", v->nr_tx_rings);
+   printf("rx_rings%"PRIu16"\n", v->nr_rx_rings);
+   printf("mem_id: %"PRIu16"\n", v->nr_mem_id);
+}
+
+static void
+dump_newif(struct nmreq_vale_newif *v)
+{
+   printf("tx_slots:   %"PRIu32"\n", v->nr_tx_slots);
+   printf("rx_slots:   %"PRIu32"\n", v->nr_rx_slots);
+   printf("tx_rings:   %"PRIu16"\n", v->nr_tx_rings);
+   printf("rx_ring:%"PRIu16"\n", v->nr_rx_rings);
+   printf("mem_id: %"PRIu16"\n", v->nr_mem_id);
+}
+
+static void
+dump_vale_list(struct nmreq_vale_list *v)
+{
+   printf("bridge_idx: %"PRIu16"\n", v->nr_bridge_idx);
+   printf("port_idx:   %"PRIu16"\n", v->nr_port_idx);
+}
+
+
+static void
+parse_ring_config(const char* conf,
+   uint32_t *nr_tx_slots,
+   uint32_t *nr_rx_slots,
+   uint16_t *nr_tx_rings,
+   uint16_t *nr_rx_rings)
+{
char *w, *tok;
int i, v;
 
-   nmr->nr_tx_rings = nmr->nr_rx_rings = 0;
-   nmr->nr_tx_slots = nmr->nr_rx_slots = 0;
+   *nr_tx_rings = *nr_rx_rings = 0;
+   *nr_tx_slots = *nr_rx_slots = 0;
if (conf == NULL || ! *conf)
return;
w = strdup(conf);
@@ -57,137 +100,235 @@ parse_nmr_config(const char* conf, struct nmreq *nmr)
v = atoi(tok);
switch (i) {
case 0:
-   nmr->nr_tx_slots = nmr->nr_rx_slots = v;
+   *nr_tx_slots = *nr_rx_slots = v;
break;
case 1:
-   nmr->nr_rx_slots = v;
+   *nr_rx_slots = v;
break;
case 2:
-   nmr->nr_tx_rings = nmr->nr_rx_rings = v;
+   *nr_tx_rings = *nr_rx_rings = v;
break;
case 3:
-   nmr->nr_rx_rings = v;
+   *nr_rx_rings = v;
break;
default:
-   D("ignored config: %s", tok);
+   fprintf(stderr, "ignored config: %s", tok);
break;
}
}
-   D("txr %d txd %d rxr %d rxd %d",
-   nmr->nr_tx_rings, nmr->nr_tx_slots,
-   nmr->nr_rx_rings, nmr->nr_rx_slots);
+   ND("txr %d txd %d rxr %d rxd %d",
+   *nr_tx_rings, *nr_tx_slots,
+   *nr_rx_rings, *nr_rx_slots);
free(w);
 }
 
 static int
-bdg_ctl(const char *name, int nr_cmd, int nr_arg, char *nmr_config, int 
nr_arg2)
+parse_poll_config(const char *conf, struct nmreq_vale_polling *v)
 {
-   struct nmreq nmr;
-   int error = 0;
-   int fd = open("/dev/netmap", O_RDWR);
+   char *w, *tok;
+   int i, p;
 
-   if (fd == -1) {
-   D("Unable to open /dev/netmap");
+   if (conf == NULL || ! *conf) {
+   fprintf(stderr, "invalid null/empty config\n");
return -1;
}
+   w = strdup(conf);
+   for (i = 0, tok = strtok(w, ","); tok; i++, tok = 

svn commit: r368035 - stable/12/tools/tools/netmap

2020-11-25 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Nov 25 21:23:58 2020
New Revision: 368035
URL: https://svnweb.freebsd.org/changeset/base/368035

Log:
  MFC r367934
  
  netmap: nmreplay: switch to libnetmap
  
  Use the newer libnetmap (included in base) rather than the older
  nm_open()/nm_close() defined in netmap_user.h

Modified:
  stable/12/tools/tools/netmap/nmreplay.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tools/tools/netmap/nmreplay.c
==
--- stable/12/tools/tools/netmap/nmreplay.c Wed Nov 25 21:23:13 2020
(r368034)
+++ stable/12/tools/tools/netmap/nmreplay.c Wed Nov 25 21:23:58 2020
(r368035)
@@ -106,12 +106,27 @@
 #define DDD(_fmt, ...) ED("--DDD-- " _fmt, ##__VA_ARGS__)
 
 #define _GNU_SOURCE// for CPU_SET() etc
+#include 
+#include 
+#include 
+#include  /* log, exp etc. */
+#include 
+#ifdef __FreeBSD__
+#include  /* pthread w/ affinity */
+#include  /* cpu_set */
+#endif /* __FreeBSD__ */
+#include 
 #include 
-#define NETMAP_WITH_LIBS
-#include 
+#include 
+#include  /* memcpy */
+#include 
+#include 
+#include 
 #include 
+#include  // setpriority
+#include 
+#include 
 
-
 /*
  *
  * A packet in the queue is q_pkt plus the payload.
@@ -242,15 +257,6 @@ static struct nm_pcap_file *readpcap(const char *fn);
 static void destroy_pcap(struct nm_pcap_file *file);
 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include  /* memcpy */
-
-#include 
-
 #define NS_SCALE 10UL  /* nanoseconds in 1s */
 
 static void destroy_pcap(struct nm_pcap_file *pf)
@@ -435,18 +441,6 @@ static int verbose = 0;
 
 static int do_abort = 0;
 
-#include 
-#include 
-#include 
-#include 
-
-#include  // setpriority
-
-#ifdef __FreeBSD__
-#include  /* pthread w/ affinity */
-#include  /* cpu_set */
-#endif /* __FreeBSD__ */
-
 #ifdef linux
 #define cpuset_tcpu_set_t
 #endif
@@ -566,7 +560,7 @@ struct _qs { /* shared queue */
struct nm_pcap_file *pcap;  /* the pcap struct */
 
/* parameters for reading from the netmap port */
-   struct nm_desc *src_port;   /* netmap descriptor */
+   struct nmport_d *src_port;  /* netmap descriptor */
const char *prod_ifname;/* interface name or pcap file */
struct netmap_ring *rxring; /* current ring being handled */
uint32_tsi; /* ring index */
@@ -640,8 +634,8 @@ struct pipe_args {
int cons_core;  /* core for cons() */
int prod_core;  /* core for prod() */
 
-   struct nm_desc *pa; /* netmap descriptor */
-   struct nm_desc *pb;
+   struct nmport_d *pa;/* netmap descriptor */
+   struct nmport_d *pb;
 
struct _qs  q;
 };
@@ -843,7 +837,7 @@ fail:
 if (q->buf != NULL) {
free(q->buf);
 }
-nm_close(pa->pb);
+nmport_close(pa->pb);
 return (NULL);
 }
 
@@ -893,7 +887,7 @@ cons(void *_pa)
continue;
}
/* XXX copy is inefficient but simple */
-   if (nm_inject(pa->pb, (char *)(p + 1), p->pktlen) == 0) {
+   if (nmport_inject(pa->pb, (char *)(p + 1), p->pktlen) == 0) {
RD(1, "inject failed len %d now %ld tx %ld h %ld t %ld next %ld",
(int)p->pktlen, (u_long)q->cons_now, (u_long)p->pt_tx,
(u_long)q->_head, (u_long)q->_tail, (u_long)p->next);
@@ -939,7 +933,7 @@ nmreplay_main(void *_a)
 pcap_prod((void*)a);
 destroy_pcap(q->pcap);
 q->pcap = NULL;
-a->pb = nm_open(q->cons_ifname, NULL, 0, NULL);
+a->pb = nmport_open(q->cons_ifname);
 if (a->pb == NULL) {
EEE("cannot open netmap on %s", q->cons_ifname);
do_abort = 1; // XXX any better way ?
@@ -1372,7 +1366,6 @@ parse_bw(const char *arg)
  * 24 useful random bits.
  */
 
-#include  /* log, exp etc. */
 static inline uint64_t
 my_random24(void)  /* 24 useful bits */
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368034 - stable/12/tools/tools/netmap

2020-11-25 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Nov 25 21:23:13 2020
New Revision: 368034
URL: https://svnweb.freebsd.org/changeset/base/368034

Log:
  MFC r367933
  
  netmap: lb: switch to libnetmap
  
  Use the newer libnetmap (included in base) rather than the older
  nm_open()/nm_close() defined in netmap_user.h

Modified:
  stable/12/tools/tools/netmap/lb.c
  stable/12/tools/tools/netmap/pkt_hash.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tools/tools/netmap/lb.c
==
--- stable/12/tools/tools/netmap/lb.c   Wed Nov 25 21:22:16 2020
(r368033)
+++ stable/12/tools/tools/netmap/lb.c   Wed Nov 25 21:23:13 2020
(r368034)
@@ -23,21 +23,22 @@
  * SUCH DAMAGE.
  */
 /* $FreeBSD$ */
-#include 
-#include 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include /* htonl */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
-
-#define NETMAP_WITH_LIBS
-#include 
+#include 
 #include 
+#include 
 
-#include /* htonl */
-
-#include 
-
 #include "pkt_hash.h"
 #include "ctrs.h"
 
@@ -86,12 +87,12 @@ struct compact_ipv6_hdr {
 #define DEF_BATCH  2048
 #define DEF_WAIT_LINK  2
 #define DEF_STATS_INT  600
-#define BUF_REVOKE 100
+#define BUF_REVOKE 150
 #define STAT_MSG_MAXSIZE 1024
 
 static struct {
-   char ifname[MAX_IFNAMELEN];
-   char base_name[MAX_IFNAMELEN];
+   char ifname[MAX_IFNAMELEN + 1];
+   char base_name[MAX_IFNAMELEN + 1];
int netmap_fd;
uint16_t output_rings;
uint16_t num_groups;
@@ -173,7 +174,7 @@ struct port_des {
unsigned int last_sync;
uint32_t last_tail;
struct overflow_queue *oq;
-   struct nm_desc *nmd;
+   struct nmport_d *nmd;
struct netmap_ring *ring;
struct group_des *group;
 };
@@ -375,7 +376,7 @@ free_buffers(void)
D("added %d buffers to netmap free list", tot);
 
for (i = 0; i < glob_arg.output_rings + 1; ++i) {
-   nm_close(ports[i].nmd);
+   nmport_close(ports[i].nmd);
}
 }
 
@@ -480,6 +481,28 @@ init_groups(void)
g->last = 1;
 }
 
+
+/* To support packets that span multiple slots (NS_MOREFRAG) we
+ * need to make sure of the following:
+ *
+ * - all fragments of the same packet must go to the same output pipe
+ * - when dropping, all fragments of the same packet must be dropped
+ *
+ * For the former point we remember and reuse the last hash computed
+ * in each input ring, and only update it when NS_MOREFRAG was not
+ * set in the last received slot (this marks the start of a new packet).
+ *
+ * For the latter point, we only update the output ring head pointer
+ * when an entire packet has been forwarded. We keep a shadow_head
+ * pointer to know where to put the next partial fragment and,
+ * when the need to drop arises, we roll it back to head.
+ */
+struct morefrag {
+   uint16_t last_flag; /* for intput rings */
+   uint32_t last_hash; /* for input rings */
+   uint32_t shadow_head;   /* for output rings */
+};
+
 /* push the packet described by slot rs to the group g.
  * This may cause other buffers to be pushed down the
  * chain headed by g.
@@ -493,21 +516,28 @@ forward_packet(struct group_des *g, struct netmap_slot
struct port_des *port = >ports[output_port];
struct netmap_ring *ring = port->ring;
struct overflow_queue *q = port->oq;
+   struct morefrag *mf = (struct morefrag *)ring->sem;
+   uint16_t curmf = rs->flags & NS_MOREFRAG;
 
/* Move the packet to the output pipe, unless there is
 * either no space left on the ring, or there is some
 * packet still in the overflow queue (since those must
 * take precedence over the new one)
*/
-   if (ring->head != ring->tail && (q == NULL || oq_empty(q))) {
-   struct netmap_slot *ts = >slot[ring->head];
+   if (mf->shadow_head != ring->tail && (q == NULL || oq_empty(q))) {
+   struct netmap_slot *ts = >slot[mf->shadow_head];
struct netmap_slot old_slot = *ts;
 
ts->buf_idx = rs->buf_idx;
ts->len = rs->len;
-   ts->flags |= NS_BUF_CHANGED;
+   ts->flags = rs->flags | NS_BUF_CHANGED;
ts->ptr = rs->ptr;
-   ring->head = nm_ring_next(ring, ring->head);
+   mf->shadow_head = nm_ring_next(ring, mf->shadow_head);
+   if (!curmf) {
+   ring->head = mf->shadow_head;
+   }
+   ND("curmf %2x ts->flags %2x shadow_head %3u head %3u tail %3u",
+   curmf, ts->flags, mf->shadow_head, ring->head, 
ring->tail);
port->ctr.bytes += rs->len;
port->ctr.pkts++;
forwarded++;
@@ -516,9 +546,20 @@ forward_packet(struct group_des *g, struct netmap_slot
 
/* use 

svn commit: r368033 - stable/12/tools/tools/netmap

2020-11-25 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Nov 25 21:22:16 2020
New Revision: 368033
URL: https://svnweb.freebsd.org/changeset/base/368033

Log:
  MFC r367932
  
  netmap: pkt-gen: switch to libnetmap
  
  Use the newer libnetmap (included in base) rather than the older
  nm_open()/nm_close() defined in netmap_user.h

Modified:
  stable/12/tools/tools/netmap/pkt-gen.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tools/tools/netmap/pkt-gen.c
==
--- stable/12/tools/tools/netmap/pkt-gen.c  Wed Nov 25 21:20:55 2020
(r368032)
+++ stable/12/tools/tools/netmap/pkt-gen.c  Wed Nov 25 21:22:16 2020
(r368033)
@@ -38,36 +38,40 @@
  */
 
 #define _GNU_SOURCE/* for CPU_SET() */
-#include 
-#define NETMAP_WITH_LIBS
-#include 
-
-#include  // isprint()
-#include // sysconf()
-#include 
 #include  /* ntohs */
-#ifndef _WIN32
-#include /* sysctl */
-#endif
+#include 
+#include  // isprint()
+#include 
+#include 
 #include/* getifaddrs */
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
+#ifndef NO_PCAP
+#include 
+#endif
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#if !defined(_WIN32) && !defined(linux)
+#include /* sysctl */
+#endif
+#include 
+#include // sysconf()
 #ifdef linux
 #define IPV6_VERSION   0x60
 #define IPV6_DEFHLIM   64
 #endif
-#include 
-#include 
 
-#include 
-
-#ifndef NO_PCAP
-#include 
-#endif
-
 #include "ctrs.h"
 
 static void usage(int);
@@ -236,7 +240,8 @@ struct mac_range {
 };
 
 /* ifname can be netmap:foo- */
-#define MAX_IFNAMELEN  64  /* our buffer for ifname */
+#define MAX_IFNAMELEN  512 /* our buffer for ifname */
+//#define MAX_PKTSIZE  1536
 #define MAX_PKTSIZEMAX_BODYSIZE/* XXX: + IP_HDR + ETH_HDR */
 
 /* compact timestamp to fit into 60 byte packet. (enough to obtain RTT) */
@@ -288,7 +293,8 @@ struct glob_arg {
 
int affinity;
int main_fd;
-   struct nm_desc *nmd;
+   struct nmport_d *nmd;
+   uint32_t orig_mode;
int report_interval;/* milliseconds between prints */
void *(*td_body)(void *);
int td_type;
@@ -322,7 +328,7 @@ struct targ {
int completed;
int cancel;
int fd;
-   struct nm_desc *nmd;
+   struct nmport_d *nmd;
/* these ought to be volatile, but they are
 * only sampled and errors should not accumulate
 */
@@ -515,17 +521,21 @@ extract_mac_range(struct mac_range *r)
 static int
 get_if_mtu(const struct glob_arg *g)
 {
-   char ifname[IFNAMSIZ];
struct ifreq ifreq;
int s, ret;
+   const char *ifname = g->nmd->hdr.nr_name;
+   size_t len;
 
-   if (!strncmp(g->ifname, "netmap:", 7) && !strchr(g->ifname, '{')
-   && !strchr(g->ifname, '}')) {
-   /* Parse the interface name and ask the kernel for the
-* MTU value. */
-   strncpy(ifname, g->ifname+7, IFNAMSIZ-1);
-   ifname[strcspn(ifname, "-*^{}/@")] = '\0';
+   if (!strncmp(g->ifname, "netmap:", 7) && !strchr(ifname, '{')
+   && !strchr(ifname, '}')) {
 
+   len = strlen(ifname);
+
+   if (len > IFNAMSIZ) {
+   D("'%s' too long, cannot ask for MTU", ifname);
+   return -1;
+   }
+
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0) {
D("socket() failed: %s", strerror(errno));
@@ -533,13 +543,15 @@ get_if_mtu(const struct glob_arg *g)
}
 
memset(, 0, sizeof(ifreq));
-   strncpy(ifreq.ifr_name, ifname, IFNAMSIZ);
+   memcpy(ifreq.ifr_name, ifname, len);
 
ret = ioctl(s, SIOCGIFMTU, );
if (ret) {
D("ioctl(SIOCGIFMTU) failed: %s", strerror(errno));
}
 
+   close(s);
+
return ifreq.ifr_mtu;
}
 
@@ -620,7 +632,7 @@ system_ncpus(void)
  * and #rx-rings.
  */
 static int
-parse_nmr_config(const char* conf, struct nmreq *nmr)
+parse_nmr_config(const char* conf, struct nmreq_register *nmr)
 {
char *w, *tok;
int i, v;
@@ -654,9 +666,7 @@ parse_nmr_config(const char* conf, struct nmreq *nmr)
nmr->nr_tx_rings, nmr->nr_tx_slots,
nmr->nr_rx_rings, nmr->nr_rx_slots);
free(w);
-   return (nmr->nr_tx_rings || nmr->nr_tx_slots ||
-   nmr->nr_rx_rings || nmr->nr_rx_slots) ?
-   NM_OPEN_RING_CFG : 0;
+   return 0;
 }
 
 
@@ -1108,20 +1118,22 @@ initialize_packet(struct targ *targ)
 static void
 get_vnet_hdr_len(struct glob_arg *g)
 {
-   struct nmreq req;
+   struct nmreq_header hdr;
+   struct nmreq_port_hdr ph;
int err;
 
-   memset(, 

svn commit: r368032 - stable/12/tools/tools/netmap

2020-11-25 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Nov 25 21:20:55 2020
New Revision: 368032
URL: https://svnweb.freebsd.org/changeset/base/368032

Log:
  MFC r367931
  
  netmap: bridge: switch to libnetmap
  
  Use the newer libnetmap (included in base) rather than the older
  nm_open()/nm_close() defined in netmap_user.h

Modified:
  stable/12/tools/tools/netmap/Makefile
  stable/12/tools/tools/netmap/bridge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tools/tools/netmap/Makefile
==
--- stable/12/tools/tools/netmap/Makefile   Wed Nov 25 20:58:01 2020
(r368031)
+++ stable/12/tools/tools/netmap/Makefile   Wed Nov 25 21:20:55 2020
(r368032)
@@ -11,7 +11,7 @@ MAN=
 .include 
 .include 
 
-LDFLAGS += -lpthread
+LDFLAGS += -lpthread -lnetmap
 .ifdef WITHOUT_PCAP
 CFLAGS += -DNO_PCAP
 .else
@@ -27,7 +27,7 @@ pkt-gen: pkt-gen.o
$(CC) $(CFLAGS) -o pkt-gen pkt-gen.o $(LDFLAGS)
 
 bridge: bridge.o
-   $(CC) $(CFLAGS) -o bridge bridge.o
+   $(CC) $(CFLAGS) -o bridge bridge.o $(LDFLAGS)
 
 nmreplay: nmreplay.o
$(CC) $(CFLAGS) -o nmreplay nmreplay.o $(LDFLAGS)

Modified: stable/12/tools/tools/netmap/bridge.c
==
--- stable/12/tools/tools/netmap/bridge.c   Wed Nov 25 20:58:01 2020
(r368031)
+++ stable/12/tools/tools/netmap/bridge.c   Wed Nov 25 21:20:55 2020
(r368032)
@@ -10,9 +10,12 @@
  */
 
 #include 
-#define NETMAP_WITH_LIBS
-#include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 static int verbose = 0;
 
@@ -32,7 +35,7 @@ sigint_h(int sig)
  * how many packets on this set of queues ?
  */
 static int
-pkt_queued(struct nm_desc *d, int tx)
+pkt_queued(struct nmport_d *d, int tx)
 {
u_int i, tot = 0;
 
@@ -61,8 +64,8 @@ process_rings(struct netmap_ring *rxring, struct netma
if (rxring->flags || txring->flags)
D("%s rxflags %x txflags %x",
msg, rxring->flags, txring->flags);
-   j = rxring->cur; /* RX */
-   k = txring->cur; /* TX */
+   j = rxring->head; /* RX */
+   k = txring->head; /* TX */
m = nm_ring_space(rxring);
if (m < limit)
limit = m;
@@ -115,11 +118,11 @@ process_rings(struct netmap_ring *rxring, struct netma
 
 /* move packts from src to destination */
 static int
-move(struct nm_desc *src, struct nm_desc *dst, u_int limit)
+move(struct nmport_d *src, struct nmport_d *dst, u_int limit)
 {
struct netmap_ring *txring, *rxring;
u_int m = 0, si = src->first_rx_ring, di = dst->first_tx_ring;
-   const char *msg = (src->req.nr_flags == NR_REG_SW) ?
+   const char *msg = (src->reg.nr_flags == NR_REG_SW) ?
"host->net" : "net->host";
 
while (si <= src->last_rx_ring && di <= dst->last_tx_ring) {
@@ -175,7 +178,7 @@ main(int argc, char **argv)
struct pollfd pollfd[2];
int ch;
u_int burst = 1024, wait_link = 4;
-   struct nm_desc *pa = NULL, *pb = NULL;
+   struct nmport_d *pa = NULL, *pb = NULL;
char *ifa = NULL, *ifb = NULL;
char ifabuf[64] = { 0 };
int loopback = 0;
@@ -252,16 +255,16 @@ main(int argc, char **argv)
} else {
/* two different interfaces. Take all rings on if1 */
}
-   pa = nm_open(ifa, NULL, 0, NULL);
+   pa = nmport_open(ifa);
if (pa == NULL) {
D("cannot open %s", ifa);
return (1);
}
/* try to reuse the mmap() of the first interface, if possible */
-   pb = nm_open(ifb, NULL, NM_OPEN_NO_MMAP, pa);
+   pb = nmport_open(ifb);
if (pb == NULL) {
D("cannot open %s", ifb);
-   nm_close(pa);
+   nmport_close(pa);
return (1);
}
zerocopy = zerocopy && (pa->mem == pb->mem);
@@ -275,8 +278,8 @@ main(int argc, char **argv)
D("Wait %d secs for link to come up...", wait_link);
sleep(wait_link);
D("Ready to go, %s 0x%x/%d <-> %s 0x%x/%d.",
-   pa->req.nr_name, pa->first_rx_ring, pa->req.nr_rx_rings,
-   pb->req.nr_name, pb->first_rx_ring, pb->req.nr_rx_rings);
+   pa->hdr.nr_name, pa->first_rx_ring, pa->reg.nr_rx_rings,
+   pb->hdr.nr_name, pb->first_rx_ring, pb->reg.nr_rx_rings);
 
/* main loop */
signal(SIGINT, sigint_h);
@@ -320,12 +323,12 @@ main(int argc, char **argv)
pollfd[0].events,
pollfd[0].revents,
pkt_queued(pa, 0),
-   NETMAP_RXRING(pa->nifp, pa->cur_rx_ring)->cur,
+   NETMAP_RXRING(pa->nifp, pa->cur_rx_ring)->head,
pkt_queued(pa, 1),
pollfd[1].events,
  

svn commit: r368031 - in head: libexec/rc sys/netinet6

2020-11-25 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Nov 25 20:58:01 2020
New Revision: 368031
URL: https://svnweb.freebsd.org/changeset/base/368031

Log:
  IPv6: set ifdisabled in the kernel rather than in rc
  
  Enable ND6_IFF_IFDISABLED when the interface is created in the
  kernel before return to user space.
  
  This avoids a race when an interface is create by a program which
  also calls ifconfig IF inet6 -ifdisabled and races with the
  devd -> /etc/pccard_ether -> .. netif start IF -> ifdisabled
  calls (the devd/rc framework disabling IPv6 again after the program
  had enabled it already).
  
  In case the global net.inet6.ip6.accept_rtadv was turned on,
  we also default to enabling IPv6 on the interfaces, rather than
  disabling them.
  
  PR:   248172
  Reported by:  Gert Doering (gert greenie.muc.de)
  Reviewed by:  glebius (, phk)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D27324

Modified:
  head/libexec/rc/network.subr
  head/sys/netinet6/nd6.c

Modified: head/libexec/rc/network.subr
==
--- head/libexec/rc/network.subrWed Nov 25 20:05:05 2020
(r368030)
+++ head/libexec/rc/network.subrWed Nov 25 20:58:01 2020
(r368031)
@@ -134,8 +134,6 @@ ifconfig_up()
if ! noafif $1 && afexists inet6; then
if checkyesno ipv6_activate_all_interfaces; then
_ipv6_opts="-ifdisabled"
-   elif [ "$1" != "lo0" ]; then
-   _ipv6_opts="ifdisabled"
fi
 
# backward compatibility: $ipv6_enable

Modified: head/sys/netinet6/nd6.c
==
--- head/sys/netinet6/nd6.c Wed Nov 25 20:05:05 2020(r368030)
+++ head/sys/netinet6/nd6.c Wed Nov 25 20:58:01 2020(r368031)
@@ -273,6 +273,10 @@ nd6_ifattach(struct ifnet *ifp)
 
nd->flags = ND6_IFF_PERFORMNUD;
 
+   /* Set IPv6 disabled on all interfaces but loopback by default. */
+   if ((ifp->if_flags & IFF_LOOPBACK) == 0)
+   nd->flags |= ND6_IFF_IFDISABLED;
+
/* A loopback interface always has ND6_IFF_AUTO_LINKLOCAL.
 * XXXHRS: Clear ND6_IFF_AUTO_LINKLOCAL on an IFT_BRIDGE interface by
 * default regardless of the V_ip6_auto_linklocal configuration to
@@ -290,8 +294,11 @@ nd6_ifattach(struct ifnet *ifp)
 */
if (V_ip6_accept_rtadv &&
!(ifp->if_flags & IFF_LOOPBACK) &&
-   (ifp->if_type != IFT_BRIDGE))
+   (ifp->if_type != IFT_BRIDGE)) {
nd->flags |= ND6_IFF_ACCEPT_RTADV;
+   /* If we globally accept rtadv, assume IPv6 on. */
+   nd->flags &= ~ND6_IFF_IFDISABLED;
+   }
if (V_ip6_no_radr && !(ifp->if_flags & IFF_LOOPBACK))
nd->flags |= ND6_IFF_NO_RADR;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368030 - head/sys/arm/freescale/imx

2020-11-25 Thread Ian Lepore
Author: ian
Date: Wed Nov 25 20:05:05 2020
New Revision: 368030
URL: https://svnweb.freebsd.org/changeset/base/368030

Log:
  Extend the imx6 gpc->gic interrupt controller fixup of fdt data at runtime
  to work with the pmu and tempmon nodes as well as the soc node.  This allows
  interrupts to work on the pmu and tempmon devices even though we don't have
  a driver for the low-power gpc interrupt controller (which is not a problem
  because we also don't have support for entering deep power-down modes where
  it gets used).

Modified:
  head/sys/arm/freescale/imx/imx6_machdep.c

Modified: head/sys/arm/freescale/imx/imx6_machdep.c
==
--- head/sys/arm/freescale/imx/imx6_machdep.c   Wed Nov 25 19:10:20 2020
(r368029)
+++ head/sys/arm/freescale/imx/imx6_machdep.c   Wed Nov 25 20:05:05 2020
(r368030)
@@ -78,6 +78,10 @@ static platform_cpu_reset_t imx6_cpu_reset;
  * node to refer to GIC instead of GPC.  This will get us by until we write our
  * own GPC driver (or until linux changes its mind and the FDT data again).
  *
+ * 2020/11/25: The tempmon and pmu nodes are siblings (not children) of the soc
+ * node, so for them to use interrupts we need to apply the same fix as we do
+ * for the soc node.
+ *
  * We validate that we have data that looks like we expect before changing it:
  *  - SOC node exists and has GPC as its interrupt parent.
  *  - GPC node exists and has GIC as its interrupt parent.
@@ -95,22 +99,30 @@ static platform_cpu_reset_t imx6_cpu_reset;
  * nodes by string matching we now have to search for both flavors of each node
  * name involved.
  */
+
 static void
+fix_node_iparent(const char* nodepath, phandle_t gpcxref, phandle_t gicxref)
+{
+   static const char *propname = "interrupt-parent";
+   phandle_t node, iparent;
+
+   if ((node = OF_finddevice(nodepath)) == -1)
+   return;
+   if (OF_getencprop(node, propname, , sizeof(iparent)) <= 0)
+   return;
+   if (iparent != gpcxref)
+   return;
+
+   OF_setprop(node, propname, , sizeof(gicxref));
+}
+
+static void
 fix_fdt_interrupt_data(void)
 {
phandle_t gicipar, gicnode, gicxref;
phandle_t gpcipar, gpcnode, gpcxref;
-   phandle_t socipar, socnode;
int result;
 
-   socnode = OF_finddevice("/soc");
-   if (socnode == -1)
-   return;
-   result = OF_getencprop(socnode, "interrupt-parent", ,
-   sizeof(socipar));
-   if (result <= 0)
-   return;
-
/* GIC node may be child of soc node, or appear directly at root. */
gicnode = OF_finddevice("/soc/interrupt-controller@00a01000");
if (gicnode == -1)
@@ -143,11 +155,13 @@ fix_fdt_interrupt_data(void)
return;
gpcxref = OF_xref_from_node(gpcnode);
 
-   if (socipar != gpcxref || gpcipar != gicxref || gicipar != gicxref)
+   if (gpcipar != gicxref || gicipar != gicxref)
return;
 
gicxref = cpu_to_fdt32(gicxref);
-   OF_setprop(socnode, "interrupt-parent", , sizeof(gicxref));
+   fix_node_iparent("/soc", gpcxref, gicxref);
+   fix_node_iparent("/pmu", gpcxref, gicxref);
+   fix_node_iparent("/tempmon", gpcxref, gicxref);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368029 - in head/sys: arm/freescale/imx modules/imx/imx6_snvs

2020-11-25 Thread Ian Lepore
Author: ian
Date: Wed Nov 25 19:10:20 2020
New Revision: 368029
URL: https://svnweb.freebsd.org/changeset/base/368029

Log:
  Convert the imx6_snvs RTC driver to access registers via the syscon device.
  This is required for it to work correctly in the GENERIC kernel.

Modified:
  head/sys/arm/freescale/imx/imx6_snvs.c
  head/sys/modules/imx/imx6_snvs/Makefile

Modified: head/sys/arm/freescale/imx/imx6_snvs.c
==
--- head/sys/arm/freescale/imx/imx6_snvs.c  Wed Nov 25 19:08:22 2020
(r368028)
+++ head/sys/arm/freescale/imx/imx6_snvs.c  Wed Nov 25 19:10:20 2020
(r368029)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include "clock_if.h"
+#include "syscon_if.h"
 
 #defineSNVS_LPCR   0x38/* Control register */
 #define  LPCR_LPCALB_VAL_SHIFT   10/* Calibration shift */
@@ -68,13 +69,12 @@ __FBSDID("$FreeBSD$");
 
 struct snvs_softc {
device_tdev;
-   struct resource *   memres;
+   struct syscon   *syscon;
uint32_tlpcr;
 };
 
 static struct ofw_compat_data compat_data[] = {
{"fsl,sec-v4.0-mon-rtc-lp", true},
-   {"fsl,sec-v4.0-mon", true},
{NULL,   false}
 };
 
@@ -82,14 +82,14 @@ static inline uint32_t
 RD4(struct snvs_softc *sc, bus_size_t offset)
 {
 
-   return (bus_read_4(sc->memres, offset));
+   return (SYSCON_READ_4(sc->syscon, offset));
 }
 
 static inline void
 WR4(struct snvs_softc *sc, bus_size_t offset, uint32_t value)
 {
 
-   bus_write_4(sc->memres, offset, value);
+   SYSCON_WRITE_4(sc->syscon, offset, value);
 }
 
 static void
@@ -187,16 +187,12 @@ static int
 snvs_attach(device_t dev)
 {
struct snvs_softc *sc;
-   int rid;
 
sc = device_get_softc(dev);
sc->dev = dev;
 
-   rid = 0;
-   sc->memres = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, ,
-   RF_ACTIVE);
-   if (sc->memres == NULL) {
-   device_printf(sc->dev, "could not allocate registers\n");
+   if (syscon_get_handle_default(sc->dev, >syscon) != 0) {
+   device_printf(sc->dev, "Cannot get syscon handle\n");
return (ENXIO);
}
 
@@ -212,7 +208,6 @@ snvs_detach(device_t dev)
 
sc = device_get_softc(dev);
clock_unregister(sc->dev);
-   bus_release_resource(sc->dev, SYS_RES_MEMORY, 0, sc->memres);
return (0);
 }
 

Modified: head/sys/modules/imx/imx6_snvs/Makefile
==
--- head/sys/modules/imx/imx6_snvs/Makefile Wed Nov 25 19:08:22 2020
(r368028)
+++ head/sys/modules/imx/imx6_snvs/Makefile Wed Nov 25 19:10:20 2020
(r368029)
@@ -11,5 +11,6 @@ SRCS+=\
clock_if.h \
device_if.h \
ofw_bus_if.h \
+   syscon_if.h \
 
 .include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368028 - head/sys/arm/conf

2020-11-25 Thread Ian Lepore
Author: ian
Date: Wed Nov 25 19:08:22 2020
New Revision: 368028
URL: https://svnweb.freebsd.org/changeset/base/368028

Log:
  Add the standard extres pseudo devices to the IMX6 kernel config.
  
  Some imx6 drivers are being converted to use features that weren't available
  when they were first written (such as accessing shared device registers via
  the syscon pseudo-device), so imx6 custom kernels that reference those
  devices will now need this infrastructure in place.

Modified:
  head/sys/arm/conf/IMX6

Modified: head/sys/arm/conf/IMX6
==
--- head/sys/arm/conf/IMX6  Wed Nov 25 18:36:38 2020(r368027)
+++ head/sys/arm/conf/IMX6  Wed Nov 25 19:08:22 2020(r368028)
@@ -117,6 +117,15 @@ optionsFDT # Configure using 
FDT/DTB data
 makeoptionsMODULES_EXTRA="dtb/imx6 imx"
 device fdt_pinctrl # FDT pinmux driver
 
+# EXT_RESOURCES pseudo devices
+optionsEXT_RESOURCES
+device clk
+device phy
+device hwreset
+device nvmem
+device regulator
+device syscon
+
 # SoC-specific devices
 device ffec# Freescale Fast Ethernet Controller
 device fsliic  # Freescale i2c/iic
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368027 - stable/12/lib/libc/string

2020-11-25 Thread Ed Maste
Author: emaste
Date: Wed Nov 25 18:36:38 2020
New Revision: 368027
URL: https://svnweb.freebsd.org/changeset/base/368027

Log:
  MFC r351700: libc: Use musl's optimized memchr
  
  Parentheses added to HASZERO macro to avoid a GCC warning.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/lib/libc/string/memchr.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/string/memchr.c
==
--- stable/12/lib/libc/string/memchr.c  Wed Nov 25 18:09:01 2020
(r368026)
+++ stable/12/lib/libc/string/memchr.c  Wed Nov 25 18:36:38 2020
(r368027)
@@ -1,55 +1,54 @@
 /*-
- * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-License-Identifier: MIT
  *
- * Copyright (c) 1990, 1993
- * The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 2005-2014 Rich Felker, et al.
  *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
  *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)memchr.c   8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
 #include 
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
+#include 
 
-void *
-memchr(const void *s, int c, size_t n)
-{
-   if (n != 0) {
-   const unsigned char *p = s;
+#define SS (sizeof(size_t))
+#define ALIGN (sizeof(size_t)-1)
+#define ONES ((size_t)-1/UCHAR_MAX)
+#define HIGHS (ONES * (UCHAR_MAX/2+1))
+#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS)
 
-   do {
-   if (*p++ == (unsigned char)c)
-   return ((void *)(p - 1));
-   } while (--n != 0);
+void *memchr(const void *src, int c, size_t n)
+{
+   const unsigned char *s = src;
+   c = (unsigned char)c;
+#ifdef __GNUC__
+   for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);
+   if (n && *s != c) {
+   typedef size_t __attribute__((__may_alias__)) word;
+   const word *w;
+   size_t k = ONES * c;
+   for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);
+   s = (const void *)w;
}
-   return (NULL);
+#endif
+   for (; n && *s != c; s++, n--);
+   return n ? (void *)s : 0;
 }
___
svn-src-all@freebsd.org mailing list

svn commit: r368026 - head/sys/arm/freescale/imx

2020-11-25 Thread Ian Lepore
Author: ian
Date: Wed Nov 25 18:09:01 2020
New Revision: 368026
URL: https://svnweb.freebsd.org/changeset/base/368026

Log:
  A couple small fixes for the imx6_sdma driver...
  
  Attach after interrupt controllers, since the attach function tries to
  set up an interrupt handler.
  
  Check for the availability of the required firmware early in the attach
  code (before allocating resources).  If the firmware is not available, set
  a static var to remember that, so that if the device is re-probed on later
  passes it won't repeatedly try to attach and then complain again about
  missing firmware.

Modified:
  head/sys/arm/freescale/imx/imx6_sdma.c

Modified: head/sys/arm/freescale/imx/imx6_sdma.c
==
--- head/sys/arm/freescale/imx/imx6_sdma.c  Wed Nov 25 17:15:24 2020
(r368025)
+++ head/sys/arm/freescale/imx/imx6_sdma.c  Wed Nov 25 18:09:01 2020
(r368026)
@@ -75,6 +75,12 @@ static struct resource_spec sdma_spec[] = {
{ -1, 0 }
 };
 
+/*
+ * This will get set to true if we can't load firmware while attaching, to
+ * prevent multiple attempts to re-attach the device on each bus pass.
+ */
+static bool firmware_unavailable;
+
 static void
 sdma_intr(void *arg)
 {
@@ -117,7 +123,7 @@ static int
 sdma_probe(device_t dev)
 {
 
-   if (!ofw_bus_status_okay(dev))
+   if (!ofw_bus_status_okay(dev) || firmware_unavailable)
return (ENXIO);
 
if (!ofw_bus_is_compatible(dev, "fsl,imx6q-sdma"))
@@ -468,6 +474,11 @@ sdma_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
 
+   if (load_firmware(sc) == -1) {
+   firmware_unavailable = true;
+   return (ENXIO);
+   }
+
if (bus_alloc_resources(dev, sdma_spec, sc->res)) {
device_printf(dev, "could not allocate resources\n");
return (ENXIO);
@@ -487,9 +498,6 @@ sdma_attach(device_t dev)
return (ENXIO);
}
 
-   if (load_firmware(sc) == -1)
-   return (ENXIO);
-
if (boot_firmware(sc) == -1)
return (ENXIO);
 
@@ -511,5 +519,6 @@ static driver_t sdma_driver = {
 
 static devclass_t sdma_devclass;
 
+/* We want to attach after all interrupt controllers, before anything else. */
 EARLY_DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0,
-BUS_PASS_RESOURCE);
+BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368025 - head/sys/net

2020-11-25 Thread Kristof Provost
Author: kp
Date: Wed Nov 25 17:15:24 2020
New Revision: 368025
URL: https://svnweb.freebsd.org/changeset/base/368025

Log:
  if: Fix non-VIMAGE build
  
  if_link_ifnet() and if_unlink_ifnet() are needed even when VIMAGE is not
  enabled.
  
  MFC after:2 weeks
  Sponsored by: Modirum MDPay

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Wed Nov 25 17:12:21 2020(r368024)
+++ head/sys/net/if.c   Wed Nov 25 17:15:24 2020(r368025)
@@ -468,6 +468,7 @@ vnet_if_uninit(const void *unused __unused)
 }
 VNET_SYSUNINIT(vnet_if_uninit, SI_SUB_INIT_IF, SI_ORDER_FIRST,
 vnet_if_uninit, NULL);
+#endif
 
 static void
 if_link_ifnet(struct ifnet *ifp)
@@ -504,6 +505,7 @@ if_unlink_ifnet(struct ifnet *ifp, bool vmove)
return (found);
 }
 
+#ifdef VIMAGE
 static void
 vnet_if_return(const void *unused __unused)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368024 - head/sys/ufs/ffs

2020-11-25 Thread Konstantin Belousov
Author: kib
Date: Wed Nov 25 17:12:21 2020
New Revision: 368024
URL: https://svnweb.freebsd.org/changeset/base/368024

Log:
  ffs_softdep.c: get_parent_vp(): Fix bp lock leak when inum inode was already 
freed.
  
  Reported by:  markj, pho
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==
--- head/sys/ufs/ffs/ffs_softdep.c  Wed Nov 25 17:04:26 2020
(r368023)
+++ head/sys/ufs/ffs/ffs_softdep.c  Wed Nov 25 17:12:21 2020
(r368024)
@@ -1409,6 +1409,29 @@ SYSCTL_INT(_debug_softdep, OID_AUTO, print_threads, CT
 /* List of all filesystems mounted with soft updates */
 static TAILQ_HEAD(, mount_softdeps) softdepmounts;
 
+static void
+get_parent_vp_unlock_bp(struct mount *mp, struct buf *bp,
+struct diraddhd *diraddhdp, struct diraddhd *unfinishedp)
+{
+   struct diradd *dap;
+
+   /*
+* Requeue unfinished dependencies before
+* unlocking buffer, which could make
+* diraddhdp invalid.
+*/
+   ACQUIRE_LOCK(VFSTOUFS(mp));
+   while ((dap = LIST_FIRST(unfinishedp)) != NULL) {
+   LIST_REMOVE(dap, da_pdlist);
+   LIST_INSERT_HEAD(diraddhdp, dap, da_pdlist);
+   }
+   FREE_LOCK(VFSTOUFS(mp));
+
+   bp->b_vflags &= ~BV_SCANNED;
+   BUF_NOREC(bp);
+   BUF_UNLOCK(bp);
+}
+
 /*
  * This function fetches inode inum on mount point mp.  We already
  * hold a locked vnode vp, and might have a locked buffer bp belonging
@@ -1439,7 +1462,6 @@ get_parent_vp(struct vnode *vp, struct mount *mp, ino_
 struct vnode **rvp)
 {
struct vnode *pvp;
-   struct diradd *dap;
int error;
bool bplocked;
 
@@ -1455,31 +1477,18 @@ get_parent_vp(struct vnode *vp, struct mount *mp, ino_
 * restart the syscall.
 */
if (VTOI(pvp)->i_mode == 0 || !bplocked) {
+   if (bp != NULL && bplocked)
+   get_parent_vp_unlock_bp(mp, bp,
+   diraddhdp, unfinishedp);
if (VTOI(pvp)->i_mode == 0)
vgone(pvp);
-   vput(pvp);
error = ERELOOKUP;
-   goto out;
+   goto out2;
}
-
-   error = 0;
goto out1;
}
if (bp != NULL && bplocked) {
-   /*
-* Requeue unfinished dependencies before
-* unlocking buffer, which could make
-* diraddhdp invalid.
-*/
-   ACQUIRE_LOCK(VFSTOUFS(mp));
-   while ((dap = LIST_FIRST(unfinishedp)) != NULL) {
-   LIST_REMOVE(dap, da_pdlist);
-   LIST_INSERT_HEAD(diraddhdp, dap, da_pdlist);
-   }
-   FREE_LOCK(VFSTOUFS(mp));
-   bp->b_vflags &= ~BV_SCANNED;
-   BUF_NOREC(bp);
-   BUF_UNLOCK(bp);
+   get_parent_vp_unlock_bp(mp, bp, diraddhdp, unfinishedp);
bplocked = false;
}
 
@@ -1528,13 +1537,13 @@ get_parent_vp(struct vnode *vp, struct mount *mp, ino_
MPASS(!bplocked);
error = ERELOOKUP;
}
+out2:
if (error != 0 && pvp != NULL) {
vput(pvp);
pvp = NULL;
}
 out1:
*rvp = pvp;
-out:
ASSERT_VOP_ELOCKED(vp, "child vnode must be locked on return");
return (error);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368023 - head/lib/libc/gen

2020-11-25 Thread Konstantin Belousov
Author: kib
Date: Wed Nov 25 17:04:26 2020
New Revision: 368023
URL: https://svnweb.freebsd.org/changeset/base/368023

Log:
  Use designated initializers for libc pthread stubs' jump table.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/lib/libc/gen/_pthread_stubs.c

Modified: head/lib/libc/gen/_pthread_stubs.c
==
--- head/lib/libc/gen/_pthread_stubs.c  Wed Nov 25 16:30:57 2020
(r368022)
+++ head/lib/libc/gen/_pthread_stubs.c  Wed Nov 25 17:04:26 2020
(r368023)
@@ -64,73 +64,73 @@ static void stub_exit(void);
(pthread_func_t)entry, (pthread_func_t)entry
 
 pthread_func_entry_t __thr_jtable[PJT_MAX] = {
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATFORK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_DESTROY */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETDETACHSTATE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETGUARDSIZE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETINHERITSCHED */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETSCHEDPARAM */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETSCHEDPOLICY */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETSCOPE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETSTACKADDR */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_GETSTACKSIZE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_INIT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETDETACHSTATE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETGUARDSIZE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETINHERITSCHED */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETSCHEDPARAM */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETSCHEDPOLICY */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETSCOPE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETSTACKADDR */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_ATTR_SETSTACKSIZE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_CANCEL */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_CLEANUP_POP */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_CLEANUP_PUSH */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_COND_BROADCAST */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_COND_DESTROY */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_COND_INIT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_COND_SIGNAL */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_COND_TIMEDWAIT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_COND_WAIT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_DETACH */
-   {PJT_DUAL_ENTRY(stub_true)},/* PJT_EQUAL */
-   {PJT_DUAL_ENTRY(stub_exit)},/* PJT_EXIT */
-   {PJT_DUAL_ENTRY(stub_null)},/* PJT_GETSPECIFIC */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_JOIN */
-   {PJT_DUAL_ENTRY(stub_fail)},/* PJT_KEY_CREATE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_KEY_DELETE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_KILL */
-   {PJT_DUAL_ENTRY(stub_main)},/* PJT_MAIN_NP */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEXATTR_DESTROY */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEXATTR_INIT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEXATTR_SETTYPE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEX_DESTROY */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEX_INIT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEX_LOCK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEX_TRYLOCK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEX_UNLOCK */
-   {PJT_DUAL_ENTRY(stub_fail)},/* PJT_ONCE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_RWLOCK_DESTROY */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_RWLOCK_INIT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_RWLOCK_RDLOCK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_RWLOCK_TRYRDLOCK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_RWLOCK_TRYWRLOCK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_RWLOCK_UNLOCK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_RWLOCK_WRLOCK */
-   {PJT_DUAL_ENTRY(stub_self)},/* PJT_SELF */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_SETCANCELSTATE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_SETCANCELTYPE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_SETSPECIFIC */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_SIGMASK */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_TESTCANCEL */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_CLEANUP_POP_IMP */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_CLEANUP_PUSH_IMP */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_CANCEL_ENTER */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_CANCEL_LEAVE */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEX_CONSISTENT */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEXATTR_GETROBUST */
-   {PJT_DUAL_ENTRY(stub_zero)},/* PJT_MUTEXATTR_SETROBUST */
-   {PJT_DUAL_ENTRY(stub_zero)},   

svn commit: r368022 - head/lib/libsysdecode

2020-11-25 Thread Pawel Biernacki
Author: kaktus
Date: Wed Nov 25 16:30:57 2020
New Revision: 368022
URL: https://svnweb.freebsd.org/changeset/base/368022

Log:
  libsysdecode: correctly decode mmap flags
  
  r352913 added decoding of mmap PROT_MAX()'d flags but didn’t account for the
  case where different values were specified for PROT_MAX and regular flags.
  Fix it.
  
  Submitted by: sigsys_gmail.com
  Reported by:  sigsys_gmail.com
  MFC after:7 days
  Differential Revision:https://reviews.freebsd.org/D27312

Modified:
  head/lib/libsysdecode/flags.c

Modified: head/lib/libsysdecode/flags.c
==
--- head/lib/libsysdecode/flags.c   Wed Nov 25 15:45:20 2020
(r368021)
+++ head/lib/libsysdecode/flags.c   Wed Nov 25 16:30:57 2020
(r368022)
@@ -662,11 +662,11 @@ sysdecode_mmap_prot(FILE *fp, int prot, int *rem)
 
printed = false;
protm = PROT_MAX_EXTRACT(prot);
+   prot = PROT_EXTRACT(prot);
if (protm != 0) {
fputs("PROT_MAX(", fp);
printed = print_mask_int(fp, mmapprot, protm, rem);
fputs(")|", fp);
-   prot = protm;
}
return (print_mask_int(fp, mmapprot, prot, rem) || printed);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368021 - head/sys/arm/ti

2020-11-25 Thread Ian Lepore
Author: ian
Date: Wed Nov 25 15:45:20 2020
New Revision: 368021
URL: https://svnweb.freebsd.org/changeset/base/368021

Log:
  Only attach the ti_scm_syscon driver when running on a compatible TI chip.
  This prevents attaching on non-TI systems in the GENERIC kernel.
  
  Reviewed by:  manu@, mmel@

Modified:
  head/sys/arm/ti/ti_scm_syscon.c

Modified: head/sys/arm/ti/ti_scm_syscon.c
==
--- head/sys/arm/ti/ti_scm_syscon.c Wed Nov 25 15:07:22 2020
(r368020)
+++ head/sys/arm/ti/ti_scm_syscon.c Wed Nov 25 15:45:20 2020
(r368021)
@@ -54,6 +54,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include "clkdev_if.h"
 
+#include 
+
 #if 0
 #define DPRINTF(dev, msg...) device_printf(dev, msg)
 #else
@@ -146,6 +148,9 @@ static int
 ti_scm_syscon_probe(device_t dev)
 {
if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+
+   if (!ti_soc_is_supported())
return (ENXIO);
 
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368020 - head/sys/net

2020-11-25 Thread Kristof Provost
Author: kp
Date: Wed Nov 25 15:07:22 2020
New Revision: 368020
URL: https://svnweb.freebsd.org/changeset/base/368020

Log:
  if: Protect V_ifnet in vnet_if_return()
  
  When we terminate a vnet (i.e. jail) we move interfaces back to their home
  vnet. We need to protect our access to the V_ifnet CK_LIST.
  
  We could enter NET_EPOCH, but if_detach_internal() (called from if_vmove())
  waits for net epoch callback completion. That's not possible from NET_EPOCH.
  Instead, we take the IFNET_WLOCK, build a list of the interfaces that need to
  move and, once we've released the lock, move them back to their home vnet.
  
  We cannot hold the IFNET_WLOCK() during if_vmove(), because that results in a
  LOR between ifnet_sx, in_multi_sx and iflib ctx lock.
  
  Separate out moving the ifp into or out of V_ifnet, so we can hold the lock as
  we do the list manipulation, but do not hold it as we if_vmove().
  
  Reviewed by:  melifaro
  MFC after:2 weeks
  Sponsored by: Modirum MDPay
  Differential Revision:https://reviews.freebsd.org/D27279

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Wed Nov 25 14:26:13 2020(r368019)
+++ head/sys/net/if.c   Wed Nov 25 15:07:22 2020(r368020)
@@ -275,6 +275,8 @@ static void if_delgroups(struct ifnet *);
 static voidif_attach_internal(struct ifnet *, int, struct if_clone *);
 static int if_detach_internal(struct ifnet *, int, struct if_clone **);
 static voidif_siocaddmulti(void *, int);
+static voidif_link_ifnet(struct ifnet *);
+static boolif_unlink_ifnet(struct ifnet *, bool);
 #ifdef VIMAGE
 static int if_vmove(struct ifnet *, struct vnet *);
 #endif
@@ -468,15 +470,81 @@ VNET_SYSUNINIT(vnet_if_uninit, SI_SUB_INIT_IF, SI_ORDE
 vnet_if_uninit, NULL);
 
 static void
+if_link_ifnet(struct ifnet *ifp)
+{
+
+   IFNET_WLOCK();
+   CK_STAILQ_INSERT_TAIL(_ifnet, ifp, if_link);
+#ifdef VIMAGE
+   curvnet->vnet_ifcnt++;
+#endif
+   IFNET_WUNLOCK();
+}
+
+static bool
+if_unlink_ifnet(struct ifnet *ifp, bool vmove)
+{
+   struct ifnet *iter;
+   int found = 0;
+
+   IFNET_WLOCK();
+   CK_STAILQ_FOREACH(iter, _ifnet, if_link)
+   if (iter == ifp) {
+   CK_STAILQ_REMOVE(_ifnet, ifp, ifnet, if_link);
+   if (!vmove)
+   ifp->if_flags |= IFF_DYING;
+   found = 1;
+   break;
+   }
+#ifdef VIMAGE
+   curvnet->vnet_ifcnt--;
+#endif
+   IFNET_WUNLOCK();
+
+   return (found);
+}
+
+static void
 vnet_if_return(const void *unused __unused)
 {
struct ifnet *ifp, *nifp;
+   struct ifnet **pending;
+   int found, i;
 
+   i = 0;
+
+   /*
+* We need to protect our access to the V_ifnet tailq. Ordinarily we'd
+* enter NET_EPOCH, but that's not possible, because if_vmove() calls
+* if_detach_internal(), which waits for NET_EPOCH callbacks to
+* complete. We can't do that from within NET_EPOCH.
+*
+* However, we can also use the IFNET_xLOCK, which is the V_ifnet
+* read/write lock. We cannot hold the lock as we call if_vmove()
+* though, as that presents LOR w.r.t ifnet_sx, in_multi_sx and iflib
+* ctx lock.
+*/
+   IFNET_WLOCK();
+
+   pending = malloc(sizeof(struct ifnet *) * curvnet->vnet_ifcnt,
+   M_IFNET, M_WAITOK | M_ZERO);
+
/* Return all inherited interfaces to their parent vnets. */
CK_STAILQ_FOREACH_SAFE(ifp, _ifnet, if_link, nifp) {
-   if (ifp->if_home_vnet != ifp->if_vnet)
-   if_vmove(ifp, ifp->if_home_vnet);
+   if (ifp->if_home_vnet != ifp->if_vnet) {
+   found = if_unlink_ifnet(ifp, true);
+   MPASS(found);
+
+   pending[i++] = ifp;
+   }
}
+   IFNET_WUNLOCK();
+
+   for (int j = 0; j < i; j++) {
+   if_vmove(pending[j], pending[j]->if_home_vnet);
+   }
+
+   free(pending, M_IFNET);
 }
 VNET_SYSUNINIT(vnet_if_return, SI_SUB_VNET_DONE, SI_ORDER_ANY,
 vnet_if_return, NULL);
@@ -906,12 +974,7 @@ if_attach_internal(struct ifnet *ifp, int vmove, struc
}
 #endif
 
-   IFNET_WLOCK();
-   CK_STAILQ_INSERT_TAIL(_ifnet, ifp, if_link);
-#ifdef VIMAGE
-   curvnet->vnet_ifcnt++;
-#endif
-   IFNET_WUNLOCK();
+   if_link_ifnet(ifp);
 
if (domain_init_status >= 2)
if_attachdomain1(ifp);
@@ -1049,9 +1112,12 @@ if_purgemaddrs(struct ifnet *ifp)
 void
 if_detach(struct ifnet *ifp)
 {
+   bool found;
 
CURVNET_SET_QUIET(ifp->if_vnet);
-   if_detach_internal(ifp, 0, NULL);
+   found = if_unlink_ifnet(ifp, false);
+   if (found)
+   if_detach_internal(ifp, 0, NULL);
CURVNET_RESTORE();

svn commit: r368019 - head/contrib/llvm-project/clang/lib/Driver/ToolChains

2020-11-25 Thread Ed Maste
Author: emaste
Date: Wed Nov 25 14:26:13 2020
New Revision: 368019
URL: https://svnweb.freebsd.org/changeset/base/368019

Log:
  clang: allow -fstack-clash-protection on FreeBSD
  
  -fstack-clash-protection was added in Clang commit e67cbac81211 but was
  enabled only on Linux.  It should work fine on FreeBSD as well, so
  enable it.
  
  To be discussed and upstreamed with a test.  The OS test should probably
  just be removed.
  
  Reviewed by:  dim
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D27366

Modified:
  head/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp

Modified: head/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
==
--- head/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp Wed Nov 
25 11:21:03 2020(r368018)
+++ head/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp Wed Nov 
25 14:26:13 2020(r368019)
@@ -2967,7 +2967,7 @@ static void RenderSCPOptions(const ToolChain , cons
  ArgStringList ) {
   const llvm::Triple  = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
 return;
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r367813 - head/lib/libutil

2020-11-25 Thread Stefan Esser

Am 19.11.20 um 00:20 schrieb Brooks Davis:

On Thu, Nov 19, 2020 at 12:05:51AM +0100, Stefan Esser wrote:

Am 18.11.20 um 23:14 schrieb Jessica Clarke:

Why not? There could easily be code out there calling getenv in a
multi-threaded context so this is inadequate as a replacement. Yes it's
inefficient but it's perfectly legal and imaginable.


Yes, calling getenv() might occur, but getlocalbase() is generally
called before configuration files are accessed, and the resulting
path is saved in the program. Other uses are possible, but this is
the recurring pattern.


This seems like a very naive assumption.  I could easily see libraries
wanting to know where localbase is and calling this completely without
knowledge of the application programmer.


Yes, and what's the issue, then?

The implementation that I provided could be called in a multi-
threaded environment and from within libraries.

It checked whether a new allocation was required and returned
the pointer stored by another thread (but with identical contents)
in case it lost a potential race that could exist once during the
execution of this function for a fraction of a microsecond. Only
if another thread had managed to store its pointer after the check
for it being NULL simultaneously, then a few bytes could have been
lost. You might have been able to trigger this with a specifically
built test program.

But I had only added the run-time allocation of that buffer (which
might be exploited to leak at most a few KB or heap space) due to
requests in the discussion. My initial version used a statically
allocated buffer and was completely safe.


I have written about this possibility and I had appreciated
if comments had been made on Phabricator before the commit.


Don't mistake posting something for review with obtaining
consensus.  I glanced at the review, but it contained no use cases or
justification for the feature so it was impossible to comment on the
implementation in the time I had.  I still don't understand what you aim
to support and why (except that your implementation fails to support
things like per-jail or per-ABI localbase which both seem like things
people might want.)


As described in the review, adding per-jail variables is a way to
extend the usefulness of this function, but out-of-scope at this
time. It requires changes to other parts of FreeBSD (kernel, jails)
that might then lead to an update of this function, but which can
be developed independently of the initial use of this function in
the limit way currently supported by the kernel.

And I do not need the run-time configurability at all. In fact,
I'd replace getlocalbase() calls by a macro substitution that just
returns _PATH_LOCALBASE as the default value the system was built
with.

But there has been interest in this feature and getenv("LOCALBASE")
has been used in a number of programs to be able to manipulate that
prefix at run-time.

This implementation just simplifies the getenv() calls in that case,
and that alone might be a justification for this function. It has
the added security feature of checking issetugid() and not using
the environment value in that case.

Thus it simplifies programs and allows them to take advantage of
other methods to configure LOCALBASE (e.g. later per jail or per
ABI) without changes to the programs reaching into LOCALBASE.


The getlocalbase() function had been suggested by Scott Long to
provide a generic means to retrieve the LOCALBASE prefix in
programs. Therefore, he implemented the getenv() functionality
found in a number of programs, before.

I had patched the calendar program to support data files provided
by a port (deskutils/calendar-data) to ease maintenance of these
date files outside of the base system. While doing this, I noticed
the use of literal "/usr/local" in a number of base system utilities
and provided this value as _PATH_LOCALBASE to make it easier to
override, if desired (not needed by me, but again requested on the
maillists in several threads).

A non-default _PATH_LOCALBASE can be compiled into programs, but
not in e.g. shell scripts. I have added the user.localbase sysctl
to query _PATH_LOCALBASE from programs that do not have it compiled
in (e.g. shell scripts).

The user.localbase sysctl variable is queried and passed to the
rc subsystem as ${_localbase} by changes committed by me in
SVN rev. 367294.

All these changes are meant to allow building a system that has a
non-default LOCALBASE, without hunting down all literal occurances
of "/usr/local" in the tree.

Making sysctl("user.localbase") available in getlocalbase() is then
a logical consequence of all the other changes.


As I wrote before: I'm interested in providing a standard method
to obtain LOCALBASE in case it is not set to the FreeBSD default
value of "/usr/local" to allow as many components of the system
to automatically use the correct paths in such an environment.

The function should always return a string value that can be used
as a prefix for 

svn commit: r368018 - head/sys/modules/dtb/allwinner

2020-11-25 Thread Emmanuel Vadot
Author: manu
Date: Wed Nov 25 11:21:03 2020
New Revision: 368018
URL: https://svnweb.freebsd.org/changeset/base/368018

Log:
  dtb: allwinner: Add pineh64 to the build

Modified:
  head/sys/modules/dtb/allwinner/Makefile

Modified: head/sys/modules/dtb/allwinner/Makefile
==
--- head/sys/modules/dtb/allwinner/Makefile Wed Nov 25 11:20:04 2020
(r368017)
+++ head/sys/modules/dtb/allwinner/Makefile Wed Nov 25 11:21:03 2020
(r368018)
@@ -47,7 +47,9 @@ DTS=  \
allwinner/sun50i-a64-pinebook.dts \
allwinner/sun50i-a64-sopine-baseboard.dts \
allwinner/sun50i-h5-orangepi-pc2.dts \
-   allwinner/sun50i-h5-nanopi-neo2.dts
+   allwinner/sun50i-h5-nanopi-neo2.dts \
+   allwinner/sun50i-h6-pine-h64.dts \
+   allwinner/sun50i-h6-pine-h64-model-b.dts
 
 DTSO=  sun50i-a64-opp.dtso \
sun50i-a64-pwm.dtso \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368017 - head/sys/arm/allwinner

2020-11-25 Thread Emmanuel Vadot
Author: manu
Date: Wed Nov 25 11:20:04 2020
New Revision: 368017
URL: https://svnweb.freebsd.org/changeset/base/368017

Log:
  arm: allwinner: aw_rtc: Add H6 compatible

Modified:
  head/sys/arm/allwinner/aw_rtc.c

Modified: head/sys/arm/allwinner/aw_rtc.c
==
--- head/sys/arm/allwinner/aw_rtc.c Wed Nov 25 11:19:42 2020
(r368016)
+++ head/sys/arm/allwinner/aw_rtc.c Wed Nov 25 11:20:04 2020
(r368017)
@@ -138,6 +138,7 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun6i-a31-rtc", (uintptr_t) _conf },
{ "allwinner,sun8i-h3-rtc", (uintptr_t) _conf },
{ "allwinner,sun50i-h5-rtc", (uintptr_t) _conf },
+   { "allwinner,sun50i-h6-rtc", (uintptr_t) _conf },
{ NULL, 0 }
 };
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368016 - head/sys/arm/allwinner/clkng

2020-11-25 Thread Emmanuel Vadot
Author: manu
Date: Wed Nov 25 11:19:42 2020
New Revision: 368016
URL: https://svnweb.freebsd.org/changeset/base/368016

Log:
  arm64: allwinner: H6: Fix pll 4x clocks
  
  The clock configured by the registers are the 4x version not the 1x.

Modified:
  head/sys/arm/allwinner/clkng/ccu_h6.c

Modified: head/sys/arm/allwinner/clkng/ccu_h6.c
==
--- head/sys/arm/allwinner/clkng/ccu_h6.c   Wed Nov 25 10:56:38 2020
(r368015)
+++ head/sys/arm/allwinner/clkng/ccu_h6.c   Wed Nov 25 11:19:42 2020
(r368016)
@@ -196,10 +196,10 @@ NMM_CLK(pll_ddr0_clk,
 28, 1000,  /* lock */
 AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK);/* flags */
 
-static const char *pll_peri0_parents[] = {"osc24M"};
-NMM_CLK(pll_peri0_clk,
-CLK_PLL_PERIPH0,   /* id */
-"pll_periph0", pll_peri0_parents,  /* name, parents */
+static const char *pll_peri0_4x_parents[] = {"osc24M"};
+NMM_CLK(pll_peri0_4x_clk,
+CLK_PLL_PERIPH0_4X,/* id */
+"pll_periph0_4x", pll_peri0_4x_parents,/* name, parents */
 0x20,  /* offset */
 8, 7, 0, 0,/* n factor */
 0, 1, 0, 0,/* m0 factor */
@@ -207,7 +207,7 @@ NMM_CLK(pll_peri0_clk,
 31,/* gate */
 28, 1000,  /* lock */
 AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK);/* flags */
-static const char *pll_peri0_2x_parents[] = {"pll_periph0"};
+static const char *pll_peri0_2x_parents[] = {"pll_periph0_4x"};
 FIXED_CLK(pll_peri0_2x_clk,
 CLK_PLL_PERIPH0_2X,/* id */
 "pll_periph0_2x",  /* name */
@@ -216,20 +216,20 @@ FIXED_CLK(pll_peri0_2x_clk,
 1, /* mult */
 2, /* div */
 0);/* flags */
-static const char *pll_peri0_4x_parents[] = {"pll_periph0"};
-FIXED_CLK(pll_peri0_4x_clk,
-CLK_PLL_PERIPH0_4X,/* id */
-"pll_periph0_4x",  /* name */
-pll_peri0_4x_parents,  /* parent */
+static const char *pll_peri0_parents[] = {"pll_periph0_4x"};
+FIXED_CLK(pll_peri0_clk,
+CLK_PLL_PERIPH0,   /* id */
+"pll_periph0", /* name */
+pll_peri0_parents, /* parent */
 0, /* freq */
 1, /* mult */
 4, /* div */
 0);/* flags */
 
-static const char *pll_peri1_parents[] = {"osc24M"};
-NMM_CLK(pll_peri1_clk,
-CLK_PLL_PERIPH1,   /* id */
-"pll_periph1", pll_peri1_parents,  /* name, parents */
+static const char *pll_peri1_4x_parents[] = {"osc24M"};
+NMM_CLK(pll_peri1_4x_clk,
+CLK_PLL_PERIPH1_4X,/* id */
+"pll_periph1_4x", pll_peri1_4x_parents,/* name, parents */
 0x28,  /* offset */
 8, 7, 0, 0,/* n factor */
 0, 1, 0, 0,/* m0 factor */
@@ -237,7 +237,7 @@ NMM_CLK(pll_peri1_clk,
 31,/* gate */
 28, 1000,  /* lock */
 AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK);/* flags */
-static const char *pll_peri1_2x_parents[] = {"pll_periph1"};
+static const char *pll_peri1_2x_parents[] = {"pll_periph1_4x"};
 FIXED_CLK(pll_peri1_2x_clk,
 CLK_PLL_PERIPH1_2X,/* id */
 "pll_periph1_2x",  /* name */
@@ -246,11 +246,11 @@ FIXED_CLK(pll_peri1_2x_clk,
 1, /* mult */
 2, /* div */
 0);/* flags */
-static const char *pll_peri1_4x_parents[] = {"pll_periph1"};
-FIXED_CLK(pll_peri1_4x_clk,
-CLK_PLL_PERIPH1_4X,/* id */
-"pll_periph1_4x",  /* name */
-pll_peri1_4x_parents,  /* parent */
+static const char *pll_peri1_parents[] = {"pll_periph1_4x"};
+FIXED_CLK(pll_peri1_clk,
+CLK_PLL_PERIPH1,   /* id */
+"pll_periph1", /* name */
+pll_peri1_parents, /* parent */
 0, /* freq */
 1, /* mult */
 4, /* div */
@@ -268,10 +268,10 @@ NMM_CLK(pll_gpu_clk,
 28, 1000,  /* lock */
 AW_CLK_HAS_GATE | AW_CLK_HAS_LOCK);/* flags */
 
-static const char 

Re: svn commit: r367813 - head/lib/libutil

2020-11-25 Thread Stefan Esser

Am 19.11.20 um 01:37 schrieb Mateusz Guzik:

On 11/19/20, Stefan Esser  wrote:

[...]

I just wanted to provide an implementation of this functionality to
be used in a number of programs where other developers had expressed
interest in such a feature (and one of these programs has been worked
on by me in recent weeks, so I'm now able to make use of it myself).


The entire localbase saga is getting way out of hand.


Yes, apparently.


To address this e-mail and things you wrote in another reply, my
comlaints are very simple and are not getting less valid for not being
raised sooner. I just was not watching any of this until recent
fallout.

For the change at hand, there has to be a reason to use a static
symbol. Standard example is catching otherwise expensive to obtain
data. For that the static localbase pointer makes perfect sense, while
the static lookup array does not have any justification that I see.


The reason to use a static symbol for the return value is that I do
not want to have to use the getlocalbase() on my systems at all.

The static lookup array is trivially changed to be stack allocated
and filled at run-time, this is a non-issue, IMHO.


As explained in an earlier discussion, I'd rather build my systems
with a _PATH_LOCALBASE set to a non-default value than use any
run-time setting of this value. And thus, my implementation will
be just to define getlocalbase in the libutil.h on my systems:

#define getlocalbase() _PATH_LOCALBASE

Copying into a user provided buffer is of course possible, and such
an implementation had been committed before. It does not allow to
enforce a compiled in _PATH_LOCALBASE in the way I want to use it,
but I would find a way around this.

But the diffs to programs that use getlocalbase with caller supplied
buffers were significantly larger. My version can just replace the
getenv("LOCALBASE") found in a number of places by getlocalbase()
(and since getlocalbase() returns the default value if the environment
variable has not been set, remove the fallback code for that case).


Bringing cache, TLB or whatever microarchitectural details into the
discussion is beyond not warranted.

I did not start bringing in such issues, see the mail I responded to.
And I argued that it just did not matter which way the argument array
was defined, since either method has minor advantages and disadvantages.


More importantly though the commit comes with a self-confessed memory
leak and is a show stopper.


There is no memory leak, actually. Only if you called getlocalbase()
in a multi-threaded environment multiple times and in such a way that
the non-NULL test before the assignment overlaps with an assignment
in another thread, there could have been a leak of a few bytes. But
you could not exploit this leak in any way, since there is a limited
number of cores that can execute threads in parallel.

My supposed initial version did not have any memory leak and had been
rejected due to the pre-allocation of a static buffer. I do not agree
that this is an issue, since the number of VM pages allocated for the
data segment of the library does not grow, and this is what counts.

It is easily possible to limit the user.localbase variable to a useful
size in the kernel and the library (e.g. 64 bytes, which should be
sufficient as a PREFIX). But even at MAXPATHLEN, the memory usage is
not increased by this buffer.


That said, I'll see about patching this up.


I have created a new review with a static buffer. It does not have any
memory leaks, does not increase the memory usage of libutil, and it is
fully thread safe and guaranteed to return the same value on each
successive invocation (which seems to make sense for a system parameter
like LOCALBASE - the code can easily be changed to perform the getenv
and sysctl calls on each invocation again).

https://reviews.freebsd.org/D27370

Regards, STefan



OpenPGP_signature
Description: OpenPGP digital signature


svn commit: r368015 - head/sys/net

2020-11-25 Thread Kristof Provost
Author: kp
Date: Wed Nov 25 10:56:38 2020
New Revision: 368015
URL: https://svnweb.freebsd.org/changeset/base/368015

Log:
  if: Remove ifnet_rwlock
  
  It no longer serves any purpose, as evidenced by the fact that we never take 
it
  without ifnet_sxlock.
  
  Sponsored by: Modirum MDPay
  Differential Revision:https://reviews.freebsd.org/D27278

Modified:
  head/sys/net/if.c
  head/sys/net/if_var.h

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Wed Nov 25 10:21:29 2020(r368014)
+++ head/sys/net/if.c   Wed Nov 25 10:56:38 2020(r368015)
@@ -306,15 +306,9 @@ VNET_DEFINE(struct ifnet **, ifindex_table);
 
 /*
  * The global network interface list (V_ifnet) and related state (such as
- * if_index, if_indexlim, and ifindex_table) are protected by an sxlock and
- * an rwlock.  Either may be acquired shared to stablize the list, but both
- * must be acquired writable to modify the list.  This model allows us to
- * both stablize the interface list during interrupt thread processing, but
- * also to stablize it over long-running ioctls, without introducing priority
- * inversions and deadlocks.
+ * if_index, if_indexlim, and ifindex_table) are protected by an sxlock.
+ * This may be acquired to stabilise the list, or we may rely on NET_EPOCH.
  */
-struct rwlock ifnet_rwlock;
-RW_SYSINIT_FLAGS(ifnet_rw, _rwlock, "ifnet_rw", RW_RECURSE);
 struct sx ifnet_sxlock;
 SX_SYSINIT_FLAGS(ifnet_sx, _sxlock, "ifnet_sx", SX_RECURSE);
 

Modified: head/sys/net/if_var.h
==
--- head/sys/net/if_var.h   Wed Nov 25 10:21:29 2020(r368014)
+++ head/sys/net/if_var.h   Wed Nov 25 10:56:38 2020(r368015)
@@ -593,29 +593,12 @@ struct ifmultiaddr {
struct  epoch_context   ifma_epoch_ctx;
 };
 
-extern struct rwlock ifnet_rwlock;
 extern struct sx ifnet_sxlock;
 
-#defineIFNET_WLOCK() do {  
\
-   sx_xlock(_sxlock);\
-   rw_wlock(_rwlock);\
-} while (0)
-
-#defineIFNET_WUNLOCK() do {
\
-   rw_wunlock(_rwlock);  \
-   sx_xunlock(_sxlock);  \
-} while (0)
-
-/*
- * To assert the ifnet lock, you must know not only whether it's for read or
- * write, but also whether it was acquired with sleep support or not.
- */
-#defineIFNET_RLOCK_ASSERT()sx_assert(_sxlock, 
SA_SLOCKED)
-#defineIFNET_WLOCK_ASSERT() do {   
\
-   sx_assert(_sxlock, SA_XLOCKED);   \
-   rw_assert(_rwlock, RA_WLOCKED);   \
-} while (0)
-
+#defineIFNET_WLOCK()   sx_xlock(_sxlock)
+#defineIFNET_WUNLOCK() sx_xunlock(_sxlock)
+#defineIFNET_RLOCK_ASSERT()sx_assert(_sxlock, SA_SLOCKED)
+#defineIFNET_WLOCK_ASSERT()sx_assert(_sxlock, SA_XLOCKED)
 #defineIFNET_RLOCK()   sx_slock(_sxlock)
 #defineIFNET_RUNLOCK() sx_sunlock(_sxlock)
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368014 - head/usr.bin/fortune/datfiles

2020-11-25 Thread Benedict Reuschling
Author: bcr (doc committer)
Date: Wed Nov 25 10:21:29 2020
New Revision: 368014
URL: https://svnweb.freebsd.org/changeset/base/368014

Log:
  Drop superfluous "of" from the systat example.

Modified:
  head/usr.bin/fortune/datfiles/freebsd-tips

Modified: head/usr.bin/fortune/datfiles/freebsd-tips
==
--- head/usr.bin/fortune/datfiles/freebsd-tips  Wed Nov 25 09:37:17 2020
(r368013)
+++ head/usr.bin/fortune/datfiles/freebsd-tips  Wed Nov 25 10:21:29 2020
(r368014)
@@ -584,7 +584,7 @@ zfs list -o space
-- Benedict Reuschling 
 %
 To learn more about what your system is doing, take a look at systat(1). For
-example, to get various of statistics related to virtual memory usage, process
+example, to get various statistics related to virtual memory usage, process
 scheduling, device interrupts, system name translation caching, and disk I/O,
 enter the following:
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368013 - in stable/11: share/man/man4 sys/contrib/ena-com sys/contrib/ena-com/ena_defs sys/dev/ena sys/modules/ena

2020-11-25 Thread Marcin Wojtas
Author: mw
Date: Wed Nov 25 09:37:17 2020
New Revision: 368013
URL: https://svnweb.freebsd.org/changeset/base/368013

Log:
  MFC: Merge ENA v2.3.0 driver
  
  r367805 Update ENA driver version to v2.3.0
  r367803 Rename descriptions of the supported ENA devices
  r367802 Add ENI metrics for the ENA driver
  r367801 Add SPDX license tag to the ENA driver files
  r367800 Add Rx offsets support for the ENA driver
  r367799 Adjust ENA driver files to latest ena-com changes
  r367795 Fix completion descriptors alignment for the ENA
  
  Obtained from:  Semihalf
  Sponsored by:   Amazon, Inc

Modified:
  stable/11/share/man/man4/ena.4
  stable/11/sys/contrib/ena-com/ena_com.c
  stable/11/sys/contrib/ena-com/ena_com.h
  stable/11/sys/contrib/ena-com/ena_defs/ena_admin_defs.h
  stable/11/sys/contrib/ena-com/ena_defs/ena_common_defs.h
  stable/11/sys/contrib/ena-com/ena_defs/ena_eth_io_defs.h
  stable/11/sys/contrib/ena-com/ena_defs/ena_gen_info.h
  stable/11/sys/contrib/ena-com/ena_defs/ena_regs_defs.h
  stable/11/sys/contrib/ena-com/ena_eth_com.c
  stable/11/sys/contrib/ena-com/ena_eth_com.h
  stable/11/sys/contrib/ena-com/ena_plat.h
  stable/11/sys/dev/ena/ena.c
  stable/11/sys/dev/ena/ena.h
  stable/11/sys/dev/ena/ena_datapath.c
  stable/11/sys/dev/ena/ena_datapath.h
  stable/11/sys/dev/ena/ena_netmap.c
  stable/11/sys/dev/ena/ena_netmap.h
  stable/11/sys/dev/ena/ena_sysctl.c
  stable/11/sys/dev/ena/ena_sysctl.h
  stable/11/sys/modules/ena/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man4/ena.4
==
--- stable/11/share/man/man4/ena.4  Wed Nov 25 03:24:43 2020
(r368012)
+++ stable/11/share/man/man4/ena.4  Wed Nov 25 09:37:17 2020
(r368013)
@@ -1,4 +1,6 @@
-.\" Copyright (c) 2015-2017 Amazon.com, Inc. or its affiliates.
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates.
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without

Modified: stable/11/sys/contrib/ena-com/ena_com.c
==
--- stable/11/sys/contrib/ena-com/ena_com.c Wed Nov 25 03:24:43 2020
(r368012)
+++ stable/11/sys/contrib/ena-com/ena_com.c Wed Nov 25 09:37:17 2020
(r368013)
@@ -1,5 +1,5 @@
 /*-
- * BSD LICENSE
+ * SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates.
  * All rights reserved.
@@ -70,9 +70,9 @@
 
 #define ENA_REGS_ADMIN_INTR_MASK 1
 
-#define ENA_MIN_POLL_US 100
+#define ENA_MIN_ADMIN_POLL_US 100
 
-#define ENA_MAX_POLL_US 5000
+#define ENA_MAX_ADMIN_POLL_US 5000
 
 /*/
 /*/
@@ -106,7 +106,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *en
   dma_addr_t addr)
 {
if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) {
-   ena_trc_err("dma address has more bits that the device 
supports\n");
+   ena_trc_err(ena_dev, "DMA address has more bits that the device 
supports\n");
return ENA_COM_INVAL;
}
 
@@ -116,16 +116,17 @@ static int ena_com_mem_addr_set(struct ena_com_dev *en
return 0;
 }
 
-static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
-   struct ena_com_admin_sq *sq = >sq;
-   u16 size = ADMIN_SQ_SIZE(queue->q_depth);
+   struct ena_com_dev *ena_dev = admin_queue->ena_dev;
+   struct ena_com_admin_sq *sq = _queue->sq;
+   u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
-   ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, sq->entries, sq->dma_addr,
+   ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, sq->entries, 
sq->dma_addr,
   sq->mem_handle);
 
if (!sq->entries) {
-   ena_trc_err("memory allocation failed\n");
+   ena_trc_err(ena_dev, "Memory allocation failed\n");
return ENA_COM_NO_MEM;
}
 
@@ -138,16 +139,17 @@ static int ena_com_admin_init_sq(struct ena_com_admin_
return 0;
 }
 
-static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
-   struct ena_com_admin_cq *cq = >cq;
-   u16 size = ADMIN_CQ_SIZE(queue->q_depth);
+   struct ena_com_dev *ena_dev = admin_queue->ena_dev;
+   struct ena_com_admin_cq *cq = _queue->cq;
+   u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
-   ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, cq->entries, cq->dma_addr,
+   ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, cq->entries, 
cq->dma_addr,