summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormsaitoh <msaitoh@NetBSD.org>2021-12-28 06:35:37 +0000
committermsaitoh <msaitoh@NetBSD.org>2021-12-28 06:35:37 +0000
commit2161215487935efe80a7ac86ce97a65ad977f2ca (patch)
tree50fcb36e070788652919b104a1a8e8018ebbc4ce /sys/dev
parentf18795248c69339edf51ef9037ba3687f2fd37c4 (diff)
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.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/mii/makphy.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/dev/mii/makphy.c b/sys/dev/mii/makphy.c
index c69147dc114..b9957ea0cb7 100644
--- a/sys/dev/mii/makphy.c
+++ b/sys/dev/mii/makphy.c
@@ -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, &reg);
- if ((reg & ESSR_AUTOSEL_DISABLE) != 0) {
+ rv = PHY_READ(sc, MAKPHY_ESSR, &reg);
+ 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: