Home | History | Annotate | Download | only in mii
History log of /src/sys/dev/mii/mii_physubr.c
RevisionDateAuthorComments
 1.103  22-May-2023  msaitoh Fix a bug when a media is changed to IFM_AUTO.

Fix a bug that ifconfig ifN media auto doesn't change the setting when
the previous media setting used autonego. When the mii_phy_setmedia()
function is called to change the media to IFM_AUTO, the BMCR_AUTOEN bit was
used to check if the previous setting was IFM_AUTO. It's not correct.
IFM_1000_T also uses autonego. So if a previous setting is IFM_1000_T and
the next setting is IFM_AUTO, mii_phy_auto() is not called if neither
MIIF_FORCEANEG nor MIIF_DOPAUSE are set. As a result, after changing
IFM_AUTO, neither 10Mbps nor 100Mbps are not advertised.

Note that almost all drivers uses MIIF_DOPAUSE flags.

TODO: cleanup ciphy.c and rgephy.c. Those have #ifdef foo.
 1.102  22-Feb-2023  msaitoh Retry autonegotiation every mii_anegticks seconds instead of mii_anegticks+1.
 1.101  23-Aug-2022  riastradh branches: 1.101.4;
mii(9): Make mii_phy_down clear the flag if it prevented the callout.

This fixes a bug in the previous change to make mii_down wait for the
mii auto timeout to complete.
 1.100  20-Aug-2022  riastradh mii(4): Make mii_down wait for concurrent mii_phy_auto to finish.

This is important for callers in if_stop routines to guarantee that
all concurrent access to the mii registers has ended.

Drivers must not call this from softint context. Drivers with custom
watchdog timers (not if_watchdog) that do if_stop from callout must
defer to thread context instead, e.g. via workqueue(9) -- as they
should be doing anyway for heavyweight operations like if_stop.
 1.99  14-Aug-2022  riastradh mii(4): Wait for MIIF_DOINGAUTO to clear with MIIF_AUTOTSLEEP too.

Otherwise mii_phy_detach may return while mii_phy_auto_timeout_locked
is still in progress in another thread.

Reuse the storage for mii_nway_ch, which is unused if MIIF_AUTOTSLEEP
is set, for a new condvar in a union. This doesn't change the kernel
ABI because sizeof(struct kcondvar) <= sizeof(struct callout) and
both have the same alignment, for an array of void *.
 1.98  14-Aug-2022  riastradh mii(4): Sprinkle assertions in mii phy auto timeout.
 1.97  28-Dec-2021  riastradh mii(9): Fix callout race between mii_phy_down and mii_phy_detach.
 1.96  15-Dec-2021  msaitoh Cosmetic change for the output of mii_get_descr().
 1.95  29-Jun-2021  pgoyette Rework the xxxVERBOSE option to share the common module-hook-based
verbose mechanism with MIIVERBOSE. This reduces some duplicated code
and allows us to once again permit auto-unload of MIIVERBOSE.

Change details:
* Update dev/devlist2h.awk to accomodate miidevs, including generation
of MII_STR_oui_model definitions and use of oui and model rather than
vendor and product. This also changes the compressed data in the
xxxdevs_data.h files to uint32_t (since mii oui's are up to 6 hex
digits long)
* Update a couple of phy drivers to use new calls to get verbose data
* Regen all of the xxxdevs{,_data}.h files (separate commit, coming
very soon)
* Update mii/mii_verbose.[ch] and mii/mii_physubr.c to use the various
DEV_VERBOSE_xxx macros
* Update the pci, usb, and hdaudio code as needed, to #include the
xxxdevs.h files (in order to get the proper printf format strings)
* Since dev/dev_verbose.c now uses non-literal printf format strings,
(to deal with the vendor/product vs oui/model issue), we need to
make sure it gets compiled with -Wno-error=format-nonliteral, even
in userland's libpci and librumpdev!
* Bump kernel version for the change in module interfaces

Welcome to 9.99.86!

XXX It might be useful in the future to extend the MII_STR_oui_model
XXX definitions to PCI as well (and perhaps USB and HDAUDIO). This
XXX would allow for a single centralized location for the products'
XXX descriptions, rather than being dispersed among individual
XXX drivers' xxx_match tables.
 1.94  27-Aug-2020  kardel branches: 1.94.6;
