RE: [net-next, v2, 7/7] enetc: support PTP domain timestamp conversion
From: "Y.b. Lu" <yangbo.lu@nxp.com>
Date: 2021-05-31 10:51:42
Hi Claudiu and Richard,
-----Original Message----- From: Richard Cochran <richardcochran@gmail.com> Sent: 2021年5月25日 20:37 To: Y.b. Lu <yangbo.lu@nxp.com> Cc: netdev@vger.kernel.org; David S . Miller <davem@davemloft.net>; Claudiu Manoil [off-list ref]; Jakub Kicinski [off-list ref] Subject: Re: [net-next, v2, 7/7] enetc: support PTP domain timestamp conversion On Fri, May 21, 2021 at 12:36:19PM +0800, Yangbo Lu wrote:quoted
@@ -472,13 +473,36 @@ static void enetc_get_tx_tstamp(struct enetc_hw*hw, union enetc_tx_bd *txbd,quoted
*tstamp = (u64)hi << 32 | tstamp_lo; } -static void enetc_tstamp_tx(struct sk_buff *skb, u64 tstamp) +static int enetc_ptp_parse_domain(struct sk_buff *skb, u8 *domain) { + unsigned int ptp_class; + struct ptp_header *hdr; + + ptp_class = ptp_classify_raw(skb); + if (ptp_class == PTP_CLASS_NONE) + return -EINVAL; + + hdr = ptp_parse_header(skb, ptp_class); + if (!hdr) + return -EINVAL; + + *domain = hdr->domain_number;This is really clunky. We do NOT want to have drivers starting to handle the PTP. That is the job of the user space stack. Instead, the conversion from raw time stamp to vclock time stamp should happen in the core infrastructure. That way, no driver hacks will be needed, and it will "just work" everywhere.
That's perfect way.
We need a way to associate a given socket with a particular vclock. Perhaps we can extend the SO_TIMESTAMPING API to allow that.
How about adding a flag SOF_TIMESTAMPING_BIND_PHC, and redefining the data passing by setsockopt like,
struct timestamping {
int flags;
u8 hwtstamp_phc; /*phc index */
};
The sock could have a new member sk_hwtstamp_phc to record it.
quoted
+ return 0; +}Thanks, Richard