CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov 27 14:04:38 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: esm.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #493):

sys/dev/pci/esm.c: revision 1.64

add missing break.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.63.2.1 src/sys/dev/pci/esm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov 27 14:04:38 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: esm.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #493):

sys/dev/pci/esm.c: revision 1.64

add missing break.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.63.2.1 src/sys/dev/pci/esm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/esm.c
diff -u src/sys/dev/pci/esm.c:1.63 src/sys/dev/pci/esm.c:1.63.2.1
--- src/sys/dev/pci/esm.c:1.63	Sat Jun  8 08:02:38 2019
+++ src/sys/dev/pci/esm.c	Wed Nov 27 14:04:38 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: esm.c,v 1.63 2019/06/08 08:02:38 isaki Exp $  */
+/*  $NetBSD: esm.c,v 1.63.2.1 2019/11/27 14:04:38 martin Exp $  */
 
 /*-
  * Copyright (c) 2002, 2003 Matt Fredette
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.63 2019/06/08 08:02:38 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.63.2.1 2019/11/27 14:04:38 martin Exp $");
 
 #include 
 #include 
@@ -1482,6 +1482,7 @@ esm_match(device_t dev, cfdata_t match, 
 		case PCI_PRODUCT_ESSTECH_MAESTRO2E:
 			return 1;
 		}
+		break;
 
 	case PCI_VENDOR_ESSTECH2:
 		switch (PCI_PRODUCT(pa->pa_id)) {



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov 27 11:08:24 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_bge.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #487):

sys/dev/pci/if_bge.c: revision 1.340
sys/dev/pci/if_bge.c: revision 1.341
sys/dev/pci/if_bge.c: revision 1.342
sys/dev/pci/if_bge.c: revision 1.336

- Avoid undefined behavior in bge_setmulti(). found by kUBSan.
- Avoid undefined behavior when setting the MAC address in bge_init().
  found by kUBSan.

 Fix a bug that SK-9D41 can't detect fiber media. Check the subsystem ID
correctly. This bug was added in if_bge.c rev. 1.161.

- Use *_FLUSH() more. The main purpose is to wait following delay() correctly.
- Add missing DELAY(80) after writing BGE_MI_MODE register.

 Modify PHY initialization code. This change fix a bug that SK-9D21 doesn't
detect MII PHY.
 - Add error check to bge_miibus_writereg().
 - Change return value of bge_miibus_readreg() when a read error occurred.
   It also add error message using with aprint_debug_dev(). This error occurs
   on some devices while detecting MII devices.
 - Move the location of BGE_MI_MODE register's initialization to next to
   bge_chipinit().
 - Set BGE_MAC_MODE before calling ifmedia_init() and/or mii_attach().
 - Add retry code for mii_attach() failed. Same as FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.335 -r1.335.2.1 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.335 src/sys/dev/pci/if_bge.c:1.335.2.1
--- src/sys/dev/pci/if_bge.c:1.335	Tue Jul  9 08:46:58 2019
+++ src/sys/dev/pci/if_bge.c	Wed Nov 27 11:08:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.335 2019/07/09 08:46:58 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.335.2.1 2019/11/27 11:08:24 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.335 2019/07/09 08:46:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.335.2.1 2019/11/27 11:08:24 martin Exp $");
 
 #include 
 #include 
@@ -1027,10 +1027,10 @@ bge_eeprom_getbyte(struct bge_softc *sc,
 	 * Enable use of auto EEPROM access so we can avoid
 	 * having to use the bitbang method.
 	 */
