Home | History | Annotate | Download | only in mii
History log of /src/sys/dev/mii/ciphy.c
RevisionDateAuthorComments
 1.42  22-Feb-2023  msaitoh Retry autonegotiation every mii_anegticks seconds instead of mii_anegticks+1.
 1.41  24-Aug-2020  msaitoh branches: 1.41.20;
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.40  07-Jul-2020  msaitoh - Remove the waitfor argument from mii_phy_auto().
- Whitespace fix.
 1.39  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.38  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.37  17-Oct-2019  msaitoh - Match a lot of Cicada and Vitesse devices correctly. This change also fixes
a bug that ciphy_fixup() didn't work.
- Match VSC8221, VSC8234 and VSC8641.
 1.36  11-Oct-2019  msaitoh Call mii_phy_flowstatus() to show the flow setting.
 1.35  11-Oct-2019  msaitoh - Indicat master mode if the negotiated result say so.
- KNF
 1.34  11-Apr-2019  msaitoh branches: 1.34.4;
KNF. No functional change.
 1.33  11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set. Same as a part of
FreeBSD r217413.
 1.32  25-Mar-2019  msaitoh KNF. No functional change.
 1.31  24-Feb-2019  christos use a macro to tidy up the phydesc array initialization, from FreeBSD
 1.30  13-Feb-2019  msaitoh Add CS8204, CS8244 VSC8211 and VSC8601 support from {Free,Open}BSD.
 1.29  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.28  16-Jan-2019  msaitoh CIPHY_MII_BMCR -> MII_BMCR in #ifdef foo.
 1.27  16-Jan-2019  msaitoh The register bit definitions from register 0 to 15 in ciphyreg.h conform to
the 802.3 spec, so remove them and use mii.h's definition.
No functional change.
 1.26  07-Jul-2016  msaitoh branches: 1.26.10; 1.26.16; 1.26.18;
KNF. Remove extra spaces. No functional change.
 1.25  16-Jun-2014  msaitoh branches: 1.25.4;
IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.24  11-Jun-2013  msaitoh branches: 1.24.6;
Update link status quickly. This change is a part of mii_physubr.c rev.
1.77-1.78.
 1.23  09-Jun-2013  msaitoh Update link status quickly. This change is a part of FreeBSD's mii_physubr.c
r158649.
 1.22  09-Jun-2013  msaitoh ciphy is gigabit PHY, so use MII_ANEGTICKS_GIGE instead of MII_ANEGTICKS.
 1.21  09-Jun-2013  msaitoh atphy, ciphy, ihphy and rgephy are gigabit PHY, so not only check IFM_AUTO
for autonegotiation but also check IFM_1000_T, too.
 1.20  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.19  12-May-2009  cegger branches: 1.19.12; 1.19.18; 1.19.22;
struct device * -> device_t, no functional changes intended.
 1.18  12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.17  14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.16  17-Nov-2008  dyoung branches: 1.16.4;
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.15  04-May-2008  xtraeme branches: 1.15.6; 1.15.8;
device_t/softc split for all mii(4) devices, and other related
cosmetic changes.
 1.14  08-Apr-2008  cegger branches: 1.14.2; 1.14.4;
use aprint_*_dev and device_xname
 1.13  09-Dec-2007  jmcneill branches: 1.13.10;
Merge jmcneill-pm branch.
 1.12  19-Oct-2007  ad branches: 1.12.4; 1.12.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11  26-Nov-2006  tsutsui branches: 1.11.8; 1.11.22; 1.11.24; 1.11.28;
Include <sys/device.h> for struct device.
 1.10  16-Nov-2006  christos - don't hardcode 5, 10 define and use MII_ANEGTICKS{,_GIGE}
- instead of != limit, use <= limit (conservative)
 1.9  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.8  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.7  14-May-2006  elad branches: 1.7.8; 1.7.10;
integrate kauth.
 1.6  29-Mar-2006  thorpej Use device_private().
 1.5  12-Mar-2006  chs branches: 1.5.2;
from OpenBSD:
We need to special case ciphy to ask for RGMII interface at 2.5V for nfe.
This makes Cicada/Vitesse PHYs attached to nfe work.
Many thanks to Bill Paul for diagnosing the problem and suggesting a solution.
 1.4  01-Dec-2005  riz branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10;
