archive mirror
 help / color / mirror / Atom feed
From: Sergey Organov <>
Cc:, "NXP Linux Team" <>
Subject: iMX 6SX FEC: broken hardware timestamping using external PTP PHY
Date: Sun, 07 Jun 2020 23:28:40 +0300	[thread overview]
Message-ID: <> (raw)


I'm using DP83640 PTP PHY connected to builtin fec1 (that
has its own PTP support) of the iMX 6SX microcontroller.

Almost everything works fine out of the box, except hardware
timestamping. The problems are that I apparently get timestamps from fec
built-in PTP instead of external PHY, and that

  ioctl(fd, SIOCSHWTSTAMP, &ifr)

ends up being executed by fec1 built-in PTP code instead of being
forwarded to the external PHY, and that this happens despite the call to

   info.cmd = ETHTOOL_GET_TS_INFO;                                                                             
   ioctl(fd, SIOCETHTOOL, &ifr);                                                                     

returning phc_index = 1 that corresponds to external PHY, and reports
features of the external PHY, leading to major inconsistency as seen
from user-space.

I chased the ioctl() problem down to the fec_enet_ioctl() function in


that specifically for SIOCSHWTSTAMP (and SIOCGHWTSTAMP) explicitly

  fec_ptp_set() (and fec_ptp_get())

instead of delegating to phy_mii_ioctl() as it does for the rest of

I've then commented-out this fec_ptp_set() calling code, and now ioctls
go to the external PHY, but I'd like to have proper fix instead of 
quick'n'dirty hack.

I checked DTS documentation, but didn't find a way to disable fec
builtin PTP support (nor would I actually like to, as it could be
useful as a hardware PPS source), or its timestamping feature.

I need to fix this, and, being newbie to the codebase, I don't even know
where to start, as I can't figure what's the supposed way of selecting
which unit should be used for hardware timestamping when there are two
of them on the current active path of newtork packets. I mean,
configuring PTP clocks is OK, as they are accessible separately through
'/dev/ptpX' interface, but hardware timestamping is to be configured
through (single) if-name, and there doesn't seem to be a way to address
different hardware timestamping units.

I'm using rather old 4.9.146 kernel, so I checked the tip of the git
master, and the code there still looks the same. I also didn't notice
any relevant commits in the recent git history.

Could somebody please help me implement (or point me to) proper fix to
reliably use external PHY to timestamp network packets?

-- Sergey

                 reply	other threads:[~2020-06-07 20:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

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

  git send-email \ \ \ \ \ \

* 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).