Move mii_phy_statusmsg(sc) back to its original position. Fixes
deafness bug on macppc reported and tested by martin@
Thanks !
 1.93  24-Aug-2020  kardel Keep the change check invariant intact. The previous code could miss
status updates by picking up a new status different from the tested
status. This left addresses in the DETACHED state although the
link status is already UP again.

addresses PR/kern 55538
 1.92  24-Aug-2020  msaitoh Don't do full initialization for autonego when just restarting autonego
because it's not required.

This change reduce extra initialization which include PHY_RESET() which
caused long delay(max 500ms).
 1.91  07-Jul-2020  msaitoh - Remove the waitfor argument from mii_phy_auto().
- Whitespace fix.
 1.90  15-Mar-2020  thorpej Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.89  27-Nov-2019  msaitoh - Simplify sc->mii_anegticks setting. Same as FreeBSD.

Don't set the default value not in the attach function. Instead, set the
default value (MII_ANEGTICKS) first in the beginning of the
mii_phy_add_media(). The function already has the code to change the value to
MII_ANEGTICKS_GIGE if it's gigabit capable.

- Remove extra pmf_device_register() call. It's done in mii_phy_add_media().
 1.88  20-Nov-2019  msaitoh 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.
 1.87  09-Apr-2019  msaitoh branches: 1.87.4;
- Use uint16_t more for MII registers.
- Whitespace.
 1.86  25-Mar-2019  msaitoh KNF. No functional change.
 1.85  25-Mar-2019  msaitoh KNF. No functional change.
 1.84  22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.83  08-Jan-2019  msaitoh Whitespace fixes. No functional change.
 1.82  28-Dec-2018  msaitoh 802.2 22.2.4.1.1 "Reset" says The reset shall be completed in 0.5s, so change
the value from 100ms to 500ms.
 1.81  05-Mar-2018  msaitoh branches: 1.81.2; 1.81.4;
KNF in comment. No functional change.
 1.80  20-Jun-2013  roy branches: 1.80.26;
Move the detaching and making tentative addresses out if in6_if_up
and into in6_if_link_up.

This fixes a possible panic where link is up but not the interface.
Note that a better solution would be to listen to the routing socket
in the kernel, but I don't know how to do that.

Reachable Router tests for IFF_UP as well.
 1.79  16-Jun-2013  msaitoh The bit location of link ability is different between 1000Base-X and others
(See annex 28B.2 and 28D). The old mii.h defined ANAR_X_PAUSE_* macros. Those
macros were named for 1000Base-X, but the bit definitions were not for
1000Base-X but for others (e.g. 1000BaseT). So there was bug in auto
negotiation for 1000Base-X, but there was no bug for other media. Define new
macro named ANAR_PAUSE_* and ANLPAR_PAUSE_* for other than 1000Base-X and fix
the bit definitions of ANAR_X_PAUSE_* and ANLPPAR_X_*. Change some PHY drivers
to use true macro. Same as other *BSDs.
 1.78  09-Jun-2013  msaitoh Fix a bug in last commit that mii_ticks isn't inclemented.
 1.77  09-Jun-2013  msaitoh Update link status quickly. This change is a part of FreeBSD's mii_physubr.c
r158649.
 1.76  06-Jun-2013  msaitoh Fix a bug that the auto negotiation timer isn't cleard as we expected.
To not to forget clearing the timer and to reduce the code duplication,
clear mii_ticks in *mii_phy_auto().
 1.75  03-Oct-2012  mlelstv use media_table instead of replicating code
 1.74  22-Jul-2012  matt branches: 1.74.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.73  10-Dec-2011  buhrow branches: 1.73.2;

Fixes PR kern/20700 reported by Darcy Cain

Make 1000baset connections work even when the user specifies media 1000baset
connections with ifconfig(8) rather then only when media auto is specified.

For a further discussion of this fix, see:
http://mail-index.NetBSD.org/current-users/2011/12/07/msg018561.html
 1.72  21-Aug-2010  pgoyette branches: 1.72.8; 1.72.12;
