Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp967973pxv; Fri, 25 Jun 2021 02:26:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhIsQAP1gdvyg1iWoFLdUvCBUsAGB5kabBUbrYa8D8TUUEI9Mg2z3so/lLRK+7RH2klwBj X-Received: by 2002:a05:6e02:1a62:: with SMTP id w2mr6886368ilv.217.1624613215794; Fri, 25 Jun 2021 02:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624613215; cv=none; d=google.com; s=arc-20160816; b=VIMOBH5URSP+BzsY0YpTMABflE21QPvhptLIAUOxFFdlOhg+uBDXqAftEh5Cfx6Eif blYLElygb958zWL1bb/q1S5wPxe1OEOIrZpJzhewbIbr22BaGMHSnPLja0Rp37+2dBAY /4bA7jUbw79WyOal6WvqdP+M1QUIM+dCaI3qKSyMCUiQ1HnWfELDbqgecXBrB0iYWj6c JU4S3eNaTWDnKZPXrcHtzb1gBH4Y+gsE1Y8YlIQHoahuEzJnvCvGysAJYY14XeoQKMHd oCfhm317+ycyN+KPqvoOnQpNKAOOCpYMz/lPnOcAq2ym6hCCrX8xvPkYIo73nYQj//yl FM8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=bDivmGi/xhBpG5FVQg8nnUyv81aoCvdo8OSTwn8dnhk=; b=ioWxU3N0FL5USX/KNPPsagvZFjQrxWo644mH+1yaUdmEE1AZ0D41LkjjIlgdG0ExVw X6JJf5sl68efMM6LuuHy5lDzawDX7V5usEahmP+fCyLzVt9hwSyWsxa5GrlVcxNYd+PL p3MlXXpW5nhKLvSQmw1FfQtOXsmHtoZfFmI5gmtPX6puy1dUZ/BbUeO39/OQ2v61Dhm7 034L7FjK+ty0ilQEg9lQwyT5vYt0QP1AOLZYIUtskRWYzb9Zzlj3xUXLxMXMRNHvK8yt 0RwhinRm0gF4Z1EpaiKc1BipUQhb2R8EHc+3fgNcPIiMCeZAvm3NJb6qEbPzu2sGyUxB x08A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si668705jaj.24.2021.06.25.02.26.44; Fri, 25 Jun 2021 02:26:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbhFYJ1a (ORCPT + 99 others); Fri, 25 Jun 2021 05:27:30 -0400 Received: from inva021.nxp.com ([92.121.34.21]:53592 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbhFYJ1G (ORCPT ); Fri, 25 Jun 2021 05:27:06 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D015C20073C; Fri, 25 Jun 2021 11:24:44 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 968CD2006F5; Fri, 25 Jun 2021 11:24:44 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id E96A8183ACDF; Fri, 25 Jun 2021 17:24:42 +0800 (+08) From: Yangbo Lu To: netdev@vger.kernel.org Cc: Yangbo Lu , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, mptcp@lists.linux.dev, Richard Cochran , "David S . Miller" , Jakub Kicinski , Mat Martineau , Matthieu Baerts , Shuah Khan , Michal Kubecek , Florian Fainelli , Andrew Lunn , Rui Sousa , Sebastien Laveze Subject: [net-next, v4, 09/11] net: socket: support hardware timestamp conversion to PHC bound Date: Fri, 25 Jun 2021 17:35:11 +0800 Message-Id: <20210625093513.38524-10-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210625093513.38524-1-yangbo.lu@nxp.com> References: <20210625093513.38524-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is to support hardware timestamp conversion to PHC bound. This applies to both RX and TX since their skb handling (for TX, it's skb clone in error queue) all goes through __sock_recv_timestamp. Signed-off-by: Yangbo Lu --- Changes for v3: - Added this patch. Changes for v4: - None. --- net/socket.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/net/socket.c b/net/socket.c index bd9233da2497..0b2dad3bdf7f 100644 --- a/net/socket.c +++ b/net/socket.c @@ -104,6 +104,7 @@ #include #include #include +#include #ifdef CONFIG_NET_RX_BUSY_POLL unsigned int sysctl_net_busy_read __read_mostly; @@ -873,12 +874,18 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, empty = 0; if (shhwtstamps && (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) && - !skb_is_swtx_tstamp(skb, false_tstamp) && - ktime_to_timespec64_cond(shhwtstamps->hwtstamp, tss.ts + 2)) { - empty = 0; - if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) && - !skb_is_err_queue(skb)) - put_ts_pktinfo(msg, skb); + !skb_is_swtx_tstamp(skb, false_tstamp)) { + if (sk->sk_tsflags & SOF_TIMESTAMPING_BIND_PHC) + ptp_convert_timestamp(shhwtstamps, sk->sk_bind_phc); + + if (ktime_to_timespec64_cond(shhwtstamps->hwtstamp, + tss.ts + 2)) { + empty = 0; + + if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) && + !skb_is_err_queue(skb)) + put_ts_pktinfo(msg, skb); + } } if (!empty) { if (sock_flag(sk, SOCK_TSTAMP_NEW)) -- 2.25.1