History log of /openbsd-current/sys/dev/mii/mii_physubr.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.46 15-Jan-2020 cheloha

mii(4): tsleep(9) -> tlseep_nsec(9); ok mpi@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.45 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.44 05-Dec-2014 mpi

Explicitly include <net/if_var.h> instead of pulling it in <net/if.h>.

ok mikeb@, krw@, bluhm@, tedu@


# 1.43 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.42 28-Dec-2013 deraadt

mii drivers no longer need activate functions. Repair of the PHY
configuration setting is done at resume time because all networks
drivers which were previously up, do an IFF_UP operation which
hits PHY_RESET.
This was in snapshots for about 2 weeks.


Revision tags: OPENBSD_5_4_BASE
# 1.41 25-Jun-2013 brad

Remove unsigned comparison < 0.

Pointed out by LLVM.

ok mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.40 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.39 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


# 1.38 02-Aug-2009 miod

Never return nonzero in a device activate method invoked with DVACT_ACTIVATE,
for this prevents it to be invoked with DVACT_DEACTIVATE later. This had
been sweeped some time ago already, but bad constructs crept in again.


# 1.37 31-Jul-2009 blambert

timeout_add -> timeout_add_msec

ok art@


# 1.36 22-Jul-2009 sthen

comment fix from Brad; OpenBSD's mii_phy_add_media() does not print
the media names like NetBSD does.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.35 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.34 13-May-2008 brad

Since Ethernet links can only be full duplex or half duplex the link
state reporting code in the MII layer / em(4) and vge(4) will never
fall back to the point of only reporting the link as being UP without
the duplex setting being reported, so simplify the code a bit here.

ok dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.33 17-Sep-2007 brad

- Use a 64-bit int for the baudrate within the ifmedia_baudrate struct and
return a 64-bit int for ifmedia_baudrate().
- Fix consumers of ifmedia_baudrate() to deal with the change.

ok claudio@ dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 10-Feb-2007 kettenis

Use right flow control autonegotiation bits for 1000baseX.


# 1.31 30-Dec-2006 kettenis

Make mii_phy_auto() advertise flow control if MIIF_DOPAUSE is set.

ok jsg@, brad@


# 1.30 28-Dec-2006 kettenis

Add function to detect flow control status. From NetBSD.

ok brad@


# 1.29 15-Dec-2006 reyk

use mii_media_active instead of mii_media_status to get the full
duplex state. this will actually enable duplex reporting for drivers
using the mii layer.

figured out by Moritz Grimm with sk(4)


# 1.28 28-Nov-2006 reyk

add additional link states to report the half duplex / full duplex
state, if known by the driver. this is required to check the full
duplex state without depending on the ifmedia ioctl which can't be
called in the kernel without process context.

ok henning@, brad@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.27 06-Nov-2005 brad

correctly track the falling edge of a media state change in mii_phy_tick().


Revision tags: OPENBSD_3_8_BASE
# 1.26 26-Mar-2005 krw

Cleanup. Use defines, standard names, consistant comparison operators, etc.
for auto negotiation ticks code. No functional change.

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.25 07-Feb-2005 mcbride

Use new if_link_state_change() instead of sending route message and notifying
carp directly.

ok brad@ mpf@


# 1.24 16-Dec-2004 brad

Make sure ifp->if_baudrate is valid when the parent's statchg
callback is made.

From NetBSD


# 1.23 08-Dec-2004 mcbride

Check if_type in carp_carpdev_state() to make sure we're not
dealing with a carp interface.


# 1.22 18-Nov-2004 brad

add mii_phy_match() for table-driven lookup.

From NetBSD


# 1.21 09-Oct-2004 brad

Allow a little time for the reset to settle in before we start polling
the BMCR again. The DP83840A manual states that there should be a 500us delay
between asserting software reset and attempting MII serial operations.

From NetBSD

ok mcbride@


# 1.20 09-Oct-2004 brad

add master flag support for 1000baseT and autonegotiation support for 1000baseX.

From NetBSD

ok mcbride@


# 1.19 27-Sep-2004 brad

ANSI protos and some minor cleanup

ok henning@


# 1.18 26-Sep-2004 brad

Restructure the PHY entry points to use a structure of
entry points instead of descrete function pointers, and
extend this to include a "reset" entry point. Make sure
any PHY-specific reset routine is always used.

From NetBSD

ok mcbride@


Revision tags: OPENBSD_3_6_BASE
# 1.17 03-Aug-2004 brad

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.

From NetBSD


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.16 28-Apr-2004 mcbride

Make carp(4) aware of its physical interface:
- If the physical interface goes down or the link goes down,
the carp interface goes down as well.
- We treat this like the preemption holdoff with pfsync.
So if one of the carp interfaces is known to be bad (because the
physical interface it's associated with is bad), all the other carp
interfaces back off: they won't preempt, and their advskew goes to 240.

ok cedric@


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.15 11-Mar-2003 jason

- Fill in the mm_gtcr column (not currently used)
- fill in the last few rows to avoid a crash on some devices


# 1.14 26-Nov-2002 nate

1000baseTX -> 1000baseT
- More technically correct
- Matches FreeBSD and NetBSD
- Preserved #define for 1000baseTX for backwards compatibility
ok jason@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.13 04-May-2002 fgsch

some space and tab cleanup.


Revision tags: OPENBSD_3_1_BASE
# 1.12 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.11 05-Oct-2001 nate

branches: 1.11.4;
Differentiate between 1000baseT and 1000baseX.
Add some support for gigabit control/status regs.


# 1.10 25-Jun-2001 nate

Change autonegotiation timeout for devices with a gigabit phy to 10s. All
other devices default to 5 seconds. ok deraadt. from NetBSD.


# 1.9 08-Jun-2001 nate

Add some general support info for gigabit phys
Fix some comments
Remove some dead code
From NetBSD


# 1.8 03-May-2001 aaron

Add an MIIF_AUTOTSLEEP flag, needed by new aue(4) code. From NetBSD.


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.7 12-Oct-2000 aaron

Don't mix usage of old and new timeout code.


# 1.6 28-Aug-2000 jason

hush


# 1.5 26-Aug-2000 nate

sync mii code with netbsd
adds detach functionality for phys
some code cleanup

Nobody really had time to test all of this out, but theo said commit anyway


# 1.4 30-Jun-2000 art

Convert to new timeouts.


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.3 07-Dec-1999 jason

branches: 1.3.2;
Merge with NetBSD:
o 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
o Clean up the code that adds media a little, and make media selection
table-driven in preparation for some other changes to be made.
o Don't add any loopback versions of media, for now.
o 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.
o Add OUI for Enable Semiconductor.
o New Driver for TDK TSC78Q2120 PHY


Revision tags: OPENBSD_2_6_BASE
# 1.2 16-Jul-1999 jason

Sync with NetBSD:
o 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.
o Correct the sense of the PCR_FLINK100 bit in nsphy.c.


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Nov-1998 jason

Merge with NetBSD:
o additional phy drivers (seeq, ics, level1)
o "unknown phy" driver for unsupported phys
o collected common code into mii_physubr
o exphy isn't the only phy that doesn't have valid id registers


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.45 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.44 05-Dec-2014 mpi

Explicitly include <net/if_var.h> instead of pulling it in <net/if.h>.

ok mikeb@, krw@, bluhm@, tedu@


# 1.43 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.42 28-Dec-2013 deraadt

mii drivers no longer need activate functions. Repair of the PHY
configuration setting is done at resume time because all networks
drivers which were previously up, do an IFF_UP operation which
hits PHY_RESET.
This was in snapshots for about 2 weeks.


Revision tags: OPENBSD_5_4_BASE
# 1.41 25-Jun-2013 brad

Remove unsigned comparison < 0.

Pointed out by LLVM.

ok mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.40 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.39 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


# 1.38 02-Aug-2009 miod

Never return nonzero in a device activate method invoked with DVACT_ACTIVATE,
for this prevents it to be invoked with DVACT_DEACTIVATE later. This had
been sweeped some time ago already, but bad constructs crept in again.


# 1.37 31-Jul-2009 blambert

timeout_add -> timeout_add_msec

ok art@


# 1.36 22-Jul-2009 sthen

comment fix from Brad; OpenBSD's mii_phy_add_media() does not print
the media names like NetBSD does.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.35 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.34 13-May-2008 brad

Since Ethernet links can only be full duplex or half duplex the link
state reporting code in the MII layer / em(4) and vge(4) will never
fall back to the point of only reporting the link as being UP without
the duplex setting being reported, so simplify the code a bit here.

ok dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.33 17-Sep-2007 brad

- Use a 64-bit int for the baudrate within the ifmedia_baudrate struct and
return a 64-bit int for ifmedia_baudrate().
- Fix consumers of ifmedia_baudrate() to deal with the change.

ok claudio@ dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 10-Feb-2007 kettenis

Use right flow control autonegotiation bits for 1000baseX.


# 1.31 30-Dec-2006 kettenis

Make mii_phy_auto() advertise flow control if MIIF_DOPAUSE is set.

ok jsg@, brad@


# 1.30 28-Dec-2006 kettenis

Add function to detect flow control status. From NetBSD.

ok brad@


# 1.29 15-Dec-2006 reyk

use mii_media_active instead of mii_media_status to get the full
duplex state. this will actually enable duplex reporting for drivers
using the mii layer.

figured out by Moritz Grimm with sk(4)


# 1.28 28-Nov-2006 reyk

add additional link states to report the half duplex / full duplex
state, if known by the driver. this is required to check the full
duplex state without depending on the ifmedia ioctl which can't be
called in the kernel without process context.

ok henning@, brad@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.27 06-Nov-2005 brad

correctly track the falling edge of a media state change in mii_phy_tick().


Revision tags: OPENBSD_3_8_BASE
# 1.26 26-Mar-2005 krw

Cleanup. Use defines, standard names, consistant comparison operators, etc.
for auto negotiation ticks code. No functional change.

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.25 07-Feb-2005 mcbride

Use new if_link_state_change() instead of sending route message and notifying
carp directly.

ok brad@ mpf@


# 1.24 16-Dec-2004 brad

Make sure ifp->if_baudrate is valid when the parent's statchg
callback is made.

From NetBSD


# 1.23 08-Dec-2004 mcbride

Check if_type in carp_carpdev_state() to make sure we're not
dealing with a carp interface.


# 1.22 18-Nov-2004 brad

add mii_phy_match() for table-driven lookup.

From NetBSD


# 1.21 09-Oct-2004 brad

Allow a little time for the reset to settle in before we start polling
the BMCR again. The DP83840A manual states that there should be a 500us delay
between asserting software reset and attempting MII serial operations.

From NetBSD

ok mcbride@


# 1.20 09-Oct-2004 brad

add master flag support for 1000baseT and autonegotiation support for 1000baseX.

From NetBSD

ok mcbride@


# 1.19 27-Sep-2004 brad

ANSI protos and some minor cleanup

ok henning@


# 1.18 26-Sep-2004 brad

Restructure the PHY entry points to use a structure of
entry points instead of descrete function pointers, and
extend this to include a "reset" entry point. Make sure
any PHY-specific reset routine is always used.

From NetBSD

ok mcbride@


Revision tags: OPENBSD_3_6_BASE
# 1.17 03-Aug-2004 brad

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.

From NetBSD


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.16 28-Apr-2004 mcbride

Make carp(4) aware of its physical interface:
- If the physical interface goes down or the link goes down,
the carp interface goes down as well.
- We treat this like the preemption holdoff with pfsync.
So if one of the carp interfaces is known to be bad (because the
physical interface it's associated with is bad), all the other carp
interfaces back off: they won't preempt, and their advskew goes to 240.

ok cedric@


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A
# 1.15 11-Mar-2003 jason

- Fill in the mm_gtcr column (not currently used)
- fill in the last few rows to avoid a crash on some devices


# 1.14 26-Nov-2002 nate

1000baseTX -> 1000baseT
- More technically correct
- Matches FreeBSD and NetBSD
- Preserved #define for 1000baseTX for backwards compatibility
ok jason@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.13 04-May-2002 fgsch

some space and tab cleanup.


Revision tags: OPENBSD_3_1_BASE
# 1.12 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.11 05-Oct-2001 nate

branches: 1.11.4;
Differentiate between 1000baseT and 1000baseX.
Add some support for gigabit control/status regs.


# 1.10 25-Jun-2001 nate

Change autonegotiation timeout for devices with a gigabit phy to 10s. All
other devices default to 5 seconds. ok deraadt. from NetBSD.


# 1.9 08-Jun-2001 nate

Add some general support info for gigabit phys
Fix some comments
Remove some dead code
From NetBSD


# 1.8 03-May-2001 aaron

Add an MIIF_AUTOTSLEEP flag, needed by new aue(4) code. From NetBSD.


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.7 12-Oct-2000 aaron

Don't mix usage of old and new timeout code.


# 1.6 28-Aug-2000 jason

hush


# 1.5 26-Aug-2000 nate

sync mii code with netbsd
adds detach functionality for phys
some code cleanup

Nobody really had time to test all of this out, but theo said commit anyway


# 1.4 30-Jun-2000 art

Convert to new timeouts.


Revision tags: OPENBSD_2_7_BASE SMP_BASE kame_19991208
# 1.3 07-Dec-1999 jason

branches: 1.3.2;
Merge with NetBSD:
o 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
o Clean up the code that adds media a little, and make media selection
table-driven in preparation for some other changes to be made.
o Don't add any loopback versions of media, for now.
o 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.
o Add OUI for Enable Semiconductor.
o New Driver for TDK TSC78Q2120 PHY


Revision tags: OPENBSD_2_6_BASE
# 1.2 16-Jul-1999 jason

Sync with NetBSD:
o 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.
o Correct the sense of the PCR_FLINK100 bit in nsphy.c.


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Nov-1998 jason

Merge with NetBSD:
o additional phy drivers (seeq, ics, level1)
o "unknown phy" driver for unsupported phys
o collected common code into mii_physubr
o exphy isn't the only phy that doesn't have valid id registers