Home | History | Annotate | Download | only in mii
History log of /src/sys/dev/mii/miivar.h
RevisionDateAuthorComments
 1.75  14-Aug-2022  riastradh mii(4): Wait for MIIF_DOINGAUTO to clear with MIIF_AUTOTSLEEP too.

Otherwise mii_phy_detach may return while mii_phy_auto_timeout_locked
is still in progress in another thread.

Reuse the storage for mii_nway_ch, which is unused if MIIF_AUTOTSLEEP
is set, for a new condvar in a union. This doesn't change the kernel
ABI because sizeof(struct kcondvar) <= sizeof(struct callout) and
both have the same alignment, for an array of void *.
 1.74  29-Jun-2021  pgoyette Rework the xxxVERBOSE option to share the common module-hook-based
verbose mechanism with MIIVERBOSE. This reduces some duplicated code
and allows us to once again permit auto-unload of MIIVERBOSE.

Change details:
* Update dev/devlist2h.awk to accomodate miidevs, including generation
of MII_STR_oui_model definitions and use of oui and model rather than
vendor and product. This also changes the compressed data in the
xxxdevs_data.h files to uint32_t (since mii oui's are up to 6 hex
digits long)
* Update a couple of phy drivers to use new calls to get verbose data
* Regen all of the xxxdevs{,_data}.h files (separate commit, coming
very soon)
* Update mii/mii_verbose.[ch] and mii/mii_physubr.c to use the various
DEV_VERBOSE_xxx macros
* Update the pci, usb, and hdaudio code as needed, to #include the
xxxdevs.h files (in order to get the proper printf format strings)
* Since dev/dev_verbose.c now uses non-literal printf format strings,
(to deal with the vendor/product vs oui/model issue), we need to
make sure it gets compiled with -Wno-error=format-nonliteral, even
in userland's libpci and librumpdev!
* Bump kernel version for the change in module interfaces

Welcome to 9.99.86!

XXX It might be useful in the future to extend the MII_STR_oui_model
XXX definitions to PCI as well (and perhaps USB and HDAUDIO). This
XXX would allow for a single centralized location for the products'
XXX descriptions, rather than being dispersed among individual
XXX drivers' xxx_match tables.
 1.73  24-Aug-2020  msaitoh branches: 1.73.6;
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.72  07-Jul-2020  msaitoh - Remove the waitfor argument from mii_phy_auto().
- Whitespace fix.
 1.71  25-May-2020  jmcneill Add MIIF_RXID and MIIF_TXID flags to signal that RX or TX delays are required, from OpenBSD.
 1.70  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.69  20-Nov-2019  msaitoh Fix a bug that atphy(4) can't negotiate correctly when the media setting is
neither auto nor 1000baseT. Use correct index for mii_media_table[].

History: mii_anar() is first added in OpenBSD and ported to NetBSD. On NetBSD,
only atphy(4) use this function. mii_physubr.c rev. 1.75 changed mii_anar()
for simplify. It changed the argument from the ifmedia word to ifm_data used
in our MII API, but the caller have not been changed. And then, PR kern/50206
was reported and the caller was modified by me to prevent panic but it was not
correct fix.
 1.68  11-Apr-2019  msaitoh branches: 1.68.4;
KNF. No functional change.
 1.67  09-Apr-2019  msaitoh - Use uint16_t more for MII registers.
- Whitespace.
 1.66  26-Feb-2019  msaitoh Add MI MII clause 45 MMD MDIO access macros via clause 22 indirect registers:

DESCRIPTION
static inline int
MMD_INDIRECT(struct mii_softc *sc, uint16_t daddr, uint16_t regnum):
Setup MMD device address and register number. It also setup
address incrementation function.

static inline int
MMD_INDIRECT_READ(struct mii_softc *sc, uint16_t daddr, uint16_t regnum,
uint16_t *valp)):
Do MMD_INDIRECT() and then read the register.

static inline int
MMD_INDIRECT_WRITE(struct mii_softc *sc, uint16_t daddr, uint16_t regnum,
uint16_t val):
Do MMD_INDIRECT() and then write the register.

RETURN VALUE
Retruns 0 on success. Non-zero vaule on failure.

