Commit Graph

944 Commits

Author SHA1 Message Date
riastradh 03dbe12f0c urlphy(4): Fix missing mii locking in urlphy_attach. 2022-01-08 17:35:05 +00:00
msaitoh fd0f817df7 QEMU e1000's PHY code doesn't reflect the PSSR_LINK bit. Do workaround.
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.
2022-01-06 07:39:10 +00:00
jmcneill 17d21f0174 Add driver for Motorcomm YT8511 GbE PHY 2022-01-03 17:18:12 +00:00
riastradh b24dc162a1 mii(9): Fix callout race between mii_phy_down and mii_phy_detach. 2021-12-28 12:00:48 +00:00
msaitoh 09ce039b20 Reduce the access of the ESSR register.
- 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.
2021-12-28 06:36:29 +00:00
msaitoh 2612a28064 QEMU e1000's PHY code doesn't implement register 16. Do workaround.
- 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.
2021-12-28 06:35:37 +00:00
msaitoh 3401d1f8f2 QEMU e1000's PHY code doesn't implement page 0 register 15. Do workaround.
- 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.
2021-12-28 06:34:40 +00:00
msaitoh 3da58d14f1 Cosmetic change for the output of mii_get_descr(). 2021-12-15 08:28:22 +00:00
msaitoh e778ac4194 Don't power down the PHY when the interface goes down.
- All of other PHY drivers don't power down the PHY. Do the same way.
 - At least, keeping the link is required for Intel AMT and WoL.
2021-11-05 01:53:30 +00:00
andvar 8135609163 Add missing RCSID and __KERNEL_RCSID(). 2021-08-25 21:50:29 +00:00
andvar ca7653601e fix various typos in comments and log messages. 2021-08-20 20:25:26 +00:00
thorpej c7fb772b85 Merge thorpej-cfargs2. 2021-08-07 16:18:40 +00:00
pgoyette b6ad7b596e Regen for new sys/dev/devlist2h.awk 2021-06-29 21:04:02 +00:00
pgoyette 74007e33ee 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.
2021-06-29 21:03:36 +00:00
pgoyette 8c69265ead Ooopppsss - typo! 2021-06-05 22:45:03 +00:00
pgoyette 202be4ee97 As with usbverbose and pciverbose, these modules are not safe to be
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.
2021-06-05 22:21:15 +00:00
thorpej 2685996b0e Merge thorpej-cfargs branch:
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?).
2021-04-24 23:36:23 +00:00
msaitoh c8b8553e08 Fix a bug that "ifconfig xx0 media none" set LINK_STATE_UNKNOWN instead of
LINK_STATE_DOWN.

XXX We should check for other PHY drivers, too.
2020-11-04 09:15:10 +00:00
msaitoh 6b533c04da Add Intel I347-AT4. 2020-10-20 08:53:34 +00:00
msaitoh c30bad5e0d Add a workaround for jumbo frame on PCH2 and newer. Tested by chs@.
- 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.
2020-09-16 15:04:01 +00:00
kardel f33b2e8145 Move mii_phy_statusmsg(sc) back to its original position. Fixes
deafness bug on macppc reported and tested by martin@
Thanks !
2020-08-27 10:10:23 +00:00
kardel 634cbaafea Keep the change check invariant intact. The previous code could miss
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
2020-08-24 12:46:04 +00:00
msaitoh 1d6d3e383e Remove extra PHY_RESET(sc) in the MII_TICK path because it's not requierd
to just restart autonego.
2020-08-24 04:49:05 +00:00
msaitoh 600be1acda 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).
2020-08-24 04:23:41 +00:00
uwe 4e04df6ed9 mii_knowndevs[] is de facto const, define it as such.
This time for real.  On my first try I did it in the generated
miidevs_data.h file.
2020-08-04 04:22:02 +00:00
uwe 6d258dd428 mii_knowndevs[] is de facto const, define it as such. 2020-08-03 14:00:41 +00:00
msaitoh e178001a00 Rename PSSR_* to MAKPHY_PSSR_* and IGPHY_PSSR_* to avoid conflict.
No functional change.
2020-08-03 07:25:59 +00:00
msaitoh bce8b71104 s/MII_IGPHY_/IGPHY_/. No functional change. 2020-08-03 07:16:51 +00:00
msaitoh d245628f58 - Remove the waitfor argument from mii_phy_auto().
- Whitespace fix.
2020-07-07 08:44:12 +00:00
msaitoh 53f3973f63 - Call tlphy_auto correctly.
- It's not required to do busy-wait by mii_phy_auto(sc, 1). Now there is
 no any PHY driver which calls mii_phy_auto(sc, 1).
