netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Sørensen, Stefan" <Stefan.Sorensen@spectralink.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"richardcochran@gmail.com" <richardcochran@gmail.com>
Subject: PTP: PHY timestamping when MAC is PTP capable
Date: Mon, 28 Aug 2017 08:39:44 +0000	[thread overview]
Message-ID: <1503909582.2455.2.camel@spectralink.com> (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

---

diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 709a4e6fb447..52f4d2dfad11 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -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
         */

             reply	other threads:[~2017-08-28  8:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28  8:39 Sørensen, Stefan [this message]
2017-08-28 12:33 ` PTP: PHY timestamping when MAC is PTP capable Richard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1503909582.2455.2.camel@spectralink.com \
    --to=stefan.sorensen@spectralink.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).