Note that old PHYs have no indirect access registers. Accessing such
devices with these functions cause timeout and return non-zero value
(e.g. ETIMEDOUT).

EXAMPLE
Read MMD Auto negotiation device's EEE advertisement register,
drop 100BASE-TX support and write it.

uint16_t eeadvert;

/* Post increment is not required */
MMD_INDIRECT_READ(sc, MDIO_MMD_AN | MMDACR_FN_DATA,
MDIO_AN_EEEADVERT, &eeadvert);
eeadvert &= ~AN_EEEADVERT_100_TX;

/*
* MMD device address and the register number are already set, so it's
* enough to read MII_MMDACR.
*/
PHY_WRITE(sc. MII_MMDACR, eeadvert);
 1.65  24-Feb-2019  christos use a macro to tidy up the phydesc array initialization, from FreeBSD
 1.64  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.63  08-Jan-2019  msaitoh s/u_int32_t/uint32_t/
 1.62  28-May-2014  msaitoh branches: 1.62.20; 1.62.26; 1.62.28;
Fix typo in comment.
 1.61  15-Mar-2013  msaitoh branches: 1.61.10;
Add BCM5756, BCM5717C, BCM5719C, BCM5720C and BCM57780.
 1.60  22-Jul-2012  matt branches: 1.60.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.59  30-May-2010  pgoyette branches: 1.59.8; 1.59.14;
Extract MIIVERBOSE into a kernel module. The module can be builtin
by defining 'options MIIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.
 1.58  24-Feb-2010  dyoung branches: 1.58.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.57  08-Jan-2010  dyoung branches: 1.57.2;
Expand PMF_FN_* macros.
 1.56  04-Dec-2009  dyoung Delete unused function mii_activate().
 1.55  12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.54  19-Apr-2009  msaitoh Add mii_mpd_rev to keep MII PHY revision.
 1.53  16-Jan-2009  cegger branches: 1.53.2;
add mii_anar(). From OpenBSD.
 1.52  04-May-2008  xtraeme branches: 1.52.8; 1.52.10;
device_t/softc split for all mii(4) devices, and other related
cosmetic changes.
 1.51  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.50  29-Feb-2008  dyoung branches: 1.50.2; 1.50.4;
Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.49  10-Jan-2008  dyoung branches: 1.49.2; 1.49.6;
Add a helper routine for ethernet drivers, mii_ifmedia_change().

Remove an mii_softc from its mii_data in mii_phy_detach(), not in
mii_detach(), so that we do not leave dangling pointers to a PHY
in an mii_data.
 1.48  09-Dec-2007  jmcneill branches: 1.48.2;
Merge jmcneill-pm branch.
 1.47  16-Nov-2006  christos branches: 1.47.2; 1.47.22; 1.47.24; 1.47.30; 1.47.34; 1.47.36;
- don't hardcode 5, 10 define and use MII_ANEGTICKS{,_GIGE}
- instead of != limit, use <= limit (conservative)
 1.46  25-Mar-2006  thorpej branches: 1.46.8; 1.46.10;
Use device_parent().
 1.45  18-Feb-2006  joerg branches: 1.45.2; 1.45.4; 1.45.6;
Change the link status code in MII to use if_link_state_change instead
of calling rt_ifmsg directly. This allows other parts of the kernel
to change the behaviour depending on the link state and is a
prerequirement for CARP.

Hide mii_phy_statusmsg, mii_phy_update should be used instead.
Don't send routing messages for baudrate changes, if_baudrate is
currently not exported via this interface.

OK tls@
 1.44  11-Dec-2005  christos branches: 1.44.2; 1.44.4; 1.44.6;
merge ktrace-lwp.
 1.43  27-Feb-2005  perry branches: 1.43.4;
nuke trailing whitespace
 1.42  16-Dec-2004  heas branches: 1.42.2; 1.42.4;
Fix a comment.
 1.41  01-Sep-2004  drochner include locators.h from .c only, avoids unnecessary dependencies
 1.40  23-Aug-2004  thorpej De-__P
 1.39  11-Apr-2004  thorpej gmii_phy_getflowcontrol() -> mii_phy_flowstatus(). From HITOSHI Osada.
 1.38  10-Apr-2004  thorpej Flow-control advertisement and parsing support. From HITOSHI Osada.
