Fix a bug that ifconfig ifN media auto doesn't change the setting when
the previous media setting used autonego. When the mii_phy_setmedia()
function is called to change the media to IFM_AUTO, the BMCR_AUTOEN bit was
used to check if the previous setting was IFM_AUTO. It's not correct.
IFM_1000_T also uses autonego. So if a previous setting is IFM_1000_T and
the next setting is IFM_AUTO, mii_phy_auto() is not called if neither
MIIF_FORCEANEG nor MIIF_DOPAUSE are set. As a result, after changing
IFM_AUTO, neither 10Mbps nor 100Mbps are not advertised.
Note that almost all drivers uses MIIF_DOPAUSE flags.
TODO: cleanup ciphy.c and rgephy.c. Those have #ifdef foo.
This is important for callers in if_stop routines to guarantee that
all concurrent access to the mii registers has ended.
Drivers must not call this from softint context. Drivers with custom
watchdog timers (not if_watchdog) that do if_stop from callout must
defer to thread context instead, e.g. via workqueue(9) -- as they
should be doing anyway for heavyweight operations like if_stop.
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 *.
IEEE 802.3 clause 22's PHY device has a link status bit in the BMCR
register, but it's required to read twice to get the correct value.
Almost all PHY devices have the vendor specific register which has
the link status bit that it's not required to read twice. makphy(4)
use the bit in the PSSR register to reduce the access cost.
QEMU's e1000 provides the PHY specific status register at 0x11 but the
link indication bit (PSSR_LINK.) is always 1 because
e1000x_update_regs_on_link_{down,up}() modify MII_SR_LINK_STATUS
(BMSR_LINK in NetBSD) but don't modify PSSR_LINK. It causes
"virsh domif-setlink xxx yyy down" doesn't work.
To avoid this problem, read the BMSR and check the BMSR_LINK bit. Add
MAKPHY_QUIRK_PSSR_LINK bit for this quirk. Set it if MII_EXTSR doesn't
exist because it's one of the case of QEMU.
Found and tested by ozaki-r.
- makphyattach() have a code to detect the Fiber/Copper auto selection
feature. Save the info to sc_flags to reduce the access
to the ESSR register. One of the reason is that the register is not
implemented on QEMU. Another reason is that it's not required to
access the register if the device is in the copper only mode.
- Marvell 88E1[01]11 (and many other Marvell PHYs) have the Fiber/Copper
auto selection feature. Our makphy(4) implement it but QEMU doesn't.
If it fails, a garbage data is used in the attach function and unexpected
media may be used. Fix this behavior by checking the return value of
PHY_READ(MAKPHY_ESSR). If the access failed, the media is regarded
as copper only. It's just a cosmetic change. It's not affected to the
packet processing.
- The BMSR register bit 8 (BMSR_EXTSTAT) denote the existence of page 0
register 15. qemu's e1000 sets BMSR_EXTSTAT but the access to register 15
fails. It doesn't conforms to the IEEE standard. Our makphy automatically
check the existence of 1000BASE-T or 1000BASE-SX by accessing the register
15. If the access failed, neither 1000BASE-T nor 1000BASE-SX is set to
the ability(mii_extcapabilities). Set EXTSR_1000TFDX and EXTSR_1000THDX
if the access failed in the attach function. It's just a cosmetic change.
It's not affected to the packet processing.
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.
auto-unloaded. Disable for now.
All of these need to be updated with an appropriate refcount mechanism
to ensure that the code and/or tables aren't unloaded while they are
being used.
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.
Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)
Remove unnecessary or redundant interface attributes where they're not
needed.
There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)
...and a sentinel value CFARG_EOL.
Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.
Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
- Add wm_lv_jumbo_workaround_ich8lan() and use it. From FreeBSD.
XXX For KUMCTRLSTA_OFFSET_HD_CTRL register modification, it's doubtful.
FreeBSD and Linux do the same thing that they set the same value on both
jumbo frame's enable case and the disable case. It seems the default value
is 0x0b0c and it's not changed on the enable case, so it might be a bug
on the enable case or the modification is not required.
- Rename I219_UNKNOWN1 to I82579_UNKNOWN1.
status updates by picking up a new status different from the tested
status. This left addresses in the DETACHED state although the
link status is already UP again.
addresses PR/kern 55538