Home | History | Annotate | Download | only in mii
History log of /src/sys/dev/mii/ukphy_subr.c
RevisionDateAuthorComments
 1.17  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.16  24-Oct-2019  msaitoh Fix a bug that ukphy_status() misunderstand master mode.
 1.15  25-Mar-2019  msaitoh branches: 1.15.4;
KNF. No functional change.
 1.14  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.13  16-Jun-2014  msaitoh branches: 1.13.20; 1.13.26; 1.13.28;
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.12  16-Jun-2014  msaitoh No functional change:
- Fix typo.
- Remove trailing white spaces.
- Capitalize comments.
- Tabify.
- KNF.
 1.11  16-Feb-2009  cegger branches: 1.11.18; 1.11.22; 1.11.36;
fix media priorities:

IEEE 802.3 Annex 28B.3 specifies the following relative
priorities of the technologies supported by
802.3 Selector Field value:

1000BASE-T full duplex
1000BASE-T
100BASE-T2 full duplex
100BASE-TX full duplex
100BASE-T2
100BASE-T4
100BASE-TX
10BASE-T full duplex
10BAST-T

Our drivers give 100BASE-T4 a higher priority than
100BASE-TX full duplex.
Fix this. This patch is based on changes in FreeBSD and OpenBSD.

Patch presented on tech-kern and tech-net:
http://mail-index.netbsd.org/tech-kern/2009/02/15/msg004397.html
http://mail-index.netbsd.org/tech-net/2009/02/15/msg001064.html

got no comments, no objections.
 1.10  28-Apr-2008  martin branches: 1.10.8; 1.10.10; 1.10.14; 1.10.18;
Remove clause 3 and 4 from TNF licenses
 1.9  11-Dec-2005  christos branches: 1.9.70; 1.9.72; 1.9.74;
merge ktrace-lwp.
 1.8  17-May-2004  thorpej If the PHY has 1000BASE-T capability, check to see if a 1000BASE-T speed
was negotiated, and check if we ended up mastering the clock if so.
 1.7  16-May-2004  thorpej Get flow control negotiation status.
 1.6  03-Jul-2002  simonb branches: 1.6.6; 1.6.8;
Don't include <malloc.h> - no memory management style functions are use
in any of the MII drivers.
 1.5  13-Nov-2001  lukem branches: 1.5.8;
add RCSID
 1.4  25-Aug-2001  thorpej ANSI'ify.
 1.3  03-Nov-1999  thorpej branches: 1.3.6; 1.3.8;
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.2  05-Nov-1998  thorpej branches: 1.2.12; 1.2.14; 1.2.18;
Common code for media-from-bmcr.
 1.1  04-Nov-1998  thorpej Routines common between the Uknown PHY driver (forthcoming) and other
PHY drivers. This file has ukphy_status(), which is what PHY drivers
should use if media detection is done by decoding NWay.
 1.2.18.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.14.1  15-Nov-1999  fvdl Sync with -current
 1.2.12.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.3.8.3  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.8.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.8.1  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.3.6.3  01-Aug-2002  nathanw Catch up to -current.
 1.3.6.2  14-Nov-2001  nathanw Catch up to -current.
 1.3.6.1  21-Sep-2001  nathanw Catch up to -current.
 1.5.8.1  15-Jul-2002  gehenna catch up with -current.
 1.6.8.1  12-Aug-2004  jmc Pullup patch (requested by toshii in ticket #743)

If the PHY has 1000BASE-T capability, check to see if a 1000BASE-T speed
was negotiated, and check if we ended up mastering the clock if so.
 1.6.6.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2  18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1  03-Aug-2004  skrll Sync with HEAD
 1.9.74.2  04-May-2009  yamt sync with head.
 1.9.74.1  16-May-2008  yamt sync with head.
 1.9.72.1  18-May-2008  yamt sync with head.
 1.9.70.1  02-Jun-2008  mjf Sync with HEAD.
 1.10.18.1  21-Apr-2010  matt sync to netbsd-5
 1.10.14.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.10.1  01-May-2009  snj Pull up following revision(s) (requested by cegger in ticket #474):
sys/dev/mii/inphy.c: revision 1.51
sys/dev/mii/iophy.c: revision 1.35
sys/dev/mii/nsphy.c: revision 1.56
sys/dev/mii/rlphy.c: revision 1.25
sys/dev/mii/ukphy_subr.c: revision 1.11
sys/dev/pci/if_txp.c: revision 1.28
fix media priorities:
IEEE 802.3 Annex 28B.3 specifies the following relative
priorities of the technologies supported by
802.3 Selector Field value:
1000BASE-T full duplex
1000BASE-T
100BASE-T2 full duplex
100BASE-TX full duplex
100BASE-T2
100BASE-T4
100BASE-TX
10BASE-T full duplex
10BAST-T
Our drivers give 100BASE-T4 a higher priority than
100BASE-TX full duplex.
Fix this. This patch is based on changes in FreeBSD and OpenBSD.
Patch presented on tech-kern and tech-net:
http://mail-index.netbsd.org/tech-kern/2009/02/15/msg004397.html
http://mail-index.netbsd.org/tech-net/2009/02/15/msg001064.html
got no comments, no objections.
 1.10.8.1  03-Mar-2009  skrll Sync with HEAD.
 1.11.36.1  10-Aug-2014  tls Rebase.
 1.11.22.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.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.13.28.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.28.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.13.28.1  10-Jun-2019  christos Sync with HEAD
 1.13.26.1  26-Jan-2019  pgoyette Sync with HEAD
 1.13.20.1  06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1426):

sys/dev/mii/ukphy_subr.c: revision 1.16

Fix a bug that ukphy_status() misunderstand master mode.
 1.15.4.1  06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #402):

sys/dev/mii/ukphy_subr.c: revision 1.16

Fix a bug that ukphy_status() misunderstand master mode.

RSS XML Feed