-	BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
+	BGE_SETBIT_FLUSH(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
 
 	/* Reset the EEPROM, load the clock period. */
-	CSR_WRITE_4(sc, BGE_EE_ADDR,
+	CSR_WRITE_4_FLUSH(sc, BGE_EE_ADDR,
 	BGE_EEADDR_RESET | BGE_EEHALFCLK(BGE_HALFCLK_384SCL));
 	DELAY(20);
 
@@ -1113,9 +1113,11 @@ bge_miibus_readreg(device_t dev, int phy
 	if (i == BGE_TIMEOUT) {
 		aprint_error_dev(sc->bge_dev, "PHY read timed out\n");
 		rv = ETIMEDOUT;
-	} else if ((data & BGE_MICOMM_READFAIL) != 0)
-		rv = -1;
-	else
+	} else if ((data & BGE_MICOMM_READFAIL) != 0) {
+		/* XXX This error occurs on some devices while attaching. */
+		aprint_debug_dev(sc->bge_dev, "PHY read I/O error\n");
+		rv = EIO;
+	} else
 		*val = data & BGE_MICOMM_DATA;
 
 	if (autopoll & BGE_MIMODE_AUTOPOLL) {
@@ -1133,7 +1135,8 @@ static int
 bge_miibus_writereg(device_t dev, int phy, int reg, uint16_t val)
 {
 	struct bge_softc *sc = device_private(dev);
-	uint32_t autopoll;
+	uint32_t data, autopoll;
+	int rv = 0;
 	int i;
 
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906 &&
@@ -1156,13 +1159,22 @@ bge_miibus_writereg(device_t dev, int ph
 
 	for (i = 0; i < BGE_TIMEOUT; i++) {
 		delay(10);
-		if (!(CSR_READ_4(sc, BGE_MI_COMM) & BGE_MICOMM_BUSY)) {
+		data = CSR_READ_4(sc, BGE_MI_COMM);
+		if (!(data & BGE_MICOMM_BUSY)) {
 			delay(5);
-			CSR_READ_4(sc, BGE_MI_COMM);
+			data = CSR_READ_4(sc, BGE_MI_COMM);
 			break;
 		}
 	}
 
+	if (i == BGE_TIMEOUT) {
+		aprint_error_dev(sc->bge_dev, "PHY write timed out\n");
+		rv = ETIMEDOUT;
+	} else if ((data & BGE_MICOMM_READFAIL) != 0) {
+		aprint_error_dev(sc->bge_dev, "PHY write I/O error\n");
+		rv = EIO;
+	}
+
 	if (autopoll & BGE_MIMODE_AUTOPOLL) {
 		BGE_STS_SETBIT(sc, BGE_STS_AUTOPOLL);
 		BGE_SETBIT_FLUSH(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL);
@@ -1176,7 +1188,7 @@ bge_miibus_writereg(device_t dev, int ph
 		return ETIMEDOUT;
 	}
 
-	return 0;
+	return rv;
 }
 
 static void
@@ -1827,7 +1839,7 @@ bge_setmulti(struct bge_softc *sc)
 		/* Just want the 7 least-significant bits. */
 		h &= 0x7f;
 
-		hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
+		hashes[(h & 0x60) >> 5] |= 1U << (h & 0x1F);
 		ETHER_NEXT_MULTI(step, enm);
 	}
 	ETHER_UNLOCK(ec);
@@ -2286,7 +2298,7 @@ bge_chipinit(struct bge_softc *sc)
 #endif
 
 	/* Set the timer prescaler (always 66MHz) */
-	CSR_WRITE_4(sc, BGE_MISC_CFG, BGE_32BITTIME_66MHZ);
+	CSR_WRITE_4_FLUSH(sc, BGE_MISC_CFG, BGE_32BITTIME_66MHZ);
 
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) {
 		DELAY(40);	/* XXX */
@@ 

CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 26 18:30:57 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #486):

sys/dev/pci/if_mcx.c: revision 1.7

Fix IFF_ALLMULTI handling.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 26 18:30:57 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #486):

sys/dev/pci/if_mcx.c: revision 1.7

Fix IFF_ALLMULTI handling.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.1.2.5 src/sys/dev/pci/if_mcx.c:1.1.2.6
--- src/sys/dev/pci/if_mcx.c:1.1.2.5	Mon Nov 18 19:46:33 2019
+++ src/sys/dev/pci/if_mcx.c	Tue Nov 26 18:30:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.1.2.5 2019/11/18 19:46:33 martin Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.1.2.6 2019/11/26 18:30:57 martin Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -6205,8 +6205,11 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 {
 	struct mcx_softc *sc = (struct mcx_softc *)ifp->if_softc;
 	struct ifreq *ifr = (struct ifreq *)data;
+	struct ethercom *ec = >sc_ec;
 	uint8_t addrhi[ETHER_ADDR_LEN], addrlo[ETHER_ADDR_LEN];
-	int s, i, error = 0;
+	struct ether_multi *enm;
+	struct ether_multistep step;
+	int s, i, flags, error = 0;
 
 	s = splnet();
 	switch (cmd) {
@@ -6214,8 +6217,10 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 	case SIOCADDMULTI:
 		if (ether_addmulti(ifreq_getaddr(cmd, ifr), >sc_ec) == ENETRESET) {
 			error = ether_multiaddr(>ifr_addr, addrlo, addrhi);
-			if (error != 0)
+			if (error != 0) {
+splx(s);
 return (error);
+			}
 
 			for (i = 0; i < MCX_NUM_MCAST_FLOWS; i++) {
 if (sc->sc_mcast_flows[i][0] == 0) {
@@ -6238,7 +6243,7 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 	error = ENETRESET;
 }
 
-if (sc->sc_ec.ec_multicnt > 0) {
+if (memcmp(addrlo, addrhi, ETHER_ADDR_LEN)) {
 	SET(ifp->if_flags, IFF_ALLMULTI);
 	error = ENETRESET;
 }
@@ -6249,8 +6254,10 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 	case SIOCDELMULTI:
 		if (ether_delmulti(ifreq_getaddr(cmd, ifr), >sc_ec) == ENETRESET) {
 			error = ether_multiaddr(>ifr_addr, addrlo, addrhi);
-			if (error != 0)
+			if (error != 0) {
+splx(s);
 return (error);
+			}
 
 			for (i = 0; i < MCX_NUM_MCAST_FLOWS; i++) {
 if (memcmp(sc->sc_mcast_flows[i], addrlo,
@@ -6269,10 +6276,23 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 sc->sc_extra_mcast--;
 
 			if (ISSET(ifp->if_flags, IFF_ALLMULTI) &&
-			(sc->sc_extra_mcast == 0) &&
-			(sc->sc_ec.ec_multicnt == 0)) {
-CLR(ifp->if_flags, IFF_ALLMULTI);
-error = ENETRESET;
+			sc->sc_extra_mcast == 0) {
+flags = 0;
+ETHER_LOCK(ec);
+ETHER_FIRST_MULTI(step, ec, enm);
+while (enm != NULL) {
+	if (memcmp(enm->enm_addrlo,
+	enm->enm_addrhi, ETHER_ADDR_LEN)) {
+		SET(flags, IFF_ALLMULTI);
+		break;
+	}
+	ETHER_NEXT_MULTI(step, enm);
+}
+ETHER_UNLOCK(ec);
+if (!ISSET(flags, IFF_ALLMULTI)) {
+	CLR(ifp->if_flags, IFF_ALLMULTI);
+	error = ENETRESET;
+}
 			}
 		}
 		break;



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 26 08:20:47 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c if_alc.c if_ale.c if_cas.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #483):

sys/dev/pci/if_cas.c: revision 1.36
sys/dev/pci/if_alc.c: revision 1.44
sys/dev/pci/if_ale.c: revision 1.35
sys/dev/pci/if_ale.c: revision 1.36
sys/dev/pci/if_age.c: revision 1.64

Fix a bug that IFF_ALLMULTI is almost always set.
 OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.

 Remove accidentally committed debug code. Sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.60.2.3 -r1.60.2.4 src/sys/dev/pci/if_age.c
cvs rdiff -u -r1.38.2.2 -r1.38.2.3 src/sys/dev/pci/if_alc.c
cvs rdiff -u -r1.33.2.1 -r1.33.2.2 src/sys/dev/pci/if_ale.c
cvs rdiff -u -r1.35 -r1.35.2.1 src/sys/dev/pci/if_cas.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_age.c
diff -u src/sys/dev/pci/if_age.c:1.60.2.3 src/sys/dev/pci/if_age.c:1.60.2.4
--- src/sys/dev/pci/if_age.c:1.60.2.3	Tue Nov 26 08:18:40 2019
+++ src/sys/dev/pci/if_age.c	Tue Nov 26 08:20:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_age.c,v 1.60.2.3 2019/11/26 08:18:40 martin Exp $ */
+/*	$NetBSD: if_age.c,v 1.60.2.4 2019/11/26 08:20:47 martin Exp $ */
 /*	$OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $	*/
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.3 2019/11/26 08:18:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.4 2019/11/26 08:20:47 martin Exp $");
 
 #include "vlan.h"
 
@@ -2275,27 +2275,37 @@ age_rxfilter(struct age_softc *sc)
 	 */
 	rxcfg |= MAC_CFG_BCAST;
 
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
+	/* Program new filter. */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		goto update;
+
+	memset(mchash, 0, sizeof(mchash));
+
+	ETHER_LOCK(ec);
+	ETHER_FIRST_MULTI(step, ec, enm);
+	while (enm != NULL) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			goto update;
+		}
+		crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+		mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+		ETHER_NEXT_MULTI(step, enm);
+	}
+	ETHER_UNLOCK(ec);
+
+update:
+	if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+		if (ifp->if_flags & IFF_PROMISC) {
 			rxcfg |= MAC_CFG_PROMISC;
-		else
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+		} else
 			rxcfg |= MAC_CFG_ALLMULTI;
 		mchash[0] = mchash[1] = 0x;
-	} else {
-		/* Program new filter. */
-		memset(mchash, 0, sizeof(mchash));
-
-		ETHER_LOCK(ec);
-		ETHER_FIRST_MULTI(step, ec, enm);
-		while (enm != NULL) {
-			crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-			mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-			ETHER_NEXT_MULTI(step, enm);
-		}
-		ETHER_UNLOCK(ec);
 	}
-
 	CSR_WRITE_4(sc, AGE_MAR0, mchash[0]);
 	CSR_WRITE_4(sc, AGE_MAR1, mchash[1]);
 	CSR_WRITE_4(sc, AGE_MAC_CFG, rxcfg);

Index: src/sys/dev/pci/if_alc.c
diff -u src/sys/dev/pci/if_alc.c:1.38.2.2 src/sys/dev/pci/if_alc.c:1.38.2.3
--- src/sys/dev/pci/if_alc.c:1.38.2.2	Wed Nov  6 09:59:38 2019
+++ src/sys/dev/pci/if_alc.c	Tue Nov 26 08:20:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_alc.c,v 1.38.2.2 2019/11/06 09:59:38 martin Exp $	*/
+/*	$NetBSD: if_alc.c,v 1.38.2.3 2019/11/26 08:20:47 martin Exp $	*/
 /*	$OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $	*/
 /*-
  * Copyright (c) 2009, Pyun YongHyeon 
@@ -3443,27 +3443,37 @@ alc_iff(struct alc_softc *sc)
 	 */
 	rxcfg |= MAC_CFG_BCAST;
 
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
+	/* Program new filter. */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		goto update;
+
+	memset(mchash, 0, sizeof(mchash));
+
+	ETHER_LOCK(ec);
+	ETHER_FIRST_MULTI(step, ec, enm);
+	while (enm != NULL) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			goto update;
+		}
+		crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+		mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+		ETHER_NEXT_MULTI(step, enm);
+	}
+	ETHER_UNLOCK(ec);
+
+update:
+	if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+		if (ifp->if_flags & IFF_PROMISC) {
 			rxcfg |= MAC_CFG_PROMISC;
-		else
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+		} else
 			rxcfg |= MAC_CFG_ALLMULTI;
 		mchash[0] = mchash[1] = 0x;
-	} else {
-		/* Program new filter. */
-		memset(mchash, 0, sizeof(mchash));
-
-		

CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 26 08:20:47 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c if_alc.c if_ale.c if_cas.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #483):

sys/dev/pci/if_cas.c: revision 1.36
sys/dev/pci/if_alc.c: revision 1.44
sys/dev/pci/if_ale.c: revision 1.35
sys/dev/pci/if_ale.c: revision 1.36
sys/dev/pci/if_age.c: revision 1.64

Fix a bug that IFF_ALLMULTI is almost always set.
 OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.

 Remove accidentally committed debug code. Sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.60.2.3 -r1.60.2.4 src/sys/dev/pci/if_age.c
cvs rdiff -u -r1.38.2.2 -r1.38.2.3 src/sys/dev/pci/if_alc.c
cvs rdiff -u -r1.33.2.1 -r1.33.2.2 src/sys/dev/pci/if_ale.c
cvs rdiff -u -r1.35 -r1.35.2.1 src/sys/dev/pci/if_cas.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 26 08:18:40 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #482):

sys/dev/pci/if_age.c: revision 1.63

Fix multicast handling. All Atheros controllers use big-endian form
when computing multicast hash. Same as OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.60.2.2 -r1.60.2.3 src/sys/dev/pci/if_age.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_age.c
diff -u src/sys/dev/pci/if_age.c:1.60.2.2 src/sys/dev/pci/if_age.c:1.60.2.3
--- src/sys/dev/pci/if_age.c:1.60.2.2	Wed Nov  6 09:59:39 2019
+++ src/sys/dev/pci/if_age.c	Tue Nov 26 08:18:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_age.c,v 1.60.2.2 2019/11/06 09:59:39 martin Exp $ */
+/*	$NetBSD: if_age.c,v 1.60.2.3 2019/11/26 08:18:40 martin Exp $ */
 /*	$OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $	*/
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.2 2019/11/06 09:59:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.3 2019/11/26 08:18:40 martin Exp $");
 
 #include "vlan.h"
 
@@ -2289,7 +2289,7 @@ age_rxfilter(struct age_softc *sc)
 		ETHER_LOCK(ec);
 		ETHER_FIRST_MULTI(step, ec, enm);
 		while (enm != NULL) {
-			crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
+			crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
 			mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
 			ETHER_NEXT_MULTI(step, enm);
 		}



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 26 08:18:40 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #482):

sys/dev/pci/if_age.c: revision 1.63

Fix multicast handling. All Atheros controllers use big-endian form
when computing multicast hash. Same as OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.60.2.2 -r1.60.2.3 src/sys/dev/pci/if_age.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 25 16:47:16 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_vge.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #477):

sys/dev/pci/if_vge.c: revision 1.76
sys/dev/pci/if_vge.c: revision 1.77

 Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.

- Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
  the current active link status.


To generate a diff of this commit:
cvs rdiff -u -r1.73.2.1 -r1.73.2.2 src/sys/dev/pci/if_vge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_vge.c
diff -u src/sys/dev/pci/if_vge.c:1.73.2.1 src/sys/dev/pci/if_vge.c:1.73.2.2
--- src/sys/dev/pci/if_vge.c:1.73.2.1	Thu Oct 17 18:58:33 2019
+++ src/sys/dev/pci/if_vge.c	Mon Nov 25 16:47:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.73.2.1 2019/10/17 18:58:33 martin Exp $ */
+/* $NetBSD: if_vge.c,v 1.73.2.2 2019/11/25 16:47:16 martin Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.73.2.1 2019/10/17 18:58:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.73.2.2 2019/11/25 16:47:16 martin Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -1916,6 +1916,7 @@ vge_miibus_statchg(struct ifnet *ifp)
 	struct vge_softc *sc = ifp->if_softc;
 	struct mii_data *mii = >sc_mii;
 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
+	uint8_t dctl;
 
 	/*
 	 * If the user manually selects a media mode, we need to turn
@@ -1927,31 +1928,37 @@ vge_miibus_statchg(struct ifnet *ifp)
 	 * always implied, so we turn on the forced mode bit but leave
 	 * the FDX bit cleared.
 	 */
+	dctl = CSR_READ_1(sc, VGE_DIAGCTL);
 
-	switch (IFM_SUBTYPE(ife->ifm_media)) {
-	case IFM_AUTO:
-		CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE);
-		CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
-		break;
-	case IFM_1000_T:
-		CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE);
-		CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
-		break;
-	case IFM_100_TX:
-	case IFM_10_T:
-		CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE);
-		if ((ife->ifm_media & IFM_FDX) != 0) {
-			CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
-		} else {
-			CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
-		}
-		break;
-	default:
-		printf("%s: unknown media type: %x\n",
-		device_xname(sc->sc_dev),
-		IFM_SUBTYPE(ife->ifm_media));
-		break;
+	if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
+		dctl &= ~VGE_DIAGCTL_MACFORCE;
+		dctl &= ~VGE_DIAGCTL_FDXFORCE;
+	} else {
+		u_int ifmword;
+
+		/* If the link is up, use the current active media. */
+		if ((mii->mii_media_status & IFM_ACTIVE) != 0)
+			ifmword = mii->mii_media_active;
+		else
+			ifmword = ife->ifm_media;
+
+		dctl |= VGE_DIAGCTL_MACFORCE;
+		if ((ifmword & IFM_FDX) != 0)
+			dctl |= VGE_DIAGCTL_FDXFORCE;
+		else
+			dctl &= ~VGE_DIAGCTL_FDXFORCE;
+
+		if (IFM_SUBTYPE(ifmword) == IFM_1000_T) {
+			/*
+			 * It means the user setting is not auto but it's
+			 * 1000baseT-FDX or 1000baseT.
+			 */
+			dctl |= VGE_DIAGCTL_GMII;
+		} else
+			dctl &= ~VGE_DIAGCTL_GMII;
 	}
+
+	CSR_WRITE_1(sc, VGE_DIAGCTL, dctl);
 }
 
 static int



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 25 16:47:16 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_vge.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #477):

sys/dev/pci/if_vge.c: revision 1.76
sys/dev/pci/if_vge.c: revision 1.77

 Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.

- Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
  the current active link status.


To generate a diff of this commit:
cvs rdiff -u -r1.73.2.1 -r1.73.2.2 src/sys/dev/pci/if_vge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:17:44 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #453):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.216
sys/dev/pci/ixgbe/ixv.c: revision 1.141

Print MAC address.

 XXX Should we move such type of printf() to ether_ifattach?


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.6 -r1.199.2.7 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.125.2.6 -r1.125.2.7 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:17:44 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #453):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.216
sys/dev/pci/ixgbe/ixv.c: revision 1.141

Print MAC address.

 XXX Should we move such type of printf() to ether_ifattach?


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.6 -r1.199.2.7 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.125.2.6 -r1.125.2.7 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.6 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.7
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.6	Thu Oct 17 19:09:14 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Tue Nov 19 13:17:44 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.199.2.6 2019/10/17 19:09:14 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.199.2.7 2019/11/19 13:17:44 martin Exp $ */
 
 /**
 
@@ -1338,6 +1338,8 @@ ixgbe_setup_interface(device_t dev, stru
 	}
 	adapter->ipq = if_percpuq_create(>osdep.ec.ec_if);
 	ether_ifattach(ifp, adapter->hw.mac.addr);
+	aprint_normal_dev(dev, "Ethernet address %s\n",
+	ether_sprintf(adapter->hw.mac.addr));
 	/*
 	 * We use per TX queue softint, so if_deferred_start_init() isn't
 	 * used.

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.125.2.6 src/sys/dev/pci/ixgbe/ixv.c:1.125.2.7
--- src/sys/dev/pci/ixgbe/ixv.c:1.125.2.6	Thu Nov 14 15:30:19 2019
+++ src/sys/dev/pci/ixgbe/ixv.c	Tue Nov 19 13:17:44 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.125.2.6 2019/11/14 15:30:19 martin Exp $*/
+/*$NetBSD: ixv.c,v 1.125.2.7 2019/11/19 13:17:44 martin Exp $*/
 
 /**
 
@@ -1610,6 +1610,8 @@ ixv_setup_interface(device_t dev, struct
 	}
 	adapter->ipq = if_percpuq_create(>osdep.ec.ec_if);
 	ether_ifattach(ifp, adapter->hw.mac.addr);
+	aprint_normal_dev(dev, "Ethernet address %s\n",
+	ether_sprintf(adapter->hw.mac.addr));
 	/*
 	 * We use per TX queue softint, so if_deferred_start_init() isn't
 	 * used.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:07:37 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_msk.c if_skreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #450):

sys/dev/pci/if_msk.c: revision 1.94
sys/dev/pci/if_skreg.h: revision 1.27

 Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

 At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.


To generate a diff of this commit:
cvs rdiff -u -r1.91.2.1 -r1.91.2.2 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.26 -r1.26.4.1 src/sys/dev/pci/if_skreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.91.2.1 src/sys/dev/pci/if_msk.c:1.91.2.2
--- src/sys/dev/pci/if_msk.c:1.91.2.1	Thu Oct 24 16:19:23 2019
+++ src/sys/dev/pci/if_msk.c	Tue Nov 19 13:07:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.91.2.1 2019/10/24 16:19:23 martin Exp $ */
+/* $NetBSD: if_msk.c,v 1.91.2.2 2019/11/19 13:07:37 martin Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.91.2.1 2019/10/24 16:19:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.91.2.2 2019/11/19 13:07:37 martin Exp $");
 
 #include 
 #include 
@@ -887,10 +887,27 @@ void
 mskc_reset(struct sk_softc *sc)
 {
 	uint32_t imtimer_ticks, reg1;
+	uint16_t status;
 	int reg;
 
 	DPRINTFN(2, ("mskc_reset\n"));
 
+	/* Disable ASF */
+	if ((sc->sk_type == SK_YUKON_EX) || (sc->sk_type == SK_YUKON_SUPR)) {
+		CSR_WRITE_4(sc, SK_Y2_CPU_WDOG, 0);
+		status = CSR_READ_2(sc, SK_Y2_ASF_HCU_CCSR);
+		/* Clear AHB bridge & microcontroller reset. */
+		status &= ~(SK_Y2_ASF_HCU_CSSR_ARB_RST |
+		SK_Y2_ASF_HCU_CSSR_CPU_RST_MODE);
+		/* Clear ASF microcontroller state. */
+		status &= ~SK_Y2_ASF_HCU_CSSR_UC_STATE_MSK;
+		status &= ~SK_Y2_ASF_HCU_CSSR_CPU_CLK_DIVIDE_MSK;
+		CSR_WRITE_2(sc, SK_Y2_ASF_HCU_CCSR, status);
+		CSR_WRITE_4(sc, SK_Y2_CPU_WDOG, 0);
+	} else
+		CSR_WRITE_1(sc, SK_Y2_ASF_CSR, SK_Y2_ASF_RESET);
+	CSR_WRITE_2(sc, SK_CSR, SK_CSR_ASF_OFF);
+
 	CSR_WRITE_1(sc, SK_CSR, SK_CSR_SW_RESET);
 	CSR_WRITE_1(sc, SK_CSR, SK_CSR_MASTER_RESET);
 
@@ -963,10 +980,6 @@ mskc_reset(struct sk_softc *sc)
 	DPRINTFN(2, ("mskc_reset: sk_link_ctrl=%x\n",
 		 CSR_READ_2(sc, SK_LINK_CTRL)));
 
-	/* Disable ASF */
-	CSR_WRITE_1(sc, SK_Y2_ASF_CSR, SK_Y2_ASF_RESET);
-	CSR_WRITE_2(sc, SK_CSR, SK_CSR_ASF_OFF);
-
 	/* Clear I2C IRQ noise */
 	CSR_WRITE_4(sc, SK_I2CHWIRQ, 1);
 
@@ -1102,9 +1115,9 @@ msk_reset(struct sk_if_softc *sc_if)
 {
 	/* GMAC and GPHY Reset */
 	SK_IF_WRITE_4(sc_if, 0, SK_GMAC_CTRL, SK_GMAC_RESET_SET);
-	SK_IF_WRITE_4(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_SET);
+	SK_IF_WRITE_1(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_SET);
 	DELAY(1000);
-	SK_IF_WRITE_4(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_CLEAR);
+	SK_IF_WRITE_1(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_CLEAR);
 	SK_IF_WRITE_4(sc_if, 0, SK_GMAC_CTRL, SK_GMAC_LOOP_OFF |
 		  SK_GMAC_PAUSE_ON | SK_GMAC_RESET_CLEAR);
 }
@@ -2410,17 +2423,31 @@ msk_init_yukon(struct sk_if_softc *sc_if
 
 	/* Configure RX MAC FIFO */
 	SK_IF_WRITE_1(sc_if, 0, SK_RXMF1_CTRL_TEST, SK_RFCTL_RESET_CLEAR);
-	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_CTRL_TEST, SK_RFCTL_OPERATION_ON |
-	SK_RFCTL_FIFO_FLUSH_ON);
-
-	/* Increase flush threshold to 64 bytes */
-	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_FLUSH_THRESHOLD,
-	SK_RFCTL_FIFO_THRESHOLD + 1);
+	v =  SK_RFCTL_OPERATION_ON | SK_RFCTL_FIFO_FLUSH_ON;
+	if ((sc->sk_type == SK_YUKON_EX) || (sc->sk_type == SK_YUKON_FE_P))
+		v |= SK_RFCTL_RX_OVER_ON;
+	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_CTRL_TEST, v);
+
+	if ((sc->sk_type == SK_YUKON_FE_P) &&
+	(sc->sk_rev == SK_YUKON_FE_P_REV_A0))
+		v = 0x178; /* Magic value */
+	else {
+		/* Increase flush threshold to 64 bytes */
+		v = SK_RFCTL_FIFO_THRESHOLD + 1;
+	}
+	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_FLUSH_THRESHOLD, v);
 
 	/* Configure TX MAC FIFO */
 	SK_IF_WRITE_1(sc_if, 0, SK_TXMF1_CTRL_TEST, SK_TFCTL_RESET_CLEAR);
 	SK_IF_WRITE_2(sc_if, 0, SK_TXMF1_CTRL_TEST, SK_TFCTL_OPERATION_ON);
 
+	if ((sc->sk_type == SK_YUKON_FE_P) &&
+	(sc->sk_rev == SK_YUKON_FE_P_REV_A0)) {
+		v = SK_IF_READ_2(sc_if, 0, SK_TXMF1_END);
+		v &= ~SK_TXEND_WM_ON;
+		SK_IF_WRITE_2(sc_if, 0, SK_TXMF1_END, v);
+	}	
+
 #if 1
 	SK_YU_WRITE_2(sc_if, YUKON_GPCR, YU_GPCR_TXEN | YU_GPCR_RXEN);
 #endif
@@ -2457,7 +2484,7 @@ msk_init(struct ifnet *ifp)
 	/* Configure transmit arbiter(s) */
 	SK_IF_WRITE_1(sc_if, 0, SK_TXAR1_COUNTERCTL, SK_TXARCTL_ON);
 #if 0
-	SK_TXARCTL_ON | SK_TXARCTL_FSYNC_ON);
+/*	SK_TXARCTL_ON | SK_TXARCTL_FSYNC_ON); */
 #endif
 
 	if (sc->sk_ramsize) {
@@ -2565,6 +2592,13 @@ msk_init(struct ifnet *ifp)
 	SK_IF_WRITE_2(sc_if, 0, SK_RXQ1_Y2_PREF_PUTIDX,
 	sc_if->sk_cdata.sk_rx_prod);
 
+	
+	if 

CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:07:37 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_msk.c if_skreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #450):

sys/dev/pci/if_msk.c: revision 1.94
sys/dev/pci/if_skreg.h: revision 1.27

 Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

 At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.


To generate a diff of this commit:
cvs rdiff -u -r1.91.2.1 -r1.91.2.2 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.26 -r1.26.4.1 src/sys/dev/pci/if_skreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:04:44 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #449


To generate a diff of this commit:
cvs rdiff -u -r1.1371.2.3 -r1.1371.2.4 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370.2.3 -r1.1370.2.4 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:03:32 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #449):

sys/dev/pci/pcidevs: revision 1.1388
sys/dev/pci/pcidevs: revision 1.1389
sys/dev/pci/pcidevs: revision 1.1390
sys/dev/pci/pcidevs: revision 1.1391

Spell controller correctly
 Add Realtek RTL8125.
- Update Intel's NVMe SSDs.
  - Modify 0x0953's description to "750 or DC P3[567]00 SSD"
  - Add DC P4[56]00
- Add Apollo Lake TXE HECI.
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.3 -r1.1383.2.4 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:03:32 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #449):

sys/dev/pci/pcidevs: revision 1.1388
sys/dev/pci/pcidevs: revision 1.1389
sys/dev/pci/pcidevs: revision 1.1390
sys/dev/pci/pcidevs: revision 1.1391

Spell controller correctly
 Add Realtek RTL8125.
- Update Intel's NVMe SSDs.
  - Modify 0x0953's description to "750 or DC P3[567]00 SSD"
  - Add DC P4[56]00
- Add Apollo Lake TXE HECI.
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.3 -r1.1383.2.4 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1383.2.3 src/sys/dev/pci/pcidevs:1.1383.2.4
--- src/sys/dev/pci/pcidevs:1.1383.2.3	Thu Oct 24 16:12:42 2019
+++ src/sys/dev/pci/pcidevs	Tue Nov 19 13:03:32 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1383.2.3 2019/10/24 16:12:42 martin Exp $
+$NetBSD: pcidevs,v 1.1383.2.4 2019/11/19 13:03:32 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2513,6 +2513,7 @@ product DLINK DL4000		0x4000	DL-4000 Gig
 product DLINK DGE550SX		0x4001	DGE-550SX
 product DLINK DFE520TX		0x4200	DFE-520TX 10/100 Ethernet
 product DLINK DGE528T		0x4300	DGE-528T Gigabit Ethernet
+product DLINK DGE530T_C1	0x4302	DGE-530T C1
 product DLINK DGE560T		0x4b00	DGE-560T Gigabit Ethernet
 product DLINK DGE560T_2		0x4b01	DGE-560T_2 Gigabit Ethernet
 product DLINK DGE560SX		0x4b02	DGE-560SX
@@ -3117,7 +3118,7 @@ product INTEL X1000_HS_UART	0x0936	Quark
 product INTEL X1000_MAC		0x0937	Quark X1000 10/100 Ethernet MAC
 product INTEL X1000_EHCI	0x0939	Quark X1000 EHCI
 product INTEL X1000_OHCI	0x093a	Quark X1000 OHCI
-product INTEL PCIE_NVME_SSD	0x0953	PCIe NVMe SSD
+product INTEL PCIE_NVME_SSD	0x0953	750 or DC P3[567]00 SSD
 product INTEL X1000_HB		0x0958	Quark X1000 Host Bridge
 product INTEL WIFI_LINK_7265_1	0x095a	Dual Band Wireless AC 7265
 product INTEL WIFI_LINK_7265_2	0x095b	Dual Band Wireless AC 7265
@@ -3142,6 +3143,8 @@ product INTEL CORE4G_S_ULT_GT3	0x0a2a	HD
 product INTEL CORE4G_R_ULT_GT3_1 0x0a2b	HD Graphics
 product INTEL CORE4G_R_ULT_GT3_2 0x0a2e	Iris Graphics 5100
 product INTEL DC_P3520_SSD	0x0a53	SSD DC P3520
+product INTEL DC_P4500_SSD	0x0a54	SSD DC P4500
+product INTEL DC_P4600_SSD	0x0a55	SSD DC P4600
 product INTEL HASWELL_HOST_DRAM	0x0c00	Haswell Host Bridge, DRAM
 product INTEL HASWELL_PCIE16	0x0c01	Haswell PCI-E x16 Controller
 product INTEL HASWELL_PCIE8	0x0c05	Haswell PCI-E x8 Controller
@@ -4944,6 +4947,9 @@ product INTEL APL_P2SB		0x5a92	Apollo La
 product INTEL APL_PMC		0x5a94	Apollo Lake PMC
 product INTEL APL_FASTSPI	0x5a96	Apollo Lake Fast SPI
 product INTEL APL_HDA		0x5a98	Apollo Lake HD Audio
+product INTEL APL_TXE_HECI_1	0x5a9a	Apollo Lake TXE HECI1
+product INTEL APL_TXE_HECI_2	0x5a9c	Apollo Lake TXE HECI2
+product INTEL APL_TXE_HECI_3	0x5a9e	Apollo Lake TXE HECI3
 product INTEL APL_ISH		0x5aa2	Apollo Lake Integrated Sensor Hub
 product INTEL APL_XHCI		0x5aa8	Apollo Lake USB Host (xHCI)
 product INTEL APL_XDCI		0x5aaa	Apollo Lake USB Device (xDCI)
@@ -5960,6 +5966,9 @@ product MYRICOM MYRINET	0x8043	Myrinet
 /* Myson-Century Technology products */
 product MYSON MTD803	0x0803	MTD803 3-in-1 Fast Ethernet Controller
 
+/* Ncube products */
+product NCUBE TG3648	0x8168	TP-Link TG-3468 v2 Gigabit Ethernet
+
 /* National Datacomm products */
 product NDC NCP130		0x0130 NCP130 Wireless NIC
 product NDC NCP130A2		0x0131 NCP130 rev A2 Wireless NIC
@@ -6839,7 +6848,7 @@ product PROMISE PDC20271	0x6269	PDC20271
 product PROMISE PDC20617	0x6617	PDC20617 Dual Ultra/133 IDE Controller
 product PROMISE PDC20620	0x6620	PDC20620 Dual Ultra/133 IDE Controller
 product PROMISE PDC20621	0x6621	PDC20621 Dual Ultra/133 IDE Controller
-product PROMISE PDC20618	0x6626	PDC20618 Dual Ultra/133 IDE Controler
+product PROMISE PDC20618	0x6626	PDC20618 Dual Ultra/133 IDE Controller
 product PROMISE PDC20619	0x6629	PDC20619 Dual Ultra/133 IDE Controller
 product PROMISE PDC20277	0x7275	PDC20277 Ultra/133 IDE Controller
 
@@ -7031,6 +7040,7 @@ product REALTEK RTL8411		0x5289	RTL8411 
 product REALTEK RT8029		0x8029	8029 Ethernet
 product REALTEK RT8139D		0x8039	8139D 10/100 Ethernet
 product REALTEK RT8100		0x8100	8100 10/100 Ethernet
+product REALTEK RT8125		0x8125	8129 10/100/1G/2.5G Ethernet
 product REALTEK RT8129		0x8129	8129 10/100 Ethernet
 product REALTEK RT8101E		0x8136	8100E/8101E/8102E 10/100 Ethernet
 product REALTEK RT8138		0x8138	8138 10/100 Ethernet



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 14 15:41:04 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pucdata.c

Log Message:
Pull up following revision(s) (requested by hauke in ticket #426):

sys/dev/pci/pucdata.c: revision 1.105

The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.
ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.2.1 src/sys/dev/pci/pucdata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 14 15:41:04 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pucdata.c

Log Message:
Pull up following revision(s) (requested by hauke in ticket #426):

sys/dev/pci/pucdata.c: revision 1.105

The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.
ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.2.1 src/sys/dev/pci/pucdata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pucdata.c
diff -u src/sys/dev/pci/pucdata.c:1.104 src/sys/dev/pci/pucdata.c:1.104.2.1
--- src/sys/dev/pci/pucdata.c:1.104	Thu May  2 21:33:12 2019
+++ src/sys/dev/pci/pucdata.c	Thu Nov 14 15:41:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pucdata.c,v 1.104 2019/05/02 21:33:12 jdolecek Exp $	*/
+/*	$NetBSD: pucdata.c,v 1.104.2.1 2019/11/14 15:41:03 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.104 2019/05/02 21:33:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.104.2.1 2019/11/14 15:41:03 martin Exp $");
 
 #include 
 #include 
@@ -2883,10 +2883,10 @@ const struct puc_device_description puc_
 	{	PCI_VENDOR_SYSTEMBASE, PCI_PRODUCT_SYSTEMBASE_SB16C1054, 0, 0 },
 	{	0x,	0x,		 0, 0 },
 	{
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ * 8 },
 	},
 	},
 
@@ -2895,14 +2895,14 @@ const struct puc_device_description puc_
 	{   PCI_VENDOR_SYSTEMBASE, PCI_PRODUCT_SYSTEMBASE_SB16C1058, 0, 0 },
 	{	0x,	0x,		 0, 0 },
 	{
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x20, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x28, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x30, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x38, COM_FREQ },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x20, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x28, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x30, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x38, COM_FREQ * 8 },
 	},
 	},
 



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-11-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 14 15:30:19 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #422):

sys/dev/pci/ixgbe/ixv.c: revision 1.140

ixv(4): disable RSS configuration on 82599 and X540 VFs.

Those VFs share their RSS configuration with PF and, thus,
they cannot be configured independently. From FreeBSD r354349.


To generate a diff of this commit:
cvs rdiff -u -r1.125.2.5 -r1.125.2.6 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.125.2.5 src/sys/dev/pci/ixgbe/ixv.c:1.125.2.6
--- src/sys/dev/pci/ixgbe/ixv.c:1.125.2.5	Tue Oct  8 17:05:16 2019
+++ src/sys/dev/pci/ixgbe/ixv.c	Thu Nov 14 15:30:19 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.125.2.5 2019/10/08 17:05:16 martin Exp $*/
+/*$NetBSD: ixv.c,v 1.125.2.6 2019/11/14 15:30:19 martin Exp $*/
 
 /**
 
@@ -1920,7 +1920,8 @@ ixv_initialize_receive_units(struct adap
 			adapter->num_rx_desc - 1);
 	}
 
-	ixv_initialize_rss_mapping(adapter);
+	if (adapter->hw.mac.type >= ixgbe_mac_X550_vf)
+		ixv_initialize_rss_mapping(adapter);
 } /* ixv_initialize_receive_units */
 
 /



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-11-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 14 15:30:19 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #422):

sys/dev/pci/ixgbe/ixv.c: revision 1.140

ixv(4): disable RSS configuration on 82599 and X540 VFs.

Those VFs share their RSS configuration with PF and, thus,
they cannot be configured independently. From FreeBSD r354349.


To generate a diff of this commit:
cvs rdiff -u -r1.125.2.5 -r1.125.2.6 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Nov 10 13:05:15 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_kse.c

Log Message:
Pull up following revision(s) (requested by nisimura in ticket #406):

sys/dev/pci/if_kse.c: revision 1.40
sys/dev/pci/if_kse.c: revision 1.41
sys/dev/pci/if_kse.c: revision 1.39

comment touchup

 -

clarify 8842 MAC behaves 100FDX only has no alternative media selection
possible.

 -

major rework to fix link control breakage


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.2.1 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Nov 10 13:05:15 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_kse.c

Log Message:
Pull up following revision(s) (requested by nisimura in ticket #406):

sys/dev/pci/if_kse.c: revision 1.40
sys/dev/pci/if_kse.c: revision 1.41
sys/dev/pci/if_kse.c: revision 1.39

comment touchup

 -

clarify 8842 MAC behaves 100FDX only has no alternative media selection
possible.

 -

major rework to fix link control breakage


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.2.1 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_kse.c
diff -u src/sys/dev/pci/if_kse.c:1.38 src/sys/dev/pci/if_kse.c:1.38.2.1
--- src/sys/dev/pci/if_kse.c:1.38	Wed May 29 10:07:29 2019
+++ src/sys/dev/pci/if_kse.c	Sun Nov 10 13:05:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_kse.c,v 1.38 2019/05/29 10:07:29 msaitoh Exp $	*/
+/*	$NetBSD: if_kse.c,v 1.38.2.1 2019/11/10 13:05:15 martin Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -29,9 +29,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include 
-__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.38 2019/05/29 10:07:29 msaitoh Exp $");
+/*
+ * Micrel 8841/8842 10/100 ethernet driver
+ */
 
+#include 
+__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.38.2.1 2019/11/10 13:05:15 martin Exp $");
 
 #include 
 #include 
@@ -58,6 +61,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #include 
 #include 
 
+#define KSE_LINKDEBUG 0
+
 #define CSR_READ_4(sc, off) \
 	bus_space_read_4(sc->sc_st, sc->sc_sh, off)
 #define CSR_WRITE_4(sc, off, val) \
@@ -93,6 +98,17 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #define P1SR	0x514	/* port 1 status */
 #define P2CR4	0x532	/* port 2 control 4 */
 #define P2SR	0x534	/* port 2 status */
+#define PxCR_STARTNEG	(1U << 9)	/* restart auto negotiation */
+#define PxCR_AUTOEN	(1U << 7)	/* auto negotiation enable */
+#define PxCR_SPD100	(1U << 6)	/* force speed 100 */
+#define PxCR_USEFDX	(1U << 5)	/* force full duplex */
+#define PxCR_USEFC	(1U << 4)	/* advertise pause flow control */
+#define PxSR_ACOMP	(1U << 6)	/* auto negotiation completed */
+#define PxSR_SPD100	(1U << 10)	/* speed is 100Mbps */
+#define PxSR_FDX	(1U << 9)	/* full duplex */
+#define PxSR_LINKUP	(1U << 5)	/* link is good */
+#define PxSR_RXFLOW	(1U << 12)	/* receive flow control active */
+#define PxSR_TXFLOW	(1U << 11)	/* transmit flow control active */
 
 #define TXC_BS_MSK	0x3f00	/* burst size */
 #define TXC_BS_SFT	(24)		/* 1,2,4,8,16,32 or 0 for unlimited */
@@ -207,8 +223,8 @@ struct kse_softc {
 	void *sc_ih;			/* interrupt cookie */
 
 	struct ifmedia sc_media;	/* ifmedia information */
-	int sc_media_status;		/* PHY */
-	int sc_media_active;		/* PHY */
+	int sc_linkstatus;		/* last P1SR register value */
+
 	callout_t  sc_callout;		/* MII tick callout */
 	callout_t  sc_stat_ch;		/* statistics counter callout */
 
@@ -313,11 +329,10 @@ static int kse_intr(void *);
 static void rxintr(struct kse_softc *);
 static void txreap(struct kse_softc *);
 static void lnkchg(struct kse_softc *);
-static int ifmedia_upd(struct ifnet *);
-static void ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int ksephy_change(struct ifnet *);
+static void ksephy_status(struct ifnet *, struct ifmediareq *);
+static void nopifm_status(struct ifnet *, struct ifmediareq *);
 static void phy_tick(void *);
-static int ifmedia2_upd(struct ifnet *);
-static void ifmedia2_sts(struct ifnet *, struct ifmediareq *);
 #ifdef KSE_EVENT_COUNTERS
 static void stat_tick(void *);
 static void zerostats(struct kse_softc *);
@@ -493,8 +508,9 @@ kse_attach(device_t parent, device_t sel
 	/* Initialize ifmedia structures. */
 	ifm = >sc_media;
 	sc->sc_ethercom.ec_ifmedia = ifm;
+	sc->sc_linkstatus = 0;
 	if (sc->sc_chip == 0x8841) {
-		ifmedia_init(ifm, 0, ifmedia_upd, ifmedia_sts);
+		ifmedia_init(ifm, 0, ksephy_change, ksephy_status);
 		ifmedia_add(ifm, IFM_ETHER | IFM_10_T, 0, NULL);
 		ifmedia_add(ifm, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL);
 		ifmedia_add(ifm, IFM_ETHER | IFM_100_TX, 0, NULL);
@@ -502,9 +518,18 @@ kse_attach(device_t parent, device_t sel
 		ifmedia_add(ifm, IFM_ETHER | IFM_AUTO, 0, NULL);
 		ifmedia_set(ifm, IFM_ETHER | IFM_AUTO);
 	} else {
-		ifmedia_init(ifm, 0, ifmedia2_upd, ifmedia2_sts);
-		ifmedia_add(ifm, IFM_ETHER | IFM_AUTO, 0, NULL);
-		ifmedia_set(ifm, IFM_ETHER | IFM_AUTO);
+		/*
+		 * pretend 100FDX w/ no alternative media selection.
+		 * 8842 MAC is tied with a builtin 3 port switch.
+		 * It can do rate control over either of tx / rx direction
+		 * respectively, tough, this driver leaves the rate unlimited
+		 * intending 100Mbps maximum.
+		 * 2 ports behave in AN mode and this driver provides no mean
+		 * to see the exact details.
+		 */
+		ifmedia_init(ifm, 0, NULL, nopifm_status);
+		ifmedia_add(ifm, IFM_ETHER | IFM_100_TX | 

CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov  6 10:07:42 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_wm.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #404):

sys/dev/pci/if_wm.c: revision 1.646
sys/dev/pci/if_wm.c: revision 1.647
sys/dev/pci/if_wm.c: revision 1.649

Use unsigned to avoid undefined behavior in wm_i82543_mii_sendbits().
Found by kUBSan.

printf -> device_printf

Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.645 -r1.645.2.1 src/sys/dev/pci/if_wm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov  6 10:07:42 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_wm.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #404):

sys/dev/pci/if_wm.c: revision 1.646
sys/dev/pci/if_wm.c: revision 1.647
sys/dev/pci/if_wm.c: revision 1.649

Use unsigned to avoid undefined behavior in wm_i82543_mii_sendbits().
Found by kUBSan.

printf -> device_printf

Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.645 -r1.645.2.1 src/sys/dev/pci/if_wm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.645 src/sys/dev/pci/if_wm.c:1.645.2.1
--- src/sys/dev/pci/if_wm.c:1.645	Tue Jul 30 04:42:29 2019
+++ src/sys/dev/pci/if_wm.c	Wed Nov  6 10:07:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.645 2019/07/30 04:42:29 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.645.2.1 2019/11/06 10:07:42 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.645 2019/07/30 04:42:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.645.2.1 2019/11/06 10:07:42 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4616,8 +4616,8 @@ wm_flush_desc_rings(struct wm_softc *sc)
 		return;
 
 	/* TX */
-	printf("%s: Need TX flush (reg = %08x, len = %u)\n",
-	device_xname(sc->sc_dev), preg, reg);
+	device_printf(sc->sc_dev, "Need TX flush (reg = %08x, len = %u)\n",
+	preg, reg);
 	reg = CSR_READ(sc, WMREG_TCTL);
 	CSR_WRITE(sc, WMREG_TCTL, reg | TCTL_EN);
 
@@ -4644,8 +4644,7 @@ wm_flush_desc_rings(struct wm_softc *sc)
 		return;
 
 	/* RX */
-	printf("%s: Need RX flush (reg = %08x)\n",
-	device_xname(sc->sc_dev), preg);
+	device_printf(sc->sc_dev, "Need RX flush (reg = %08x)\n", preg);
 	rctl = CSR_READ(sc, WMREG_RCTL);
 	CSR_WRITE(sc, WMREG_RCTL, rctl & ~RCTL_EN);
 	CSR_WRITE_FLUSH(sc);
@@ -4885,7 +4884,7 @@ wm_reset(struct wm_softc *sc)
 			reg |= CTRL_PHY_RESET;
 			phy_reset = 1;
 		} else
-			printf("XXX reset is blocked!!!\n");
+			device_printf(sc->sc_dev, "XXX reset is blocked!!!\n");
 		sc->phy.acquire(sc);
 		CSR_WRITE(sc, WMREG_CTRL, reg);
 		/* Don't insert a completion barrier when reset */
@@ -9033,7 +9032,8 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
  * Fiber?
  * Shoud not enter here.
  */
-printf("unknown media (%x)\n", active);
+device_printf(dev, "unknown media (%x)\n",
+active);
 break;
 			}
 			if (active & IFM_FDX)
@@ -9893,7 +9893,7 @@ wm_gmii_reset(struct wm_softc *sc)
  * result might be incorrect.
  *
  *  In the second call, PHY OUI and model is used to identify PHY type.
- * It might not be perfpect because of the lack of compared entry, but it
+ * It might not be perfect because of the lack of compared entry, but it
  * would be better than the first call.
  *
  *  If the detected new result and previous assumption is different,
@@ -10413,7 +10413,7 @@ wm_i82543_mii_sendbits(struct wm_softc *
 	v &= ~(MDI_IO | MDI_CLK | (CTRL_SWDPIO_MASK << CTRL_SWDPIO_SHIFT));
 	v |= MDI_DIR | CTRL_SWDPIO(3);
 
-	for (i = 1 << (nbits - 1); i != 0; i >>= 1) {
+	for (i = __BIT(nbits - 1); i != 0; i >>= 1) {
 		if (data & i)
 			v |= MDI_IO;
 		else
@@ -11137,7 +11137,7 @@ wm_gmii_hv_readreg_locked(device_t dev, 
 	 * own func
 	 */
 	if ((page > 0) && (page < HV_INTC_FC_PAGE_START)) {
-		printf("gmii_hv_readreg!!!\n");
+		device_printf(dev, "gmii_hv_readreg!!!\n");
 		return -1;
 	}
 
@@ -11205,7 +11205,7 @@ wm_gmii_hv_writereg_locked(device_t dev,
 	 * own func
 	 */
 	if ((page > 0) && (page < HV_INTC_FC_PAGE_START)) {
-		printf("gmii_hv_writereg!!!\n");
+		device_printf(dev, "gmii_hv_writereg!!!\n");
 		return -1;
 	}
 
@@ -11229,7 +11229,7 @@ wm_gmii_hv_writereg_locked(device_t dev,
 			if ((child != NULL) && (child->mii_mpd_rev >= 1)
 			&& (phy == 2) && ((regnum & MII_ADDRMASK) == 0)
 			&& ((val & (1 << 11)) != 0)) {
-printf("XXX need workaround\n");
+device_printf(dev, "XXX need workaround\n");
 			}
 		}
 
@@ -12851,12 +12851,12 @@ wm_ich8_cycle_init(struct wm_softc *sc)
 	/*
 	 * Either we should have a hardware SPI cycle in progress bit to check
 	 * against, in order to start a new cycle or FDONE bit should be
-	 * changed in the hardware so that it is 1 after harware reset, which
+	 * changed in the hardware so that it is 1 after hardware reset, which
 	 * can then be used as an indication whether a cycle is in progress or
 	 * has been completed .. we should also have some software semaphore
 	 * mechanism to guard FDONE or the cycle in progress bit so that two
 	 * threads access to those bits can be sequentiallized or a way so that
-	 * 2 threads dont start the cycle at the same time
+	 * 2 threads don't start the cycle at the same time
 	 */
 
 	

CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov  6 09:52:20 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #401):

sys/dev/pci/pci.c: revision 1.156

PCIe downstream ports only have a single child device, so limit probing to
dev 0.


To generate a diff of this commit:
cvs rdiff -u -r1.154.4.1 -r1.154.4.2 src/sys/dev/pci/pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov  6 09:52:20 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #401):

sys/dev/pci/pci.c: revision 1.156

PCIe downstream ports only have a single child device, so limit probing to
dev 0.


To generate a diff of this commit:
cvs rdiff -u -r1.154.4.1 -r1.154.4.2 src/sys/dev/pci/pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pci.c
diff -u src/sys/dev/pci/pci.c:1.154.4.1 src/sys/dev/pci/pci.c:1.154.4.2
--- src/sys/dev/pci/pci.c:1.154.4.1	Tue Oct 15 19:33:23 2019
+++ src/sys/dev/pci/pci.c	Wed Nov  6 09:52:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.c,v 1.154.4.1 2019/10/15 19:33:23 martin Exp $	*/
+/*	$NetBSD: pci.c,v 1.154.4.2 2019/11/06 09:52:20 martin Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.154.4.1 2019/10/15 19:33:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.154.4.2 2019/11/06 09:52:20 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -695,17 +695,26 @@ pci_enumerate_bus(struct pci_softc *sc, 
 
 	device_t bridgedev;
 	bool arien = false;
+	bool downstream_port = false;
 
-	/* Check PCIe ARI */
+	/* Check PCIe ARI and port type */
 	bridgedev = device_parent(sc->sc_dev);
 	if (device_is_a(bridgedev, "ppb")) {
 		struct ppb_softc *ppbsc = device_private(bridgedev);
 		pci_chipset_tag_t ppbpc = ppbsc->sc_pc;
 		pcitag_t ppbtag = ppbsc->sc_tag;
-		pcireg_t pciecap, reg;
+		pcireg_t pciecap, capreg, reg;
 
 		if (pci_get_capability(ppbpc, ppbtag, PCI_CAP_PCIEXPRESS,
-		, NULL) != 0) {
+		, ) != 0) {
+			switch (PCIE_XCAP_TYPE(capreg)) {
+			case PCIE_XCAP_TYPE_ROOT:
+			case PCIE_XCAP_TYPE_DOWN:
+			case PCIE_XCAP_TYPE_PCI2PCIE:
+downstream_port = true;
+break;
+			}
+
 			reg = pci_conf_read(ppbpc, ppbtag, pciecap
 			+ PCIE_DCSR2);
 			if ((reg & PCIE_DCSR2_ARI_FWD) != 0)
@@ -714,6 +723,11 @@ pci_enumerate_bus(struct pci_softc *sc, 
 	}
 
 	n = pci_bus_devorder(sc->sc_pc, sc->sc_bus, devs, __arraycount(devs));
+	if (downstream_port) {
+		/* PCIe downstream ports only have a single child device */
+		n = 1;
+	}
+
 	for (i = 0; i < n; i++) {
 		device = devs[i];
 



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:25:33 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_jme.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #376):

sys/dev/pci/if_jme.c: revision 1.46

A * is missing here. This could cause a use-after-free.
Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/dev/pci/if_jme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_jme.c
diff -u src/sys/dev/pci/if_jme.c:1.44 src/sys/dev/pci/if_jme.c:1.44.2.1
--- src/sys/dev/pci/if_jme.c:1.44	Tue Jul  9 08:46:59 2019
+++ src/sys/dev/pci/if_jme.c	Thu Oct 24 16:25:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_jme.c,v 1.44 2019/07/09 08:46:59 msaitoh Exp $	*/
+/*	$NetBSD: if_jme.c,v 1.44.2.1 2019/10/24 16:25:33 martin Exp $	*/
 
 /*
  * Copyright (c) 2008 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.44 2019/07/09 08:46:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.44.2.1 2019/10/24 16:25:33 martin Exp $");
 
 
 #include 
@@ -1453,7 +1453,7 @@ jme_encap(struct jme_softc *sc, struct m
 			"DMA segments, dropping...\n",
 			device_xname(sc->jme_dev));
 			m_freem(*m_head);
-			m_head = NULL;
+			*m_head = NULL;
 		}
 		return (error);
 	}



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:25:33 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_jme.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #376):

sys/dev/pci/if_jme.c: revision 1.46

A * is missing here. This could cause a use-after-free.
Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/dev/pci/if_jme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:19:23 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_msk.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #374):

sys/dev/pci/if_msk.c: revision 1.92

Fix order of m_freem(). Found by kASan. OK'd by jdolecek and mrg.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.91.2.1 src/sys/dev/pci/if_msk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:19:23 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_msk.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #374):

sys/dev/pci/if_msk.c: revision 1.92

Fix order of m_freem(). Found by kASan. OK'd by jdolecek and mrg.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.91.2.1 src/sys/dev/pci/if_msk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.91 src/sys/dev/pci/if_msk.c:1.91.2.1
--- src/sys/dev/pci/if_msk.c:1.91	Mon Jun  3 05:22:57 2019
+++ src/sys/dev/pci/if_msk.c	Thu Oct 24 16:19:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.91 2019/06/03 05:22:57 msaitoh Exp $ */
+/* $NetBSD: if_msk.c,v 1.91.2.1 2019/10/24 16:19:23 martin Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.91 2019/06/03 05:22:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.91.2.1 2019/10/24 16:19:23 martin Exp $");
 
 #include 
 #include 
@@ -2118,9 +2118,6 @@ msk_txeof(struct sk_if_softc *sc_if)
 		if (sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf != NULL) {
 			entry = sc_if->sk_cdata.sk_tx_map[idx];
 
-			m_freem(sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf);
-			sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf = NULL;
-
 			bus_dmamap_sync(sc->sc_dmatag, entry->dmamap, 0,
 			entry->dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE);
 
@@ -2128,6 +2125,8 @@ msk_txeof(struct sk_if_softc *sc_if)
 			SIMPLEQ_INSERT_TAIL(_if->sk_txmap_head, entry,
 	  link);
 			sc_if->sk_cdata.sk_tx_map[idx] = NULL;
+			m_freem(sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf);
+			sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf = NULL;
 		}
 		sc_if->sk_cdata.sk_tx_cnt--;
 		SK_INC(idx, MSK_TX_RING_CNT);
@@ -2646,13 +2645,19 @@ msk_stop(struct ifnet *ifp, int disable)
 
 	for (i = 0; i < MSK_TX_RING_CNT; i++) {
 		if (sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf != NULL) {
-			m_freem(sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf);
-			sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf = NULL;
+			dma = sc_if->sk_cdata.sk_tx_map[i];
+
+			bus_dmamap_sync(sc->sc_dmatag, dma->dmamap, 0,
+			dma->dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE);
+
+			bus_dmamap_unload(sc->sc_dmatag, dma->dmamap);
 #if 1
 			SIMPLEQ_INSERT_HEAD(_if->sk_txmap_head,
 			sc_if->sk_cdata.sk_tx_map[i], link);
 			sc_if->sk_cdata.sk_tx_map[i] = 0;
 #endif
+			m_freem(sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf);
+			sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf = NULL;
 		}
 	}
 



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:14:11 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #373


To generate a diff of this commit:
cvs rdiff -u -r1.1371.2.2 -r1.1371.2.3 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370.2.2 -r1.1370.2.3 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:14:11 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #373


To generate a diff of this commit:
cvs rdiff -u -r1.1371.2.2 -r1.1371.2.3 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370.2.2 -r1.1370.2.3 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffs are larger than 1MB and have been omitted


CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:12:42 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #373):

sys/dev/pci/pcidevs: revision 1.1386
sys/dev/pci/pcidevs: revision 1.1387

Modify Attansic Ethernet devices' description to clarify.
Add Killer E2400 and E2500.


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.2 -r1.1383.2.3 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 24 16:12:42 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #373):

sys/dev/pci/pcidevs: revision 1.1386
sys/dev/pci/pcidevs: revision 1.1387

Modify Attansic Ethernet devices' description to clarify.
Add Killer E2400 and E2500.


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.2 -r1.1383.2.3 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1383.2.2 src/sys/dev/pci/pcidevs:1.1383.2.3
--- src/sys/dev/pci/pcidevs:1.1383.2.2	Tue Sep 24 02:59:35 2019
+++ src/sys/dev/pci/pcidevs	Thu Oct 24 16:12:42 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1383.2.2 2019/09/24 02:59:35 martin Exp $
+$NetBSD: pcidevs,v 1.1383.2.3 2019/10/24 16:12:42 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1332,18 +1332,20 @@ product ASUSTEK HFCPCI		0x0675	ISDN
 /* Attansic Technology Corp. */
 product ATTANSIC ETHERNET_L1E	0x1026	L1E Gigabit Ethernet Adapter
 product ATTANSIC ETHERNET_GIGA	0x1048	L1 Gigabit Ethernet Adapter
-product ATTANSIC AR8132		0x1062	AR8132 Fast Ethernet Adapter
-product ATTANSIC AR8131		0x1063	AR8131 Gigabit Ethernet Adapter
-product ATTANSIC AR8151		0x1073	AR8151 v1.0 Gigabit Ethernet Adapter
-product ATTANSIC AR8151_V2	0x1083	AR8151 v2.0 Gigabit Ethernet Adapter
+product ATTANSIC AR8132		0x1062	AR8132 L2C Fast Ethernet Adapter
+product ATTANSIC AR8131		0x1063	AR8131 L1C Gigabit Ethernet Adapter
+product ATTANSIC AR8151		0x1073	AR8151 v1.0 L1D Gigabit Ethernet Adapter
+product ATTANSIC AR8151_V2	0x1083	AR8151 v2.0 L1D Gigabit Ethernet Adapter
 product ATTANSIC AR8162		0x1090	AR8162
 product ATTANSIC AR8161		0x1091	AR8161
 product ATTANSIC AR8172		0x10a0	AR8172
 product ATTANSIC AR8171		0x10a1	AR8171
 product ATTANSIC ETHERNET_100	0x2048	L2 100 Mbit Ethernet Adapter
-product ATTANSIC AR8152_B	0x2060	AR8152 v1.1 Fast Ethernet Adapter
-product ATTANSIC AR8152_B2	0x2062	AR8152 v2.0 Fast Ethernet Adapter
-product ATTANSIC E2200		0xe091	E2200
+product ATTANSIC AR8152_B	0x2060	AR8152 v1.1 L2C Fast Ethernet Adapter
+product ATTANSIC AR8152_B2	0x2062	AR8152 v2.0 L2C Fast Ethernet Adapter
+product ATTANSIC E2200		0xe091	Killer E2200
+product ATTANSIC E2400		0xe0a1	Killer E2400
+product ATTANSIC E2500		0xe0b1	Killer E2500
 
 /* ATI products */
 /* See http://www.x.org/wiki/Radeon%20ASICs */



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 19:38:52 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_bce.c if_bcereg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #370):

sys/dev/pci/if_bce.c: revision 1.55
sys/dev/pci/if_bce.c: revision 1.56
sys/dev/pci/if_bcereg.h: revision 1.5

- Add missing splnet()/splx() around mii_tick(). Same as OpenBSD rev. 1.23
- Use device_printf() instead of aprint_error_dev)() in bce_watchdog().
- Remove unnecessary inclusion.

>From OpenBSD:
 - Mark ETHERCAP_VLAN_MTU.
 - Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
 - Set proper LED modes.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.52.2.1 src/sys/dev/pci/if_bce.c
cvs rdiff -u -r1.4 -r1.4.170.1 src/sys/dev/pci/if_bcereg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 19:38:52 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_bce.c if_bcereg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #370):

sys/dev/pci/if_bce.c: revision 1.55
sys/dev/pci/if_bce.c: revision 1.56
sys/dev/pci/if_bcereg.h: revision 1.5

- Add missing splnet()/splx() around mii_tick(). Same as OpenBSD rev. 1.23
- Use device_printf() instead of aprint_error_dev)() in bce_watchdog().
- Remove unnecessary inclusion.

>From OpenBSD:
 - Mark ETHERCAP_VLAN_MTU.
 - Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
 - Set proper LED modes.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.52.2.1 src/sys/dev/pci/if_bce.c
cvs rdiff -u -r1.4 -r1.4.170.1 src/sys/dev/pci/if_bcereg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bce.c
diff -u src/sys/dev/pci/if_bce.c:1.52 src/sys/dev/pci/if_bce.c:1.52.2.1
--- src/sys/dev/pci/if_bce.c:1.52	Thu May 30 02:32:18 2019
+++ src/sys/dev/pci/if_bce.c	Wed Oct 23 19:38:52 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bce.c,v 1.52 2019/05/30 02:32:18 msaitoh Exp $	 */
+/* $NetBSD: if_bce.c,v 1.52.2.1 2019/10/23 19:38:52 martin Exp $	 */
 
 /*
  * Copyright (c) 2003 Clifford Wright. All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.52 2019/05/30 02:32:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.52.2.1 2019/10/23 19:38:52 martin Exp $");
 
 #include "vlan.h"
 
@@ -63,8 +63,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1
 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 
@@ -423,6 +421,8 @@ bce_attach(device_t parent, device_t sel
 	ifp->if_stop = bce_stop;
 	IFQ_SET_READY(>if_snd);
 
+	sc->ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
+
 	/* Initialize our media structures and probe the MII. */
 
 	mii->mii_ifp = ifp;
@@ -653,7 +653,7 @@ bce_watchdog(struct ifnet *ifp)
 {
 	struct bce_softc *sc = ifp->if_softc;
 
-	aprint_error_dev(sc->bce_dev, "device timeout\n");
+	device_printf(sc->bce_dev, "device timeout\n");
 	ifp->if_oerrors++;
 
 	(void) bce_init(ifp);
@@ -920,10 +920,15 @@ bce_init(struct ifnet *ifp)
 	sc->bce_txsnext = 0;
 	sc->bce_txin = 0;
 
-	/* enable crc32 generation */
+	/* enable crc32 generation and set proper LED modes */
 	bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_MACCTL,
 	bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_MACCTL) |
-	BCE_EMC_CG);
+	BCE_EMC_CRC32_ENAB | BCE_EMC_LED);
+
+	/* reset or clear powerdown control bit  */
+	bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_MACCTL,
+	bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_MACCTL) &
+	~BCE_EMC_PDOWN);
 
 	/* setup DMA interrupt control */
 	bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_DMAI_CTL, 1 << 24);	/* MAGIC */
@@ -1476,9 +1481,11 @@ static void
 bce_tick(void *v)
 {
 	struct bce_softc *sc = v;
+	int s;
 
-	/* Tick the MII. */
+	s = splnet();
 	mii_tick(>bce_mii);
+	splx(s);
 
 	callout_reset(>bce_timeout, hz, bce_tick, sc);
 }

Index: src/sys/dev/pci/if_bcereg.h
diff -u src/sys/dev/pci/if_bcereg.h:1.4 src/sys/dev/pci/if_bcereg.h:1.4.170.1
--- src/sys/dev/pci/if_bcereg.h:1.4	Sun Dec 11 12:22:49 2005
+++ src/sys/dev/pci/if_bcereg.h	Wed Oct 23 19:38:52 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bcereg.h,v 1.4 2005/12/11 12:22:49 christos Exp $	 */
+/* $NetBSD: if_bcereg.h,v 1.4.170.1 2019/10/23 19:38:52 martin Exp $	 */
 
 /*
  * Copyright (c) 2003 Clifford Wright. All rights reserved.
@@ -71,7 +71,10 @@
 /* Ethernet MAC Control */
 #define BCE_MACCTL			0x00A8	/* ethernet mac control */
 /* mac control bits */
-#define BCE_EMC_CG			0x0001	/* crc32 generation */
+#define BCE_EMC_CRC32_ENAB		0x0001	/* crc32 generation */
+#define BCE_EMC_PDOWN			0x0004	/* PHY powerdown */
+#define BCE_EMC_EDET			0x0008	/* PHY energy detect */
+#define BCE_EMC_LED			0x00e0	/* PHY LED control */
 
 /* DMA Interrupt control */
 #define BCE_DMAI_CTL			0x0100



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 18:09:18 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: ahcisata_pci.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #358):

sys/dev/pci/ahcisata_pci.c: revision 1.56

ahcisata: make sure bus mastering and memory space are actually enabled
This makes the "ROCKPro64 PCI-e to Dual SATA-II Interface Card" work.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.4.1 src/sys/dev/pci/ahcisata_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 18:09:18 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: ahcisata_pci.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #358):

sys/dev/pci/ahcisata_pci.c: revision 1.56

ahcisata: make sure bus mastering and memory space are actually enabled
This makes the "ROCKPro64 PCI-e to Dual SATA-II Interface Card" work.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.4.1 src/sys/dev/pci/ahcisata_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ahcisata_pci.c
diff -u src/sys/dev/pci/ahcisata_pci.c:1.55 src/sys/dev/pci/ahcisata_pci.c:1.55.4.1
--- src/sys/dev/pci/ahcisata_pci.c:1.55	Sun Jan 27 02:08:42 2019
+++ src/sys/dev/pci/ahcisata_pci.c	Wed Oct 23 18:09:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_pci.c,v 1.55 2019/01/27 02:08:42 pgoyette Exp $	*/
+/*	$NetBSD: ahcisata_pci.c,v 1.55.4.1 2019/10/23 18:09:18 martin Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.55 2019/01/27 02:08:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.55.4.1 2019/10/23 18:09:18 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ahcisata_pci.h"
@@ -394,6 +394,7 @@ ahci_pci_attach(device_t parent, device_
 	struct ahci_softc *sc = >ah_sc;
 	bool ahci_cap_64bit;
 	bool ahci_bad_64bit;
+	pcireg_t reg;
 
 	sc->sc_atac.atac_dev = self;
 
@@ -447,6 +448,10 @@ ahci_pci_attach(device_t parent, device_
 		AHCIDEBUG_PRINT(("%s: SATA mode\n", AHCINAME(sc)), DEBUG_PROBE);
 	}
 
+	reg = pci_conf_read(psc->sc_pc, psc->sc_pcitag, PCI_COMMAND_STATUS_REG);
+	reg |= (PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE);
+	pci_conf_write(psc->sc_pc, psc->sc_pcitag, PCI_COMMAND_STATUS_REG, reg);
+
 	ahci_attach(sc);
 
 	if (!pmf_device_register(self, NULL, ahci_pci_resume))



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-10-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 17 19:09:14 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #348):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.214

Apply FreeBSD r353599:
 > ixgbe: Disable EEE for backplane X550EM_X
 >
 > From Zach:
 > Intel documentation indicates that backplane X550EM_X KR devices do not
 > support Energy Efficient Ethernet. Prior to this patch, X552 devices
 > (device ID 0x15AB) will crash the system when transitioning EEE state
 > via sysctl.
 >
 > Signed-off-by: Zach Vargas 
 >
 > PR:  240320
 > Submitted by:Zach Vargas 
 > Reviewed by: erj@
 > MFC after:   3 days
 > Differential Revision:   https://reviews.freebsd.org/D21673


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.5 -r1.199.2.6 src/sys/dev/pci/ixgbe/ixgbe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-10-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 17 19:09:14 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #348):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.214

Apply FreeBSD r353599:
 > ixgbe: Disable EEE for backplane X550EM_X
 >
 > From Zach:
 > Intel documentation indicates that backplane X550EM_X KR devices do not
 > support Energy Efficient Ethernet. Prior to this patch, X552 devices
 > (device ID 0x15AB) will crash the system when transitioning EEE state
 > via sysctl.
 >
 > Signed-off-by: Zach Vargas 
 >
 > PR:  240320
 > Submitted by:Zach Vargas 
 > Reviewed by: erj@
 > MFC after:   3 days
 > Differential Revision:   https://reviews.freebsd.org/D21673


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.5 -r1.199.2.6 src/sys/dev/pci/ixgbe/ixgbe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.5 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.6
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.5	Thu Sep 26 19:07:22 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Oct 17 19:09:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.199.2.5 2019/09/26 19:07:22 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.199.2.6 2019/10/17 19:09:14 martin Exp $ */
 
 /**
 
@@ -5860,7 +5860,7 @@ ixgbe_sysctl_eee_state(SYSCTLFN_ARGS)
 	if ((new_eee < 0) || (new_eee > 1))
 		return (EINVAL);
 
-	retval = adapter->hw.mac.ops.setup_eee(>hw, new_eee);
+	retval = ixgbe_setup_eee(>hw, new_eee);
 	if (retval) {
 		device_printf(dev, "Error in EEE setup: 0x%08X\n", retval);
 		return (EINVAL);
@@ -6034,8 +6034,6 @@ ixgbe_init_device_features(struct adapte
 		 */
 		adapter->feat_cap |= IXGBE_FEATURE_SRIOV;
 		adapter->feat_cap |= IXGBE_FEATURE_FDIR;
-		if (adapter->hw.device_id == IXGBE_DEV_ID_X550EM_X_KR)
-			adapter->feat_cap |= IXGBE_FEATURE_EEE;
 		break;
 	case ixgbe_mac_X550EM_a:
 		/*



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 17 19:02:55 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_et.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #346):

sys/dev/pci/if_et.c: revision 1.27

Fix a bug that multicast address filter doesn't work correctly.
XXX pullup-[789].


To generate a diff of this commit:
cvs rdiff -u -r1.24.2.1 -r1.24.2.2 src/sys/dev/pci/if_et.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 17 19:02:55 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_et.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #346):

sys/dev/pci/if_et.c: revision 1.27

Fix a bug that multicast address filter doesn't work correctly.
XXX pullup-[789].


To generate a diff of this commit:
cvs rdiff -u -r1.24.2.1 -r1.24.2.2 src/sys/dev/pci/if_et.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_et.c
diff -u src/sys/dev/pci/if_et.c:1.24.2.1 src/sys/dev/pci/if_et.c:1.24.2.2
--- src/sys/dev/pci/if_et.c:1.24.2.1	Fri Aug  9 16:03:13 2019
+++ src/sys/dev/pci/if_et.c	Thu Oct 17 19:02:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_et.c,v 1.24.2.1 2019/08/09 16:03:13 martin Exp $	*/
+/*	$NetBSD: if_et.c,v 1.24.2.2 2019/10/17 19:02:54 martin Exp $	*/
 /*	$OpenBSD: if_et.c,v 1.12 2008/07/11 09:29:02 kevlo $	*/
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.24.2.1 2019/08/09 16:03:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.24.2.2 2019/10/17 19:02:54 martin Exp $");
 
 #include "opt_inet.h"
 #include "vlan.h"
@@ -1304,7 +1304,6 @@ et_setmulti(struct et_softc *sc)
 	uint32_t rxmac_ctrl, pktfilt;
 	struct ether_multi *enm;
 	struct ether_multistep step;
-	uint8_t addr[ETHER_ADDR_LEN];
 	int i, count;
 
 	pktfilt = CSR_READ_4(sc, ET_PKTFILT);
@@ -1316,19 +1315,13 @@ et_setmulti(struct et_softc *sc)
 		goto back;
 	}
 
-	bcopy(etherbroadcastaddr, addr, ETHER_ADDR_LEN);
-
 	count = 0;
 	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		uint32_t *hp, h;
 
-		for (i = 0; i < ETHER_ADDR_LEN; i++) {
-			addr[i] &= enm->enm_addrlo[i];
-		}
-
-		h = ether_crc32_be(addr, ETHER_ADDR_LEN);
+		h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
 		h = (h & 0x3f80) >> 23;
 
 		hp = [0];



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 17 18:58:33 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_vge.c if_vgereg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #345):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/dev/pci/if_vge.c
cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/dev/pci/if_vgereg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 17 18:58:33 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_vge.c if_vgereg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #345):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/dev/pci/if_vge.c
cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/dev/pci/if_vgereg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_vge.c
diff -u src/sys/dev/pci/if_vge.c:1.73 src/sys/dev/pci/if_vge.c:1.73.2.1
--- src/sys/dev/pci/if_vge.c:1.73	Tue Jul  9 08:46:59 2019
+++ src/sys/dev/pci/if_vge.c	Thu Oct 17 18:58:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.73 2019/07/09 08:46:59 msaitoh Exp $ */
+/* $NetBSD: if_vge.c,v 1.73.2.1 2019/10/17 18:58:33 martin Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.73 2019/07/09 08:46:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.73.2.1 2019/10/17 18:58:33 martin Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -328,6 +328,7 @@ static void vge_miibus_statchg(struct if
 
 static void vge_cam_clear(struct vge_softc *);
 static int vge_cam_set(struct vge_softc *, uint8_t *);
+static void	vge_clrwol(struct vge_softc *);
 static void vge_setmulti(struct vge_softc *);
 static void vge_reset(struct vge_softc *);
 
@@ -953,6 +954,9 @@ vge_attach(device_t parent, device_t sel
 	aprint_normal_dev(self, "Ethernet address %s\n",
 	ether_sprintf(eaddr));
 
+	/* Clear WOL and take hardware from powerdown. */
+	vge_clrwol(sc);
+
 	/*
 	 * Use the 32bit tag. Hardware supports 48bit physical addresses,
 	 * but we don't use that for now.
@@ -2156,3 +2160,30 @@ vge_shutdown(device_t self, int howto)
 
 	return true;
 }
+
+static void
+vge_clrwol(struct vge_softc *sc)
+{
+	uint8_t val;
+
+	val = CSR_READ_1(sc, VGE_PWRSTAT);
+	val &= ~VGE_STICKHW_SWPTAG;
+	CSR_WRITE_1(sc, VGE_PWRSTAT, val);
+	/* Disable WOL and clear power state indicator. */
+	val = CSR_READ_1(sc, VGE_PWRSTAT);
+	val &= ~(VGE_STICKHW_DS0 | VGE_STICKHW_DS1);
+	CSR_WRITE_1(sc, VGE_PWRSTAT, val);
+
+	CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_GMII);
+	CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE);
+
+	/* Clear WOL on pattern match. */
+	CSR_WRITE_1(sc, VGE_WOLCR0C, VGE_WOLCR0_PATTERN_ALL);
+	/* Disable WOL on magic/unicast packet. */
+	CSR_WRITE_1(sc, VGE_WOLCR1C, 0x0F);
+	CSR_WRITE_1(sc, VGE_WOLCFGC, VGE_WOLCFG_SAB | VGE_WOLCFG_SAM |
+	VGE_WOLCFG_PMEOVR);
+	/* Clear WOL status on pattern match. */
+	CSR_WRITE_1(sc, VGE_WOLSR0C, 0xFF);
+	CSR_WRITE_1(sc, VGE_WOLSR1C, 0xFF);
+}

Index: src/sys/dev/pci/if_vgereg.h
diff -u src/sys/dev/pci/if_vgereg.h:1.4 src/sys/dev/pci/if_vgereg.h:1.4.2.1
--- src/sys/dev/pci/if_vgereg.h:1.4	Thu Jul 11 03:49:51 2019
+++ src/sys/dev/pci/if_vgereg.h	Thu Oct 17 18:58:33 2019
@@ -540,6 +540,31 @@
 #define VGE_TXBLOCK_128PKTS	0x08
 #define VGE_TXBLOCK_8PKTS	0x0C
 
+/* Sticky bit shadow register */
+
+#define	VGE_STICKHW_DS0		0x01
+#define	VGE_STICKHW_DS1		0x02
+#define	VGE_STICKHW_WOL_ENB	0x04
+#define	VGE_STICKHW_WOL_STS	0x08
+#define	VGE_STICKHW_SWPTAG	0x10
+
+/* WOL pattern control */
+#define	VGE_WOLCR0_PATTERN0	0x01
+#define	VGE_WOLCR0_PATTERN1	0x02
+#define	VGE_WOLCR0_PATTERN2	0x04
+#define	VGE_WOLCR0_PATTERN3	0x08
+#define	VGE_WOLCR0_PATTERN4	0x10
+#define	VGE_WOLCR0_PATTERN5	0x20
+#define	VGE_WOLCR0_PATTERN6	0x40
+#define	VGE_WOLCR0_PATTERN7	0x80
+#define	VGE_WOLCR0_PATTERN_ALL	0xFF
+
+/* WOL config register */
+#define	VGE_WOLCFG_PHYINT_ENB	0x01
+#define	VGE_WOLCFG_SAB		0x10
+#define	VGE_WOLCFG_SAM		0x20
+#define	VGE_WOLCFG_PMEOVR	0x80
+
 /* EEPROM control/status register */
 
 #define VGE_EECSR_EDO		0x01	/* data out pin */



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 15 19:33:24 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #331):

sys/dev/pci/pci.c: revision 1.155

The PCI Local Bus Specification says that we should probe devices by
reading PCI_ID_REG. pci_enumerate_bus was incorrectly reading PCI_BHLC_REG
first, which surprisingly has worked for the past 16 years. Unfortunately,
this undefined behavior does the wrong thing on Amazon's Annapurna Labs
PCIe host controller.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.4.1 src/sys/dev/pci/pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pci.c
diff -u src/sys/dev/pci/pci.c:1.154 src/sys/dev/pci/pci.c:1.154.4.1
--- src/sys/dev/pci/pci.c:1.154	Sat Dec 15 05:38:45 2018
+++ src/sys/dev/pci/pci.c	Tue Oct 15 19:33:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.c,v 1.154 2018/12/15 05:38:45 msaitoh Exp $	*/
+/*	$NetBSD: pci.c,v 1.154.4.1 2019/10/15 19:33:23 martin Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.154 2018/12/15 05:38:45 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.154.4.1 2019/10/15 19:33:23 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -723,10 +723,6 @@ pci_enumerate_bus(struct pci_softc *sc, 
 
 		tag = pci_make_tag(pc, sc->sc_bus, device, 0);
 
-		bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
-		if (PCI_HDRTYPE_TYPE(bhlcr) > 2)
-			continue;
-
 		id = pci_conf_read(pc, tag, PCI_ID_REG);
 
 		/* Invalid vendor ID value? */
@@ -736,6 +732,10 @@ pci_enumerate_bus(struct pci_softc *sc, 
 		if (PCI_VENDOR(id) == 0)
 			continue;
 
+		bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
+		if (PCI_HDRTYPE_TYPE(bhlcr) > 2)
+			continue;
+
 		qd = pci_lookup_quirkdata(PCI_VENDOR(id), PCI_PRODUCT(id));
 
 		if (qd != NULL &&



CVS commit: [netbsd-9] src/sys/dev/pci

2019-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 15 19:33:24 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #331):

sys/dev/pci/pci.c: revision 1.155

The PCI Local Bus Specification says that we should probe devices by
reading PCI_ID_REG. pci_enumerate_bus was incorrectly reading PCI_BHLC_REG
first, which surprisingly has worked for the past 16 years. Unfortunately,
this undefined behavior does the wrong thing on Amazon's Annapurna Labs
PCIe host controller.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.4.1 src/sys/dev/pci/pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 17:05:16 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #293):

sys/dev/pci/ixgbe/ixv.c: revision 1.139

Set MTU correctly if mtu > 1500.


To generate a diff of this commit:
cvs rdiff -u -r1.125.2.4 -r1.125.2.5 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.125.2.4 src/sys/dev/pci/ixgbe/ixv.c:1.125.2.5
--- src/sys/dev/pci/ixgbe/ixv.c:1.125.2.4	Thu Sep 26 19:07:22 2019
+++ src/sys/dev/pci/ixgbe/ixv.c	Tue Oct  8 17:05:16 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.125.2.4 2019/09/26 19:07:22 martin Exp $*/
+/*$NetBSD: ixv.c,v 1.125.2.5 2019/10/08 17:05:16 martin Exp $*/
 
 /**
 
@@ -716,6 +716,9 @@ ixv_init_locked(struct adapter *adapter)
 	for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++)
 		que->disabled_count = 0;
 
+	adapter->max_frame_size =
+	ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
 	/* reprogram the RAR[0] in case user changed it. */
 	hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 
@@ -748,10 +751,10 @@ ixv_init_locked(struct adapter *adapter)
 	 * Determine the correct mbuf pool
 	 * for doing jumbo/headersplit
 	 */
-	if (ifp->if_mtu > ETHERMTU)
-		adapter->rx_mbuf_sz = MJUMPAGESIZE;
-	else
+	if (adapter->max_frame_size <= MCLBYTES)
 		adapter->rx_mbuf_sz = MCLBYTES;
+	else
+		adapter->rx_mbuf_sz = MJUMPAGESIZE;
 
 	/* Prepare receive descriptors and buffers */
 	if (ixgbe_setup_receive_structures(adapter)) {



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 17:05:16 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #293):

sys/dev/pci/ixgbe/ixv.c: revision 1.139

Set MTU correctly if mtu > 1500.


To generate a diff of this commit:
cvs rdiff -u -r1.125.2.4 -r1.125.2.5 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 29 07:26:23 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #266):

sys/dev/pci/if_mcx.c: revision 1.3
sys/dev/pci/if_mcx.c: revision 1.4

mcx(4): fix rx mbuf DMA overrun
pullup-9

 -

len -> m_len


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 29 07:26:23 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #266):

sys/dev/pci/if_mcx.c: revision 1.3
sys/dev/pci/if_mcx.c: revision 1.4

mcx(4): fix rx mbuf DMA overrun
pullup-9

 -

len -> m_len


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.1.2.3 src/sys/dev/pci/if_mcx.c:1.1.2.4
--- src/sys/dev/pci/if_mcx.c:1.1.2.3	Thu Sep 26 19:09:57 2019
+++ src/sys/dev/pci/if_mcx.c	Sun Sep 29 07:26:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.1.2.3 2019/09/26 19:09:57 martin Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.1.2.4 2019/09/29 07:26:23 martin Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -5620,15 +5620,16 @@ mcx_rx_fill_slots(struct mcx_softc *sc, 
 #endif
 
 		m->m_data += ETHER_ALIGN;
-		m->m_len = m->m_pkthdr.len = bufsize;
+		m->m_len = m->m_pkthdr.len = m->m_ext.ext_size - ETHER_ALIGN;
 		if (bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m,
 		BUS_DMA_NOWAIT) != 0) {
 			m_freem(m);
 			break;
 		}
+		bus_dmamap_sync(sc->sc_dmat, ms->ms_map, 0, ms->ms_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 		ms->ms_m = m;
 
-		rqe[slot].rqe_byte_count = htobe32(bufsize);
+		rqe[slot].rqe_byte_count = htobe32(m->m_len);
 		rqe[slot].rqe_addr = htobe64(ms->ms_map->dm_segs[0].ds_addr);
 		rqe[slot].rqe_lkey = htobe32(sc->sc_lkey);
 



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:09:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #247):

sys/dev/pci/if_mcx.c: revision 1.2

Use IFM_50G_SR2.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:09:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #247):

sys/dev/pci/if_mcx.c: revision 1.2

Use IFM_50G_SR2.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.1.2.2 src/sys/dev/pci/if_mcx.c:1.1.2.3
--- src/sys/dev/pci/if_mcx.c:1.1.2.2	Mon Sep 23 07:04:40 2019
+++ src/sys/dev/pci/if_mcx.c	Thu Sep 26 19:09:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.1.2.2 2019/09/23 07:04:40 martin Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.1.2.3 2019/09/26 19:09:57 martin Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -2159,7 +2159,7 @@ static const uint64_t mcx_eth_cap_map[] 
 	IFM_40G_SR4,
 	IFM_40G_LR4,
 	0,
-	0, /* IFM_50G_SR2 */
+	IFM_50G_SR2,
 	0,
 	IFM_100G_CR4,
 	IFM_100G_SR4,



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 18:52:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci_subr.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #243):

sys/dev/pci/pci_subr.c: revision 1.216
sys/dev/pci/pci_subr.c: revision 1.217

Whitespace fixes. No functional change.

 -

Print some DPC register values not with %04x but with %08x because those
are 32bit.


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.215.2.1 src/sys/dev/pci/pci_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.215 src/sys/dev/pci/pci_subr.c:1.215.2.1
--- src/sys/dev/pci/pci_subr.c:1.215	Thu Jul 18 07:49:26 2019
+++ src/sys/dev/pci/pci_subr.c	Thu Sep 26 18:52:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.215 2019/07/18 07:49:26 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.215.2.1 2019/09/26 18:52:57 martin Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.215 2019/07/18 07:49:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.215.2.1 2019/09/26 18:52:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -209,7 +209,7 @@ static const struct pci_class pci_subcla
 
 /* PCI bridge programming interface */
 static const struct pci_class pci_interface_pcibridge[] = {
-	{ "",			PCI_INTERFACE_BRIDGE_PCI_PCI, NULL,	},
+	{ "",			PCI_INTERFACE_BRIDGE_PCI_PCI,	NULL,	},
 	{ "subtractive decode",	PCI_INTERFACE_BRIDGE_PCI_SUBDEC, NULL,	},
 	{ NULL,			0,NULL,	},
 };
@@ -223,8 +223,8 @@ static const struct pci_class pci_interf
 
 /* Advanced Switching programming interface */
 static const struct pci_class pci_interface_advsw[] = {
-	{ "custom interface",	PCI_INTERFACE_ADVSW_CUSTOM, NULL, },
-	{ "ASI-SIG",		PCI_INTERFACE_ADVSW_ASISIG, NULL, },
+	{ "custom interface",	PCI_INTERFACE_ADVSW_CUSTOM,	NULL, },
+	{ "ASI-SIG",		PCI_INTERFACE_ADVSW_ASISIG,	NULL, },
 	{ NULL,			0,NULL,	},
 };
 
@@ -304,7 +304,7 @@ static const struct pci_class pci_subcla
 /*
  * Class 0x08.
  * Base system peripheral.
- */ 
+ */
 
 /* PIC programming interface */
 static const struct pci_class pci_interface_pic[] = {
@@ -429,10 +429,10 @@ static const struct pci_class pci_interf
 
 /* IPMI programming interface */
 static const struct pci_class pci_interface_ipmi[] = {
-	{ "SMIC",		PCI_INTERFACE_IPMI_SMIC,		NULL,},
-	{ "keyboard",		PCI_INTERFACE_IPMI_KBD,			NULL,},
-	{ "block transfer",	PCI_INTERFACE_IPMI_BLOCKXFER,		NULL,},
-	{ NULL,			0,	NULL,},
+	{ "SMIC",		PCI_INTERFACE_IPMI_SMIC,	NULL,	},
+	{ "keyboard",		PCI_INTERFACE_IPMI_KBD,		NULL,	},
+	{ "block transfer",	PCI_INTERFACE_IPMI_BLOCKXFER,	NULL,	},
+	{ NULL,			0,NULL,	},
 };
 
 /* Subclasses */
@@ -478,8 +478,8 @@ static const struct pci_class pci_subcla
 
 /* Intelligent IO programming interface */
 static const struct pci_class pci_interface_i2o[] = {
-	{ "FIFO at offset 0x40", PCI_INTERFACE_I2O_FIFOAT40,		NULL,},
-	{ NULL,			0,	NULL,},
+	{ "FIFO at offset 0x40", PCI_INTERFACE_I2O_FIFOAT40,	NULL,	},
+	{ NULL,			0,NULL,	},
 };
 
 /* Subclasses */
@@ -494,9 +494,9 @@ static const struct pci_class pci_subcla
  * Satellite communication controller.
  */
 static const struct pci_class pci_subclass_satcom[] = {
-	{ "TV",			PCI_SUBCLASS_SATCOM_TV,	 	NULL,	},
-	{ "audio",		PCI_SUBCLASS_SATCOM_AUDIO, 	NULL,	},
-	{ "voice",		PCI_SUBCLASS_SATCOM_VOICE, 	NULL,	},
+	{ "TV",			PCI_SUBCLASS_SATCOM_TV,		NULL,	},
+	{ "audio",		PCI_SUBCLASS_SATCOM_AUDIO,	NULL,	},
+	{ "voice",		PCI_SUBCLASS_SATCOM_VOICE,	NULL,	},
 	{ "data",		PCI_SUBCLASS_SATCOM_DATA,	NULL,	},
 	{ "miscellaneous",	PCI_SUBCLASS_SATCOM_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
@@ -507,9 +507,9 @@ static const struct pci_class pci_subcla
  * Encryption/Decryption controller.
  */
 static const struct pci_class pci_subclass_crypto[] = {
-	{ "network/computing",	PCI_SUBCLASS_CRYPTO_NETCOMP, 	NULL,	},
+	{ "network/computing",	PCI_SUBCLASS_CRYPTO_NETCOMP,	NULL,	},
 	{ "entertainment",	PCI_SUBCLASS_CRYPTO_ENTERTAINMENT, NULL,},
-	{ "miscellaneous",	PCI_SUBCLASS_CRYPTO_MISC, 	NULL,	},
+	{ "miscellaneous",	PCI_SUBCLASS_CRYPTO_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
 
@@ -585,7 +585,7 @@ DEV_VERBOSE_DEFINE(pci);
  * a positive value if the dest buffer would have overflowed.
  */
 
-static int __printflike(3,4)
+static int __printflike(3, 4)
 snappendf(char **dest, size_t *len, const char * restrict fmt, ...)
 {
 	va_list	ap;
@@ -609,7 +609,7 @@ snappendf(char **dest, size_t *len, cons
 	/* Update dest & len to point at trailing NUL */
 	*dest += count;
 	*len -= count;
-		
+
 	return 0;
 }
 
@@ -1285,7 +1285,7 @@ pci_conf_print_pcix_cap_2ndbusmode(int n
 		printf("PCI-X 266 (Mode 2)\n");
 	else
 		printf("PCI-X 533 (Mode 2)\n");
-	
+
 	printf("  

CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 18:52:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci_subr.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #243):

sys/dev/pci/pci_subr.c: revision 1.216
sys/dev/pci/pci_subr.c: revision 1.217

Whitespace fixes. No functional change.

 -

Print some DPC register values not with %04x but with %08x because those
are 32bit.


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.215.2.1 src/sys/dev/pci/pci_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 24 03:02:05 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
regen for ticket #237 (Mellanox device IDs added)


To generate a diff of this commit:
cvs rdiff -u -r1.1371.2.1 -r1.1371.2.2 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370.2.1 -r1.1370.2.2 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 24 02:59:35 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #237):

sys/dev/pci/pcidevs: revision 1.1385

Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.1 -r1.1383.2.2 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1383.2.1 src/sys/dev/pci/pcidevs:1.1383.2.2
--- src/sys/dev/pci/pcidevs:1.1383.2.1	Mon Aug 26 13:58:19 2019
+++ src/sys/dev/pci/pcidevs	Tue Sep 24 02:59:35 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1383.2.1 2019/08/26 13:58:19 martin Exp $
+$NetBSD: pcidevs,v 1.1383.2.2 2019/09/24 02:59:35 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -5869,6 +5869,10 @@ product MATROX G550_AGP		0x2527	MGA G550
 product MEDIAQ MQ200		0x0200	MQ200
 
 /* Mellanox Technologies */
+product MELLANOX MT27700	0x1013	ConnectX-4
+product MELLANOX MT27710	0x1015	ConnectX-4 Lx
+product MELLANOX MT27800	0x1017	ConnectX-5
+product MELLANOX MT28800	0x1019	ConnectX-5 Ex
 product MELLANOX MT23108	0x5a44	InfiniHost (Tavor)
 product MELLANOX MT23108_PCI	0x5a46	InfiniHost PCI Bridge (Tavor)
 product MELLANOX MT25204_OLD	0x5e8c	InfiniHost III Lx (old Sinai)



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 24 02:59:35 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #237):

sys/dev/pci/pcidevs: revision 1.1385

Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.1 -r1.1383.2.2 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:15:28 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #216):

sys/dev/pci/if_age.c: revision 1.61

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.2.1 src/sys/dev/pci/if_age.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_age.c
diff -u src/sys/dev/pci/if_age.c:1.60 src/sys/dev/pci/if_age.c:1.60.2.1
--- src/sys/dev/pci/if_age.c:1.60	Tue Jul  9 08:46:58 2019
+++ src/sys/dev/pci/if_age.c	Sun Sep 22 12:15:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_age.c,v 1.60 2019/07/09 08:46:58 msaitoh Exp $ */
+/*	$NetBSD: if_age.c,v 1.60.2.1 2019/09/22 12:15:28 martin Exp $ */
 /*	$OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $	*/
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60 2019/07/09 08:46:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.1 2019/09/22 12:15:28 martin Exp $");
 
 #include "vlan.h"
 
@@ -575,7 +575,7 @@ age_get_macaddr(struct age_softc *sc, ui
 		 */
 		CSR_WRITE_4(sc, AGE_TWSI_CTRL, CSR_READ_4(sc, AGE_TWSI_CTRL) |
 		TWSI_CTRL_SW_LD_START);
-		for (i = 100; i > 0; i++) {
+		for (i = 100; i > 0; i--) {
 			DELAY(1000);
 			reg = CSR_READ_4(sc, AGE_TWSI_CTRL);
 			if ((reg & TWSI_CTRL_SW_LD_START) == 0)



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:15:28 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #216):

sys/dev/pci/if_age.c: revision 1.61

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.2.1 src/sys/dev/pci/if_age.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-09-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  5 09:11:03 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ix_txrx.c ixgbe.c ixgbe_netbsd.c
ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #180):

sys/dev/pci/ixgbe/ixv.c: revision 1.130
sys/dev/pci/ixgbe/ixgbe.c: revision 1.207
sys/dev/pci/ixgbe/ixgbe.c: revision 1.208
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.55
sys/dev/pci/ixgbe/ixv.c: revision 1.129
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.10

 printf -> device_printf

 Set IFM_1000_BX10 correctly.

 Use aprint_*() in the attach function.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.2.1 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.199.2.3 -r1.199.2.4 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
cvs rdiff -u -r1.125.2.2 -r1.125.2.3 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-09-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  5 09:11:03 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ix_txrx.c ixgbe.c ixgbe_netbsd.c
ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #180):

sys/dev/pci/ixgbe/ixv.c: revision 1.130
sys/dev/pci/ixgbe/ixgbe.c: revision 1.207
sys/dev/pci/ixgbe/ixgbe.c: revision 1.208
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.55
sys/dev/pci/ixgbe/ixv.c: revision 1.129
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.10

 printf -> device_printf

 Set IFM_1000_BX10 correctly.

 Use aprint_*() in the attach function.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.2.1 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.199.2.3 -r1.199.2.4 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
cvs rdiff -u -r1.125.2.2 -r1.125.2.3 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.54 src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.1
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.54	Thu Jul  4 08:56:35 2019
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Thu Sep  5 09:11:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.54 2019/07/04 08:56:35 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.54.2.1 2019/09/05 09:11:03 martin Exp $ */
 
 /**
 
@@ -1363,7 +1363,9 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr,
 			error = bus_dmamap_load_mbuf(rxr->ptag->dt_dmat,
 			rxbuf->pmap, mp, BUS_DMA_NOWAIT);
 			if (error != 0) {
-printf("Refresh mbufs: payload dmamap load failure - %d\n", error);
+device_printf(adapter->dev, "Refresh mbufs: "
+"payload dmamap load failure - %d\n",
+error);
 m_free(mp);
 rxbuf->buf = NULL;
 goto update;

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.3 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.4
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.3	Sun Sep  1 13:08:12 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Sep  5 09:11:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.199.2.3 2019/09/01 13:08:12 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.199.2.4 2019/09/05 09:11:03 martin Exp $ */
 
 /**
 
@@ -1403,7 +1403,6 @@ static void
 ixgbe_add_media_types(struct adapter *adapter)
 {
 	struct ixgbe_hw *hw = >hw;
-	device_t	dev = adapter->dev;
 	u64		layer;
 
 	layer = adapter->phy_layer;
@@ -1469,7 +1468,7 @@ ixgbe_add_media_types(struct adapter *ad
 		ADD(IFM_5000_T | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_BX)
-		device_printf(dev, "Media supported: 1000baseBX\n");
+		ADD(IFM_1000_BX10 | IFM_FDX, 0);
 	/* XXX no ifmedia_set? */
 
 	ADD(IFM_AUTO, 0);
@@ -3306,7 +3305,8 @@ ixgbe_sysctl_instance(struct adapter *ad
 
 	return rnode;
 err:
-	printf("%s: sysctl_createv failed, rc = %d\n", __func__, rc);
+	device_printf(adapter->dev,
+	"%s: sysctl_createv failed, rc = %d\n", __func__, rc);
 	return NULL;
 }
 

Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.9 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.9.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.9	Thu Dec  6 13:25:02 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c	Thu Sep  5 09:11:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_netbsd.c,v 1.9 2018/12/06 13:25:02 msaitoh Exp $ */
+/* $NetBSD: ixgbe_netbsd.c,v 1.9.4.1 2019/09/05 09:11:03 martin Exp $ */
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -197,7 +197,8 @@ ixgbe_jcl_reinit(struct adapter *adapter
 
 	for (i = 0; i < nbuf; i++) {
 		if ((em = ixgbe_newext(eh, dmat, size)) == NULL) {
-			printf("%s: only %d of %d jumbo buffers allocated\n",
+			device_printf(adapter->dev,
+			"%s: only %d of %d jumbo buffers allocated\n",
 			__func__, i, nbuf);
 			break;
 		}

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.125.2.2 src/sys/dev/pci/ixgbe/ixv.c:1.125.2.3
--- src/sys/dev/pci/ixgbe/ixv.c:1.125.2.2	Sun Sep  1 11:12:45 2019
+++ src/sys/dev/pci/ixgbe/ixv.c	Thu Sep  5 09:11:03 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.125.2.2 2019/09/01 11:12:45 martin Exp $*/
+/*$NetBSD: ixv.c,v 1.125.2.3 2019/09/05 09:11:03 martin Exp $*/
 
 /**
 
@@ -516,7 +516,7 @@ ixv_attach(device_t parent, device_t dev
 
 	error = ixv_allocate_msix(adapter, pa);
 	if (error) {
-		device_printf(dev, "ixv_allocate_msix() failed!\n");
+		aprint_error_dev(dev, "ixv_allocate_msix() failed!\n");
 		goto err_late;
 	}
 
@@ -2406,7 +2406,8 @@ ixv_sysctl_instance(struct adapter *adap
 
 	return rnode;
 err:
-	printf("%s: sysctl_createv failed, rc = %d\n", __func__, 

CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 13:08:13 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #136):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.205
sys/dev/pci/ixgbe/ixgbe.c: revision 1.206

fix typo in error handling of ixgbe_allocate_legacy().
ok by msaitoh@n.o

pullup-8, pullup-9

 -

Fix panic when ncpu == 1 && sysctl -w hw.ixg0.txrx_workqueue=1. Reported by 
nonaka@n.o.

ok by msaitoh@n.o and nonaka@n.o

pullup-8, pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.2 -r1.199.2.3 src/sys/dev/pci/ixgbe/ixgbe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.2 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.3
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.2	Sun Sep  1 11:12:45 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sun Sep  1 13:08:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.199.2.2 2019/09/01 11:12:45 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.199.2.3 2019/09/01 13:08:12 martin Exp $ */
 
 /**
 
@@ -6467,7 +6467,9 @@ ixgbe_allocate_legacy(struct adapter *ad
 	int		counts[PCI_INTR_TYPE_SIZE];
 	pci_intr_type_t intr_type, max_type;
 	char		intrbuf[PCI_INTRSTR_LEN];
+	char		wqname[MAXCOMLEN];
 	const char	*intrstr = NULL;
+	int defertx_error = 0, error;
 
 	/* We allocate a single interrupt resource */
 	max_type = PCI_INTR_TYPE_MSI;
@@ -6529,15 +6531,27 @@ alloc_retry:
 	 * Try allocating a fast interrupt and the associated deferred
 	 * processing contexts.
 	 */
-	if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX))
+	if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) {
 		txr->txr_si =
 		softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
 			ixgbe_deferred_mq_start, txr);
+
+		snprintf(wqname, sizeof(wqname), "%sdeferTx", device_xname(dev));
+		defertx_error = workqueue_create(>txr_wq, wqname,
+		ixgbe_deferred_mq_start_work, adapter, IXGBE_WORKQUEUE_PRI,
+		IPL_NET, IXGBE_WORKQUEUE_FLAGS);
+		adapter->txr_wq_enqueued = percpu_alloc(sizeof(u_int));
+	}
 	que->que_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
 	ixgbe_handle_que, que);
+	snprintf(wqname, sizeof(wqname), "%sTxRx", device_xname(dev));
+	error = workqueue_create(>que_wq, wqname,
+	ixgbe_handle_que_work, adapter, IXGBE_WORKQUEUE_PRI, IPL_NET,
+	IXGBE_WORKQUEUE_FLAGS);
 
 	if ((!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)
-		& (txr->txr_si == NULL)) || (que->que_si == NULL)) {
+		&& ((txr->txr_si == NULL) || defertx_error != 0))
+	|| (que->que_si == NULL) || error != 0) {
 		aprint_error_dev(dev,
 		"could not establish software interrupts\n");
 



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 13:08:13 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #136):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.205
sys/dev/pci/ixgbe/ixgbe.c: revision 1.206

fix typo in error handling of ixgbe_allocate_legacy().
ok by msaitoh@n.o

pullup-8, pullup-9

 -

Fix panic when ncpu == 1 && sysctl -w hw.ixg0.txrx_workqueue=1. Reported by 
nonaka@n.o.

ok by msaitoh@n.o and nonaka@n.o

pullup-8, pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.2 -r1.199.2.3 src/sys/dev/pci/ixgbe/ixgbe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 11:12:45 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #134):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.202
sys/dev/pci/ixgbe/ixgbe.c: revision 1.203
sys/dev/pci/ixgbe/ixgbe.c: revision 1.204
sys/dev/pci/ixgbe/ixv.c: revision 1.128

Simplify ix{gbe,v}_[un]register_vlan() API suggested by knakahara.

 The API was the same as FreeBSD's pre-iflib's. They use iflib now and it's
not required for us to keep the old API.
X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.

 An interrupt might not arrive when a module is inserted. When an link status
change interrupt occurred and the driver still regard SFP as unplugged, link
becomes up and the real media type is unknown. e.g:

 % ifconfig -m ixg0
 (snip)
 media: Ethernet autoselect (autoselect rxpause,txpause)
 status: active
 supported Ethernet media:
 media none
 media autoselect
 (snip)

To resolve this problem, when an link status change interrupt occurred and the
driver still regard SFP as unplugged, issue the module softint before issuing
LSC interrupt.


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.1 -r1.199.2.2 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.125.2.1 -r1.125.2.2 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.1 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.2
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.1	Sun Sep  1 11:07:05 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sun Sep  1 11:12:45 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.199.2.1 2019/09/01 11:07:05 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.199.2.2 2019/09/01 11:12:45 martin Exp $ */
 
 /**
 
@@ -222,8 +222,8 @@ static void	ixgbe_eitr_write(struct adap
 static void	ixgbe_setup_vlan_hw_tagging(struct adapter *);
 static void	ixgbe_setup_vlan_hw_support(struct adapter *);
 static int	ixgbe_vlan_cb(struct ethercom *, uint16_t, bool);
-static int	ixgbe_register_vlan(void *, struct ifnet *, u16);
-static int	ixgbe_unregister_vlan(void *, struct ifnet *, u16);
+static int	ixgbe_register_vlan(struct adapter *, u16);
+static int	ixgbe_unregister_vlan(struct adapter *, u16);
 
 static void	ixgbe_add_device_sysctls(struct adapter *);
 static void	ixgbe_add_hw_stats(struct adapter *);
@@ -1489,6 +1489,8 @@ ixgbe_is_sfp(struct ixgbe_hw *hw)
 			return (TRUE);
 		return (FALSE);
 	case ixgbe_mac_82599EB:
+	case ixgbe_mac_X550EM_x:
+	case ixgbe_mac_X550EM_a:
 		switch (hw->mac.ops.get_media_type(hw)) {
 		case ixgbe_media_type_fiber:
 		case ixgbe_media_type_fiber_qsfp:
@@ -1496,11 +1498,6 @@ ixgbe_is_sfp(struct ixgbe_hw *hw)
 		default:
 			return (FALSE);
 		}
-	case ixgbe_mac_X550EM_x:
-	case ixgbe_mac_X550EM_a:
-		if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
-			return (TRUE);
-		return (FALSE);
 	default:
 		return (FALSE);
 	}
@@ -2310,9 +2307,9 @@ ixgbe_vlan_cb(struct ethercom *ec, uint1
 	int rv;
 
 	if (set)
-		rv = ixgbe_register_vlan(ifp->if_softc, ifp, vid);
+		rv = ixgbe_register_vlan(adapter, vid);
 	else
-		rv = ixgbe_unregister_vlan(ifp->if_softc, ifp, vid);
+		rv = ixgbe_unregister_vlan(adapter, vid);
 
 	if (rv != 0)
 		return rv;
@@ -2336,15 +2333,11 @@ ixgbe_vlan_cb(struct ethercom *ec, uint1
  *   VFTA, init will repopulate the real table.
  /
 static int
-ixgbe_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
+ixgbe_register_vlan(struct adapter *adapter, u16 vtag)
 {
-	struct adapter	*adapter = ifp->if_softc;
 	u16		index, bit;
 	int		error;
 
-	if (ifp->if_softc != arg)   /* Not our event */
-		return EINVAL;
-
 	if ((vtag == 0) || (vtag > 4095))	/* Invalid */
 		return EINVAL;
 
@@ -2367,15 +2360,11 @@ ixgbe_register_vlan(void *arg, struct if
  *   Run via vlan unconfig EVENT, remove our entry in the soft vfta.
  /
 static int
-ixgbe_unregister_vlan(void *arg, struct ifnet *ifp, u16 vtag)
+ixgbe_unregister_vlan(struct adapter *adapter, u16 vtag)
 {
-	struct adapter	*adapter = ifp->if_softc;
 	u16		index, bit;
 	int		error;
 
-	if (ifp->if_softc != arg)
-		return EINVAL;
-
 	if ((vtag == 0) || (vtag > 4095))	/* Invalid */
 		return EINVAL;
 
@@ -3124,6 +3113,34 @@ ixgbe_msix_link(void *arg)
 	/* Clear interrupt with write */
 	IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
 
+	if (ixgbe_is_sfp(hw)) {
+		/* Pluggable optics-related interrupt */
+		if (hw->mac.type >= ixgbe_mac_X540)
+			eicr_mask = IXGBE_EICR_GPI_SDP0_X540;
+		else
+			eicr_mask = IXGBE_EICR_GPI_SDP2_BY_MAC(hw);
+
+		

CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 11:12:45 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c ixv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #134):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.202
sys/dev/pci/ixgbe/ixgbe.c: revision 1.203
sys/dev/pci/ixgbe/ixgbe.c: revision 1.204
sys/dev/pci/ixgbe/ixv.c: revision 1.128

Simplify ix{gbe,v}_[un]register_vlan() API suggested by knakahara.

 The API was the same as FreeBSD's pre-iflib's. They use iflib now and it's
not required for us to keep the old API.
X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.

 An interrupt might not arrive when a module is inserted. When an link status
change interrupt occurred and the driver still regard SFP as unplugged, link
becomes up and the real media type is unknown. e.g:

 % ifconfig -m ixg0
 (snip)
 media: Ethernet autoselect (autoselect rxpause,txpause)
 status: active
 supported Ethernet media:
 media none
 media autoselect
 (snip)

To resolve this problem, when an link status change interrupt occurred and the
driver still regard SFP as unplugged, issue the module softint before issuing
LSC interrupt.


To generate a diff of this commit:
cvs rdiff -u -r1.199.2.1 -r1.199.2.2 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.125.2.1 -r1.125.2.2 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:59:47 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #112


To generate a diff of this commit:
cvs rdiff -u -r1.1371 -r1.1371.2.1 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370 -r1.1370.2.1 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:58:19 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by mrg in ticket #112):

sys/dev/pci/pcidevs: revision 1.1384

add micron/crucial SM2263 nvme.
add some device found on asus x570-p with ryzen 3200G cpu.
spell it "PCIe' when using the name.


To generate a diff of this commit:
cvs rdiff -u -r1.1383 -r1.1383.2.1 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:59:47 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #112


To generate a diff of this commit:
cvs rdiff -u -r1.1371 -r1.1371.2.1 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370 -r1.1370.2.1 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffs are larger than 1MB and have been omitted


CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:58:19 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by mrg in ticket #112):

sys/dev/pci/pcidevs: revision 1.1384

add micron/crucial SM2263 nvme.
add some device found on asus x570-p with ryzen 3200G cpu.
spell it "PCIe' when using the name.


To generate a diff of this commit:
cvs rdiff -u -r1.1383 -r1.1383.2.1 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1383 src/sys/dev/pci/pcidevs:1.1383.2.1
--- src/sys/dev/pci/pcidevs:1.1383	Sun Jul 28 15:20:22 2019
+++ src/sys/dev/pci/pcidevs	Mon Aug 26 13:58:19 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1383 2019/07/28 15:20:22 mlelstv Exp $
+$NetBSD: pcidevs,v 1.1383.2.1 2019/08/26 13:58:19 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -686,6 +686,7 @@ vendor ADP2		0x9005	Adaptec (2nd PCI Ven
 vendor ATRONICS		0x907f	Atronics
 vendor NETMOS		0x9710	Netmos
 vendor PARALLELS	0x	Parallels	
+vendor MICRON		0xc0a9	Micron/Crucial Technology
 vendor CHRYSALIS	0xcafe	Chrysalis-ITS
 vendor MIDDLE_DIGITAL	0xdeaf	Middle Digital
 vendor ARC		0xedd8	ARC Logic
@@ -963,10 +964,10 @@ product AMAZON NVME	0x8061	NVMe SSD
 product AMAZON ENA	0xec20	Elastic Network Adapter
 
 /* AMD products */
-product AMD AMD64_HT	0x1100	K8 AMD64 HyperTransport Configuration
-product AMD AMD64_ADDR	0x1101	K8 AMD64 Address Map Configuration
-product AMD AMD64_DRAM	0x1102	K8 AMD64 DRAM Configuration
-product AMD AMD64_MISC	0x1103	K8 AMD64 Miscellaneous Configuration
+product AMD AMD64_HT		0x1100	K8 AMD64 HyperTransport Configuration
+product AMD AMD64_ADDR		0x1101	K8 AMD64 Address Map Configuration
+product AMD AMD64_DRAM		0x1102	K8 AMD64 DRAM Configuration
+product AMD AMD64_MISC		0x1103	K8 AMD64 Miscellaneous Configuration
 product AMD AMD64_F10_HT	0x1200	AMD64 Family10h HyperTransport Configuration
 product AMD AMD64_F10_ADDR	0x1201	AMD64 Family10h Address Map Configuration
 product AMD AMD64_F10_DRAM	0x1202	AMD64 Family10h DRAM Configuration
@@ -977,140 +978,145 @@ product AMD AMD64_F11_ADDR	0x1301	AMD64 
 product AMD AMD64_F11_DRAM	0x1302	AMD64 Family11h DRAM Configuration
 product AMD AMD64_F11_MISC	0x1303	AMD64 Family11h Miscellaneous Configuration
 product AMD AMD64_F11_LINK	0x1304	AMD64 Family11h Link Configuration
-product AMD F15_10_PF_0	0x1400	Family15h Processor Function 0
-product AMD F15_10_PF_1	0x1401	Family15h Processor Function 1
-product AMD F15_10_PF_2	0x1402	Family15h Processor Function 2
-product AMD F15_10_PF_3	0x1403	Family15h Processor Function 3
-product AMD F15_10_PF_4	0x1404	Family15h Processor Function 4
-product AMD F15_10_PF_5	0x1405	Family15h Processor Function 5
-product AMD F15_10_RC	0x1410	Family15h Root Complex
-product AMD F15_10_RP_2	0x1412	Family15h Root Port
-product AMD F15_10_RP_3	0x1413	Family15h Root Port
-product AMD F15_10_RP_4	0x1414	Family15h Root Port
-product AMD F15_10_RP_5	0x1415	Family15h Root Port
-product AMD F15_10_RP_6	0x1416	Family15h Root Port
-product AMD F15_10_RP_7	0x1417	Family15h Root Port
-product AMD F15_10_RP_8	0x1418	Family15h Root Port
+product AMD F15_10_PF_0		0x1400	Family15h Processor Function 0
+product AMD F15_10_PF_1		0x1401	Family15h Processor Function 1
+product AMD F15_10_PF_2		0x1402	Family15h Processor Function 2
+product AMD F15_10_PF_3		0x1403	Family15h Processor Function 3
+product AMD F15_10_PF_4		0x1404	Family15h Processor Function 4
+product AMD F15_10_PF_5		0x1405	Family15h Processor Function 5
+product AMD F15_10_RC		0x1410	Family15h Root Complex
+product AMD F15_10_RP_2		0x1412	Family15h Root Port
+product AMD F15_10_RP_3		0x1413	Family15h Root Port
+product AMD F15_10_RP_4		0x1414	Family15h Root Port
+product AMD F15_10_RP_5		0x1415	Family15h Root Port
+product AMD F15_10_RP_6		0x1416	Family15h Root Port
+product AMD F15_10_RP_7		0x1417	Family15h Root Port
+product AMD F15_10_RP_8		0x1418	Family15h Root Port
 product AMD F15_10_IOMMU	0x1419	Family15h IOMMU
-product AMD F15_30_PF_0	0x141a	Family15h Processor Function 0
-product AMD F15_30_PF_1	0x141b	Family15h Processor Function 1
-product AMD F15_30_PF_2	0x141c	Family15h Processor Function 2
-product AMD F15_30_PF_3	0x141d	Family15h Processor Function 3
-product AMD F15_30_PF_4	0x141e	Family15h Processor Function 4
-product AMD F15_30_PF_5	0x141f	Family15h Processor Function 5
-product AMD F15_30_RC	0x1422	Family15h Root Complex
+product AMD F15_30_PF_0		0x141a	Family15h Processor Function 0
+product AMD F15_30_PF_1		0x141b	Family15h Processor Function 1
+product AMD F15_30_PF_2		0x141c	Family15h Processor Function 2
+product AMD F15_30_PF_3		0x141d	Family15h Processor Function 3
+product AMD F15_30_PF_4		0x141e	Family15h Processor Function 4
+product AMD F15_30_PF_5		0x141f	Family15h Processor 

CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug 18 09:58:49 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: radeonfb.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #86):

sys/dev/pci/radeonfb.c: revision 1.105

Support bitmap fonts with stride 4 (i.e., width 17 to 32).


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.4.1 src/sys/dev/pci/radeonfb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug 18 09:58:49 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: radeonfb.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #86):

sys/dev/pci/radeonfb.c: revision 1.105

Support bitmap fonts with stride 4 (i.e., width 17 to 32).


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.4.1 src/sys/dev/pci/radeonfb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.104 src/sys/dev/pci/radeonfb.c:1.104.4.1
--- src/sys/dev/pci/radeonfb.c:1.104	Wed Mar 27 22:00:33 2019
+++ src/sys/dev/pci/radeonfb.c	Sun Aug 18 09:58:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.104 2019/03/27 22:00:33 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.104.4.1 2019/08/18 09:58:49 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.104 2019/03/27 22:00:33 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.104.4.1 2019/08/18 09:58:49 martin Exp $");
 
 #include 
 #include 
@@ -2931,6 +2931,7 @@ radeonfb_putchar(void *cookie, int row, 
 	uint32_t		reg;
 	uint8_t			*data8;
 	uint16_t		*data16;
+	uint32_t		*data32;
 	void			*data;
 
 	if (dp->rd_wsmode != WSDISPLAYIO_MODE_EMUL)
@@ -3009,6 +3010,16 @@ radeonfb_putchar(void *cookie, int row, 
 			}
 			break;
 		}
+		case 4: {
+			data32 = data;
+			for (i = 0; i < h; i++) {
+reg = *data32;
+bus_space_write_stream_4(sc->sc_regt, 
+sc->sc_regh, RADEON_HOST_DATA0, reg);
+data32++;
+			}
+			break;
+		}
 	}
 	if (attr & 1)
 		radeonfb_rectfill(dp, xd, yd + h - 2, w, 1, fg);



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:03:13 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_et.c if_etreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #36):

sys/dev/pci/if_et.c: revision 1.25
sys/dev/pci/if_et.c: revision 1.26
sys/dev/pci/if_etreg.h: revision 1.2
sys/dev/pci/if_etreg.h: revision 1.3

Avoid undefined behavior when reset the chip. found by kUBSan.

 Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags controllable.

Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
  if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.2.1 src/sys/dev/pci/if_et.c
cvs rdiff -u -r1.1 -r1.1.68.1 src/sys/dev/pci/if_etreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:03:13 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_et.c if_etreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #36):

sys/dev/pci/if_et.c: revision 1.25
sys/dev/pci/if_et.c: revision 1.26
sys/dev/pci/if_etreg.h: revision 1.2
sys/dev/pci/if_etreg.h: revision 1.3

Avoid undefined behavior when reset the chip. found by kUBSan.

 Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags controllable.

Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
  if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.2.1 src/sys/dev/pci/if_et.c
cvs rdiff -u -r1.1 -r1.1.68.1 src/sys/dev/pci/if_etreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_et.c
diff -u src/sys/dev/pci/if_et.c:1.24 src/sys/dev/pci/if_et.c:1.24.2.1
--- src/sys/dev/pci/if_et.c:1.24	Tue May 28 07:41:49 2019
+++ src/sys/dev/pci/if_et.c	Fri Aug  9 16:03:13 2019
@@ -1,5 +1,5 @@
-/*	$NetBSD: if_et.c,v 1.24 2019/05/28 07:41:49 msaitoh Exp $	*/
-/*	$OpenBSD: if_et.c,v 1.11 2008/06/08 06:18:07 jsg Exp $	*/
+/*	$NetBSD: if_et.c,v 1.24.2.1 2019/08/09 16:03:13 martin Exp $	*/
+/*	$OpenBSD: if_et.c,v 1.12 2008/07/11 09:29:02 kevlo $	*/
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  *
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.24 2019/05/28 07:41:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.24.2.1 2019/08/09 16:03:13 martin Exp $");
 
 #include "opt_inet.h"
 #include "vlan.h"
@@ -83,17 +83,19 @@ __KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.
 
 int	et_match(device_t, cfdata_t, void *);
 void	et_attach(device_t, device_t, void *);
-int	et_detach(device_t, int flags);
+int	et_detach(device_t, int);
 int	et_shutdown(device_t);
 
 int	et_miibus_readreg(device_t, int, int, uint16_t *);
 int	et_miibus_writereg(device_t, int, int, uint16_t);
 void	et_miibus_statchg(struct ifnet *);
 
-int	et_init(struct ifnet *ifp);
+int	et_init(struct ifnet *);
 int	et_ioctl(struct ifnet *, u_long, void *);
 void	et_start(struct ifnet *);
 void	et_watchdog(struct ifnet *);
+static int	et_ifmedia_upd(struct ifnet *);
+static void	et_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 
 int	et_intr(void *);
 void	et_enable_intrs(struct et_softc *, uint32_t);
@@ -131,7 +133,6 @@ int	et_start_rxdma(struct et_softc *);
 int	et_start_txdma(struct et_softc *);
 int	et_stop_rxdma(struct et_softc *);
 int	et_stop_txdma(struct et_softc *);
-int	et_enable_txrx(struct et_softc *);
 void	et_reset(struct et_softc *);
 int	et_bus_config(struct et_softc *);
 void	et_get_eaddr(struct et_softc *, uint8_t[]);
@@ -190,6 +191,7 @@ et_attach(device_t parent, device_t self
 	const char *intrstr;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct mii_data * const mii = >sc_miibus;
+	uint32_t pmcfg;
 	pcireg_t memtype;
 	int error;
 	char intrbuf[PCI_INTRSTR_LEN];
@@ -234,6 +236,9 @@ et_attach(device_t parent, device_t self
 	sc->sc_pct = pa->pa_pc;
 	sc->sc_pcitag = pa->pa_tag;
 
+	if (pa->pa_id == PCI_PRODUCT_LUCENT_ET1301)
+		sc->sc_flags |= ET_FLAG_FASTETHER;
+
 	error = et_bus_config(sc);
 	if (error)
 		goto fail;
@@ -243,8 +248,11 @@ et_attach(device_t parent, device_t self
 	aprint_normal_dev(self, "Ethernet address %s\n",
 	ether_sprintf(sc->sc_enaddr));
 
-	CSR_WRITE_4(sc, ET_PM,
-		ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE | ET_PM_RXCLK_GATE);
+	/* Take PHY out of COMA and enable clocks. */
+	pmcfg = ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE | ET_PM_RXCLK_GATE;
+	if ((sc->sc_flags & ET_FLAG_FASTETHER) == 0)
+		pmcfg |= EM_PM_GIGEPHY_ENB;
+	CSR_WRITE_4(sc, ET_PM, pmcfg);
 
 	et_reset(sc);
 
@@ -273,8 +281,7 @@ et_attach(device_t parent, device_t self
 	mii->mii_statchg = et_miibus_statchg;
 
 	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(>mii_media, 0, ether_mediachange,
-	ether_mediastatus);
+	ifmedia_init(>mii_media, 0, et_ifmedia_upd, et_ifmedia_sts);
 	mii_attach(self, mii, 0x, MII_PHY_ANY, MII_OFFSET_ANY, 0);
 	if (LIST_FIRST(>mii_phys) == NULL) {
 		aprint_error_dev(self, "no PHY found!\n");
@@ -450,31 +457,117 @@ et_miibus_statchg(struct ifnet *ifp)
 {
 	struct et_softc *sc = ifp->if_softc;
 	struct mii_data *mii = >sc_miibus;
-	uint32_t cfg2, ctrl;
+	uint32_t cfg1, cfg2, ctrl;
+	int i;
+
+	sc->sc_flags &= ~ET_FLAG_LINK;
+	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
+	(IFM_ACTIVE | IFM_AVALID)) {
+		switch (IFM_SUBTYPE(mii->mii_media_active)) {
+		case IFM_10_T:
+		case IFM_100_TX:
+			sc->sc_flags |= ET_FLAG_LINK;
+			break;
+		case IFM_1000_T:
+			if ((sc->sc_flags & ET_FLAG_FASTETHER) == 0)
+