svn commit: r356065 - head/sys/arm/arm

2019-12-24 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Dec 24 23:43:29 2019
New Revision: 356065
URL: https://svnweb.freebsd.org/changeset/base/356065

Log:
  Initialize the bounce pages list in armv[4|6] DMA maps.
  
  Fixes the crash on the first use of STAILQ_INSERT_TAIL() in
  add_bounce_page().
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/arm/busdma_machdep-v4.c
  head/sys/arm/arm/busdma_machdep-v6.c

Modified: head/sys/arm/arm/busdma_machdep-v4.c
==
--- head/sys/arm/arm/busdma_machdep-v4.cTue Dec 24 23:20:18 2019
(r356064)
+++ head/sys/arm/arm/busdma_machdep-v4.cTue Dec 24 23:43:29 2019
(r356065)
@@ -669,6 +669,7 @@ allocate_map(bus_dma_tag_t dmat, int mflags)
return (NULL);
}
map->segments = (bus_dma_segment_t *)((uintptr_t)map + mapsize);
+   STAILQ_INIT(>bpages);
return (map);
 }
 

Modified: head/sys/arm/arm/busdma_machdep-v6.c
==
--- head/sys/arm/arm/busdma_machdep-v6.cTue Dec 24 23:20:18 2019
(r356064)
+++ head/sys/arm/arm/busdma_machdep-v6.cTue Dec 24 23:43:29 2019
(r356065)
@@ -735,6 +735,7 @@ allocate_map(bus_dma_tag_t dmat, int mflags)
return (NULL);
}
map->segments = (bus_dma_segment_t *)((uintptr_t)map + mapsize);
+   STAILQ_INIT(>bpages);
return (map);
 }
 
___
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: r355462 - in head/sys: conf dev/gpio

2019-12-06 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Dec  6 20:21:07 2019
New Revision: 355462
URL: https://svnweb.freebsd.org/changeset/base/355462

Log:
  Add a GPIO based MDIO bit-banging bus driver.
  
  Uses two GPIO pins as MDC (clock) and MDIO (bidirectional I/O), relies
  on mii_bitbang.
  
  Tested on SG-3200 where the PHY for one of the ports is wired independently
  of the SoC MDIO bus.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Added:
  head/sys/dev/gpio/gpiomdio.c   (contents, props changed)
Modified:
  head/sys/conf/files

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Dec  6 20:05:08 2019(r355461)
+++ head/sys/conf/files Fri Dec  6 20:21:07 2019(r355462)
@@ -1753,6 +1753,7 @@ dev/gpio/gpioc.c  optional gpio   
\
 dev/gpio/gpioiic.c optional gpioiic
 dev/gpio/gpioled.c optional gpioled !fdt
 dev/gpio/gpioled_fdt.c optional gpioled fdt
+dev/gpio/gpiomdio.coptional gpiomdio mii_bitbang
 dev/gpio/gpiopower.c   optional gpiopower fdt
 dev/gpio/gpioregulator.c   optional gpioregulator fdt ext_resources
 dev/gpio/gpiospi.c optional gpiospi

