svn commit: r341844 - head/contrib/tcpdump

2018-12-12 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Dec 12 09:51:10 2018
New Revision: 341844
URL: https://svnweb.freebsd.org/changeset/base/341844

Log:
  Don't register IOCTLs with capsicum when there is no valid file descriptor.
  This fixes tcpdump when using mlx5_X devices.
  
  Differential Revision:https://reviews.freebsd.org/D18499
  Reviewed by:  kib@, slavash@, oshogbo@
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/contrib/tcpdump/tcpdump.c

Modified: head/contrib/tcpdump/tcpdump.c
==
--- head/contrib/tcpdump/tcpdump.c  Wed Dec 12 09:03:10 2018
(r341843)
+++ head/contrib/tcpdump/tcpdump.c  Wed Dec 12 09:51:10 2018
(r341844)
@@ -1915,7 +1915,7 @@ main(int argc, char **argv)
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
 #ifdef HAVE_CAPSICUM
-   if (RFileName == NULL && VFileName == NULL) {
+   if (RFileName == NULL && VFileName == NULL && pcap_fileno(pd) != -1) {
static const unsigned long cmds[] = { BIOCGSTATS, BIOCROTZBUF };
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r341988 - head/sys/dev/asmc

2018-12-12 Thread David Bright
Author: dab
Date: Wed Dec 12 13:43:55 2018
New Revision: 341988
URL: https://svnweb.freebsd.org/changeset/base/341988

Log:
  asmc: Add Support for Macbook Pro 8,1
  
  PR:   217505
  Submitted by: John O. Brickley , updated by Maciej 
Pasternacki 
  Reported by:  John O. Brickley 
  MFC after:1 week

Modified:
  head/sys/dev/asmc/asmc.c
  head/sys/dev/asmc/asmcvar.h

Modified: head/sys/dev/asmc/asmc.c
==
--- head/sys/dev/asmc/asmc.cWed Dec 12 13:17:51 2018(r341987)
+++ head/sys/dev/asmc/asmc.cWed Dec 12 13:43:55 2018(r341988)
@@ -219,9 +219,15 @@ struct asmc_model asmc_models[] = {
},
 
{
+ "MacBookPro8,1", "Apple SMC MacBook Pro (early 2011, 13-inch)",
+ ASMC_SMS_FUNCS_DISABLED, ASMC_FAN_FUNCS2, ASMC_LIGHT_FUNCS,
+ ASMC_MBP81_TEMPS, ASMC_MBP81_TEMPNAMES, ASMC_MBP81_TEMPDESCS
+   },
+
+   {
  "MacBookPro8,2", "Apple SMC MacBook Pro (early 2011)",
  ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS,
- ASMC_MBP8_TEMPS, ASMC_MBP8_TEMPNAMES, ASMC_MBP8_TEMPDESCS
+ ASMC_MBP82_TEMPS, ASMC_MBP82_TEMPNAMES, ASMC_MBP82_TEMPDESCS
},
 
{

Modified: head/sys/dev/asmc/asmcvar.h
==
--- head/sys/dev/asmc/asmcvar.h Wed Dec 12 13:17:51 2018(r341987)
+++ head/sys/dev/asmc/asmcvar.h Wed Dec 12 13:43:55 2018(r341988)
@@ -218,21 +218,39 @@ struct asmc_softc {
  "Heatsink 2", "Memory Controller", \
  "PCI Express Slot Pin", "PCI Express Slot 
(unk)" }
 
-#define ASMC_MBP8_TEMPS{ "TB0T", "TB1T", "TB2T", "TC0C", 
"TC0D", \
+#define ASMC_MBP81_TEMPS   { "TB0T", "TB1T", "TB2T", "TC0C", "TC0D", \
  "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
+ "TCFC", "TCGC", "TCSA", "TM0S", "TMBS", \
+ "TP0P", "TPCD", "TW0P", "Th1H", "Ts0P", \
+ "Ts0S", NULL }
+
+#define ASMC_MBP81_TEMPNAMES   { "enclosure", "TB1T", "TB2T", "TC0C", "TC0D", \
+ "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
+ "TCFC", "TCGC", "TCSA", "TM0S", "TMBS", \
+ "TP0P", "TPCD", "wireless", "Th1H", "Ts0P", \
+ "Ts0S" }
+
+#define ASMC_MBP81_TEMPDESCS   { "Enclosure Bottomside", "TB1T", "TB2T", 
"TC0C", "TC0D", \
+ "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
+ "TCFC", "TCGC", "TCSA", "TM0S", "TMBS", \
+ "TP0P", "TPCD", "TW0P", "Th1H", "Ts0P", \
+ "Ts0S" }
+
+#define ASMC_MBP82_TEMPS   { "TB0T", "TB1T", "TB2T", "TC0C", "TC0D", \
+ "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
  "TC3C", "TC4C", "TCFC", "TCGC", "TCSA", \
  "TCTD", "TG0D", "TG0P", "THSP", "TM0S", \
  "TMBS", "TP0P", "TPCD", "TW0P", "Th1H", \
  "Th2H", "Tm0P", "Ts0P", "Ts0S", NULL }
 
-#define ASMC_MBP8_TEMPNAMES{ "enclosure", "TB1T", "TB2T", "TC0C", "TC0D", \
+#define ASMC_MBP82_TEMPNAMES   { "enclosure", "TB1T", "TB2T", "TC0C", "TC0D", \
  "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
  "TC3C", "TC4C", "TCFC", "TCGC", "TCSA", \
  "TCTD", "graphics", "TG0P", "THSP", "TM0S", \
  "TMBS", "TP0P", "TPCD", "wireless", "Th1H", \
  "Th2H", "memory", "Ts0P", "Ts0S" }
 
-#define ASMC_MBP8_TEMPDESCS{ "Enclosure Bottomside", "TB1T", "TB2T", 
"TC0C", "TC0D", \
+#define ASMC_MBP82_TEMPDESCS   { "Enclosure Bottomside", "TB1T", "TB2T", 
"TC0C", "TC0D", \
  "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
  "TC3C", "TC4C", "TCFC", "TCGC", "TCSA", \
  "TCTD", "TG0D", "TG0P", "THSP", "TM0S", \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r341989 - head

2018-12-12 Thread Ed Maste
Author: emaste
Date: Wed Dec 12 15:23:40 2018
New Revision: 341989
URL: https://svnweb.freebsd.org/changeset/base/341989

Log:
  Makefile.inc1: update stale wpa dependency removal statement
  
  Only stale .depend files are removed; do not mention object files.

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Wed Dec 12 13:43:55 2018(r341988)
+++ head/Makefile.inc1  Wed Dec 12 15:23:40 2018(r341989)
@@ -981,7 +981,7 @@ _cleanobj_fast_depend_hack: .PHONY
@if [ -e "${OBJTOP}/usr.sbin/wpa/wpa_supplicant/.depend.rrm.o" ] && \
egrep -q 'src/ap/rrm.c' \
${OBJTOP}/usr.sbin/wpa/wpa_supplicant/.depend.rrm.o; then \
-   echo "Removing stale wpa dependencies and objects"; \
+   echo "Removing stale wpa dependencies"; \
rm -f ${OBJTOP}/usr.sbin/wpa/*/.depend*; \
fi
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r341990 - head/sys/dev/bwn

2018-12-12 Thread Mark Johnston
Author: markj
Date: Wed Dec 12 15:49:14 2018
New Revision: 341990
URL: https://svnweb.freebsd.org/changeset/base/341990

Log:
  Fix a possible mbuf double free in bwn_dma_tx_start().
  
  If bus_dmamap_load_mbuf() fails following a defrag, the caller of
  bwn_dma_tx_start() would free the original mbuf after m_defrag() had
  already done so.  Fix this by returning the defragged mbuf to the
  caller instead.  Update bwn_pio_tx_start() similarly for consistency.
  
  Reported by:  Ilja Van Sprundel 
  Reviewed by:  landonf
  Tested by:landonf
  MFC after:3 days
  admbug:   820
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18342

Modified:
  head/sys/dev/bwn/if_bwn.c

Modified: head/sys/dev/bwn/if_bwn.c
==
--- head/sys/dev/bwn/if_bwn.c   Wed Dec 12 15:23:40 2018(r341989)
+++ head/sys/dev/bwn/if_bwn.c   Wed Dec 12 15:49:14 2018(r341990)
@@ -209,7 +209,7 @@ static void bwn_pio_rx_write_2(struct bwn_pio_rxqueue 
 static voidbwn_pio_rx_write_4(struct bwn_pio_rxqueue *, uint16_t,
uint32_t);
 static int bwn_pio_tx_start(struct bwn_mac *, struct ieee80211_node *,
-   struct mbuf *);
+   struct mbuf **);
 static struct bwn_pio_txqueue *bwn_pio_select(struct bwn_mac *, uint8_t);
 static uint32_tbwn_pio_write_multi_4(struct bwn_mac *,
struct bwn_pio_txqueue *, uint32_t, const void *, int);
@@ -273,7 +273,7 @@ static void bwn_ratectl_tx_complete(const struct ieee8
 static voidbwn_dma_handle_txeof(struct bwn_mac *,
const struct bwn_txstatus *);
 static int bwn_dma_tx_start(struct bwn_mac *, struct ieee80211_node *,
-   struct mbuf *);
+   struct mbuf **);
 static int bwn_dma_getslot(struct bwn_dma_ring *);
 static struct bwn_dma_ring *bwn_dma_select(struct bwn_mac *,
uint8_t);
@@ -1068,7 +1068,7 @@ bwn_tx_start(struct bwn_softc *sc, struct ieee80211_no
}
 
error = (mac->mac_flags & BWN_MAC_FLAG_DMA) ?
-   bwn_dma_tx_start(mac, ni, m) : bwn_pio_tx_start(mac, ni, m);
+   bwn_dma_tx_start(mac, ni, &m) : bwn_pio_tx_start(mac, ni, &m);
if (error) {
m_freem(m);
return (error);
@@ -1077,13 +1077,14 @@ bwn_tx_start(struct bwn_softc *sc, struct ieee80211_no
 }
 
 static int
-bwn_pio_tx_start(struct bwn_mac *mac, struct ieee80211_node *ni, struct mbuf 
*m)
+bwn_pio_tx_start(struct bwn_mac *mac, struct ieee80211_node *ni,
+struct mbuf **mp)
 {
struct bwn_pio_txpkt *tp;
-   struct bwn_pio_txqueue *tq = bwn_pio_select(mac, M_WME_GETAC(m));
+   struct bwn_pio_txqueue *tq;
struct bwn_softc *sc = mac->mac_sc;
struct bwn_txhdr txhdr;
-   struct mbuf *m_new;
+   struct mbuf *m, *m_new;
uint32_t ctl32;
int error;
uint16_t ctl16;
@@ -1092,6 +1093,8 @@ bwn_pio_tx_start(struct bwn_mac *mac, struct ieee80211
 
/* XXX TODO send packets after DTIM */
 
+   m = *mp;
+   tq = bwn_pio_select(mac, M_WME_GETAC(m));
KASSERT(!TAILQ_EMPTY(&tq->tq_pktlist), ("%s: fail", __func__));
tp = TAILQ_FIRST(&tq->tq_pktlist);
tp->tp_ni = ni;
@@ -,13 +1114,14 @@ bwn_pio_tx_start(struct bwn_mac *mac, struct ieee80211
/*
 * XXX please removes m_defrag(9)
 */
-   m_new = m_defrag(m, M_NOWAIT);
+   m_new = m_defrag(*mp, M_NOWAIT);
if (m_new == NULL) {
device_printf(sc->sc_dev,
"%s: can't defrag TX buffer\n",
__func__);
return (ENOBUFS);
}
+   *mp = m_new;
if (m_new->m_next != NULL)
device_printf(sc->sc_dev,
"TODO: fragmented packets for PIO\n");
@@ -1168,15 +1172,17 @@ bwn_pio_select(struct bwn_mac *mac, uint8_t prio)
 }
 
 static int