Update the various xxx_verbose modules to conform to the module subsystem's
new locking protocol.
 1.71  25-Jul-2010  pgoyette Move setting of mii_verbose_loaded flag into the module's init routine.
This ensures that the flag is set even if the module was manually loaded
by the user rather than just auto-loaded.
 1.70  06-Jun-2010  pgoyette Update miiverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.69  02-Jun-2010  martin Move all miiverbose/module related functions from ukphy.c to mii_physubr.c -
ukphy is not included in all kernels, but mii_physubr.c should be in every
kernel that has a phy.
 1.68  02-Mar-2010  martin branches: 1.68.2;
Before destroying a autonegotiation callout, make sure it is quiet
 1.67  24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.66  08-Jan-2010  dyoung branches: 1.66.2;
Expand PMF_FN_* macros.
 1.65  06-Nov-2009  dyoung Simplify mii_phy_activate(). Remark in mii_phy_activate() and
mii_phy_detach() comments that we may need to invalidate the parent's
media setting. No functional change intended.
 1.64  12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.63  07-Apr-2009  dyoung In mii_phy_detach(), destroy the NWay callout.
 1.62  16-Jan-2009  cegger branches: 1.62.2;
add mii_anar(). From OpenBSD.
 1.61  17-Nov-2008  dyoung Reduce code duplication: most PHY drivers call mii_phy_add_media()
when they attach to the device tree, so call pmf_device_register(9)
once there instead of once in more than twenty drivers.
 1.60  04-May-2008  xtraeme branches: 1.60.6; 1.60.8; 1.60.10;
device_t/softc split for all mii(4) devices, and other related
cosmetic changes.
 1.59  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.58  29-Feb-2008  dyoung branches: 1.58.2; 1.58.4;
Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.57  20-Jan-2008  msaitoh branches: 1.57.2; 1.57.6;
mii_physubr.c::mii_phy_reset() has gphyter and nsphyter specific delay(500).
This delay cause 500us loops under splnet() per linkdown port per mii_tick.
It causes periodically drop packets. It's not acceptable for other devices.

Move gphyter and nsphyter specific delay(500) into the drivers from
mii_physubr.c.
 1.56  10-Jan-2008  dyoung Add a helper routine for ethernet drivers, mii_ifmedia_change().

Remove an mii_softc from its mii_data in mii_phy_detach(), not in
mii_detach(), so that we do not leave dangling pointers to a PHY
in an mii_data.
 1.55  29-Dec-2007  dyoung Remove the device_is_active() check from each individual PHY's
service routine. Add a wrapper for PHY_SERVICE(), called phy_service(),
and check device_is_active() there. Make the mii_*() routines call
the PHY service routines thorugh phy_service() instead of PHY_SERVICE().

In mii_phy_resume(), restore a PHY's state after resetting it by
sending a MII_MEDIACHG command. This change makes bnx(4) resume
more reliably and more quickly; it should help other NICs to resume,
too, if they attach PHYs through MII.
 1.54  09-Dec-2007  jmcneill branches: 1.54.2;
Merge jmcneill-pm branch.
 1.53  16-Nov-2006  christos branches: 1.53.2; 1.53.22; 1.53.24; 1.53.30; 1.53.34; 1.53.36;
- don't hardcode 5, 10 define and use MII_ANEGTICKS{,_GIGE}
- instead of != limit, use <= limit (conservative)
 1.52  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.51  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.50  02-Sep-2006  christos branches: 1.50.2; 1.50.4;
comment out unreachable code
 1.49  29-Mar-2006  thorpej Use device_private().
 1.48  25-Mar-2006  thorpej Use device_parent().
 1.47  20-Feb-2006  thorpej branches: 1.47.2; 1.47.4; 1.47.6;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
 1.46  18-Feb-2006  joerg Change the link status code in MII to use if_link_state_change instead
of calling rt_ifmsg directly. This allows other parts of the kernel
to change the behaviour depending on the link state and is a
prerequirement for CARP.

Hide mii_phy_statusmsg, mii_phy_update should be used instead.
Don't send routing messages for baudrate changes, if_baudrate is
currently not exported via this interface.

