summaryrefslogtreecommitdiff
path: root/sys/dev/dc/dcphy.c
Commit message (Collapse)AuthorAgeFilesLines
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-181-0/+2
| | | | | | | | | | | | | | | | | | | | The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* Introduce a procedural interface to the ifnet structure. The newMarcel Moolenaar2014-06-021-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | interface allows the ifnet structure to be defined as an opaque type in NIC drivers. This then allows the ifnet structure to be changed without a need to change or recompile NIC drivers. Put differently, NIC drivers can be written and compiled once and be used with different network stack implementations, provided of course that those network stack implementations have an API and ABI compatible interface. This commit introduces the 'if_t' type to replace 'struct ifnet *' as the type of a network interface. The 'if_t' type is defined as 'void *' to enable the compiler to perform type conversion to 'struct ifnet *' and vice versa where needed and without warnings. The functions that implement the API are the only functions that need to have an explicit cast. The MII code has been converted to use the driver API to avoid unnecessary code churn. Code churn comes from having to work with both converted and unconverted drivers in correlation with having callback functions that take an interface. By converting the MII code first, the callback functions can be defined so that the compiler will perform the typecasts automatically. As soon as all drivers have been converted, the if_t type can be redefined as needed and the API functions can be fix to not need an explicit cast. The immediate benefactors of this change are: 1. Juniper Networks - The network stack implementation in Junos is entirely different from FreeBSD's one and this change allows Juniper to build "stock" NIC drivers that can be used in combination with both the FreeBSD and Junos stacks. 2. FreeBSD - This change opens the door towards changing ifnet and implementing new features and optimizations in the network stack without it requiring a change in the many NIC drivers FreeBSD has. Submitted by: Anuranjan Shukla <anshukla@juniper.net> Reviewed by: glebius@ Obtained from: Juniper Networks, Inc. Notes: svn path=/head/; revision=266974
* The r48589 promised to remove implicit inclusion of if_var.h soon. PrepareGleb Smirnoff2013-10-261-0/+1
| | | | | | | | | | | to this event, adding if_var.h to files that do need it. Also, include all includes that now are included due to implicit pollution via if_var.h Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=257176
* Use DEVMETHOD_END.Marius Strobl2011-11-231-1/+1
| | | | Notes: svn path=/head/; revision=227908
* There's no need to read DC_10BTSTAT twice in dcphy_status().Marius Strobl2011-11-181-6/+5
| | | | Notes: svn path=/head/; revision=227686
* Remove duplicate header includesKevin Lo2011-06-281-1/+0
| | | | Notes: svn path=/head/; revision=223624
* - Remove attempts to implement setting of BMCR_LOOP/MIIF_NOLOOPMarius Strobl2011-05-031-23/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reporting IFM_LOOP based on BMCR_LOOP is left in place though as it might provide useful for debugging). For most mii(4) drivers it was unclear whether the PHYs driven by them actually support loopback or not. Moreover, typically loopback mode also needs to be activated on the MAC, which none of the Ethernet drivers using mii(4) implements. Given that loopback media has no real use (and obviously hardly had a chance to actually work) besides for driver development (which just loopback mode should be sufficient for though, i.e one doesn't necessary need support for loopback media) support for it is just dropped as both NetBSD and OpenBSD already did quite some time ago. - Let mii_phy_add_media() also announce the support of IFM_NONE. - 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 lxtphy(4) which disables MII interrupts (as is done for a few other PHYs we have drivers for). This includes changing NIC drivers which previously just called the generic mii_phy_reset() to now actually call the PHY-specific reset routine, which might be crucial in some cases. While at it, the redundant checks in these NIC drivers for mii->mii_instance not being zero before calling the reset routines were removed because as soon as one PHY driver attaches mii->mii_instance is incremented and we hardly can end up in their media change callbacks etc if no PHY driver has attached as mii_attach() would have failed in that case and not attach a miibus(4) instance. Consequently, NIC drivers now no longer should call mii_phy_reset() directly, so it was removed from EXPORT_SYMS. - Add a mii_phy_dev_attach() as a companion helper to mii_phy_dev_probe(). The purpose of that function is to perform the common steps to attach a PHY driver instance and to hook it up to the miibus(4) instance and to optionally also handle the probing, addition and initialization of the supported media. So all a PHY driver without any special requirements has to do in its bus attach method is to call mii_phy_dev_attach() along with PHY-specific MIIF_* flags, a pointer to its PHY functions and the add_media set to one. All PHY drivers were updated to take advantage of mii_phy_dev_attach() as appropriate. Along with these changes the capability mask was added to the mii_softc structure so PHY drivers taking advantage of mii_phy_dev_attach() but still handling media on their own do not need to fiddle with the MII attach arguments anyway. - Keep track of the PHY offset in the mii_softc structure. This is done for compatibility with NetBSD/OpenBSD. - Keep track of the PHY's OUI, model and revision in the mii_softc structure. Several PHY drivers require this information also after attaching and previously had to wrap their own softc around mii_softc. NetBSD/OpenBSD also keep track of the model and revision on their mii_softc structure. All PHY drivers were updated to take advantage as appropriate. - Convert the mebers of the MII data structure to unsigned where appropriate. This is partly inspired by NetBSD/OpenBSD. - According to IEEE 802.3-2002 the bits actually have to be reversed when mapping an OUI to the MII ID registers. All PHY drivers and miidevs where changed as necessary. Actually this now again allows to largely share miidevs with NetBSD, which fixed this problem already 9 years ago. Consequently miidevs was synced as far as possible. - Add MIIF_NOMANPAUSE and mii_phy_flowstatus() calls to drivers that weren't explicitly converted to support flow control before. It's unclear whether flow control actually works with these but typically it should and their net behavior should be more correct with these changes in place than without if the MAC driver sets MIIF_DOPAUSE. Obtained from: NetBSD (partially) Reviewed by: yongari (earlier version), silence on arch@ and net@ Notes: svn path=/head/; revision=221407
* - Even after masking the media with IFM_GMASK the result may have bitsMarius Strobl2011-01-141-8/+3
| | | | | | | | | | | | | besides the duplex ones set so just comparing it with IFM_FDX may lead to false negatives. - Just let the default case handle all unsupported media types. - In pnphy_status() don't unnecessarily read a register twice. - Remove unnused macros. MFC after: 1 week Notes: svn path=/head/; revision=217417
* Convert the PHY drivers to honor the mii_flags passed down and convertMarius Strobl2010-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | the NIC drivers as well as the PHY drivers to take advantage of the mii_attach() introduced in r213878 to get rid of certain hacks. For the most part these were: - Artificially limiting miibus_{read,write}reg methods to certain PHY addresses; we now let mii_attach() only probe the PHY at the desired address(es) instead. - PHY drivers setting MIIF_* flags based on the NIC driver they hang off from, partly even based on grabbing and using the softc of the parent; we now pass these flags down from the NIC to the PHY drivers via mii_attach(). This got us rid of all such hacks except those of brgphy() in combination with bce(4) and bge(4), which is way beyond what can be expressed with simple flags. While at it, I took the opportunity to change the NIC drivers to pass up the error returned by mii_attach() (previously by mii_phy_probe()) and unify the error message used in this case where and as appropriate as mii_attach() actually can fail for a number of reasons, not just because of no PHY(s) being present at the expected address(es). This file was missed in r213893. Notes: svn path=/head/; revision=213908
* Consistently always explicitly set IFM_HDX for half-duplex.Marius Strobl2010-10-031-5/+7
| | | | | | | Obtained from: OpenBSD (mostly) Notes: svn path=/head/; revision=213384
* - In the spirit of previous simplifications factor out the checks for aMarius Strobl2010-10-021-21/+1
| | | | | | | | | | | | | | | | | | | | different PHY instance being selected and isolation out into the wrappers around the service methods rather than duplicating them over and over again (besides, a PHY driver shouldn't need to care about which instance it actually is). - Centralize the check for the need to isolate a non-zero PHY instance not supporting isolation in mii_mediachg() and just ignore it rather than panicing, which should sufficient given that a) things are likely to just work anyway if one doesn't plug in more than one port at a time and b) refusing to attach in this case just leaves us in a unknown but most likely also not exactly correct configuration (besides several drivers setting MIIF_NOISOLATE didn't care about these anyway, probably due to setting this flag for no real reason). - Minor fixes like removing unnecessary setting of sc->mii_anegticks, using sc->mii_anegticks instead of hardcoded values etc. Notes: svn path=/head/; revision=213364
* Use the mii_data provided via mii_attach_args and mii_pdata respectivelyMarius Strobl2010-09-271-1/+1
| | | | | | | instead of reaching out for the softc of the parent. Notes: svn path=/head/; revision=213229
* - Set MIIF_NOLOOP and don't add IFM_LOOP as loopback apparently isn'tMarius Strobl2009-03-191-8/+6
| | | | | | | | | | | supported with these pseudo-PHYs. The MIIF_NOLOOP flag currently triggers nothing but hopefully will be respected by mii_phy_setmedia() later on. - Don't add IFM_NONE as isolation isn't supported by these pseudo-PHYs. - Use mii_phy_add_media() instead of mii_add_media() so the latter can be eventually retired. Notes: svn path=/head/; revision=190117
* cosmetic changes and style fixesMarius Strobl2008-09-301-33/+22
| | | | Notes: svn path=/head/; revision=183505
* IEEE 802.3 Annex 28B.3 explicitly specifies the following relativePyun YongHyeon2007-11-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 However PHY drivers didn't honor the order such that 100BASE-T4 had higher priority than 100BASE-TX full duplex. Fix that long standing bugs such that have PHY drivers choose the highest common denominator ability. Fix a bug in dcphy which inadvertently aceepts 100BASE-T4. PR: 92599 Notes: svn path=/head/; revision=173665
* Replace hard-coded magic constants to system defined constantsPyun YongHyeon2006-08-021-1/+1
| | | | | | | | | (BUS_PROBE_DEFAULT, BUS_PROBE_GENERIC etc). These pseudo PHY drivers were forgotten from the conversion due to the repo copy to dc driver location. Notes: svn path=/head/; revision=160907
* Use PCI bus accessors rather than reading config registers directly toJohn Baldwin2006-06-031-2/+3
| | | | | | | get the subvendor device id. Notes: svn path=/head/; revision=159201
* Make dc compile after repo-copy.Warner Losh2005-10-181-1/+1
| | | | Notes: svn path=/head/; revision=151435
* Use ansi function definitions in preference to K&R to reduce diffsWarner Losh2005-09-301-14/+6
| | | | | | | with NetBSD (and cause it looks cooler). Notes: svn path=/head/; revision=150763
* Remove bus_{mem,p}io.h and related code for a micro-optimization on i386Yoshihiro Takahashi2005-05-291-2/+0
| | | | | | | | | and amd64. The optimization is a trivial on recent machines. Reviewed by: -arch (imp, marcel, dfr) Notes: svn path=/head/; revision=146734
* Start each of the license/copyright comments with /*-, minor shuffle of linesWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139749
* Spelling fix in a comment.Marius Strobl2004-05-291-1/+1
| | | | Notes: svn path=/head/; revision=129845
* Remove double __FBSDID and move the remaining one into a common place afterMarius Strobl2004-05-291-3/+0
| | | | | | | | the license(s) and before the driver comment (the latter only in drivers not having __FBSDID at that location). Notes: svn path=/head/; revision=129844
* Correct the phy_service() routine case MII_TICK to correctly trackAndre Oppermann2004-05-031-1/+1
| | | | | | | | | | | | | the falling edge of a media state change. This is in preparation for media state change notification to the routing socket. No objections by: sam, wpaul, ru, bms Brucification by: bde Notes: svn path=/head/; revision=128870
* Use __FBSDID().David E. O'Brien2003-08-241-0/+3
| | | | | | | Also some minor style cleanups. Notes: svn path=/head/; revision=119418
* Prefer new location of pci include files (which have only been in theWarner Losh2003-08-221-1/+1
| | | | | | | | tree for two or more years now), except in a few places where there's code to be compatible with older versions of FreeBSD. Notes: svn path=/head/; revision=119285
* Remove unnecessary breaks.Poul-Henning Kamp2003-05-311-1/+0
| | | | | | | | | | Remove unused variables. Add XXX comment where a break may be missing. [lxtphy.c] Found by: FlexeLint Notes: svn path=/head/; revision=115520
* Use __FBSDID rather than rcsid[].David E. O'Brien2003-04-031-7/+3
| | | | Notes: svn path=/head/; revision=113038
* Remove miidevs.h and generate it from miidevs at compile time.David E. O'Brien2003-01-191-1/+1
| | | | | | | The devlist2h.awk tool to do this has been repocopied to sys/tools/. Notes: svn path=/head/; revision=109514
* Put function return types on a line by themselves.Alfred Perlstein2002-10-141-4/+6
| | | | | | | | Cleanup my earlier de-__P sweep and remove whitespace between function names and paramters. Notes: svn path=/head/; revision=105135
* Clean up mii/phy drivers: Remove the MIIF_DOINGAUTO which doesn't reallyPoul-Henning Kamp2002-05-041-45/+14
| | | | | | | | do anything at the end of the day except bloat the drivers which has copy&pasted it. Notes: svn path=/head/; revision=96026
* Make one generic mii_phy_detach() to replace 19 slightly different ones.Poul-Henning Kamp2002-04-291-16/+1
| | | | | | | | | | Rename mii_phy_auto_stop() mii_phy_down(). Introduce mii_down(), use it from nge. Do not indirect it to 19 identical case's in 19 switchstatements like NetBSD did. Notes: svn path=/head/; revision=95722
* Don't pass three args when one will do just fine, and even preventPoul-Henning Kamp2002-04-281-1/+1
| | | | | | | mistakes like the one brgphy.c (now corrected). Notes: svn path=/head/; revision=95667
* Improve an API by about 4 lines per driver.Poul-Henning Kamp2002-04-281-4/+1
| | | | Notes: svn path=/head/; revision=95665
* Work around an Intel 21143 chip bug.Stephen McKay2002-04-181-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rev 1.56 of if_dc.c removed calls to mii_pollstat() from the dc_tick() routine. dc_tick() is called regularly to detect link up and link down status, especially when autonegotiating. The expectation was that mii_tick() (which is still called from dc_tick()) would update status information automatically in all cases where it would be sensible to do so. Unfortunately, with authentic 21143 chips this is not the case, and the driver never successfully autonegotiates. This is because (despite what it says in the 21143 manual) the chip always claims that link is not present while the autonegotiation enable bit is set. Autonegotation takes place and succeeds, but the driver tests the link bits before it switches off the autonegotiation enable bit, and success is not recognised. The simplest solution is to call dcphy_status() more often for MII_TICK calls by dropping out of the switch statement instead of exiting when we are autonegotiating and link appears to not be present. When autonegotiation succeeds, dcphy_status() will note the speed and fdx/hdx state and turn off the autonegotiation enable bit. The next call to dcphy_status() will notice that link is present, and the dc driver code will be notified. Macronix chips also use this code, but implement link detection as described in the manual, and hence don't need this patch. However, tests on a Macronix 98715AEC-C show that it does not adversely affect them. This could be done better but is the minimal effective change, and most closely mimics what was happening prior to rev 1.56 of if_dc.c. (Actually I also deleted a small amount of unnecessary code while I was in the area.) Reviewed by: wpaul Notes: svn path=/head/; revision=94994
* Remove __P.Alfred Perlstein2002-03-201-7/+7
| | | | Notes: svn path=/head/; revision=92739
* Cleanup pass for mii drivers.Jonathan Lemon2001-09-291-16/+13
| | | | | | | | | | . Make internal service routines static. . Use a consistent ordering of checks in MII_TICK. Do the work in the mii_phy_tick() subroutine if appropriate. . Call mii_phy_update() to trigger the callbacks. Notes: svn path=/head/; revision=84145
* Catch up to header include changes:John Baldwin2001-03-281-0/+1
| | | | | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h> Notes: svn path=/head/; revision=74914
* Catch up to moving headers:John Baldwin2000-10-201-1/+1
| | | | | | | | - machine/ipl.h -> sys/ipl.h - machine/mutex.h -> sys/mutex.h Notes: svn path=/head/; revision=67365
* Remove unneeded #include <machine/clock.h>Poul-Henning Kamp2000-10-151-1/+0
| | | | Notes: svn path=/head/; revision=67164
* Add #include <machine/mutex.h> since these files need it and don'tBill Paul2000-10-131-0/+1
| | | | | | | | include anything else that includes mutex.h. Needed to resolve struct mtx from struct dc_softc. Notes: svn path=/head/; revision=67091
* Add support for parsing the media blocks from the SROM on 21143Bill Paul2000-10-051-9/+15
| | | | | | | | | | | | | adapters. This is necessary in order to make this driver work with the built-in ethernet on the alpha Miata machines. These systems have a 21143-PC chip on-board and optional daughtercards with either a 10/100 MII transceiver or a 10baseT/10base2 transceiver. In both cases, you need to twiddle the GPIO bits on the controller in order to turn the transceivers on, and you have to read the media info from the SROM in order to find out what bits to twiddle. Notes: svn path=/head/; revision=66681
* Don't bother checking the link state in dcphy_status() if the interfaceBill Paul2000-06-051-0/+3
| | | | | | | isn't up. Notes: svn path=/head/; revision=61290
* Rework the support for the internal autonegotiation on the 21143 andBill Paul2000-05-311-60/+23
| | | | | | | | | | | | | | | | | | | | | workalike chips (Macronix 98713A/98715 and PNIC II). Timing is somewhat critical: you need to bring the link as soon as possible after NWAY is done, and the old one second polling interval was too long. Now we poll every 10th of a second until NWAY completes (at which point we return to the 1 second interval again to keep an eye on the link state). I tested all the other cards I had on hand to make sure I didn't bust any of them and they seem to work (including the MII-based 21143 card). This should fix some autoneg problems with DE500-BA cards and the built-in 10/100 ethernet on some alpha systems. (Now before anyone asks why I never noticed this before, the old code worked just find with the Intel swich I used for testing back in NY. Apparently not all switches are as picky about the timing.) Notes: svn path=/head/; revision=61110
* Remove ~25 unneeded #include <sys/conf.h>Poul-Henning Kamp2000-04-191-1/+0
| | | | | | | Remove ~60 unneeded #include <sys/malloc.h> Notes: svn path=/head/; revision=59391
* Fix some problems reported by Mike Pritchard:Bill Paul1999-12-131-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add a flag DC_TX_INTR_ALWAYS which causes the transmit code to request a TX done interrupt for every packet. The PNIC seems to need this to insure that the sent TX buffers get reaped in a timely fashion. - Try to unreset the SIA as soon as possible after resetting the whole chip. - Change dcphy to support either 10/100 or 10Mbps only NICs. The built-in 21143 ethernet in Compaq Presario machines is 10Mbps only and it doesn't work right if we try to advertise 100Mbps modes during autoneg. When restricted to only 10mbps modes, it works fine. Note that for now, I detect this condition by checking the PCI subsystem ID on this NIC (which has a Compaq vendor/device ID). Yes, I know that's what the SROM is supposed to be for. I'm deliberately ignoring the SROM wherever possible. Sue me. The latter two fixes allow if_dc to work correctly with the built-in ethernet on certain Compaq Presario boxes. There are liable to be quite a few people using these as their home systems who might want to try FreeBSD; may as well be nice to them. Now if anybody out there has an Alpha miata with 10Mbps ethernet and can show me the output from pciconf -l on their system, I'd be grateful. Notes: svn path=/head/; revision=54577
* Add the if_dc driver and remove all of the al, ax, dm, pn and mx driversBill Paul1999-12-041-0/+528
which it replaces. The new driver supports all of the chips supported by the ones it replaces, as well as many DEC/Intel 21143 10/100 cards. This also completes my quest to convert things to miibus and add Alpha support. Notes: svn path=/head/; revision=54134