Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic - Add MII flow control support
details: https://anonhg.NetBSD.org/src/rev/6b1a0b74450e
branches: trunk
changeset: 333935:6b1a0b74450e
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Nov 22 18:31:03 2014 +0000
description:
- Add MII flow control support
- Set "disable jabber" and "auto padding/CRC stripping" bits in MAC conf
- Write intr mask to intr mask register, not status
- Setup both TX and RX burst modes
- Setup both TX and RX store & forward modes
- Correct an issue with the "end" descriptor passed to dwc_gmac_txdesc_sync
in dwc_gmac_tx_intr
ok martin@
diffstat:
sys/dev/ic/dwc_gmac.c | 37 ++++++++++++++++++++++++++-----------
sys/dev/ic/dwc_gmac_reg.h | 17 ++++++++++++++---
sys/dev/ic/dwc_gmac_var.h | 4 ++--
3 files changed, 42 insertions(+), 16 deletions(-)
diffs (190 lines):
diff -r b16438b078ea -r 6b1a0b74450e sys/dev/ic/dwc_gmac.c
--- a/sys/dev/ic/dwc_gmac.c Sat Nov 22 15:47:42 2014 +0000
+++ b/sys/dev/ic/dwc_gmac.c Sat Nov 22 18:31:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.24 2014/10/27 09:40:00 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.25 2014/11/22 18:31:03 jmcneill Exp $ */
/*-
* Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.24 2014/10/27 09:40:00 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.25 2014/11/22 18:31:03 jmcneill Exp $");
/* #define DWC_GMAC_DEBUG 1 */
@@ -225,7 +225,8 @@
mii->mii_readreg = dwc_gmac_miibus_read_reg;
mii->mii_writereg = dwc_gmac_miibus_write_reg;
mii->mii_statchg = dwc_gmac_miibus_statchg;
- mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0);
+ mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY,
+ MIIF_DOPAUSE);
if (LIST_EMPTY(&mii->mii_phys)) {
aprint_error_dev(sc->sc_dev, "no PHY found!\n");
@@ -246,7 +247,7 @@
* Enable interrupts
*/
s = splnet();
- bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_MAC_INTR,
+ bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_MAC_INTMASK,
AWIN_DEF_MAC_INTRMASK);
bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_INTENABLE,
GMAC_DEF_DMA_INT_MASK);
@@ -668,7 +669,7 @@
{
struct dwc_gmac_softc * const sc = ifp->if_softc;
struct mii_data * const mii = &sc->sc_mii;
- uint32_t conf;
+ uint32_t conf, flow;
/*
* Set MII or GMII interface based on the speed
@@ -679,6 +680,8 @@
|AWIN_GMAC_MAC_CONF_FULLDPLX);
conf |= AWIN_GMAC_MAC_CONF_FRAMEBURST
| AWIN_GMAC_MAC_CONF_DISABLERXOWN
+ | AWIN_GMAC_MAC_CONF_DISABLEJABBER
+ | AWIN_GMAC_MAC_CONF_ACS
| AWIN_GMAC_MAC_CONF_RXENABLE
| AWIN_GMAC_MAC_CONF_TXENABLE;
switch (IFM_SUBTYPE(mii->mii_media_active)) {
@@ -692,8 +695,20 @@
case IFM_1000_T:
break;
}
- if (IFM_OPTIONS(mii->mii_media_active) & IFM_FDX)
+
+ flow = 0;
+ if (IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) {
conf |= AWIN_GMAC_MAC_CONF_FULLDPLX;
+ flow |= __SHIFTIN(0x200, AWIN_GMAC_MAC_FLOWCTRL_PAUSE);
+ }
+ if (mii->mii_media_active & IFM_ETH_TXPAUSE) {
+ flow |= AWIN_GMAC_MAC_FLOWCTRL_TFE;
+ }
+ if (mii->mii_media_active & IFM_ETH_RXPAUSE) {
+ flow |= AWIN_GMAC_MAC_FLOWCTRL_RFE;
+ }
+ bus_space_write_4(sc->sc_bst, sc->sc_bsh,
+ AWIN_GMAC_MAC_FLOWCTRL, flow);
#ifdef DWC_GMAC_DEBUG
aprint_normal_dev(sc->sc_dev,
@@ -720,9 +735,9 @@
* XXX - the GMAC_BUSMODE_PRIORXTX bits are undocumented.
*/
bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_BUSMODE,
- GMAC_BUSMODE_FIXEDBURST |
- __SHIFTIN(GMAC_BUSMODE_PRIORXTX_41, GMAC_BUSMODE_PRIORXTX) |
- __SHIFTIN(8, GMCA_BUSMODE_PBL));
+ GMAC_BUSMODE_FIXEDBURST | GMAC_BUSMODE_4PBL |
+ __SHIFTIN(2, GMAC_BUSMODE_RPBL) |
+ __SHIFTIN(2, GMAC_BUSMODE_PBL));
/*
* Set up address filter
@@ -758,7 +773,7 @@
*/
bus_space_write_4(sc->sc_bst, sc->sc_bsh,
AWIN_GMAC_DMA_OPMODE, GMAC_DMA_OP_RXSTART | GMAC_DMA_OP_TXSTART |
- GMAC_DMA_OP_STOREFORWARD);
+ GMAC_DMA_OP_RXSTOREFORWARD | GMAC_DMA_OP_TXSTOREFORWARD);
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
@@ -967,7 +982,7 @@
#endif
desc = &sc->sc_txq.t_desc[i];
- dwc_gmac_txdesc_sync(sc, i, i+1,
+ dwc_gmac_txdesc_sync(sc, i, TX_NEXT(i),
BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
flags = le32toh(desc->ddesc_status);
diff -r b16438b078ea -r 6b1a0b74450e sys/dev/ic/dwc_gmac_reg.h
--- a/sys/dev/ic/dwc_gmac_reg.h Sat Nov 22 15:47:42 2014 +0000
+++ b/sys/dev/ic/dwc_gmac_reg.h Sat Nov 22 18:31:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac_reg.h,v 1.12 2014/10/25 18:15:18 joerg Exp $ */
+/* $NetBSD: dwc_gmac_reg.h,v 1.13 2014/11/22 18:31:03 jmcneill Exp $ */
/*-
* Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -44,6 +44,7 @@
#define AWIN_GMAC_MAC_ADDR0LO 0x0044
#define AWIN_GMAC_MII_STATUS 0x00D8
+#define AWIN_GMAC_MAC_CONF_DISABLEJABBER __BIT(22) /* jabber disable */
#define AWIN_GMAC_MAC_CONF_FRAMEBURST __BIT(21) /* allow TX frameburst when
in half duplex mode */
#define AWIN_GMAC_MAC_CONF_MIISEL __BIT(15) /* select MII phy */
@@ -52,6 +53,7 @@
TX frames in half duplex
mode */
#define AWIN_GMAC_MAC_CONF_FULLDPLX __BIT(11) /* select full duplex */
+#define AWIN_GMAC_MAC_CONF_ACS __BIT(7) /* auto pad/CRC stripping */
#define AWIN_GMAC_MAC_CONF_TXENABLE __BIT(3) /* enable TX dma engine */
#define AWIN_GMAC_MAC_CONF_RXENABLE __BIT(2) /* enable RX dma engine */
@@ -72,6 +74,11 @@
#define AWIN_GMAC_MAC_INT_LINKCHG __BIT(1)
#define AWIN_GMAC_MAC_INT_RGSMII __BIT(0)
+#define AWIN_GMAC_MAC_FLOWCTRL_PAUSE __BITS(31,16)
+#define AWIN_GMAC_MAC_FLOWCTRL_RFE __BIT(2)
+#define AWIN_GMAC_MAC_FLOWCTRL_TFE __BIT(1)
+#define AWIN_GMAC_MAC_FLOWCTRL_BUSY __BIT(0)
+
#define AWIN_GMAC_DMA_BUSMODE 0x1000
#define AWIN_GMAC_DMA_TXPOLL 0x1004
#define AWIN_GMAC_DMA_RXPOLL 0x1008
@@ -109,20 +116,24 @@
#define GMAC_MII_CLK_DIV18 0xf
#define GMAC_MII_CLKMASK __BITS(5,2)
+#define GMAC_BUSMODE_4PBL __BIT(24)
+#define GMAC_BUSMODE_RPBL __BITS(22,17)
#define GMAC_BUSMODE_FIXEDBURST __BIT(16)
#define GMAC_BUSMODE_PRIORXTX __BITS(15,14)
#define GMAC_BUSMODE_PRIORXTX_41 3
#define GMAC_BUSMODE_PRIORXTX_31 2
#define GMAC_BUSMODE_PRIORXTX_21 1
#define GMAC_BUSMODE_PRIORXTX_11 0
-#define GMCA_BUSMODE_PBL __BITS(13,8) /* possible DMA
+#define GMAC_BUSMODE_PBL __BITS(13,8) /* possible DMA
burst len */
#define GMAC_BUSMODE_RESET __BIT(0)
#define AWIN_GMAC_MII_IRQ __BIT(0)
-#define GMAC_DMA_OP_STOREFORWARD __BIT(21) /* start TX when a
+#define GMAC_DMA_OP_RXSTOREFORWARD __BIT(24) /* start RX when a
+ full frame is available */
+#define GMAC_DMA_OP_TXSTOREFORWARD __BIT(21) /* start TX when a
full frame is available */
#define GMAC_DMA_OP_FLUSHTX __BIT(20) /* flush TX fifo */
#define GMAC_DMA_OP_TXSTART __BIT(13) /* start TX DMA engine */
diff -r b16438b078ea -r 6b1a0b74450e sys/dev/ic/dwc_gmac_var.h
--- a/sys/dev/ic/dwc_gmac_var.h Sat Nov 22 15:47:42 2014 +0000
+++ b/sys/dev/ic/dwc_gmac_var.h Sat Nov 22 18:31:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac_var.h,v 1.5 2014/10/26 17:39:16 martin Exp $ */
+/* $NetBSD: dwc_gmac_var.h,v 1.6 2014/11/22 18:31:03 jmcneill Exp $ */
/*-
* Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
#define AWGE_TOTAL_RING_COUNT \
(AWGE_RX_RING_COUNT + AWGE_TX_RING_COUNT)
-#define AWGE_MAX_PACKET (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN)
+#define AWGE_MAX_PACKET 0x7ff
Home |
Main Index |
Thread Index |
Old Index