Slightly modified by me.
 1.37  01-Jul-2003  msaitoh branches: 1.37.2;
- last commit (rev. 1.36) add a entry to keep model number of the PHY in
mii_softc. There are some situations to want to check model number.
- add comment
 1.36  01-Jul-2003  msaitoh Add ICS1889 and 1892
 1.35  20-Feb-2003  matt 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.
Make the gem driver use it. (XXX hme probably should use it but I can't
test that).
 1.34  07-Nov-2002  thorpej Make mii_media_active unsigned.
 1.33  07-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.32  29-Sep-2002  wiz "definitions" has lots of 'i's, but that's not reason to leave one out.
 1.31  10-May-2002  thorpej Make sure ifp->if_baudrate is valid when the parent's statchg
callback is made.

Pointed out by Matt Thomas.
 1.30  25-Mar-2002  thorpej Get flags passed down to PHY drivers correctly. This was done on
an adhoc basis in a couple of PHY drivers, this fixes it more generally.

Per a discussion w/ Cliff Neighbors <cliff@allegronetworks.com>.
 1.29  25-Aug-2001  thorpej Add a flag that indicates that a device is a HomePNA device.
 1.28  27-Jul-2001  thorpej Clean up 1000BASE-SX autonegotiation, and add a way to advertise
PAUSE capability.
 1.27  02-Jun-2001  thorpej branches: 1.27.2;
Make PHY matching all table-driven.
 1.26  31-May-2001  thorpej Enable frobbing the 1000baseT control register on Gig-E PHYs,
used for hard-wiring master mode, and for advertising the 1000baseT
media options during autonegotiation.
 1.25  31-May-2001  thorpej Make the number of ticks between auto-negotiation tries PHY-specific,
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.
 1.24  17-May-2001  drochner re-enable mii_flags in attach args - I've found a use for it: tell the
PHY which support it that a fiber interface is present
 1.23  30-Apr-2001  thorpej Add code to recognize and set media on GMII (Gigabit MII) PHYs.

802.3 doens't specify ANAR or ANLPAR bits for GMII. Need to
use PHY-specific registers for this, for now, which means we
need specific drivers for the Gigabit-capable PHYs (I think the
most common is the BCM5400).
 1.22  13-Apr-2001  augustss Comment out some flag stuff that isn't used. Someone should take a look
at this. There is something fishy with the mii code, the last argument to
mii_attach() is not being used in any meaningful way.
 1.21  13-Apr-2001  augustss Add a flag to mii_flags which will cause autonegotiation to use tsleep()
instead of callout. This way adapters which need a process context for
PHY register access (e.g. USB adapters) have a chance.
 1.20  28-Mar-2001  drochner Reading the IEEE specs shows that the bits have to be reversed when
mapping an OUI to the MII id registers.
Doing this in the MII_OUI() macro would be too complex, so put it into
a helper function and move the MII id register interpretation stuff
into miivar.h.
 1.19  04-Jul-2000  thorpej branches: 1.19.2;
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 the LXT-970 which disables MII
interrupts (as is done for a few other PHYs we have drivers for).
 1.18  23-Mar-2000  thorpej branches: 1.18.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.17  06-Mar-2000  thorpej Factor out the tick handling code into a common function, and send
rt_ifmsg's when the link speed or link status changes.
 1.16  02-Feb-2000  thorpej Make PHY drivers provide a pointer to their status routine, and add
a generic mii_phy_status() that calls back into the PHY. It doesn't
do anything interesting yet, but it will soon.
 1.15  02-Feb-2000  thorpej Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().
 1.14  02-Feb-2000  thorpej Bring some order to the chaos which was the MII code function naming
"conventions".
 1.13  27-Jan-2000  thorpej Add detachment support to the MII layer.
 1.12  12-Nov-1999  thorpej 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.
 1.11  04-Nov-1999  thorpej Allow mii_phy_probe() to be called multiple times, and allow the caller