Match all model numbers with both Cicada OUIs; this allows the proper PHY to
attach on my ZyXEL GN650-T.
 1.3  16-Mar-2005  briggs branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
Changes to match xxCICADA 8201B found in a VT6122.
Match at > 1 (10) to ensure we get ciphy instead of ukphy.
Use aprint(9) on attach.
Minor stylistic changes.
All from Tomokazu HARADA in PR kern/29705.
 1.2  27-Feb-2005  perry branches: 1.2.2;
nuke trailing whitespace
 1.1  20-Feb-2005  jdolecek Add driver for 10/100/1000 copper PHY integrated on VIA Networking Technologies
VT6122 gigabit ethernet chips

From FreeBSD
 1.2.2.4  11-Dec-2005  christos Sync with head.
 1.2.2.3  01-Apr-2005  skrll Sync with HEAD.
 1.2.2.2  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.1  27-Feb-2005  skrll file ciphy.c was added on branch ktrace-lwp on 2005-03-04 16:44:57 +0000
 1.3.8.4  21-Jan-2008  yamt sync with head
 1.3.8.3  27-Oct-2007  yamt sync with head.
 1.3.8.2  30-Dec-2006  yamt sync with head.
 1.3.8.1  21-Jun-2006  yamt sync with head.
 1.3.6.2  29-Apr-2005  kent sync with -current
 1.3.6.1  16-Mar-2005  kent file ciphy.c was added on branch kent-audio2 on 2005-04-29 11:29:04 +0000
 1.3.4.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.4.1  16-Mar-2005  yamt file ciphy.c was added on branch yamt-km on 2005-03-19 08:34:59 +0000
 1.3.2.1  20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
sys/dev/mii/ciphyreg.h: revision 1.4 via patch
sys/dev/mii/ciphy.c: revision 1.5 via patch
from OpenBSD:
We need to special case ciphy to ask for RGMII interface at 2.5V for nfe.
This makes Cicada/Vitesse PHYs attached to nfe work.
Many thanks to Bill Paul for diagnosing the problem and suggesting a solution.
 1.4.10.1  19-Apr-2006  elad sync with head.
 1.4.8.2  01-Apr-2006  yamt sync with head.
 1.4.8.1  13-Mar-2006  yamt sync with head.
 1.4.6.1  22-Apr-2006  simonb Sync with head.
 1.4.4.1  09-Sep-2006  rpaulo sync with head
 1.5.2.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.7.10.2  10-Dec-2006  yamt sync with head.
 1.7.10.1  22-Oct-2006  yamt sync with head
 1.7.8.2  12-Jan-2007  ad Sync with head.
 1.7.8.1  18-Nov-2006  ad Sync with head.
 1.11.28.1  25-Oct-2007  bouyer Sync with HEAD.
 1.11.24.2  09-Jan-2008  matt sync with HEAD
 1.11.24.1  06-Nov-2007  matt sync with HEAD
 1.11.22.3  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.11.22.2  27-Nov-2007  joerg Register MII PHY drives with the PM framework. Nothing to do on suspend,
just reset the PHY on resume.
 1.11.22.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.8.1  23-Oct-2007  ad Sync with head.
 1.12.6.1  11-Dec-2007  yamt sync with head.
 1.12.4.1  26-Dec-2007  ad Sync with head.
 1.13.10.2  17-Jan-2009  mjf Sync with HEAD.
 1.13.10.1  02-Jun-2008  mjf Sync with HEAD.
 1.14.4.3  16-May-2009  yamt sync with head
 1.14.4.2  04-May-2009  yamt sync with head.
 1.14.4.1  16-May-2008  yamt sync with head.
 1.14.2.1  18-May-2008  yamt sync with head.
 1.15.8.2  28-Apr-2009  skrll Sync with HEAD.
 1.15.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.15.6.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.22.3  03-Dec-2017  jdolecek update from HEAD
 1.19.22.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.22.1  23-Jun-2013  tls resync from head
 1.19.18.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.19.18.1  09-Nov-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #1189):