2020-07-07 08:35:16 +00:00
msaitoh 1f74e5c827 "no media present" is intended case on tlphy(4), so don't use
aprint_error_dev().
2020-07-07 06:59:22 +00:00
msaitoh b08ea1183c Regen. 2020-06-23 14:35:59 +00:00
msaitoh 6705c5b537 Add some Microsemi (Vitesse) devices. 2020-06-23 14:35:36 +00:00
jmcneill 207da896f9 Add support for BCM54213PE RGMII clock delays, from OpenBSD 2020-05-25 19:48:38 +00:00
jmcneill 0008e4812f Add MIIF_RXID and MIIF_TXID flags to signal that RX or TX delays are required, from OpenBSD. 2020-05-25 19:47:58 +00:00
msaitoh 114be2d1a2 Add two new RDC PHYs from Andrius V. 2020-04-08 03:01:58 +00:00
msaitoh 7b253dbc0f Regen. 2020-04-08 03:01:28 +00:00
msaitoh eb639955e5 Add two new RDC PHYs from Andrius V. 2020-04-08 03:01:05 +00:00
thorpej 68e9e41ed4 Don't set DVF_DETACH_SHUTDOWN. The MII layer wants to manage the lifecycle
of the PHY devices, and if a NIC driver chooses not to detach its PHYs
at shutdown, that's the driver's business.

PR kern/55121.
2020-03-28 18:37:18 +00:00
thorpej 7a9a30c5e7 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.
2020-03-15 23:04:50 +00:00
msaitoh 79d9ef08e7 Fix a bug that atphy(4) doesn't work with Attansic L2 rev. 1.
Reported by Rocky Hotas.

- On ASUS M2N-MX SE Plus (NVIDIA MCP61 with Attansic L2 rev. 1), changing
  debug port 0x29's value makes the next PHY read fail with error.  Read any
  register to ignore this problem if the PHY is Attansic L2 revision 1.
  I don't know if this problem is from L2 rev. 1 itself or from the
  combination because I have only one machine which has L2 rev. "1".
  At least, ASUS eee pc 900 (Attansic L2 rev. "2") has no this problem.
- Add comment. AR8021 document has no description about the power saving
  control register(debug port 0x29).
- Add comment. AR8031 document says the lower 14 bits are reserved and the
  default value is 0x36d0. Shouldn't we clear those bits?
- I have no document neither L1(F1) nor L2(F2), so I don't know whether the
  debug port access is correct or not.

Tested with the following machines:
- ASUS P5B SE,         L1 rev. 5,            age(4)
- ASUS K50IJ,          L1 rev. 9,            ale(4)
- ASUS eee pc 900,     L2 rev. 2,            lii(4)
- ASUS M2N-MX SE Plus, L2 rev. 1,            nfe(4)
- Intel DP55WB,        82578(AR8021 rev. 2), wm(4)
- Dell inspiron 14z,   AR0835 rev. 9,        alc(4)
2020-03-13 18:57:49 +00:00
msaitoh 20ab1f8621 Regen. 2020-03-13 04:44:58 +00:00
msaitoh b556be9077 0x001374 is non-bitreversed value of Attansic OUI(0x00c82e).
Attansic/Atheros correctly uses ID1 and ID2 register, so delete all 0x001374
related entries.
2020-03-13 04:44:34 +00:00
msaitoh ab00d4f830 - Add Quake Technologies and Aeluros' OUI
- Add Teranetics TN1010 10GBase-T PHY
2020-03-13 04:43:03 +00:00
msaitoh 3102c6481b Move PHY_RESET() in the media change path from if_et.c to etphy.c.
I don't know if the reset is required or not. I tested some media
transitions without the reset and it worked. It might be OK to remove
but Linux does it only in et1011c_config_aneg(). So move the reset to
etphy_service(,,MII_MEDIACHG)'s autonego case. This change is also
required for future locking changes.
2020-02-28 05:13:19 +00:00
msaitoh 89323825a1 Regen. 2020-02-27 06:17:50 +00:00
msaitoh 5bb46a41c0 Use xxVIA instead of VIA.
0x004063 is VIA's official OUI but VT6103 use 0x0002c6.
0x0002c6 is non-bitreversed value of 0x004063. Reported by Andrius V.
2020-02-27 06:17:28 +00:00
jmcneill eb15acbd6a Match BCM54213PE 2020-02-22 18:57:31 +00:00
jmcneill 0210926b50 regen 2020-02-22 18:57:09 +00:00
jmcneill 65d0cc155b Add BCM54213PE 2020-02-22 18:56:57 +00:00