[rtems-libbsd commit] ffec: Add FECFLAG_AVB variant flag

Sebastian Huber sebh at rtems.org
Wed Sep 27 09:12:37 UTC 2017


Module:    rtems-libbsd
Branch:    master
Commit:    ba0b05902bb3ee23afd5a2ee2ca589914f11beaa
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=ba0b05902bb3ee23afd5a2ee2ca589914f11beaa

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Sep 27 09:54:56 2017 +0200

ffec: Add FECFLAG_AVB variant flag

This flag is analogous to the Linux driver FEC_QUIRK_HAS_AVB.  It
indicates an FEC with support for Audio Video Bridging (AVB).  This
indicator is used for various other parts in the Linux driver
(drivers/net/ethernet/freescale/fec_main.c).

Use it to customize the receive/transmit buffer alignment.  The receive
buffer alignment increased to 64-bytes on the i.MX 6SoloX and i.MX
7Dual.  There are no hard alignment restrictions for transmit buffers on
these chips.

Fix the ffec_softc::fectype type to provide enough storage for the
feature flags.

---

 freebsd/sys/dev/ffec/if_ffec.c    | 22 +++++++++++++++++-----
 freebsd/sys/dev/ffec/if_ffecreg.h |  2 --
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/freebsd/sys/dev/ffec/if_ffec.c b/freebsd/sys/dev/ffec/if_ffec.c
index f4914ad..85a720f 100644
--- a/freebsd/sys/dev/ffec/if_ffec.c
+++ b/freebsd/sys/dev/ffec/if_ffec.c
@@ -106,7 +106,8 @@ enum {
  * SoCs.  These are ORed into the FECTYPE enum values.
  */
 #define	FECTYPE_MASK		0x0000ffff
-#define	FECFLAG_GBE		(0x0001 << 16)
+#define	FECFLAG_GBE		(1 << 16)
+#define	FECFLAG_AVB		(1 << 17)
 
 /*
  * Table of supported FDT compat strings and their associated FECTYPE values.
@@ -117,6 +118,7 @@ static struct ofw_compat_data compat_data[] = {
 	{"fsl,imx6q-fec",	FECTYPE_IMX6 | FECFLAG_GBE},
 	{"fsl,mvf600-fec",	FECTYPE_MVF},
 	{"fsl,mvf-fec",		FECTYPE_MVF},
+	{"fsl,imx7d-fec",	FECTYPE_IMX6 | FECFLAG_GBE | FECFLAG_AVB},
 	{NULL,		 	FECTYPE_NONE},
 };
 
@@ -155,12 +157,14 @@ struct ffec_softc {
 	void *			intr_cookie;
 	struct callout		ffec_callout;
 	uint8_t			phy_conn_type;
-	uint8_t			fectype;
+	uintptr_t		fectype;
 	boolean_t		link_is_up;
 	boolean_t		is_attached;
 	boolean_t		is_detaching;
 	int			tx_watchdog_count;
 	int			stats_harvest_count;
+	int                     rxbuf_align;
+	int                     txbuf_align;
 
 	bus_dma_tag_t		rxdesc_tag;
 	bus_dmamap_t		rxdesc_map;
@@ -751,7 +755,7 @@ ffec_setup_rxbuf(struct ffec_softc *sc, int idx, struct mbuf * m)
 	 * have to ensure that the beginning of the buffer is aligned to the
 	 * hardware's requirements.
 	 */
-	m_adj(m, roundup(ETHER_ALIGN, FEC_RXBUF_ALIGN));
+	m_adj(m, roundup(ETHER_ALIGN, sc->rxbuf_align));
 
 	error = bus_dmamap_load_mbuf_sg(sc->rxbuf_tag, sc->rxbuf_map[idx].map,
 	    m, &seg, &nsegs, 0);
@@ -1099,7 +1103,7 @@ ffec_init_locked(struct ffec_softc *sc)
 	 * when we support jumbo frames and receiving fragments of them into
 	 * separate buffers.
 	 */
-	maxbuf = MCLBYTES - roundup(ETHER_ALIGN, FEC_RXBUF_ALIGN);
+	maxbuf = MCLBYTES - roundup(ETHER_ALIGN, sc->rxbuf_align);
 	maxfl = min(maxbuf, 0x7ff);
 
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
@@ -1450,6 +1454,14 @@ ffec_attach(device_t dev)
 	 */
 	sc->fectype = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
 
+	if (sc->fectype & FECFLAG_AVB) {
+		sc->rxbuf_align = 64;
+		sc->txbuf_align = 1;
+	} else {
+		sc->rxbuf_align = 16;
+		sc->txbuf_align = 16;
+	}
+
 	/*
 	 * We have to be told what kind of electrical connection exists between
 	 * the MAC and PHY or we can't operate correctly.
@@ -1541,7 +1553,7 @@ ffec_attach(device_t dev)
 
 	error = bus_dma_tag_create(
 	    bus_get_dma_tag(dev),	/* Parent tag. */
-	    FEC_TXBUF_ALIGN, 0,		/* alignment, boundary */
+	    sc->txbuf_align, 0,		/* alignment, boundary */
 	    BUS_SPACE_MAXADDR_32BIT,	/* lowaddr */
 	    BUS_SPACE_MAXADDR,		/* highaddr */
 	    NULL, NULL,			/* filter, filterarg */
diff --git a/freebsd/sys/dev/ffec/if_ffecreg.h b/freebsd/sys/dev/ffec/if_ffecreg.h
index 6faa095..bb1d197 100644
--- a/freebsd/sys/dev/ffec/if_ffecreg.h
+++ b/freebsd/sys/dev/ffec/if_ffecreg.h
@@ -318,7 +318,5 @@ struct ffec_hwdesc
  * DMA transfers.  These values are expressed in bytes (not bits).
  */
 #define	FEC_DESC_RING_ALIGN		64
-#define	FEC_RXBUF_ALIGN			16
-#define	FEC_TXBUF_ALIGN			16
 
 #endif	/* IF_FFECREG_H */




More information about the vc mailing list