Skip to contentSkip to conversation

PTP: PHY timestamping when MAC is PTP capable

PATCH Sørensen, Stefan 2 participants 2 messages Aug 28, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

I have run into a problem with packet timestamping on a platform (cpsw
+ dp83640) where both the PHY and the MAC is PTP capable and I need the PHY to perform the timestamping. In the current code, SIOCGHWTSTAMP is passed to the MAC driver and only if it does not support PTP itself will it pass it on to the PHY driver.

I see two ways to fix this:

1. Prefer PHY timestamping by passing SIOCGHWTSTAMP to the PHY driver first, and only if it does not support PTP, pass is on to the MAC driver. To me this seems reasonable as PHY timestamps will usually be of better quality, and with a hardware design using a PTP capable PHY you will most likely want to utilize it. Note that the ethtool get_ts_info op takes this route and as such may currently return incorrect info when both MAC and PHY is PTP capable.

2. Let the user decide, by e.g. a new ethtool op.

For now I am using the patch below, but it does not seem quite right to me.

Any suggestions on the best way forward?

Regards,
Stefan

---

net/core/dev_ioctl.c +1 -0
index 709a4e6fb447..52f4d2dfad11 100644
@@ -4,6 +4,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/net_tstamp.h>
 #include <linux/wireless.h>
+#include <linux/phy.h>
 #include <net/wext.h>
 
 /*
@@ -316,6 +317,14 @@ static int dev_ifsioc(struct net *net, struct

ifreq *ifr, unsigned int cmd)

                        return err;
                /* fall through */

+ case SIOCGHWTSTAMP:
+ if (dev->phydev) {
+ err = phy_mii_ioctl(dev->phydev, ifr, cmd);
+ if (err != -EOPNOTSUPP)
+ return err;
+ }
+ /* fall through */
+

        /*
         *      Unknown or private ioctl
         */
#1 lore raw
Quoted 7 lines · Stefan

I have run into a problem with packet timestamping on a platform (cpsw
+ dp83640) where both the PHY and the MAC is PTP capable and I need the PHY to perform the timestamping. In the current code, SIOCGHWTSTAMP is passed to the MAC driver and only if it does not support PTP itself will it pass it on to the PHY driver.

I see two ways to fix this:

Just disable CONFIG_CPTS and patch cpsw.c to pass SIOC[GS]HWTSTAMP.

I don't see any reasonable way to make this sort of thing configurable at run time.

Thanks,
Richard