svn commit: r367887 - head/sys/dev/dwc

Emmanuel Vadot manu at FreeBSD.org
Fri Nov 20 11:31:05 UTC 2020


Author: manu
Date: Fri Nov 20 11:31:04 2020
New Revision: 367887
URL: https://svnweb.freebsd.org/changeset/base/367887

Log:
  if_dwc: Add flow control support

Modified:
  head/sys/dev/dwc/if_dwc.c
  head/sys/dev/dwc/if_dwc.h

Modified: head/sys/dev/dwc/if_dwc.c
==============================================================================
--- head/sys/dev/dwc/if_dwc.c	Fri Nov 20 11:30:44 2020	(r367886)
+++ head/sys/dev/dwc/if_dwc.c	Fri Nov 20 11:31:04 2020	(r367887)
@@ -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
  */
@@ -333,6 +337,15 @@ dwc_miibus_statchg(device_t dev)
 	else
 		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));
 

Modified: head/sys/dev/dwc/if_dwc.h
==============================================================================
--- head/sys/dev/dwc/if_dwc.h	Fri Nov 20 11:30:44 2020	(r367886)
+++ head/sys/dev/dwc/if_dwc.h	Fri Nov 20 11:31:04 2020	(r367887)
@@ -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


More information about the svn-src-all mailing list