-bwn_dma_tx_start(struct bwn_mac *mac, struct ieee80211_node *ni, struct mbuf 
*m)
+bwn_dma_tx_start(struct bwn_mac *mac, struct ieee80211_node *ni,
+struct mbuf **mp)
 {
 #defineBWN_GET_TXHDRCACHE(slot)
\
&(txhdr_cache[(slot / BWN_TX_SLOTS_PER_FRAME) * BWN_HDRSIZE(mac)])
struct bwn_dma *dma = &mac->mac_method.dma;
-   struct bwn_dma_ring *dr = bwn_dma_select(mac, M_WME_GETAC(m));
+   struct bwn_dma_ring *dr = bwn_dma_select(mac, M_WME_GETAC(*mp));
struct bwn_dmadesc_generic *desc;
struct bwn_dmadesc_meta *mt;
struct bwn_softc *sc = mac->mac_sc;
+   struct mbuf *m;
uint8_t *txhdr_cache = (uint8_t *)dr->dr_txhdr_cache;
int error, slot, backup[2] = { dr->dr_curslot, dr->dr_usedslot };
 
@@ -1185,6 +1191,7 @@ bwn_dma_tx_start(str

svn commit: r341992 - head/sys/dev/netmap

2018-12-12 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Dec 12 16:32:15 2018
New Revision: 341992
URL: https://svnweb.freebsd.org/changeset/base/341992

Log:
  netmap: fix warning in netmap_kloop.c
  
  Reported by:  markj
  MFC after:3 days

Modified:
  head/sys/dev/netmap/netmap_kloop.c

Modified: head/sys/dev/netmap/netmap_kloop.c
==
--- head/sys/dev/netmap/netmap_kloop.c  Wed Dec 12 16:25:30 2018
(r341991)
+++ head/sys/dev/netmap/netmap_kloop.c  Wed Dec 12 16:32:15 2018
(r341992)
@@ -111,6 +111,7 @@ csb_ktoa_kick_enable(struct nm_csb_ktoa __user *csb_kt
CSB_WRITE(csb_ktoa, kern_need_kick, val);
 }
 
+#ifdef SYNC_KLOOP_POLL
 /* Are application interrupt enabled or disabled? */
 static inline uint32_t
 csb_atok_intr_enabled(struct nm_csb_atok __user *csb_atok)
@@ -121,6 +122,7 @@ csb_atok_intr_enabled(struct nm_csb_atok __user *csb_a
 
return v;
 }
+#endif  /* SYNC_KLOOP_POLL */
 
 static inline void
 sync_kloop_kring_dump(const char *title, const struct netmap_kring *kring)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2018-12-12 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Dec 12 17:05:47 2018
New Revision: 341993
URL: https://svnweb.freebsd.org/changeset/base/341993

Log:
  netmap: add man page for ptnet
  
  Add a man page for ptnet(4), describing the guest driver for netmap 
passthrough.
  
  Reviewed by:  bcr
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D18518

Added:
  head/share/man/man4/ptnet.4   (contents, props changed)

Added: head/share/man/man4/ptnet.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/ptnet.4 Wed Dec 12 17:05:47 2018(r341993)
@@ -0,0 +1,140 @@
+.\" Copyright (c) 2018 Vincenzo Maffione
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd December 11, 2018
+.Dt PTNET 4
+.Os
+.Sh NAME
+.Nm ptnet
+.Nd Ethernet driver for passed-through netmap ports
+.Sh SYNOPSIS
+This network driver is included in
+.Xr netmap 4 ,
+and it can be compiled into the kernel by adding the following
+line in your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device netmap"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+device driver provides direct access to host netmap ports,
+from within a Virtual Machine (VM).
+Applications running inside
+the VM can access the TX/RX rings and buffers of a netmap port
+that the hypervisor has passed-through to the VM.
+Hypervisor support for
+.Nm
+is currently available for QEMU/KVM.
+Any
+.Xr netmap 4
+port can be passed-through, including physical NICs,
+.Xr vale 4
+ports, netmap pipes, etc.
+.Pp
+The main use-case for netmap passthrough is Network Function
+Virtualization (NFV), where middlebox applications running within
+VMs may want to process very high packet rates (e.g., 1-10 millions
+packets per second or more).
+Note, however, that those applications
+must use the device in netmap mode in order to achieve such rates.
+In addition to the general advantages of netmap, the improved
+performance of
+.Nm
+when compared to hypervisor device emulation or paravirtualization (e.g.,
+.Xr vtnet 4 ,
+.Xr vmx 4 )
+comes from the hypervisor being completely bypassed in the data-path.
+For example, when using
+.Xr vtnet 4
+the VM has to convert each
+.Xr mbuf 9
+to a VirtIO-specific packet representation
+and publish that to a VirtIO queue; on the hypervisor side, the
+packet is extracted from the VirtIO queue and converted to a
+hypervisor-specific packet representation.
+The overhead of format conversions (and packet copies, in same cases) is not
+incured by
+.Nm
+in netmap mode, because mbufs are not used at all, and the packet format
+is the one defined by netmap (e.g.,
+.Ar struct netmap_slot )
+along the whole data-path.
+No format conversions or copies happen.
+.Pp
+It is also possible to use a
+.Nm
+device like a regular network interface, which interacts with the
+.Fx
+network stack (i.e., not in netmap mode).
+However, in that case it is necessary to pay the cost of data copies
+between mbufs and netmap buffers, which generally results in lower
+TCP/UDP performance than
+.Xr vtnet 4
+or other paravirtualized network devices.
+If the passed-through netmap port supports the VirtIO network header,
+.Nm
+is able to use it, and support TCP/UDP checksum offload (for both transmit
+and receive), TCP segmentation offload (TSO) and TCP large receive offload
+(LRO).
+Currently,
+.Xr vale 4
+ports support the header.
+Note that the VirtIO network header is generally not used in NFV
+use-cases, because middleboxes are not endpoints of TCP/UDP connections.
+.Sh TUNABLES
+Tunables can be set at the
+.Xr loader 8
+prompt before booting the kernel 

svn commit: r341994 - head/sys/geom/mirror

2018-12-12 Thread Conrad Meyer
Author: cem
Date: Wed Dec 12 18:13:56 2018
New Revision: 341994
URL: https://svnweb.freebsd.org/changeset/base/341994

Log:
  gmirror: Remove a last-minute INVARIANTS breakage in r341840
  
  I mistakenly added a lock assertion to this routine at the last minute
  without confirming it was held during g_mirror_create.  It isn't (it isn't
  even initialized yet).  Mea culpa.  Access is exclusive in both callers,
  just not always by that particular lock.
  
  Reported by:  lwhsu
  X-MFC-With:   r341840, r341674

Modified:
  head/sys/geom/mirror/g_mirror.c

Modified: head/sys/geom/mirror/g_mirror.c
==
--- head/sys/geom/mirror/g_mirror.c Wed Dec 12 17:05:47 2018
(r341993)
+++ head/sys/geom/mirror/g_mirror.c Wed Dec 12 18:13:56 2018
(r341994)
@@ -3061,8 +3061,6 @@ g_mirror_reinit_from_metadata(struct g_mirror_softc *s
 const struct g_mirror_metadata *md)
 {
 
-   sx_assert(&sc->sc_lock, SX_XLOCKED);
-
sc->sc_genid = md->md_genid;
sc->sc_syncid = md->md_syncid;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r341996 - head/sys/conf

2018-12-12 Thread Maxim Sobolev
Author: sobomax
Date: Wed Dec 12 19:02:37 2018
New Revision: 341996
URL: https://svnweb.freebsd.org/changeset/base/341996

Log:
  Add NETGRAPH_CHECKSUM.
  
  MFC after:1 week

Modified:
  head/sys/conf/NOTES
  head/sys/conf/files

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Wed Dec 12 18:18:34 2018(r341995)
+++ head/sys/conf/NOTES Wed Dec 12 19:02:37 2018(r341996)
@@ -767,6 +767,7 @@ options NETGRAPH_BLUETOOTH_UBTBCMFW # ubtbcmfw(4)
 optionsNETGRAPH_BPF
 optionsNETGRAPH_BRIDGE
 optionsNETGRAPH_CAR
+optionsNETGRAPH_CHECKSUM
 optionsNETGRAPH_CISCO
 optionsNETGRAPH_DEFLATE
 optionsNETGRAPH_DEVICE

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Dec 12 18:18:34 2018(r341995)
+++ head/sys/conf/files Wed Dec 12 19:02:37 2018(r341996)
@@ -4212,6 +4212,7 @@ netgraph/ng_base.coptional netgraph
 netgraph/ng_bpf.c  optional netgraph_bpf
 netgraph/ng_bridge.c   optional netgraph_bridge
 netgraph/ng_car.c  optional netgraph_car
+netgraph/ng_checksum.c optional netgraph_checksum
 netgraph/ng_cisco.coptional netgraph_cisco
 netgraph/ng_deflate.c  optional netgraph_deflate
 netgraph/ng_device.c   optional netgraph_device
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r341997 - head/usr.bin/calendar/calendars

2018-12-12 Thread Shteryana Shopova
Author: syrinx
Date: Wed Dec 12 19:58:54 2018
New Revision: 341997
URL: https://svnweb.freebsd.org/changeset/base/341997

Log:
  Add myself to the calendar

Modified:
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdWed Dec 12 19:02:37 
2018(r341996)
+++ head/usr.bin/calendar/calendars/calendar.freebsdWed Dec 12 19:58:54 
2018(r341997)
@@ -425,6 +425,7 @@
 11/19  Konstantin Belousov  born in Kiev, USSR, 1972
 11/20  Dmitry Morozovsky  born in Moscow, USSR, 1968
 11/20  Gavin Atkinson  born in Middlesbrough, United 
Kingdom, 1979
+11/21  Shteryana Shopova  born in Petrich, Bulgaria, 1982
 11/21  Mark Johnston  born in Toronto, Ontario, Canada, 1989
 11/22  Frederic Culot  born in Saint-Germain-En-Laye, 
France, 1976
 11/23  Josef Lawrence Karthauser  born in Pembury, Kent, 
United Kingdom, 1972
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r341998 - head/sys/netpfil/pf

2018-12-12 Thread Kristof Provost
Author: kp
Date: Wed Dec 12 20:15:06 2018
New Revision: 341998
URL: https://svnweb.freebsd.org/changeset/base/341998

Log:
  pf: Fix endless loop on NAT exhaustion with sticky-address
  
  When we try to find a source port in pf_get_sport() it's possible that
  all available source ports will be in use. In that case we call
  pf_map_addr() to try to find a new source IP to try from. If there are
  no more available source IPs pf_map_addr() will return 1 and we stop
  trying.
  
  However, if sticky-address is set we'll always return the same IP
  address, even if we've already tried that one.
  We need to check the supplied address, because if that's the one we'd
  set it means pf_get_sport() has already tried it, and we should error
  out rather than keep trying.
  
  PR:   233867
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D18483

Modified:
  head/sys/netpfil/pf/pf.c
  head/sys/netpfil/pf/pf_lb.c

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cWed Dec 12 19:58:54 2018(r341997)
+++ head/sys/netpfil/pf/pf.cWed Dec 12 20:15:06 2018(r341998)
@@ -5513,6 +5513,8 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, 
dst.sin_len = sizeof(dst);
dst.sin_addr = ip->ip_dst;
 
+   bzero(&naddr, sizeof(naddr));
+
if (TAILQ_EMPTY(&r->rpool.list)) {
DPFPRINTF(PF_DEBUG_URGENT,
("%s: TAILQ_EMPTY(&r->rpool.list)\n", __func__));
@@ -5671,6 +5673,8 @@ pf_route6(struct mbuf **m, struct pf_rule *r, int dir,
dst.sin6_family = AF_INET6;
dst.sin6_len = sizeof(dst);
dst.sin6_addr = ip6->ip6_dst;
+
+   bzero(&naddr, sizeof(naddr));
 
if (TAILQ_EMPTY(&r->rpool.list)) {
DPFPRINTF(PF_DEBUG_URGENT,

Modified: head/sys/netpfil/pf/pf_lb.c
==
--- head/sys/netpfil/pf/pf_lb.c Wed Dec 12 19:58:54 2018(r341997)
+++ head/sys/netpfil/pf/pf_lb.c Wed Dec 12 20:15:06 2018(r341998)
@@ -328,6 +328,12 @@ pf_map_addr(sa_family_t af, struct pf_rule *r, struct 
   src node was created just a moment ago in pf_create_state and it
   needs to be filled in with routing decision calculated here. */
if (*sn != NULL && !PF_AZERO(&(*sn)->raddr, af)) {
+   /* If the supplied address is the same as the current one we've
+* been asked before, so tell the caller that there's no other
+* address to be had. */
+   if (PF_AEQ(naddr, &(*sn)->raddr, af))
+   return (1);
+
PF_ACPY(naddr, &(*sn)->raddr, af);
if (V_pf_status.debug >= PF_DEBUG_MISC) {
printf("pf_map_addr: src tracking maps ");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r341999 - head/tests/sys/netpfil/pf

2018-12-12 Thread Kristof Provost
Author: kp
Date: Wed Dec 12 20:19:18 2018
New Revision: 341999
URL: https://svnweb.freebsd.org/changeset/base/341999

Log:
  pf tests: NAT exhaustion test
  
  It's been reported that pf doesn't handle running out of available ports
  for NAT correctly. It freezes until a state expires and it can find a
  free port.
  Test for this, by setting up a situation where only two ports are
  available for NAT and then attempting to create three connections.
  
  If successful the third connection will fail immediately. In an
  incorrect case the connection attempt will freeze, also freezing all
  interaction with pf through pfctl and trigger timeout.
  
  PR:   233867
  MFC after:2 weeks

Added:
  head/tests/sys/netpfil/pf/nat.sh   (contents, props changed)
Modified:
  head/tests/sys/netpfil/pf/Makefile

Modified: head/tests/sys/netpfil/pf/Makefile
==
--- head/tests/sys/netpfil/pf/Makefile  Wed Dec 12 20:15:06 2018
(r341998)
+++ head/tests/sys/netpfil/pf/Makefile  Wed Dec 12 20:19:18 2018
(r341999)
@@ -10,6 +10,7 @@ ATF_TESTS_SH+=anchor \
forward \
fragmentation \
names \
+   nat \
set_tos \
route_to \
synproxy \

Added: head/tests/sys/netpfil/pf/nat.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/netpfil/pf/nat.shWed Dec 12 20:19:18 2018
(r341999)
@@ -0,0 +1,64 @@
+# $FreeBSD$
+
+. $(atf_get_srcdir)/utils.subr
+
+atf_test_case "exhaust" "cleanup"
+exhaust_head()
+{
+   atf_set descr 'Test exhausting the NAT pool'
+   atf_set require.user root
+}
+
+exhaust_body()
+{
+   pft_init
+
+   epair_nat=$(pft_mkepair)
+   epair_echo=$(pft_mkepair)
+
+   pft_mkjail nat ${epair_nat}b ${epair_echo}a
+   pft_mkjail echo ${epair_echo}b
+
+   ifconfig ${epair_nat}a 192.0.2.2/24 up
+   route add -net 198.51.100.0/24 192.0.2.1
+
+   jexec nat ifconfig ${epair_nat}b 192.0.2.1/24 up
+   jexec nat ifconfig ${epair_echo}a 198.51.100.1/24 up
+   jexec nat sysctl net.inet.ip.forwarding=1
+
+   jexec echo ifconfig ${epair_echo}b 198.51.100.2/24 up
+   jexec echo /usr/sbin/inetd $(atf_get_srcdir)/echo_inetd.conf
+
+   # Enable pf!
+   jexec nat pfctl -e
+   pft_set_rules nat \
+   "nat pass on ${epair_echo}a inet from 192.0.2.0/24 to any -> 
(${epair_echo}a) port 3:30001 sticky-address"
+
+   # Sanity check
+   atf_check -s exit:0 -o ignore ping -c 3 198.51.100.2
+
+   echo "foo" | nc -N 198.51.100.2 7
+   echo "foo" | nc -N 198.51.100.2 7
+
+   # This one will fail, but that's expected
+   echo "foo" | nc -N 198.51.100.2 7 &
+
+   sleep 1
+
+   # If the kernel is stuck in pf_get_sport() this will not succeed either.
+   timeout 2 jexec nat pfctl -sa
+   if [ $? -eq 124 ]; then
+   # Timed out
+   atf_fail "pfctl timeout"
+   fi
+}
+
+exhaust_cleanup()
+{
+   pft_cleanup
+}
+
+atf_init_test_cases()
+{
+   atf_add_test_case "exhaust"
+}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342000 - head/tests/sys/netpfil/pf

2018-12-12 Thread Kristof Provost
Author: kp
Date: Wed Dec 12 20:19:56 2018
New Revision: 342000
URL: https://svnweb.freebsd.org/changeset/base/342000

Log:
  pf tests: Basic rdr test
  
  MFC after:2 weeks

Added:
  head/tests/sys/netpfil/pf/rdr.sh   (contents, props changed)
Modified:
  head/tests/sys/netpfil/pf/Makefile

Modified: head/tests/sys/netpfil/pf/Makefile
==
--- head/tests/sys/netpfil/pf/Makefile  Wed Dec 12 20:19:18 2018
(r341999)
+++ head/tests/sys/netpfil/pf/Makefile  Wed Dec 12 20:19:56 2018
(r342000)
@@ -12,6 +12,7 @@ ATF_TESTS_SH+=anchor \
names \
nat \
set_tos \
+   rdr \
route_to \
synproxy \
set_skip \

Added: head/tests/sys/netpfil/pf/rdr.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/netpfil/pf/rdr.shWed Dec 12 20:19:56 2018
(r342000)
@@ -0,0 +1,48 @@
+# $FreeBSD$
+
+. $(atf_get_srcdir)/utils.subr
+
+atf_test_case "basic" "cleanup"
+basic_head()
+{
+   atf_set descr 'Basic rdr test'
+   atf_set require.user root
+}
+
+basic_body()
+{
+   pft_init
+
+   epair=$(pft_mkepair)
+
+   pft_mkjail alcatraz ${epair}b
+
+   ifconfig ${epair}a 192.0.2.2/24 up
+   route add -net 198.51.100.0/24 192.0.2.1
+
+   jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up
+   jexec alcatraz sysctl net.inet.ip.forwarding=1
+
+   # Enable pf!
+   jexec alcatraz pfctl -e
+   pft_set_rules alcatraz \
+   "rdr pass on ${epair}b proto tcp from any to 198.51.100.0/24 
port 1234 -> 192.0.2.1 port 4321"
+
+   echo "foo" | jexec alcatraz nc -N -l 4321 &
+   sleep 1
+
+   result=$(nc -N -w 3 198.51.100.2 1234)
+   if [ "$result" != "foo" ]; then
+   atf_fail "Redirect failed"
+   fi
+}
+
+basic_cleanup()
+{
+   pft_cleanup
+}
+
+atf_init_test_cases()
+{
+   atf_add_test_case "basic"
+}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342001 - head/lib/libcapsicum

2018-12-12 Thread Mariusz Zaborski
Author: oshogbo
Date: Wed Dec 12 20:32:17 2018
New Revision: 342001
URL: https://svnweb.freebsd.org/changeset/base/342001

Log:
  libcapsicum: add missing links
  
  Reported by:  manu

Modified:
  head/lib/libcapsicum/Makefile

Modified: head/lib/libcapsicum/Makefile
==
--- head/lib/libcapsicum/Makefile   Wed Dec 12 20:19:56 2018
(r342000)
+++ head/lib/libcapsicum/Makefile   Wed Dec 12 20:32:17 2018
(r342001)
@@ -9,6 +9,8 @@ MAN+=   capsicum_helpers.3
 MLINKS+=capsicum_helpers.3 caph_enter.3
 MLINKS+=capsicum_helpers.3 caph_enter_casper.3
 MLINKS+=capsicum_helpers.3 caph_rights_limit.3
+MLINKS+=capsicum_helpers.3 caph_fcntls_limit.3
+MLINKS+=capsicum_helpers.3 caph_ioctls_limit.3
 MLINKS+=capsicum_helpers.3 caph_limit_stream.3
 MLINKS+=capsicum_helpers.3 caph_limit_stdin.3
 MLINKS+=capsicum_helpers.3 caph_limit_stderr.3
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342002 - head/sys/conf

2018-12-12 Thread Maxim Sobolev
Author: sobomax
Date: Wed Dec 12 20:40:01 2018
New Revision: 342002
URL: https://svnweb.freebsd.org/changeset/base/342002

Log:
  Add NETGRAPH_CHECKSUM.
  
  MFC after:1 week

Modified:
  head/sys/conf/options

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Wed Dec 12 20:32:17 2018(r342001)
+++ head/sys/conf/options   Wed Dec 12 20:40:01 2018(r342002)
@@ -504,6 +504,7 @@ NETGRAPH_BLUETOOTH_UBTBCMFW opt_netgraph.h
 NETGRAPH_BPF   opt_netgraph.h
 NETGRAPH_BRIDGEopt_netgraph.h
 NETGRAPH_CAR   opt_netgraph.h
+NETGRAPH_CHECKSUM  opt_netgraph.h
 NETGRAPH_CISCO opt_netgraph.h
 NETGRAPH_DEFLATE   opt_netgraph.h
 NETGRAPH_DEVICEopt_netgraph.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342003 - in head: share/man/man9 sys/conf sys/dev/pwm sys/sys usr.sbin usr.sbin/pwm

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 20:56:56 2018
New Revision: 342003
URL: https://svnweb.freebsd.org/changeset/base/342003

Log:
  Add a pwm subsystem so we can configure pwm controller from kernel and 
userland.
  
  The pwm subsystem consist of API for PWM controllers, pwmbus to register them
  and a pwm(8) utility to talk to them from userland.
  
  Reviewed by:  oshgobo (capsicum), bcr (manpage), 0mp (manpage)
  Differential Revision:https://reviews.freebsd.org/D17938

Added:
  head/share/man/man9/pwm.9   (contents, props changed)
  head/share/man/man9/pwmbus.9   (contents, props changed)
  head/sys/dev/pwm/
  head/sys/dev/pwm/ofw_pwm.c   (contents, props changed)
  head/sys/dev/pwm/pwm_if.m   (contents, props changed)
  head/sys/dev/pwm/pwmbus.c   (contents, props changed)
  head/sys/dev/pwm/pwmbus.h   (contents, props changed)
  head/sys/dev/pwm/pwmbus_if.m   (contents, props changed)
  head/sys/dev/pwm/pwmc.c   (contents, props changed)
  head/sys/sys/pwm.h   (contents, props changed)
  head/usr.sbin/pwm/
  head/usr.sbin/pwm/Makefile   (contents, props changed)
  head/usr.sbin/pwm/pwm.8   (contents, props changed)
  head/usr.sbin/pwm/pwm.c   (contents, props changed)
Modified:
  head/share/man/man9/Makefile
  head/sys/conf/files
  head/usr.sbin/Makefile

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileWed Dec 12 20:40:01 2018
(r342002)
+++ head/share/man/man9/MakefileWed Dec 12 20:56:56 2018
(r342003)
@@ -269,6 +269,8 @@ MAN=accept_filter.9 \
proc_rwmem.9 \
pseudofs.9 \
psignal.9 \
+   pwm.9 \
+   pwmbus.9 \
random.9 \
random_harvest.9 \
ratecheck.9 \

Added: head/share/man/man9/pwm.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/pwm.9   Wed Dec 12 20:56:56 2018(r342003)
@@ -0,0 +1,93 @@
+.\" Copyright (c) 2018 Emmanuel Vadot 
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd November 12, 2018
+.Dt PWM 9
+.Os
+.Sh NAME
+.Nm pwm ,
+.Nm PWM_GET_BUS ,
+.Nm PWM_CHANNEL_CONFIG ,
+.Nm PWM_CHANNEL_GET_CONFIG ,
+.Nm PWM_CHANNEL_SET_FLAGS ,
+.Nm PWM_CHANNEL_GET_FLAGS ,
+.Nm PWM_CHANNEL_ENABLE ,
+.Nm PWM_CHANNEL_IS_ENABLED ,
+.Nm PWM_CHANNEL_MAX
+.Nd PWM methods
+.Sh SYNOPSIS
+.Cd "device pwm"
+.In "pwm_if.h"
+.Ft device_t
+.Fn PWM_GET_BUS "device_t dev"
+.Ft int
+.Fn PWM_CHANNEL_CONFIG "device_t dev" "int channel" "uint64_t period" 
"uint64_t duty"
+.Ft int
+.Fn PWM_CHANNEL_GET_CONFIG "device_t dev" "int channel" "uint64_t *period" 
"uint64_t *duty"
+.Ft int
+.Fn PWM_CHANNEL_SET_FLAGS "device_t dev" "int channel" "uint32_t flags"
+.Ft int
+.Fn PWM_CHANNEL_GET_FLAGS "device_t dev" "int channel" "uint32_t *flags"
+.Ft int
+.Fn PWM_CHANNEL_ENABLE "device_t dev" "int channel" "bool enable"
+.Ft int
+.Fn PWM_CHANNEL_IS_ENABLED "device_t dev" "int channel" "bool *enabled"
+.Ft int
+.Fn PWM_CHANNEL_MAX "device_t dev" "int channel" "int *nchannel"
+.Sh DESCRIPTION
+The PWM (Pulse-Width Modulation) interface allows the device driver to 
register to a global
+bus so other devices in the kernel can use them in a generic way.
+.Sh INTERFACE
+.Bl -tag -width indent
+.It Fn PWM_GET_BUS "device_t dev"
+Return the bus device.
+.It Fn PWM_CHANNEL_CONFIG "device_t dev" "int channel" "uint64_t period" 
"uint64_t duty"
+Configure the period and duty (in nanoseconds) in the PWM controller for the 
specified channel.
+Returns 0 on success or
+.Er EINVAL
+if the values are not supported by the controller or
+.Er EBUSY
+is the PWM controller is in u

svn commit: r342004 - in head/sys: arm/allwinner arm64/conf conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 20:58:43 2018
New Revision: 342004
URL: https://svnweb.freebsd.org/changeset/base/342004

Log:
  arm64: allwinner: Add pwm driver
  
  Add a pwm driver for Allwinner PWM
  Add pwm and aw_pwm to the GENERIC kernel

Added:
  head/sys/arm/allwinner/aw_pwm.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Added: head/sys/arm/allwinner/aw_pwm.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/allwinner/aw_pwm.c Wed Dec 12 20:58:43 2018
(r342004)
@@ -0,0 +1,340 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Emmanuel Vadot 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include "pwm_if.h"
+
+#defineAW_PWM_CTRL 0x00
+#define AW_PWM_CTRL_PRESCALE_MASK  0xF
+#define AW_PWM_CTRL_EN (1 << 4)
+#define AW_PWM_CTRL_ACTIVE_LEVEL_HIGH  (1 << 5)
+#define AW_PWM_CTRL_GATE   (1 << 6)
+#define AW_PWM_CTRL_MODE_MASK  0x80
+#define AW_PWM_CTRL_PULSE_MODE (1 << 7)
+#define AW_PWM_CTRL_CYCLE_MODE (0 << 7)
+#define AW_PWM_CTRL_PULSE_START(1 << 8)
+#define AW_PWM_CTRL_CLK_BYPASS (1 << 9)
+#define AW_PWM_CTRL_PERIOD_BUSY(1 << 28)
+
+#defineAW_PWM_PERIOD   0x04
+#defineAW_PWM_PERIOD_TOTAL_MASK0x
+#defineAW_PWM_PERIOD_TOTAL_SHIFT   16
+#defineAW_PWM_PERIOD_ACTIVE_MASK   0x
+#defineAW_PWM_PERIOD_ACTIVE_SHIFT  0
+
+#defineAW_PWM_MAX_FREQ 2400
+
+#defineNS_PER_SEC  10
+
+static struct ofw_compat_data compat_data[] = {
+   { "allwinner,sun5i-a13-pwm",1 },
+   { NULL, 0 }
+};
+
+static struct resource_spec aw_pwm_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
+   { -1, 0 }
+};
+
+struct aw_pwm_softc {
+   device_tdev;
+   device_tbusdev;
+   clk_t   clk;
+   struct resource *res;
+
+   uint64_tclk_freq;
+   uint64_tperiod;
+   uint64_tduty;
+   uint32_tflags;
+   boolenabled;
+};
+
+static uint32_t aw_pwm_clk_prescaler[] = {
+   120,
+   180,
+   240,
+   360,
+   480,
+   0,
+   0,
+   0,
+   12000,
+   24000,
+   36000,
+   48000,
+   72000,
+   0,
+   0,
+   1,
+};
+
+#defineAW_PWM_READ(sc, reg)bus_read_4((sc)->res, (reg))
+#defineAW_PWM_WRITE(sc, reg, val)  bus_write_4((sc)->res, (reg), 
(val))
+
+static int aw_pwm_probe(device_t dev);
+static int aw_pwm_attach(device_t dev);
+static int aw_pwm_detach(device_t dev);
+
+static int
+aw_pwm_probe(device_t dev)
+{
+   if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+
+   if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
+   return (ENXIO);
+
+   device_set_desc(dev, "Allwinner PWM");
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+aw_pwm_attach(device_t dev)
+{
+   struct aw_pwm_softc *sc;
+   /* uint32_t reg; */
+   int error;
+
+   sc = device_get_softc(dev);
+   sc->dev = dev;
+
+   error = clk_get_by_ofw_index(dev, 0, 0, &sc->clk);
+   if (error != 0) {
+   device_prin

svn commit: r342005 - in head/sys: dts/arm64/overlays modules/dtb/allwinner

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 21:02:22 2018
New Revision: 342005
URL: https://svnweb.freebsd.org/changeset/base/342005

Log:
  arm64: allwinner: Add DTSO for pwm and r_pwm
  
  Those are both dtso (overlays) for the two pwm controllers found on the A64.

Added:
  head/sys/dts/arm64/overlays/sun50i-a64-pwm.dtso   (contents, props changed)
  head/sys/dts/arm64/overlays/sun50i-a64-rpwm.dtso   (contents, props changed)
Modified:
  head/sys/modules/dtb/allwinner/Makefile

Added: head/sys/dts/arm64/overlays/sun50i-a64-pwm.dtso
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dts/arm64/overlays/sun50i-a64-pwm.dtso Wed Dec 12 21:02:22 
2018(r342005)
@@ -0,0 +1,52 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+   compatible = "allwinner,sun50i-a64";
+};
+
+&{/soc} {
+   pwm: pwm@1c21400 {
+   compatible = "allwinner,sun50i-a64-pwm",
+"allwinner,sun5i-a13-pwm";
+   reg = <0x01c21400 0x400>;
+   clocks = <&osc24M>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pwm_pin>;
+   #pwm-cells = <3>;
+   status = "disabled";
+   };
+};
+
+&{/soc/pinctrl@1c20800} {
+   pwm_pin: pwm_pin {
+   pins = "PD22";
+   function = "pwm";
+   };
+};
+/dts-v1/;
+/plugin/;
+
+/ {
+   compatible = "allwinner,sun50i-a64";
+};
+
+&{/soc} {
+   pwm: pwm@1c21400 {
+   compatible = "allwinner,sun50i-a64-pwm",
+"allwinner,sun5i-a13-pwm";
+   reg = <0x01c21400 0x400>;
+   clocks = <&osc24M>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pwm_pin>;
+   #pwm-cells = <3>;
+   status = "disabled";
+   };
+};
+
+&{/soc/pinctrl@1c20800} {
+   pwm_pin: pwm_pin {
+   pins = "PD22";
+   function = "pwm";
+   };
+};

Added: head/sys/dts/arm64/overlays/sun50i-a64-rpwm.dtso
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dts/arm64/overlays/sun50i-a64-rpwm.dtsoWed Dec 12 21:02:22 
2018(r342005)
@@ -0,0 +1,52 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+   compatible = "allwinner,sun50i-a64";
+};
+
+&{/soc} {
+   r_pwm: pwm@1f03800 {
+   compatible = "allwinner,sun50i-a64-pwm",
+"allwinner,sun5i-a13-pwm";
+   reg = <0x01f03800 0x400>;
+   clocks = <&osc24M>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&r_pwm_pin>;
+   #pwm-cells = <3>;
+   status = "okay";
+   };
+};
+
+&{/soc/pinctrl@1f02c00} {
+   r_pwm_pin: pwm {
+   pins = "PL10";
+   function = "s_pwm";
+   };
+};
+/dts-v1/;
+/plugin/;
+
+/ {
+   compatible = "allwinner,sun50i-a64";
+};
+
+&{/soc} {
+   r_pwm: pwm@1f03800 {
+   compatible = "allwinner,sun50i-a64-pwm",
+"allwinner,sun5i-a13-pwm";
+   reg = <0x01f03800 0x400>;
+   clocks = <&osc24M>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&r_pwm_pin>;
+   #pwm-cells = <3>;
+   status = "okay";
+   };
+};
+
+&{/soc/pinctrl@1f02c00} {
+   r_pwm_pin: pwm {
+   pins = "PL10";
+   function = "s_pwm";
+   };
+};

Modified: head/sys/modules/dtb/allwinner/Makefile
==
--- head/sys/modules/dtb/allwinner/Makefile Wed Dec 12 20:58:43 2018
(r342004)
+++ head/sys/modules/dtb/allwinner/Makefile Wed Dec 12 21:02:22 2018
(r342005)
@@ -45,6 +45,8 @@ DTS=  \
allwinner/sun50i-h5-orangepi-pc2.dts
 
 DTSO=  sun50i-a64-opp.dtso \
+   sun50i-a64-pwm.dtso \
+   sun50i-a64-rpwm.dtso \
sun50i-a64-sid.dtso \
sun50i-a64-ths.dtso \
sun50i-a64-timer.dtso
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342006 - head/sys/dts/arm64/overlays

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 21:10:34 2018
New Revision: 342006
URL: https://svnweb.freebsd.org/changeset/base/342006

Log:
  arm64: allwinner: Fix pwm dtso
  
  Double patched files ended up in the tree
  
  Reported by:  kevans

Modified:
  head/sys/dts/arm64/overlays/sun50i-a64-pwm.dtso
  head/sys/dts/arm64/overlays/sun50i-a64-rpwm.dtso

Modified: head/sys/dts/arm64/overlays/sun50i-a64-pwm.dtso
==
--- head/sys/dts/arm64/overlays/sun50i-a64-pwm.dtso Wed Dec 12 21:02:22 
2018(r342005)
+++ head/sys/dts/arm64/overlays/sun50i-a64-pwm.dtso Wed Dec 12 21:10:34 
2018(r342006)
@@ -24,29 +24,3 @@
function = "pwm";
};
 };
-/dts-v1/;
-/plugin/;
-
-/ {
-   compatible = "allwinner,sun50i-a64";
-};
-
-&{/soc} {
-   pwm: pwm@1c21400 {
-   compatible = "allwinner,sun50i-a64-pwm",
-"allwinner,sun5i-a13-pwm";
-   reg = <0x01c21400 0x400>;
-   clocks = <&osc24M>;
-   pinctrl-names = "default";
-   pinctrl-0 = <&pwm_pin>;
-   #pwm-cells = <3>;
-   status = "disabled";
-   };
-};
-
-&{/soc/pinctrl@1c20800} {
-   pwm_pin: pwm_pin {
-   pins = "PD22";
-   function = "pwm";
-   };
-};

Modified: head/sys/dts/arm64/overlays/sun50i-a64-rpwm.dtso
==
--- head/sys/dts/arm64/overlays/sun50i-a64-rpwm.dtsoWed Dec 12 21:02:22 
2018(r342005)
+++ head/sys/dts/arm64/overlays/sun50i-a64-rpwm.dtsoWed Dec 12 21:10:34 
2018(r342006)
@@ -24,29 +24,3 @@
function = "s_pwm";
};
 };
-/dts-v1/;
-/plugin/;
-
-/ {
-   compatible = "allwinner,sun50i-a64";
-};
-
-&{/soc} {
-   r_pwm: pwm@1f03800 {
-   compatible = "allwinner,sun50i-a64-pwm",
-"allwinner,sun5i-a13-pwm";
-   reg = <0x01f03800 0x400>;
-   clocks = <&osc24M>;
-   pinctrl-names = "default";
-   pinctrl-0 = <&r_pwm_pin>;
-   #pwm-cells = <3>;
-   status = "okay";
-   };
-};
-
-&{/soc/pinctrl@1f02c00} {
-   r_pwm_pin: pwm {
-   pins = "PL10";
-   function = "s_pwm";
-   };
-};
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342007 - head/usr.sbin/pwm

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 21:25:52 2018
New Revision: 342007
URL: https://svnweb.freebsd.org/changeset/base/342007

Log:
  pwm: Fix some arches by using %ju and casting to uintmax_t
  
  Reported by:  ci.freebsd.org

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

Modified: head/usr.sbin/pwm/pwm.c
==
--- head/usr.sbin/pwm/pwm.c Wed Dec 12 21:10:34 2018(r342006)
+++ head/usr.sbin/pwm/pwm.c Wed Dec 12 21:25:52 2018(r342007)
@@ -190,9 +190,9 @@ main(int argc, char *argv[])
}
break;
case PWM_SHOW_CONFIG:
-   printf("period: %lu\nduty: %lu\nenabled:%d\n",
-   state.period,
-   state.duty,
+   printf("period: %ju\nduty: %ju\nenabled:%d\n",
+   (uintmax_t) state.period,
+   (uintmax_t) state.duty,
state.enable);
break;
case PWM_PERIOD:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342010 - in head/sys: arm64/conf conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 21:58:30 2018
New Revision: 342010
URL: https://svnweb.freebsd.org/changeset/base/342010

Log:
  arm64: Add new SoC type MARVELL_8K
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/options.arm64

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Wed Dec 12 21:56:47 2018(r342009)
+++ head/sys/arm64/conf/GENERIC Wed Dec 12 21:58:30 2018(r342010)
@@ -107,6 +107,7 @@ options SOC_ALLWINNER_H5
 optionsSOC_CAVM_THUNDERX
 optionsSOC_HISI_HI6220
 optionsSOC_BRCM_BCM2837
+optionsSOC_MARVELL_8K
 optionsSOC_ROCKCHIP_RK3328
 optionsSOC_ROCKCHIP_RK3399
 optionsSOC_XILINX_ZYNQ

Modified: head/sys/conf/options.arm64
==
--- head/sys/conf/options.arm64 Wed Dec 12 21:56:47 2018(r342009)
+++ head/sys/conf/options.arm64 Wed Dec 12 21:58:30 2018(r342010)
@@ -19,6 +19,7 @@ SOC_ALLWINNER_H5  opt_soc.h
 SOC_BRCM_BCM2837   opt_soc.h
 SOC_CAVM_THUNDERX  opt_soc.h
 SOC_HISI_HI6220opt_soc.h
+SOC_MARVELL_8K opt_soc.h
 SOC_ROCKCHIP_RK3328opt_soc.h
 SOC_ROCKCHIP_RK3399opt_soc.h
 SOC_XILINX_ZYNQopt_soc.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342011 - in head/sys: arm/mv arm64/conf conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:00:05 2018
New Revision: 342011
URL: https://svnweb.freebsd.org/changeset/base/342011

Log:
  arm64: mvebu_pinctrl: Add driver for Marvell Pinmux Controller
  
  Add a driver compatible with Marvell mvebu-pinctrl and add ap806-pinctrl
  support.
  
  Sponsored by: Rubicon Communications, LCC ("Netgate")

Added:
  head/sys/arm/mv/mvebu_pinctrl.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Added: head/sys/arm/mv/mvebu_pinctrl.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/mvebu_pinctrl.c Wed Dec 12 22:00:05 2018
(r342011)
@@ -0,0 +1,246 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "opt_soc.h"
+
+#definePINS_PER_REG8
+#defineBITS_PER_PIN4
+#definePINS_MASK   0xf
+#defineMAX_PIN_FUNC5
+
+struct mv_pins {
+   const char  *name;
+   const char  *functions[MAX_PIN_FUNC];
+};
+
+struct mv_padconf {
+   const struct mv_pins*pins;
+   size_t  npins;
+};
+
+#ifdef SOC_MARVELL_8K
+const static struct mv_pins ap806_pins[] = {
+   {"mpp0", {"gpio", "sdio", NULL, "spi0"}},
+   {"mpp1", {"gpio", "sdio", NULL, "spi0"}},
+   {"mpp2", {"gpio", "sdio", NULL, "spi0"}},
+   {"mpp3", {"gpio", "sdio", NULL, "spi0"}},
+   {"mpp4", {"gpio", "sdio", NULL, "i2c0"}},
+   {"mpp5", {"gpio", "sdio", NULL, "i2c0"}},
+   {"mpp6", {"gpio", "sdio", NULL, NULL}},
+   {"mpp7", {"gpio", "sdio", NULL, "uart1"}},
+   {"mpp8", {"gpio", "sdio", NULL, "uart1"}},
+   {"mpp9", {"gpio", "sdio", NULL, "spi0"}},
+   {"mpp10", {"gpio", "sdio", NULL, NULL}},
+   {"mpp11", {"gpio", NULL, NULL, "uart0"}},
+   {"mpp12", {"gpio", "sdio", "sdio", NULL}},
+   {"mpp13", {"gpio", NULL, NULL}},
+   {"mpp14", {"gpio", NULL, NULL}},
+   {"mpp15", {"gpio", NULL, NULL}},
+   {"mpp16", {"gpio", NULL, NULL}},
+   {"mpp17", {"gpio", NULL, NULL}},
+   {"mpp18", {"gpio", NULL, NULL}},
+   {"mpp19", {"gpio", NULL, NULL, "uart0", "sdio"}},
+};
+
+const struct mv_padconf ap806_padconf = {
+   .npins = nitems(ap806_pins),
+   .pins = ap806_pins,
+};
+#endif
+
+struct mv_pinctrl_softc {
+   device_tdev;
+   struct resource *res;
+
+   struct mv_padconf   *padconf;
+};
+
+static struct resource_spec mv_pinctrl_res_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE | RF_SHAREABLE },
+   { -1, 0 }
+};
+
+static struct ofw_compat_data compat_data[] = {
+#ifdef SOC_MARVELL_8K
+   {"marvell,ap806-pinctrl", (uintptr_t)&ap806_padconf},
+#endif
+   {NULL, 0}
+};
+
+#defineRD4(sc, reg)bus_read_4((sc)->res, (reg))
+#defineWR4(sc, reg, val)   bus_write_4((sc)->res, (reg), (val))
+
+static void
+mv_pinctrl_configure_pin(struct mv_pinctrl_softc *sc, uint32_t pin,
+uint32_t function)
+{
+   uint32_t offset, shift, reg;
+
+   offset = (pin / PINS_PER_REG) * BITS_PER_PIN;
+   shift = (pin % PINS_PER_REG) * BITS_PER_PIN;
+   reg = RD4(sc, offset);
+   reg &= ~(PINS_MASK << shift);
+   reg |= function << shift;
+   WR4(sc, offset, reg);
+}
+
+static int
+mv_pinctrl_configur

svn commit: r342008 - in head/sys: conf dev/fdt

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 21:56:45 2018
New Revision: 342008
URL: https://svnweb.freebsd.org/changeset/base/342008

Log:
  fdt: Add support for simple-mfd bus
  
  Quoting the binding Documentation :
  
  "These devices comprise a nexus for heterogeneous hardware blocks containing
  more than one non-unique yet varying hardware functionality."
  
  Reviewed by:  loos
  Sponsored by: Rubicon Communications, LLC ("Netgate")
  Differential Revision:https://reviews.freebsd.org/D17751

Added:
  head/sys/dev/fdt/simple_mfd.c   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/fdt/simplebus.c
  head/sys/dev/fdt/simplebus.h

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Dec 12 21:25:52 2018(r342007)
+++ head/sys/conf/files Wed Dec 12 21:56:45 2018(r342008)
@@ -1762,6 +1762,7 @@ dev/fdt/fdt_slicer.c  optional fdt cfi | fdt 
nand | fd
 dev/fdt/fdt_static_dtb.S   optional fdt fdt_dtb_static \
dependency  "fdt_dtb_file"
 dev/fdt/simplebus.coptional fdt
+dev/fdt/simple_mfd.c   optional fdt
 dev/fe/if_fe.c optional fe
 dev/fe/if_fe_pccard.c  optional fe pccard
 dev/filemon/filemon.c  optional filemon

Added: head/sys/dev/fdt/simple_mfd.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/fdt/simple_mfd.c   Wed Dec 12 21:56:45 2018
(r342008)
@@ -0,0 +1,176 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+#include 
+
+struct simple_mfd_softc {
+   struct simplebus_softc  sc;
+};
+
+device_t simple_mfd_add_device(device_t dev, phandle_t node, u_int order,
+const char *name, int unit, struct simplebus_devinfo *di);
+struct simplebus_devinfo *simple_mfd_setup_dinfo(device_t dev, phandle_t node, 
struct simplebus_devinfo *di);
+
+static int
+simple_mfd_probe(device_t dev)
+{
+
+   if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+   if (!ofw_bus_is_compatible(dev, "simple-mfd"))
+   return (ENXIO);
+
+   device_set_desc(dev, "Simple MFD (Multi-Functions Device)");
+
+   return (BUS_PROBE_GENERIC);
+}
+
+static int
+simple_mfd_attach(device_t dev)
+{
+   struct simple_mfd_softc *sc;
+   phandle_t node, child;
+   device_t cdev;
+
+   sc = device_get_softc(dev);
+   node = ofw_bus_get_node(dev);
+
+   /* Parse address-cells and size-cells from the parent node as a 
fallback */
+   if (OF_getencprop(node, "#address-cells", &sc->sc.acells,
+   sizeof(sc->sc.acells)) == -1) {
+   if (OF_getencprop(OF_parent(node), "#address-cells", 
&sc->sc.acells,
+   sizeof(sc->sc.acells)) == -1) {
+   sc->sc.acells = 2;
+   }
+   }
+   if (OF_getencprop(node, "#size-cells", &sc->sc.scells,
+   sizeof(sc->sc.scells)) == -1) {
+   if (OF_getencprop(OF_parent(node), "#size-cells", 
&sc->sc.scells,
+   sizeof(sc->sc.scells)) == -1) {
+   sc->sc.scells = 1;
+   }
+   }
+
+   /* If the node has a ranges prop, parse it so children mapping will be 
done correctly */
+   if (OF_hasprop(node, "ranges")) {
+   if (simplebus_fill_ranges(node, &sc->sc) < 0) {
+   

svn commit: r342012 - in head/sys: arm/mv conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:01:06 2018
New Revision: 342012
URL: https://svnweb.freebsd.org/changeset/base/342012

Log:
  arm64: marvell: Add driver for Marvell Ap806 System Controller
  
  The first two clocks are for the clusters and their frequencies can be
  found reading a register. Then a fixed 1200Mhz clock is present and two
  fixed clocks, 'mss' which is 1200 / 6 and 'sdio' which is 1200 / 3.
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Added:
  head/sys/arm/mv/mv_ap806_clock.c   (contents, props changed)
Modified:
  head/sys/conf/files.arm64

Added: head/sys/arm/mv/mv_ap806_clock.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/mv_ap806_clock.cWed Dec 12 22:01:06 2018
(r342012)
@@ -0,0 +1,210 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+
+static struct clk_fixed_def ap806_clk_cluster_0 = {
+   .clkdef.id = 0,
+   .clkdef.name = "ap806-cpu-cluster-0",
+   .freq = 0,
+};
+
+static struct clk_fixed_def ap806_clk_cluster_1 = {
+   .clkdef.id = 1,
+   .clkdef.name = "ap806-cpu-cluster-1",
+   .freq = 0,
+};
+
+static struct clk_fixed_def ap806_clk_fixed = {
+   .clkdef.id = 2,
+   .clkdef.name = "ap806-fixed",
+   .freq = 12,
+};
+
+/* Thoses are the only exported clocks AFAICT */
+
+static const char *mss_parents[] = {"ap806-fixed"};
+static struct clk_fixed_def ap806_clk_mss = {
+   .clkdef.id = 3,
+   .clkdef.name = "ap806-mss",
+   .clkdef.parent_names = mss_parents,
+   .clkdef.parent_cnt = 1,
+   .mult = 1,
+   .div = 6,
+};
+
+static const char *sdio_parents[] = {"ap806-fixed"};
+static struct clk_fixed_def ap806_clk_sdio = {
+   .clkdef.id = 4,
+   .clkdef.name = "ap806-sdio",
+   .clkdef.parent_names = sdio_parents,
+   .clkdef.parent_cnt = 1,
+   .mult = 1,
+   .div = 3,
+};
+
+struct mv_ap806_clock_softc {
+   struct simplebus_softc  simplebus_sc;
+   device_tdev;
+   struct resource *res;
+};
+
+static struct resource_spec mv_ap806_clock_res_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE | RF_SHAREABLE },
+   { -1, 0 }
+};
+
+static struct ofw_compat_data compat_data[] = {
+   {"marvell,ap806-clock", 1},
+   {NULL, 0}
+};
+
+#defineRD4(sc, reg)bus_read_4((sc)->res, (reg))
+#defineWR4(sc, reg, val)   bus_write_4((sc)->res, (reg), (val))
+
+static int
+mv_ap806_clock_probe(device_t dev)
+{
+
+   if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+
+   if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+   return (ENXIO);
+
+   device_set_desc(dev, "Marvell AP806 Clock Controller");
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+mv_ap806_clock_attach(device_t dev)
+{
+   struct mv_ap806_clock_softc *sc;
+   struct clkdom *clkdom;
+   uint64_t clock_freq;
+   uint32_t reg;
+
+   sc = device_get_softc(dev);
+   sc->dev = dev;
+
+   if (bus_alloc_resources(dev, mv_ap806_clock_res_spec, &sc->res) != 0) {
+   device_printf(dev, "cannot allocate resources for device\n");
+   return (ENXIO);
+   }
+
+   /* 
+* We might miss some combinations

svn commit: r342009 - head/secure/lib/libcrypto

2018-12-12 Thread Jung-uk Kim
Author: jkim
Date: Wed Dec 12 21:56:47 2018
New Revision: 342009
URL: https://svnweb.freebsd.org/changeset/base/342009

Log:
  Enable devcryptoeng for OpenSSL.
  
  Since OpenSSL 1.1.1, the good old BSD-specific cryptodev engine has been
  deprecated in favor of this new engine.  However, this engine is not
  throughly tested on FreeBSD because it was originally written for Linux.
  
  http://cryptodev-linux.org/
  
  Also, the author actually meant to enable it by default on BSD platforms but
  he failed to do so because there was a bug in the Configure script.
  
  https://github.com/openssl/openssl/pull/7882
  
  Now they found that it was more generic issue.
  
  https://github.com/openssl/openssl/pull/7885
  
  Therefore, we need to enable this engine on head to give it more exposure.

Modified:
  head/secure/lib/libcrypto/Makefile
  head/secure/lib/libcrypto/opensslconf.h.in

Modified: head/secure/lib/libcrypto/Makefile
==
--- head/secure/lib/libcrypto/Makefile  Wed Dec 12 21:56:45 2018
(r342008)
+++ head/secure/lib/libcrypto/Makefile  Wed Dec 12 21:56:47 2018
(r342009)
@@ -192,8 +192,8 @@ SRCS+=  ecp_nistz256-x86.S ecp_nistz256.c
 .endif
 
 # engine
-SRCS+= eng_all.c eng_cnf.c eng_ctrl.c eng_dyn.c eng_err.c eng_fat.c
-SRCS+= eng_init.c eng_lib.c eng_list.c eng_openssl.c eng_pkey.c
+SRCS+= eng_all.c eng_cnf.c eng_ctrl.c eng_devcrypto.c eng_dyn.c eng_err.c
+SRCS+= eng_fat.c eng_init.c eng_lib.c eng_list.c eng_openssl.c eng_pkey.c
 SRCS+= eng_rdrand.c eng_table.c tb_asnmth.c tb_cipher.c tb_dh.c tb_digest.c
 SRCS+= tb_dsa.c tb_eckey.c tb_pkmeth.c tb_rand.c tb_rsa.c
 

Modified: head/secure/lib/libcrypto/opensslconf.h.in
==
--- head/secure/lib/libcrypto/opensslconf.h.in  Wed Dec 12 21:56:45 2018
(r342008)
+++ head/secure/lib/libcrypto/opensslconf.h.in  Wed Dec 12 21:56:47 2018
(r342009)
@@ -46,9 +46,6 @@ extern "C" {
 #ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
 # define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
 #endif
-#ifndef OPENSSL_NO_DEVCRYPTOENG
-# define OPENSSL_NO_DEVCRYPTOENG
-#endif
 #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
 # define OPENSSL_NO_EC_NISTP_64_GCC_128
 #endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342013 - in head/sys: arm/mv arm64/conf conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:02:57 2018
New Revision: 342013
URL: https://svnweb.freebsd.org/changeset/base/342013

Log:
  arm64: mv_gpio: Add Marvell 8K support
  
  While here put the interrupts setup in it's own function
  
  Sponsored by: Rubicon Communications, LCC ("Netgate")

Modified:
  head/sys/arm/mv/gpio.c
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Modified: head/sys/arm/mv/gpio.c
==
--- head/sys/arm/mv/gpio.c  Wed Dec 12 22:01:06 2018(r342012)
+++ head/sys/arm/mv/gpio.c  Wed Dec 12 22:02:57 2018(r342013)
@@ -60,6 +60,10 @@ __FBSDID("$FreeBSD$");
 
 #include "gpio_if.h"
 
+#ifdef __aarch64__
+#include "opt_soc.h"
+#endif
+
 #define GPIO_MAX_INTR_COUNT8
 #define GPIO_PINS_PER_REG  32
 #define GPIO_GENERIC_CAP   (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | 
\
@@ -74,6 +78,7 @@ __FBSDID("$FreeBSD$");
 #define DEBOUNCE_CHECK_TICKS   ((hz / 1000) * DEBOUNCE_CHECK_MS)
 
 struct mv_gpio_softc {
+   device_tdev;
device_tsc_busdev;
struct resource *   mem_res;
int mem_rid;
@@ -83,6 +88,7 @@ struct mv_gpio_softc {
void*ih_cookie[GPIO_MAX_INTR_COUNT];
bus_space_tag_t bst;
bus_space_handle_t  bsh;
+   uint32_toffset;
struct mtx  mutex;
uint8_t pin_num;/* number of GPIO pins */
uint8_t irq_num;/* number of real IRQs occupied 
by GPIO controller */
@@ -189,9 +195,12 @@ static devclass_t mv_gpio_devclass;
 
 DRIVER_MODULE(mv_gpio, simplebus, mv_gpio_driver, mv_gpio_devclass, 0, 0);
 
-struct ofw_compat_data gpio_controllers[] = {
-   { "mrvl,gpio", (uintptr_t)true },
-   { "marvell,orion-gpio", (uintptr_t)true },
+struct ofw_compat_data compat_data[] = {
+   { "mrvl,gpio", 1 },
+   { "marvell,orion-gpio", 1 },
+#ifdef SOC_MARVELL_8K
+   { "marvell,armada-8k-gpio", 1 },
+#endif
{ NULL, 0 }
 };
 
@@ -201,7 +210,7 @@ mv_gpio_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
 
-   if (ofw_bus_search_compatible(dev, gpio_controllers)->ocd_data == 0)
+   if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
 
device_set_desc(dev, "Marvell Integrated GPIO Controller");
@@ -209,61 +218,75 @@ mv_gpio_probe(device_t dev)
 }
 
 static int
-mv_gpio_attach(device_t dev)
+mv_gpio_setup_interrupts(struct mv_gpio_softc *sc, phandle_t node)
 {
-   int i, size;
-   struct mv_gpio_softc *sc;
-   pcell_t pincnt = 0;
-   pcell_t irq_cells = 0;
phandle_t iparent;
+   pcell_t irq_cells;
+   int i, size;
 
-   sc = (struct mv_gpio_softc *)device_get_softc(dev);
-   if (sc == NULL)
-   return (ENXIO);
-
-   if (OF_getencprop(ofw_bus_get_node(dev), "pin-count", &pincnt,
-   sizeof(pcell_t)) >= 0 ||
-   OF_getencprop(ofw_bus_get_node(dev), "ngpios", &pincnt,
-   sizeof(pcell_t)) >= 0) {
-   sc->pin_num = MIN(pincnt, MV_GPIO_MAX_NPINS);
-   if (bootverbose)
-   device_printf(dev, "%d pins available\n", sc->pin_num);
-   } else {
-   device_printf(dev, "ERROR: no pin-count or ngpios entry 
found!\n");
-   return (ENXIO);
-   }
-
-   /* Assign generic capabilities to every gpio pin */
-   for(i = 0; i < sc->pin_num; i++)
-   sc->gpio_setup[i].gp_caps = GPIO_GENERIC_CAP;
-
/* Find root interrupt controller */
-   iparent = ofw_bus_find_iparent(ofw_bus_get_node(dev));
+   iparent = ofw_bus_find_iparent(node);
if (iparent == 0) {
-   device_printf(dev, "No interrupt-parrent found. "
+   device_printf(sc->dev, "No interrupt-parrent found. "
"Error in DTB\n");
return (ENXIO);
} else {
/* While at parent - store interrupt cells prop */
if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &irq_cells, sizeof(irq_cells)) == -1) {
-   device_printf(dev, "DTB: Missing #interrupt-cells "
+   device_printf(sc->dev, "DTB: Missing #interrupt-cells "
"property in interrupt parent node\n");
return (ENXIO);
}
}
 
-   size = OF_getproplen(ofw_bus_get_node(dev), "interrupts");
+   size = OF_getproplen(node, "interrupts");
if (size != -1) {
size = size / sizeof(pcell_t);
size = size / irq_cells;
sc->irq_num = size;
-   device_printf(dev, "%d IRQs available\n", sc->irq_num);
+   device_printf(sc->dev, "%d IRQs available\n",

svn commit: r342014 - in head/sys: arm/mv conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:04:21 2018
New Revision: 342014
URL: https://svnweb.freebsd.org/changeset/base/342014

Log:
  arm64: marvell: Add cp110 clock controller support
  
  The cp110 clock controller controls the clocks and gate of the CP110
  hardware block.
  
  Every clock/gate are implemented except the NAND clock.
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Added:
  head/sys/arm/mv/mv_cp110_clock.c   (contents, props changed)
  head/sys/arm/mv/mv_cp110_clock.h   (contents, props changed)
Modified:
  head/sys/conf/files.arm64

Added: head/sys/arm/mv/mv_cp110_clock.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/mv_cp110_clock.cWed Dec 12 22:04:21 2018
(r342014)
@@ -0,0 +1,375 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "clkdev_if.h"
+
+/* Clocks */
+static struct clk_fixed_def cp110_clk_pll_0 = {
+   .clkdef.id = CP110_PLL_0,
+   .freq = 10,
+};
+
+static const char *clk_parents_0[] = {"cp110-pll0-0"};
+static const char *clk_parents_1[] = {"cp110-pll0-1"};
+
+static struct clk_fixed_def cp110_clk_ppv2_core = {
+   .clkdef.id = CP110_PPV2_CORE,
+   .clkdef.parent_cnt = 1,
+   .mult = 1,
+   .div = 3,
+};
+
+static struct clk_fixed_def cp110_clk_x2core = {
+   .clkdef.id = CP110_X2CORE,
+   .clkdef.parent_cnt = 1,
+   .mult = 1,
+   .div = 2,
+};
+
+static const char *core_parents_0[] = {"cp110-x2core-0"};
+static const char *core_parents_1[] = {"cp110-x2core-1"};
+
+static struct clk_fixed_def cp110_clk_core = {
+   .clkdef.id = CP110_CORE,
+   .clkdef.parent_cnt = 1,
+   .mult = 1,
+   .div = 2,
+};
+
+static struct clk_fixed_def cp110_clk_sdio = {
+   .clkdef.id = CP110_SDIO,
+   .clkdef.parent_cnt = 1,
+   .mult = 2,
+   .div = 5,
+};
+
+/* Gates */
+
+static struct cp110_gate cp110_gates[] = {
+   CCU_GATE(CP110_GATE_AUDIO, "cp110-gate-audio", 0)
+   CCU_GATE(CP110_GATE_COMM_UNIT, "cp110-gate-comm_unit", 1)
+   /* CCU_GATE(CP110_GATE_NAND, "cp110-gate-nand", 2) */
+   CCU_GATE(CP110_GATE_PPV2, "cp110-gate-ppv2", 3)
+   CCU_GATE(CP110_GATE_SDIO, "cp110-gate-sdio", 4)
+   CCU_GATE(CP110_GATE_MG, "cp110-gate-mg", 5)
+   CCU_GATE(CP110_GATE_MG_CORE, "cp110-gate-mg_core", 6)
+   CCU_GATE(CP110_GATE_XOR1, "cp110-gate-xor1", 7)
+   CCU_GATE(CP110_GATE_XOR0, "cp110-gate-xor0", 8)
+   CCU_GATE(CP110_GATE_GOP_DP, "cp110-gate-gop_dp", 9)
+   CCU_GATE(CP110_GATE_PCIE_X1_0, "cp110-gate-pcie_x10", 11)
+   CCU_GATE(CP110_GATE_PCIE_X1_1, "cp110-gate-pcie_x11", 12)
+   CCU_GATE(CP110_GATE_PCIE_X4, "cp110-gate-pcie_x4", 13)
+   CCU_GATE(CP110_GATE_PCIE_XOR, "cp110-gate-pcie_xor", 14)
+   CCU_GATE(CP110_GATE_SATA, "cp110-gate-sata", 15)
+   CCU_GATE(CP110_GATE_SATA_USB, "cp110-gate-sata_usb", 16)
+   CCU_GATE(CP110_GATE_MAIN, "cp110-gate-main", 17)
+   CCU_GATE(CP110_GATE_SDMMC_GOP, "cp110-gate-sdmmc_gop", 18)
+   CCU_GATE(CP110_GATE_SLOW_IO, "cp110-gate-slow_io", 21)
+   CCU_GATE(CP110_GATE_USB3H0, "cp110-gate-usb3h0", 22)
+   CCU_GATE(CP110_GATE_USB3H1, "cp110-gate-usb3h1", 23)
+   CCU_GATE(CP110_GATE_USB3DEV, "cp110-gate-usb3dev", 24)
+   CCU_GATE(CP110_GATE_EI

svn commit: r342015 - in head/sys: conf dev/iicbus/twsi

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:05:07 2018
New Revision: 342015
URL: https://svnweb.freebsd.org/changeset/base/342015

Log:
  twsi: Clean up marvell part and add support for Marvell 7k/8k
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Modified:
  head/sys/conf/files.arm64
  head/sys/dev/iicbus/twsi/mv_twsi.c
  head/sys/dev/iicbus/twsi/twsi.c
  head/sys/dev/iicbus/twsi/twsi.h

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Wed Dec 12 22:04:21 2018(r342014)
+++ head/sys/conf/files.arm64   Wed Dec 12 22:05:07 2018(r342015)
@@ -201,6 +201,7 @@ dev/axgbe/xgbe-dev.coptionalaxgbe
 dev/axgbe/xgbe-drv.c   optionalaxgbe
 dev/axgbe/xgbe-mdio.c  optionalaxgbe
 dev/cpufreq/cpufreq_dt.c   optionalcpufreq fdt
+dev/iicbus/twsi/mv_twsi.c  optionaltwsi fdt
 dev/iicbus/twsi/a10_twsi.c optionaltwsi fdt
 dev/iicbus/twsi/twsi.c optionaltwsi fdt
 dev/hwpmc/hwpmc_arm64.coptionalhwpmc

Modified: head/sys/dev/iicbus/twsi/mv_twsi.c
==
--- head/sys/dev/iicbus/twsi/mv_twsi.c  Wed Dec 12 22:04:21 2018
(r342014)
+++ head/sys/dev/iicbus/twsi/mv_twsi.c  Wed Dec 12 22:05:07 2018
(r342015)
@@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -98,6 +100,7 @@ static int mv_twsi_attach(device_t);
 static struct ofw_compat_data compat_data[] = {
{ "mrvl,twsi",  true },
{ "marvell,mv64xxx-i2c",true },
+   { "marvell,mv78230-i2c",true },
{ NULL, false }
 };
 
@@ -141,29 +144,27 @@ mv_twsi_probe(device_t dev)
if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
return (ENXIO);
 
-   sc->reg_data = TWSI_DATA;
-   sc->reg_slave_addr = TWSI_ADDR;
-   sc->reg_slave_ext_addr = TWSI_XADDR;
-   sc->reg_control = TWSI_CNTR;
-   sc->reg_status = TWSI_STAT;
-   sc->reg_baud_rate = TWSI_BAUD_RATE;
-   sc->reg_soft_reset = TWSI_SRST;
-
device_set_desc(dev, "Marvell Integrated I2C Bus Controller");
return (BUS_PROBE_DEFAULT);
 }
 
 #defineABSSUB(a,b) (((a) > (b)) ? (a) - (b) : (b) - (a))
 static void
-mv_twsi_cal_baud_rate(const uint32_t target, struct twsi_baud_rate *rate)
+mv_twsi_cal_baud_rate(struct twsi_softc *sc, const uint32_t target,
+struct twsi_baud_rate *rate)
 {
-   uint32_t clk, cur, diff, diff0;
+   uint64_t clk;
+   uint32_t cur, diff, diff0;
int m, n, m0, n0;
 
/* Calculate baud rate. */
m0 = n0 = 4;/* Default values on reset */
diff0 = 0x;
+#ifdef __aarch64__
+   clk_get_freq(sc->clk_core, &clk);
+#else
clk = get_tclk();
+#endif
 
for (n = 0; n < 8; n++) {
for (m = 0; m < 16; m++) {
@@ -186,17 +187,37 @@ static int
 mv_twsi_attach(device_t dev)
 {
struct twsi_softc *sc;
-   phandle_t child, iicbusnode;
-   device_t childdev;
-   struct iicbus_ivar *devi;
-   char dname[32]; /* 32 is taken from struct u_device */
-   uint32_t paddr;
-   int len, error, ret;
+#ifdef __aarch64__
+   int error;
+#endif
 
sc = device_get_softc(dev);
+   sc->dev = dev;
 
-   mv_twsi_cal_baud_rate(TWSI_BAUD_RATE_SLOW, &sc->baud_rate[IIC_SLOW]);
-   mv_twsi_cal_baud_rate(TWSI_BAUD_RATE_FAST, &sc->baud_rate[IIC_FAST]);
+#ifdef __aarch64__
+   /* Activate clock */
+   error = clk_get_by_ofw_index(dev, 0, 0, &sc->clk_core);
+   if (error != 0) {
+   device_printf(dev, "could not find core clock\n");
+   return (error);
+   }
+   error = clk_enable(sc->clk_core);
+   if (error != 0) {
+   device_printf(dev, "could not enable core clock\n");
+   return (error);
+   }
+
+   if (clk_get_by_ofw_index(dev, 0, 1, &sc->clk_reg) == 0) {
+   error = clk_enable(sc->clk_reg);
+   if (error != 0) {
+   device_printf(dev, "could not enable core clock\n");
+   return (error);
+   }
+   }
+#endif
+
+   mv_twsi_cal_baud_rate(sc, TWSI_BAUD_RATE_SLOW, 
&sc->baud_rate[IIC_SLOW]);
+   mv_twsi_cal_baud_rate(sc, TWSI_BAUD_RATE_FAST, 
&sc->baud_rate[IIC_FAST]);
if (bootverbose)
device_printf(dev, "calculated baud rates are:\n"
" %" PRIu32 " kHz (M=%d, N=%d) for slow,\n"
@@ -208,56 +229,13 @@ mv_twsi_attach(device_t dev)
sc->baud_rate[IIC_FAST].m,
sc->baud_rate[IIC_FAST].n);
 
+   sc->reg_data = TWSI_DATA;
+   sc->reg_slave_addr = TWSI_ADDR;
+   sc->reg_slave_ext_addr = TWSI_XADDR;
+   sc->reg_control = TWSI_

svn commit: r342016 - in head/sys: arm/mv arm64/conf conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:08:43 2018
New Revision: 342016
URL: https://svnweb.freebsd.org/changeset/base/342016

Log:
  arm64: Add mv_cp110_icu and mv_cp110_gicp
  
  icu is a interrupt concentrator in the CP110 block and gicp
  is a gic extension to allow interrupts in the CP block to be turned
  into GIC SPI interrupts
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Added:
  head/sys/arm/mv/mv_ap806_gicp.c   (contents, props changed)
  head/sys/arm/mv/mv_cp110_icu.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Added: head/sys/arm/mv/mv_ap806_gicp.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/mv_ap806_gicp.c Wed Dec 12 22:08:43 2018
(r342016)
@@ -0,0 +1,289 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include "pic_if.h"
+
+#defineMV_AP806_GICP_MAX_NIRQS 207
+
+struct mv_ap806_gicp_softc {
+   device_tdev;
+   device_tparent;
+   struct resource *res;
+
+   ssize_t spi_ranges_cnt;
+   uint32_t*spi_ranges;
+};
+
+static struct ofw_compat_data compat_data[] = {
+   {"marvell,ap806-gicp", 1},
+   {NULL, 0}
+};
+
+#defineRD4(sc, reg)bus_read_4((sc)->res, (reg))
+#defineWR4(sc, reg, val)   bus_write_4((sc)->res, (reg), (val))
+
+static int
+mv_ap806_gicp_probe(device_t dev)
+{
+
+   if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+
+   if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+   return (ENXIO);
+
+   device_set_desc(dev, "Marvell GICP");
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+mv_ap806_gicp_attach(device_t dev)
+{
+   struct mv_ap806_gicp_softc *sc;
+   phandle_t node, xref, intr_parent;
+
+   sc = device_get_softc(dev);
+   sc->dev = dev;
+   node = ofw_bus_get_node(dev);
+
+   /* Look for our parent */
+   if ((intr_parent = ofw_bus_find_iparent(node)) == 0) {
+   device_printf(dev, "Cannot find our parent interrupt 
controller\n");
+   return (ENXIO);
+   }
+   if ((sc->parent = OF_device_from_xref(intr_parent)) == NULL) {
+   device_printf(dev, "cannot find parent interrupt controller 
device\n");
+   return (ENXIO);
+   }
+
+   sc->spi_ranges_cnt = OF_getencprop_alloc(node, "marvell,spi-ranges",
+   (void **)&sc->spi_ranges);
+
+   xref = OF_xref_from_node(node);
+   if (intr_pic_register(dev, xref) == NULL) {
+   device_printf(dev, "Cannot register GICP\n");
+   return (ENXIO);
+   }
+
+   OF_device_register_xref(xref, dev);
+
+   return (0);
+}
+
+static int
+mv_ap806_gicp_detach(device_t dev)
+{
+
+   return (EBUSY);
+}
+
+static int
+mv_ap806_gicp_activate_intr(device_t dev, struct intr_irqsrc *isrc,
+struct resource *res, struct intr_map_data *data)
+{
+   struct mv_ap806_gicp_softc *sc;
+
+   sc = device_get_softc(dev);
+
+   return (PIC_ACTIVATE_INTR(sc->parent, isrc, res, data));
+}
+
+static void
+mv_ap806_gicp_enable_intr(device_t dev, struct intr_irqsrc *isrc)
+{
+   struct mv_ap806_gicp_softc *sc;
+
+   sc = device_

svn commit: r342018 - head/sys/arm/mv

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:10:11 2018
New Revision: 342018
URL: https://svnweb.freebsd.org/changeset/base/342018

Log:
  mv_gpio: Since it's also an interrupt controller, attach sooner
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Modified:
  head/sys/arm/mv/gpio.c

Modified: head/sys/arm/mv/gpio.c
==
--- head/sys/arm/mv/gpio.c  Wed Dec 12 22:09:35 2018(r342017)
+++ head/sys/arm/mv/gpio.c  Wed Dec 12 22:10:11 2018(r342018)
@@ -193,7 +193,8 @@ static driver_t mv_gpio_driver = {
 
 static devclass_t mv_gpio_devclass;
 
-DRIVER_MODULE(mv_gpio, simplebus, mv_gpio_driver, mv_gpio_devclass, 0, 0);
+EARLY_DRIVER_MODULE(mv_gpio, simplebus, mv_gpio_driver, mv_gpio_devclass, 0, 0,
+BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST);
 
 struct ofw_compat_data compat_data[] = {
{ "mrvl,gpio", 1 },
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342017 - head/sys/dev/sdhci

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:09:35 2018
New Revision: 342017
URL: https://svnweb.freebsd.org/changeset/base/342017

Log:
  sdhci_xenon: Add Marvell 8k compatible string
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Modified:
  head/sys/dev/sdhci/sdhci_xenon.c

Modified: head/sys/dev/sdhci/sdhci_xenon.c
==
--- head/sys/dev/sdhci/sdhci_xenon.cWed Dec 12 22:08:43 2018
(r342016)
+++ head/sys/dev/sdhci/sdhci_xenon.cWed Dec 12 22:09:35 2018
(r342017)
@@ -62,11 +62,16 @@ __FBSDID("$FreeBSD$");
 #include "sdhci_if.h"
 
 #include "opt_mmccam.h"
+#include "opt_soc.h"
 
 #defineMAX_SLOTS   6
 
 static struct ofw_compat_data compat_data[] = {
{ "marvell,armada-3700-sdhci",  1 },
+#ifdef SOC_MARVELL_8K
+   { "marvell,armada-cp110-sdhci", 1 },
+   { "marvell,armada-ap806-sdhci", 1 },
+#endif
{ NULL, 0 }
 };
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342019 - head/sys/arm/mv

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:24:30 2018
New Revision: 342019
URL: https://svnweb.freebsd.org/changeset/base/342019

Log:
  arm64: mv_cp110_icu: Fix build

Modified:
  head/sys/arm/mv/mv_cp110_icu.c

Modified: head/sys/arm/mv/mv_cp110_icu.c
==
--- head/sys/arm/mv/mv_cp110_icu.c  Wed Dec 12 22:10:11 2018
(r342018)
+++ head/sys/arm/mv/mv_cp110_icu.c  Wed Dec 12 22:24:30 2018
(r342019)
@@ -196,7 +196,7 @@ mv_cp110_icu_map_intr(device_t dev, struct intr_map_da
 
if ((reg & ICU_INT_ENABLE) == 0) {
reg |= ICU_INT_ENABLE;
-   WR4(sc, ICU_INT_CFG(daf->cells[1], reg));
+   WR4(sc, ICU_INT_CFG(daf->cells[1]), reg);
}
 
daf->cells[1] = reg & ICU_INT_MASK;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342020 - in head/sys: arm/mv arm64/conf conf

2018-12-12 Thread Emmanuel Vadot
Author: manu
Date: Wed Dec 12 22:33:05 2018
New Revision: 342020
URL: https://svnweb.freebsd.org/changeset/base/342020

Log:
  mv_thermal: Add thermal driver for AP806 and CP110 thermal sensor
  
  Sponsored by: Rubicon Communications, LLC ("Netgate")

Added:
  head/sys/arm/mv/mv_thermal.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Added: head/sys/arm/mv/mv_thermal.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/mv_thermal.cWed Dec 12 22:33:05 2018
(r342020)
@@ -0,0 +1,381 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#defineCONTROL00x00
+#define CONTROL0_TSEN_START(1 << 0)
+#define CONTROL0_TSEN_RESET(1 << 1)
+#define CONTROL0_TSEN_EN   (1 << 2)
+#define CONTROL0_CHANNEL_SHIFT 13
+#define CONTROL0_CHANNEL_MASK  0xF
+#define CONTROL0_OSR_SHIFT 24
+#define CONTROL0_OSR_MAX   3   /* OSR = 512 * 4uS = ~2mS */
+#define CONTROL0_MODE_SHIFT30
+#define CONTROL0_MODE_EXTERNAL 0x2
+#define CONTROL0_MODE_MASK 0x3
+
+#defineCONTROL10x04
+/* This doesn't seems to work */
+#defineCONTROL1_TSEN_SENS_SHIFT21
+#defineCONTROL1_TSEN_SENS_MASK 0x7
+
+#defineSTATUS  0x00
+#defineSTATUS_TEMP_MASK0x3FF
+
+enum mv_thermal_type {
+   MV_AP806 = 1,
+   MV_CP110,
+};
+
+struct mv_thermal_config {
+   enum mv_thermal_typetype;
+   int ncpus;
+   int64_t calib_mul;
+   int64_t calib_add;
+   int64_t calib_div;
+   uint32_tvalid_mask;
+   boolsigned_value;
+};
+
+struct mv_thermal_softc {
+   device_tdev;
+   struct resource *res[2];
+   struct mtx  mtx;
+
+   struct mv_thermal_config*config;
+   int cur_sensor;
+};
+
+static struct mv_thermal_config mv_ap806_config = {
+   .type = MV_AP806,
+   .ncpus = 4,
+   .calib_mul = 423,
+   .calib_add = -15,
+   .calib_div = 100,
+   .valid_mask = (1 << 16),
+   .signed_value = true,
+};
+
+static struct mv_thermal_config mv_cp110_config = {
+   .type = MV_CP110,
+   .calib_mul = 296,
+   .calib_add = 1172499100,
+   .calib_div = 420100,
+   .valid_mask = (1 << 10),
+   .signed_value = false,
+};
+
+static struct resource_spec mv_thermal_res_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
+   { SYS_RES_MEMORY,   1,  RF_ACTIVE },
+   { -1, 0 }
+};
+
+static struct ofw_compat_data compat_data[] = {
+   {"marvell,armada-ap806-thermal", (uintptr_t) &mv_ap806_config},
+   {"marvell,armada-cp110-thermal", (uintptr_t) &mv_cp110_config},
+   {NULL, 0}
+};
+
+#defineRD_STA(sc, reg) bus_read_4((sc)->res[0], (reg))
+#defineWR_STA(sc, reg, val)bus_write_4((sc)->res[0], (reg), (val))
+#defineRD_CON(sc, reg) bus_read_4((sc)->res[1], (reg))
+#defineWR_CON(sc, reg, val)bus_write_4((sc)->res[1], (reg), (val))

svn commit: r342022 - head/sys/mips/include

2018-12-12 Thread Warner Losh
Author: imp
Date: Thu Dec 13 00:42:26 2018
New Revision: 342022
URL: https://svnweb.freebsd.org/changeset/base/342022

Log:
  Correctly implemenet atomic_swap_long for mips64.
  
  MIPS64 has 64-bit longs, so use uint64_t for it, otherwise uint32_t.
  sizeof(long) == sizeof(ptr) for all platforms, so define
  atomic_swap_ptr in terms of atomic_swap_long.
  
  Submitted by: hps@

Modified:
  head/sys/mips/include/atomic.h

Modified: head/sys/mips/include/atomic.h
==
--- head/sys/mips/include/atomic.h  Wed Dec 12 22:39:17 2018
(r342021)
+++ head/sys/mips/include/atomic.h  Thu Dec 13 00:42:26 2018
(r342022)
@@ -793,6 +793,7 @@ atomic_swap_64(volatile uint64_t *ptr, const uint64_t 
 }
 #endif
 
+#ifdef __mips_n64
 static __inline unsigned long
 atomic_swap_long(volatile unsigned long *ptr, const unsigned long value)
 {
@@ -800,16 +801,16 @@ atomic_swap_long(volatile unsigned long *ptr, const un
 
retval = *ptr;
 
-   while (!atomic_fcmpset_32((volatile uint32_t *)ptr,
-   (uint32_t *)&retval, value))
+   while (!atomic_fcmpset_64((volatile uint64_t *)ptr,
+   (uint64_t *)&retval, value))
;
return (retval);
 }
-
-static __inline uintptr_t
-atomic_swap_ptr(volatile uintptr_t *ptr, const uintptr_t value)
+#else
+static __inline unsigned long
+atomic_swap_long(volatile unsigned long *ptr, const unsigned long value)
 {
-   uintptr_t retval;
+   unsigned long retval;
 
retval = *ptr;
 
@@ -818,5 +819,7 @@ atomic_swap_ptr(volatile uintptr_t *ptr, const uintptr
;
return (retval);
 }
+#endif
+#defineatomic_swap_ptr(ptr, value) atomic_swap_long((unsigned long 
*)(ptr), value)
 
 #endif /* ! _MACHINE_ATOMIC_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342024 - in head/sys: crypto/aesni opencrypto

2018-12-12 Thread Matt Macy
Author: mmacy
Date: Thu Dec 13 04:40:53 2018
New Revision: 342024
URL: https://svnweb.freebsd.org/changeset/base/342024

Log:
  Generalize AES iov optimization
  
  Right now, aesni_cipher_alloc does a bit of special-casing
  for CRYPTO_F_IOV, to not do any allocation if the first uio
  is large enough for the requested size. While working on ZFS
  crypto port, I ran into horrible performance because the code
  uses scatter-gather, and many of the times the data to encrypt
  was in the second entry. This code looks through the list, and
  tries to see if there is a single uio that can contain the
  requested data, and, if so, uses that.
  
  This has a slight impact on the current consumers, in that the
  check is a little more complicated for the ones that use
  CRYPTO_F_IOV -- but none of them meet the criteria for testing
  more than one.
  
  Submitted by: sef at ixsystems.com
  Reviewed by:  cem@
  MFC after:3 days
  Sponsored by: iX Systems
  Differential Revision:https://reviews.freebsd.org/D18522

Modified:
  head/sys/crypto/aesni/aesni.c
  head/sys/opencrypto/criov.c
  head/sys/opencrypto/cryptodev.h

Modified: head/sys/crypto/aesni/aesni.c
==
--- head/sys/crypto/aesni/aesni.c   Thu Dec 13 03:12:15 2018
(r342023)
+++ head/sys/crypto/aesni/aesni.c   Thu Dec 13 04:40:53 2018
(r342024)
@@ -403,29 +403,14 @@ static uint8_t *
 aesni_cipher_alloc(struct cryptodesc *enccrd, struct cryptop *crp,
 bool *allocated)
 {
-   struct mbuf *m;
-   struct uio *uio;
-   struct iovec *iov;
uint8_t *addr;
 
-   if (crp->crp_flags & CRYPTO_F_IMBUF) {
-   m = (struct mbuf *)crp->crp_buf;
-   if (m->m_next != NULL)
-   goto alloc;
-   addr = mtod(m, uint8_t *);
-   } else if (crp->crp_flags & CRYPTO_F_IOV) {
-   uio = (struct uio *)crp->crp_buf;
-   if (uio->uio_iovcnt != 1)
-   goto alloc;
-   iov = uio->uio_iov;
-   addr = (uint8_t *)iov->iov_base;
-   } else
-   addr = (uint8_t *)crp->crp_buf;
-   *allocated = false;
-   addr += enccrd->crd_skip;
-   return (addr);
-
-alloc:
+   addr = crypto_contiguous_subsegment(crp->crp_flags,
+   crp->crp_buf, enccrd->crd_skip, enccrd->crd_len);
+   if (addr != NULL) {
+   *allocated = false;
+   return (addr);
+   }
addr = malloc(enccrd->crd_len, M_AESNI, M_NOWAIT);
if (addr != NULL) {
*allocated = true;

Modified: head/sys/opencrypto/criov.c
==
--- head/sys/opencrypto/criov.c Thu Dec 13 03:12:15 2018(r342023)
+++ head/sys/opencrypto/criov.c Thu Dec 13 04:40:53 2018(r342024)
@@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -239,3 +241,55 @@ crypto_mbuftoiov(struct mbuf *mbuf, struct iovec **iov
*cnt = i;
return 0;
 }
+
+static inline void *
+m_contiguous_subsegment(struct mbuf *m, size_t skip, size_t len)
+{
+   int rel_off;
+
+   MPASS(skip <= INT_MAX);
+
+   m = m_getptr(m, (int)skip, &rel_off);
+   if (m == NULL)
+   return (NULL);
+
+   MPASS(rel_off >= 0);
+   skip = rel_off;
+   if (skip + len > m->m_len)
+   return (NULL);
+
+   return (mtod(m, char*) + skip);
+}
+
+static inline void *
+cuio_contiguous_segment(struct uio *uio, size_t skip, size_t len)
+{
+   int rel_off, idx;
+
+   MPASS(skip <= INT_MAX);
+   idx = cuio_getptr(uio, (int)skip, &rel_off);
+   if (idx < 0)
+   return (NULL);
+
+   MPASS(rel_off >= 0);
+   skip = rel_off;
+   if (skip + len > uio->uio_iov[idx].iov_len)
+   return (NULL);
+   return ((char *)uio->uio_iov[idx].iov_base + skip);
+}
+
+void *
+crypto_contiguous_subsegment(int crp_flags, void *crpbuf,
+size_t skip, size_t len)
+{
+   if ((crp_flags & CRYPTO_F_IMBUF) != 0)
+   return (m_contiguous_subsegment(crpbuf, skip, len));
+   else if ((crp_flags & CRYPTO_F_IOV) != 0)
+   return (cuio_contiguous_segment(crpbuf, skip, len));
+   else {
+   MPASS((crp_flags & (CRYPTO_F_IMBUF | CRYPTO_F_IOV)) !=
+   (CRYPTO_F_IMBUF | CRYPTO_F_IOV));
+   return ((char*)crpbuf + skip);
+   }
+}
+

Modified: head/sys/opencrypto/cryptodev.h
==
--- head/sys/opencrypto/cryptodev.h Thu Dec 13 03:12:15 2018
(r342023)
+++ head/sys/opencrypto/cryptodev.h Thu Dec 13 04:40:53 2018
(r342024)
@@ -564,5 +564,7 @@ extern  void crypto_copydata(int flags, caddr_t buf, in
 extern int crypto_apply(int flags, caddr_t buf, int off, int len,
i

svn commit: r342025 - head/sys/powerpc/booke

2018-12-12 Thread Justin Hibbits
Author: jhibbits
Date: Thu Dec 13 04:48:28 2018
New Revision: 342025
URL: https://svnweb.freebsd.org/changeset/base/342025

Log:
  powerpcspe: Fix GPR handling in SPE exception handler
  
  Optimize the exception handler to only save and load the upper word of the
  GPRs used in the emulating instruction.  This reduces the save/load
  overhead, and as a side effect does not overwrite the upper word of any
  temporary register.
  
  With this commit I am now able to run editors/abiword and math/gnumeric on a
  e500-based system.
  
  MFC after:1 week
  MFC With: r341752,r341751

Modified:
  head/sys/powerpc/booke/spe.c

Modified: head/sys/powerpc/booke/spe.c
==
--- head/sys/powerpc/booke/spe.cThu Dec 13 04:40:53 2018
(r342024)
+++ head/sys/powerpc/booke/spe.cThu Dec 13 04:48:28 2018
(r342025)
@@ -66,7 +66,6 @@ save_vec_int(struct thread *td)
 */
msr = mfmsr();
mtmsr(msr | PSL_VEC);
-   isync();
 
/*
 * Save the vector registers and SPEFSCR to the PCB
@@ -419,6 +418,52 @@ spe_explode(struct fpemu *fe, struct fpn *fp, uint32_t
return (0);
 }
 
+/*
+ * Save the high word of a 64-bit GPR for manipulation in the exception 
handler.
+ */
+static uint32_t
+spe_save_reg_high(int reg)
+{
+   uint32_t vec[2];
+#define EVSTDW(n)   case n: __asm ("evstdw %1,0(%0)" \
+   :: "b"(vec), "n"(n)); break;
+   switch (reg) {
+   EVSTDW(0);  EVSTDW(1);  EVSTDW(2);  EVSTDW(3);
+   EVSTDW(4);  EVSTDW(5);  EVSTDW(6);  EVSTDW(7);
+   EVSTDW(8);  EVSTDW(9);  EVSTDW(10); EVSTDW(11);
+   EVSTDW(12); EVSTDW(13); EVSTDW(14); EVSTDW(15);
+   EVSTDW(16); EVSTDW(17); EVSTDW(18); EVSTDW(19);
+   EVSTDW(20); EVSTDW(21); EVSTDW(22); EVSTDW(23);
+   EVSTDW(24); EVSTDW(25); EVSTDW(26); EVSTDW(27);
+   EVSTDW(28); EVSTDW(29); EVSTDW(30); EVSTDW(31);
+   }
+#undef EVSTDW
+
+   return (vec[0]);
+}
+
+/*
+ * Load the given value into the high word of the requested register.
+ */
+static void
+spe_load_reg_high(int reg, uint32_t val)
+{
+#defineEVLDW(n)   case n: __asm __volatile("evmergelo "#n",%0,0," \
+   :: "r"(val)); break;
+   switch (reg) {
+   EVLDW(1);   EVLDW(2);   EVLDW(3);   EVLDW(4);
+   EVLDW(5);   EVLDW(6);   EVLDW(7);   EVLDW(8);
+   EVLDW(9);   EVLDW(10);  EVLDW(11);  EVLDW(12);
+   EVLDW(13);  EVLDW(14);  EVLDW(15);  EVLDW(16);
+   EVLDW(17);  EVLDW(18);  EVLDW(19);  EVLDW(20);
+   EVLDW(21);  EVLDW(22);  EVLDW(23);  EVLDW(24);
+   EVLDW(25);  EVLDW(26);  EVLDW(27);  EVLDW(28);
+   EVLDW(29);  EVLDW(30);  EVLDW(31);  EVLDW(0);
+   }
+#undef EVLDW
+
+}
+
 void
 spe_handle_fpdata(struct trapframe *frame)
 {
@@ -426,11 +471,12 @@ spe_handle_fpdata(struct trapframe *frame)
struct fpn *result;
uint32_t instr, instr_sec_op;
uint32_t cr_shift, ra, rb, rd, src;
-   uint32_t high, low, res; /* For vector operations. */
+   uint32_t high, low, res, tmp; /* For vector operations. */
uint32_t spefscr = 0;
uint32_t ftod_res[2];
int width; /* Single, Double, Vector, Integer */
int err;
+   uint32_t msr;
 
err = fueword32((void *)frame->srr0, &instr);

@@ -441,6 +487,7 @@ spe_handle_fpdata(struct trapframe *frame)
if ((instr >> OPC_SHIFT) != SPE_OPC)
return;
 
+   msr = mfmsr();
/*
 * 'cr' field is the upper 3 bits of rd.  Magically, since a) rd is 5
 * bits, b) each 'cr' field is 4 bits, and c) Only the 'GT' bit is
@@ -460,32 +507,35 @@ spe_handle_fpdata(struct trapframe *frame)
width = NONE;
switch (src) {
case SPE:
-   save_vec_nodrop(curthread);
+   mtmsr(msr | PSL_VEC);
switch (instr_sec_op) {
case EVFSABS:
-   curthread->td_pcb->pcb_vec.vr[rd][0] = 
-   curthread->td_pcb->pcb_vec.vr[ra][0] & ~(1U << 31);
+   high = spe_save_reg_high(ra) & ~(1U << 31);
frame->fixreg[rd] = frame->fixreg[ra] & ~(1U << 31);
+   spe_load_reg_high(rd, high);
break;
case EVFSNABS:
-   curthread->td_pcb->pcb_vec.vr[rd][0] = 
-   curthread->td_pcb->pcb_vec.vr[ra][0] | (1U << 31);
+   high = spe_save_reg_high(ra) | (1U << 31);
frame->fixreg[rd] = frame->fixreg[ra] | (1U << 31);
+   spe_load_reg_high(rd, high);
break;
case EVFSNEG:
-   curthread->td_pcb->pcb_vec.vr[rd][0] = 
-   

svn commit: r342026 - head/sys/powerpc/include

2018-12-12 Thread Justin Hibbits
Author: jhibbits
Date: Thu Dec 13 05:07:39 2018
New Revision: 342026
URL: https://svnweb.freebsd.org/changeset/base/342026

Log:
  powerpc/booke: Change KERNBASE to be physical load address
  
  Previous commits have made VM_MIN_KERNEL_ADDRESS its own separate entity,
  and rebased the kernel around that address instead of KERNBASE.  This commit
  pulls the trigger to rebase KERNBASE to a physical load address.  The
  eventual goal is to align the address with the AIM KERNBASE, but at this
  time that's not an option.
  
  Currently a Book-E kernel must be loaded on a 64MB boundary, due to size
  issues.  The common load address is at the 64MB mark (0x0400), so simply
  make that the default KERNBASE.
  
  As of this commit, Book-E kernels can be loaded and booted with ubldr.
  
  MFC after:3 weeks

Modified:
  head/sys/powerpc/include/vmparam.h

Modified: head/sys/powerpc/include/vmparam.h
==
--- head/sys/powerpc/include/vmparam.h  Thu Dec 13 04:48:28 2018
(r342025)
+++ head/sys/powerpc/include/vmparam.h  Thu Dec 13 05:07:39 2018
(r342026)
@@ -133,16 +133,9 @@
 
 #else /* Book-E */
 
-#ifdef __powerpc64__
-#ifndef LOCORE
-#defineKERNBASE0xe100UL/* start of kernel 
virtual */
-#else
-#defineKERNBASE0xe100  /* start of kernel 
virtual */
-#endif
-#else
-#defineKERNBASE0xc000  /* start of kernel 
virtual */
-
-#defineVM_MIN_KERNEL_ADDRESS   KERNBASE
+#defineKERNBASE0x04000100  /* start of kernel 
physical */
+#ifndef __powerpc64__
+#defineVM_MIN_KERNEL_ADDRESS   0xc000
 #defineVM_MAX_KERNEL_ADDRESS   0xefff
 #defineVM_MAX_SAFE_KERNEL_ADDRESS  VM_MAX_KERNEL_ADDRESS
 #endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r342009 - head/secure/lib/libcrypto

2018-12-12 Thread Yuri Pankov

Jung-uk Kim wrote:

Author: jkim
Date: Wed Dec 12 21:56:47 2018
New Revision: 342009
URL: https://svnweb.freebsd.org/changeset/base/342009

Log:
   Enable devcryptoeng for OpenSSL.
   
   Since OpenSSL 1.1.1, the good old BSD-specific cryptodev engine has been

   deprecated in favor of this new engine.  However, this engine is not
   throughly tested on FreeBSD because it was originally written for Linux.
   
   http://cryptodev-linux.org/
   
   Also, the author actually meant to enable it by default on BSD platforms but

   he failed to do so because there was a bug in the Configure script.
   
   https://github.com/openssl/openssl/pull/7882
   
   Now they found that it was more generic issue.
   
   https://github.com/openssl/openssl/pull/7885
   
   Therefore, we need to enable this engine on head to give it more exposure.


Modified:
   head/secure/lib/libcrypto/Makefile
   head/secure/lib/libcrypto/opensslconf.h.in

Modified: head/secure/lib/libcrypto/Makefile
==
--- head/secure/lib/libcrypto/Makefile  Wed Dec 12 21:56:45 2018
(r342008)
+++ head/secure/lib/libcrypto/Makefile  Wed Dec 12 21:56:47 2018
(r342009)
@@ -192,8 +192,8 @@ SRCS+=  ecp_nistz256-x86.S ecp_nistz256.c
  .endif
  
  # engine

-SRCS+= eng_all.c eng_cnf.c eng_ctrl.c eng_dyn.c eng_err.c eng_fat.c
-SRCS+= eng_init.c eng_lib.c eng_list.c eng_openssl.c eng_pkey.c
+SRCS+= eng_all.c eng_cnf.c eng_ctrl.c eng_devcrypto.c eng_dyn.c eng_err.c
+SRCS+= eng_fat.c eng_init.c eng_lib.c eng_list.c eng_openssl.c eng_pkey.c
  SRCS+=eng_rdrand.c eng_table.c tb_asnmth.c tb_cipher.c tb_dh.c 
tb_digest.c
  SRCS+=tb_dsa.c tb_eckey.c tb_pkmeth.c tb_rand.c tb_rsa.c
  


Modified: head/secure/lib/libcrypto/opensslconf.h.in
==
--- head/secure/lib/libcrypto/opensslconf.h.in  Wed Dec 12 21:56:45 2018
(r342008)
+++ head/secure/lib/libcrypto/opensslconf.h.in  Wed Dec 12 21:56:47 2018
(r342009)
@@ -46,9 +46,6 @@ extern "C" {
  #ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
  # define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
  #endif
-#ifndef OPENSSL_NO_DEVCRYPTOENG
-# define OPENSSL_NO_DEVCRYPTOENG
-#endif
  #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
  # define OPENSSL_NO_EC_NISTP_64_GCC_128
  #endif


I'm now getting "Could not open /dev/crypto: No such file or directory" 
from every other utility unless cryptodev is loaded; given that it's not 
in GENERIC, this is somewhat unexpected change in behavior.

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


svn commit: r342029 - head

2018-12-12 Thread Dimitry Andric
Author: dim
Date: Thu Dec 13 06:59:55 2018
New Revision: 342029
URL: https://svnweb.freebsd.org/changeset/base/342029

Log:
  Fix dates that I set into the future incorrectly.
  
  Noticed by:   ler

Modified:
  head/ObsoleteFiles.inc
  head/UPDATING

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Dec 13 06:51:20 2018(r342028)
+++ head/ObsoleteFiles.inc  Thu Dec 13 06:59:55 2018(r342029)
@@ -38,7 +38,7 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
-# 20181218: new clang import which bumps version from 6.0.1 to 7.0.1.
+# 20181211: new clang import which bumps version from 6.0.1 to 7.0.1.
 OLD_FILES+=usr/lib/clang/6.0.1/include/sanitizer/allocator_interface.h
 OLD_FILES+=usr/lib/clang/6.0.1/include/sanitizer/asan_interface.h
 OLD_FILES+=usr/lib/clang/6.0.1/include/sanitizer/common_interface_defs.h

Modified: head/UPDATING
==
--- head/UPDATING   Thu Dec 13 06:51:20 2018(r342028)
+++ head/UPDATING   Thu Dec 13 06:59:55 2018(r342029)
@@ -31,7 +31,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
-20181218:
+20181211:
Clang, llvm, lld, lldb, compiler-rt and libc++ have been upgraded to
7.0.1.  Please see the 20141231 entry below for information about
prerequisites and upgrading, if you are not already using clang 3.5.0
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"