Added: head/sys/dev/gpio/gpiomdio.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/gpio/gpiomdio.cFri Dec  6 20:21:07 2019
(r355462)
@@ -0,0 +1,243 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 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 "opt_platform.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "gpiobus_if.h"
+#include "miibus_if.h"
+
+#defineGPIOMDIO_MDC_DFLT   0
+#defineGPIOMDIO_MDIO_DFLT  1
+#defineGPIOMDIO_MIN_PINS   2
+
+#defineMDO_BIT 0x01
+#defineMDI_BIT 0x02
+#defineMDC_BIT 0x04
+#defineMDIRPHY_BIT 0x08
+#defineMDIRHOST_BIT0x10
+#defineMDO sc->miibb_ops.mbo_bits[MII_BIT_MDO]
+#defineMDI sc->miibb_ops.mbo_bits[MII_BIT_MDI]
+#defineMDC sc->miibb_ops.mbo_bits[MII_BIT_MDC]
+#defineMDIRPHY 
sc->miibb_ops.mbo_bits[MII_BIT_DIR_HOST_PHY]
+#defineMDIRHOST
sc->miibb_ops.mbo_bits[MII_BIT_DIR_PHY_HOST]
+
+static uint32_t gpiomdio_bb_read(device_t);
+static void gpiomdio_bb_write(device_t, uint32_t);
+
+struct gpiomdio_softc
+{
+   device_tsc_dev;
+   device_tsc_busdev;
+   int mdc_pin;
+   int mdio_pin;
+   struct mii_bitbang_ops  miibb_ops;
+};
+
+
+static int
+gpiomdio_probe(device_t dev)
+{
+   struct gpiobus_ivar *devi;
+
+   if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+   if (!ofw_bus_is_compatible(dev, "freebsd,gpiomdio"))
+   return (ENXIO);
+   devi = GPIOBUS_IVAR(dev);
+   if (devi->npins < GPIOMDIO_MIN_PINS) {
+   device_printf(dev,
+   "gpiomdio needs at least %d GPIO pins (only %d given).\n",
+   GPIOMDIO_MIN_PINS, devi->npins);
+   return (ENXIO);
+   }
+   device_set_desc(dev, "GPIO MDIO bit-banging Bus driver");
+
+   return 

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

2019-12-06 Thread Luiz Otavio O Souza
On Fri, Dec 6, 2019 at 12:57 PM Hans Petter Selasky  wrote:
>
> On 2019-12-06 13:55, Luiz Otavio O Souza wrote:
> > Author: loos
> > Date: Fri Dec  6 12:55:39 2019
> > New Revision: 355444
> > URL: https://svnweb.freebsd.org/changeset/base/355444
> >
> > Log:
> >Add the SPI driver for the Marvell Armada 37x0 SoC.
> >
> >Interrupt based driver, implements SPI mode and clock configuration.
> >
> >Tested on espressobin and SG-3200.
> >
> >Sponsored by:  Rubicon Communications, LLC (Netgate)
> >
> > Added:
>
> This breaks aarch64. You need to add #include 

Fixed in r355461.

Sorry for the breakage.

Luiz
___
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: r355444 - in head/sys: arm/mv arm64/conf conf

2019-12-06 Thread Luiz Otavio O Souza
On Fri, Dec 6, 2019 at 1:58 PM Ian Lepore  wrote:
>
> On Fri, 2019-12-06 at 12:55 +, Luiz Otavio O Souza wrote:
> > Author: loos
> > Date: Fri Dec  6 12:55:39 2019
> > New Revision: 355444
> > URL: https://svnweb.freebsd.org/changeset/base/355444
> >
> > Log:
> >   Add the SPI driver for the Marvell Armada 37x0 SoC.
> >
> >   Interrupt based driver, implements SPI mode and clock configuration.
> >
> >   Tested on espressobin and SG-3200.
> >
> >   Sponsored by:   Rubicon Communications, LLC (Netgate)
> >
> > Added:
> >   head/sys/arm/mv/a37x0_spi.c   (contents, props changed)
> > Modified:
> >   head/sys/arm64/conf/GENERIC
> >   head/sys/conf/files.arm64
> >
> > Added: head/sys/arm/mv/a37x0_spi.c
> >
> >
> > +static int
> > +a37x0_spi_detach(device_t dev)
> > +{
> > + struct a37x0_spi_softc *sc;
> > +
> > + bus_generic_detach(dev);
> >
>
> It's possible for detaching children to fail (like if one of them
> returns EBUSY from its detach), in which case you should bail on your
> detach and return the error status.  Also, this needs a
> device_destroy_children() here after detaching them, to remove the
> spibus child added in attach (in case the module is unloaded then
> reloaded, that avoids adding a second copy of the child).
>

Fixed in r355461.

Thanks Ian.

Luiz
___
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: r355461 - head/sys/arm/mv

2019-12-06 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Dec  6 20:05:08 2019
New Revision: 355461
URL: https://svnweb.freebsd.org/changeset/base/355461

Log:
  Fix the ARM64 build, include the necessary  header.
  
  While here, call device_delete_children() to detach and dealloc all the
  existent children and handle the child's detach errors properly.
  
  Reported by:  jenkins, hselasky, ian
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/arm/mv/a37x0_spi.c
==
--- head/sys/arm/mv/a37x0_spi.c Fri Dec  6 19:33:39 2019(r355460)
+++ head/sys/arm/mv/a37x0_spi.c Fri Dec  6 20:05:08 2019(r355461)
@@ -29,9 +29,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -228,9 +228,11 @@ a37x0_spi_attach(device_t dev)
 static int
 a37x0_spi_detach(device_t dev)
 {
+   int err;
struct a37x0_spi_softc *sc;
 
-   bus_generic_detach(dev);
+   if ((err = device_delete_children(dev)) != 0)
+   return (err);
sc = device_get_softc(dev);
mtx_destroy(>sc_mtx);
if (sc->sc_intrhand)
___
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: r355444 - in head/sys: arm/mv arm64/conf conf

2019-12-06 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Dec  6 12:55:39 2019
New Revision: 355444
URL: https://svnweb.freebsd.org/changeset/base/355444

Log:
  Add the SPI driver for the Marvell Armada 37x0 SoC.
  
  Interrupt based driver, implements SPI mode and clock configuration.
  
  Tested on espressobin and SG-3200.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Added: head/sys/arm/mv/a37x0_spi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/a37x0_spi.c Fri Dec  6 12:55:39 2019(r355444)
@@ -0,0 +1,494 @@
+/*-
+ * Copyright (c) 2018, 2019 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 ``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.
+ *
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "spibus_if.h"
+
+struct a37x0_spi_softc {
+   device_tsc_dev;
+   struct mtx  sc_mtx;
+   struct resource *sc_mem_res;
+   struct resource *sc_irq_res;
+   struct spi_command  *sc_cmd;
+   bus_space_tag_t sc_bst;
+   bus_space_handle_t  sc_bsh;
+   uint32_tsc_len;
+   uint32_tsc_maxfreq;
+   uint32_tsc_read;
+   uint32_tsc_flags;
+   uint32_tsc_written;
+   void*sc_intrhand;
+};
+
+#defineA37X0_SPI_WRITE(_sc, _off, _val)\
+bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off), (_val))
+#defineA37X0_SPI_READ(_sc, _off)   \
+bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off))
+#defineA37X0_SPI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
+#defineA37X0_SPI_UNLOCK(_sc)   mtx_unlock(&(_sc)->sc_mtx)
+
+#defineA37X0_SPI_BUSY  (1 << 0)
+/*
+ * While the A3700 utils from Marvell usually sets the QSF clock to 200MHz,
+ * there is no guarantee that it is correct without the proper clock framework
+ * to retrieve the actual TBG and PLL settings.
+ */
+#defineA37X0_SPI_CLOCK 2   /* QSF Clock 
200MHz */
+
+#defineA37X0_SPI_CONTROL   0x0
+#define A37X0_SPI_CS_SHIFT 16
+#define A37X0_SPI_CS_MASK  (0xf << A37X0_SPI_CS_SHIFT)
+#defineA37X0_SPI_CONF  0x4
+#define A37X0_SPI_WFIFO_THRS_SHIFT 28
+#define A37X0_SPI_RFIFO_THRS_SHIFT 24
+#define A37X0_SPI_AUTO_CS_EN   (1 << 20)
+#define A37X0_SPI_DMA_WR_EN(1 << 19)
+#define A37X0_SPI_DMA_RD_EN(1 << 18)
+#define A37X0_SPI_FIFO_MODE(1 << 17)
+#define A37X0_SPI_SRST (1 << 16)
+#define A37X0_SPI_XFER_START   (1 << 15)
+#define A37X0_SPI_XFER_STOP(1 << 14)
+#define A37X0_SPI_INSTR_PIN(1 << 13)
+#define A37X0_SPI_ADDR_PIN (1 << 12)
+#define A37X0_SPI_DATA_PIN_MASK0x3
+#define A37X0_SPI_DATA_PIN_SHIFT   10
+#define A37X0_SPI_FIFO_FLUSH   (1 << 9)
+#define A37X0_SPI_RW_EN(1 << 8)
+#define A37X0_SPI_CLK_POL  (1 << 7)
+#define A37X0_SPI_CLK_PHASE(1 << 6)
+#define A37X0_SPI_BYTE_LEN (1 << 5)
+#define A37X0_SPI_PSC_MASK 0x1f
+#defineA37X0_SPI_DATA_OUT 

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

2019-12-04 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Dec  5 02:01:47 2019
New Revision: 355409
URL: https://svnweb.freebsd.org/changeset/base/355409

Log:
  Fix the build, use the correct include path.
  
  Pointy hat to:loos

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

Modified: head/sys/arm/mv/a37x0_iic.c
==
--- head/sys/arm/mv/a37x0_iic.c Thu Dec  5 00:56:03 2019(r355408)
+++ head/sys/arm/mv/a37x0_iic.c Thu Dec  5 02:01:47 2019(r355409)
@@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
 
 #include "iicbus_if.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: r355408 - in head/sys: arm/mv arm64/conf conf

2019-12-04 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Dec  5 00:56:03 2019
New Revision: 355408
URL: https://svnweb.freebsd.org/changeset/base/355408

Log:
  Add the I2C driver for the Armada 37x0.
  
  This controller is a bit tricky as the STOP condition must be indicated in
  the last tranferred byte, some devices will not like the repeated start
  behavior of this controller.  A proper fix to this issue is in the works.
  
  This driver works in polling mode, can be used early in the boot (required
  in some cases).
  
  Tested on espressobin/SG-1100 and the SG-3200.
  
  Obtained from:pfSense
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Added: head/sys/arm/mv/a37x0_iic.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/a37x0_iic.c Thu Dec  5 00:56:03 2019(r355408)
@@ -0,0 +1,484 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018, 2019 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$");
+
+/*
+ * Driver for Armada 37x0 i2c controller.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "iicbus_if.h"
+
+struct a37x0_iic_softc {
+   boolean_t   sc_fast_mode;
+   bus_space_tag_t sc_bst;
+   bus_space_handle_t  sc_bsh;
+   device_tsc_dev;
+   device_tsc_iicbus;
+   struct mtx  sc_mtx;
+   struct resource *sc_mem_res;
+   struct resource *sc_irq_res;
+   void*sc_intrhand;
+};
+
+#defineA37X0_IIC_WRITE(_sc, _off, _val)\
+bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, _off, _val)
+#defineA37X0_IIC_READ(_sc, _off)   \
+bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, _off)
+#defineA37X0_IIC_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
+#defineA37X0_IIC_UNLOCK(_sc)   mtx_unlock(&(_sc)->sc_mtx)
+
+static struct ofw_compat_data compat_data[] = {
+   { "marvell,armada-3700-i2c",1 },
+   { NULL, 0 }
+};
+
+#undef A37x0_IIC_DEBUG
+
+static void a37x0_iic_intr(void *);
+static int a37x0_iic_detach(device_t);
+
+static void
+a37x0_iic_rmw(struct a37x0_iic_softc *sc, uint32_t off, uint32_t mask,
+uint32_t value)
+{
+   uint32_t reg;
+
+   mtx_assert(>sc_mtx, MA_OWNED);
+   reg = A37X0_IIC_READ(sc, off);
+   reg &= ~mask;
+   reg |= value;
+   A37X0_IIC_WRITE(sc, off, reg);
+}
+
+static int
+a37x0_iic_wait_clear(struct a37x0_iic_softc *sc, uint32_t mask)
+{
+   int timeout;
+   uint32_t status;
+
+   mtx_assert(>sc_mtx, MA_OWNED);
+   timeout = 1000;
+   do {
+   DELAY(10);
+   status = A37X0_IIC_READ(sc, A37X0_IIC_ISR);
+   if (--timeout == 0)
+   return (0);
+   } while ((status & mask) != 0);
+
+   return (1);
+}
+
+static int
+a37x0_iic_wait_set(struct a37x0_iic_softc *sc, uint32_t mask)
+{
+   int timeout;
+   uint32_t status;
+
+   mtx_assert(>sc_mtx, MA_OWNED);
+   timeout = 1000;
+   do {
+   DELAY(10);
+   status = A37X0_IIC_READ(sc, A37X0_IIC_ISR);
+   if (--timeout == 0)
+   

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

2019-07-01 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jul  1 13:41:37 2019
New Revision: 349578
URL: https://svnweb.freebsd.org/changeset/base/349578

Log:
  Add support for the Marvell 88E6190 11 ports switch.
  
  With more ports, some of the registers are shifted a bit to accommodate.
  
  This switch also adds two high speed Serdes/SGMII interfaces (2.5 Gb/s).
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Mon Jul  1 11:52:54 2019
(r349577)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Mon Jul  1 13:41:37 2019
(r349578)
@@ -106,6 +106,8 @@ static int e6000sw_parse_fixed_link(e6000sw_softc_t *,
 static int e6000sw_parse_ethernet(e6000sw_softc_t *, phandle_t, uint32_t);
 static int e6000sw_attach(device_t);
 static int e6000sw_detach(device_t);
+static int e6000sw_read_xmdio(device_t, int, int, int);
+static int e6000sw_write_xmdio(device_t, int, int, int, int);
 static int e6000sw_readphy(device_t, int, int);
 static int e6000sw_writephy(device_t, int, int, int);
 static etherswitch_info_t* e6000sw_getinfo(device_t);
@@ -205,16 +207,26 @@ e6000sw_probe(device_t dev)
const char *description;
phandle_t switch_node;
 
+   sc = device_get_softc(dev);
switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
"marvell,mv88e6085");
+   if (switch_node == 0) {
+   switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
+   "marvell,mv88e6190");
 
-   if (switch_node == 0)
-   return (ENXIO);
+   if (switch_node == 0)
+   return (ENXIO);
 
+   /*
+* Trust DTS and fix the port register offset for the MV88E6190
+* detection bellow.
+*/
+   sc->swid = MV88E6190;
+   }
+
if (bootverbose)
device_printf(dev, "Found switch_node: 0x%x\n", switch_node);
 
-   sc = device_get_softc(dev);
sc->dev = dev;
sc->node = switch_node;
 
@@ -230,7 +242,7 @@ e6000sw_probe(device_t dev)
 */
sx_init(>sx, "e6000sw_tmp");
E6000SW_LOCK(sc);
-   sc->swid = e6000sw_readreg(sc, REG_PORT(0), SWITCH_ID) & 0xfff0;
+   sc->swid = e6000sw_readreg(sc, REG_PORT(sc, 0), SWITCH_ID) & 0xfff0;
E6000SW_UNLOCK(sc);
sx_destroy(>sx);
 
@@ -257,6 +269,10 @@ e6000sw_probe(device_t dev)
description = "Marvell 88E6176";
sc->num_ports = 7;
break;
+   case MV88E6190:
+   description = "Marvell 88E6190";
+   sc->num_ports = 11;
+   break;
default:
device_printf(dev, "Unrecognized device, id 0x%x.\n", sc->swid);
return (ENXIO);
@@ -278,18 +294,16 @@ e6000sw_parse_fixed_link(e6000sw_softc_t *sc, phandle_
if (fixed_link != 0) {
sc->fixed_mask |= (1 << port);
 
-   if (OF_getencprop(fixed_link, "speed", , sizeof(speed))> 
0) {
-   if (speed == 2500 &&
-   (MVSWITCH(sc, MV88E6141) ||
-MVSWITCH(sc, MV88E6341)))
-   sc->fixed25_mask |= (1 << port);
-   } else {
-   device_printf(sc->dev,
+   if (OF_getencprop(fixed_link,
+   "speed", , sizeof(speed)) < 0) {
+   device_printf(sc->dev,
"Port %d has a fixed-link node without a speed "
"property\n", port);
-
-   return (ENXIO);
+   return (ENXIO);
}
+   if (speed == 2500 && (MVSWITCH(sc, MV88E6141) ||
+MVSWITCH(sc, MV88E6341) || MVSWITCH(sc, MV88E6190)))
+   sc->fixed25_mask |= (1 << port);
}
 
return (0);
@@ -383,9 +397,36 @@ e6000sw_attach_miibus(e6000sw_softc_t *sc, int port)
return (0);
 }
 
+static void
+e6000sw_serdes_power(device_t dev, int port, bool sgmii)
+{
+   uint32_t reg;
+
+   /* SGMII */
+   reg = e6000sw_read_xmdio(dev, port, E6000SW_SERDES_DEV,
+   E6000SW_SERDES_SGMII_CTL);
+   if (sgmii)
+   reg &= ~E6000SW_SERDES_PDOWN;
+   else
+   reg |= E6000SW_SERDES_PDOWN;
+   e6000sw_write_xmdio(dev, port, E6000SW_SERDES_DEV,
+   E6000SW_SERDES_SGMII_CTL, reg);
+
+   /* 10GBASE-R/10GBASE-X4/X2 */
+   reg = e6000sw_read_xmdio(dev, port, E6000SW_SERDES_DEV,
+   E6000SW_SERDES_PCS_CTL1);
+   if (sgmii)
+   reg |= E6000SW_SERDES_PDOWN;
+   else
+   reg &= ~E6000SW_SERDES_PDOWN;
+   e6000sw_write_xmdio(dev, port, 

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

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

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

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

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

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

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

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

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

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

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

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


Re: svn commit: r348882 - head/sys/dev/sdhci

2019-06-21 Thread Luiz Otavio O Souza
On Fri, 14 Jun 2019 at 05:25, Bjoern A. Zeeb
 wrote:
>
> On 10 Jun 2019, at 21:50, Luiz Otavio O Souza wrote:
>
> > Author: loos
> > Date: Mon Jun 10 21:50:07 2019
> > New Revision: 348882
> > URL: https://svnweb.freebsd.org/changeset/base/348882
> >
> > Log:
> >   Add support for the GPIO SD Card VCC regulator/switch and the GPIO
> > SD Card
> >   detection pins to the Marvell Xenon SDHCI controller.
> >
> >   These features are enable by 'vqmmc-supply' and 'cd-gpios'
> > properties in the
> >   DTS.
> >
> >   This fixes the SD Card detection on espressobin.
>
> Do you have a copy or a reference to such a (working) dts file?

I'm using the in tree DTS for the espresso bin:
sys/gnu/dts/arm64/marvell/armada-3720-espressobin.dts

Now that it works, I think we could build it by default.

Luiz
___
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: r348882 - head/sys/dev/sdhci

2019-06-10 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jun 10 21:50:07 2019
New Revision: 348882
URL: https://svnweb.freebsd.org/changeset/base/348882

Log:
  Add support for the GPIO SD Card VCC regulator/switch and the GPIO SD Card
  detection pins to the Marvell Xenon SDHCI controller.
  
  These features are enable by 'vqmmc-supply' and 'cd-gpios' properties in the
  DTS.
  
  This fixes the SD Card detection on espressobin.
  
  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.cMon Jun 10 21:34:07 2019
(r348881)
+++ head/sys/dev/sdhci/sdhci_xenon.cMon Jun 10 21:50:07 2019
(r348882)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -56,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 
 #include "mmcbr_if.h"
@@ -84,10 +86,12 @@ struct sdhci_xenon_softc {
uint32_tmax_clk;/* Max possible freq */
struct resource *irq_res;   /* IRQ resource */
void*intrhand;  /* Interrupt handle */
+   struct sdhci_fdt_gpio *gpio;/* GPIO pins for CD detection. */
 
struct sdhci_slot *slot;/* SDHCI internal data */
struct resource *mem_res;   /* Memory resource */
 
+   regulator_t reg_vqmmc;  /* vqmmc-supply regulator */
uint8_t znr;/* PHY ZNR */
uint8_t zpr;/* PHY ZPR */
boolno_18v; /* No 1.8V support */
@@ -188,6 +192,14 @@ sdhci_xenon_get_ro(device_t bus, device_t dev)
return (sdhci_generic_get_ro(bus, dev) ^ sc->wp_inverted);
 }
 
+static bool
+sdhci_xenon_get_card_present(device_t dev, struct sdhci_slot *slot)
+{
+   struct sdhci_xenon_softc *sc = device_get_softc(dev);
+
+   return (sdhci_fdt_gpio_get_present(sc->gpio));
+}
+
 static int
 sdhci_xenon_phy_init(device_t brdev, struct mmc_ios *ios)
 {
@@ -337,6 +349,25 @@ sdhci_xenon_update_ios(device_t brdev, device_t reqdev
slot = device_get_ivars(reqdev);
ios = >host.ios;
 
+   switch (ios->power_mode) {
+   case power_on:
+   break;
+   case power_off:
+   if (bootverbose)
+   device_printf(sc->dev, "Powering down sd/mmc\n");
+
+   if (sc->reg_vqmmc)
+   regulator_disable(sc->reg_vqmmc);
+   break;
+   case power_up:
+   if (bootverbose)
+   device_printf(sc->dev, "Powering up sd/mmc\n");
+
+   if (sc->reg_vqmmc)
+   regulator_enable(sc->reg_vqmmc);
+   break;
+   };
+
/* Update the PHY settings. */
if (ios->clock != 0)
sdhci_xenon_phy_set(brdev, ios);
@@ -352,6 +383,42 @@ sdhci_xenon_update_ios(device_t brdev, device_t reqdev
 }
 
 static int
+sdhci_xenon_switch_vccq(device_t brdev, device_t reqdev)
+{
+   struct sdhci_xenon_softc *sc;
+   struct sdhci_slot *slot;
+   int uvolt, err;
+
+   sc = device_get_softc(brdev);
+
+if (sc->reg_vqmmc == NULL)
+   return EOPNOTSUPP;
+
+   slot = device_get_ivars(reqdev);
+   switch (slot->host.ios.vccq) {
+   case vccq_180:
+   uvolt = 180;
+   break;
+   case vccq_330:
+   uvolt = 330;
+   break;
+   default:
+   return EINVAL;
+   }
+
+   err = regulator_set_voltage(sc->reg_vqmmc, uvolt, uvolt);
+   if (err != 0) {
+   device_printf(sc->dev,
+   "Cannot set vqmmc to %d<->%d\n",
+   uvolt,
+   uvolt);
+   return (err);
+   }
+
+   return (0);
+}
+
+static int
 sdhci_xenon_probe(device_t dev)
 {
struct sdhci_xenon_softc *sc = device_get_softc(dev);
@@ -389,6 +456,11 @@ sdhci_xenon_probe(device_t dev)
if ((OF_getencprop(sc->node, "marvell,xenon-phy-zpr", ,
sizeof(cid))) > 0)
sc->zpr = cid & XENON_ZPR_MASK;
+   if (regulator_get_by_ofw_property(dev, 0, "vqmmc-supply",
+   >reg_vqmmc) == 0 && bootverbose) {
+   if (bootverbose)
+   device_printf(dev, "vqmmc-supply regulator found\n");
+   }
 
return (0);
 }
@@ -437,6 +509,12 @@ sdhci_xenon_attach(device_t dev)
slot->max_clk = sc->max_clk;
sc->slot = slot;
 
+   /*
+* Set up any gpio pin handling described in the FDT data. This cannot
+* fail; see comments in sdhci_fdt_gpio.h for details.
+*/
+   sc->gpio = sdhci_fdt_gpio_setup(dev, slot);
+
if (sdhci_init_slot(dev, sc->slot, 0))
goto fail;
 
@@ -497,6 +575,9 @@ sdhci_xenon_detach(device_t dev)
 {
struct sdhci_xenon_softc 

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

2019-06-10 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jun 10 21:27:21 2019
New Revision: 348880
URL: https://svnweb.freebsd.org/changeset/base/348880

Log:
  Add the GPIO driver for the North/South bridge in Marvell Armada 37x0.
  
  The A3700 has a different GPIO controller and thus, do not use the old (and
  shared) code for Marvell.
  
  The pinctrl driver, also part of the controller, is not supported yet (but
  the implementation should be straightforward).
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Added: head/sys/arm/mv/a37x0_gpio.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/a37x0_gpio.cMon Jun 10 21:27:21 2019
(r348880)
@@ -0,0 +1,352 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018-2019, Rubicon Communications, LLC (Netgate)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "gpio_if.h"
+
+static struct resource_spec a37x0_gpio_res_spec[] = {
+   { SYS_RES_MEMORY, 0, RF_ACTIVE },   /* Pinctl / GPIO */
+   { SYS_RES_MEMORY, 1, RF_ACTIVE },   /* Interrupts control */
+   { -1, 0, 0 }
+};
+
+struct a37x0_gpio_softc {
+   bus_space_tag_t sc_bst;
+   bus_space_handle_t  sc_bsh;
+   device_tsc_busdev;
+   int sc_type;
+   uint32_tsc_max_pins;
+   uint32_tsc_npins;
+   struct resource *sc_mem_res[nitems(a37x0_gpio_res_spec) - 1];
+};
+
+/* Memory regions. */
+#defineA37X0_GPIO  0
+#defineA37X0_INTR  1
+
+/* North Bridge / South Bridge. */
+#defineA37X0_NB_GPIO   1
+#defineA37X0_SB_GPIO   2
+
+#defineA37X0_GPIO_WRITE(_sc, _off, _val)   \
+bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off), (_val))
+#defineA37X0_GPIO_READ(_sc, _off)  \
+bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off))
+
+#defineA37X0_GPIO_BIT(_p)  (1U << ((_p) % 32))
+#defineA37X0_GPIO_OUT_EN(_p)   (0x0 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_LATCH(_p)(0x8 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_INPUT(_p)(0x10 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_OUTPUT(_p)   (0x18 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_SEL  0x30
+
+
+static struct ofw_compat_data compat_data[] = {
+   { "marvell,armada3710-nb-pinctrl",  A37X0_NB_GPIO },
+   { "marvell,armada3710-sb-pinctrl",  A37X0_SB_GPIO },
+   { NULL, 0 }
+};
+
+static phandle_t
+a37x0_gpio_get_node(device_t bus, device_t dev)
+{
+
+   return (ofw_bus_get_node(bus));
+}
+
+static device_t
+a37x0_gpio_get_bus(device_t dev)
+{
+   struct a37x0_gpio_softc *sc;
+
+   sc = device_get_softc(dev);
+
+   return (sc->sc_busdev);
+}
+
+static int
+a37x0_gpio_pin_max(device_t dev, int *maxpin)
+{
+   struct a37x0_gpio_softc *sc;
+
+   sc = device_get_softc(dev);
+   *maxpin = sc->sc_npins - 1;
+
+   return (0);
+}
+
+static int
+a37x0_gpio_pin_getname(device_t dev, uint32_t pin, char *name)
+{
+   struct a37x0_gpio_softc *sc;
+
+   sc = device_get_softc(dev);
+   if (pin >= sc->sc_npins)
+   return (EINVAL);
+   

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

2019-06-06 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Jun  6 21:25:46 2019
New Revision: 348762
URL: https://svnweb.freebsd.org/changeset/base/348762

Log:
  Do not overwrite the RGMII bits in the CPU port register of Switch.
  
  Fixes the network on Espressobin.
  
  The GENERIC kernel now boots over NFS.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Thu Jun  6 21:24:40 2019
(r348761)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Thu Jun  6 21:25:46 2019
(r348762)
@@ -441,10 +441,12 @@ e6000sw_attach(device_t dev)
 * Force speed, full-duplex, EEE off and flow-control
 * on.
 */
+   reg &= ~(PSC_CONTROL_SPD2500 | PSC_CONTROL_ALT_SPD |
+   PSC_CONTROL_FORCED_EEE);
if (e6000sw_is_fixed25port(sc, port))
-   reg = PSC_CONTROL_SPD2500;
+   reg |= PSC_CONTROL_SPD2500;
else
-   reg = PSC_CONTROL_SPD1000;
+   reg |= PSC_CONTROL_SPD1000;
reg |= PSC_CONTROL_FORCED_DPX | PSC_CONTROL_FULLDPX |
PSC_CONTROL_FORCED_LINK | PSC_CONTROL_LINK_UP |
PSC_CONTROL_FORCED_FC | PSC_CONTROL_FC_ON |

Modified: head/sys/dev/etherswitch/e6000sw/e6000swreg.h
==
--- head/sys/dev/etherswitch/e6000sw/e6000swreg.h   Thu Jun  6 21:24:40 
2019(r348761)
+++ head/sys/dev/etherswitch/e6000sw/e6000swreg.h   Thu Jun  6 21:25:46 
2019(r348762)
@@ -74,6 +74,7 @@ struct atu_opt {
 
 #define PSC_CONTROL0x1
 #definePSC_CONTROL_FORCED_SPD  (1 << 13)
+#definePSC_CONTROL_ALT_SPD (1 << 12)
 #definePSC_CONTROL_EEE_ON  (1 << 9)
 #definePSC_CONTROL_FORCED_EEE  (1 << 8)
 #definePSC_CONTROL_FC_ON   (1 << 7)
___
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: r348759 - head/sys/dev/gpio

2019-06-06 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Jun  6 20:54:09 2019
New Revision: 348759
URL: https://svnweb.freebsd.org/changeset/base/348759

Log:
  Zero the GPIO regulator pins memory.
  
  This fixes a panic in Espressobin when gpioregulator fails to allocate the
  GPIO pin (the GPIO controller is not there).
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/gpio/gpioregulator.c

Modified: head/sys/dev/gpio/gpioregulator.c
==
--- head/sys/dev/gpio/gpioregulator.c   Thu Jun  6 20:35:41 2019
(r348758)
+++ head/sys/dev/gpio/gpioregulator.c   Thu Jun  6 20:54:09 2019
(r348759)
@@ -248,7 +248,7 @@ gpioregulator_parse_fdt(struct gpioregulator_softc *sc
/* "gpios" property */
sc->init_def.npins = 32 - __builtin_clz(mask);
sc->init_def.pins = malloc(sc->init_def.npins *
-   sizeof(sc->init_def.pins), M_DEVBUF, M_WAITOK);
+   sizeof(sc->init_def.pins), M_DEVBUF, M_WAITOK | M_ZERO);
for (n = 0; n < sc->init_def.npins; n++) {
error = gpio_pin_get_by_ofw_idx(sc->dev, node, n,
>init_def.pins[n]);
___
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: r340458 - head/sys/arm/mv

2018-11-15 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Nov 15 17:05:02 2018
New Revision: 340458
URL: https://svnweb.freebsd.org/changeset/base/340458

Log:
  Set the SPI clock speed and polarity on each transfer to catch up with
  recent changes in spibus and allow the use of different SPI modes on
  the same bus.
  
  Reported by:  ian
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/arm/mv/mv_spi.c
==
--- head/sys/arm/mv/mv_spi.cThu Nov 15 16:42:59 2018(r340457)
+++ head/sys/arm/mv/mv_spi.cThu Nov 15 17:05:02 2018(r340458)
@@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #include "spibus_if.h"
 
 struct mv_spi_softc {
@@ -70,11 +72,23 @@ struct mv_spi_softc {
 #defineMV_SPI_UNLOCK(_sc)  mtx_unlock(&(_sc)->sc_mtx)
 
 #defineMV_SPI_CONTROL  0
+#defineMV_SPI_CTRL_CS_MASK 7
 #defineMV_SPI_CTRL_CS_SHIFT2
 #defineMV_SPI_CTRL_SMEMREADY   (1 << 1)
 #defineMV_SPI_CTRL_CS_ACTIVE   (1 << 0)
 #defineMV_SPI_CONF 0x4
+#defineMV_SPI_CONF_MODE_SHIFT  12
+#defineMV_SPI_CONF_MODE_MASK   (3 << MV_SPI_CONF_MODE_SHIFT)
 #defineMV_SPI_CONF_BYTELEN (1 << 5)
+#defineMV_SPI_CONF_CLOCK_SPR_MASK  0xf
+#defineMV_SPI_CONF_CLOCK_SPPR_MASK 1
+#defineMV_SPI_CONF_CLOCK_SPPR_SHIFT4
+#defineMV_SPI_CONF_CLOCK_SPPRHI_MASK   3
+#defineMV_SPI_CONF_CLOCK_SPPRHI_SHIFT  6
+#defineMV_SPI_CONF_CLOCK_MASK  
\
+((MV_SPI_CONF_CLOCK_SPPRHI_MASK << MV_SPI_CONF_CLOCK_SPPRHI_SHIFT) | \
+(MV_SPI_CONF_CLOCK_SPPR_MASK << MV_SPI_CONF_CLOCK_SPPR_SHIFT) |\
+MV_SPI_CONF_CLOCK_SPR_MASK)
 #defineMV_SPI_DATAOUT  0x8
 #defineMV_SPI_DATAIN   0xc
 #defineMV_SPI_INTR_STAT0x10
@@ -244,10 +258,27 @@ mv_spi_intr(void *arg)
 }
 
 static int
+mv_spi_psc_calc(uint32_t clock, uint32_t *spr, uint32_t *sppr)
+{
+   uint32_t divider, tclk;
+
+   tclk = get_tclk_armada38x();
+   for (*spr = 2; *spr <= 15; (*spr)++) {
+   for (*sppr = 0; *sppr <= 7; (*sppr)++) {
+   divider = *spr * (1 << *sppr);
+   if (tclk / divider <= clock)
+   return (0);
+   }
+   }
+
+   return (EINVAL);
+}
+
+static int
 mv_spi_transfer(device_t dev, device_t child, struct spi_command *cmd)
 {
struct mv_spi_softc *sc;
-   uint32_t cs, reg;
+   uint32_t clock, cs, mode, reg, spr, sppr;
int resid, timeout;
 
KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz,
@@ -255,9 +286,23 @@ mv_spi_transfer(device_t dev, device_t child, struct s
KASSERT(cmd->tx_data_sz == cmd->rx_data_sz,
("TX/RX data sizes should be equal"));
 
-   /* Get the proper chip select for this child. */
+   /* Get the proper chip select, mode and clock for this transfer. */
spibus_get_cs(child, );
cs &= ~SPIBUS_CS_HIGH;
+   spibus_get_mode(child, );
+   if (mode > 3) {
+   device_printf(dev,
+   "Invalid mode %u requested by %s\n", mode,
+   device_get_nameunit(child));
+   return (EINVAL);
+   }
+   spibus_get_clock(child, );
+   if (clock == 0 || mv_spi_psc_calc(clock, , ) != 0) {
+   device_printf(dev,
+   "Invalid clock %uHz requested by %s\n", clock,
+   device_get_nameunit(child));
+   return (EINVAL);
+   }
 
sc = device_get_softc(dev);
MV_SPI_LOCK(sc);
@@ -275,7 +320,20 @@ mv_spi_transfer(device_t dev, device_t child, struct s
sc->sc_written = 0;
sc->sc_len = cmd->tx_cmd_sz + cmd->tx_data_sz;
 
-   MV_SPI_WRITE(sc, MV_SPI_CONTROL, cs << MV_SPI_CTRL_CS_SHIFT);
+   /* Set SPI Mode and Clock. */
+   reg = MV_SPI_READ(sc, MV_SPI_CONF);
+   reg &= ~(MV_SPI_CONF_MODE_MASK | MV_SPI_CONF_CLOCK_MASK);
+   reg |= mode << MV_SPI_CONF_MODE_SHIFT;
+   reg |= spr & MV_SPI_CONF_CLOCK_SPR_MASK;
+   reg |= (sppr & MV_SPI_CONF_CLOCK_SPPR_MASK) <<
+   MV_SPI_CONF_CLOCK_SPPR_SHIFT;
+   reg |= (sppr & MV_SPI_CONF_CLOCK_SPPRHI_MASK) <<
+   MV_SPI_CONF_CLOCK_SPPRHI_SHIFT;
+   MV_SPI_WRITE(sc, MV_SPI_CONTROL, reg);
+
+   /* Set CS number and assert CS. */
+   reg = (cs & MV_SPI_CTRL_CS_MASK) << MV_SPI_CTRL_CS_SHIFT;
+   MV_SPI_WRITE(sc, MV_SPI_CONTROL, reg);
reg = MV_SPI_READ(sc, MV_SPI_CONTROL);
MV_SPI_WRITE(sc, MV_SPI_CONTROL, reg | MV_SPI_CTRL_CS_ACTIVE);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to 

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

2018-11-15 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Nov 15 16:29:27 2018
New Revision: 340456
URL: https://svnweb.freebsd.org/changeset/base/340456

Log:
  Comment MD_ROOT and remove 'device re' which is not part of the system and
  can be loaded as module.

Modified:
  head/sys/arm/conf/ARMADA38X

Modified: head/sys/arm/conf/ARMADA38X
==
--- head/sys/arm/conf/ARMADA38X Thu Nov 15 16:13:25 2018(r340455)
+++ head/sys/arm/conf/ARMADA38X Thu Nov 15 16:29:27 2018(r340456)
@@ -14,7 +14,7 @@ options   SOC_MV_ARMADA38X
 makeoptionsWERROR="-Werror"
 makeoptionsMODULES_EXTRA="dtb/mv"
 
-optionsMD_ROOT
+#options   MD_ROOT
 #makeoptions   MFS_IMAGE=/path/to/miniroot
 #options   ROOTDEVNAME=\"ufs:md0\"
 optionsROOTDEVNAME=\"/dev/da0s1a\"
@@ -39,7 +39,6 @@ deviceether
 device vlan
 device mii
 device bpf
-device re
 device mdio
 device etherswitch
 device e6000sw
___
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: r340432 - in head/sys/arm: conf mv

2018-11-14 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Nov 14 14:26:32 2018
New Revision: 340432
URL: https://svnweb.freebsd.org/changeset/base/340432

Log:
  Add the driver for the SPI controller on ARMADA38X.
  
  Tested on Clearfog (Pro) and SG-3100.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Added:
  head/sys/arm/mv/mv_spi.c   (contents, props changed)
Modified:
  head/sys/arm/conf/ARMADA38X
  head/sys/arm/conf/GENERIC
  head/sys/arm/mv/files.arm7

Modified: head/sys/arm/conf/ARMADA38X
==
--- head/sys/arm/conf/ARMADA38X Wed Nov 14 14:18:35 2018(r340431)
+++ head/sys/arm/conf/ARMADA38X Wed Nov 14 14:26:32 2018(r340432)
@@ -76,6 +76,11 @@ device   iic
 device iicbus
 device twsi
 
+# SPI
+device spibus
+device spigen
+device mv_spi
+
 # Wireless NIC cards
 device wlan# 802.11 support
 device ath # Atheros NIC's

Modified: head/sys/arm/conf/GENERIC
==
--- head/sys/arm/conf/GENERIC   Wed Nov 14 14:18:35 2018(r340431)
+++ head/sys/arm/conf/GENERIC   Wed Nov 14 14:26:32 2018(r340432)
@@ -169,6 +169,7 @@ device  aw_cir
 device spibus
 device spigen
 device bcm2835_spi
+device mv_spi
 device ti_spi
 
 # ADC support

Modified: head/sys/arm/mv/files.arm7
==
--- head/sys/arm/mv/files.arm7  Wed Nov 14 14:18:35 2018(r340431)
+++ head/sys/arm/mv/files.arm7  Wed Nov 14 14:26:32 2018(r340432)
@@ -18,6 +18,7 @@ arm/mv/armada38x/armada38x_mp.c   optionalsmp
 arm/mv/armada38x/pmsu.cstandard
 arm/mv/armada38x/armada38x_rtc.c   standard
 arm/mv/armada38x/armada38x_pl310.c optional pl310
+arm/mv/mv_spi.coptionalmv_spi spibus
 dev/sdhci/sdhci_fdt.c  optionalsdhci
 
 arm/mv/rtc.c   standard

Added: head/sys/arm/mv/mv_spi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/mv_spi.cWed Nov 14 14:26:32 2018(r340432)
@@ -0,0 +1,351 @@
+/*-
+ * Copyright (c) 2017-2018, Rubicon Communications, LLC (Netgate)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "spibus_if.h"
+
+struct mv_spi_softc {
+   device_tsc_dev;
+   struct mtx  sc_mtx;
+   struct resource *sc_mem_res;
+   struct resource *sc_irq_res;
+   struct spi_command  *sc_cmd;
+   bus_space_tag_t sc_bst;
+   bus_space_handle_t  sc_bsh;
+   uint32_tsc_len;
+   uint32_tsc_read;
+   uint32_tsc_flags;
+   uint32_tsc_written;
+   void*sc_intrhand;
+};
+
+#defineMV_SPI_BUSY 0x1
+#defineMV_SPI_WRITE(_sc, _off, _val)   \
+bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off), (_val))
+#defineMV_SPI_READ(_sc, _off)  \
+bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off))
+#defineMV_SPI_LOCK(_sc)mtx_lock(&(_sc)->sc_mtx)
+#defineMV_SPI_UNLOCK(_sc)  mtx_unlock(&(_sc)->sc_mtx)
+
+#defineMV_SPI_CONTROL  0
+#define

Re: svn commit: r338371 - in head/sys: arm/nvidia dev/sdhci

2018-08-29 Thread Luiz Otavio O Souza
On Wed, Aug 29, 2018 at 11:01 AM Emmanuel Vadot wrote:
>
> Author: manu
> Date: Wed Aug 29 14:01:27 2018
> New Revision: 338371
> URL: https://svnweb.freebsd.org/changeset/base/338371
>
> Log:
>   arm64: GENERIC-MMCCAM: Fix build and module depend
>
>   Fix the build of the GENERIC-MMCCAM kernel config after the sdhci_xenon
>   driver was commited.
>   While here correct sdhci_fdt and tegra_sdhci, even with MMCCAM they do
>   need to depend on sdhci(4)
>
>   Reported by:  Reshetnikov Dmitriy 

Thanks Manu!
___
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: r337860 - head/sys/netpfil/ipfw

2018-08-15 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Aug 15 16:36:29 2018
New Revision: 337860
URL: https://svnweb.freebsd.org/changeset/base/337860

Log:
  Fix a typo in comment.
  
  MFC after:3 days
  X-MFC with:   r321316
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/netpfil/ipfw/ip_dn_io.c

Modified: head/sys/netpfil/ipfw/ip_dn_io.c
==
--- head/sys/netpfil/ipfw/ip_dn_io.cWed Aug 15 16:34:31 2018
(r337859)
+++ head/sys/netpfil/ipfw/ip_dn_io.cWed Aug 15 16:36:29 2018
(r337860)
@@ -809,7 +809,7 @@ dummynet_send(struct mbuf *m)
ether_demux(m->m_pkthdr.rcvif, m);
break;
 
-   case DIR_OUT | PROTO_LAYER2: /* N_TO_ETH_OUT: */
+   case DIR_OUT | PROTO_LAYER2: /* DN_TO_ETH_OUT: */
ether_output_frame(ifp, m);
break;
 
___
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: r337854 - head/sys/netinet

2018-08-15 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Aug 15 15:44:30 2018
New Revision: 337854
URL: https://svnweb.freebsd.org/changeset/base/337854

Log:
  Late style follow up on r312770.
  
  Submitted by: glebius
  X-MFC with:   r312770
  MFC after:3 days

Modified:
  head/sys/netinet/in.c

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Wed Aug 15 14:57:34 2018(r337853)
+++ head/sys/netinet/in.c   Wed Aug 15 15:44:30 2018(r337854)
@@ -620,8 +620,7 @@ in_difaddr_ioctl(u_long cmd, caddr_t data, struct ifne
in_ifadown(>ia_ifa, 1);
 
if (ia->ia_ifa.ifa_carp)
-   (*carp_detach_p)(>ia_ifa,
-   (cmd == SIOCDIFADDR) ? false : true);
+   (*carp_detach_p)(>ia_ifa, cmd == SIOCAIFADDR);
 
/*
 * If this is the last IPv4 address configured on this
___
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: r337844 - head/sys/netgraph

2018-08-15 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Aug 15 13:42:22 2018
New Revision: 337844
URL: https://svnweb.freebsd.org/changeset/base/337844

Log:
  The interface name must be sanitized before the search to match the existing
  netgraph node.
  
  Fixes the search (and use) of VLANs with dot notation.
  
  Obtained from:pfSense
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/netgraph/ng_ether.c

Modified: head/sys/netgraph/ng_ether.c
==
--- head/sys/netgraph/ng_ether.cWed Aug 15 13:40:16 2018
(r337843)
+++ head/sys/netgraph/ng_ether.cWed Aug 15 13:42:22 2018
(r337844)
@@ -314,7 +314,8 @@ ng_ether_attach(struct ifnet *ifp)
 * eiface nodes, which may be problematic due to naming
 * clashes.
 */
-   if ((node = ng_name2noderef(NULL, ifp->if_xname)) != NULL) {
+   ng_ether_sanitize_ifname(ifp->if_xname, name);
+   if ((node = ng_name2noderef(NULL, name)) != NULL) {
NG_NODE_UNREF(node);
return;
}
@@ -341,7 +342,6 @@ ng_ether_attach(struct ifnet *ifp)
priv->hwassist = ifp->if_hwassist;
 
/* Try to give the node the same name as the interface */
-   ng_ether_sanitize_ifname(ifp->if_xname, name);
if (ng_name_node(node, name) != 0)
log(LOG_WARNING, "%s: can't name node %s\n", __func__, name);
 }
___
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: r337811 - head/sys/dev/neta

2018-08-14 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Aug 14 18:58:16 2018
New Revision: 337811
URL: https://svnweb.freebsd.org/changeset/base/337811

Log:
  Disable the auto negotiation if the port is set to fixed-link.
  
  Tested on SG-3100 (ARMADA38X) and Espresso.bin (A37x0).  Fixes the network
  on espresso.bin.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/neta/if_mvneta.c

Modified: head/sys/dev/neta/if_mvneta.c
==
--- head/sys/dev/neta/if_mvneta.c   Tue Aug 14 18:58:01 2018
(r337810)
+++ head/sys/dev/neta/if_mvneta.c   Tue Aug 14 18:58:16 2018
(r337811)
@@ -757,6 +757,7 @@ mvneta_attach(device_t self)
 
} else {
/* Fixed-link, use predefined values */
+   mvneta_update_autoneg(sc, FALSE);
ifmedia_init(>mvneta_ifmedia, 0, mvneta_mediachange,
mvneta_mediastatus);
 
___
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: r337772 - in head/sys: arm64/conf conf dev/sdhci

2018-08-14 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Aug 14 16:33:30 2018
New Revision: 337772
URL: https://svnweb.freebsd.org/changeset/base/337772

Log:
  Add support to the Marvell Xenon SDHCI controller.
  
  Tested on Espresso.bin (37x0) and Macchiato.bin (8k) with SD cards and
  eMMCs.
  
  Obtained from:pfSense
  Sponsored by: Rubicon Communications, LLC (Netgate)

Added:
  head/sys/dev/sdhci/sdhci_xenon.c   (contents, props changed)
  head/sys/dev/sdhci/sdhci_xenon.h   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Tue Aug 14 16:29:10 2018(r337771)
+++ head/sys/arm64/conf/GENERIC Tue Aug 14 16:33:30 2018(r337772)
@@ -159,6 +159,7 @@ device  pass# Passthrough device 
(direct ATA/SCSI ac
 
 # MMC/SD/SDIO Card slot support
 device sdhci
+device sdhci_xenon # Marvell Xenon SD/MMC controller
 device aw_mmc  # Allwinner SD/MMC controller
 device mmc # mmc/sd bus
 device mmcsd   # mmc/sd flash cards

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Tue Aug 14 16:29:10 2018(r337771)
+++ head/sys/conf/files.arm64   Tue Aug 14 16:33:30 2018(r337772)
@@ -211,6 +211,7 @@ dev/pci/pci_host_generic_fdt.c  optionalpci fdt
 dev/psci/psci.cstandard
 dev/psci/psci_arm64.S  standard
 dev/psci/smccc.c   standard
+dev/sdhci/sdhci_xenon.coptionalsdhci_xenon sdhci fdt
 dev/uart/uart_cpu_arm64.c  optionaluart
 dev/uart/uart_dev_mu.c optionaluart uart_mu
 dev/uart/uart_dev_pl011.c  optionaluart pl011

Added: head/sys/dev/sdhci/sdhci_xenon.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/sdhci/sdhci_xenon.cTue Aug 14 16:33:30 2018
(r337772)
@@ -0,0 +1,546 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Marvell Xenon SDHCI controller driver.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "mmcbr_if.h"
+#include "sdhci_if.h"
+
+#defineMAX_SLOTS   6
+
+static struct ofw_compat_data compat_data[] = {
+   { "marvell,armada-3700-sdhci",  1 },
+   { NULL, 0 }
+};
+
+struct sdhci_xenon_softc {
+   device_tdev;/* Controller device */
+   int slot_id;/* Controller ID */
+   phandle_t   node;   /* FDT node */
+   uint32_tquirks; /* Chip specific quirks */
+   uint32_tcaps;   /* If we override SDHCI_CAPABILITIES */
+   uint32_tmax_clk;/* Max possible freq */
+   struct resource *irq_res;   /* IRQ resource */
+   void*intrhand;  /* Interrupt handle */
+
+   struct sdhci_slot *slot;/* SDHCI internal data */
+   struct resource *mem_res;   /* Memory resource */
+
+   uint8_t znr;/* PHY ZNR */
+   uint8_t zpr;/* PHY ZPR */
+   

svn commit: r337759 - head/sys/arm64/arm64

2018-08-14 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Aug 14 15:27:50 2018
New Revision: 337759
URL: https://svnweb.freebsd.org/changeset/base/337759

Log:
  Use the correct PTE when changing the attribute of multiple pages.
  
  Submitted by: andrew (long time ago)
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Aug 14 14:50:06 2018(r337758)
+++ head/sys/arm64/arm64/pmap.c Tue Aug 14 15:27:50 2018(r337759)
@@ -4813,7 +4813,7 @@ pmap_change_attr_locked(vm_offset_t va, vm_size_t size
return (EINVAL);
 
for (tmpva = base; tmpva < base + size; ) {
-   pte = pmap_pte(kernel_pmap, va, );
+   pte = pmap_pte(kernel_pmap, tmpva, );
if (pte == NULL)
return (EINVAL);
 
___
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: r337752 - head/sys/dev/psci

2018-08-14 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Aug 14 13:56:49 2018
New Revision: 337752
URL: https://svnweb.freebsd.org/changeset/base/337752

Log:
  Fix a typo on the PSCI smc call wrapper.
  
  Looks good from:  andrew
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/psci/psci_arm.S
  head/sys/dev/psci/psci_arm64.S

Modified: head/sys/dev/psci/psci_arm.S
==
--- head/sys/dev/psci/psci_arm.STue Aug 14 13:56:42 2018
(r337751)
+++ head/sys/dev/psci/psci_arm.STue Aug 14 13:56:49 2018
(r337752)
@@ -45,4 +45,4 @@ END(psci_hvc_despatch)
 ENTRY(psci_smc_despatch)
smc #0
RET
-END(psci_hvc_despatch)
+END(psci_smc_despatch)

Modified: head/sys/dev/psci/psci_arm64.S
==
--- head/sys/dev/psci/psci_arm64.S  Tue Aug 14 13:56:42 2018
(r337751)
+++ head/sys/dev/psci/psci_arm64.S  Tue Aug 14 13:56:49 2018
(r337752)
@@ -46,4 +46,4 @@ END(psci_hvc_despatch)
 ENTRY(psci_smc_despatch)
smc #0
ret
-END(psci_hvc_despatch)
+END(psci_smc_despatch)
___
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: r321989 - head/usr.bin/calendar/calendars

2017-08-03 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Aug  3 13:26:51 2017
New Revision: 321989
URL: https://svnweb.freebsd.org/changeset/base/321989

Log:
  Add myself to the calendar.freebsd.
  
  Reported by:  mckusick

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

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdThu Aug  3 10:11:06 
2017(r321988)
+++ head/usr.bin/calendar/calendars/calendar.freebsdThu Aug  3 13:26:51 
2017(r321989)
@@ -99,6 +99,7 @@
 03/07  Michael P. Pritchard <m...@freebsd.org> born in Los Angeles, 
California, United States, 1964
 03/07  Giorgos Keramidas <keram...@freebsd.org> born in Athens, Greece, 1976
 03/10  Andreas Klemm <andr...@freebsd.org> born in Duesseldorf, 
Nordrhein-Westfalen, Germany, 1963
+03/10  Luiz Otavio O Souza <l...@freebsd.org> born in Bauru, Sao Paulo, 
Brazil, 1978
 03/10  Nikolai Lifanov <lifa...@freebsd.org> born in Moscow, Russian 
Federation, 1989
 03/11  Soeren Straarup <xr...@freebsd.org> born in Andst, Denmark, 1978
 03/12  Greg Lewis <gle...@freebsd.org> born in Adelaide, South Australia, 
Australia, 1969
___
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: r321649 - head/sys/net

2017-07-27 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jul 28 04:41:57 2017
New Revision: 321649
URL: https://svnweb.freebsd.org/changeset/base/321649

Log:
  Remove the unused mutex since r273220.
  
  MFC after:1 week
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/net/if_stf.c

Modified: head/sys/net/if_stf.c
==
--- head/sys/net/if_stf.c   Fri Jul 28 03:33:09 2017(r321648)
+++ head/sys/net/if_stf.c   Fri Jul 28 04:41:57 2017(r321649)
@@ -139,7 +139,6 @@ SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CT
 
 struct stf_softc {
struct ifnet*sc_ifp;
-   struct mtx  sc_ro_mtx;
u_int   sc_fibnum;
const struct encaptab *encap_cookie;
 };
@@ -147,10 +146,6 @@ struct stf_softc {
 
 static const char stfname[] = "stf";
 
-/*
- * Note that mutable fields in the softc are not currently locked.
- * We do lock sc_ro in stf_output though.
- */
 static MALLOC_DEFINE(M_STF, stfname, "6to4 Tunnel Interface");
 static const int ip_stf_ttl = 40;
 
@@ -253,7 +248,6 @@ stf_clone_create(struct if_clone *ifc, char *name, siz
ifp->if_dname = stfname;
ifp->if_dunit = IF_DUNIT_NONE;
 
-   mtx_init(&(sc)->sc_ro_mtx, "stf ro", NULL, MTX_DEF);
sc->encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV6,
stf_encapcheck, _stf_protosw, sc);
if (sc->encap_cookie == NULL) {
@@ -280,7 +274,6 @@ stf_clone_destroy(struct if_clone *ifc, struct ifnet *
 
err = encap_detach(sc->encap_cookie);
KASSERT(err == 0, ("Unexpected error detaching encap_cookie"));
-   mtx_destroy(&(sc)->sc_ro_mtx);
bpfdetach(ifp);
if_detach(ifp);
if_free(ifp);
___
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: r321602 - head/sys/dev/etherswitch/e6000sw

2017-07-26 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Jul 27 02:38:53 2017
New Revision: 321602
URL: https://svnweb.freebsd.org/changeset/base/321602

Log:
  Fix the port vlan support in e6000 based switches.
  
  Reduce the use of local copies of switch register data.
  
  The switch now works with the upstream dsa node (i.e. the upstream DTS).
  
  Tested on:ClearFog Pro (88E6176), SG-3100 (88E6141)
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Thu Jul 27 00:30:13 2017
(r321601)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Thu Jul 27 02:38:53 2017
(r321602)
@@ -72,6 +72,7 @@ typedef struct e6000sw_softc {
struct proc *kproc;
 
uint32_tswid;
+   uint32_tvlan_mode;
uint32_tcpuports_mask;
uint32_tfixed_mask;
uint32_tfixed25_mask;
@@ -80,15 +81,11 @@ typedef struct e6000sw_softc {
int sw_addr;
int num_ports;
boolean_t   multi_chip;
-
-   int vid[E6000SW_NUM_VGROUPS];
-   int members[E6000SW_NUM_VGROUPS];
-   int vgroup[E6000SW_MAX_PORTS];
 } e6000sw_softc_t;
 
 static etherswitch_info_t etherswitch_info = {
.es_nports =0,
-   .es_nvlangroups =   E6000SW_NUM_VGROUPS,
+   .es_nvlangroups =   0,
.es_vlan_caps = ETHERSWITCH_VLAN_PORT,
.es_name =  "Marvell 6000 series switch"
 };
@@ -263,15 +260,14 @@ e6000sw_probe(device_t dev)
 }
 
 static int
-e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child, int *pport,
-int *pvlangroup)
+e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child, int *pport)
 {
char *name, *portlabel;
int speed;
phandle_t fixed_link;
-   uint32_t port, vlangroup;
+   uint32_t port;
 
-   if (pport == NULL || pvlangroup == NULL)
+   if (pport == NULL)
return (ENXIO);
 
if (OF_getencprop(child, "reg", (void *), sizeof(port)) < 0)
@@ -280,15 +276,6 @@ e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t
return (ENXIO);
*pport = port;
 
-   if (OF_getencprop(child, "vlangroup", (void *),
-   sizeof(vlangroup)) > 0) {
-   if (vlangroup >= E6000SW_NUM_VGROUPS)
-   return (ENXIO);
-   *pvlangroup = vlangroup;
-   } else {
-   *pvlangroup = -1;
-   }
-
if (OF_getprop_alloc(child, "label", 1, (void **)) > 0) {
if (strncmp(portlabel, "cpu", 3) == 0) {
device_printf(sc->dev, "CPU port at %d\n", port);
@@ -364,11 +351,9 @@ e6000sw_attach_miibus(e6000sw_softc_t *sc, int port)
 static int
 e6000sw_attach(device_t dev)
 {
-   etherswitch_vlangroup_t vg;
e6000sw_softc_t *sc;
phandle_t child;
-   int err, port, vlangroup;
-   int member_ports[E6000SW_NUM_VGROUPS];
+   int err, port;
uint32_t reg;
 
err = 0;
@@ -383,18 +368,14 @@ e6000sw_attach(device_t dev)
 
E6000SW_LOCK(sc);
e6000sw_setup(dev, sc);
-   bzero(member_ports, sizeof(member_ports));
 
for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) {
-   err = e6000sw_parse_child_fdt(sc, child, , );
+   err = e6000sw_parse_child_fdt(sc, child, );
if (err != 0) {
device_printf(sc->dev, "failed to parse DTS\n");
goto out_fail;
}
 
-   if (vlangroup != -1)
-   member_ports[vlangroup] |= (1 << port);
-
/* Port is in use. */
sc->ports_mask |= (1 << port);
 
@@ -440,21 +421,9 @@ e6000sw_attach(device_t dev)
}
 
etherswitch_info.es_nports = sc->num_ports;
-   for (port = 0; port < sc->num_ports; port++)
-   sc->vgroup[port] = E6000SW_PORT_NO_VGROUP;
 
-   /* Set VLAN configuration */
+   /* Default to port vlan. */
e6000sw_port_vlan_conf(sc);
-
-   /* Set vlangroups */
-   for (vlangroup = 0; vlangroup < E6000SW_NUM_VGROUPS; vlangroup++)
-   if (member_ports[vlangroup] != 0) {
-   vg.es_vlangroup = vg.es_vid = vlangroup;
-   vg.es_member_ports = vg.es_untagged_ports =
-   member_ports[vlangroup];
-   e6000sw_setvgroup(dev, );
-   }
-
E6000SW_UNLOCK(sc);
 
bus_generic_probe(dev);
@@ -597,12 +566,14 @@ e6000sw_getinfo(device_t dev)
 }
 
 static int
-e6000sw_getconf(device_t 

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

2017-07-20 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jul 21 03:59:56 2017
New Revision: 321321
URL: https://svnweb.freebsd.org/changeset/base/321321

Log:
  Restore the changes done in r313982: Replace zero with NULL for pointers.
  
  Spotted by:   Harry Schmalzbauer
  MFC after:1 week
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/netmap/netmap_freebsd.c
  head/sys/dev/netmap/netmap_mem2.c

Modified: head/sys/dev/netmap/netmap_freebsd.c
==
--- head/sys/dev/netmap/netmap_freebsd.cFri Jul 21 03:48:09 2017
(r321320)
+++ head/sys/dev/netmap/netmap_freebsd.cFri Jul 21 03:59:56 2017
(r321321)
@@ -671,7 +671,7 @@ nm_os_pt_memdev_iomap(struct ptnetmap_memdev *ptn_dev,
, 0, ~0, *mem_size, RF_ACTIVE);
if (ptn_dev->pci_mem == NULL) {
*nm_paddr = 0;
-   *nm_addr = 0;
+   *nm_addr = NULL;
return ENOMEM;
}
 

Modified: head/sys/dev/netmap/netmap_mem2.c
==
--- head/sys/dev/netmap/netmap_mem2.c   Fri Jul 21 03:48:09 2017
(r321320)
+++ head/sys/dev/netmap/netmap_mem2.c   Fri Jul 21 03:59:56 2017
(r321321)
@@ -2146,7 +2146,7 @@ netmap_mem_pt_guest_deref(struct netmap_mem_d *nmd)
if (ptnmd->ptn_dev) {
nm_os_pt_memdev_iounmap(ptnmd->ptn_dev);
}
-   ptnmd->nm_addr = 0;
+   ptnmd->nm_addr = NULL;
ptnmd->nm_paddr = 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: r321319 - head/sys/net

2017-07-20 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jul 21 03:42:09 2017
New Revision: 321319
URL: https://svnweb.freebsd.org/changeset/base/321319

Log:
  Update netmap_user.h with the current version of netmap.  This file should
  have been committed together with r319881.
  
  MFC after:1 week
  MFC with: r319881
  Pointy hat to:loos

Modified:
  head/sys/net/netmap_user.h

Modified: head/sys/net/netmap_user.h
==
--- head/sys/net/netmap_user.h  Fri Jul 21 03:40:05 2017(r321318)
+++ head/sys/net/netmap_user.h  Fri Jul 21 03:42:09 2017(r321319)
@@ -309,16 +309,16 @@ typedef void (*nm_cb_t)(u_char *, const struct nm_pkth
  * ifname  (netmap:foo or vale:foo) is the port name
  * a suffix can indicate the follwing:
  * ^   bind the host (sw) ring pair
- * *   bind host and NIC ring pairs (transparent)
+ * *   bind host and NIC ring pairs
  * -NN bind individual NIC ring pair
  * {NN bind master side of pipe NN
  * }NN bind slave side of pipe NN
  * a suffix starting with / and the following flags,
  * in any order:
  * x   exclusive access
- * z   zero copy monitor
- * t   monitor tx side
- * r   monitor rx side
+ * z   zero copy monitor (both tx and rx)
+ * t   monitor tx side (copy monitor)
+ * r   monitor rx side (copy monitor)
  * R   bind only RX ring(s)
  * T   bind only TX ring(s)
  *
@@ -634,9 +634,10 @@ nm_open(const char *ifname, const struct nmreq *req,
const char *vpname = NULL;
 #define MAXERRMSG 80
char errmsg[MAXERRMSG] = "";
-   enum { P_START, P_RNGSFXOK, P_GETNUM, P_FLAGS, P_FLAGSOK } p_state;
+   enum { P_START, P_RNGSFXOK, P_GETNUM, P_FLAGS, P_FLAGSOK, P_MEMID } 
p_state;
int is_vale;
long num;
+   uint16_t nr_arg2 = 0;
 
if (strncmp(ifname, "netmap:", 7) &&
strncmp(ifname, NM_BDG_NAME, strlen(NM_BDG_NAME))) {
@@ -665,7 +666,7 @@ nm_open(const char *ifname, const struct nmreq *req,
}
 
/* scan for a separator */
-   for (; *port && !index("-*^{}/", *port); port++)
+   for (; *port && !index("-*^{}/@", *port); port++)
;
 
if (is_vale && !nm_is_identifier(vpname, port)) {
@@ -707,6 +708,9 @@ nm_open(const char *ifname, const struct nmreq *req,
case '/': /* start of flags */
p_state = P_FLAGS;
break;
+   case '@': /* start of memid */
+   p_state = P_MEMID;
+   break;
default:
snprintf(errmsg, MAXERRMSG, "unknown modifier: 
'%c'", *port);
goto fail;
@@ -718,6 +722,9 @@ nm_open(const char *ifname, const struct nmreq *req,
case '/':
p_state = P_FLAGS;
break;
+   case '@':
+   p_state = P_MEMID;
+   break;
default:
snprintf(errmsg, MAXERRMSG, "unexpected 
character: '%c'", *port);
goto fail;
@@ -736,6 +743,11 @@ nm_open(const char *ifname, const struct nmreq *req,
break;
case P_FLAGS:
case P_FLAGSOK:
+   if (*port == '@') {
+   port++;
+   p_state = P_MEMID;
+   break;
+   }
switch (*port) {
case 'x':
nr_flags |= NR_EXCLUSIVE;
@@ -762,17 +774,25 @@ nm_open(const char *ifname, const struct nmreq *req,
port++;
p_state = P_FLAGSOK;
break;
+   case P_MEMID:
+   if (nr_arg2 != 0) {
+   snprintf(errmsg, MAXERRMSG, "double setting of 
memid");
+   goto fail;
+   }
+   num = strtol(port, (char **), 10);
+   if (num <= 0) {
+   snprintf(errmsg, MAXERRMSG, "invalid memid %ld, 
must be >0", num);
+   goto fail;
+   }
+   nr_arg2 = num;
+   p_state = P_RNGSFXOK;
+   break;
}
}
if 

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

2017-07-20 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jul 21 03:28:35 2017
New Revision: 321317
URL: https://svnweb.freebsd.org/changeset/base/321317

Log:
  Do not allow the use of the loopback interface in netmap.
  
  The generic support in netmap send the packets using if_transmit() and the
  loopback do not support packets coming from if_transmit()/if_start().
  
  This avoids the use of the loopback interface and the subsequent crash that
  happens when the application send packets to the loopback interface.
  
  Details in:   https://github.com/luigirizzo/netmap/issues/322
  Reported by:  Vincenzo Maffione 
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/netmap/netmap_generic.c
==
--- head/sys/dev/netmap/netmap_generic.cFri Jul 21 03:04:55 2017
(r321316)
+++ head/sys/dev/netmap/netmap_generic.cFri Jul 21 03:28:35 2017
(r321317)
@@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
 #include  /* sockaddrs */
 #include 
 #include 
+#include 
 #include 
 #include /* bus_dmamap_* in netmap_kern.h */
 
@@ -1197,6 +1198,13 @@ generic_netmap_attach(struct ifnet *ifp)
struct netmap_generic_adapter *gna;
int retval;
u_int num_tx_desc, num_rx_desc;
+
+#ifdef __FreeBSD__
+   if (ifp->if_type == IFT_LOOP) {
+   D("if_loop is not supported by %s", __func__);
+   return EINVAL;
+   }
+#endif
 
num_tx_desc = num_rx_desc = netmap_generic_ringsize; /* starting point 
*/
 
___
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: r321316 - head/sys/netpfil/ipfw

2017-07-20 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jul 21 03:04:55 2017
New Revision: 321316
URL: https://svnweb.freebsd.org/changeset/base/321316

Log:
  Fix a couple of typos in a comment.
  
  MFC after:1 week
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/netpfil/ipfw/ip_fw_table.c

Modified: head/sys/netpfil/ipfw/ip_fw_table.c
==
--- head/sys/netpfil/ipfw/ip_fw_table.c Fri Jul 21 01:35:55 2017
(r321315)
+++ head/sys/netpfil/ipfw/ip_fw_table.c Fri Jul 21 03:04:55 2017
(r321316)
@@ -1658,7 +1658,7 @@ ipfw_unref_table(struct ip_fw_chain *ch, uint16_t kidx
 }
 
 /*
- * Lookup an arbtrary key @paddr of legth @plen in table @tbl.
+ * Lookup an arbitrary key @paddr of length @plen in table @tbl.
  * Stores found value in @val.
  *
  * Returns 1 if key was found.
___
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: r320161 - head/sys/dev/iicbus/twsi

2017-06-20 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jun 20 18:38:51 2017
New Revision: 320161
URL: https://svnweb.freebsd.org/changeset/base/320161

Log:
  Always ignore the START and STOP bits whenever the control register is
  being overwritten, they are set only bits (cleared by hardware).
  
  Disable the Acknowledge of the controller slave address.  The slave mode is
  not supported.
  
  Make sure the interrupt flag bit is being cleared as recommended, add a
  delay() _after_ clear the interrupt bit.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/iicbus/twsi/twsi.c

Modified: head/sys/dev/iicbus/twsi/twsi.c
==
--- head/sys/dev/iicbus/twsi/twsi.c Tue Jun 20 18:29:01 2017
(r320160)
+++ head/sys/dev/iicbus/twsi/twsi.c Tue Jun 20 18:38:51 2017
(r320161)
@@ -114,6 +114,7 @@ twsi_control_clear(struct twsi_softc *sc, uint32_t mas
uint32_t val;
 
val = TWSI_READ(sc, sc->reg_control);
+   val &= ~(TWSI_CONTROL_STOP | TWSI_CONTROL_START);
val &= ~mask;
TWSI_WRITE(sc, sc->reg_control, val);
 }
@@ -124,6 +125,7 @@ twsi_control_set(struct twsi_softc *sc, uint32_t mask)
uint32_t val;
 
val = TWSI_READ(sc, sc->reg_control);
+   val &= ~(TWSI_CONTROL_STOP | TWSI_CONTROL_START);
val |= mask;
TWSI_WRITE(sc, sc->reg_control, val);
 }
@@ -204,8 +206,8 @@ twsi_locked_start(device_t dev, struct twsi_softc *sc,
}
 
TWSI_WRITE(sc, sc->reg_data, slave);
-   DELAY(1000);
twsi_clear_iflg(sc);
+   DELAY(1000);
 
if (twsi_poll_ctrl(sc, timeout, TWSI_CONTROL_IFLG)) {
debugf("timeout sending slave address\n");
@@ -251,7 +253,7 @@ twsi_reset(device_t dev, u_char speed, u_char addr, u_
TWSI_WRITE(sc, sc->reg_soft_reset, 0x0);
DELAY(2000);
TWSI_WRITE(sc, sc->reg_baud_rate, param);
-   TWSI_WRITE(sc, sc->reg_control, TWSI_CONTROL_TWSIEN | TWSI_CONTROL_ACK);
+   TWSI_WRITE(sc, sc->reg_control, TWSI_CONTROL_TWSIEN);
DELAY(1000);
mtx_unlock(>mutex);
 
@@ -266,9 +268,10 @@ twsi_stop(device_t dev)
sc = device_get_softc(dev);
 
mtx_lock(>mutex);
+   twsi_control_clear(sc, TWSI_CONTROL_ACK);
twsi_control_set(sc, TWSI_CONTROL_STOP);
-   DELAY(1000);
twsi_clear_iflg(sc);
+   DELAY(1000);
mtx_unlock(>mutex);
 
return (IIC_NOERR);
@@ -341,8 +344,8 @@ twsi_read(device_t dev, char *buf, int len, int *read,
else
twsi_control_set(sc, TWSI_CONTROL_ACK);
 
-   DELAY (1000);
twsi_clear_iflg(sc);
+   DELAY(1000);
 
if (twsi_poll_ctrl(sc, delay, TWSI_CONTROL_IFLG)) {
debugf("timeout reading data\n");
@@ -382,6 +385,7 @@ twsi_write(device_t dev, const char *buf, int len, int
TWSI_WRITE(sc, sc->reg_data, *buf++);
 
twsi_clear_iflg(sc);
+   DELAY(1000);
if (twsi_poll_ctrl(sc, timeout, TWSI_CONTROL_IFLG)) {
debugf("timeout writing data\n");
rv = IIC_ETIMEOUT;
___
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: r320159 - in head/sys/dev/iicbus: . twsi

2017-06-20 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jun 20 18:25:27 2017
New Revision: 320159
URL: https://svnweb.freebsd.org/changeset/base/320159

Log:
  Make ofw_iicbus attach to twsi I2C controllers.
  
  Add the ofw_bus_get_node() callback in mv_twsi, it is mandatory for the
  ofw_iicbus usage.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/iicbus/ofw_iicbus.c
  head/sys/dev/iicbus/twsi/mv_twsi.c

Modified: head/sys/dev/iicbus/ofw_iicbus.c
==
--- head/sys/dev/iicbus/ofw_iicbus.cTue Jun 20 18:14:56 2017
(r320158)
+++ head/sys/dev/iicbus/ofw_iicbus.cTue Jun 20 18:25:27 2017
(r320159)
@@ -84,6 +84,8 @@ EARLY_DRIVER_MODULE(ofw_iicbus, iicbb, ofw_iicbus_driv
 0, 0, BUS_PASS_BUS);
 EARLY_DRIVER_MODULE(ofw_iicbus, iichb, ofw_iicbus_driver, ofwiicbus_devclass,
 0, 0, BUS_PASS_BUS);
+EARLY_DRIVER_MODULE(ofw_iicbus, twsi, ofw_iicbus_driver, ofwiicbus_devclass,
+0, 0, BUS_PASS_BUS);
 MODULE_VERSION(ofw_iicbus, 1);
 MODULE_DEPEND(ofw_iicbus, iicbus, 1, 1, 1);
 

Modified: head/sys/dev/iicbus/twsi/mv_twsi.c
==
--- head/sys/dev/iicbus/twsi/mv_twsi.c  Tue Jun 20 18:14:56 2017
(r320158)
+++ head/sys/dev/iicbus/twsi/mv_twsi.c  Tue Jun 20 18:25:27 2017
(r320159)
@@ -91,6 +91,7 @@ __FBSDID("$FreeBSD$");
 #define debugf(fmt, args...)
 #endif
 
+static phandle_t mv_twsi_get_node(device_t, device_t);
 static int mv_twsi_probe(device_t);
 static int mv_twsi_attach(device_t);
 
@@ -105,7 +106,10 @@ static device_method_t mv_twsi_methods[] = {
DEVMETHOD(device_probe, mv_twsi_probe),
DEVMETHOD(device_attach,mv_twsi_attach),
 
-   { 0, 0 }
+   /* ofw_bus interface */
+   DEVMETHOD(ofw_bus_get_node, mv_twsi_get_node),
+
+   DEVMETHOD_END
 };
 
 DEFINE_CLASS_1(twsi, mv_twsi_driver, mv_twsi_methods,
@@ -116,6 +120,14 @@ static devclass_t mv_twsi_devclass;
 DRIVER_MODULE(twsi, simplebus, mv_twsi_driver, mv_twsi_devclass, 0, 0);
 DRIVER_MODULE(iicbus, twsi, iicbus_driver, iicbus_devclass, 0, 0);
 MODULE_DEPEND(twsi, iicbus, 1, 1, 1);
+
+static phandle_t
+mv_twsi_get_node(device_t bus, device_t dev)
+{
+
+   /* Used by ofw_iicbus. */
+   return (ofw_bus_get_node(bus));
+}
 
 static int
 mv_twsi_probe(device_t dev)
___
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: r320158 - head/sys/dev/neta

2017-06-20 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jun 20 18:14:56 2017
New Revision: 320158
URL: https://svnweb.freebsd.org/changeset/base/320158

Log:
  Allow the use of extended media types with if_mvneta, so it can report 2.5G
  speeds properly.
  
  While here remove a couple of stray white spaces.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/neta/if_mvneta.c

Modified: head/sys/dev/neta/if_mvneta.c
==
--- head/sys/dev/neta/if_mvneta.c   Tue Jun 20 18:11:23 2017
(r320157)
+++ head/sys/dev/neta/if_mvneta.c   Tue Jun 20 18:14:56 2017
(r320158)
@@ -2100,6 +2100,7 @@ mvneta_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da
break;
}
case SIOCGIFMEDIA: /* FALLTHROUGH */
+   case SIOCGIFXMEDIA:
if (!sc->phy_attached)
error = ifmedia_ioctl(ifp, ifr, >mvneta_ifmedia,
cmd);
@@ -2469,7 +2470,7 @@ mvneta_adjust_link(struct mvneta_softc *sc)
mvneta_linkupdate(sc, phy_linkup);
 
/* Don't update media on disabled link */
-   if (!phy_linkup )
+   if (!phy_linkup)
return;
 
/* Check for media type change */
@@ -3547,7 +3548,7 @@ mvneta_update_mib(struct mvneta_softc *sc)
if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS, reg);
 
/* TX watchdog. */
-   if (sc->counter_watchdog_mib > 0 ) {
+   if (sc->counter_watchdog_mib > 0) {
if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 
sc->counter_watchdog_mib);
sc->counter_watchdog_mib = 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: r320157 - head/sys/dev/etherswitch/e6000sw

2017-06-20 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jun 20 18:11:23 2017
New Revision: 320157
URL: https://svnweb.freebsd.org/changeset/base/320157

Log:
  Add support to 2.5G uplink for the MV88E6141 and MV88E6341 switches.
  
  Force the switch port settings for fixed media types.
  
  Tested with:  88E6176, 88E6141
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Tue Jun 20 17:39:24 2017
(r320156)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Tue Jun 20 18:11:23 2017
(r320157)
@@ -71,8 +71,10 @@ typedef struct e6000sw_softc {
device_tmiibus[E6000SW_MAX_PORTS];
struct proc *kproc;
 
+   uint32_tswid;
uint32_tcpuports_mask;
uint32_tfixed_mask;
+   uint32_tfixed25_mask;
uint32_tports_mask;
int phy_base;
int sw_addr;
@@ -126,6 +128,7 @@ static int e6000sw_get_pvid(e6000sw_softc_t *, int, in
 static int e6000sw_set_pvid(e6000sw_softc_t *, int, int);
 static __inline bool e6000sw_is_cpuport(e6000sw_softc_t *, int);
 static __inline bool e6000sw_is_fixedport(e6000sw_softc_t *, int);
+static __inline bool e6000sw_is_fixed25port(e6000sw_softc_t *, int);
 static __inline bool e6000sw_is_phyport(e6000sw_softc_t *, int);
 static __inline bool e6000sw_is_portenabled(e6000sw_softc_t *, int);
 static __inline struct mii_data *e6000sw_miiforphy(e6000sw_softc_t *,
@@ -198,7 +201,6 @@ e6000sw_probe(device_t dev)
e6000sw_softc_t *sc;
const char *description;
phandle_t dsa_node, switch_node;
-   uint32_t id;
 
dsa_node = fdt_find_compatible(OF_finddevice("/"),
"marvell,dsa", 0);
@@ -223,35 +225,35 @@ e6000sw_probe(device_t dev)
 */
sx_init(>sx, "e6000sw_tmp");
E6000SW_LOCK(sc);
-   id = e6000sw_readreg(sc, REG_PORT(0), SWITCH_ID);
+   sc->swid = e6000sw_readreg(sc, REG_PORT(0), SWITCH_ID) & 0xfff0;
E6000SW_UNLOCK(sc);
sx_destroy(>sx);
 
-   switch (id & 0xfff0) {
-   case 0x3400:
+   switch (sc->swid) {
+   case MV88E6141:
description = "Marvell 88E6141";
sc->phy_base = 0x10;
sc->num_ports = 6;
break;
-   case 0x3410:
+   case MV88E6341:
description = "Marvell 88E6341";
sc->phy_base = 0x10;
sc->num_ports = 6;
break;
-   case 0x3520:
+   case MV88E6352:
description = "Marvell 88E6352";
sc->num_ports = 7;
break;
-   case 0x1720:
+   case MV88E6172:
description = "Marvell 88E6172";
sc->num_ports = 7;
break;
-   case 0x1760:
+   case MV88E6176:
description = "Marvell 88E6176";
sc->num_ports = 7;
break;
default:
-   device_printf(dev, "Unrecognized device, id 0x%x.\n", id);
+   device_printf(dev, "Unrecognized device, id 0x%x.\n", sc->swid);
return (ENXIO);
}
 
@@ -261,18 +263,22 @@ e6000sw_probe(device_t dev)
 }
 
 static int
-e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child,
-uint32_t *fixed_mask, uint32_t *cpu_mask, int *pport, int *pvlangroup)
+e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child, int *pport,
+int *pvlangroup)
 {
-   boolean_t fixed_link;
-   char portlabel[100];
+   char *name, *portlabel;
+   int speed;
+   phandle_t fixed_link;
uint32_t port, vlangroup;
 
-   if (fixed_mask == NULL || cpu_mask == NULL || pport == NULL)
+   if (pport == NULL || pvlangroup == NULL)
return (ENXIO);
 
-   OF_getprop(child, "label", (void *)portlabel, sizeof(portlabel));
-   OF_getencprop(child, "reg", (void *), sizeof(port));
+   if (OF_getencprop(child, "reg", (void *), sizeof(port)) < 0)
+   return (ENXIO);
+   if (port >= sc->num_ports)
+   return (ENXIO);
+   *pport = port;
 
if (OF_getencprop(child, "vlangroup", (void *),
sizeof(vlangroup)) > 0) {
@@ -283,22 +289,36 @@ e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t
*pvlangroup = -1;
}
 
-   if (port >= sc->num_ports)
-   return (ENXIO);
-   *pport = port;
-
-   if (strncmp(portlabel, "cpu", 3) == 0) {
-   device_printf(sc->dev, "CPU port at %d\n", port);
-   *cpu_mask |= (1 << port);
+   if (OF_getprop_alloc(child, "label", 1, (void **)) > 0) {
+   if (strncmp(portlabel, "cpu", 3) == 0) {

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

2017-06-12 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jun 13 00:42:23 2017
New Revision: 319886
URL: https://svnweb.freebsd.org/changeset/base/319886

Log:
  Add the initial support for the Marvell 88E6141 and 88E6341 switches.
  
  Right now the driver only supports port VLANs, so make sure
  etherswitch_getinfo() return the proper switch capabilities.
  
  Handle the cases where not all ports are in use (that will also require
  etherswitch cooperation).
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Tue Jun 13 00:31:16 2017
(r319885)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Tue Jun 13 00:42:23 2017
(r319886)
@@ -73,6 +73,8 @@ typedef struct e6000sw_softc {
 
uint32_tcpuports_mask;
uint32_tfixed_mask;
+   uint32_tports_mask;
+   int phy_base;
int sw_addr;
int num_ports;
boolean_t   multi_chip;
@@ -85,6 +87,7 @@ typedef struct e6000sw_softc {
 static etherswitch_info_t etherswitch_info = {
.es_nports =0,
.es_nvlangroups =   E6000SW_NUM_VGROUPS,
+   .es_vlan_caps = ETHERSWITCH_VLAN_PORT,
.es_name =  "Marvell 6000 series switch"
 };
 
@@ -95,6 +98,7 @@ static int e6000sw_detach(device_t);
 static int e6000sw_readphy(device_t, int, int);
 static int e6000sw_writephy(device_t, int, int, int);
 static etherswitch_info_t* e6000sw_getinfo(device_t);
+static int e6000sw_getconf(device_t, etherswitch_conf_t *);
 static void e6000sw_lock(device_t);
 static void e6000sw_unlock(device_t);
 static int e6000sw_getport(device_t, etherswitch_port_t *);
@@ -123,6 +127,7 @@ static int e6000sw_set_pvid(e6000sw_softc_t *, int, in
 static __inline bool e6000sw_is_cpuport(e6000sw_softc_t *, int);
 static __inline bool e6000sw_is_fixedport(e6000sw_softc_t *, int);
 static __inline bool e6000sw_is_phyport(e6000sw_softc_t *, int);
+static __inline bool e6000sw_is_portenabled(e6000sw_softc_t *, int);
 static __inline struct mii_data *e6000sw_miiforphy(e6000sw_softc_t *,
 unsigned int);
 
@@ -142,6 +147,7 @@ static device_method_t e6000sw_methods[] = {
 
/* etherswitch interface */
DEVMETHOD(etherswitch_getinfo,  e6000sw_getinfo),
+   DEVMETHOD(etherswitch_getconf,  e6000sw_getconf),
DEVMETHOD(etherswitch_lock, e6000sw_lock),
DEVMETHOD(etherswitch_unlock,   e6000sw_unlock),
DEVMETHOD(etherswitch_getport,  e6000sw_getport),
@@ -202,7 +208,6 @@ e6000sw_probe(device_t dev)
return (ENXIO);
 
sc = device_get_softc(dev);
-   bzero(sc, sizeof(e6000sw_softc_t));
sc->dev = dev;
sc->node = switch_node;
 
@@ -219,14 +224,27 @@ e6000sw_probe(device_t dev)
E6000SW_UNLOCK(sc);
 
switch (id & 0xfff0) {
+   case 0x3400:
+   description = "Marvell 88E6141";
+   sc->phy_base = 0x10;
+   sc->num_ports = 6;
+   break;
+   case 0x3410:
+   description = "Marvell 88E6341";
+   sc->phy_base = 0x10;
+   sc->num_ports = 6;
+   break;
case 0x3520:
description = "Marvell 88E6352";
+   sc->num_ports = 7;
break;
case 0x1720:
description = "Marvell 88E6172";
+   sc->num_ports = 7;
break;
case 0x1760:
description = "Marvell 88E6176";
+   sc->num_ports = 7;
break;
default:
sx_destroy(>sx);
@@ -240,17 +258,17 @@ e6000sw_probe(device_t dev)
 }
 
 static int
-e6000sw_parse_child_fdt(device_t dev, phandle_t child, uint32_t *fixed_mask,
-uint32_t *cpu_mask, int *pport, int *pvlangroup)
+e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child,
+uint32_t *fixed_mask, uint32_t *cpu_mask, int *pport, int *pvlangroup)
 {
+   boolean_t fixed_link;
char portlabel[100];
uint32_t port, vlangroup;
-   boolean_t fixed_link;
 
if (fixed_mask == NULL || cpu_mask == NULL || pport == NULL)
return (ENXIO);
 
-   OF_getprop(child, "label", (void *)portlabel, 100);
+   OF_getprop(child, "label", (void *)portlabel, sizeof(portlabel));
OF_getencprop(child, "reg", (void *), sizeof(port));
 
if (OF_getencprop(child, "vlangroup", (void *),
@@ -262,22 +280,21 @@ e6000sw_parse_child_fdt(device_t dev, phandle_t child,
*pvlangroup = -1;
}
 
-   if (port >= E6000SW_MAX_PORTS)
+   if (port >= sc->num_ports)
return (ENXIO);
*pport = port;
 
if 

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

2017-06-12 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jun 12 22:53:18 2017
New Revision: 319881
URL: https://svnweb.freebsd.org/changeset/base/319881

Log:
  Update the current version of netmap to bring it in sync with the github
  version.
  
  This commit contains mostly refactoring, a few fixes and minor added
  functionality.
  
  Submitted by: Vincenzo Maffione 
  Requested by: many
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/netmap/if_ixl_netmap.h
  head/sys/dev/netmap/netmap.c
  head/sys/dev/netmap/netmap_freebsd.c
  head/sys/dev/netmap/netmap_generic.c
  head/sys/dev/netmap/netmap_kern.h
  head/sys/dev/netmap/netmap_mbq.h
  head/sys/dev/netmap/netmap_mem2.c
  head/sys/dev/netmap/netmap_mem2.h
  head/sys/dev/netmap/netmap_monitor.c
  head/sys/dev/netmap/netmap_pipe.c
  head/sys/dev/netmap/netmap_pt.c
  head/sys/dev/netmap/netmap_vale.c

Modified: head/sys/dev/netmap/if_ixl_netmap.h
==
--- head/sys/dev/netmap/if_ixl_netmap.h Mon Jun 12 21:31:26 2017
(r319880)
+++ head/sys/dev/netmap/if_ixl_netmap.h Mon Jun 12 22:53:18 2017
(r319881)
@@ -129,7 +129,7 @@ ixl_netmap_attach(struct ixl_vsi *vsi)
na.ifp = vsi->ifp;
na.na_flags = NAF_BDG_MAYSLEEP;
// XXX check that queues is set.
-   printf("queues is %p\n", vsi->queues);
+   nm_prinf("queues is %p\n", vsi->queues);
if (vsi->queues) {
na.num_tx_desc = vsi->queues[0].num_desc;
na.num_rx_desc = vsi->queues[0].num_desc;

Modified: head/sys/dev/netmap/netmap.c
==
--- head/sys/dev/netmap/netmap.cMon Jun 12 21:31:26 2017
(r319880)
+++ head/sys/dev/netmap/netmap.cMon Jun 12 22:53:18 2017
(r319881)
@@ -388,7 +388,7 @@ ports attached to the switch)
  *
  *  - VALE ports:
  * concurrently:
- * 1) ioctlNIOCRXSYNC)/netmap_poll() in process context
+ * 1) ioctl(NIOCRXSYNC)/netmap_poll() in process context
  *kring->nm_sync() == netmap_vp_rxsync()
  * 2) from nm_bdg_flush()
  *na->nm_notify() == netmap_notify()
@@ -484,7 +484,7 @@ int netmap_mitigate = 1;
 int netmap_no_pendintr = 1;
 int netmap_txsync_retry = 2;
 int netmap_flags = 0;  /* debug flags */
-static int netmap_fwd = 0; /* force transparent mode */
+static int netmap_fwd = 0; /* force transparent forwarding */
 
 /*
  * netmap_admode selects the netmap mode to use.
@@ -522,6 +522,9 @@ int netmap_generic_rings = 1;
 /* Non-zero if ptnet devices are allowed to use virtio-net headers. */
 int ptnet_vnet_hdr = 1;
 
+/* 0 if ptnetmap should not use worker threads for TX processing */
+int ptnetmap_tx_workers = 1;
+
 /*
  * SYSCTL calls are grouped between SYSBEGIN and SYSEND to be emulated
  * in some other operating systems
@@ -548,6 +551,7 @@ SYSCTL_INT(_dev_netmap, OID_AUTO, generic_ringsize, CT
 SYSCTL_INT(_dev_netmap, OID_AUTO, generic_rings, CTLFLAG_RW, 
_generic_rings, 0 , "");
 SYSCTL_INT(_dev_netmap, OID_AUTO, generic_txqdisc, CTLFLAG_RW, 
_generic_txqdisc, 0 , "");
 SYSCTL_INT(_dev_netmap, OID_AUTO, ptnet_vnet_hdr, CTLFLAG_RW, _vnet_hdr, 
0 , "");
+SYSCTL_INT(_dev_netmap, OID_AUTO, ptnetmap_tx_workers, CTLFLAG_RW, 
_tx_workers, 0 , "");
 
 SYSEND;
 
@@ -669,7 +673,7 @@ nm_bound_var(u_int *v, u_int dflt, u_int lo, u_int hi,
op = "Clamp";
}
if (op && msg)
-   printf("%s %s to %d (was %d)\n", op, msg, *v, oldv);
+   nm_prinf("%s %s to %d (was %d)\n", op, msg, *v, oldv);
return *v;
 }
 
@@ -801,13 +805,18 @@ netmap_krings_create(struct netmap_adapter *na, u_int 
u_int n[NR_TXRX];
enum txrx t;
 
+   if (na->tx_rings != NULL) {
+   D("warning: krings were already created");
+   return 0;
+   }
+
/* account for the (possibly fake) host rings */
n[NR_TX] = na->num_tx_rings + 1;
n[NR_RX] = na->num_rx_rings + 1;
 
len = (n[NR_TX] + n[NR_RX]) * sizeof(struct netmap_kring) + tailroom;
 
-   na->tx_rings = malloc((size_t)len, M_DEVBUF, M_NOWAIT | M_ZERO);
+   na->tx_rings = nm_os_malloc((size_t)len);
if (na->tx_rings == NULL) {
D("Cannot allocate krings");
return ENOMEM;
@@ -866,6 +875,11 @@ netmap_krings_delete(struct netmap_adapter *na)
struct netmap_kring *kring = na->tx_rings;
enum txrx t;
 
+   if (na->tx_rings == NULL) {
+   D("warning: krings were already deleted");
+   return;
+   }
+
for_rx_tx(t)
nm_os_selinfo_uninit(>si[t]);
 
@@ -874,7 +888,7 @@ netmap_krings_delete(struct netmap_adapter *na)
mtx_destroy(>q_lock);
nm_os_selinfo_uninit(>si);
}
-   free(na->tx_rings, M_DEVBUF);
+   nm_os_free(na->tx_rings);
na->tx_rings = 

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

2017-06-09 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jun  9 20:38:18 2017
New Revision: 319760
URL: https://svnweb.freebsd.org/changeset/base/319760

Log:
  Remove an unnecessary variable from the switch softc structure and make the
  functions that are used as booleans return real boolean values.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Fri Jun  9 20:26:42 2017
(r319759)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Fri Jun  9 20:38:18 2017
(r319760)
@@ -69,7 +69,6 @@ typedef struct e6000sw_softc {
struct ifnet*ifp[E6000SW_MAX_PORTS];
char*ifname[E6000SW_MAX_PORTS];
device_tmiibus[E6000SW_MAX_PORTS];
-   struct mii_data *mii[E6000SW_MAX_PORTS];
struct proc *kproc;
 
uint32_tcpuports_mask;
@@ -121,9 +120,9 @@ static int e6000sw_atu_mac_table(device_t, e6000sw_sof
 int);
 static int e6000sw_get_pvid(e6000sw_softc_t *, int, int *);
 static int e6000sw_set_pvid(e6000sw_softc_t *, int, int);
-static __inline int e6000sw_is_cpuport(e6000sw_softc_t *, int);
-static __inline int e6000sw_is_fixedport(e6000sw_softc_t *, int);
-static __inline int e6000sw_is_phyport(e6000sw_softc_t *, int);
+static __inline bool e6000sw_is_cpuport(e6000sw_softc_t *, int);
+static __inline bool e6000sw_is_fixedport(e6000sw_softc_t *, int);
+static __inline bool e6000sw_is_phyport(e6000sw_softc_t *, int);
 static __inline struct mii_data *e6000sw_miiforphy(e6000sw_softc_t *,
 unsigned int);
 
@@ -278,7 +277,7 @@ e6000sw_parse_child_fdt(device_t dev, phandle_t child,
*fixed_mask |= (1 << port);
device_printf(dev, "fixed port at %d\n", port);
} else {
-   device_printf(dev, "PHY at %d\n", port);
+   device_printf(dev, "PHY at port %d\n", port);
}
 
return (0);
@@ -319,7 +318,6 @@ e6000sw_attach_miibus(e6000sw_softc_t *sc, int port)
if (err != 0)
return (err);
 
-   sc->mii[port] = device_get_softc(sc->miibus[port]);
return (0);
 }
 
@@ -413,8 +411,8 @@ e6000sw_poll_done(e6000sw_softc_t *sc)
 
for (i = 0; i < E6000SW_SMI_TIMEOUT; i++) {
 
-   if (!(e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_CMD_REG) &
-   (1 << PHY_CMD_SMI_BUSY)))
+   if ((e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_CMD_REG) &
+   (1 << PHY_CMD_SMI_BUSY)) == 0)
return (0);
 
pause("e6000sw PHY poll", hz/1000);
@@ -915,27 +913,27 @@ e6000sw_writereg(e6000sw_softc_t *sc, int addr, int re
}
 }
 
-static __inline int
+static __inline bool
 e6000sw_is_cpuport(e6000sw_softc_t *sc, int port)
 {
 
-   return (sc->cpuports_mask & (1 << port));
+   return ((sc->cpuports_mask & (1 << port)) ? true : false);
 }
 
-static __inline int
+static __inline bool
 e6000sw_is_fixedport(e6000sw_softc_t *sc, int port)
 {
 
-   return (sc->fixed_mask & (1 << port));
+   return ((sc->fixed_mask & (1 << port)) ? true : false);
 }
 
-static __inline int
+static __inline bool
 e6000sw_is_phyport(e6000sw_softc_t *sc, int port)
 {
uint32_t phy_mask;
phy_mask = ~(sc->fixed_mask | sc->cpuports_mask);
 
-   return (phy_mask & (1 << port));
+   return ((phy_mask & (1 << port)) ? true : false);
 }
 
 static __inline int
@@ -999,6 +997,7 @@ static void
 e6000sw_tick (void *arg)
 {
e6000sw_softc_t *sc;
+   struct mii_data *mii;
struct mii_softc *miisc;
uint16_t portstatus;
int port;
@@ -1014,14 +1013,18 @@ e6000sw_tick (void *arg)
if (!e6000sw_is_phyport(sc, port))
continue;
 
-   portstatus = e6000sw_readreg(sc, REG_PORT(port), 
PORT_STATUS);
+   mii = e6000sw_miiforphy(sc, port);
+   if (mii == NULL)
+   continue;
 
+   portstatus = e6000sw_readreg(sc, REG_PORT(port),
+   PORT_STATUS);
+
e6000sw_update_ifmedia(portstatus,
-   >mii[port]->mii_media_status,
-   >mii[port]->mii_media_active);
+   >mii_media_status, >mii_media_active);
 
-   LIST_FOREACH(miisc, >mii[port]->mii_phys, mii_list) 
{
-   if 
(IFM_INST(sc->mii[port]->mii_media.ifm_cur->ifm_media)
+   LIST_FOREACH(miisc, >mii_phys, mii_list) {
+   if (IFM_INST(mii->mii_media.ifm_cur->ifm_media)
!= miisc->mii_inst)
continue;
   

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

2017-06-02 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Jun  2 15:12:32 2017
New Revision: 319498
URL: https://svnweb.freebsd.org/changeset/base/319498

Log:
  style(9) fixes, remove unnecessary headers, remove duplicate #defines and
  in some cases, shuffle the code around to simplify locking.
  
  No functional changes.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Fri Jun  2 15:11:43 2017
(r319497)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Fri Jun  2 15:12:32 2017
(r319498)
@@ -28,40 +28,25 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
 #include 
-#include 
-#include 
+#include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 
 #include 
 #include 
 #include 
 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
 #include 
-#include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
-#include 
 
 #include "e6000swreg.h"
 #include "etherswitch_if.h"
@@ -71,14 +56,10 @@ __FBSDID("$FreeBSD$");
 MALLOC_DECLARE(M_E6000SW);
 MALLOC_DEFINE(M_E6000SW, "e6000sw", "e6000sw switch");
 
-#define E6000SW_LOCK(_sc)  \
-   sx_xlock(&(_sc)->sx)
-#define E6000SW_UNLOCK(_sc)\
-   sx_unlock(&(_sc)->sx)
-#define E6000SW_LOCK_ASSERT(_sc, _what)\
-   sx_assert(&(_sc)->sx, (_what))
-#define E6000SW_TRYLOCK(_sc)   \
-   sx_tryxlock(&(_sc)->sx)
+#defineE6000SW_LOCK(_sc)   sx_xlock(&(_sc)->sx)
+#defineE6000SW_UNLOCK(_sc) sx_unlock(&(_sc)->sx)
+#defineE6000SW_LOCK_ASSERT(_sc, _what) sx_assert(&(_sc)->sx, (_what))
+#defineE6000SW_TRYLOCK(_sc)sx_tryxlock(&(_sc)->sx)
 
 typedef struct e6000sw_softc {
device_tdev;
@@ -108,46 +89,43 @@ static etherswitch_info_t etherswitch_info = {
.es_name =  "Marvell 6000 series switch"
 };
 
-static void e6000sw_identify(driver_t *driver, device_t parent);
-static int e6000sw_probe(device_t dev);
-static int e6000sw_attach(device_t dev);
-static int e6000sw_detach(device_t dev);
-static int e6000sw_readphy(device_t dev, int phy, int reg);
-static int e6000sw_writephy(device_t dev, int phy, int reg, int data);
-static etherswitch_info_t* e6000sw_getinfo(device_t dev);
-static void e6000sw_lock(device_t dev);
-static void e6000sw_unlock(device_t dev);
-static int e6000sw_getport(device_t dev, etherswitch_port_t *p);
-static int e6000sw_setport(device_t dev, etherswitch_port_t *p);
-static int e6000sw_readreg_wrapper(device_t dev, int addr_reg);
-static int e6000sw_writereg_wrapper(device_t dev, int addr_reg, int val);
-static int e6000sw_readphy_wrapper(device_t dev, int phy, int reg);
-static int e6000sw_writephy_wrapper(device_t dev, int phy, int reg, int data);
-static int e6000sw_getvgroup_wrapper(device_t dev, etherswitch_vlangroup_t 
*vg);
-static int e6000sw_setvgroup_wrapper(device_t dev, etherswitch_vlangroup_t 
*vg);
-static int e6000sw_setvgroup(device_t dev, etherswitch_vlangroup_t *vg);
-static int e6000sw_getvgroup(device_t dev, etherswitch_vlangroup_t *vg);
-static void e6000sw_setup(device_t dev, e6000sw_softc_t *sc);
-static void e6000sw_port_vlan_conf(e6000sw_softc_t *sc);
-static void e6000sw_tick(void *arg);
-static void e6000sw_set_atustat(device_t dev, e6000sw_softc_t *sc, int bin,
-int flag);
-static int e6000sw_atu_flush(device_t dev, e6000sw_softc_t *sc, int flag);
-static __inline void e6000sw_writereg(e6000sw_softc_t *sc, int addr, int reg,
-int val);
-static __inline uint32_t e6000sw_readreg(e6000sw_softc_t *sc, int addr,
-int reg);
-static int e6000sw_ifmedia_upd(struct ifnet *ifp);
-static void e6000sw_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
-static int e6000sw_atu_mac_table(device_t dev, e6000sw_softc_t *sc, struct
-atu_opt *atu, int flag);
-static int e6000sw_get_pvid(e6000sw_softc_t *sc, int port, int *pvid);
-static int e6000sw_set_pvid(e6000sw_softc_t *sc, int port, int pvid);
-static __inline int e6000sw_is_cpuport(e6000sw_softc_t *sc, int port);
-static __inline int e6000sw_is_fixedport(e6000sw_softc_t *sc, int port);
-static __inline int e6000sw_is_phyport(e6000sw_softc_t *sc, int port);
-static __inline struct mii_data *e6000sw_miiforphy(e6000sw_softc_t *sc,
-unsigned int phy);
+static void e6000sw_identify(driver_t *, device_t);
+static int e6000sw_probe(device_t);
+static int e6000sw_attach(device_t);
+static int e6000sw_detach(device_t);
+static int e6000sw_readphy(device_t, int, int);
+static int e6000sw_writephy(device_t, int, int, int);
+static etherswitch_info_t* e6000sw_getinfo(device_t);
+static void 

svn commit: r318428 - head/sys/boot/fdt/dts/arm

2017-05-17 Thread Luiz Otavio O Souza
Author: loos
Date: Wed May 17 22:05:07 2017
New Revision: 318428
URL: https://svnweb.freebsd.org/changeset/base/318428

Log:
  Fix the offset for the CPU0 MPIC registers.
  
  Please note that only a subset of CPU0 registers are exported.  CPU1
  registers are not touched.
  
  Obtained from:ARMADA38X Functional Specifications
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/boot/fdt/dts/arm/armada-38x.dtsi

Modified: head/sys/boot/fdt/dts/arm/armada-38x.dtsi
==
--- head/sys/boot/fdt/dts/arm/armada-38x.dtsi   Wed May 17 21:33:37 2017
(r318427)
+++ head/sys/boot/fdt/dts/arm/armada-38x.dtsi   Wed May 17 22:05:07 2017
(r318428)
@@ -419,7 +419,7 @@
 
mpic: interrupt-controller@20a00 {
compatible = "marvell,mpic";
-   reg = <0x20a00 0x2d0>, <0x21070 0x58>;
+   reg = <0x20a00 0x2d0>, <0x21870 0x58>;
#interrupt-cells = <1>;
#size-cells = <1>;
interrupt-controller;
___
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: r318426 - head/sys/arm/mv

2017-05-17 Thread Luiz Otavio O Souza
Author: loos
Date: Wed May 17 21:14:27 2017
New Revision: 318426
URL: https://svnweb.freebsd.org/changeset/base/318426

Log:
  Use the MACROS to access the Global mpic registers.  Makes the code
  consistent and easier to read.
  
  While here, remove two unused static functions and fix a unused function
  warning when building !INTRNG.
  
  No functional changes.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/arm/mv/mpic.c
==
--- head/sys/arm/mv/mpic.c  Wed May 17 20:23:27 2017(r318425)
+++ head/sys/arm/mv/mpic.c  Wed May 17 21:14:27 2017(r318426)
@@ -148,12 +148,10 @@ static void   mpic_unmask_irq(uintptr_t nb
 static voidmpic_mask_irq(uintptr_t nb);
 static voidmpic_mask_irq_err(uintptr_t nb);
 static voidmpic_unmask_irq_err(uintptr_t nb);
+#ifdef INTRNG
 static int mpic_intr(void *arg);
-static voidmpic_unmask_msi(void);
-#ifndef INTRNG
-static voidarm_mask_irq_err(uintptr_t);
-static voidarm_unmask_irq_err(uintptr_t);
 #endif
+static voidmpic_unmask_msi(void);
 
 #defineMPIC_WRITE(softc, reg, val) \
 bus_space_write_4((softc)->mpic_bst, (softc)->mpic_bsh, (reg), (val))
@@ -260,8 +258,7 @@ mv_mpic_attach(device_t dev)
sc->drbl_bsh = rman_get_bushandle(sc->mpic_res[2]);
}
 
-   bus_space_write_4(mv_mpic_sc->mpic_bst, mv_mpic_sc->mpic_bsh,
-   MPIC_CTRL, 1);
+   MPIC_WRITE(mv_mpic_sc, MPIC_CTRL, 1);
MPIC_CPU_WRITE(mv_mpic_sc, MPIC_CTP, 0);
 
val = MPIC_READ(mv_mpic_sc, MPIC_CTRL);
@@ -435,27 +432,12 @@ arm_mask_irq(uintptr_t nb)
mpic_mask_irq(nb);
 }
 
-
-static void
-arm_mask_irq_err(uintptr_t nb)
-{
-
-   mpic_mask_irq_err(nb);
-}
-
 void
 arm_unmask_irq(uintptr_t nb)
 {
 
mpic_unmask_irq(nb);
 }
-
-void
-arm_unmask_irq_err(uintptr_t nb)
-{
-
-   mpic_unmask_irq_err(nb);
-}
 #endif
 
 static void
@@ -471,8 +453,7 @@ mpic_unmask_irq_err(uintptr_t nb)
uint32_t mask;
uint8_t bit_off;
 
-   bus_space_write_4(mv_mpic_sc->mpic_bst, mv_mpic_sc->mpic_bsh,
-   MPIC_ISE, MPIC_INT_ERR);
+   MPIC_WRITE(mv_mpic_sc, MPIC_ISE, MPIC_INT_ERR);
MPIC_CPU_WRITE(mv_mpic_sc, MPIC_ICM, MPIC_INT_ERR);
 
bit_off = nb - ERR_IRQ;
@@ -498,8 +479,7 @@ mpic_unmask_irq(uintptr_t nb)
 {
 
if (nb < ERR_IRQ) {
-   bus_space_write_4(mv_mpic_sc->mpic_bst, mv_mpic_sc->mpic_bsh,
-   MPIC_ISE, nb);
+   MPIC_WRITE(mv_mpic_sc, MPIC_ISE, nb);
MPIC_CPU_WRITE(mv_mpic_sc, MPIC_ICM, nb);
} else if (nb < MSI_IRQ)
mpic_unmask_irq_err(nb);
@@ -513,8 +493,7 @@ mpic_mask_irq(uintptr_t nb)
 {
 
if (nb < ERR_IRQ) {
-   bus_space_write_4(mv_mpic_sc->mpic_bst, mv_mpic_sc->mpic_bsh,
-   MPIC_ICE, nb);
+   MPIC_WRITE(mv_mpic_sc, MPIC_ICE, nb);
MPIC_CPU_WRITE(mv_mpic_sc, MPIC_ISM, nb);
} else if (nb < MSI_IRQ)
mpic_mask_irq_err(nb);
@@ -533,8 +512,7 @@ mv_mpic_get_cause_err(void)
uint32_t err_cause;
uint8_t bit_off;
 
-   err_cause = bus_space_read_4(mv_mpic_sc->mpic_bst,
-   mv_mpic_sc->mpic_bsh, MPIC_ERR_CAUSE);
+   err_cause = MPIC_READ(mv_mpic_sc, MPIC_ERR_CAUSE);
 
if (err_cause)
bit_off = ffs(err_cause) - 1;
@@ -615,8 +593,7 @@ pic_ipi_send(cpuset_t cpus, u_int ipi)
if (CPU_ISSET(i, ))
val |= (1 << (8 + i));
val |= ipi;
-   bus_space_write_4(mv_mpic_sc->mpic_bst, mv_mpic_sc->mpic_bsh,
-   MPIC_SOFT_INT, val);
+   MPIC_WRITE(mv_mpic_sc, MPIC_SOFT_INT, val);
 }
 
 int
___
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: r318404 - head/sys/arm/mv

2017-05-17 Thread Luiz Otavio O Souza
Author: loos
Date: Wed May 17 15:13:01 2017
New Revision: 318404
URL: https://svnweb.freebsd.org/changeset/base/318404

Log:
  Move the IO Window Control Register defines out of the ARMADA38X ifdef.
  
  Fixes the build of Marvell kernels (other than ARMADA38X) after r318336.
  
  Reported by:  mmel

Modified:
  head/sys/arm/mv/mvwin.h

Modified: head/sys/arm/mv/mvwin.h
==
--- head/sys/arm/mv/mvwin.h Wed May 17 14:35:21 2017(r318403)
+++ head/sys/arm/mv/mvwin.h Wed May 17 15:13:01 2017(r318404)
@@ -305,18 +305,6 @@
 #defineMV_BOOTROM_WIN_SIZE 0xF
 #defineMV_CPU_SUBSYS_REGS_LEN  0x100
 
-/* IO Window Control Register fields */
-#defineIO_WIN_SIZE_SHIFT   16
-#defineIO_WIN_SIZE_MASK0x
-#defineIO_WIN_ATTR_SHIFT   8
-#defineIO_WIN_ATTR_MASK0xFF
-#defineIO_WIN_TGT_SHIFT4
-#defineIO_WIN_TGT_MASK 0xF
-#defineIO_WIN_SYNC_SHIFT   1
-#defineIO_WIN_SYNC_MASK0x1
-#defineIO_WIN_ENA_SHIFT0
-#defineIO_WIN_ENA_MASK 0x1
-
 #defineIO_WIN_9_CTRL_OFFSET0x98
 #defineIO_WIN_9_BASE_OFFSET0x9C
 
@@ -329,6 +317,18 @@
 #defineMV_SYNC_BARRIER_CTRL_ALL0x
 #endif
 
+/* IO Window Control Register fields */
+#defineIO_WIN_SIZE_SHIFT   16
+#defineIO_WIN_SIZE_MASK0x
+#defineIO_WIN_ATTR_SHIFT   8
+#defineIO_WIN_ATTR_MASK0xFF
+#defineIO_WIN_TGT_SHIFT4
+#defineIO_WIN_TGT_MASK 0xF
+#defineIO_WIN_SYNC_SHIFT   1
+#defineIO_WIN_SYNC_MASK0x1
+#defineIO_WIN_ENA_SHIFT0
+#defineIO_WIN_ENA_MASK 0x1
+
 #define WIN_REG_IDX_RD(pre,reg,off,base)   
\
static __inline uint32_t
\
pre ## _ ## reg ## _read(int i) 
\
___
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: r318337 - in head/sys: arm/conf arm/mv/armada38x dev/sdhci

2017-05-15 Thread Luiz Otavio O Souza
Author: loos
Date: Tue May 16 05:10:15 2017
New Revision: 318337
URL: https://svnweb.freebsd.org/changeset/base/318337

Log:
  Add the Marvell SDHCI controller to the list of supported devices in
  sdhci_fdt.
  
  Enable the SDHCI controller, bus and devices on ARMADA38X kernel.
  
  Tested on:ClearFog Pro
  Reviewed by:  Marcin Wojtas 
  Sponsored by: Rubicon Communications, LLC (Netgate)
  Differential Revision:https://reviews.freebsd.org/D10606

Modified:
  head/sys/arm/conf/ARMADA38X
  head/sys/arm/mv/armada38x/files.armada38x
  head/sys/dev/sdhci/sdhci_fdt.c

Modified: head/sys/arm/conf/ARMADA38X
==
--- head/sys/arm/conf/ARMADA38X Tue May 16 04:47:50 2017(r318336)
+++ head/sys/arm/conf/ARMADA38X Tue May 16 05:10:15 2017(r318337)
@@ -63,6 +63,11 @@ device   scbus
 device pass
 device da
 
+# MMC/SD/SDIO Card slot support
+device mmc # mmc/sd bus
+device mmcsd   # mmc/sd flash cards
+device sdhci   # mmc/sd host controller
+
 # SATA
 device ahci
 

Modified: head/sys/arm/mv/armada38x/files.armada38x
==
--- head/sys/arm/mv/armada38x/files.armada38x   Tue May 16 04:47:50 2017
(r318336)
+++ head/sys/arm/mv/armada38x/files.armada38x   Tue May 16 05:10:15 2017
(r318337)
@@ -8,3 +8,4 @@ arm/mv/armada38x/armada38x_mp.c optional
 arm/mv/armada38x/pmsu.cstandard
 arm/mv/armada38x/rtc.c standard
 arm/mv/armada38x/armada38x_pl310.c optional pl310
+dev/sdhci/sdhci_fdt.c  optional sdhci

Modified: head/sys/dev/sdhci/sdhci_fdt.c
==
--- head/sys/dev/sdhci/sdhci_fdt.c  Tue May 16 04:47:50 2017
(r318336)
+++ head/sys/dev/sdhci/sdhci_fdt.c  Tue May 16 05:10:15 2017
(r318337)
@@ -57,7 +57,17 @@ __FBSDID("$FreeBSD$");
 #include "mmcbr_if.h"
 #include "sdhci_if.h"
 
-#defineMAX_SLOTS   6
+#defineMAX_SLOTS   6
+#defineSDHCI_FDT_ARMADA38X 1
+#defineSDHCI_FDT_GENERIC   2
+#defineSDHCI_FDT_XLNX_ZY7  3
+
+static struct ofw_compat_data compat_data[] = {
+   { "marvell,armada-380-sdhci",   SDHCI_FDT_ARMADA38X },
+   { "sdhci_generic",  SDHCI_FDT_GENERIC },
+   { "xlnx,zy7_sdhci", SDHCI_FDT_XLNX_ZY7 },
+   { NULL, 0 }
+};
 
 struct sdhci_fdt_softc {
device_tdev;/* Controller device */
@@ -181,13 +191,21 @@ sdhci_fdt_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
 
-   if (ofw_bus_is_compatible(dev, "sdhci_generic")) {
+   switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) {
+   case SDHCI_FDT_ARMADA38X:
+   sc->quirks = SDHCI_QUIRK_BROKEN_AUTO_STOP;
+   device_set_desc(dev, "ARMADA38X SDHCI controller");
+   break;
+   case SDHCI_FDT_GENERIC:
device_set_desc(dev, "generic fdt SDHCI controller");
-   } else if (ofw_bus_is_compatible(dev, "xlnx,zy7_sdhci")) {
+   break;
+   case SDHCI_FDT_XLNX_ZY7:
sc->quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
device_set_desc(dev, "Zynq-7000 generic fdt SDHCI controller");
-   } else
+   break;
+   default:
return (ENXIO);
+   }
 
node = ofw_bus_get_node(dev);
 
___
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: r318336 - head/sys/arm/mv

2017-05-15 Thread Luiz Otavio O Souza
Author: loos
Date: Tue May 16 04:47:50 2017
New Revision: 318336
URL: https://svnweb.freebsd.org/changeset/base/318336

Log:
  Add the SDHCI Address Decoder registers and routines for ARMADA 38X.
  
  Tested on:ClearFog Pro
  Reviewed by:  Marcin Wojtas 
  Sponsored by: Rubicon Communications, LLC (Netgate)
  Differential Revision:https://reviews.freebsd.org/D10601

Modified:
  head/sys/arm/mv/mv_common.c
  head/sys/arm/mv/mvwin.h

Modified: head/sys/arm/mv/mv_common.c
==
--- head/sys/arm/mv/mv_common.c Tue May 16 03:31:49 2017(r318335)
+++ head/sys/arm/mv/mv_common.c Tue May 16 04:47:50 2017(r318336)
@@ -82,6 +82,7 @@ static int decode_win_usb3_valid(void);
 static int decode_win_eth_valid(void);
 static int decode_win_pcie_valid(void);
 static int decode_win_sata_valid(void);
+static int decode_win_sdhci_valid(void);
 
 static int decode_win_idma_valid(void);
 static int decode_win_xor_valid(void);
@@ -95,6 +96,7 @@ static void decode_win_usb3_setup(u_long
 static void decode_win_eth_setup(u_long);
 static void decode_win_sata_setup(u_long);
 static void decode_win_ahci_setup(u_long);
+static void decode_win_sdhci_setup(u_long);
 
 static void decode_win_idma_setup(u_long);
 static void decode_win_xor_setup(u_long);
@@ -105,6 +107,7 @@ static void decode_win_eth_dump(u_long b
 static void decode_win_idma_dump(u_long base);
 static void decode_win_xor_dump(u_long base);
 static void decode_win_ahci_dump(u_long base);
+static void decode_win_sdhci_dump(u_long);
 
 static int fdt_get_ranges(const char *, void *, int, int *, int *);
 #ifdef SOC_MV_ARMADA38X
@@ -138,6 +141,7 @@ static struct soc_node_spec soc_nodes[] 
{ "mrvl,usb-ehci", _win_usb_setup, _win_usb_dump },
{ "marvell,armada-380-xhci", _win_usb3_setup, 
_win_usb3_dump },
{ "marvell,armada-380-ahci", _win_ahci_setup, 
_win_ahci_dump },
+   { "marvell,armada-380-sdhci", _win_sdhci_setup, 
_win_sdhci_dump },
{ "mrvl,sata", _win_sata_setup, NULL },
{ "mrvl,xor", _win_xor_setup, _win_xor_dump },
{ "mrvl,idma", _win_idma_setup, _win_idma_dump },
@@ -568,7 +572,8 @@ soc_decode_win(void)
if (!decode_win_cpu_valid() || !decode_win_usb_valid() ||
!decode_win_eth_valid() || !decode_win_idma_valid() ||
!decode_win_pcie_valid() || !decode_win_sata_valid() ||
-   !decode_win_xor_valid() || !decode_win_usb3_valid())
+   !decode_win_xor_valid() || !decode_win_usb3_valid() ||
+   !decode_win_sdhci_valid())
return (EINVAL);
 
decode_win_cpu_setup();
@@ -659,6 +664,11 @@ WIN_REG_BASE_IDX_RD(win_sata, sz, MV_WIN
 WIN_REG_BASE_IDX_WR(win_sata, sz, MV_WIN_SATA_SIZE);
 #endif
 
+WIN_REG_BASE_IDX_RD(win_sdhci, cr, MV_WIN_SDHCI_CTRL);
+WIN_REG_BASE_IDX_RD(win_sdhci, br, MV_WIN_SDHCI_BASE);
+WIN_REG_BASE_IDX_WR(win_sdhci, cr, MV_WIN_SDHCI_CTRL);
+WIN_REG_BASE_IDX_WR(win_sdhci, br, MV_WIN_SDHCI_BASE);
+
 #ifndef SOC_MV_DOVE
 WIN_REG_IDX_RD(ddr, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE)
 WIN_REG_IDX_RD(ddr, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE)
@@ -2073,6 +2083,60 @@ decode_win_sata_valid(void)
return (decode_win_can_cover_ddr(MV_WIN_SATA_MAX));
 }
 
+static void
+decode_win_sdhci_setup(u_long base)
+{
+   uint32_t cr, br;
+   int i, j;
+
+   for (i = 0; i < MV_WIN_SDHCI_MAX; i++) {
+   win_sdhci_cr_write(base, i, 0);
+   win_sdhci_br_write(base, i, 0);
+   }
+
+   for (i = 0; i < MV_WIN_DDR_MAX; i++)
+   if (ddr_is_active(i)) {
+   br = ddr_base(i);
+   cr = (((ddr_size(i) - 1) &
+   (IO_WIN_SIZE_MASK << IO_WIN_SIZE_SHIFT)) |
+   (ddr_attr(i) << IO_WIN_ATTR_SHIFT) |
+   (ddr_target(i) << IO_WIN_TGT_SHIFT) |
+   IO_WIN_ENA_MASK);
+
+   /* Use the first available SDHCI window */
+   for (j = 0; j < MV_WIN_SDHCI_MAX; j++) {
+   if (win_sdhci_cr_read(base, j) & 
IO_WIN_ENA_MASK)
+   continue;
+
+   win_sdhci_cr_write(base, j, cr);
+   win_sdhci_br_write(base, j, br);
+   break;
+   }
+   }
+}
+
+static void
+decode_win_sdhci_dump(u_long base)
+{
+   int i;
+
+   for (i = 0; i < MV_WIN_SDHCI_MAX; i++)
+   printf("SDHCI window#%d: c 0x%08x, b 0x%08x\n", i,
+   win_sdhci_cr_read(base, i), win_sdhci_br_read(base, i));
+}
+
+static int
+decode_win_sdhci_valid(void)
+{
+
+#ifdef SOC_MV_ARMADA38X
+   return (decode_win_can_cover_ddr(MV_WIN_SDHCI_MAX));
+#endif
+
+   /* Satisfy platforms not equipped with this controller. */
+   return (1);
+}
+
 

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

2017-05-09 Thread Luiz Otavio O Souza
Author: loos
Date: Tue May  9 19:01:57 2017
New Revision: 318095
URL: https://svnweb.freebsd.org/changeset/base/318095

Log:
  Add a new SDHCI quirk, SDHCI_QUIRK_BROKEN_AUTO_STOP, to workaround
  controllers that do not support or have broken ACMD12 implementations.
  
  Reviewed by:  jmcneill
  Obtained from:NetBSD
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)
  Differential Revision:https://reviews.freebsd.org/D10602

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

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Tue May  9 18:54:35 2017(r318094)
+++ head/sys/dev/sdhci/sdhci.c  Tue May  9 19:01:57 2017(r318095)
@@ -1060,7 +1060,7 @@ sdhci_set_transfer_mode(struct sdhci_slo
mode |= SDHCI_TRNS_MULTI;
if (data->flags & MMC_DATA_READ)
mode |= SDHCI_TRNS_READ;
-   if (slot->req->stop)
+   if (slot->req->stop && !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP))
mode |= SDHCI_TRNS_ACMD12;
if (slot->flags & SDHCI_USE_DMA)
mode |= SDHCI_TRNS_DMA;
@@ -1305,7 +1305,8 @@ sdhci_finish_data(struct sdhci_slot *slo
slot->intmask |= SDHCI_INT_RESPONSE);
}
/* Unload rest of data from DMA buffer. */
-   if (!slot->data_done && (slot->flags & SDHCI_USE_DMA)) {
+   if (!slot->data_done && (slot->flags & SDHCI_USE_DMA) &&
+   slot->curcmd->data != NULL) {
if (data->flags & MMC_DATA_READ) {
left = data->len - slot->offset;
bus_dmamap_sync(slot->dmatag, slot->dmamap,
@@ -1343,17 +1344,18 @@ sdhci_start(struct sdhci_slot *slot)
sdhci_start_command(slot, req->cmd);
return;
}
-/* We don't need this until using Auto-CMD12 feature
-   if (!(slot->flags & STOP_STARTED) && req->stop) {
+   if ((slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP) &&
+   !(slot->flags & STOP_STARTED) && req->stop) {
slot->flags |= STOP_STARTED;
sdhci_start_command(slot, req->stop);
return;
}
-*/
if (sdhci_debug > 1)
slot_printf(slot, "result: %d\n", req->cmd->error);
if (!req->cmd->error &&
-   (slot->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST)) {
+   ((slot->curcmd == req->stop &&
+(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP)) ||
+(slot->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) {
sdhci_reset(slot, SDHCI_RESET_CMD);
sdhci_reset(slot, SDHCI_RESET_DATA);
}

Modified: head/sys/dev/sdhci/sdhci.h
==
--- head/sys/dev/sdhci/sdhci.h  Tue May  9 18:54:35 2017(r318094)
+++ head/sys/dev/sdhci/sdhci.h  Tue May  9 19:01:57 2017(r318095)
@@ -87,6 +87,8 @@
 #defineSDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400(1 << 26)
 /* Controller support for SDHCI_CTRL2_PRESET_VALUE is broken. */
 #defineSDHCI_QUIRK_PRESET_VALUE_BROKEN (1 << 27)
+/* Controller does not support or the support for ACMD12 is broken. */
+#defineSDHCI_QUIRK_BROKEN_AUTO_STOP(1 << 28)
 
 /*
  * Controller registers
___
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: r318068 - in head/sys: arm/conf modules/dtb/mv

2017-05-09 Thread Luiz Otavio O Souza
Author: loos
Date: Tue May  9 18:12:05 2017
New Revision: 318068
URL: https://svnweb.freebsd.org/changeset/base/318068

Log:
  Disable the build of the static/embedded DTB for the ARMADA38X kernel.
  
  Build the supported DTBs as part of modules build.
  
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Added:
  head/sys/modules/dtb/mv/
  head/sys/modules/dtb/mv/Makefile   (contents, props changed)
Modified:
  head/sys/arm/conf/ARMADA38X

Modified: head/sys/arm/conf/ARMADA38X
==
--- head/sys/arm/conf/ARMADA38X Tue May  9 17:35:16 2017(r318067)
+++ head/sys/arm/conf/ARMADA38X Tue May  9 18:12:05 2017(r318068)
@@ -12,6 +12,7 @@ ident ARMADA38X
 optionsSOC_MV_ARMADA38X
 
 makeoptionsWERROR="-Werror"
+makeoptionsMODULES_EXTRA="dtb/mv"
 
 optionsMD_ROOT
 #makeoptions   MFS_IMAGE=/path/to/miniroot
@@ -78,7 +79,5 @@ devicecryptodev
 # L2 Cache
 device pl310
 
-#FDT
+# FDT
 optionsFDT
-optionsFDT_DTB_STATIC
-makeoptionsFDT_DTS_FILE=armada-388-gp.dts

Added: head/sys/modules/dtb/mv/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/modules/dtb/mv/MakefileTue May  9 18:12:05 2017
(r318068)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+# All the dts files for Marvell systems we support.
+DTS=   \
+   armada-388-clearfog.dts \
+   armada-388-gp.dts
+
+.include 
___
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: r317800 - head/sys/dev/sdhci

2017-05-04 Thread Luiz Otavio O Souza
Author: loos
Date: Thu May  4 18:56:11 2017
New Revision: 317800
URL: https://svnweb.freebsd.org/changeset/base/317800

Log:
  Add support for the no-1-8-v and wp-inverted properties in generic SDHCI
  FDT glue.
  
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/sdhci/sdhci_fdt.c
==
--- head/sys/dev/sdhci/sdhci_fdt.c  Thu May  4 17:23:39 2017
(r317799)
+++ head/sys/dev/sdhci/sdhci_fdt.c  Thu May  4 18:56:11 2017
(r317800)
@@ -70,6 +70,9 @@ struct sdhci_fdt_softc {
int num_slots;  /* Number of slots on this controller*/
struct sdhci_slot slots[MAX_SLOTS];
struct resource *mem_res[MAX_SLOTS];/* Memory resource */
+
+   boolwp_inverted;/* WP pin is inverted */
+   boolno_18v; /* No 1.8V support */
 };
 
 static uint8_t
@@ -110,8 +113,13 @@ static uint32_t
 sdhci_fdt_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off)
 {
struct sdhci_fdt_softc *sc = device_get_softc(dev);
+   uint32_t val32;
+
+   val32 = bus_read_4(sc->mem_res[slot->num], off);
+   if (off == SDHCI_CAPABILITIES && sc->no_18v)
+   val32 &= ~SDHCI_CAN_VDD_180;
 
-   return (bus_read_4(sc->mem_res[slot->num], off));
+   return (val32);
 }
 
 static void
@@ -152,6 +160,14 @@ sdhci_fdt_intr(void *arg)
 }
 
 static int
+sdhci_fdt_get_ro(device_t bus, device_t dev)
+{
+   struct sdhci_fdt_softc *sc = device_get_softc(bus);
+
+   return (sdhci_generic_get_ro(bus, dev) ^ sc->wp_inverted);
+}
+
+static int
 sdhci_fdt_probe(device_t dev)
 {
struct sdhci_fdt_softc *sc = device_get_softc(dev);
@@ -182,6 +198,10 @@ sdhci_fdt_probe(device_t dev)
sc->num_slots = cid;
if ((OF_getencprop(node, "max-frequency", , sizeof(cid))) > 0)
sc->max_clk = cid;
+   if (OF_hasprop(node, "no-1-8-v"))
+   sc->no_18v = true;
+   if (OF_hasprop(node, "wp-inverted"))
+   sc->wp_inverted = true;
 
return (0);
 }
@@ -279,7 +299,7 @@ static device_method_t sdhci_fdt_methods
/* mmcbr_if */
DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios),
DEVMETHOD(mmcbr_request,sdhci_generic_request),
-   DEVMETHOD(mmcbr_get_ro, sdhci_generic_get_ro),
+   DEVMETHOD(mmcbr_get_ro, sdhci_fdt_get_ro),
DEVMETHOD(mmcbr_acquire_host,   sdhci_generic_acquire_host),
DEVMETHOD(mmcbr_release_host,   sdhci_generic_release_host),
 
___
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: r317605 - head/sys/dev/etherswitch/e6000sw

2017-04-30 Thread Luiz Otavio O Souza
Author: loos
Date: Sun Apr 30 07:51:31 2017
New Revision: 317605
URL: https://svnweb.freebsd.org/changeset/base/317605

Log:
  When the switch is set to operate in the Multi Chip Addressing Mode we
  cannot access the GLOBAL2 register directly.
  
  Despite the comment in code (which was misleading), the indirect access is
  only used to read the switch CONFIG data from the scrap register and not
  for the GLOBAL2 access.
  
  Use the dsa data to define when the switch is in the Multi Chip Addressing
  Mode (a even address different than zero).
  
  While here fix a typo.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Sun Apr 30 07:31:48 2017
(r317604)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Sun Apr 30 07:51:31 2017
(r317605)
@@ -214,7 +214,6 @@ e6000sw_probe(device_t dev)
e6000sw_softc_t *sc;
const char *description;
unsigned int id;
-   uint16_t dev_addr;
phandle_t dsa_node, switch_node;
 
dsa_node = fdt_find_compatible(OF_finddevice("/"),
@@ -229,21 +228,11 @@ e6000sw_probe(device_t dev)
sc->dev = dev;
sc->node = switch_node;
 
-   /* Read ADDR[4:1]n using indirect access */
-   MDIO_WRITE(dev, REG_GLOBAL2, SCR_AND_MISC_REG,
-   SCR_AND_MISC_PTR_CFG);
-   dev_addr = MDIO_READ(dev, REG_GLOBAL2, SCR_AND_MISC_REG) &
-   SCR_AND_MISC_DATA_CFG_MASK;
-   if (dev_addr != 0) {
-   sc->multi_chip = true;
-   device_printf(dev, "multi-chip addresing mode\n");
-   } else {
-   device_printf(dev, "single-chip addressing mode\n");
-   }
-
if (OF_getencprop(sc->node, "reg", >sw_addr,
sizeof(sc->sw_addr)) < 0)
return (ENXIO);
+   if (sc->sw_addr != 0 && (sc->sw_addr % 2) == 0)
+   sc->multi_chip = true;
 
/* Lock is necessary due to assertions. */
sx_init(>sx, "e6000sw");
@@ -368,6 +357,11 @@ e6000sw_attach(device_t dev)
err = 0;
sc = device_get_softc(dev);
 
+   if (sc->multi_chip)
+   device_printf(dev, "multi-chip addressing mode\n");
+   else
+   device_printf(dev, "single-chip addressing mode\n");
+
E6000SW_LOCK(sc);
e6000sw_setup(dev, sc);
bzero(member_ports, sizeof(member_ports));
___
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: r317604 - head/sys/dev/fdt

2017-04-30 Thread Luiz Otavio O Souza
Author: loos
Date: Sun Apr 30 07:31:48 2017
New Revision: 317604
URL: https://svnweb.freebsd.org/changeset/base/317604

Log:
  Set the correct default for #address-cells variable when the property does
  not exist.
  
  This has never caused any issue because #address-cells is mandatory.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)
  MFC after:2 weeks

Modified:
  head/sys/dev/fdt/fdt_common.c

Modified: head/sys/dev/fdt/fdt_common.c
==
--- head/sys/dev/fdt/fdt_common.c   Sun Apr 30 06:15:56 2017
(r317603)
+++ head/sys/dev/fdt/fdt_common.c   Sun Apr 30 07:31:48 2017
(r317604)
@@ -422,7 +422,7 @@ fdt_addrsize_cells(phandle_t node, int *
 */
cell_size = sizeof(cell);
if (OF_getencprop(node, "#address-cells", , cell_size) < cell_size)
-   *addr_cells = 2;
+   cell = 2;
*addr_cells = (int)cell;
 
if (OF_getencprop(node, "#size-cells", , cell_size) < cell_size)
___
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: r313911 - head/sys/dev/vmware/vmxnet3

2017-02-17 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Feb 18 06:18:14 2017
New Revision: 313911
URL: https://svnweb.freebsd.org/changeset/base/313911

Log:
  Spell VMXNET3_LEGACY_TX correctly.
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/vmware/vmxnet3/if_vmxvar.h

Modified: head/sys/dev/vmware/vmxnet3/if_vmxvar.h
==
--- head/sys/dev/vmware/vmxnet3/if_vmxvar.h Sat Feb 18 06:03:16 2017
(r313910)
+++ head/sys/dev/vmware/vmxnet3/if_vmxvar.h Sat Feb 18 06:18:14 2017
(r313911)
@@ -131,7 +131,7 @@ struct vmxnet3_txq_stats {
 struct vmxnet3_txqueue {
struct mtx   vxtxq_mtx;
struct vmxnet3_softc*vxtxq_sc;
-#ifndef VMXNET3_TX_LEGACY
+#ifndef VMXNET3_LEGACY_TX
struct buf_ring *vxtxq_br;
 #endif
int  vxtxq_id;
@@ -142,7 +142,7 @@ struct vmxnet3_txqueue {
struct vmxnet3_txq_stats vxtxq_stats;
struct vmxnet3_txq_shared   *vxtxq_ts;
struct sysctl_oid_list  *vxtxq_sysctl;
-#ifndef VMXNET3_TX_LEGACY
+#ifndef VMXNET3_LEGACY_TX
struct task  vxtxq_defrtask;
 #endif
char vxtxq_name[16];
___
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: r312979 - head/sys/net

2017-01-29 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jan 30 03:04:33 2017
New Revision: 312979
URL: https://svnweb.freebsd.org/changeset/base/312979

Log:
  Do not update the lagg link layer address when destroying a lagg clone.
  
  This would enqueue an event to send the gratuitous arp on a dying lagg
  interface without any physical ports attached to it.
  
  Apart from that, the taskqueue_drain() on lagg_clone_destroy() runs too
  late, when the ifp data structure is already freed.  Fix that too.
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/net/if_lagg.c
  head/sys/net/if_lagg.h

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Mon Jan 30 02:52:15 2017(r312978)
+++ head/sys/net/if_lagg.c  Mon Jan 30 03:04:33 2017(r312979)
@@ -550,12 +550,15 @@ lagg_clone_destroy(struct ifnet *ifp)
EVENTHANDLER_DEREGISTER(vlan_unconfig, sc->vlan_detach);
 
/* Shutdown and remove lagg ports */
-   while ((lp = SLIST_FIRST(>sc_ports)) != NULL)
+   while ((lp = SLIST_FIRST(>sc_ports)) != NULL) {
+   lp->lp_detaching = LAGG_CLONE_DESTROY;
lagg_port_destroy(lp, 1);
+   }
/* Unhook the aggregation protocol */
lagg_proto_detach(sc);
LAGG_UNLOCK_ASSERT(sc);
 
+   taskqueue_drain(taskqueue_swi, >sc_lladdr_task);
ifmedia_removeall(>sc_media);
ether_ifdetach(ifp);
if_free(ifp);
@@ -564,7 +567,6 @@ lagg_clone_destroy(struct ifnet *ifp)
SLIST_REMOVE(_lagg_list, sc, lagg_softc, sc_entries);
LAGG_LIST_UNLOCK();
 
-   taskqueue_drain(taskqueue_swi, >sc_lladdr_task);
LAGG_LOCK_DESTROY(sc);
free(sc, M_DEVBUF);
 }
@@ -902,7 +904,7 @@ lagg_port_destroy(struct lagg_port *lp, 
 * Remove multicast addresses and interface flags from this port and
 * reset the MAC address, skip if the interface is being detached.
 */
-   if (!lp->lp_detaching) {
+   if (lp->lp_detaching == 0) {
lagg_ether_cmdmulti(lp, 0);
lagg_setflags(lp, 0);
lagg_port_lladdr(lp, lp->lp_lladdr, LAGG_LLQTYPE_PHYS);
@@ -935,7 +937,8 @@ lagg_port_destroy(struct lagg_port *lp, 
bcopy(lp0->lp_lladdr,
lladdr, ETHER_ADDR_LEN);
}
-   lagg_lladdr(sc, lladdr);
+   if (lp->lp_detaching != LAGG_CLONE_DESTROY)
+   lagg_lladdr(sc, lladdr);
 
/* Mark lp0 as new primary */
sc->sc_primary = lp0;
@@ -950,7 +953,7 @@ lagg_port_destroy(struct lagg_port *lp, 
}
 
/* Remove any pending lladdr changes from the queue */
-   if (lp->lp_detaching) {
+   if (lp->lp_detaching != 0) {
SLIST_FOREACH(llq, >sc_llq_head, llq_entries) {
if (llq->llq_ifp == ifp) {
SLIST_REMOVE(>sc_llq_head, llq, lagg_llq,
@@ -1129,7 +1132,7 @@ lagg_port_ifdetach(void *arg __unused, s
sc = lp->lp_softc;
 
LAGG_WLOCK(sc);
-   lp->lp_detaching = 1;
+   lp->lp_detaching = LAGG_PORT_DETACH;
lagg_port_destroy(lp, 1);
LAGG_WUNLOCK(sc);
 }
@@ -1660,7 +1663,7 @@ lagg_ether_cmdmulti(struct lagg_port *lp
} else {
while ((mc = SLIST_FIRST(>lp_mc_head)) != NULL) {
SLIST_REMOVE(>lp_mc_head, mc, lagg_mc, mc_entries);
-   if (mc->mc_ifma && !lp->lp_detaching)
+   if (mc->mc_ifma && lp->lp_detaching == 0)
if_delmulti_ifma(mc->mc_ifma);
free(mc, M_DEVBUF);
}

Modified: head/sys/net/if_lagg.h
==
--- head/sys/net/if_lagg.h  Mon Jan 30 02:52:15 2017(r312978)
+++ head/sys/net/if_lagg.h  Mon Jan 30 03:04:33 2017(r312979)
@@ -261,6 +261,8 @@ struct lagg_port {
void*lh_cookie; /* if state hook */
void*lp_psc;/* protocol data */
int lp_detaching;   /* ifnet is detaching */
+#defineLAGG_PORT_DETACH0x01/* detach lagg 
port */
+#defineLAGG_CLONE_DESTROY  0x02/* destroy lagg 
clone */
 
SLIST_HEAD(__mclhd, lagg_mc)lp_mc_head; /* multicast addresses 
*/
 
___
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: r312953 - head/sys/net

2017-01-29 Thread Luiz Otavio O Souza
Author: loos
Date: Sun Jan 29 18:41:09 2017
New Revision: 312953
URL: https://svnweb.freebsd.org/changeset/base/312953

Log:
  The stf(4) interface name does not conform with the default naming
  convention for interfaces, because only one stf(4) interface can exist
  in the system.
  
  This disallow the use of unit numbers different than 0, however, it is
  possible to create the clone without specify the unit number (wildcard).
  
  In the wildcard case we must update the interface name before return.
  
  This fix an infinite recursion in pf code that keeps track of network
  interfaces and groups:
  
  1 - a group for the cloned type of the interface is added (stf in this
  case);
  2 - the system will now try to add an interface named stf (instead of
  stf0) to stf group;
  3 - when pfi_kif_attach() tries to search for an already existing 'stf'
  interface, the 'stf' group is returned and thus the group is added
  as an interface of itself;
  
  This will now cause a crash at the first attempt to traverse the groups
  which the stf interface belongs (which loops over itself).
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/net/if_stf.c

Modified: head/sys/net/if_stf.c
==
--- head/sys/net/if_stf.c   Sun Jan 29 16:54:55 2017(r312952)
+++ head/sys/net/if_stf.c   Sun Jan 29 18:41:09 2017(r312953)
@@ -202,10 +202,16 @@ stf_clone_match(struct if_clone *ifc, co
 static int
 stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
 {
-   int err, unit;
+   char *dp;
+   int err, unit, wildcard;
struct stf_softc *sc;
struct ifnet *ifp;
 
+   err = ifc_name2unit(name, );
+   if (err != 0)
+   return (err);
+   wildcard = (unit < 0);
+
/*
 * We can only have one unit, but since unit allocation is
 * already locked, we use it to keep from allocating extra
@@ -229,7 +235,20 @@ stf_clone_create(struct if_clone *ifc, c
/*
 * Set the name manually rather then using if_initname because
 * we don't conform to the default naming convention for interfaces.
+* In the wildcard case, we need to update the name.
 */
+   if (wildcard) {
+   for (dp = name; *dp != '\0'; dp++);
+   if (snprintf(dp, len - (dp-name), "%d", unit) >
+   len - (dp-name) - 1) {
+   /*
+* This can only be a programmer error and
+* there's no straightforward way to recover if
+* it happens.
+*/
+   panic("if_clone_create(): interface name too long");
+   }
+   }
strlcpy(ifp->if_xname, name, IFNAMSIZ);
ifp->if_dname = stfname;
ifp->if_dunit = IF_DUNIT_NONE;
___
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: r312943 - head/sys/netpfil/pf

2017-01-28 Thread Luiz Otavio O Souza
Author: loos
Date: Sun Jan 29 02:17:52 2017
New Revision: 312943
URL: https://svnweb.freebsd.org/changeset/base/312943

Log:
  Do not run the pf purge thread while the VNET variables are not
  initialized, this can cause a divide by zero (if the VNET initialization
  takes to long to complete).
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cSun Jan 29 00:45:52 2017(r312942)
+++ head/sys/netpfil/pf/pf.cSun Jan 29 02:17:52 2017(r312943)
@@ -129,6 +129,8 @@ VNET_DEFINE(int, pf_tcp_secret_init);
 #defineV_pf_tcp_secret_init VNET(pf_tcp_secret_init)
 VNET_DEFINE(int,pf_tcp_iss_off);
 #defineV_pf_tcp_iss_off VNET(pf_tcp_iss_off)
+VNET_DECLARE(int,   pf_vnet_active);
+#defineV_pf_vnet_active VNET(pf_vnet_active)
 
 /*
  * Queue for pf_intr() sends.
@@ -1441,6 +1443,12 @@ pf_purge_thread(void *unused __unused)
kproc_exit(0);
}
 
+   /* Wait while V_pf_default_rule.timeout is initialized. */
+   if (V_pf_vnet_active == 0) {
+   CURVNET_RESTORE();
+   continue;
+   }
+
/* Process 1/interval fraction of the state table every run. */
idx = pf_purge_expired_states(idx, pf_hashmask /
(V_pf_default_rule.timeout[PFTM_INTERVAL] * 10));
___
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: r312770 - in head/sys: net netinet netinet6

2017-01-25 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Jan 25 19:04:08 2017
New Revision: 312770
URL: https://svnweb.freebsd.org/changeset/base/312770

Log:
  After the in_control() changes in r257692, an existing address is
  (intentionally) deleted first and then completely added again (so all the
  events, announces and hooks are given a chance to run).
  
  This cause an issue with CARP where the existing CARP data structure is
  removed together with the last address for a given VHID, which will cause
  a subsequent fail when the address is later re-added.
  
  This change fixes this issue by adding a new flag to keep the CARP data
  structure when an address is not being removed.
  
  There was an additional issue with IPv6 CARP addresses, where the CARP data
  structure would never be removed after a change and lead to VHIDs which
  cannot be destroyed.
  
  Reviewed by:  glebius
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/net/if.c
  head/sys/netinet/in.c
  head/sys/netinet/ip_carp.c
  head/sys/netinet/ip_carp.h
  head/sys/netinet6/in6.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Wed Jan 25 18:31:51 2017(r312769)
+++ head/sys/net/if.c   Wed Jan 25 19:04:08 2017(r312770)
@@ -145,7 +145,7 @@ int (*carp_output_p)(struct ifnet *ifp, 
 const struct sockaddr *sa);
 int(*carp_ioctl_p)(struct ifreq *, u_long, struct thread *);   
 int(*carp_attach_p)(struct ifaddr *, int);
-void   (*carp_detach_p)(struct ifaddr *);
+void   (*carp_detach_p)(struct ifaddr *, bool);
 #endif
 #ifdef INET
 int(*carp_iamatch_p)(struct ifaddr *, uint8_t **);

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Wed Jan 25 18:31:51 2017(r312769)
+++ head/sys/netinet/in.c   Wed Jan 25 19:04:08 2017(r312770)
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 static int in_aifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
-static int in_difaddr_ioctl(caddr_t, struct ifnet *, struct thread *);
+static int in_difaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
 
 static voidin_socktrim(struct sockaddr_in *);
 static voidin_purgemaddrs(struct ifnet *);
@@ -245,7 +245,7 @@ in_control(struct socket *so, u_long cmd
break;
case SIOCDIFADDR:
sx_xlock(_control_sx);
-   error = in_difaddr_ioctl(data, ifp, td);
+   error = in_difaddr_ioctl(cmd, data, ifp, td);
sx_xunlock(_control_sx);
return (error);
case OSIOCAIFADDR:  /* 9.x compat */
@@ -390,7 +390,7 @@ in_aifaddr_ioctl(u_long cmd, caddr_t dat
IF_ADDR_RUNLOCK(ifp);
 
if (ia != NULL)
-   (void )in_difaddr_ioctl(data, ifp, td);
+   (void )in_difaddr_ioctl(cmd, data, ifp, td);
 
ifa = ifa_alloc(sizeof(struct in_ifaddr), M_WAITOK);
ia = (struct in_ifaddr *)ifa;
@@ -528,7 +528,7 @@ fail2:
 
 fail1:
if (ia->ia_ifa.ifa_carp)
-   (*carp_detach_p)(>ia_ifa);
+   (*carp_detach_p)(>ia_ifa, false);
 
IF_ADDR_WLOCK(ifp);
TAILQ_REMOVE(>if_addrhead, >ia_ifa, ifa_link);
@@ -545,7 +545,7 @@ fail1:
 }
 
 static int
-in_difaddr_ioctl(caddr_t data, struct ifnet *ifp, struct thread *td)
+in_difaddr_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, struct thread 
*td)
 {
const struct ifreq *ifr = (struct ifreq *)data;
const struct sockaddr_in *addr = (const struct sockaddr_in *)
@@ -618,7 +618,8 @@ in_difaddr_ioctl(caddr_t data, struct if
in_ifadown(>ia_ifa, 1);
 
if (ia->ia_ifa.ifa_carp)
-   (*carp_detach_p)(>ia_ifa);
+   (*carp_detach_p)(>ia_ifa,
+   (cmd == SIOCDIFADDR) ? false : true);
 
/*
 * If this is the last IPv4 address configured on this

Modified: head/sys/netinet/ip_carp.c
==
--- head/sys/netinet/ip_carp.c  Wed Jan 25 18:31:51 2017(r312769)
+++ head/sys/netinet/ip_carp.c  Wed Jan 25 19:04:08 2017(r312770)
@@ -1969,7 +1969,7 @@ carp_attach(struct ifaddr *ifa, int vhid
 }
 
 void
-carp_detach(struct ifaddr *ifa)
+carp_detach(struct ifaddr *ifa, bool keep_cif)
 {
struct ifnet *ifp = ifa->ifa_ifp;
struct carp_if *cif = ifp->if_carp;
@@ -2015,12 +2015,13 @@ carp_detach(struct ifaddr *ifa)
carp_hmac_prepare(sc);
carp_sc_state(sc);
 
-   if (sc->sc_naddrs == 0 && sc->sc_naddrs6 == 0)
+   if (!keep_cif && sc->sc_naddrs == 0 && sc->sc_naddrs6 == 0)
carp_destroy(sc);
else
CARP_UNLOCK(sc);
 
-   CIF_FREE(cif);
+   if (!keep_cif)
+   CIF_FREE(cif);
 
sx_xunlock(_sx);
 }

Modified: 

svn commit: r312637 - head/sys/arm/ti/cpsw

2017-01-22 Thread Luiz Otavio O Souza
Author: loos
Date: Sun Jan 22 17:24:00 2017
New Revision: 312637
URL: https://svnweb.freebsd.org/changeset/base/312637

Log:
  Be a little more pedantic here, the TRM says the hardware is supposed to
  only clean the OWNER bit on SOP descriptors.
  
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Sun Jan 22 17:07:37 2017
(r312636)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Sun Jan 22 17:24:00 2017
(r312637)
@@ -1981,7 +1981,8 @@ cpsw_tx_dequeue(struct cpsw_softc *sc)
sc->tx.teardown = 1;
}
 
-   if ((flags & CPDMA_BD_OWNER) != 0 && sc->tx.teardown == 0)
+   if ((flags & (CPDMA_BD_SOP | CPDMA_BD_OWNER)) ==
+   (CPDMA_BD_SOP | CPDMA_BD_OWNER) && sc->tx.teardown == 0)
break; /* Hardware is still using this packet. */
 
bus_dmamap_sync(sc->mbuf_dtag, slot->dmamap, 
BUS_DMASYNC_POSTWRITE);
___
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: r312608 - head/sys/arm/ti/cpsw

2017-01-21 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Jan 21 23:07:15 2017
New Revision: 312608
URL: https://svnweb.freebsd.org/changeset/base/312608

Log:
  Handle the rx queue stall while reading the packets from NIC (when the
  descriptor state will not change anymore).  This seems to eliminate the
  race where we can miss a stalled queue under high load.
  
  While here remove the unnecessary curly brackets.
  
  Reported by:  Konstantin Kormashev 
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Sat Jan 21 21:03:26 2017
(r312607)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Sat Jan 21 23:07:15 2017
(r312608)
@@ -1652,6 +1652,14 @@ cpsw_rx_dequeue(struct cpsw_softc *sc)
}
}
 
+   if (STAILQ_FIRST(>rx.active) != NULL &&
+   (bd.flags & (CPDMA_BD_EOP | CPDMA_BD_EOQ)) ==
+   (CPDMA_BD_EOP | CPDMA_BD_EOQ)) {
+   cpsw_write_hdp_slot(sc, >rx,
+   STAILQ_FIRST(>rx.active));
+   sc->rx.queue_restart++;
+   }
+
/* Add mbuf to packet list to be returned. */
if (mb_tail) {
mb_tail->m_nextpkt = slot->mbuf;
@@ -1684,7 +1692,6 @@ cpsw_rx_enqueue(struct cpsw_softc *sc)
struct cpsw_cpdma_bd bd;
struct cpsw_slot *first_new_slot, *last_old_slot, *next, *slot;
int error, nsegs, added = 0;
-   uint32_t flags;
 
/* Register new mbufs with hardware. */
first_new_slot = NULL;
@@ -1750,22 +1757,13 @@ cpsw_rx_enqueue(struct cpsw_softc *sc)
} else {
/* Add buffers to end of current queue. */
cpsw_cpdma_write_bd_next(sc, last_old_slot, first_new_slot);
-   /* If underrun, restart queue. */
-   if ((flags = cpsw_cpdma_read_bd_flags(sc, last_old_slot)) &
-   CPDMA_BD_EOQ) {
-   flags &= ~CPDMA_BD_EOQ;
-   cpsw_cpdma_write_bd_flags(sc, last_old_slot, flags);
-   cpsw_write_hdp_slot(sc, >rx, first_new_slot);
-   sc->rx.queue_restart++;
-   }
}
sc->rx.queue_adds += added;
sc->rx.avail_queue_len -= added;
sc->rx.active_queue_len += added;
cpsw_write_4(sc, CPSW_CPDMA_RX_FREEBUFFER(0), added);
-   if (sc->rx.active_queue_len > sc->rx.max_active_queue_len) {
+   if (sc->rx.active_queue_len > sc->rx.max_active_queue_len)
sc->rx.max_active_queue_len = sc->rx.active_queue_len;
-   }
 }
 
 static void
___
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: r312605 - head/sys/arm/ti/cpsw

2017-01-21 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Jan 21 19:56:28 2017
New Revision: 312605
URL: https://svnweb.freebsd.org/changeset/base/312605

Log:
  Commit the struture changes for the padding of small packets on if_cpsw.
  
  Should have been committed together with r312604.
  
  MFC with: r312604

Modified:
  head/sys/arm/ti/cpsw/if_cpswvar.h

Modified: head/sys/arm/ti/cpsw/if_cpswvar.h
==
--- head/sys/arm/ti/cpsw/if_cpswvar.h   Sat Jan 21 19:49:39 2017
(r312604)
+++ head/sys/arm/ti/cpsw/if_cpswvar.h   Sat Jan 21 19:56:28 2017
(r312605)
@@ -104,10 +104,8 @@ struct cpsw_softc {
struct resource *irq_res[CPSW_INTR_COUNT];
void*ih_cookie[CPSW_INTR_COUNT];
 
-   /* An mbuf full of nulls for TX padding. */
-   bus_dmamap_t null_mbuf_dmamap;
-   struct mbuf *null_mbuf;
-   bus_addr_t null_mbuf_paddr;
+   /* A buffer full of nulls for TX padding. */
+   void*nullpad;
 
bus_dma_tag_t   mbuf_dtag;
 
___
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: r312604 - head/sys/arm/ti/cpsw

2017-01-21 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Jan 21 19:49:39 2017
New Revision: 312604
URL: https://svnweb.freebsd.org/changeset/base/312604

Log:
  Simplify the handling of small packets padding in cpsw:
  
   - Pad small packets to 60 bytes and not 64 (exclude the CRC bytes);
   - Pad the packet using m_append(9), if the packet has enough space for
 padding, which is usually true, it will not be necessary append a newly
 allocated mbuf to the chain.
  
  Suggested by: yongari
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Sat Jan 21 19:38:26 2017
(r312603)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Sat Jan 21 19:49:39 2017
(r312604)
@@ -783,8 +783,7 @@ cpsw_get_fdt_data(struct cpsw_softc *sc,
 static int
 cpsw_attach(device_t dev)
 {
-   bus_dma_segment_t segs[1];
-   int error, i, nsegs;
+   int error, i;
struct cpsw_softc *sc;
uint32_t reg;
 
@@ -859,15 +858,8 @@ cpsw_attach(device_t dev)
return (error);
}
 
-   /* Allocate the null mbuf and pre-sync it. */
-   sc->null_mbuf = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
-   memset(sc->null_mbuf->m_data, 0, sc->null_mbuf->m_ext.ext_size);
-   bus_dmamap_create(sc->mbuf_dtag, 0, >null_mbuf_dmamap);
-   bus_dmamap_load_mbuf_sg(sc->mbuf_dtag, sc->null_mbuf_dmamap,
-   sc->null_mbuf, segs, , BUS_DMA_NOWAIT);
-   bus_dmamap_sync(sc->mbuf_dtag, sc->null_mbuf_dmamap,
-   BUS_DMASYNC_PREWRITE);
-   sc->null_mbuf_paddr = segs[0].ds_addr;
+   /* Allocate a NULL buffer for padding. */
+   sc->nullpad = malloc(ETHER_MIN_LEN, M_DEVBUF, M_WAITOK | M_ZERO);
 
cpsw_init_slots(sc);
 
@@ -946,13 +938,9 @@ cpsw_detach(device_t dev)
for (i = 0; i < nitems(sc->_slots); ++i)
cpsw_free_slot(sc, >_slots[i]);
 
-   /* Free null mbuf. */
-   if (sc->null_mbuf_dmamap) {
-   bus_dmamap_unload(sc->mbuf_dtag, sc->null_mbuf_dmamap);
-   error = bus_dmamap_destroy(sc->mbuf_dtag, sc->null_mbuf_dmamap);
-   KASSERT(error == 0, ("Mapping still active"));
-   m_freem(sc->null_mbuf);
-   }
+   /* Free null padding buffer. */
+   if (sc->nullpad)
+   free(sc->nullpad, M_DEVBUF);
 
/* Free DMA tag */
if (sc->mbuf_dtag) {
@@ -1829,21 +1817,19 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
break;
 
slot->mbuf = m0;
-   padlen = ETHER_MIN_LEN - slot->mbuf->m_pkthdr.len;
+   padlen = ETHER_MIN_LEN - ETHER_CRC_LEN - m0->m_pkthdr.len;
if (padlen < 0)
padlen = 0;
+   else if (padlen > 0)
+   m_append(slot->mbuf, padlen, sc->swsc->nullpad);
 
/* Create mapping in DMA memory */
error = bus_dmamap_load_mbuf_sg(sc->swsc->mbuf_dtag,
slot->dmamap, slot->mbuf, segs, , BUS_DMA_NOWAIT);
/* If the packet is too fragmented, try to simplify. */
if (error == EFBIG ||
-   (error == 0 &&
-   nsegs + (padlen > 0 ? 1 : 0) > 
sc->swsc->tx.avail_queue_len)) {
+   (error == 0 && nsegs > sc->swsc->tx.avail_queue_len)) {
bus_dmamap_unload(sc->swsc->mbuf_dtag, slot->dmamap);
-   if (padlen > 0) /* May as well add padding. */
-   m_append(slot->mbuf, padlen,
-   sc->swsc->null_mbuf->m_data);
m0 = m_defrag(slot->mbuf, M_NOWAIT);
if (m0 == NULL) {
device_printf(sc->dev,
@@ -1895,7 +1881,7 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
bd.bufptr = segs[0].ds_addr;
bd.bufoff = 0;
bd.buflen = segs[0].ds_len;
-   bd.pktlen = m_length(slot->mbuf, NULL) + padlen;
+   bd.pktlen = m_length(slot->mbuf, NULL);
bd.flags =  CPDMA_BD_SOP | CPDMA_BD_OWNER;
if (sc->swsc->dualemac) {
bd.flags |= CPDMA_BD_TO_PORT;
@@ -1920,42 +1906,18 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
bd.pktlen = 0;
bd.flags = CPDMA_BD_OWNER;
}
+
/* Save the final buffer. */
-   if (padlen <= 0)
-   bd.flags |= CPDMA_BD_EOP;
-   else {
-   next = STAILQ_NEXT(slot, next);
-   bd.next = cpsw_cpdma_bd_paddr(sc->swsc, next);
-   }
+   bd.flags |= CPDMA_BD_EOP;
cpsw_cpdma_write_bd(sc->swsc, slot, );
STAILQ_REMOVE_HEAD(>swsc->tx.avail, 

svn commit: r312411 - head/sys/arm/ti/cpsw

2017-01-19 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Jan 19 14:58:55 2017
New Revision: 312411
URL: https://svnweb.freebsd.org/changeset/base/312411

Log:
  Handle the set capabilities ioctl, letting the hardware checksum be
  disabled (Hi netmap!).
  
  Only remove the CRC bytes from packets when the hardware tell us to do so.
  
  Fixes the 'discard frame w/o leading ethernet header' issues.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/cpsw/if_cpswreg.h

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Thu Jan 19 14:49:55 2017
(r312410)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Thu Jan 19 14:58:55 2017
(r312411)
@@ -1395,6 +1395,16 @@ cpswp_ioctl(struct ifnet *ifp, u_long co
ifr = (struct ifreq *)data;
 
switch (command) {
+   case SIOCSIFCAP:
+   changed = ifp->if_capenable ^ ifr->ifr_reqcap;
+   if (changed & IFCAP_HWCSUM) {
+   if ((ifr->ifr_reqcap & changed) & IFCAP_HWCSUM)
+   ifp->if_capenable |= IFCAP_HWCSUM;
+   else
+   ifp->if_capenable &= ~IFCAP_HWCSUM;
+   }
+   error = 0;
+   break;
case SIOCSIFFLAGS:
CPSW_PORT_LOCK(sc);
if (ifp->if_flags & IFF_UP) {
@@ -1632,15 +1642,22 @@ cpsw_rx_dequeue(struct cpsw_softc *sc)
/* TODO: track SOP/EOP bits to assemble a full mbuf
   out of received fragments. */
slot->mbuf->m_data += bd.bufoff;
-   slot->mbuf->m_len = bd.pktlen - 4;
-   slot->mbuf->m_pkthdr.len = bd.pktlen - 4;
-   slot->mbuf->m_flags |= M_PKTHDR;
-   slot->mbuf->m_pkthdr.rcvif = psc->ifp;
+   slot->mbuf->m_len = bd.buflen;
+   if (bd.flags & CPDMA_BD_SOP) {
+   slot->mbuf->m_pkthdr.len = bd.pktlen;
+   slot->mbuf->m_pkthdr.rcvif = psc->ifp;
+   slot->mbuf->m_flags |= M_PKTHDR;
+   }
+   slot->mbuf->m_next = NULL;
slot->mbuf->m_nextpkt = NULL;
+   if (bd.flags & CPDMA_BD_PASS_CRC)
+   m_adj(slot->mbuf, -ETHER_CRC_LEN);
 
if ((psc->ifp->if_capenable & IFCAP_RXCSUM) != 0) {
/* check for valid CRC by looking into pkt_err[5:4] */
-   if ((bd.flags & CPDMA_BD_PKT_ERR_MASK) == 0) {
+   if ((bd.flags &
+   (CPDMA_BD_SOP | CPDMA_BD_PKT_ERR_MASK)) ==
+   CPDMA_BD_SOP) {
slot->mbuf->m_pkthdr.csum_flags |= 
CSUM_IP_CHECKED;
slot->mbuf->m_pkthdr.csum_flags |= 
CSUM_IP_VALID;
slot->mbuf->m_pkthdr.csum_data = 0x;

Modified: head/sys/arm/ti/cpsw/if_cpswreg.h
==
--- head/sys/arm/ti/cpsw/if_cpswreg.h   Thu Jan 19 14:49:55 2017
(r312410)
+++ head/sys/arm/ti/cpsw/if_cpswreg.h   Thu Jan 19 14:58:55 2017
(r312411)
@@ -191,6 +191,7 @@
 #define CPDMA_BD_OWNER (1 << 13)
 #define CPDMA_BD_EOQ   (1 << 12)
 #define CPDMA_BD_TDOWNCMPLT(1 << 11)
+#define CPDMA_BD_PASS_CRC  (1 << 10)
 #define CPDMA_BD_PKT_ERR_MASK  (3 << 4)
 #define CPDMA_BD_TO_PORT   (1 << 4)
 #define CPDMA_BD_PORT_MASK 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: r312408 - head/sys/arm/ti/cpsw

2017-01-19 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Jan 19 14:05:49 2017
New Revision: 312408
URL: https://svnweb.freebsd.org/changeset/base/312408

Log:
  The port number and the to_port_en flag are valid only on SOP descriptor.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Thu Jan 19 13:35:14 2017
(r312407)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Thu Jan 19 14:05:49 2017
(r312408)
@@ -1800,13 +1800,8 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
struct cpsw_cpdma_bd bd;
struct cpsw_slot *first_new_slot, *last, *last_old_slot, *next, *slot;
struct mbuf *m0;
-   int error, flags, nsegs, seg, added = 0, padlen;
+   int error, nsegs, seg, added = 0, padlen;
 
-   flags = 0;
-   if (sc->swsc->dualemac) {
-   flags = CPDMA_BD_TO_PORT |
-   ((sc->unit + 1) & CPDMA_BD_PORT_MASK);
-   }
/* Pull pending packets from IF queue and prep them for DMA. */
last = NULL;
first_new_slot = NULL;
@@ -1884,7 +1879,11 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
bd.bufoff = 0;
bd.buflen = segs[0].ds_len;
bd.pktlen = m_length(slot->mbuf, NULL) + padlen;
-   bd.flags =  CPDMA_BD_SOP | CPDMA_BD_OWNER | flags;
+   bd.flags =  CPDMA_BD_SOP | CPDMA_BD_OWNER;
+   if (sc->swsc->dualemac) {
+   bd.flags |= CPDMA_BD_TO_PORT;
+   bd.flags |= ((sc->unit + 1) & CPDMA_BD_PORT_MASK);
+   }
for (seg = 1; seg < nsegs; ++seg) {
/* Save the previous buffer (which isn't EOP) */
cpsw_cpdma_write_bd(sc->swsc, slot, );
@@ -1902,7 +1901,7 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
bd.bufoff = 0;
bd.buflen = segs[seg].ds_len;
bd.pktlen = 0;
-   bd.flags = CPDMA_BD_OWNER | flags;
+   bd.flags = CPDMA_BD_OWNER;
}
/* Save the final buffer. */
if (padlen <= 0)
@@ -1924,7 +1923,7 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
bd.bufoff = 0;
bd.buflen = padlen;
bd.pktlen = 0;
-   bd.flags = CPDMA_BD_EOP | CPDMA_BD_OWNER | flags;
+   bd.flags = CPDMA_BD_EOP | CPDMA_BD_OWNER;
cpsw_cpdma_write_bd(sc->swsc, slot, );
++nsegs;
 
___
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: r312347 - head/sys/boot/fdt/dts/arm

2017-01-17 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jan 17 18:04:13 2017
New Revision: 312347
URL: https://svnweb.freebsd.org/changeset/base/312347

Log:
  The write-protect is not wired on uFW, disable it to allow writes to SD
  card.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/boot/fdt/dts/arm/ufw.dts

Modified: head/sys/boot/fdt/dts/arm/ufw.dts
==
--- head/sys/boot/fdt/dts/arm/ufw.dts   Tue Jan 17 17:41:14 2017
(r312346)
+++ head/sys/boot/fdt/dts/arm/ufw.dts   Tue Jan 17 18:04:13 2017
(r312347)
@@ -278,6 +278,7 @@
pinctrl-0 = <_pins>;
bus-width = <4>;
non-removable;
+   wp-disable;
status = "okay";
 };
 
___
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: r312346 - head/sys/dev/sdhci

2017-01-17 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jan 17 17:41:14 2017
New Revision: 312346
URL: https://svnweb.freebsd.org/changeset/base/312346

Log:
  Set the the wp_disabled flag when asked to.
  
  While here, add the missing new line.
  
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/sdhci/sdhci_fdt_gpio.c
==
--- head/sys/dev/sdhci/sdhci_fdt_gpio.c Tue Jan 17 16:20:21 2017
(r312345)
+++ head/sys/dev/sdhci/sdhci_fdt_gpio.c Tue Jan 17 17:41:14 2017
(r312346)
@@ -90,7 +90,7 @@ cd_setup(struct sdhci_fdt_gpio *gpio, ph
gpio->slot->opt |= SDHCI_NON_REMOVABLE;
gpio->cd_disabled = true;
if (bootverbose)
-   device_printf(dev, "Non-removable media");
+   device_printf(dev, "Non-removable media\n");
return;
}
 
@@ -177,8 +177,12 @@ wp_setup(struct sdhci_fdt_gpio *gpio, ph
 
dev = gpio->dev;
 
-   if (OF_hasprop(node, "wp-disable"))
+   if (OF_hasprop(node, "wp-disable")) {
+   gpio->wp_disabled = true;
+   if (bootverbose)
+   device_printf(dev, "Write protect disabled\n");
return;
+   }
 
if (gpio_pin_get_by_ofw_property(dev, node, "wp-gpios", >wp_pin))
return;
___
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: r311701 - head/sys/dev/gpio

2017-01-08 Thread Luiz Otavio O Souza
Author: loos
Date: Sun Jan  8 20:41:32 2017
New Revision: 311701
URL: https://svnweb.freebsd.org/changeset/base/311701

Log:
  Convert gpioc to use the make_dev_s(9) KPI.  This fix a possible race where
  si_drv1 can be accessed before it gets set.
  
  This is inspired on r311700.
  
  MFC after:3 days

Modified:
  head/sys/dev/gpio/gpioc.c

Modified: head/sys/dev/gpio/gpioc.c
==
--- head/sys/dev/gpio/gpioc.c   Sun Jan  8 20:37:41 2017(r311700)
+++ head/sys/dev/gpio/gpioc.c   Sun Jan  8 20:41:32 2017(r311701)
@@ -78,18 +78,25 @@ gpioc_probe(device_t dev)
 static int
 gpioc_attach(device_t dev)
 {
-   struct gpioc_softc *sc = device_get_softc(dev);
+   int err;
+   struct gpioc_softc *sc;
+   struct make_dev_args devargs;
 
+   sc = device_get_softc(dev);
sc->sc_dev = dev;
sc->sc_pdev = device_get_parent(dev);
sc->sc_unit = device_get_unit(dev);
-   sc->sc_ctl_dev = make_dev(_cdevsw, sc->sc_unit,
-   UID_ROOT, GID_WHEEL, 0600, "gpioc%d", sc->sc_unit);
-   if (!sc->sc_ctl_dev) {
+   make_dev_args_init();
+   devargs.mda_devsw = _cdevsw;
+   devargs.mda_uid = UID_ROOT;
+   devargs.mda_gid = GID_WHEEL;
+   devargs.mda_mode = 0600;
+   devargs.mda_si_drv1 = sc;
+   err = make_dev_s(, >sc_ctl_dev, "gpioc%d", sc->sc_unit);
+   if (err != 0) {
printf("Failed to create gpioc%d", sc->sc_unit);
return (ENXIO);
}
-   sc->sc_ctl_dev->si_drv1 = sc;
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r311700 - head/sys/dev/etherswitch

2017-01-08 Thread Luiz Otavio O Souza
Author: loos
Date: Sun Jan  8 20:37:41 2017
New Revision: 311700
URL: https://svnweb.freebsd.org/changeset/base/311700

Log:
  Convert etherswitch to use the make_dev_s(9) KPI.  This fix a possible race
  where si_drv1 can be accessed before it gets set.
  
  MFC after:3 days
  Suggested by: kib
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/etherswitch.c
==
--- head/sys/dev/etherswitch/etherswitch.c  Sun Jan  8 20:29:35 2017
(r311699)
+++ head/sys/dev/etherswitch/etherswitch.c  Sun Jan  8 20:37:41 2017
(r311700)
@@ -99,17 +99,24 @@ etherswitch_probe(device_t dev)
 static int
 etherswitch_attach(device_t dev)
 {
-   struct etherswitch_softc *sc = (struct etherswitch_softc 
*)device_get_softc(dev);
+   int err;
+   struct etherswitch_softc *sc;
+   struct make_dev_args devargs;
 
+   sc = device_get_softc(dev);
sc->sc_dev = dev;
-   sc->sc_devnode = make_dev(_cdevsw, device_get_unit(dev),
-   UID_ROOT, GID_WHEEL,
-   0600, "etherswitch%d", device_get_unit(dev));
-   if (sc->sc_devnode == NULL) {
+   make_dev_args_init();
+   devargs.mda_devsw = _cdevsw;
+   devargs.mda_uid = UID_ROOT;
+   devargs.mda_gid = GID_WHEEL;
+   devargs.mda_mode = 0600;
+   devargs.mda_si_drv1 = sc;
+   err = make_dev_s(, >sc_devnode, "etherswitch%d",
+   device_get_unit(dev));
+   if (err != 0) {
device_printf(dev, "failed to create character device\n");
return (ENXIO);
}
-   sc->sc_devnode->si_drv1 = sc;
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r311157 - head/sys/boot/fdt/dts/arm

2017-01-03 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Jan  3 16:46:51 2017
New Revision: 311157
URL: https://svnweb.freebsd.org/changeset/base/311157

Log:
  Remove a GPL licensed DTS.
  
  The micro-Firewall DTS is now a single BSD licensed file.
  
  Reported by:  manu
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Deleted:
  head/sys/boot/fdt/dts/arm/ubmc.dtsi
Modified:
  head/sys/boot/fdt/dts/arm/ufw.dts

Modified: head/sys/boot/fdt/dts/arm/ufw.dts
==
--- head/sys/boot/fdt/dts/arm/ufw.dts   Tue Jan  3 15:59:39 2017
(r311156)
+++ head/sys/boot/fdt/dts/arm/ufw.dts   Tue Jan  3 16:46:51 2017
(r311157)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016 Rubicon Communications, LLC (Netgate)
+ * Copyright (c) 2016, 2017 Rubicon Communications, LLC (Netgate)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,11 +29,247 @@
 /dts-v1/;
 
 #include "am33xx.dtsi"
-#include "ubmc.dtsi"
 
 / {
model = "AM335x uFW";
compatible = "ti,am335x-ufw", "ti,am335x-ubmc", "ti,am33xx";
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x1000>; /* 256 MB */
+   };
+
+   vmmcsd_fixed: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vmmcsd_fixed";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+};
+
+_pinmux {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pin>;
+
+   i2c0_pins: pinmux_i2c0_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x988, PIN_INPUT_PULLUP | MUX_MODE0)   
/* i2c0_sda.i2c0_sda */
+   AM33XX_IOPAD(0x98c, PIN_INPUT_PULLUP | MUX_MODE0)   
/* i2c0_scl.i2c0_scl */
+   >;
+   };
+
+   i2c1_pins: pinmux_i2c1_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x968, PIN_INPUT_PULLUP | MUX_MODE3)   
/* uart0_ctsn.i2c1_sda */
+   AM33XX_IOPAD(0x96c, PIN_INPUT_PULLUP | MUX_MODE3)   
/* uart0_rtsn.i2c1_scl */
+   >;
+   };
+
+   uart0_pins: pinmux_uart0_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x970, PIN_INPUT_PULLUP | MUX_MODE0)   
/* uart0_rxd.uart0_rxd */
+   AM33XX_IOPAD(0x974, PIN_OUTPUT_PULLDOWN | MUX_MODE0)
/* uart0_txd.uart0_txd */
+   >;
+   };
+
+   clkout2_pin: pinmux_clkout2_pin {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x9b4, PIN_OUTPUT_PULLDOWN | MUX_MODE3)
/* xdma_event_intr1.clkout2 */
+   >;
+   };
+
+   cpsw_default: cpsw_default {
+   pinctrl-single,pins = <
+   /* Slave 1 */
+   AM33XX_IOPAD(0x914, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txen.rgmii_1_txen */
+   AM33XX_IOPAD(0x918, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxdv.rgmii_1_rxdv */
+   AM33XX_IOPAD(0x91c, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd3.rgmii_1_txd3 */
+   AM33XX_IOPAD(0x920, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd2.rgmii_1_txd2 */
+   AM33XX_IOPAD(0x924, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd1.rgmii_1_txd1 */
+   AM33XX_IOPAD(0x928, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd0.rgmii_1_txd0 */
+   AM33XX_IOPAD(0x92c, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txclk.rgmii_1_txclk */
+   AM33XX_IOPAD(0x930, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxclk.rgmii_1_rxclk */
+   AM33XX_IOPAD(0x934, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxd3.rgmii_1_rxd3 */
+   AM33XX_IOPAD(0x938, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxd2.rgmii_1_rxd2 */
+   AM33XX_IOPAD(0x93c, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxd1.rgmii_1_rxd1 */
+   AM33XX_IOPAD(0x940, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxd0.rgmii_1_rxd0 */
+
+   /* Slave 2 */
+   AM33XX_IOPAD(0x840, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* gmpc_a0.rgmii_2_txen */
+   AM33XX_IOPAD(0x844, PIN_INPUT_PULLUP | MUX_MODE2)   
/* gmpc_a1.rgmii_2_rxdv */
+   AM33XX_IOPAD(0x848, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* gmpc_a2.rgmii_2_txd3 */
+   AM33XX_IOPAD(0x84c, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* gmpc_a3.rgmii_2_txd2 */
+   AM33XX_IOPAD(0x850, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* gmpc_a4.rgmii_2_txd1 */
+   AM33XX_IOPAD(0x854, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* gmpc_a5.rgmii_2_txd0 */
+   

svn commit: r310887 - head/sys/dev/rccgpio

2016-12-30 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Dec 31 02:23:15 2016
New Revision: 310887
URL: https://svnweb.freebsd.org/changeset/base/310887

Log:
  Fix rcc_gpio_modify_bits().  Obviously (1 << 0) is not the same as 0.
  
  Pointy hat to:loos
  MFC after:3 days

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

Modified: head/sys/dev/rccgpio/rccgpio.c
==
--- head/sys/dev/rccgpio/rccgpio.c  Sat Dec 31 02:18:08 2016
(r310886)
+++ head/sys/dev/rccgpio/rccgpio.c  Sat Dec 31 02:23:15 2016
(r310887)
@@ -57,12 +57,12 @@ struct rcc_gpio_pin {
 };
 
 static struct rcc_gpio_pin rcc_pins[] = {
-   { .pin = 11, .name = "reset switch", .caps = GPIO_PIN_INPUT },
-   { .pin = 15, .name = "red LED", .caps = GPIO_PIN_OUTPUT },
-   { .pin = 17, .name = "green LED", .caps = GPIO_PIN_OUTPUT },
+   { .pin = (1 << 11), .name = "reset switch", .caps = GPIO_PIN_INPUT },
+   { .pin = (1 << 15), .name = "red LED", .caps = GPIO_PIN_OUTPUT },
+   { .pin = (1 << 17), .name = "green LED", .caps = GPIO_PIN_OUTPUT },
 #if 0
-   { .pin = 16, .name = "HD1 LED", .caps = GPIO_PIN_OUTPUT },
-   { .pin = 18, .name = "HD2 LED", .caps = GPIO_PIN_OUTPUT },
+   { .pin = (1 << 16), .name = "HD1 LED", .caps = GPIO_PIN_OUTPUT },
+   { .pin = (1 << 18), .name = "HD2 LED", .caps = GPIO_PIN_OUTPUT },
 #endif
 };
 
@@ -87,14 +87,14 @@ struct rcc_gpio_softc {
 
 static void
 rcc_gpio_modify_bits(struct rcc_gpio_softc *sc, uint32_t reg, uint32_t mask,
-   uint32_t bit)
+   uint32_t writebits)
 {
uint32_t value;
 
RCC_GPIO_LOCK(sc);
value = RCC_READ(sc, reg);
-   value &= ~(1 << mask);
-   value |= (1 << bit);
+   value &= ~mask;
+   value |= writebits;
RCC_WRITE(sc, reg, value);
RCC_GPIO_UNLOCK(sc);
 }
___
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: r310886 - head/sys/arm/ti/am335x

2016-12-30 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Dec 31 02:18:08 2016
New Revision: 310886
URL: https://svnweb.freebsd.org/changeset/base/310886

Log:
  Fixes the sensor initialization, always reset the digital outputs to start.
  
  Obtained from:pfSense
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/am335x/am335x_scm.c

Modified: head/sys/arm/ti/am335x/am335x_scm.c
==
--- head/sys/arm/ti/am335x/am335x_scm.c Sat Dec 31 02:02:42 2016
(r310885)
+++ head/sys/arm/ti/am335x/am335x_scm.c Sat Dec 31 02:18:08 2016
(r310886)
@@ -110,11 +110,14 @@ am335x_scm_attach(device_t dev)
struct sysctl_oid_list *tree;
uint32_t reg;
 
-   /* Set ADC to continous mode, clear output reset. */
-   reg = SCM_BGAP_CLRZ | SCM_BGAP_CONTCONV;
-   ti_scm_reg_write_4(SCM_BGAP_CTRL, reg);
-   /* Flush write. */
+   /* Reset the digital outputs. */
+   ti_scm_reg_write_4(SCM_BGAP_CTRL, 0);
+   ti_scm_reg_read_4(SCM_BGAP_CTRL, );
+   DELAY(500);
+   /* Set continous mode. */
+   ti_scm_reg_write_4(SCM_BGAP_CTRL, SCM_BGAP_CONTCONV);
ti_scm_reg_read_4(SCM_BGAP_CTRL, );
+   DELAY(500);
/* Start the ADC conversion. */
reg = SCM_BGAP_CLRZ | SCM_BGAP_CONTCONV | SCM_BGAP_SOC;
ti_scm_reg_write_4(SCM_BGAP_CTRL, reg);
___
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: r310707 - head/sbin/pfctl

2016-12-28 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Dec 28 16:16:48 2016
New Revision: 310707
URL: https://svnweb.freebsd.org/changeset/base/310707

Log:
  Fix the parsing of NPt binat rules.
  
  In this specific case the src address can be set to any, which was not
  accepted prior to this commit.
  
  pfSense bug report:   https://redmine.pfsense.org/issues/6985
  Reviewed by:  kp
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sbin/pfctl/parse.y

Modified: head/sbin/pfctl/parse.y
==
--- head/sbin/pfctl/parse.y Wed Dec 28 16:16:36 2016(r310706)
+++ head/sbin/pfctl/parse.y Wed Dec 28 16:16:48 2016(r310707)
@@ -4195,7 +4195,7 @@ natrule   : nataction interface af proto 
}
;
 
-binatrule  : no BINAT natpasslog interface af proto FROM host toipspec tag
+binatrule  : no BINAT natpasslog interface af proto FROM ipspec toipspec 
tag
tagged rtable redirection
{
struct pf_rule  binat;
___
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: r310000 - head/sys/dev/gpio

2016-12-12 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Dec 13 03:36:41 2016
New Revision: 31
URL: https://svnweb.freebsd.org/changeset/base/31

Log:
  Remove a too strict test and instead, just filter the passed flags with the
  supported capabilities.
  
  Spotted by:   yamori...@yahoo.co.jp (Hiroki Mori)
  MFC after:2 weeks

Modified:
  head/sys/dev/gpio/gpiobus.c

Modified: head/sys/dev/gpio/gpiobus.c
==
--- head/sys/dev/gpio/gpiobus.c Tue Dec 13 03:26:12 2016(r30)
+++ head/sys/dev/gpio/gpiobus.c Tue Dec 13 03:36:41 2016(r31)
@@ -120,9 +120,9 @@ int
 gpio_check_flags(uint32_t caps, uint32_t flags)
 {
 
-   /* Check for unwanted flags. */
-   if ((flags & caps) == 0 || (flags & caps) != flags)
-   return (EINVAL);
+   /* Filter unwanted flags. */
+   flags &= caps;
+
/* Cannot mix input/output together. */
if (flags & GPIO_PIN_INPUT && flags & GPIO_PIN_OUTPUT)
return (EINVAL);
___
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: r309717 - head/sys/net

2016-12-08 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Dec  8 18:18:48 2016
New Revision: 309717
URL: https://svnweb.freebsd.org/changeset/base/309717

Log:
  Fix the typos and style(9) in comment.
  
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/net/route.c

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cThu Dec  8 16:41:18 2016(r309716)
+++ head/sys/net/route.cThu Dec  8 18:18:48 2016(r309717)
@@ -467,9 +467,8 @@ rtalloc1_fib(struct sockaddr *dst, int r
RIB_RUNLOCK(rh);

/*
-* Either we hit the root or couldn't find any match,
-* Which basically means
-* "caint get there frm here"
+* Either we hit the root or could not find any match,
+* which basically means: "cannot get there from here".
 */
 miss:
V_rtstat.rts_unreach++;
___
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: r309604 - head/sys/arm/include

2016-12-05 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Dec  6 06:15:28 2016
New Revision: 309604
URL: https://svnweb.freebsd.org/changeset/base/309604

Log:
  Fix the armv6 build after r309553.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/include/pmap.h

Modified: head/sys/arm/include/pmap.h
==
--- head/sys/arm/include/pmap.h Tue Dec  6 06:12:01 2016(r309603)
+++ head/sys/arm/include/pmap.h Tue Dec  6 06:15:28 2016(r309604)
@@ -30,7 +30,6 @@
 #ifndef _MACHINE_PMAP_H_
 #define _MACHINE_PMAP_H_
 
-#include 
 #if __ARM_ARCH >= 6
 #include 
 #else
@@ -38,6 +37,7 @@
 #endif
 
 #ifdef _KERNEL
+#include 
 
 extern vm_paddr_t dump_avail[];
 extern vm_paddr_t phys_avail[];
___
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: r309461 - head/sys/dev/etherswitch

2016-12-02 Thread Luiz Otavio O Souza
Author: loos
Date: Sat Dec  3 01:55:38 2016
New Revision: 309461
URL: https://svnweb.freebsd.org/changeset/base/309461

Log:
  Allow simultaneous access to switch device, there is no reason to prevent
  it.
  
  Remove bogus wrappers and use the kernel defaults.
  
  While here, use DEVMETHOD_END.
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/dev/etherswitch/etherswitch.c
==
--- head/sys/dev/etherswitch/etherswitch.c  Sat Dec  3 01:14:21 2016
(r309460)
+++ head/sys/dev/etherswitch/etherswitch.c  Sat Dec  3 01:55:38 2016
(r309461)
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -45,19 +44,11 @@
 
 #include "etherswitch_if.h"
 
-#define BUFSIZE 1024
-
 struct etherswitch_softc {
device_t sc_dev;
-   int sc_count;
-
struct cdev *sc_devnode;
-   struct sx sc_lock;
 };
 
-#defineSWITCH_LOCK(sc) sx_xlock(&(sc)->sc_lock)
-#defineSWITCH_UNLOCK(sc)   
sx_xunlock(&(sc)->sc_lock)
-
 static int etherswitch_probe(device_t);
 static int etherswitch_attach(device_t);
 static int etherswitch_detach(device_t);
@@ -72,7 +63,7 @@ static device_method_t etherswitch_metho
DEVMETHOD(device_attach,etherswitch_attach),
DEVMETHOD(device_detach,etherswitch_detach),
 
-   { 0, 0 }
+   DEVMETHOD_END
 };
 
 driver_t etherswitch_driver = {
@@ -81,19 +72,11 @@ driver_t etherswitch_driver = {
sizeof(struct etherswitch_softc),
 };
 
-static d_open_tetherswitchopen;
-static d_close_t   etherswitchclose;
-static d_write_t   etherswitchwrite;
-static d_read_tetherswitchread;
 static d_ioctl_t   etherswitchioctl;
 
 static struct cdevsw etherswitch_cdevsw = {
.d_version =D_VERSION,
.d_flags =  D_TRACKCLOSE,
-   .d_open =   etherswitchopen,
-   .d_close =  etherswitchclose,
-   .d_read =   etherswitchread,
-   .d_write =  etherswitchwrite,
.d_ioctl =  etherswitchioctl,
.d_name =   "etherswitch",
 };
@@ -119,13 +102,11 @@ etherswitch_attach(device_t dev)
struct etherswitch_softc *sc = (struct etherswitch_softc 
*)device_get_softc(dev);
 
sc->sc_dev = dev;
-   sx_init(>sc_lock, "etherswitch");
sc->sc_devnode = make_dev(_cdevsw, device_get_unit(dev),
UID_ROOT, GID_WHEEL,
0600, "etherswitch%d", device_get_unit(dev));
if (sc->sc_devnode == NULL) {
device_printf(dev, "failed to create character device\n");
-   sx_destroy(>sc_lock);
return (ENXIO);
}
sc->sc_devnode->si_drv1 = sc;
@@ -140,61 +121,11 @@ etherswitch_detach(device_t dev)
 
if (sc->sc_devnode)
destroy_dev(sc->sc_devnode);
-   sx_destroy(>sc_lock);
-
-   return (0);
-}
-
-static int
-etherswitchopen(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
-   struct etherswitch_softc *sc = dev->si_drv1;
-
-   SWITCH_LOCK(sc);
-   if (sc->sc_count > 0) {
-   SWITCH_UNLOCK(sc);
-   return (EBUSY);
-   }
-
-   sc->sc_count++;
-   SWITCH_UNLOCK(sc);
-
-   return (0);
-}
-
-static int
-etherswitchclose(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
-   struct etherswitch_softc *sc = dev->si_drv1;
-
-   SWITCH_LOCK(sc);
-   if (sc->sc_count == 0) {
-   SWITCH_UNLOCK(sc);
-   return (EINVAL);
-   }
-
-   sc->sc_count--;
-
-   if (sc->sc_count < 0)
-   panic("%s: etherswitch_count < 0!", __func__);
-   SWITCH_UNLOCK(sc);
 
return (0);
 }
 
 static int
-etherswitchwrite(struct cdev *dev, struct uio * uio, int ioflag)
-{
-   return (EINVAL);
-}
-
-static int
-etherswitchread(struct cdev *dev, struct uio * uio, int ioflag)
-{
-   return (EINVAL);
-}
-
-static int
 etherswitchioctl(struct cdev *cdev, u_long cmd, caddr_t data, int flags, 
struct thread *td)
 {
struct etherswitch_softc *sc = cdev->si_drv1;
___
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: r309347 - head/sys/arm/ti/cpsw

2016-11-30 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Dec  1 03:34:04 2016
New Revision: 309347
URL: https://svnweb.freebsd.org/changeset/base/309347

Log:
  MDIO_PHYACCESS_ACK is only valid for read access, remove it from
  miibus_writereg.
  
  Reduce the DELAY() between reads while waiting for MII access.
  
  Spotted by:   yongari
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/cpsw/if_cpswvar.h

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Thu Dec  1 03:27:16 2016
(r309346)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Thu Dec  1 03:34:04 2016
(r309347)
@@ -1512,9 +1512,6 @@ cpswp_miibus_writereg(device_t dev, int 
return (0);
}
 
-   if ((cpsw_read_4(sc->swsc, sc->phyaccess) & MDIO_PHYACCESS_ACK) == 0)
-   device_printf(dev, "Failed to write to PHY.\n");
-
return (0);
 }
 

Modified: head/sys/arm/ti/cpsw/if_cpswvar.h
==
--- head/sys/arm/ti/cpsw/if_cpswvar.h   Thu Dec  1 03:27:16 2016
(r309346)
+++ head/sys/arm/ti/cpsw/if_cpswvar.h   Thu Dec  1 03:34:04 2016
(r309347)
@@ -33,8 +33,8 @@
 #defineCPSW_INTR_COUNT 4
 
 /* MII BUS  */
-#defineCPSW_MIIBUS_RETRIES 5
-#defineCPSW_MIIBUS_DELAY   1000
+#defineCPSW_MIIBUS_RETRIES 20
+#defineCPSW_MIIBUS_DELAY   100
 
 #defineCPSW_MAX_ALE_ENTRIES1024
 
___
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: r309345 - head/sys/arm/ti/cpsw

2016-11-30 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Dec  1 02:35:15 2016
New Revision: 309345
URL: https://svnweb.freebsd.org/changeset/base/309345

Log:
  The RX_FREEBUFFER registers are a write to increment field.
  
  Writing the full queue size to it every time was makeing it overflow with a
  lot of bogus values.
  
  This fixes the interrupt storms on irq 40.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Thu Dec  1 02:21:36 2016
(r309344)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Thu Dec  1 02:35:15 2016
(r309345)
@@ -1760,7 +1760,7 @@ cpsw_rx_enqueue(struct cpsw_softc *sc)
sc->rx.queue_adds += added;
sc->rx.avail_queue_len -= added;
sc->rx.active_queue_len += added;
-   cpsw_write_4(sc, CPSW_CPDMA_RX_FREEBUFFER(0), sc->rx.active_queue_len);
+   cpsw_write_4(sc, CPSW_CPDMA_RX_FREEBUFFER(0), added);
if (sc->rx.active_queue_len > sc->rx.max_active_queue_len) {
sc->rx.max_active_queue_len = sc->rx.active_queue_len;
}
___
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: r309113 - in head/sys: arm/ti/cpsw conf

2016-11-24 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Nov 24 20:14:43 2016
New Revision: 309113
URL: https://svnweb.freebsd.org/changeset/base/309113

Log:
  Add the etherswitch(4) support for TI CPSW.
  
  Adds VLAN and port management abilities for etherswitchcfg(8).
  
  The code is conditionally enabled for now, because it is not necessary on
  single ethernet use cases.
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/cpsw/if_cpswreg.h
  head/sys/arm/ti/cpsw/if_cpswvar.h
  head/sys/conf/options.arm

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Thu Nov 24 20:08:17 2016
(r309112)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Thu Nov 24 20:14:43 2016
(r309113)
@@ -47,6 +47,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_cpsw.h"
+
 #include 
 #include 
 #include 
@@ -78,6 +80,11 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+ 
+#ifdef CPSW_ETHERSWITCH
+#include 
+#include "etherswitch_if.h"
+#endif
 
 #include "if_cpswreg.h"
 #include "if_cpswvar.h"
@@ -142,6 +149,19 @@ static void cpsw_add_sysctls(struct cpsw
 static void cpsw_stats_collect(struct cpsw_softc *);
 static int cpsw_stats_sysctl(SYSCTL_HANDLER_ARGS);
 
+#ifdef CPSW_ETHERSWITCH
+static etherswitch_info_t *cpsw_getinfo(device_t);
+static int cpsw_getport(device_t, etherswitch_port_t *);
+static int cpsw_setport(device_t, etherswitch_port_t *);
+static int cpsw_getconf(device_t, etherswitch_conf_t *);
+static int cpsw_getvgroup(device_t, etherswitch_vlangroup_t *);
+static int cpsw_setvgroup(device_t, etherswitch_vlangroup_t *);
+static int cpsw_readreg(device_t, int);
+static int cpsw_writereg(device_t, int, int);
+static int cpsw_readphy(device_t, int, int);
+static int cpsw_writephy(device_t, int, int, int);
+#endif
+
 /*
  * Arbitrary limit on number of segments in an mbuf to be transmitted.
  * Packets with more segments than this will be defragmented before
@@ -158,8 +178,23 @@ static device_method_t cpsw_methods[] = 
DEVMETHOD(device_shutdown,  cpsw_shutdown),
DEVMETHOD(device_suspend,   cpsw_suspend),
DEVMETHOD(device_resume,cpsw_resume),
+   /* Bus interface */
+   DEVMETHOD(bus_add_child,device_add_child_ordered),
/* OFW methods */
DEVMETHOD(ofw_bus_get_node, cpsw_get_node),
+#ifdef CPSW_ETHERSWITCH
+   /* etherswitch interface */
+   DEVMETHOD(etherswitch_getinfo,  cpsw_getinfo),
+   DEVMETHOD(etherswitch_readreg,  cpsw_readreg),
+   DEVMETHOD(etherswitch_writereg, cpsw_writereg),
+   DEVMETHOD(etherswitch_readphyreg,   cpsw_readphy),
+   DEVMETHOD(etherswitch_writephyreg,  cpsw_writephy),
+   DEVMETHOD(etherswitch_getport,  cpsw_getport),
+   DEVMETHOD(etherswitch_setport,  cpsw_setport),
+   DEVMETHOD(etherswitch_getvgroup,cpsw_getvgroup),
+   DEVMETHOD(etherswitch_setvgroup,cpsw_setvgroup),
+   DEVMETHOD(etherswitch_getconf,  cpsw_getconf),
+#endif
DEVMETHOD_END
 };
 
@@ -194,11 +229,20 @@ static driver_t cpswp_driver = {
 
 static devclass_t cpswp_devclass;
 
+#ifdef CPSW_ETHERSWITCH
+DRIVER_MODULE(etherswitch, cpswss, etherswitch_driver, etherswitch_devclass, 
0, 0);
+MODULE_DEPEND(cpswss, etherswitch, 1, 1, 1);
+#endif
+
 DRIVER_MODULE(cpsw, cpswss, cpswp_driver, cpswp_devclass, 0, 0);
 DRIVER_MODULE(miibus, cpsw, miibus_driver, miibus_devclass, 0, 0);
 MODULE_DEPEND(cpsw, ether, 1, 1, 1);
 MODULE_DEPEND(cpsw, miibus, 1, 1, 1);
 
+#ifdef CPSW_ETHERSWITCH
+static struct cpsw_vlangroups cpsw_vgroups[CPSW_VLANS];
+#endif
+
 static uint32_t slave_mdio_addr[] = { 0x4a100200, 0x4a100300 };
 
 static struct resource_spec irq_res_spec[] = {
@@ -576,7 +620,8 @@ cpsw_init(struct cpsw_softc *sc)
cpsw_write_4(sc, CPSW_PORT_P0_CPDMA_RX_CH_MAP, 0);
 
/* Initialize ALE: set host port to forwarding(3). */
-   cpsw_write_4(sc, CPSW_ALE_PORTCTL(0), 3);
+   cpsw_write_4(sc, CPSW_ALE_PORTCTL(0),
+   ALE_PORTCTL_INGRESS | ALE_PORTCTL_FORWARD);
 
cpsw_write_4(sc, CPSW_SS_PTYPE, 0);
 
@@ -851,6 +896,11 @@ cpsw_attach(device_t dev)
return (ENXIO);
}
 
+#ifdef CPSW_ETHERSWITCH
+   for (i = 0; i < CPSW_VLANS; i++)
+   cpsw_vgroups[i].vid = -1;
+#endif
+
/* Reset the controller. */
cpsw_reset(sc);
cpsw_init(sc);
@@ -864,6 +914,7 @@ cpsw_attach(device_t dev)
return (ENXIO);
}
}
+   bus_generic_probe(dev);
bus_generic_attach(dev);
 
return (0);
@@ -918,7 +969,12 @@ cpsw_detach(device_t dev)
mtx_destroy(>rx.lock);
mtx_destroy(>tx.lock);
 
-   return (0);
+   /* Detach the switch device, if present. */
+   error = bus_generic_detach(dev);
+   if (error != 0)
+   

svn commit: r308775 - head/sbin/etherswitchcfg

2016-11-17 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Nov 17 19:02:25 2016
New Revision: 308775
URL: https://svnweb.freebsd.org/changeset/base/308775

Log:
  Zero etherswitch_vlangroup structure before doing partial assignments.
  
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sbin/etherswitchcfg/etherswitchcfg.c

Modified: head/sbin/etherswitchcfg/etherswitchcfg.c
==
--- head/sbin/etherswitchcfg/etherswitchcfg.c   Thu Nov 17 18:38:35 2016
(r308774)
+++ head/sbin/etherswitchcfg/etherswitchcfg.c   Thu Nov 17 19:02:25 2016
(r308775)
@@ -308,7 +308,8 @@ set_vlangroup_vid(struct cfg *cfg, char 
 {
int v;
etherswitch_vlangroup_t vg;
-   
+
+   memset(, 0, sizeof(vg));
v = strtol(argv[1], NULL, 0);
if (v < 0 || v > IEEE802DOT1Q_VID_MAX)
errx(EX_USAGE, "vlan must be between 0 and %d", 
IEEE802DOT1Q_VID_MAX);
@@ -327,8 +328,9 @@ set_vlangroup_members(struct cfg *cfg, c
int member, untagged;
char *c, *d;
int v;
-   
+
member = untagged = 0;
+   memset(, 0, sizeof(vg));
if (strcmp(argv[1], "none") != 0) {
for (c=argv[1]; *c; c=d) {
v = strtol(c, , 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: r308698 - head/sys/arm/ti

2016-11-15 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Nov 15 21:18:55 2016
New Revision: 308698
URL: https://svnweb.freebsd.org/changeset/base/308698

Log:
  After r308533, the platform compatible string must be an exact match.
  
  Use "ti,am33xx" instead of "ti,am335x", which gives an exact match in every
  DTS we support.
  
  This fixes the boot on TI SoCs after r308533.
  
  Suggested by: gonzo
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/arm/ti/ti_machdep.c
==
--- head/sys/arm/ti/ti_machdep.cTue Nov 15 20:44:19 2016
(r308697)
+++ head/sys/arm/ti/ti_machdep.cTue Nov 15 21:18:55 2016
(r308698)
@@ -124,5 +124,5 @@ static platform_method_t am335x_methods[
PLATFORMMETHOD_END,
 };
 
-FDT_PLATFORM_DEF(am335x, "am335x", 0, "ti,am335x", 200);
+FDT_PLATFORM_DEF(am335x, "am335x", 0, "ti,am33xx", 200);
 #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: r308693 - head/sys/arm/ti

2016-11-15 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Nov 15 19:09:36 2016
New Revision: 308693
URL: https://svnweb.freebsd.org/changeset/base/308693

Log:
  Change the TI aintc driver name to "ti_aintc" to avoid the conflict with
  the aintc driver for Allwinner A10.
  
  This fixes the boot of the GENERIC ARM kernel on TI/AM335x SoCs.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: head/sys/arm/ti/aintc.c
==
--- head/sys/arm/ti/aintc.c Tue Nov 15 18:57:25 2016(r308692)
+++ head/sys/arm/ti/aintc.c Tue Nov 15 19:09:36 2016(r308693)
@@ -297,13 +297,13 @@ static device_method_t ti_aintc_methods[
 };
 
 static driver_t ti_aintc_driver = {
-   "aintc",
+   "ti_aintc",
ti_aintc_methods,
sizeof(struct ti_aintc_softc),
 };
 
 static devclass_t ti_aintc_devclass;
 
-EARLY_DRIVER_MODULE(aintc, simplebus, ti_aintc_driver, ti_aintc_devclass,
+EARLY_DRIVER_MODULE(ti_aintc, simplebus, ti_aintc_driver, ti_aintc_devclass,
 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
 SIMPLEBUS_PNP_INFO(compat_data);
___
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: r308692 - head/sys/arm/ti

2016-11-15 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Nov 15 18:57:25 2016
New Revision: 308692
URL: https://svnweb.freebsd.org/changeset/base/308692

Log:
  Fix ti_gpio_detach() to avoid crashing if something goes wrong.
  
  Sponsored by: Rubicon Communication, LLC (Netgate)

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

Modified: head/sys/arm/ti/ti_gpio.c
==
--- head/sys/arm/ti/ti_gpio.c   Tue Nov 15 18:22:50 2016(r308691)
+++ head/sys/arm/ti/ti_gpio.c   Tue Nov 15 18:57:25 2016(r308692)
@@ -710,7 +710,8 @@ ti_gpio_detach(device_t dev)
/* Disable all interrupts */
if (sc->sc_mem_res != NULL)
ti_gpio_intr_clr(sc, 0x);
-   gpiobus_detach_bus(dev);
+   if (sc->sc_busdev != NULL)
+   gpiobus_detach_bus(dev);
if (sc->sc_isrcs != NULL)
ti_gpio_pic_detach(sc);
/* Release the memory and IRQ resources. */
@@ -718,10 +719,12 @@ ti_gpio_detach(device_t dev)
bus_teardown_intr(dev, sc->sc_irq_res,
sc->sc_irq_hdl);
}
-   bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid,
-   sc->sc_irq_res);
-   bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid,
-   sc->sc_mem_res);
+   if (sc->sc_irq_res)
+   bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid,
+   sc->sc_irq_res);
+   if (sc->sc_mem_res)
+   bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid,
+   sc->sc_mem_res);
TI_GPIO_LOCK_DESTROY(sc);
 
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308659 - head/sys/contrib/vchiq/interface/compat

2016-11-14 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Nov 15 00:58:31 2016
New Revision: 308659
URL: https://svnweb.freebsd.org/changeset/base/308659

Log:
  Reduce dmesg verbosity.

Modified:
  head/sys/contrib/vchiq/interface/compat/vchi_bsd.c

Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.c
==
--- head/sys/contrib/vchiq/interface/compat/vchi_bsd.c  Tue Nov 15 00:28:07 
2016(r308658)
+++ head/sys/contrib/vchiq/interface/compat/vchi_bsd.c  Tue Nov 15 00:58:31 
2016(r308659)
@@ -300,7 +300,6 @@ void sema_sysinit(void *arg)
 {
struct semaphore *s = arg;
 
-   printf("sema_sysinit\n");
_sema_init(s, 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: r308651 - head/sys/arm/conf

2016-11-14 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Nov 14 20:57:30 2016
New Revision: 308651
URL: https://svnweb.freebsd.org/changeset/base/308651

Log:
  Add the cpsw, the NIC driver for ti/am335x, to GENERIC kernel.
  
  While here:
  
   - remove 'device mii' - included by miibus;
   - remove 'device smcphy' - included by miibus;
   - sorted the network drivers list;
   - added a comment about miibus based on amd64/GENERIC.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/conf/GENERIC

Modified: head/sys/arm/conf/GENERIC
==
--- head/sys/arm/conf/GENERIC   Mon Nov 14 20:37:07 2016(r308650)
+++ head/sys/arm/conf/GENERIC   Mon Nov 14 20:57:30 2016(r308651)
@@ -182,18 +182,18 @@ deviceusfs
 device loop
 device ether
 device vlan# 802.1Q VLAN support
-device mii
 device bpf
 
-device emac# 10/100 integrated EMAC controller
-device dwc # 10/100/1000 integrated GMAC controller
-device awg # 10/100/1000 integrated EMAC controller
-
-# USB ethernet support, requires miibus
-device smcphy
-device smsc
+# Ethernet NICs that use the common MII bus controller code.
+# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
 device miibus
 
+device awg # 10/100/1000 integrated EMAC controller
+device cpsw# TI Common Platform Ethernet Switch 
(CPSW)
+device dwc # 10/100/1000 integrated GMAC controller
+device emac# 10/100 integrated EMAC controller
+device smsc# SMSC LAN91C111
+
 # Sound support
 device sound
 
___
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: r308649 - head/sys/arm/conf

2016-11-14 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Nov 14 19:53:46 2016
New Revision: 308649
URL: https://svnweb.freebsd.org/changeset/base/308649

Log:
  Build the Ti/AM335x DTBs as part of GENERIC kernel.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/conf/GENERIC

Modified: head/sys/arm/conf/GENERIC
==
--- head/sys/arm/conf/GENERIC   Mon Nov 14 18:57:21 2016(r308648)
+++ head/sys/arm/conf/GENERIC   Mon Nov 14 19:53:46 2016(r308649)
@@ -219,4 +219,4 @@ options EFI
 
 # Flattened Device Tree
 optionsFDT # Configure using FDT/DTB data
-makeoptionsMODULES_EXTRA="dtb/allwinner dtb/nvidia dtb/rpi"
+makeoptionsMODULES_EXTRA="dtb/allwinner dtb/am335x dtb/nvidia dtb/rpi"
___
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: r308458 - in head/sys: boot/fdt/dts/arm modules/dtb/am335x

2016-11-08 Thread Luiz Otavio O Souza
On 9 November 2016 at 02:26, Emmanuel Vadot wrote:
> On Wed, 9 Nov 2016 04:07:15 + (UTC)
> Luiz Otavio O Souza wrote:
>
>> Author: loos
>> Date: Wed Nov  9 04:07:15 2016
>> New Revision: 308458
>> URL: https://svnweb.freebsd.org/changeset/base/308458
>>
>> Log:
>>   Add the DTS for the Netgate SG-1000 (micro-Firewall).
>>
>>   The SG-1000 boots with GENERIC ARM kernel on -head.
>>
>>   Obtained from:  pfSense
>>   Sponsored by:   Rubicon Communications, LLC (Netgate)
>>
>> Added:
>>   head/sys/boot/fdt/dts/arm/ubmc.dtsi   (contents, props changed)
>>   head/sys/boot/fdt/dts/arm/ufw.dts   (contents, props changed)
>> Modified:
>>   head/sys/modules/dtb/am335x/Makefile
>
>  Hello Luiz,
>
>  Two things:
>
>  - If ubmc.dtsi is gnu licenced it shouldn't go in sys/boot/fdt/dts.
> It shouldn't go to sys/gnu/dts too as it's not from upstream.
>   - I don't understand why you didn't use the am33xx.dtsi from
> upstream, it is the way to go for dts.
>
>  The correct way to add support for this board would be :
>
>  1) Create a ubmc.dtsi that uses upstream am33xx.dtsi and submit it
> upstream (i.e. linux-arm), MIT/GPL dual licence
>  2) Create a ufw.dts and also submit it upstream (also MIT/GPL)
>  3) Since those are also MIT you could add them to sys/boot/fdt
>  4) When we will update the dts from upstream you can then remove them
> from sys/boot/fdt
>
>  But there would still be a problem since the am33xx.dtsi is not MIT/GPL
> licenced.
>  So I guess you don't have any other solution than dealing with DTS
> somewhere in the pfsense repository (maybe with package or something).
>
>  The DTS world is already a mess with it's licence and the fact that
> linux is the "official" place, so please do not add more :)

Hi Emmanuel,

Yes, you're right.  I forgot about the licence in this file.

This is not an issue for us in pfSense (we do not depend on this
change in FreeBSD), we want to provide support for the people that is
going to use/test FreeBSD on uFW.

As this is all our work, I'll redo the files and include our changes
in a single file.

FreeBSD is the upstream here, it is the first officially supported OS for uFW.

Thanks,
Luiz
___
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: r308458 - in head/sys: boot/fdt/dts/arm modules/dtb/am335x

2016-11-08 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Nov  9 04:07:15 2016
New Revision: 308458
URL: https://svnweb.freebsd.org/changeset/base/308458

Log:
  Add the DTS for the Netgate SG-1000 (micro-Firewall).
  
  The SG-1000 boots with GENERIC ARM kernel on -head.
  
  Obtained from:pfSense
  Sponsored by: Rubicon Communications, LLC (Netgate)

Added:
  head/sys/boot/fdt/dts/arm/ubmc.dtsi   (contents, props changed)
  head/sys/boot/fdt/dts/arm/ufw.dts   (contents, props changed)
Modified:
  head/sys/modules/dtb/am335x/Makefile

Added: head/sys/boot/fdt/dts/arm/ubmc.dtsi
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/boot/fdt/dts/arm/ubmc.dtsi Wed Nov  9 04:07:15 2016
(r308458)
@@ -0,0 +1,315 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * $FreeBSD$
+ */
+
+/ {
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x1000>; /* 256 MB */
+   };
+
+   vmmcsd_fixed: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vmmcsd_fixed";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+};
+
+_pinmux {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pin>;
+
+   i2c0_pins: pinmux_i2c0_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x988, PIN_INPUT_PULLUP | MUX_MODE0)   
/* i2c0_sda.i2c0_sda */
+   AM33XX_IOPAD(0x98c, PIN_INPUT_PULLUP | MUX_MODE0)   
/* i2c0_scl.i2c0_scl */
+   >;
+   };
+
+   i2c1_pins: pinmux_i2c1_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x968, PIN_INPUT_PULLUP | MUX_MODE3)   
/* uart0_ctsn.i2c1_sda */
+   AM33XX_IOPAD(0x96c, PIN_INPUT_PULLUP | MUX_MODE3)   
/* uart0_rtsn.i2c1_scl */
+   >;
+   };
+
+   spi0_pins: pinmux_spi0_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x950, PIN_INPUT_PULLDOWN | MUX_MODE0) 
/* spi0_sclk.spi0_sclk */
+   AM33XX_IOPAD(0x954, PIN_INPUT_PULLDOWN | MUX_MODE0) 
/* spi0_d0.spi0_miso */
+   AM33XX_IOPAD(0x958, PIN_INPUT_PULLUP | MUX_MODE0)   
/* spi0_d1.spi0_mosi */
+   AM33XX_IOPAD(0x95c, PIN_INPUT_PULLUP | MUX_MODE0)   
/* spi0_cs0.spi0_cs0 */
+   >;
+   };
+
+   spi1_pins: pinmux_spi1_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x908, PIN_INPUT_PULLDOWN | MUX_MODE2) 
/* mii1_col.spi1_sclk */
+   AM33XX_IOPAD(0x90c, PIN_INPUT_PULLDOWN | MUX_MODE2) 
/* mii1_crs.spi1_miso */
+   AM33XX_IOPAD(0x910, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rx_er.spi1_mosi */
+   AM33XX_IOPAD(0x944, PIN_INPUT_PULLUP | MUX_MODE2)   
/* rmii1_ref_clk.spi1_cs0 */
+   >;
+   };
+
+   uart0_pins: pinmux_uart0_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x970, PIN_INPUT_PULLUP | MUX_MODE0)   
/* uart0_rxd.uart0_rxd */
+   AM33XX_IOPAD(0x974, PIN_OUTPUT_PULLDOWN | MUX_MODE0)
/* uart0_txd.uart0_txd */
+   >;
+   };
+
+   clkout2_pin: pinmux_clkout2_pin {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x9b4, PIN_OUTPUT_PULLDOWN | MUX_MODE3)
/* xdma_event_intr1.clkout2 */
+   >;
+   };
+
+   cpsw_default: cpsw_default {
+   pinctrl-single,pins = <
+   /* Slave 1 */
+   AM33XX_IOPAD(0x914, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txen.rgmii_1_txen */
+   AM33XX_IOPAD(0x918, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxdv.rgmii_1_rxdv */
+   AM33XX_IOPAD(0x91c, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd3.rgmii_1_txd3 */
+   AM33XX_IOPAD(0x920, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd2.rgmii_1_txd2 */
+   AM33XX_IOPAD(0x924, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd1.rgmii_1_txd1 */
+   AM33XX_IOPAD(0x928, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txd0.rgmii_1_txd0 */
+   AM33XX_IOPAD(0x92c, PIN_OUTPUT_PULLDOWN | MUX_MODE2)
/* mii1_txclk.rgmii_1_txclk */
+   AM33XX_IOPAD(0x930, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxclk.rgmii_1_rxclk */
+   AM33XX_IOPAD(0x934, PIN_INPUT_PULLUP | MUX_MODE2)   
/* mii1_rxd3.rgmii_1_rxd3 */
+   AM33XX_IOPAD(0x938, 

svn commit: r308237 - head/sys/netpfil/ipfw

2016-11-02 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Nov  3 00:26:58 2016
New Revision: 308237
URL: https://svnweb.freebsd.org/changeset/base/308237

Log:
  Remove the mbuf tag after use (for reinjected packets).
  
  Fixes the packet processing in dummynet l2 rules.
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/netpfil/ipfw/ip_fw_pfil.c

Modified: head/sys/netpfil/ipfw/ip_fw_pfil.c
==
--- head/sys/netpfil/ipfw/ip_fw_pfil.c  Wed Nov  2 23:58:10 2016
(r308236)
+++ head/sys/netpfil/ipfw/ip_fw_pfil.c  Thu Nov  3 00:26:58 2016
(r308237)
@@ -315,20 +315,15 @@ ipfw_check_frame(void *arg, struct mbuf 
struct ip_fw_args args;
struct m_tag *mtag;
 
-   /* fetch start point from rule, if any */
+   /* fetch start point from rule, if any.  remove the tag if present. */
mtag = m_tag_locate(*m0, MTAG_IPFW_RULE, 0, NULL);
if (mtag == NULL) {
args.rule.slot = 0;
} else {
-   /* dummynet packet, already partially processed */
-   struct ipfw_rule_ref *r;
-
-   /* XXX can we free it after use ? */
-   mtag->m_tag_id = PACKET_TAG_NONE;
-   r = (struct ipfw_rule_ref *)(mtag + 1);
-   if (r->info & IPFW_ONEPASS)
+   args.rule = *((struct ipfw_rule_ref *)(mtag+1));
+   m_tag_delete(*m0, mtag);
+   if (args.rule.info & IPFW_ONEPASS)
return (0);
-   args.rule = *r;
}
 
/* I need some amt of data to be contiguous */
___
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: r308176 - head/sys/netpfil/ipfw

2016-11-01 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Nov  1 18:42:44 2016
New Revision: 308176
URL: https://svnweb.freebsd.org/changeset/base/308176

Log:
  Stop abusing from struct ifnet presence to determine the packet direction
  for dummynet, use the correct argument for that, remove the false coment
  about the presence of struct ifnet.
  
  Fixes the input match of dummynet l2 rules.
  
  Obtained from:pfSense
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/netpfil/ipfw/ip_fw_pfil.c

Modified: head/sys/netpfil/ipfw/ip_fw_pfil.c
==
--- head/sys/netpfil/ipfw/ip_fw_pfil.c  Tue Nov  1 18:18:09 2016
(r308175)
+++ head/sys/netpfil/ipfw/ip_fw_pfil.c  Tue Nov  1 18:42:44 2016
(r308176)
@@ -303,11 +303,9 @@ again:
 
 /*
  * ipfw processing for ethernet packets (in and out).
- * Inteface is NULL from ether_demux, and ifp from
- * ether_output_frame.
  */
 int
-ipfw_check_frame(void *arg, struct mbuf **m0, struct ifnet *dst, int dir,
+ipfw_check_frame(void *arg, struct mbuf **m0, struct ifnet *ifp, int dir,
 struct inpcb *inp)
 {
struct ether_header *eh;
@@ -348,7 +346,7 @@ ipfw_check_frame(void *arg, struct mbuf 
m_adj(m, ETHER_HDR_LEN);/* strip ethernet header */
 
args.m = m; /* the packet we are looking at */
-   args.oif = dir == PFIL_OUT ? dst: NULL; /* destination, if any  */
+   args.oif = dir == PFIL_OUT ? ifp: NULL; /* destination, if any  */
args.next_hop = NULL;   /* we do not support forward yet*/
args.next_hop6 = NULL;  /* we do not support forward yet*/
args.eh = _eh; /* MAC header for bridged/MAC packets   */
@@ -383,14 +381,13 @@ ipfw_check_frame(void *arg, struct mbuf 
 
case IP_FW_DUMMYNET:
ret = EACCES;
-   int dir;
 
if (ip_dn_io_ptr == NULL)
break; /* i.e. drop */
 
*m0 = NULL;
-   dir = PROTO_LAYER2 | (dst ? DIR_OUT : DIR_IN);
-   ip_dn_io_ptr(, dir, );
+   dir = (dir == PFIL_IN) ? DIR_IN : DIR_OUT;
+   ip_dn_io_ptr(, dir | PROTO_LAYER2, );
return 0;
 
default:
___
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: r306717 - head/sys/arm/ti/cpsw

2016-10-05 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Oct  5 19:09:27 2016
New Revision: 306717
URL: https://svnweb.freebsd.org/changeset/base/306717

Log:
  if_cpsw overhaul:
  
  - Fix RX and TX teardown:
. TX teardown would not reclaim the abandoned descriptors;
. Interrupt storms in RX teardown;
. Fixed the acknowledge of the teardown completion interrupt.
  
  - Remove temporary lists for the descriptors;
  
  - Simplified the descriptor handling (less writes and reads from
descriptors where possible);
  
  - Better debug;
  
  - Add support for the RX threshold interrupts:
With interrupt moderation only, an RX overrun is likely to happen.  The
RX threshold is set to trigger a non paced interrupt everytime your RX
free buffers are under the minimum threshold, helping to prevent the rx
overrun.
  
  The NIC now survive when pushed over its limits (where previously it would
  lock up in a few seconds).
  
  uFW (600MHz SoC) can now forward up to 560Mb/s of UDP traffic (netmap
  pkt-gen as source and sink).  TCP forwarding rate is over 350Mb/s.
  
  No difference (other than CPU use) was seen on Beaglebone black (1GHz SoC)
  for his fast ethernet.
  
  Tested on:uFW, BBB
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/cpsw/if_cpswreg.h
  head/sys/arm/ti/cpsw/if_cpswvar.h

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Wed Oct  5 19:01:00 2016
(r306716)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Wed Oct  5 19:09:27 2016
(r306717)
@@ -336,6 +336,8 @@ cpsw_debugf(const char *fmt, ...)
bus_write_region_4(sc->mem_res, slot->bd_offset, (uint32_t *) val, 4)
 #definecpsw_cpdma_write_bd_next(sc, slot, next_slot)   
\
cpsw_write_4(sc, slot->bd_offset, cpsw_cpdma_bd_paddr(sc, next_slot))
+#definecpsw_cpdma_write_bd_flags(sc, slot, val)
\
+   bus_write_2(sc->mem_res, slot->bd_offset + 14, val)
 #definecpsw_cpdma_read_bd_flags(sc, slot)  
\
bus_read_2(sc->mem_res, slot->bd_offset + 14)
 #definecpsw_write_hdp_slot(sc, queue, slot)
\
@@ -383,7 +385,8 @@ cpsw_dump_slot(struct cpsw_softc *sc, st
int i;
 
cpsw_cpdma_read_bd(sc, slot, );
-   printf("BD Addr: 0x%08x   Next: 0x%08x\n", cpsw_cpdma_bd_paddr(sc, 
slot), bd.next);
+   printf("BD Addr : 0x%08x   Next  : 0x%08x\n",
+   cpsw_cpdma_bd_paddr(sc, slot), bd.next);
printf("  BufPtr: 0x%08x   BufLen: 0x%08x\n", bd.bufptr, bd.buflen);
printf("  BufOff: 0x%08x   PktLen: 0x%08x\n", bd.bufoff, bd.pktlen);
printf("  Flags: ");
@@ -417,7 +420,7 @@ cpsw_dump_queue(struct cpsw_softc *sc, s
int others = 0;
 
STAILQ_FOREACH(slot, q, next) {
-   if (i > 4)
+   if (i > CPSW_TXFRAGS)
++others;
else
cpsw_dump_slot(sc, slot);
@@ -581,16 +584,14 @@ cpsw_init(struct cpsw_softc *sc)
/* Enable statistics for ports 0, 1 and 2 */
cpsw_write_4(sc, CPSW_SS_STAT_PORT_EN, 7);
 
-   /* Experiment:  Turn off flow control */
-   /* This seems to fix the watchdog resets that have plagued
-  earlier versions of this driver; I'm not yet sure if there
-  are negative effects yet. */
+   /* Turn off flow control. */
cpsw_write_4(sc, CPSW_SS_FLOW_CONTROL, 0);
 
/* Make IP hdr aligned with 4 */
cpsw_write_4(sc, CPSW_CPDMA_RX_BUFFER_OFFSET, 2);
 
/* Initialize RX Buffer Descriptors */
+   cpsw_write_4(sc, CPSW_CPDMA_RX_PENDTHRESH(0), 0);
cpsw_write_4(sc, CPSW_CPDMA_RX_FREEBUFFER(0), 0);
 
/* Enable TX & RX DMA */
@@ -607,7 +608,8 @@ cpsw_init(struct cpsw_softc *sc)
cpsw_write_4(sc, CPSW_CPDMA_DMA_INTMASK_SET, 3);
 
/* Enable interrupts for RX and TX on Channel 0 */
-   cpsw_write_4(sc, CPSW_CPDMA_RX_INTMASK_SET, 1);
+   cpsw_write_4(sc, CPSW_CPDMA_RX_INTMASK_SET,
+   CPSW_CPDMA_RX_INT(0) | CPSW_CPDMA_RX_INT_THRESH(0));
cpsw_write_4(sc, CPSW_CPDMA_TX_INTMASK_SET, 1);
 
/* Initialze MDIO - ENABLE, PREAMBLE=0, FAULTENB, CLKDIV=0xFF */
@@ -625,6 +627,8 @@ cpsw_init(struct cpsw_softc *sc)
if (slot != NULL)
cpsw_write_hdp_slot(sc, >rx, slot);
cpsw_rx_enqueue(sc);
+   cpsw_write_4(sc, CPSW_CPDMA_RX_FREEBUFFER(0), sc->rx.active_queue_len);
+   cpsw_write_4(sc, CPSW_CPDMA_RX_PENDTHRESH(0), CPSW_TXFRAGS);
 
/* Activate network interface. */
sc->rx.running = 1;
@@ -1154,58 +1158,52 @@ cpsw_shutdown(device_t dev)
 }
 
 static void
-cpsw_rx_teardown_locked(struct cpsw_softc *sc)
+cpsw_rx_teardown(struct cpsw_softc *sc)
 {
-   struct ifnet *ifp;
-   struct mbuf *received, *next;
int i = 0;
 
+   

svn commit: r306654 - head/sys/arm/ti/cpsw

2016-10-03 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Oct  3 19:48:56 2016
New Revision: 306654
URL: https://svnweb.freebsd.org/changeset/base/306654

Log:
  Enable the TX completion interrupt for the cpsw NIC to assure the free tx
  descriptors are reclaimed as soon as possible.
  
  Without this the free buffers are reclaimed only on watchdog runs or after
  trying to enqueue more packets.
  
  Sponsored by: Rubicon Communications, LLC (Netgte)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Mon Oct  3 19:34:32 2016
(r306653)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Mon Oct  3 19:48:56 2016
(r306654)
@@ -117,6 +117,7 @@ static void cpsw_intr_rx(void *arg);
 static struct mbuf *cpsw_rx_dequeue(struct cpsw_softc *);
 static void cpsw_rx_enqueue(struct cpsw_softc *);
 static void cpswp_start(struct ifnet *);
+static void cpsw_intr_tx(void *);
 static void cpswp_tx_enqueue(struct cpswp_softc *);
 static int cpsw_tx_dequeue(struct cpsw_softc *);
 
@@ -209,6 +210,15 @@ static struct resource_spec irq_res_spec
{ -1, 0 }
 };
 
+static struct {
+   void (*cb)(void *);
+} cpsw_intr_cb[] = {
+   { cpsw_intr_rx_thresh },
+   { cpsw_intr_rx },
+   { cpsw_intr_tx },
+   { cpsw_intr_misc },
+};
+
 /* Number of entries here must match size of stats
  * array in struct cpswp_softc. */
 static struct cpsw_stat {
@@ -590,13 +600,15 @@ cpsw_init(struct cpsw_softc *sc)
/* Enable Interrupts for core 0 */
cpsw_write_4(sc, CPSW_WR_C_RX_THRESH_EN(0), 0xFF);
cpsw_write_4(sc, CPSW_WR_C_RX_EN(0), 0xFF);
+   cpsw_write_4(sc, CPSW_WR_C_TX_EN(0), 0xFF);
cpsw_write_4(sc, CPSW_WR_C_MISC_EN(0), 0x1F);
 
/* Enable host Error Interrupt */
cpsw_write_4(sc, CPSW_CPDMA_DMA_INTMASK_SET, 3);
 
-   /* Enable interrupts for RX Channel 0 */
+   /* Enable interrupts for RX and TX on Channel 0 */
cpsw_write_4(sc, CPSW_CPDMA_RX_INTMASK_SET, 1);
+   cpsw_write_4(sc, CPSW_CPDMA_TX_INTMASK_SET, 1);
 
/* Initialze MDIO - ENABLE, PREAMBLE=0, FAULTENB, CLKDIV=0xFF */
/* TODO Calculate MDCLK=CLK/(CLKDIV+1) */
@@ -645,22 +657,14 @@ cpsw_probe(device_t dev)
 static int
 cpsw_intr_attach(struct cpsw_softc *sc)
 {
+   int i;
 
-   /* Note: We don't use sc->irq_res[2] (TX interrupt) */
-   if (bus_setup_intr(sc->dev, sc->irq_res[0],
-   INTR_TYPE_NET | INTR_MPSAFE, NULL, cpsw_intr_rx_thresh,
-   sc, >ih_cookie[0]) != 0) {
-   return (-1);
-   }
-   if (bus_setup_intr(sc->dev, sc->irq_res[1],
-   INTR_TYPE_NET | INTR_MPSAFE, NULL, cpsw_intr_rx,
-   sc, >ih_cookie[1]) != 0) {
-   return (-1);
-   }
-   if (bus_setup_intr(sc->dev, sc->irq_res[3],
-   INTR_TYPE_NET | INTR_MPSAFE, NULL, cpsw_intr_misc,
-   sc, >ih_cookie[3]) != 0) {
-   return (-1);
+   for (i = 0; i < CPSW_INTR_COUNT; i++) {
+   if (bus_setup_intr(sc->dev, sc->irq_res[i],
+   INTR_TYPE_NET | INTR_MPSAFE, NULL,
+   cpsw_intr_cb[i].cb, sc, >ih_cookie[i]) != 0) {
+   return (-1);
+   }
}
 
return (0);
@@ -1696,6 +1700,18 @@ cpswp_start(struct ifnet *ifp)
 }
 
 static void
+cpsw_intr_tx(void *arg)
+{
+   struct cpsw_softc *sc;
+
+   sc = (struct cpsw_softc *)arg;
+   CPSW_TX_LOCK(sc);
+   cpsw_tx_dequeue(sc);
+   cpsw_write_4(sc, CPSW_CPDMA_CPDMA_EOI_VECTOR, 2);
+   CPSW_TX_UNLOCK(sc);
+}
+
+static void
 cpswp_tx_enqueue(struct cpswp_softc *sc)
 {
bus_dma_segment_t segs[CPSW_TXFRAGS];
___
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: r306513 - head/sys/arm/ti/cpsw

2016-09-30 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Sep 30 17:30:39 2016
New Revision: 306513
URL: https://svnweb.freebsd.org/changeset/base/306513

Log:
  Remove the GLOBAL queue lock which just adds unnecessary complexity to code
  (when used together with the individual tx and rx locks).
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Fri Sep 30 17:27:17 2016
(r306512)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Fri Sep 30 17:30:39 2016
(r306513)
@@ -301,25 +301,6 @@ cpsw_debugf(const char *fmt, ...)
 #defineCPSW_RX_UNLOCK(sc)  mtx_unlock(&(sc)->rx.lock)
 #defineCPSW_RX_LOCK_ASSERT(sc) mtx_assert(&(sc)->rx.lock, MA_OWNED)
 
-#defineCPSW_GLOBAL_LOCK(sc) do {   
\
-   if ((mtx_owned(&(sc)->tx.lock) ? 1 : 0) !=  \
-   (mtx_owned(&(sc)->rx.lock) ? 1 : 0)) {  \
-   panic("cpsw deadlock possibility detection!");  \
-   }   \
-   mtx_lock(&(sc)->tx.lock);   \
-   mtx_lock(&(sc)->rx.lock);   \
-} while (0)
-
-#defineCPSW_GLOBAL_UNLOCK(sc) do { 
\
-   CPSW_RX_UNLOCK(sc); \
-   CPSW_TX_UNLOCK(sc); \
-} while (0)
-
-#defineCPSW_GLOBAL_LOCK_ASSERT(sc) do {
\
-   CPSW_TX_LOCK_ASSERT(sc);\
-   CPSW_RX_LOCK_ASSERT(sc);\
-} while (0)
-
 #define CPSW_PORT_LOCK(_sc) do {   \
mtx_assert(&(_sc)->lock, MA_NOTOWNED);  \
mtx_lock(&(_sc)->lock); \
@@ -1179,7 +1160,7 @@ cpsw_rx_teardown_locked(struct cpsw_soft
cpsw_write_4(sc, CPSW_CPDMA_RX_TEARDOWN, 0);
for (;;) {
received = cpsw_rx_dequeue(sc);
-   CPSW_GLOBAL_UNLOCK(sc);
+   CPSW_RX_UNLOCK(sc);
while (received != NULL) {
next = received->m_nextpkt;
received->m_nextpkt = NULL;
@@ -1188,7 +1169,7 @@ cpsw_rx_teardown_locked(struct cpsw_soft
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
received = next;
}
-   CPSW_GLOBAL_LOCK(sc);
+   CPSW_RX_LOCK(sc);
if (!sc->rx.running) {
CPSW_DEBUGF(sc,
("finished RX teardown (%d retries)", i));
@@ -1245,10 +1226,12 @@ cpswp_stop_locked(struct cpswp_softc *sc
 
/* Tear down the RX/TX queues. */
if (cpsw_ports_down(sc->swsc)) {
-   CPSW_GLOBAL_LOCK(sc->swsc);
+   CPSW_RX_LOCK(sc->swsc);
cpsw_rx_teardown_locked(sc->swsc);
+   CPSW_RX_UNLOCK(sc->swsc);
+   CPSW_TX_LOCK(sc->swsc);
cpsw_tx_teardown_locked(sc->swsc);
-   CPSW_GLOBAL_UNLOCK(sc->swsc);
+   CPSW_TX_UNLOCK(sc->swsc);
}
 
/* Stop MAC RX/TX modules. */
@@ -2155,7 +2138,7 @@ cpsw_tx_watchdog(void *msc)
struct cpsw_softc *sc;
 
sc = msc;
-   CPSW_GLOBAL_LOCK(sc);
+   CPSW_TX_LOCK(sc);
if (sc->tx.active_queue_len == 0 || !sc->tx.running) {
sc->watchdog.timer = 0; /* Nothing to do. */
} else if (sc->tx.queue_removes > sc->tx.queue_removes_at_last_tick) {
@@ -2172,7 +2155,7 @@ cpsw_tx_watchdog(void *msc)
}
}
sc->tx.queue_removes_at_last_tick = sc->tx.queue_removes;
-   CPSW_GLOBAL_UNLOCK(sc);
+   CPSW_TX_UNLOCK(sc);
 
/* Schedule another timeout one second from now */
callout_reset(>watchdog.callout, hz, cpsw_tx_watchdog, sc);
___
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: r306511 - head/sys/arm/ti/cpsw

2016-09-30 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Sep 30 17:19:43 2016
New Revision: 306511
URL: https://svnweb.freebsd.org/changeset/base/306511

Log:
  Fix a typo in CPSW_DEBUG MACRO and then replace all the CPSWP_DEBUG() calls
  with CPSW_DEBUG().
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Fri Sep 30 17:16:02 2016
(r306510)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Fri Sep 30 17:19:43 2016
(r306511)
@@ -255,8 +255,6 @@ static struct cpsw_stat {
  * Basic debug support.
  */
 
-#defineIF_DEBUG(_sc)   if ((_sc)->if_flags & IFF_DEBUG)
-
 static void
 cpsw_debugf_head(const char *funcname)
 {
@@ -278,20 +276,12 @@ cpsw_debugf(const char *fmt, ...)
 }
 
 #defineCPSW_DEBUGF(_sc, a) do {
\
-   if (sc->debug) {\
+   if ((_sc)->debug) { \
cpsw_debugf_head(__func__); \
cpsw_debugf a;  \
}   \
 } while (0)
 
-#defineCPSWP_DEBUGF(_sc, a) do {   
\
-   IF_DEBUG((_sc)) {   \
-   cpsw_debugf_head(__func__); \
-   cpsw_debugf a;  \
-   }   \
-} while (0)
-
-
 /*
  * Locking macros
  */
@@ -1052,7 +1042,7 @@ cpswp_detach(device_t dev)
struct cpswp_softc *sc;
 
sc = device_get_softc(dev);
-   CPSWP_DEBUGF(sc, (""));
+   CPSW_DEBUGF(sc->swsc, (""));
if (device_is_attached(dev)) {
ether_ifdetach(sc->ifp);
CPSW_PORT_LOCK(sc);
@@ -1098,7 +1088,7 @@ cpswp_init(void *arg)
 {
struct cpswp_softc *sc = arg;
 
-   CPSWP_DEBUGF(sc, (""));
+   CPSW_DEBUGF(sc->swsc, (""));
CPSW_PORT_LOCK(sc);
cpswp_init_locked(arg);
CPSW_PORT_UNLOCK(sc);
@@ -,7 +1101,7 @@ cpswp_init_locked(void *arg)
struct ifnet *ifp;
uint32_t reg;
 
-   CPSWP_DEBUGF(sc, (""));
+   CPSW_DEBUGF(sc->swsc, (""));
CPSW_PORT_LOCK_ASSERT(sc);
ifp = sc->ifp;
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
@@ -1240,7 +1230,7 @@ cpswp_stop_locked(struct cpswp_softc *sc
uint32_t reg;
 
ifp = sc->ifp;
-   CPSWP_DEBUGF(sc, (""));
+   CPSW_DEBUGF(sc->swsc, (""));
CPSW_PORT_LOCK_ASSERT(sc);
 
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
@@ -1362,7 +1352,7 @@ cpswp_ioctl(struct ifnet *ifp, u_long co
if (ifp->if_flags & IFF_UP) {
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
changed = ifp->if_flags ^ sc->if_flags;
-   CPSWP_DEBUGF(sc,
+   CPSW_DEBUGF(sc->swsc,
("SIOCSIFFLAGS: UP & RUNNING 
(changed=0x%x)",
changed));
if (changed & IFF_PROMISC)
@@ -1372,12 +1362,12 @@ cpswp_ioctl(struct ifnet *ifp, u_long co
cpsw_set_allmulti(sc,
ifp->if_flags & IFF_ALLMULTI);
} else {
-   CPSWP_DEBUGF(sc,
+   CPSW_DEBUGF(sc->swsc,
("SIOCSIFFLAGS: UP but not RUNNING; 
starting up"));
cpswp_init_locked(sc);
}
} else if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-   CPSWP_DEBUGF(sc,
+   CPSW_DEBUGF(sc->swsc,
("SIOCSIFFLAGS: not UP but RUNNING; shutting 
down"));
cpswp_stop_locked(sc);
}
@@ -1488,7 +1478,7 @@ cpswp_miibus_statchg(device_t dev)
uint32_t mac_control, reg;
 
sc = device_get_softc(dev);
-   CPSWP_DEBUGF(sc, (""));
+   CPSW_DEBUGF(sc->swsc, (""));
 
reg = CPSW_SL_MACCONTROL(sc->unit);
mac_control = cpsw_read_4(sc->swsc, reg);
@@ -1766,7 +1756,7 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
"Can't defragment packet; dropping\n");
m_freem(slot->mbuf);
} else {
-   CPSWP_DEBUGF(sc,
+   CPSW_DEBUGF(sc->swsc,
("Requeueing defragmented packet"));
IF_PREPEND(>ifp->if_snd, m0);
   

svn commit: r306510 - head/sys/arm/ti/cpsw

2016-09-30 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Sep 30 17:16:02 2016
New Revision: 306510
URL: https://svnweb.freebsd.org/changeset/base/306510

Log:
  Sort and remove unnecessary includes.
  
  No functional changes.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Fri Sep 30 17:11:03 2016
(r306509)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Fri Sep 30 17:16:02 2016
(r306510)
@@ -48,35 +48,27 @@
 __FBSDID("$FreeBSD$");
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
+#include 
 #include 
 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
 
 #include 
 #include 
@@ -273,7 +265,6 @@ cpsw_debugf_head(const char *funcname)
printf("%02d:%02d:%02d %s ", t / (60 * 60), (t / 60) % 60, t % 60, 
funcname);
 }
 
-#include 
 static void
 cpsw_debugf(const char *fmt, ...)
 {
___
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: r306388 - head/sys/arm/ti/cpsw

2016-09-27 Thread Luiz Otavio O Souza
Author: loos
Date: Wed Sep 28 04:22:06 2016
New Revision: 306388
URL: https://svnweb.freebsd.org/changeset/base/306388

Log:
  Fix a typo.
  
  Pointy hat to:loos

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Wed Sep 28 04:08:20 2016
(r306387)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Wed Sep 28 04:22:06 2016
(r306388)
@@ -1941,7 +1941,7 @@ cpsw_tx_dequeue(struct cpsw_softc *sc)
 
/* TearDown complete is only marked on the SOP for the packet. 
*/
if ((flags & (CPDMA_BD_SOP | CPDMA_BD_TDOWNCMPLT)) ==
-   (CPDMA_BD_EOP | CPDMA_BD_TDOWNCMPLT)) {
+   (CPDMA_BD_SOP | CPDMA_BD_TDOWNCMPLT)) {
CPSW_DEBUGF(sc, ("TX teardown in progress"));
cpsw_write_cp(sc, >tx, 0xfffc);
// TODO: Increment a count of dropped TX packets
___
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: r306376 - head/sys/arm/ti/cpsw

2016-09-27 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Sep 27 18:19:29 2016
New Revision: 306376
URL: https://svnweb.freebsd.org/changeset/base/306376

Log:
  Add a sysctl to control the interrupt pacing on AM335x integrated switch.
  
  The hardware can be set to limit the number of interrupts from 2 to 63
  interrupts per ms.
  
  To keep the compatibility with the TI documentation the sysctl take the
  interval between the interrupts pulses: 16~500 us.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/cpsw/if_cpswreg.h
  head/sys/arm/ti/cpsw/if_cpswvar.h

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Tue Sep 27 18:08:38 2016
(r306375)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Tue Sep 27 18:19:29 2016
(r306376)
@@ -583,6 +583,11 @@ cpsw_init(struct cpsw_softc *sc)
struct cpsw_slot *slot;
uint32_t reg;
 
+   /* Disable the interrupt pacing. */
+   reg = cpsw_read_4(sc, CPSW_WR_INT_CONTROL);
+   reg &= ~(CPSW_WR_INT_PACE_EN | CPSW_WR_INT_PRESCALE_MASK);
+   cpsw_write_4(sc, CPSW_WR_INT_CONTROL, reg);
+
/* Clear ALE */
cpsw_write_4(sc, CPSW_ALE_CONTROL, CPSW_ALE_CTL_CLEAR_TBL);
 
@@ -2492,6 +2497,51 @@ cpsw_stat_attached(SYSCTL_HANDLER_ARGS)
 }
 
 static int
+cpsw_intr_coalesce(SYSCTL_HANDLER_ARGS)
+{
+   int error;
+   struct cpsw_softc *sc;
+   uint32_t ctrl, intr_per_ms;
+
+   sc = (struct cpsw_softc *)arg1;
+   error = sysctl_handle_int(oidp, >coal_us, 0, req);
+   if (error != 0 || req->newptr == NULL)
+   return (error);
+
+   ctrl = cpsw_read_4(sc, CPSW_WR_INT_CONTROL);
+   ctrl &= ~(CPSW_WR_INT_PACE_EN | CPSW_WR_INT_PRESCALE_MASK);
+   if (sc->coal_us == 0) {
+   /* Disable the interrupt pace hardware. */
+   cpsw_write_4(sc, CPSW_WR_INT_CONTROL, ctrl);
+   cpsw_write_4(sc, CPSW_WR_C_RX_IMAX(0), 0);
+   cpsw_write_4(sc, CPSW_WR_C_TX_IMAX(0), 0);
+   return (0);
+   }
+
+   if (sc->coal_us > CPSW_WR_C_IMAX_US_MAX)
+   sc->coal_us = CPSW_WR_C_IMAX_US_MAX;
+   if (sc->coal_us < CPSW_WR_C_IMAX_US_MIN)
+   sc->coal_us = CPSW_WR_C_IMAX_US_MIN;
+   intr_per_ms = 1000 / sc->coal_us;
+   /* Just to make sure... */
+   if (intr_per_ms > CPSW_WR_C_IMAX_MAX)
+   intr_per_ms = CPSW_WR_C_IMAX_MAX;
+   if (intr_per_ms < CPSW_WR_C_IMAX_MIN)
+   intr_per_ms = CPSW_WR_C_IMAX_MIN;
+
+   /* Set the prescale to produce 4us pulses from the 125 Mhz clock. */
+   ctrl |= (125 * 4) & CPSW_WR_INT_PRESCALE_MASK;
+
+   /* Enable the interrupt pace hardware. */
+   cpsw_write_4(sc, CPSW_WR_C_RX_IMAX(0), intr_per_ms);
+   cpsw_write_4(sc, CPSW_WR_C_TX_IMAX(0), intr_per_ms);
+   ctrl |= CPSW_WR_INT_C0_RX_PULSE | CPSW_WR_INT_C0_TX_PULSE;
+   cpsw_write_4(sc, CPSW_WR_INT_CONTROL, ctrl);
+
+   return (0);
+}
+
+static int
 cpsw_stat_uptime(SYSCTL_HANDLER_ARGS)
 {
struct cpsw_softc *swsc;
@@ -2576,6 +2626,10 @@ cpsw_add_sysctls(struct cpsw_softc *sc)
CTLTYPE_UINT | CTLFLAG_RD, sc, 0, cpsw_stat_attached, "IU",
"Time since driver attach");
 
+   SYSCTL_ADD_PROC(ctx, parent, OID_AUTO, "intr_coalesce_us",
+   CTLTYPE_UINT | CTLFLAG_RW, sc, 0, cpsw_intr_coalesce, "IU",
+   "minimum time between interrupts");
+
node = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "ports",
CTLFLAG_RD, NULL, "CPSW Ports Statistics");
ports_parent = SYSCTL_CHILDREN(node);

Modified: head/sys/arm/ti/cpsw/if_cpswreg.h
==
--- head/sys/arm/ti/cpsw/if_cpswreg.h   Tue Sep 27 18:08:38 2016
(r306375)
+++ head/sys/arm/ti/cpsw/if_cpswreg.h   Tue Sep 27 18:19:29 2016
(r306376)
@@ -138,6 +138,17 @@
 #defineCPSW_WR_SOFT_RESET  (CPSW_WR_OFFSET + 0x04)
 #defineCPSW_WR_CONTROL (CPSW_WR_OFFSET + 0x08)
 #defineCPSW_WR_INT_CONTROL (CPSW_WR_OFFSET + 0x0c)
+#define CPSW_WR_INT_C0_RX_PULSE(1 << 16)
+#define CPSW_WR_INT_C0_TX_PULSE(1 << 17)
+#define CPSW_WR_INT_C1_RX_PULSE(1 << 18)
+#define CPSW_WR_INT_C1_TX_PULSE(1 << 19)
+#define CPSW_WR_INT_C2_RX_PULSE(1 << 20)
+#define CPSW_WR_INT_C2_TX_PULSE(1 << 21)
+#define CPSW_WR_INT_PACE_EN
\
+   (CPSW_WR_INT_C0_RX_PULSE | CPSW_WR_INT_C0_TX_PULSE |\
+CPSW_WR_INT_C1_RX_PULSE | CPSW_WR_INT_C1_TX_PULSE |\
+CPSW_WR_INT_C2_RX_PULSE | CPSW_WR_INT_C2_TX_PULSE)
+#define CPSW_WR_INT_PRESCALE_MASK  0xfff
 #defineCPSW_WR_C_RX_THRESH_EN(p)   (CPSW_WR_OFFSET + (0x10 * (p)) 
+ 0x10)
 #define

svn commit: r306205 - in head/sys/dev/usb: . serial

2016-09-22 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Sep 22 18:45:25 2016
New Revision: 306205
URL: https://svnweb.freebsd.org/changeset/base/306205

Log:
  Add the ID for the Huawei ME909S LTE modem.
  
  Submitted by: svenauhagen at github
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/usb/serial/u3g.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/serial/u3g.c
==
--- head/sys/dev/usb/serial/u3g.c   Thu Sep 22 18:31:50 2016
(r306204)
+++ head/sys/dev/usb/serial/u3g.c   Thu Sep 22 18:45:25 2016
(r306205)
@@ -312,6 +312,7 @@ static const STRUCT_USB_HOST_ID u3g_devs
U3G_DEV(HUAWEI, E220BIS, U3GINIT_HUAWEI),
U3G_DEV(HUAWEI, E392, U3GINIT_HUAWEISCSI),
U3G_DEV(HUAWEI, ME909U, U3GINIT_HUAWEISCSI2),
+   U3G_DEV(HUAWEI, ME909S, U3GINIT_HUAWEISCSI2),
U3G_DEV(HUAWEI, MOBILE, U3GINIT_HUAWEI),
U3G_DEV(HUAWEI, E1752, U3GINIT_HUAWEISCSI),
U3G_DEV(HUAWEI, E1820, U3GINIT_HUAWEISCSI),

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsThu Sep 22 18:31:50 2016(r306204)
+++ head/sys/dev/usb/usbdevsThu Sep 22 18:45:25 2016(r306205)
@@ -2431,6 +2431,7 @@ product HUAWEI E3272_INIT 0x155b  LTE mod
 product HUAWEI ME909U  0x1573  LTE modem
 product HUAWEI R215_INIT   0x1582  LTE modem initial
 product HUAWEI R2150x1588  LTE modem
+product HUAWEI ME909S  0x15c1  LTE modem
 product HUAWEI ETS2055 0x1803  CDMA modem
 product HUAWEI E1730x1c05  3G modem
 product HUAWEI E173_INIT   0x1c0b  3G modem initial
___
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: r306050 - head/sys/arm/ti/am335x

2016-09-20 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Sep 20 19:06:58 2016
New Revision: 306050
URL: https://svnweb.freebsd.org/changeset/base/306050

Log:
  If present, honor the USB port mode (host or peripheral) set on DTS, if not,
  keep the beaglebone defaults: USB0 -> peripheral/gadget, USB1 -> host.
  
  This is only a workaround as in fact fact this hardware is capable of detect
  the USB port mode based on type of cable and act according with the detected
  mode.  Unfortunately the driver does not handle that at moment.
  
  MFC after:3 days
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/am335x/am335x_musb.c

Modified: head/sys/arm/ti/am335x/am335x_musb.c
==
--- head/sys/arm/ti/am335x/am335x_musb.cTue Sep 20 18:53:42 2016
(r306049)
+++ head/sys/arm/ti/am335x/am335x_musb.cTue Sep 20 19:06:58 2016
(r306050)
@@ -237,6 +237,7 @@ static int
 musbotg_attach(device_t dev)
 {
struct musbotg_super_softc *sc = device_get_softc(dev);
+   char mode[16];
int err;
uint32_t reg;
 
@@ -308,10 +309,19 @@ musbotg_attach(device_t dev)
}
 
sc->sc_otg.sc_platform_data = sc;
-   if (sc->sc_otg.sc_id == 0)
-   sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
-   else
-   sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+   if (OF_getprop(ofw_bus_get_node(dev), "dr_mode", mode,
+   sizeof(mode)) > 0) {
+   if (strcasecmp(mode, "host") == 0)
+   sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+   else
+   sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
+   } else {
+   /* Beaglebone defaults: USB0 device, USB1 HOST. */
+   if (sc->sc_otg.sc_id == 0)
+   sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
+   else
+   sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+   }
 
/*
 * software-controlled function
___
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: r305432 - in head/sys/arm/ti: am335x cpsw

2016-09-05 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Sep  5 18:42:21 2016
New Revision: 305432
URL: https://svnweb.freebsd.org/changeset/base/305432

Log:
  Revert r305119, move the control module register data to am335x_scm.h and
  fix if_cpsw.c to include the correct header.
  
  Discussed with:   bz

Modified:
  head/sys/arm/ti/am335x/am335x_scm.h
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/cpsw/if_cpswreg.h

Modified: head/sys/arm/ti/am335x/am335x_scm.h
==
--- head/sys/arm/ti/am335x/am335x_scm.h Mon Sep  5 18:05:45 2016
(r305431)
+++ head/sys/arm/ti/am335x/am335x_scm.h Mon Sep  5 18:42:21 2016
(r305432)
@@ -42,6 +42,8 @@
 #defineSCM_USB_STS00x624
 #defineSCM_USB_CTRL1   0x628
 #defineSCM_USB_STS10x62C
+#defineSCM_MAC_ID0_LO  0x630
+#defineSCM_MAC_ID0_HI  0x634
 #defineSCM_PWMSS_CTRL  0x664
 
 #endif /* __AM335X_SCM_H__ */

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Mon Sep  5 18:05:45 2016
(r305431)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Mon Sep  5 18:42:21 2016
(r305432)
@@ -78,6 +78,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -87,8 +90,6 @@ __FBSDID("$FreeBSD$");
 
 #include "if_cpswreg.h"
 #include "if_cpswvar.h"
- 
-#include 
 
 #include "miibus_if.h"
 
@@ -1019,14 +1020,14 @@ cpswp_attach(device_t dev)
IFQ_SET_READY(>if_snd);
 
/* Get high part of MAC address from control module (mac_id[0|1]_hi) */
-   ti_scm_reg_read_4(CPSW_MAC_ID0_HI + sc->unit * 8, );
+   ti_scm_reg_read_4(SCM_MAC_ID0_HI + sc->unit * 8, );
mac_addr[0] = reg & 0xFF;
mac_addr[1] = (reg >>  8) & 0xFF;
mac_addr[2] = (reg >> 16) & 0xFF;
mac_addr[3] = (reg >> 24) & 0xFF;
 
/* Get low part of MAC address from control module (mac_id[0|1]_lo) */
-   ti_scm_reg_read_4(CPSW_MAC_ID0_LO + sc->unit * 8, );
+   ti_scm_reg_read_4(SCM_MAC_ID0_LO + sc->unit * 8, );
mac_addr[4] = reg & 0xFF;
mac_addr[5] = (reg >>  8) & 0xFF;
 

Modified: head/sys/arm/ti/cpsw/if_cpswreg.h
==
--- head/sys/arm/ti/cpsw/if_cpswreg.h   Mon Sep  5 18:05:45 2016
(r305431)
+++ head/sys/arm/ti/cpsw/if_cpswreg.h   Mon Sep  5 18:42:21 2016
(r305432)
@@ -46,9 +46,6 @@
 #defineCPSW_PORT_P_SA_LO(p)(CPSW_PORT_OFFSET + 0x120 + 
((p-1) * 0x100))
 #defineCPSW_PORT_P_SA_HI(p)(CPSW_PORT_OFFSET + 0x124 + 
((p-1) * 0x100))
 
-#defineCPSW_MAC_ID0_LO 0x0630
-#defineCPSW_MAC_ID0_HI 0x0634
-
 #defineCPSW_CPDMA_OFFSET   0x0800
 #defineCPSW_CPDMA_TX_CONTROL   (CPSW_CPDMA_OFFSET + 0x04)
 #defineCPSW_CPDMA_TX_TEARDOWN  (CPSW_CPDMA_OFFSET + 0x08)
___
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: r305114 - head/sys/arm/ti

2016-08-31 Thread Luiz Otavio O Souza
On Wed, Aug 31, 2016 at 3:54 PM, wrote:
>
>> On Aug 31, 2016, at 12:22 AM, Luiz Otavio O Souza wrote:
>>
>> Author: loos
>> Date: Wed Aug 31 07:22:14 2016
>> New Revision: 305114
>> URL: https://svnweb.freebsd.org/changeset/base/305114
>>
>> Log:
>>  Allow the use of control module extensions to cope with specific platform
>>  features.
>>
>>  Sponsored by:Rubicon Communications, LLC (Netgate)
>>
>> Modified:
>>  head/sys/arm/ti/ti_scm.c
>>
>> Modified: head/sys/arm/ti/ti_scm.c
>> ==
>> --- head/sys/arm/ti/ti_scm.c  Wed Aug 31 07:03:06 2016(r305113)
>> +++ head/sys/arm/ti/ti_scm.c  Wed Aug 31 07:22:14 2016(r305114)
>> @@ -131,7 +131,11 @@ ti_scm_attach(device_t dev)
>>
>>   ti_scm_sc = sc;
>>
>> - return (0);
>> + /* Attach platform extensions, if any. */
>> + bus_generic_probe(dev);
>> + bus_enumerate_hinted_children(dev);
>> +
>> + return (bus_generic_attach(dev));
>> }
>
> Is bus_enumerate_hinted_children really required? I think all TI platforms 
> are FDT-compatible


No, it is not required.  Fixed in r305149.

Thanks!

Luiz
___
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"


  1   2   3   4   5   >