OK tls@
 1.45  11-Dec-2005  christos branches: 1.45.2; 1.45.4; 1.45.6;
merge ktrace-lwp.
 1.44  27-Feb-2005  perry branches: 1.44.4;
nuke trailing whitespace
 1.43  23-Aug-2004  thorpej branches: 1.43.4; 1.43.6;
Make use of static.
 1.42  11-Apr-2004  thorpej mii_phy_flowstatus(): short-circuit processing if both sides advertise
symmetric pause capability. From HITOSHI Osada.
 1.41  11-Apr-2004  thorpej Add a comment describing why we force renegotiation when PAUSE is being
used. From HITOSHI Osada.
 1.40  11-Apr-2004  thorpej gmii_phy_getflowcontrol() -> mii_phy_flowstatus(). From HITOSHI Osada.
 1.39  10-Apr-2004  thorpej gmii_phy_getflowcontrol(): Bail out early if the MAC didn't tell us to
do flow control processing.
 1.38  10-Apr-2004  thorpej Flow-control advertisement and parsing support. From HITOSHI Osada.
Slightly modified by me.
 1.37  10-Sep-2003  briggs It is best to allow a little time for the reset to settle in before
we start polling the BMCR again. Greg Woods noted on tech-net@
that the DP83840A manual states that there should be a 500us delay
between asserting software reset and attempting MII serial operations.

I've also noted that a DP83815 can get into a bad state on cable
removal and reinsertion if we do not delay here.

This may well address PR/16346, and I seem to recall occasional
reports of auto-negotiation and flaky kinds of errors that this
might also alleviate.
 1.36  29-Apr-2003  thorpej branches: 1.36.2;
Use aprint*().
 1.35  20-Feb-2003  matt Add a MIIF_FORCEANEG flag to be passed to mii_attach. This forces an
autonegotiation to take place if IFM_AUTO is selected in mii_media_set.
Make the gem driver use it. (XXX hme probably should use it but I can't
test that).
 1.34  07-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.33  12-May-2002  thorpej Back out change accidentally committed.
 1.32  10-May-2002  thorpej Make sure ifp->if_baudrate is valid when the parent's statchg
callback is made.

Pointed out by Matt Thomas.
 1.31  07-May-2002  uwe Delint somewhat.
 1.30  13-Nov-2001  lukem add RCSID
 1.29  25-Aug-2001  thorpej ANSI'ify.
 1.28  25-Aug-2001  thorpej For HomePNA PHYs, don't register it w/ ifmedia as 10BASE-T, but
rather as HomePNA1.
 1.27  27-Jul-2001  thorpej Clean up 1000BASE-SX autonegotiation, and add a way to advertise
PAUSE capability.
 1.26  25-Jul-2001  thorpej Fix 1000BASE-X duplex negotiation. That'll teach me to read the
manual more carefully next time.
 1.25  30-Jun-2001  bjh21 branches: 1.25.2;
IFM_1000_TX -> IFM_1000_T, as (breifly) discussed on tech-net.
 1.24  02-Jun-2001  thorpej Make PHY matching all table-driven.
 1.23  31-May-2001  thorpej Enable frobbing the 1000baseT control register on Gig-E PHYs,
used for hard-wiring master mode, and for advertising the 1000baseT
media options during autonegotiation.
 1.22  31-May-2001  thorpej Make the number of ticks between auto-negotiation tries PHY-specific,
and default every PHY to 5 seconds (what we used before). If we find
Gig-E media on a PHY, bump it to 10 seconds, since it can take 5
seconds just to negotiate a Gig-E link.
 1.21  30-Apr-2001  thorpej Add code to recognize and set media on GMII (Gigabit MII) PHYs.

802.3 doens't specify ANAR or ANLPAR bits for GMII. Need to
use PHY-specific registers for this, for now, which means we
need specific drivers for the Gigabit-capable PHYs (I think the
most common is the BCM5400).
 1.20  13-Apr-2001  thorpej Remove the use of splimp() from the NetBSD kernel. splnet()
and only splnet() is allowed for the protection of data structures
used by network devices.
 1.19  13-Apr-2001  augustss Add a flag to mii_flags which will cause autonegotiation to use tsleep()