to specify either the PHY number or the PHY `offset' (1st, 2nd, 3rd, etc.)
to configure.
 1.10  03-Nov-1999  thorpej 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.9  25-Sep-1999  thorpej branches: 1.9.2; 1.9.4; 1.9.8;
Add a PHY `offset' (e.g. "first PHY on bus, second PHY on bus, ...") to
the PHY's softc.
 1.8  23-Apr-1999  thorpej 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. Fixes PR 7361.
 1.7  05-Nov-1998  thorpej branches: 1.7.6;
Common code for media-from-bmcr.
 1.6  05-Nov-1998  thorpej Place the essentially common "ticks" and "active" members into the
mii_softc (generic phy goo), and just switch all of the PHY drivers
(except tlphy, which really does have special stuff) to use an mii_softc
instead of a private one.
 1.5  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.4  04-Nov-1998  thorpej Factor out the common reset code. Use the NOISOLATE flags as appropriate
to prevent a PHY from being isolated in the event the MAC can't deal with
this. (3Com 3c905B-TX, and Intel i82557).
 1.3  04-Nov-1998  thorpej Factor out some common code from all the PHY drivers (autonegotiation, for
now.)
 1.2  04-Nov-1998  thorpej Define and use generic PHY read/write reg macros.
 1.1  10-Aug-1998  thorpej Near complete rewrite of the MII layer to present an interface compatible
with BSDI's MII layer to device drivers.
 1.7.6.1  23-Apr-1999  perry branches: 1.7.6.1.2;
pullup 1.7->1.8 (thorpej): Fix PR7361
 1.7.6.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.9.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.4.1  15-Nov-1999  fvdl Sync with -current
 1.9.2.2  21-Apr-2001  bouyer Sync with HEAD
 1.9.2.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.18.4.1  04-Jul-2000  thorpej Update from trunk:
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 the LXT-970 which disables MII
interrupts (as is done for a few other PHYs we have drivers for).
 1.19.2.8  11-Nov-2002  nathanw Catch up to -current
 1.19.2.7  18-Oct-2002  nathanw Catch up to -current.
 1.19.2.6  20-Jun-2002  nathanw Catch up to -current.
 1.19.2.5  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.19.2.4  21-Sep-2001  nathanw Catch up to -current.
 1.19.2.3  24-Aug-2001  nathanw Catch up with -current.
 1.19.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.19.2.1  09-Apr-2001  nathanw Catch up with -current.
 1.27.2.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.27.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.27.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.27.2.1  03-Aug-2001  lukem update to -current
 1.37.2.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.37.2.6  18-Dec-2004  skrll Sync with HEAD.
 1.37.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.37.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.37.2.3  03-Sep-2004  skrll Sync with HEAD
 1.37.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.37.2.1  03-Aug-2004  skrll Sync with HEAD
 1.42.4.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.42.2.1  29-Apr-2005  kent sync with -current
 1.43.4.4  17-Mar-2008  yamt sync with head.
 1.43.4.3  21-Jan-2008  yamt sync with head
 1.43.4.2  30-Dec-2006  yamt sync with head.
 1.43.4.1  21-Jun-2006  yamt sync with head.
 1.44.6.1  22-Apr-2006  simonb Sync with head.
 1.44.4.1  09-Sep-2006  rpaulo sync with head
 1.44.2.1  01-Mar-2006  yamt sync with head.
 1.45.6.1  28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.45.4.1  19-Apr-2006  elad sync with head.
 1.45.2.1  01-Apr-2006  yamt sync with head.
 1.46.10.1  10-Dec-2006  yamt sync with head.
 1.46.8.1  18-Nov-2006  ad Sync with head.
 1.47.36.1  11-Dec-2007  yamt sync with head.
 1.47.34.1  26-Dec-2007  ad Sync with head.
 1.47.30.1  18-Feb-2008  mjf Sync with HEAD.
 1.47.24.2  23-Mar-2008  matt sync with HEAD
 1.47.24.1  09-Jan-2008  matt sync with HEAD
 1.47.22.1  27-Nov-2007  joerg Register MII PHY drives with the PM framework. Nothing to do on suspend,
just reset the PHY on resume.
 1.47.2.1  18-Aug-2009  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1342):