sys/dev/pci/if_wm.c: revision 1.270
sys/dev/mii/inphy.c: revision 1.53
sys/dev/mii/glxtphy.c: revision 1.24
sys/dev/mii/tlphy.c: revision 1.62
sys/dev/mii/iophy.c: revision 1.37
sys/dev/mii/brgphy.c: revision 1.70
sys/dev/mii/ihphy.c: revision 1.8
sys/dev/mii/bmtphy.c: revision 1.31
sys/dev/mii/urlphy.c: revision 1.30
sys/dev/mii/makphy.c: revision 1.40
sys/dev/mii/qsphy.c: revision 1.48
sys/dev/mii/igphy.c: revision 1.23
sys/dev/mii/nsphy.c: revision 1.58
sys/dev/mii/mvphy.c: revision 1.10
sys/dev/pci/if_txp.c: revision 1.41
sys/dev/mii/nsphy.c: revision 1.59
sys/dev/mii/rlphy.c: revision 1.28
sys/dev/mii/icsphy.c: revision 1.49
sys/dev/mii/rlphy.c: revision 1.29
sys/dev/mii/lxtphy.c: revision 1.49
sys/dev/mii/ciphyreg.h: revision 1.5
sys/dev/mii/nsphyter.c: revision 1.38
sys/dev/mii/sqphy.c: revision 1.50
sys/dev/mii/gentbi.c: revision 1.26
sys/dev/mii/gentbi.c: revision 1.27
sys/dev/mii/tqphy.c: revision 1.39
sys/dev/mii/ikphy.c: revision 1.10
sys/dev/mii/dmphy.c: revision 1.35
sys/dev/mii/amhphy.c: revision 1.20
sys/dev/mii/acphy.c: revision 1.24
sys/dev/mii/ciphy.c: revision 1.25
sys/dev/mii/brgphyreg.h: revision 1.8
sys/dev/mii/ukphy_subr.c: revision 1.12
sys/dev/ic/rtl80x9.c: revision 1.16
sys/arch/mips/adm5120/dev/if_admsw.c: revision 1.12
sys/dev/pci/if_kse.c: revision 1.28
sys/dev/mii/ukphy_subr.c: revision 1.13
sys/dev/mii/mii.h: revision 1.18
sys/dev/mii/gphyter.c: revision 1.29
No functional change:
- Fix typo.
- Remove trailing white spaces.
- Capitalize comments.
- Tabify.
- KNF.
IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.19.12.1  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.24.6.1  10-Aug-2014  tls Rebase.
 1.25.4.1  09-Jul-2016  skrll Sync with HEAD
 1.26.18.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.26.18.1  10-Jun-2019  christos Sync with HEAD
 1.26.16.2  26-Jan-2019  pgoyette Sync with HEAD
 1.26.16.1  18-Jan-2019  pgoyette Synch with HEAD
 1.26.10.3  24-Oct-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/mii/ciphy.c 1.34-1.37 via patch
sys/dev/mii/miidevs 1.158

- Indicate master mode if the negotiated result say so.
- Call mii_phy_flowstatus() to show the flow setting.
- Match a lot of Cicada and Vitesse devices correctly.
- Add support for VSC8221, VSC8234 and VSC8641.
- KNF
 1.26.10.2  01-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1350:

sys/dev/mii/ciphy.c 1.27-1.28, 1.30, 1.32
via patch
sys/dev/mii/ciphyreg.h 1.6

- The register bit definitions from register 0 to 15 in ciphyreg.h
conform to the 802.3 spec, so remove them and use mii.h's definition.
No functional change.
- Add CS8204, CS8244 VSC8211 and VSC8601 support from {Free,Open}BSD.
- KNF.
 1.26.10.1  13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.34.4.3  24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #378):

sys/dev/mii/ciphy.c: revision 1.36

Call mii_phy_flowstatus() to show the flow setting.
 1.34.4.2  23-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #372):

sys/dev/mii/miidevs: revision 1.158
sys/dev/mii/ciphy.c: revision 1.37

- All of Cicada and Vitesse devices' OUI are not bit-reversed, so use "xx".
- Rename CS82xx -> CIS82xx
- Add Vitesse VSC8224, VSC8234, VSC8641 and VSC8501.
- Match a lot of Cicada and Vitesse devices correctly. This change also fixes
a bug that ciphy_fixup() didn't work.
- Match VSC8221, VSC8234 and VSC8641.
 1.34.4.1  17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #347):

sys/dev/mii/ciphy.c: revision 1.35
sys/dev/mii/rgephy.c: revision 1.56
sys/dev/mii/rgephy.c: revision 1.57

Make new rgephy_linkup() function and share it like FreeBSD.
No functional change intended.

- Indicate master mode if the negotiated result say so.
- KNF
 1.41.20.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