From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBF76C7618F for ; Mon, 15 Jul 2019 13:59:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B526420C01 for ; Mon, 15 Jul 2019 13:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563199148; bh=zpUo1nj/5sSnF28n+BhNMKd1g7eI0npNqkdu+ypBo2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g3QhSDFDChYQeh20dAzryN9Oh+Jhjt1pWtCcxshuFjLbWoMPBZltMt7enPgfxdKfl v6ays4XIwjTbBCULTAiabQ5VLPhTtFZlzqojRp1E/yMC8lJ/6g0Qahmv624LoGJ++l 46WkJp51waY7G08hdwJ3cjDAtbXL+TTLiOzifOYs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733260AbfGON7H (ORCPT ); Mon, 15 Jul 2019 09:59:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:39044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733252AbfGON7E (ORCPT ); Mon, 15 Jul 2019 09:59:04 -0400 Received: from sasha-vm.mshome.net (unknown [73.61.17.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9013D21530; Mon, 15 Jul 2019 13:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563199144; bh=zpUo1nj/5sSnF28n+BhNMKd1g7eI0npNqkdu+ypBo2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+Gtecbt4JGGQxyPNvx89XmQOx1Q8UexygbVewVSgz9qHCMt+zbKJwokpvRxdMOlI wTqkFpSZvzmiCU2fGdXGeXXH/tb4zmJE8hrQMRNT4X48aMJ7ZTwZCWT2LShmdQPRW8 IXwZ9TeHCY44MPW6DWUawkZ8uXAyP6LKLDvHt8XA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vedang Patel , Aaron Brown , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 204/249] igb: clear out skb->tstamp after reading the txtime Date: Mon, 15 Jul 2019 09:46:09 -0400 Message-Id: <20190715134655.4076-204-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134655.4076-1-sashal@kernel.org> References: <20190715134655.4076-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vedang Patel [ Upstream commit 1e08511d5d01884a3c9070afd52a47799312074a ] If a packet which is utilizing the launchtime feature (via SO_TXTIME socket option) also requests the hardware transmit timestamp, the hardware timestamp is not delivered to the userspace. This is because the value in skb->tstamp is mistaken as the software timestamp. Applications, like ptp4l, request a hardware timestamp by setting the SOF_TIMESTAMPING_TX_HARDWARE socket option. Whenever a new timestamp is detected by the driver (this work is done in igb_ptp_tx_work() which calls igb_ptp_tx_hwtstamps() in igb_ptp.c[1]), it will queue the timestamp in the ERR_QUEUE for the userspace to read. When the userspace is ready, it will issue a recvmsg() call to collect this timestamp. The problem is in this recvmsg() call. If the skb->tstamp is not cleared out, it will be interpreted as a software timestamp and the hardware tx timestamp will not be successfully sent to the userspace. Look at skb_is_swtx_tstamp() and the callee function __sock_recv_timestamp() in net/socket.c for more details. Signed-off-by: Vedang Patel Tested-by: Aaron Brown Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igb/igb_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 39f33afc479c..005c1693efc8 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -5687,6 +5687,7 @@ static void igb_tx_ctxtdesc(struct igb_ring *tx_ring, */ if (tx_ring->launchtime_enable) { ts = ns_to_timespec64(first->skb->tstamp); + first->skb->tstamp = 0; context_desc->seqnum_seed = cpu_to_le32(ts.tv_nsec / 32); } else { context_desc->seqnum_seed = 0; -- 2.20.1