sys/dev/pci/if_bge.c: revisions 1.135, 1.146, 1.151-1.152,
1.155-1.167 via patch
sys/dev/pci/if_bgereg.h: revisions 1.43, 1.48-1.52
sys/dev/pci/if_bgevar.h: revision 1.1
sys/dev/mii/brgphy.c: revisions 1.36, 1.40, 1.43-1.44 and
1.47-1.48 via patch
sys/dev/mii/brgphyreg.h: revisions 1.3-1.4
sys/dev/mii/miidevs: revisions 1.75, 1.77, 1.85
sys/dev/mii/miidevs.h: regen
sys/dev/mii/miidevs_data.h: regen
sys/dev/mii/miivar.h: revision 1.54
For bge:
- Really set Tx threshold.
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the "link changed" bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
- Add BCM5786 support.
for brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2, BCM5708C, BCM5722, and BCM5906.
 1.48.2.1  10-Jan-2008  bouyer Sync with HEAD
 1.49.6.3  17-Jan-2009  mjf Sync with HEAD.
 1.49.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.49.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.49.2.1  24-Mar-2008  keiichi sync with head.
 1.50.4.5  11-Aug-2010  yamt sync with head.
 1.50.4.4  11-Mar-2010  yamt sync with head
 1.50.4.3  16-May-2009  yamt sync with head
 1.50.4.2  04-May-2009  yamt sync with head.
 1.50.4.1  16-May-2008  yamt sync with head.
 1.50.2.1  18-May-2008  yamt sync with head.
 1.52.10.3  09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.52.10.2  04-Aug-2009  snj Apply patch (requested by msaitoh in ticket #866):
For bge:
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the 'link changed' bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
For brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2 and BCM5722.
 1.52.10.1  23-Apr-2009  snj branches: 1.52.10.1.4;
Pull up following revision(s) (requested by sborrill in ticket #715):
sys/dev/mii/mii_physubr.c: revision 1.62
sys/dev/mii/miivar.h: revision 1.53
add mii_anar(). From OpenBSD.
 1.52.10.1.4.1  21-Apr-2010  matt sync to netbsd-5
 1.52.8.2  28-Apr-2009  skrll Sync with HEAD.
 1.52.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.53.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.57.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.57.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.58.2.1  03-Jul-2010  rmind sync with head
 1.59.14.1  07-Sep-2013  bouyer sys/dev/pci/if_bge.c 1.203-1.237, 1.239-1.241, 1.243-1.258 via patch
sys/dev/pci/if_bgereg.h 1.58-1.74, 1.76-1.83 via patch
sys/dev/pci/if_bgevar.h 1.10-1.16 via patch
sys/dev/pci/pcidevs 1.1149 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/brgphy.c 1.61-1.63, 1.65, 1.67 via patch
sys/dev/mii/miivar.h 1.61 via patch
sys/dev/mii/miidevs 1.112-1.113 via patch
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/bge.4 1.13-1.15 via patch

Add some device support, fix a lot of bugs and add some enahcements.
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F,
BCM5785G, BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- brgphy(4): Add BCM5756, BCM5717C, BCM5719C, BCM5720C and BCM57780.
- Add some bugfixes and enhancement from FreeBSD:
- Workaround for BCM5906 silicon bug. When auto-negotiation results in
half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292)
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.
(FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf.
(FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC.
(FreeBSD r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems
we have seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
From Linux tg3 driver.
- Sync with *BSD. No functional change:
- make bge_chipid() and use it.
- use switch() instead of a lot of if()s.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case.
Note that {tcp,udp}6csum flag is currently not added in the
capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking. FreeBSD has the same delay().
- Rename PHY related flags for the consistency. It's the same as
FreeBSD.
- Remove BGE_10_100_ONLY flag because this was not used.
For 10/100 devices, when calling mii_attach(), mask BMSR_EXTSTAT
flag to not to check Gigabit flags. It's the same as FreeBSD.
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this commit,
only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK calls MI
mii_phy_auto(). That was not intended.
- Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that
do not have jumbo support
- Wait for the bootcode to complete initialization for 5717 and newer
devices. See BCM5718 programmer's guide's "step 13,
Device reset Procedure, Section7".
57781's document has the same note.
- 5718 and 57785 document say we should wait 100us.
- Change the order of register settings a little to match both
Broadcom's document and Linux tg3.
- Add detach function.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix a bug that the NVRAM lock timeout occured on sparc64 onboard bge.
- Check BGE_SGDIG_STS when the chip is NOT a 5717 A0, like freebsd
(OpenBSD rev. 1.327).
- Fix the setting of Tx Random Backoff Register.
- Add BGE_PCIMISCCTL_PCISTATE_RW in BGE_INIT. It's required to set the
PCISTATE register correctly.
- Update comments from 57XX-PG105-R.pdf and 5718-PG106-R.pdf.
- Add missing bus_dmamap_sync() in bge_intr(). The status word is
in DMAed area. Same as other *BSDs.
- Check the hardware config words and print them. This change only
read them and print the values.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind().
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- bge_init_tx_ring() uses BGE_RSLOTS (==256) but bge_free_tx_ring() uses
BGE_TX_RING_CNT (== 512). Delete BGE_RSLOTS and use BGE_TX_RING_CNT.
Same as OpenBSD's if_bge.c rev. 1.86.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Call bge_poll_fw() before writing BGE_MODE_CTL register like the
latest linux tg3 dirver.
- Set DMA watermark depend on the PCI max payload size.
- Add BGE_JUMBO_CAPABLE flag to some chips. With this commit, 5714,
5780, 5717, 5718, 5719 (exclude rev. A0), 5720, 57765 and 57766 are
added to support jumbo frame.
- Fix the setting of sc->bge_flags for 5717 and newer devices.
- Fix a link detect bug on non-autopoll systems. Same as OpenBSD
(rev.1.329 and 1.336) and FreeBSD (r213710).
- 57765 series is not based on 5717 series. 5717 series is based on
57765 series.
- Set the TX DMA segment size based on the MTU size.
- Change the TX ring size for 5717 series and 57764 series.
- For 57766, set BGE_RDMAMODE_JMB_2K_MMRR for non-jumbo frame.
Same as Linux tg3.
- For 57765 and newer devices, set BGE_MAX_RX_FRAME_LOWAT to 1.
This value is recommended by the document.
- Change sysctl related functions for consistency.
- Style change.
- Use macro. Remove duplicated macro. Remove unused variable.
- Fix comments. Add comments.
- Remove extra semicolon. Remove unused code.
[msaitoh, ticket #939]
 1.59.8.2  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.59.8.1  30-Oct-2012  yamt sync with head
 1.60.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.60.2.1  23-Jun-2013  tls resync from head
 1.61.10.1  10-Aug-2014  tls Rebase.
 1.62.28.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.62.28.1  10-Jun-2019  christos Sync with HEAD
 1.62.26.2  26-Jan-2019  pgoyette Sync with HEAD
 1.62.26.1  18-Jan-2019  pgoyette Synch with HEAD
 1.62.20.1  21-Nov-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1454:

sys/dev/mii/atphy.c 1.22-1.23, 1.25 via patch
sys/dev/mii/mii_physubr.c 1.88 via patch
sys/dev/mii/miivar.h 1.69 via patch

- Fix a bug that atphy(4) can't negotiate correctly when the media
setting is neither auto nor 1000baseT.
- Code cleanup.
 1.68.4.1  21-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #459):

sys/dev/mii/atphy.c: revision 1.23
sys/dev/mii/atphy.c: revision 1.25
sys/dev/mii/miivar.h: revision 1.69
sys/dev/mii/mii_physubr.c: revision 1.88

s/etphy/atphy/. No functional change.

Fix a bug that atphy(4) can't negotiate correctly when the media setting is
neither auto nor 1000baseT. Use correct index for mii_media_table[].

History: mii_anar() is first added in OpenBSD and ported to NetBSD. On NetBSD,
only atphy(4) use this function. mii_physubr.c rev. 1.75 changed mii_anar()
for simplify. It changed the argument from the ifmedia word to ifm_data used
in our MII API, but the caller have not been changed. And then, PR kern/50206
was reported and the caller was modified by me to prevent panic but it was not
correct fix.
 1.73.6.1  01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed