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 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 373E3C43602 for ; Tue, 30 Jun 2026 11:27:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CFB9A60FE2; Tue, 30 Jun 2026 11:27:12 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id yvVwot2Hb5OW; Tue, 30 Jun 2026 11:27:12 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org EA0AC60FE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1782818832; bh=FGWjX5Iw+idjzBCUjhnqRS4MmD5hoBNLO0VdMjNcb0g=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ZFoghbG3HxuZHGmvnzOiDEE0gy3IbOhTQlvihwKbZPP2x+06yYNsNSWHJVJGDhEUp 1cEoH6tfWKbSmzKQ/jm7CPw+pIO6kj5V000nN7xlKO2SrKLUNL0lg9nQGMY0rYI/vO YBlWk+7ZHa0xJCdUJ1EHzAc4AiZ8wcXoQBpGI4QzLghBNS/lHLdlwo+rqLBFc5H9nR eoF6SitnfMwlg1I4Up8L+ry2QP3laAG0SeOcp5EiSdsooQbrx9Jk7hDikoVEjxNrsV OXhmK3NzwTq4NZeJOD7H8j76uhvW/g0hOsP/Mnu+cytNzBL6LISUKnYiooE+4pD0aN BTNEVA7TnWqGQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id EA0AC60FE5; Tue, 30 Jun 2026 11:27:11 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists1.osuosl.org (Postfix) with ESMTP id 3AC94ED6 for ; Tue, 30 Jun 2026 11:27:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2097C41016 for ; Tue, 30 Jun 2026 11:27:11 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id UQSohyONfZls for ; Tue, 30 Jun 2026 11:27:09 +0000 (UTC) X-Greylist: delayed 304 seconds by postgrey-1.37 at util1.osuosl.org; Tue, 30 Jun 2026 11:27:08 UTC DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 114D740207 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 114D740207 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=185.136.64.228; helo=mta-64-228.siemens.flowmailer.net; envelope-from=fm-1335312-20260630112200cc8f9f316c0002079e-as78u0@rts-flowmailer.siemens.com; receiver= Received: from mta-64-228.siemens.flowmailer.net (mta-64-228.siemens.flowmailer.net [185.136.64.228]) by smtp2.osuosl.org (Postfix) with ESMTPS id 114D740207 for ; Tue, 30 Jun 2026 11:27:07 +0000 (UTC) Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 20260630112200cc8f9f316c0002079e for ; Tue, 30 Jun 2026 13:22:01 +0200 To: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jan.kiszka@siemens.com, florian.bezdeka@siemens.com Cc: intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, meng.ding@siemens.com, wq.wang@siemens.com, pmenzel@molgen.mpg.de, stable@vger.kernel.org, Aleksandr Loktionov , Piotr Kwapulinski Date: Tue, 30 Jun 2026 19:15:23 +0800 Message-ID: <20260630112056.885071-1-meng.ding@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1335312:519-21489:flowmailer X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=meng.ding@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; bh=FGWjX5Iw+idjzBCUjhnqRS4MmD5hoBNLO0VdMjNcb0g=; b=au27Z8YjSO7lrdMiXMKZKX04axUjx3tCBcFn/n1iVduzZQwpYpn1MMDv3JXmUT35/VG1nZ muiVJZ9oa28547LGKhhcioH4cLarvCqcVCeULc1MIYDKoMg/tsspDJYrLs5agqoM3Wd6nmzV uWt5dJ3z9uyDhixiGcY6khTLwWraKKUYJNf5wicZaEBMfi8C75m8rC+w/9qM6cHt+vBV7j6z i7Sz1wK9qXAFdZQf3+Vq02+VIRgvywuG/EjTl+riq+DSvgLzQvwumxPQ6wJjAjI8qO2PKlji ZKijyupNhmCSt8qaljxIxGPu9lD+MvbnaanfmIHM4eOqjUWuq6NEYtqQ==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=reject dis=none) header.from=siemens.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=siemens.com header.i=meng.ding@siemens.com header.a=rsa-sha256 header.s=fm2 header.b=au27Z8Yj Subject: [Intel-wired-lan] [PATCH net v2] igc: Fix RX HW timestamp reporting when NET_RX_BUSY_POLL is disabled X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Ding Meng via Intel-wired-lan Reply-To: Ding Meng Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" When CONFIG_NET_RX_BUSY_POLL is deactivated, fetching RX HW timestamps from the NIC no longer works as expected, often resulting in incorrect or negative values such as "HW raw -121948.050407424". This occurs because disabling CONFIG_NET_RX_BUSY_POLL disables the SKB NAPI mapping in __skb_mark_napi_id(). Consequently, get_timestamp() fails to perform its driver lookup, and the igc driver's struct net_device_ops::ndo_get_tstamp is never invoked. Instead, get_timestamp() falls back to use shhwtstamps(skb)->hwtstamp, a field that the driver has not populated. This results in incorrect timestamps. Fix this by populating the hwtstamp field with the correct timestamp in the default timer when CONFIG_NET_RX_BUSY_POLL is disabled. The "igc_adapter" is passed to igc_construct_skb() to enable igc_ptp_rx_pktstamp() to access the necessary adapter details for adjusting the timestamp. Test case: Disable CONFIG_NET_RX_BUSY_POLL. Sender: # tools/testing/selftests/net/timestamping en0 \ SOF_TIMESTAMPING_TX_HARDWARE PTPV2 IP_MULTICAST_LOOP Receiver: # tools/testing/selftests/net/timestamping en0 \ SOF_TIMESTAMPING_RX_HARDWARE SOF_TIMESTAMPING_RAW_HARDWARE PTPV2 Before patch, receiver prints HW raw -121948.050407424 After patch, receiver prints HW raw 1760648763.746974064 Fixes: 069b142f5819 ("igc: Add support for PTP .getcyclesx64()") Cc: stable@vger.kernel.org Co-developed-by: Florian Bezdeka Signed-off-by: Florian Bezdeka Signed-off-by: Ding Meng Reviewed-by: Aleksandr Loktionov Reviewed-by: Piotr Kwapulinski --- V2: - update commit message(suggested by Paul Menzel): add error log explain why need to pass igc_adapter add test case - move variable declarations on top of the function - Cc stable@vger.kernel.org V1: https://lore.kernel.org/intel-wired-lan/20260622041718.6106-1-meng.ding@siemens.com/ --- drivers/net/ethernet/intel/igc/igc_main.c | 41 ++++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 8ac16808023..5c4beb8b5d4 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1992,7 +1992,29 @@ static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring, return skb; } -static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring, +static void igc_construct_skb_timestamps(struct igc_adapter *adapter, + struct sk_buff *skb, + struct igc_xdp_buff *ctx) +{ +#ifndef CONFIG_NET_RX_BUSY_POLL + struct igc_inline_rx_tstamps *tstamps; +#endif + + if (!ctx->rx_ts) + return; + +#ifndef CONFIG_NET_RX_BUSY_POLL + tstamps = ctx->rx_ts; + skb_hwtstamps(skb)->hwtstamp = igc_ptp_rx_pktstamp(adapter, + tstamps->timer0); +#else + skb_shinfo(skb)->tx_flags |= SKBTX_HW_TSTAMP_NETDEV; + skb_hwtstamps(skb)->netdev_data = ctx->rx_ts; +#endif +} + +static struct sk_buff *igc_construct_skb(struct igc_adapter *adapter, + struct igc_ring *rx_ring, struct igc_rx_buffer *rx_buffer, struct igc_xdp_buff *ctx) { @@ -2013,10 +2035,7 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring, if (unlikely(!skb)) return NULL; - if (ctx->rx_ts) { - skb_shinfo(skb)->tx_flags |= SKBTX_HW_TSTAMP_NETDEV; - skb_hwtstamps(skb)->netdev_data = ctx->rx_ts; - } + igc_construct_skb_timestamps(adapter, skb, ctx); /* Determine available headroom for copy */ headlen = size; @@ -2686,7 +2705,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) else if (ring_uses_build_skb(rx_ring)) skb = igc_build_skb(rx_ring, rx_buffer, &ctx.xdp); else - skb = igc_construct_skb(rx_ring, rx_buffer, &ctx); + skb = igc_construct_skb(adapter, rx_ring, rx_buffer, &ctx); /* exit if we failed to retrieve a buffer */ if (!xdp_res && !skb) { @@ -2738,7 +2757,8 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) return total_packets; } -static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring, +static struct sk_buff *igc_construct_skb_zc(struct igc_adapter *adapter, + struct igc_ring *ring, struct igc_xdp_buff *ctx) { struct xdp_buff *xdp = &ctx->xdp; @@ -2760,10 +2780,7 @@ static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring, __skb_pull(skb, metasize); } - if (ctx->rx_ts) { - skb_shinfo(skb)->tx_flags |= SKBTX_HW_TSTAMP_NETDEV; - skb_hwtstamps(skb)->netdev_data = ctx->rx_ts; - } + igc_construct_skb_timestamps(adapter, skb, ctx); return skb; } @@ -2775,7 +2792,7 @@ static void igc_dispatch_skb_zc(struct igc_q_vector *q_vector, struct igc_ring *ring = q_vector->rx.ring; struct sk_buff *skb; - skb = igc_construct_skb_zc(ring, ctx); + skb = igc_construct_skb_zc(q_vector->adapter, ring, ctx); if (!skb) { ring->rx_stats.alloc_failed++; set_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &ring->flags); base-commit: 4549871118cf616eecdd2d939f78e3b9e1dddc48 -- 2.47.3