How do I enable hardware timestamping for Ethernet?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I enable hardware timestamping for Ethernet?

17,184 Views
brianbrittain
Contributor I

I am using the LSDK with the LS1043A-RDB and I have turned on all of the kernel configuration options for PTP, but when I check the timestamping capabilities of any of the network interfaces with "ethtool -T fm1-macx" it reports no hardware capabilities.  What do I need to check to find the problem?

Labels (1)
Tags (3)
0 Kudos
10 Replies

13,396 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please configure Linux Kernel as the following.

CONFIG_FSL_DPAA_1588=y
CONFIG_PTP_1588_CLOCK=y
CONFIG_PTP_1588_CLOCK_DPAA=y
# CONFIG_PTP_1588_CLOCK_DPAA2 is not set


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

13,396 Views
sbangalore
Contributor I

Hi Yiping,

Thanks for your response. I have all these kernel settings configured as you pointed out. I still don't see the hardware timestamping enabled.

Here's what I am seeing...

Capture-PTP-Properties.PNG

Also, FYI, I have included below a portion of the device tree file with PTP settings. Please let me know if the information entered is correct.

&fman0 {
ethernet@e0000 {
fixed-link = <1 1 1000 0 0>;
phy-connection-type = "sgmii";
};

ethernet@e2000 {
fixed-link = <1 1 1000 0 0>;
phy-connection-type = "sgmii";
};

ethernet@e4000 {
fixed-link = <1 1 1000 0 0>;
phy-connection-type = "rgmii-txid";
};

ethernet@e6000 {
fixed-link = <1 1 1000 0 0>;
phy-connection-type = "rgmii-txid";
};

ethernet@e8000 {
fixed-link = <1 1 1000 0 0>;
phy-connection-type = "sgmii";
};

ethernet@ea000 {
fixed-link = <1 1 1000 0 0>;
phy-connection-type = "sgmii";
};

ethernet@f0000 { /* 10GEC1 */
fixed-link = <1 1 1000 0 0>;
phy-connection-type = "sgmii";
};

mdio@fc000 {
rgmii_phy1: ethernet-phy@1 {
reg = <0x1>;
};

rgmii_phy2: ethernet-phy@2 {
reg = <0x2>;
};

qsgmii_phy1: ethernet-phy@4 {
reg = <0x4>;
};

qsgmii_phy2: ethernet-phy@5 {
reg = <0x5>;
};

qsgmii_phy3: ethernet-phy@6 {
reg = <0x6>;
};

qsgmii_phy4: ethernet-phy@7 {
reg = <0x7>;
};
};

mdio@fd000 {
aqr105_phy: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c45";
interrupts = <0 132 4>;
reg = <0x1>;
};
};

ptp_clock@2d10e00 {
compatible = "fsl,etsec-ptp";
reg = <0x0 0x2d10e00 0x0 0xb0>;
interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
fsl,tclk-period = <5>;
fsl,tmr-prsc = <2>;
fsl,tmr-add = <0xaaaaaaab>;
fsl,tmr-fiper1 = <999999990>;
fsl,tmr-fiper2 = <99990>;
fsl-max-adj = <499999999>;
};
ptp_timer@fe000 {
compatible = "fsl,fman-ptp-timer", "fsl,fman-rtc";
reg = <0xfe000 0x1000>;
};

0 Kudos

13,396 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello Srinivas Bangalore,

Please refer to the following explanation.

Please refer to the following Linux Kernel option.

config PTP_1588_CLOCK_DPAA
        tristate "Freescale DPAA as PTP clock"
        depends on FSL_SDK_DPAA_ETH
        select PTP_1588_CLOCK
        select FSL_DPAA_TS
        default n
        help
This driver adds support for using the DPAA 1588 timer module as a PTP clock.    This clock is only useful if your PTP programs are getting hardware time stamps on the PTP Ethernet packets using the SO_TIMESTAMPING API.

The DPAA1 driver for PTPd (dpaa_ptp.c) really only supports PTPd, and not linux-ptp. The reason why ethtool doesn't report correct information is because the lack of support for the get_ts_info callback for ethtool. In addition, not any PTPd will work, but only the one that we have patched to work (https://github.com/qoriq-open-source/ptpd). Upstream ptpd and linux-ptp will not work, because the DPAA1 PTP driver exposes a non-standard interface to userspace. Please use ptpd provided in NXP(Freescale) released Linux SDK.


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

13,396 Views
sbangalore
Contributor I

Hi Yiping,

Thanks for your help. I followed your instructions and here’s what I am seeing:

I can also see messages being received on the PTP slave side, so the master and slave are communicating.

Sorry, but I have a few more questions…

1. How can I tell from the above output that hardware time stamps are enabled?

2. Why does the log show a timestamp/date of 1970-01-01?

Thanks,

Srinivas

0 Kudos

