zkkkk12 commented on PR #21485: URL: https://github.com/apache/nuttx/pull/21485#issuecomment-6658086835
> @zkkkk12 this is a great improvement to NuttX! Question: some PHYs now are having features that were supposed to exist only on MAC side, i.e.: PTP: https://www.ti.com/lit/ds/symlink/dp83630.pdf , WoL: https://www.ti.com/lit/an/snla261a/snla261a.pdf , etc. How is PHYLIB planning to support the extended features? Could you please add details about it inside the Documentation? @acassis Thanks for the review! Support for these PHY-side extended features (PTP, WoL, EEE, ...) is handled as a framework-level extensibility design rather than hard-coding each feature into the core. There are four extension points, all already present in the framework: **1. Optional callbacks in `struct phy_driver_s` (the main entry point).** The core (state machine, matching, lifecycle) only knows this callback table. Adding a feature means adding a group of *optional* callbacks, exactly like the existing `config_intr` / `handle_interrupt` / `read_page`. A driver that implements them advertises the capability; one that doesn't falls back to genphy behavior. Appending callbacks to the end of the struct keeps the ABI stable for existing drivers. **2. `phy_ioctl()` as the unified user-space control plane.** All MII/ethtool commands are offered to `phy_ioctl()` first by the netdev upper-half, falling back to the MAC only on `-ENOTTY`. A new feature just adds its ethtool command branch here, so user space reaches it through the standard ethtool interface with uniform in-framework behavior. **3. Register access and events reuse existing infrastructure.** These features' registers usually live in MMD or vendor pages, reached with the existing `phy_read_mmd` / `phy_*_paged` accessors — no new mechanism needed. Asynchronous events (PTP timestamp ready, WoL wake) reuse the interrupt path (`config_intr` / `handle_interrupt`). **4. `phydev->priv` for private state.** Per-chip state outside IEEE 802.3 (PTP clock context, WoL match rules, ...) lives here, without polluting the generic `phy_device_s`. How your two examples map onto this model: - **WoL**: add optional `get_wol` / `set_wol` callbacks mapped to the ethtool WoL commands (those ethtool commands would be added to the NuttX ethtool layer when needed); the wake match rules sit in `phydev->priv` and the wake interrupt flows through `handle_interrupt`. This is a PHY-side-only capability that closes the loop with the extension points above. - **PTP / timestamping**: capability discovery can be reported from a PHY-side callback filling `struct ethtool_ts_info` via `ETHTOOL_GET_TS_INFO`. To be candid, full PTP is more than a PHY callback — per-packet hardware timestamping also needs the stack data plane (per-packet `SO_TIMESTAMPING` delivery, and a `SIOCSHWTSTAMP`-style config interface which NuttX currently lacks). So PHYLIB provides the capability discovery and PHY 1588 register configuration extension points, while the data plane is a larger, separately tracked work item. Current scope: this series is the base framework, link management and the RTL PHY drivers. The PTP/WoL callbacks above are not implemented yet — they are the extension path the framework reserves, and require no change to existing drivers. I've added an "Extended Features" section to the PHYLIB documentation describing this model and how PTP/WoL would be wired in. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