instead of callout. This way adapters which need a process context for
PHY register access (e.g. USB adapters) have a chance.
 1.18  04-Jul-2000  thorpej branches: 1.18.2;
Restructure the PHY entry points to use a structure of entry points
instead of discrete function pointers, and extend this to include
a "reset" entry point. Make sure any PHY-specific reset routine is
always used, and provide one for the LXT-970 which disables MII
interrupts (as is done for a few other PHYs we have drivers for).
 1.17  23-Mar-2000  thorpej branches: 1.17.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.16  15-Mar-2000  thorpej - Go to splimp() when sending the rtsock message regarding link status.
- Would like to notify protocols if a link goes up or down, to e.g.
restart Duplicate Address Detection, etc. Add a comment to this
effect.
 1.15  06-Mar-2000  thorpej Factor out the tick handling code into a common function, and send
rt_ifmsg's when the link speed or link status changes.
 1.14  03-Feb-2000  thorpej Some PHYs go off into left field for a few seconds if you attempt to kick
autonegotiation while it's already enabled.
 1.13  03-Feb-2000  thorpej Oops, missing return;
 1.12  02-Feb-2000  thorpej Let mii_phy_setmedia() handle the IFM_AUTO case, too.
 1.11  02-Feb-2000  thorpej Make PHY drivers provide a pointer to their status routine, and add
a generic mii_phy_status() that calls back into the PHY. It doesn't
do anything interesting yet, but it will soon.
 1.10  02-Feb-2000  thorpej Bring some order to the chaos which was the MII code function naming
"conventions".
 1.9  27-Jan-2000  thorpej Add detachment support to the MII layer.
 1.8  12-Nov-1999  thorpej Add mii_down(), which is used by MAC drivers to inform PHYs that the
interface is now down. PHYs use this to cancel pending asynchronous
operations.
 1.7  03-Nov-1999  thorpej Don't add any loopback versions of media, for now.
 1.6  03-Nov-1999  thorpej Clean up the code that adds media a little, and make media selection
table-driven in preparation for some other changes to be made.
 1.5  03-Aug-1999  drochner branches: 1.5.2; 1.5.4; 1.5.8;
move common support functions for phy drivers from mii.c to mii_physubr.c,
so that they are not includes if no PHY is configured
(avoids code bloat if an interface driver has the "mii" attribute but
mii is not used by the particular version)
 1.4  26-Apr-1999  kleink mii_phy_auto(): don't rely on an implicit declaration of the waitfor argument.
 1.3  23-Apr-1999  thorpej Implement asynchronous autonegotiation when driven by the MII tick
(one-second clock). Prevents .5s delays every 5 seconds when the interface
is up but there is no link. Fixes PR 7361.
 1.2  04-Nov-1998  thorpej branches: 1.2.6;
Factor out the common reset code. Use the NOISOLATE flags as appropriate
to prevent a PHY from being isolated in the event the MAC can't deal with
this. (3Com 3c905B-TX, and Intel i82557).
 1.1  04-Nov-1998  thorpej Factor out some common code from all the PHY drivers (autonegotiation, for
now.)
 1.2.6.1  23-Apr-1999  perry branches: 1.2.6.1.2;
pullup 1.2->1.3 (thorpej): Fix PR7361
 1.2.6.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.5.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.4.1  15-Nov-1999  fvdl Sync with -current
 1.5.2.2  21-Apr-2001  bouyer Sync with HEAD
 1.5.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.17.4.1  04-Jul-2000  thorpej Update from trunk:
