summaryrefslogtreecommitdiff
path: root/sys/dev/mii/inphy.c
AgeCommit message (Collapse)Author
2020-03-15Define and implement a locking protocol for the ifmedia / mii layers:thorpej
- 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.
2019-11-27- Simplify sc->mii_anegticks setting. Same as FreeBSD.msaitoh
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().
2019-03-25 KNF. No functional change.msaitoh
2019-02-24use a macro to tidy up the phydesc array initialization, from FreeBSDchristos
2019-01-22 Change MII PHY read/write API from:msaitoh
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
2016-11-08Set mii_mpd_{oui,model,rev}.msaitoh
2016-07-07KNF. Remove extra spaces. No functional change.msaitoh
2014-06-16 IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not fullmsaitoh
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set, but not for others. Same as {Free|Open}BSD.
2009-10-19Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsenbouyer
for the booring work !
2009-02-16fix media priorities:cegger
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.
2009-01-18The PCI revision numbers are unique to a PCI vendor/productmrg
ID pair. Misuse of the revision numbers was causing some of the chip features to be disabled on some integrated Intel chips. So, move the determination of the features into the bus frontend, where the vendor/product ID is known. (Note: sc_rev should be removed. The microcode patch stuff is also busted and needs to be fixed.) Also, poll the actual flow control status in inphy, rather than making assumptions. contributed anonymously.
2008-11-17Reduce code duplication: most PHY drivers call mii_phy_add_media()dyoung
when they attach to the device tree, so call pmf_device_register(9) once there instead of once in more than twenty drivers.
2008-05-04device_t/softc split for all mii(4) devices, and other relatedxtraeme
cosmetic changes.
2008-04-28Remove clause 3 and 4 from TNF licensesmartin
2008-04-08use aprint_*_dev and device_xnamecegger
2007-12-29Remove the device_is_active() check from each individual PHY'sdyoung
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.
2007-12-09Merge jmcneill-pm branch.jmcneill
2006-11-16- don't hardcode 5, 10 define and use MII_ANEGTICKS{,_GIGE}christos
- instead of != limit, use <= limit (conservative)
2006-11-16__unused removal on arguments; approved by core.christos
2006-10-12- sprinkle __unused on function decls.christos
- fix a couple of unused bugs - no more -Wno-unused for i386
2006-09-27Add support for 82562G.cube
2006-03-29Use device_private().thorpej
2006-02-20Use device_is_active() rather than testing dv_flags for DVF_ACTIVEthorpej
directly.
2005-12-11merge ktrace-lwp.christos
2004-08-23Make use of static.thorpej
2003-04-29Use aprint*().thorpej
2003-03-27Before checking the (Intel specific) SCR_T4 register, makedrochner
sure the chip implements 100T4 (in BMSR). The 82562 (which doesn't implement 100T4) has the SCR_T4 bit (always?) set, which led to wrong media status reports. approved by thorpej
2003-03-07Fix C&P tpyo.matt
2003-03-06Make the intel phy match the i82562 phys.matt
2002-10-02Add trailing ; to CFATTACH_DECL.thorpej
2002-09-30Use CFATTACH_DECL().thorpej
2002-09-27Declare all cfattach structures const.thorpej
2002-07-03Don't include <malloc.h> - no memory management style functions are usesimonb
in any of the MII drivers.
2002-03-25Get flags passed down to PHY drivers correctly. This was done onthorpej
an adhoc basis in a couple of PHY drivers, this fixes it more generally. Per a discussion w/ Cliff Neighbors <cliff@allegronetworks.com>.
2001-11-13add RCSIDlukem
2001-08-25ANSI'ify.thorpej
2001-08-06Advertize pause capability (802.3x flow control) to peer.enami
2001-06-02Make PHY matching all table-driven.thorpej
2001-05-31Make the number of ticks between auto-negotiation tries PHY-specific,thorpej
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.
2001-03-28update for miidevs changesdrochner
2000-07-04Restructure the PHY entry points to use a structure of entry pointsthorpej
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).
2000-03-06Factor out the tick handling code into a common function, and sendthorpej
rt_ifmsg's when the link speed or link status changes.
2000-02-02Let mii_phy_setmedia() handle the IFM_AUTO case, too.thorpej
2000-02-02Make PHY drivers provide a pointer to their status routine, and addthorpej
a generic mii_phy_status() that calls back into the PHY. It doesn't do anything interesting yet, but it will soon.
2000-02-02Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, passthorpej
flags down from the parent to child vi mii_attach().
2000-02-02Bring some order to the chaos which was the MII code function namingthorpej
"conventions".
2000-01-27Add detachment support to the MII layer.thorpej
1999-11-12Add mii_down(), which is used by MAC drivers to inform PHYs that thethorpej
interface is now down. PHYs use this to cancel pending asynchronous operations.
1999-11-03Clean up the code that adds media a little, and make media selectionthorpej
table-driven in preparation for some other changes to be made.
1999-04-23Implement asynchronous autonegotiation when driven by the MII tickthorpej
(one-second clock). Prevents .5s delays every 5 seconds when the interface is up but there is no link. Fixes PR 7361.