diff options
author | Emmanuel Vadot <manu@FreeBSD.org> | 2020-11-20 11:31:04 +0000 |
---|---|---|
committer | Emmanuel Vadot <manu@FreeBSD.org> | 2020-11-20 11:31:04 +0000 |
commit | 2b4a66ed171eb0ecd78a9e7f0c7988bdf409e8cf (patch) | |
tree | 7871629b847749ef7130b33b284105c7b5cbc8f7 | |
parent | 354cb625eec82b6f857497c2053a8f7cdcc87bbd (diff) |
if_dwc: Add flow control support
Notes
Notes:
svn path=/head/; revision=367887
-rw-r--r-- | sys/dev/dwc/if_dwc.c | 13 | ||||
-rw-r--r-- | sys/dev/dwc/if_dwc.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c index 919f8fee1527..2a2b285bf31e 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -224,6 +224,10 @@ static void dwc_stop_dma(struct dwc_softc *sc); static void dwc_tick(void *arg); +/* Pause time field in the transmitted control frame */ +static int dwc_pause_time = 0xffff; +TUNABLE_INT("hw.dwc.pause_time", &dwc_pause_time); + /* * MIIBUS functions */ @@ -334,6 +338,15 @@ dwc_miibus_statchg(device_t dev) reg &= ~(CONF_DM); WRITE4(sc, MAC_CONFIGURATION, reg); + reg = FLOW_CONTROL_UP; + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0) + reg |= FLOW_CONTROL_TX; + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0) + reg |= FLOW_CONTROL_RX; + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) + reg |= dwc_pause_time << FLOW_CONTROL_PT_SHIFT; + WRITE4(sc, FLOW_CONTROL, reg); + IF_DWC_SET_SPEED(dev, IFM_SUBTYPE(mii->mii_media_active)); } diff --git a/sys/dev/dwc/if_dwc.h b/sys/dev/dwc/if_dwc.h index 045072abe611..28290d139b55 100644 --- a/sys/dev/dwc/if_dwc.h +++ b/sys/dev/dwc/if_dwc.h @@ -70,6 +70,10 @@ #define GMII_ADDRESS_GB (1 << 0) /* Busy */ #define GMII_DATA 0x14 #define FLOW_CONTROL 0x18 +#define FLOW_CONTROL_PT_SHIFT 16 +#define FLOW_CONTROL_UP (1 << 3) /* Unicast pause enable */ +#define FLOW_CONTROL_RX (1 << 2) /* RX Flow control enable */ +#define FLOW_CONTROL_TX (1 << 1) /* TX Flow control enable */ #define GMAC_VLAN_TAG 0x1C #define VERSION 0x20 #define DEBUG 0x24 |