Restructure the PHY entry points to use a structure of entry points
instead of discrete function pointers, and extend this to include
a "reset" entry point. Make sure any PHY-specific reset routine is
always used, and provide one for the LXT-970 which disables MII
interrupts (as is done for a few other PHYs we have drivers for).
 1.18.2.6  11-Nov-2002  nathanw Catch up to -current
 1.18.2.5  20-Jun-2002  nathanw Catch up to -current.
 1.18.2.4  14-Nov-2001  nathanw Catch up to -current.
 1.18.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.18.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.18.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.25.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.25.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.25.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.25.2.1  03-Aug-2001  lukem update to -current
 1.36.2.5  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.36.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.36.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.36.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.36.2.1  03-Aug-2004  skrll Sync with HEAD
 1.43.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.43.4.1  29-Apr-2005  kent sync with -current
 1.44.4.4  17-Mar-2008  yamt sync with head.
 1.44.4.3  21-Jan-2008  yamt sync with head
 1.44.4.2  30-Dec-2006  yamt sync with head.
 1.44.4.1  21-Jun-2006  yamt sync with head.
 1.45.6.1  22-Apr-2006  simonb Sync with head.
 1.45.4.1  09-Sep-2006  rpaulo sync with head
 1.45.2.1  01-Mar-2006  yamt sync with head.
 1.47.6.2  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.47.6.1  28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.47.4.1  19-Apr-2006  elad sync with head.
 1.47.2.2  03-Sep-2006  yamt sync with head.
 1.47.2.1  01-Apr-2006  yamt sync with head.
 1.50.4.2  10-Dec-2006  yamt sync with head.
 1.50.4.1  22-Oct-2006  yamt sync with head
 1.50.2.1  18-Nov-2006  ad Sync with head.
 1.53.36.1  11-Dec-2007  yamt sync with head.
 1.53.34.1  26-Dec-2007  ad Sync with head.
 1.53.30.1  18-Feb-2008  mjf Sync with HEAD.
 1.53.24.2  23-Mar-2008  matt sync with HEAD
 1.53.24.1  09-Jan-2008  matt sync with HEAD
 1.53.22.1  27-Nov-2007  joerg Register MII PHY drives with the PM framework. Nothing to do on suspend,
