Module Name: src
Committed By: martin
Date: Thu Nov 21 14:00:49 UTC 2019
Modified Files:
src/sys/dev/mii [netbsd-9]: atphy.c mii_physubr.c miivar.h
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #459):
sys/dev/mii/atphy.c: revision 1.23
sys/dev/mii/atphy.c: revision 1.25
sys/dev/mii/miivar.h: revision 1.69
sys/dev/mii/mii_physubr.c: revision 1.88
s/etphy/atphy/. No functional change.
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.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/dev/mii/atphy.c
cvs rdiff -u -r1.87 -r1.87.4.1 src/sys/dev/mii/mii_physubr.c
cvs rdiff -u -r1.68 -r1.68.4.1 src/sys/dev/mii/miivar.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/mii/atphy.c
diff -u src/sys/dev/mii/atphy.c:1.22 src/sys/dev/mii/atphy.c:1.22.4.1
--- src/sys/dev/mii/atphy.c:1.22 Thu Apr 11 09:00:34 2019
+++ src/sys/dev/mii/atphy.c Thu Nov 21 14:00:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: atphy.c,v 1.22 2019/04/11 09:00:34 msaitoh Exp $ */
+/* $NetBSD: atphy.c,v 1.22.4.1 2019/11/21 14:00:49 martin 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.22 2019/04/11 09:00:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.22.4.1 2019/11/21 14:00:49 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -90,7 +90,7 @@ const struct mii_phy_funcs atphy_funcs =
atphy_service, atphy_status, atphy_reset,
};
-static const struct mii_phydesc etphys[] = {
+static const struct mii_phydesc atphys[] = {
MII_PHY_DESC(ATHEROS, F1),
MII_PHY_DESC(ATTANSIC, L1),
MII_PHY_DESC(ATTANSIC, L2),
@@ -118,7 +118,7 @@ atphy_match(device_t parent, cfdata_t ma
{
struct mii_attach_args *ma = aux;
- if (mii_phy_match(ma, etphys) != NULL)
+ if (mii_phy_match(ma, atphys) != NULL)
return 10;
return 0;
@@ -133,7 +133,7 @@ atphy_attach(device_t parent, device_t s
const struct mii_phydesc *mpd;
uint16_t bmsr;
- mpd = mii_phy_match(ma, etphys);
+ mpd = mii_phy_match(ma, atphys);
aprint_naive(": Media interface\n");
aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
@@ -222,7 +222,7 @@ atphy_service(struct mii_softc *sc, stru
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. */
Index: src/sys/dev/mii/mii_physubr.c
diff -u src/sys/dev/mii/mii_physubr.c:1.87 src/sys/dev/mii/mii_physubr.c:1.87.4.1
--- src/sys/dev/mii/mii_physubr.c:1.87 Tue Apr 9 11:28:45 2019
+++ src/sys/dev/mii/mii_physubr.c Thu Nov 21 14:00:49 2019
@@ -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.87.4.1 2019/11/21 14:00:49 martin 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.87.4.1 2019/11/21 14:00:49 martin Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -697,19 +697,16 @@ mii_phy_resume(device_t dv, const pmf_qu
/*
- * 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;
}
Index: src/sys/dev/mii/miivar.h
diff -u src/sys/dev/mii/miivar.h:1.68 src/sys/dev/mii/miivar.h:1.68.4.1
--- src/sys/dev/mii/miivar.h:1.68 Thu Apr 11 09:14:07 2019
+++ src/sys/dev/mii/miivar.h Thu Nov 21 14:00:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: miivar.h,v 1.68 2019/04/11 09:14:07 msaitoh Exp $ */
+/* $NetBSD: miivar.h,v 1.68.4.1 2019/11/21 14:00:49 martin Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -287,7 +287,7 @@ int mii_mediachg(struct mii_data *);
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 *);