13,395 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello Srinivas,

1. Please refer to the following source code drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c in Linux Kernel when CONFIG_FSL_DPAA_TS is enabled.

#ifdef CONFIG_FSL_DPAA_1588
        if (priv->tsu && priv->tsu->valid && priv->tsu->hwts_tx_en_ioctl)
                fd.cmd |= FM_FD_CMD_UPD;
#endif
#ifdef CONFIG_FSL_DPAA_TS
        if (unlikely(priv->ts_tx_en &&
                        skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))
                fd.cmd |= FM_FD_CMD_UPD;
        skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
#endif /* CONFIG_FSL_DPAA_TS */

#ifdef CONFIG_FSL_DPAA_TS
        if (priv->ts_rx_en)
                dpa_get_ts(priv, RX, skb_hwtstamps(skb), vaddr);
#endif /*

2. In the latest Linux Kernel source code, there is a testptp tool in kernel source to set ptp clock time.

You can cross-compile tools/testing/selftests/ptp/testptp.c to use.

Here is example to use.

root@ls1028a:~# ./testptp -h

usage: testptp [options]

-a val     request a one-shot alarm after 'val' seconds

-A val     request a periodic alarm every 'val' seconds

-c         query the ptp clock's capabilities

-d name    device to open

-e val     read 'val' external time stamp events

-f val     adjust the ptp clock frequency by 'val' ppb

-g         get the ptp clock time

-h         prints this message

-i val     index for event/trigger

-k val     measure the time offset between system and phc clock

            for 'val' times (Maximum 25)

-l         list the current pin configuration

-L pin,val configure pin index 'pin' with function 'val'

            the channel index is taken from the '-i' option

            'val' specifies the auxiliary function:

            0 - none

            1 - external time stamp

            2 - periodic output

-p val     enable output with a period of 'val' nanoseconds

-P val     enable or disable (val=1|0) the system clock PPS

-s         set the ptp clock time from the system time

-S         set the system time from the ptp clock time

-t val     shift the ptp clock time by 'val' seconds

-T val     set the ptp clock time to 'val' seconds

root@ls1028a:~# date

Tue Sep 25 11:21:54 UTC 2018

root@ls1028a:~# ./testptp /dev/ptp0 -g

clock time: 544.497962405 or Thu Jan  1 00:09:04 1970

root@ls1028a:~# ./testptp /dev/ptp0 -s

set time okay

root@ls1028a:~# ./testptp /dev/ptp0 -g

clock time: 1537874537.256845540 or Tue Sep 25 11:22:17 2018

root@ls1028a:~#

 


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

13,396 Views
sbangalore
Contributor I

Thank you! This has been very helpful.

-Srini

0 Kudos

13,396 Views
sbangalore
Contributor I

Thank you. I will try this and let you know.

If I can’t use Ethtool to test the availability of hw timestamps, how else can I know if it’s working? Are there other tools or logs that report hw time stamp functionality?

Thanks!

Sent from my iPhone

0 Kudos

13,396 Views
sbangalore
Contributor I

I am having exactly the same problem noted by Brian Brittain. I can see the master and slave sides sending messages, but the Ethernet port does not show the hardware timestamping enabled. 

What am I missing?

Thanks!

0 Kudos

13,396 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello Brian Brittain,

Please check the following configuration.

Configure PTPd stack

Device Drivers --->

  PTP clock support --->

      <*> Freescale DPAA as PTP clock

 

In the Kernel configuration file enable the following configuration

CONFIG_PTP_1588_CLOCK_DPAA

CONFIG_FSL_SDK_DPAA_ETH

 

In the dts configuration, please add the following configuration.

ptp_timer0: ptp-timer@fe000 {

compatible = "fsl,fman-ptp-timer", "fsl,fman-rtc";

reg = <0xfe000 0x1000>;

};

 

In Linux Kernel booting up log, please check message "pps pps0: new PPS source ptp0".

 

On the master side

# ifconfig eth0 up

# ifconfig eth0 192.168.1.100

# ptpd2 -i eth0 -MV

On the slave side

# ifconfig eth0 up

# ifconfig eth0 192.168.1.200

# ptpd2 -i eth0 -sV --servo:kp=0.32 --servo:ki=0.05

The slave side would print synchronization messages.


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

13,396 Views
brianbrittain
Contributor I

OK - I have verified that the correct configuration options are selected and that the "pps pps0: new PPS source ptp0" message appears in the boot log.  However, when I query the ethernet capabilities I get

root@localhost:/var/log# ethtool -T fm1-mac5
Time stamping parameters for fm1-mac5:
Capabilities:
software-receive (SOF_TIMESTAMPING_RX_SOFTWARE)
software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none

The ptpd2 software works fine (I get synchronization messages) but I need the accuracy provided by the hardware timestamping.  It appears to me that it is using software timestamping.

0 Kudos