just reset the PHY on resume.
 1.53.2.1  12-Jun-2012  sborrill Pull up the following revisions(s) (requested by buhrow in ticket #1448):
sys/dev/mii/mii_physubr.c: revision 1.73 via patch

Make 1000baseT connections work even when the user specifies media 1000baseT
connections with ifconfig(8) rather than only when media auto is specified.
Fixes PR kern/20700.
 1.54.2.3  20-Jan-2008  bouyer Sync with HEAD
 1.54.2.2  10-Jan-2008  bouyer Sync with HEAD
 1.54.2.1  02-Jan-2008  bouyer Sync with HEAD
 1.57.6.3  17-Jan-2009  mjf Sync with HEAD.
 1.57.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.57.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.57.2.1  24-Mar-2008  keiichi sync with head.
 1.58.4.6  09-Oct-2010  yamt sync with head
 1.58.4.5  11-Aug-2010  yamt sync with head.
 1.58.4.4  11-Mar-2010  yamt sync with head
 1.58.4.3  16-May-2009  yamt sync with head
 1.58.4.2  04-May-2009  yamt sync with head.
 1.58.4.1  16-May-2008  yamt sync with head.
 1.58.2.1  18-May-2008  yamt sync with head.
 1.60.10.2  25-Jan-2012  riz Pull up following revision(s) (requested by buhrow in ticket #1701):
sys/dev/mii/mii_physubr.c: revision 1.73
Fixes PR kern/20700 reported by Darcy Cain
Make 1000baset connections work even when the user specifies media 1000baset
connections with ifconfig(8) rather then only when media auto is specified.
For a further discussion of this fix, see:
http://mail-index.NetBSD.org/current-users/2011/12/07/msg018561.html
 1.60.10.1  23-Apr-2009  snj Pull up following revision(s) (requested by sborrill in ticket #715):
sys/dev/mii/mii_physubr.c: revision 1.62
sys/dev/mii/miivar.h: revision 1.53
add mii_anar(). From OpenBSD.
 1.60.8.2  28-Apr-2009  skrll Sync with HEAD.
 1.60.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.60.6.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.62.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.66.2.3  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.66.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.66.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.68.2.2  05-Mar-2011  rmind sync with head
 1.68.2.1  03-Jul-2010  rmind sync with head
 1.72.12.1  18-Feb-2012  mrg merge to -current.
 1.72.8.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.72.8.2  30-Oct-2012  yamt sync with head
 1.72.8.1  17-Apr-2012  yamt sync with head
 1.73.2.2  04-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #1245):
sys/dev/mii/rgephy.c: revision 1.30
sys/dev/mii/brgphy.c: revision 1.64
sys/dev/mii/atphy.c: revision 1.13
sys/dev/mii/urlphy.c: revision 1.26
sys/dev/mii/ciphy.c: revision 1.20
sys/dev/mii/mii_physubr.c: revision 1.76
Fix a bug that the auto negotiation timer isn't cleard as we expected.
To not to forget clearing the timer and to reduce the code duplication,
clear mii_ticks in *mii_phy_auto().
 1.73.2.1  04-Nov-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #1146):
sys/dev/mii/mii_physubr.c: revision 1.79
sys/dev/mii/rgephy.c: revision 1.33
sys/dev/mii/brgphy.c: revision 1.66
sys/dev/mii/atphy.c: revision 1.15
sys/dev/mii/mii.h: revision 1.17
The bit location of link ability is different between 1000Base-X and others
(See annex 28B.2 and 28D). The old mii.h defined ANAR_X_PAUSE_* macros. Those
macros were named for 1000Base-X, but the bit definitions were not for
1000Base-X but for others (e.g. 1000BaseT). So there was bug in auto
negotiation for 1000Base-X, but there was no bug for other media. Define new
macro named ANAR_PAUSE_* and ANLPAR_PAUSE_* for other than 1000Base-X and fix
the bit definitions of ANAR_X_PAUSE_* and ANLPPAR_X_*. Change some PHY drivers
to use true macro. Same as other *BSDs.
 1.74.2.2  23-Jun-2013  tls resync from head
 1.74.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.80.26.2  21-Nov-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1454:

sys/dev/mii/atphy.c 1.22-1.23, 1.25 via patch
sys/dev/mii/mii_physubr.c 1.88 via patch
sys/dev/mii/miivar.h 1.69 via patch

- Fix a bug that atphy(4) can't negotiate correctly when the media
setting is neither auto nor 1000baseT.
- Code cleanup.
 1.80.26.1  30-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1149):

sys/dev/mii/mii_physubr.c: revision 1.81
sys/dev/mii/mii_physubr.c: revision 1.82

KNF in comment. No functional change.

-

802.3 22.2.4.1.1 "Reset" says The reset shall be completed in 0.5s, so change
the value from 100ms to 500ms.
 1.81.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.81.4.1  10-Jun-2019  christos Sync with HEAD
 1.81.2.2  26-Jan-2019  pgoyette Sync with HEAD
 1.81.2.1  18-Jan-2019  pgoyette Synch with HEAD
 1.87.4.1  21-Nov-2019  martin 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.
 1.94.6.1  01-Aug-2021  thorpej Sync with HEAD.
 1.101.4.2  21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #211):

sys/dev/mii/mii_physubr.c: revision 1.103

Fix a bug when a media is changed to IFM_AUTO.

Fix a bug that ifconfig ifN media auto doesn't change the setting when
the previous media setting used autonego. When the mii_phy_setmedia()
function is called to change the media to IFM_AUTO, the BMCR_AUTOEN bit was
used to check if the previous setting was IFM_AUTO. It's not correct.

IFM_1000_T also uses autonego. So if a previous setting is IFM_1000_T and
the next setting is IFM_AUTO, mii_phy_auto() is not called if neither
MIIF_FORCEANEG nor MIIF_DOPAUSE are set. As a result, after changing
IFM_AUTO, neither 10Mbps nor 100Mbps are not advertised.

Note that almost all drivers uses MIIF_DOPAUSE flags.

TODO: cleanup ciphy.c and rgephy.c. Those have #ifdef foo.
 1.101.4.1  21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #208):

sys/dev/mii/ciphy.c: revision 1.42
sys/dev/mii/brgphy.c: revision 1.91
sys/dev/mii/mii_physubr.c: revision 1.102
sys/dev/mii/ipgphy.c: revision 1.11
sys/dev/mii/tlphy.c: revision 1.72
sys/dev/mii/jmphy.c: revision 1.5
sys/dev/mii/urlphy.c: revision 1.40
sys/dev/mii/atphy.c: revision 1.31

Retry autonegotiation every mii_anegticks seconds instead of mii_anegticks+1.

RSS XML Feed