Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/mii Fix a bug that atphy(4) can't negotiate correctl...
details: https://anonhg.NetBSD.org/src/rev/730c2890e4bf
branches: trunk
changeset: 966870:730c2890e4bf
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Wed Nov 20 08:50:59 2019 +0000
description:
Fix a bug that atphy(4) can't negotiate correctly when the media setting is
neither auto nor 1000baseT. Use correct index for mii_media_table[].
History: mii_anar() is first added in OpenBSD and ported to NetBSD. On NetBSD,
only atphy(4) use this function. mii_physubr.c rev. 1.75 changed mii_anar()
for simplify. It changed the argument from the ifmedia word to ifm_data used
in our MII API, but the caller have not been changed. And then, PR kern/50206
was reported and the caller was modified by me to prevent panic but it was not
correct fix.
diffstat:
sys/dev/mii/atphy.c | 6 +++---
sys/dev/mii/mii_physubr.c | 15 ++++++---------
sys/dev/mii/miivar.h | 4 ++--
3 files changed, 11 insertions(+), 14 deletions(-)
diffs (87 lines):
diff -r e9a7eceeada0 -r 730c2890e4bf sys/dev/mii/atphy.c
--- a/sys/dev/mii/atphy.c Wed Nov 20 08:17:01 2019 +0000
+++ b/sys/dev/mii/atphy.c Wed Nov 20 08:50:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atphy.c,v 1.24 2019/10/18 12:53:08 hkenken Exp $ */
+/* $NetBSD: atphy.c,v 1.25 2019/11/20 08:50:59 msaitoh Exp $ */
/* $OpenBSD: atphy.c,v 1.1 2008/09/25 20:47:16 brad Exp $ */
/*-
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.24 2019/10/18 12:53:08 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.25 2019/11/20 08:50:59 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -273,7 +273,7 @@
return EINVAL;
}
- anar = mii_anar(IFM_SUBTYPE(ife->ifm_media));
+ anar = mii_anar(ife);
if ((ife->ifm_media & IFM_FDX) != 0) {
bmcr |= BMCR_FDX;
/* Enable pause. */
diff -r e9a7eceeada0 -r 730c2890e4bf sys/dev/mii/mii_physubr.c
--- a/sys/dev/mii/mii_physubr.c Wed Nov 20 08:17:01 2019 +0000
+++ b/sys/dev/mii/mii_physubr.c Wed Nov 20 08:50:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mii_physubr.c,v 1.87 2019/04/09 11:28:45 msaitoh Exp $ */
+/* $NetBSD: mii_physubr.c,v 1.88 2019/11/20 08:50:59 msaitoh Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.87 2019/04/09 11:28:45 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.88 2019/11/20 08:50:59 msaitoh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -697,19 +697,16 @@
/*
- * Given an ifmedia word, return the corresponding ANAR value.
+ * Given an ifmedia_entry, return the corresponding ANAR value.
*/
uint16_t
-mii_anar(int media)
+mii_anar(struct ifmedia_entry *ife)
{
- int rv;
#ifdef DIAGNOSTIC
- if (/* media < 0 || */ media >= MII_NMEDIA)
+ if (ife->ifm_data >= MII_NMEDIA)
panic("mii_anar");
#endif
- rv = mii_media_table[media].mm_anar;
-
- return rv;
+ return mii_media_table[ife->ifm_data].mm_anar;
}
diff -r e9a7eceeada0 -r 730c2890e4bf sys/dev/mii/miivar.h
--- a/sys/dev/mii/miivar.h Wed Nov 20 08:17:01 2019 +0000
+++ b/sys/dev/mii/miivar.h Wed Nov 20 08:50:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: miivar.h,v 1.68 2019/04/11 09:14:07 msaitoh Exp $ */
+/* $NetBSD: miivar.h,v 1.69 2019/11/20 08:50:59 msaitoh Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -287,7 +287,7 @@
void mii_tick(struct mii_data *);
void mii_pollstat(struct mii_data *);
void mii_down(struct mii_data *);
-uint16_t mii_anar(int);
+uint16_t mii_anar(struct ifmedia_entry *);
int mii_ifmedia_change(struct mii_data *);
Home |
Main Index |
Thread Index |
Old Index