Module Name: src Committed By: msaitoh Date: Tue Dec 28 06:35:37 UTC 2021
Modified Files: src/sys/dev/mii: makphy.c Log Message: QEMU e1000's PHY code doesn't implement register 16. Do workaround. - Marvell 88E1[01]11 (and many other Marvell PHYs) have the Fiber/Copper auto selection feature. Our makphy(4) implement it but QEMU doesn't. If it fails, a garbage data is used in the attach function and unexpected media may be used. Fix this behavior by checking the return value of PHY_READ(MAKPHY_ESSR). If the access failed, the media is regarded as copper only. It's just a cosmetic change. It's not affected to the packet processing. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/dev/mii/makphy.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/mii/makphy.c diff -u src/sys/dev/mii/makphy.c:1.69 src/sys/dev/mii/makphy.c:1.70 --- src/sys/dev/mii/makphy.c:1.69 Tue Dec 28 06:34:40 2021 +++ src/sys/dev/mii/makphy.c Tue Dec 28 06:35:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: makphy.c,v 1.69 2021/12/28 06:34:40 msaitoh Exp $ */ +/* $NetBSD: makphy.c,v 1.70 2021/12/28 06:35:37 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.69 2021/12/28 06:34:40 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.70 2021/12/28 06:35:37 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -230,8 +230,18 @@ page0: case MII_MODEL_xxMARVELL_E1011: case MII_MODEL_xxMARVELL_E1111: /* These devices have ESSR register */ - PHY_READ(sc, MAKPHY_ESSR, ®); - if ((reg & ESSR_AUTOSEL_DISABLE) != 0) { + rv = PHY_READ(sc, MAKPHY_ESSR, ®); + if (rv != 0) { + /* + * XXX Emulator (e.g qemu) may not implement + * the ESSR register. If so, regard as copper + * media. + */ + copperonly = true; + aprint_verbose_dev(self, "Failed to access " + "ESSR. Are you an emulator? Regard as " + "copper only media.\n"); + } else if ((reg & ESSR_AUTOSEL_DISABLE) != 0) { switch (reg & ESSR_HWCFG_MODE) { case ESSR_RTBI_FIBER: case ESSR_RGMII_FIBER: