From nobody Mon Feb 9 05:41:53 2026 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D51BE2F8BC3 for ; Thu, 18 Dec 2025 02:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766024995; cv=none; b=uzmIdcLTd8Dx4cFJnGyewEJrSGsrMFH68DhdVESd2v4ae9soOoG7Y5hbsXsNg2JtCxa92R2VMqycSYY1RS7KRtMEVVVfdRMY2uyMEJunLLsSN8YLTsXZiYVm7f+b2khr5El2wVLW0BykMOOELd2ZGKzanMpIxTwu8+oN9Thc1Hs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766024995; c=relaxed/simple; bh=zlziAxvPwJj8HgeZzSpcXhPCekluk2rCReJ0Fw/8umI=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=UVjfrtdeIuEsl5MVGiNcyr9Ai3uYe3Em1rNUwo7b7ZLK0o0RIyZ4aUdnWxFfDVy48HrEgk51pa1G+Va7XJvkVq7E9XMvwQqKZMAdkMFQb5jW31KcJM22NmNwSIMbLN7Xi7o3/StFtnNJ6vogdZ8oCtoqhETNK4o++wlhuqko8ac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=auPdLCaL; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="auPdLCaL" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7d481452732so381989b3a.1 for ; Wed, 17 Dec 2025 18:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766024993; x=1766629793; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Mbkt/LgClY9Ed+U/AqFg7ozVmIhVbSqVhAx0YrbLQGM=; b=auPdLCaLlkQy1M/9nZdm6uFAKeS7L18O3gf6MxeCrUa3GCPDKcnXGec8Dgx0IUN+2h JF7sGTiJqVE9U4QSixNOhow+OX+Q3vrxmJZgsgga1GQRplD7VxCtvFe/sB1uE47fPL83 +ra7aEqWsQ1RSVWi4zFov6YuI8wlJwXCtGp0C/Wvp0pEzDyt1e1Im6bM/QwRrBS9qaYB zD540uwf/HPJqlWxgJ39x+cACzJVOvT0f4i4ap0EbJQmRjbD3njiBiphGi73th6rsq0w Xh5+pRXwCNCpT1IPTU8HKQgEXOXlonyPE+dfoX5KTLI2FxNdnC9wfVTuhsBSGDJg7PiJ mE+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766024993; x=1766629793; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Mbkt/LgClY9Ed+U/AqFg7ozVmIhVbSqVhAx0YrbLQGM=; b=WaiBJwhMmdsjVrTFoAQRd/m0xruuNynnT1EcEM7E3/Shp0XWNg8022uNec2Wo4yZVW oqd2XmODVQplgxnPZJdr7RymsyUdizo9Wb8zklcsqT/NjT1hrcnSCTDB7A8rs6sQHg/U uw/8VsoqMBH+uIjc+/KctjfoNCjuMO5vDM6bCD7KM6YEsfFnu6EYkzu9dpathqOPoKJb 5IHmVUPydVFQTwOM9UWELgT6tgMW9hpOG2Fi0nrG2bpg4gCMAF5WX5ZyBI1sysxaKCr1 A0gCuV2HOJPyLj7PgL0DSaexOaLQLnsuJ3KvKGHlc3V0rsULwP3XbEX7T1+5VaybgZe/ iKHA== X-Forwarded-Encrypted: i=1; AJvYcCUZgPGanAZVB9Ew9EfBURAbMlMiH139DvXOmfYuTGYW3RkFMiTvr5EjjXgeXtPAnpgnbjdiYl3s2NXcnAQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxE0gkNFZCS7VWk7GQM220bWZGPanZ5r1yPPY7UYWszsAYTLoA1 8jtVe4h9qkY0XXR4OGnm9xv29Ocihvcy7Ix0JCKusvCE8qXGZrJbjAeD652e+5bUOwGmo0pFlVM /FbhgpxVGSQop4OOxCzEu9r7AMg== X-Google-Smtp-Source: AGHT+IFE6xajScfzbLpRFiQQS67W5ZN8gStF0mO1QPIpwdD4OiKSevZ12bwmQxwPQs3VZazL0vtBUS/b7RY63UwVGw== X-Received: from dlbrj5.prod.google.com ([2002:a05:7022:f405:b0:11f:2e2e:de3]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2902:b0:11b:8f02:a876 with SMTP id a92af1059eb24-11f354cce50mr11251803c88.23.1766024992932; Wed, 17 Dec 2025 18:29:52 -0800 (PST) Date: Thu, 18 Dec 2025 02:29:36 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.313.g674ac2bdf7-goog Message-ID: <20251218022948.3288897-1-almasrymina@google.com> Subject: [PATCH net-next v2] idpf: export RX hardware timestamping information to XDP From: Mina Almasry To: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: YiFei Zhu , Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Tony Nguyen , Przemek Kitszel , Andrew Lunn , Eric Dumazet , Paolo Abeni , Alexander Lobakin , Richard Cochran , intel-wired-lan@lists.osuosl.org, Mina Almasry , Aleksandr Loktionov Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: YiFei Zhu The logic is similar to idpf_rx_hwtstamp, but the data is exported as a BPF kfunc instead of appended to an skb. A idpf_queue_has(PTP, rxq) condition is added to check the queue supports PTP similar to idpf_rx_process_skb_fields. Cc: intel-wired-lan@lists.osuosl.org Signed-off-by: YiFei Zhu Signed-off-by: Mina Almasry Reviewed-by: Aleksandr Loktionov --- v2: https://lore.kernel.org/netdev/20251122140839.3922015-1-almasrymina@goo= gle.com/ - Fixed alphabetical ordering - Use the xdp desc type instead of virtchnl one (required some added helpers) --- drivers/net/ethernet/intel/idpf/xdp.c | 29 +++++++++++++++++++++++++++ drivers/net/ethernet/intel/idpf/xdp.h | 17 ++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/net/ethernet/intel/idpf/xdp.c b/drivers/net/ethernet/i= ntel/idpf/xdp.c index 958d16f87424..7744d6898f74 100644 --- a/drivers/net/ethernet/intel/idpf/xdp.c +++ b/drivers/net/ethernet/intel/idpf/xdp.c @@ -2,6 +2,7 @@ /* Copyright (C) 2025 Intel Corporation */ =20 #include "idpf.h" +#include "idpf_ptp.h" #include "idpf_virtchnl.h" #include "xdp.h" #include "xsk.h" @@ -391,8 +392,36 @@ static int idpf_xdpmo_rx_hash(const struct xdp_md *ctx= , u32 *hash, pt); } =20 +static int idpf_xdpmo_rx_timestamp(const struct xdp_md *ctx, u64 *timestam= p) +{ + const struct libeth_xdp_buff *xdp =3D (typeof(xdp))ctx; + struct idpf_xdp_rx_desc desc __uninitialized; + const struct idpf_rx_queue *rxq; + u64 cached_time, ts_ns; + u32 ts_high; + + idpf_xdp_get_qw1(&desc, xdp->desc); + rxq =3D libeth_xdp_buff_to_rq(xdp, typeof(*rxq), xdp_rxq); + + if (!idpf_queue_has(PTP, rxq)) + return -ENODATA; + if (!(idpf_xdp_rx_ts_low(&desc) & VIRTCHNL2_RX_FLEX_TSTAMP_VALID)) + return -ENODATA; + + cached_time =3D READ_ONCE(rxq->cached_phc_time); + + idpf_xdp_get_qw3(&desc, xdp->desc); + + ts_high =3D idpf_xdp_rx_ts_high(&desc); + ts_ns =3D idpf_ptp_tstamp_extend_32b_to_64b(cached_time, ts_high); + + *timestamp =3D ts_ns; + return 0; +} + static const struct xdp_metadata_ops idpf_xdpmo =3D { .xmo_rx_hash =3D idpf_xdpmo_rx_hash, + .xmo_rx_timestamp =3D idpf_xdpmo_rx_timestamp, }; =20 void idpf_xdp_set_features(const struct idpf_vport *vport) diff --git a/drivers/net/ethernet/intel/idpf/xdp.h b/drivers/net/ethernet/i= ntel/idpf/xdp.h index 479f5ef3c604..86be6cae9689 100644 --- a/drivers/net/ethernet/intel/idpf/xdp.h +++ b/drivers/net/ethernet/intel/idpf/xdp.h @@ -112,11 +112,13 @@ struct idpf_xdp_rx_desc { aligned_u64 qw1; #define IDPF_XDP_RX_BUF GENMASK_ULL(47, 32) #define IDPF_XDP_RX_EOP BIT_ULL(1) +#define IDPF_XDP_RX_TS_LOW GENMASK_ULL(31, 24) =20 aligned_u64 qw2; #define IDPF_XDP_RX_HASH GENMASK_ULL(31, 0) =20 aligned_u64 qw3; +#define IDPF_XDP_RX_TS_HIGH GENMASK_ULL(63, 32) } __aligned(4 * sizeof(u64)); static_assert(sizeof(struct idpf_xdp_rx_desc) =3D=3D sizeof(struct virtchnl2_rx_flex_desc_adv_nic_3)); @@ -128,6 +130,8 @@ static_assert(sizeof(struct idpf_xdp_rx_desc) =3D=3D #define idpf_xdp_rx_buf(desc) FIELD_GET(IDPF_XDP_RX_BUF, (desc)->qw1) #define idpf_xdp_rx_eop(desc) !!((desc)->qw1 & IDPF_XDP_RX_EOP) #define idpf_xdp_rx_hash(desc) FIELD_GET(IDPF_XDP_RX_HASH, (desc)->qw2) +#define idpf_xdp_rx_ts_low(desc) FIELD_GET(IDPF_XDP_RX_TS_LOW, (desc)->qw1) +#define idpf_xdp_rx_ts_high(desc) FIELD_GET(IDPF_XDP_RX_TS_HIGH, (desc)->q= w3) =20 static inline void idpf_xdp_get_qw0(struct idpf_xdp_rx_desc *desc, @@ -166,6 +170,19 @@ idpf_xdp_get_qw2(struct idpf_xdp_rx_desc *desc, #endif } =20 +static inline void +idpf_xdp_get_qw3(struct idpf_xdp_rx_desc *desc, + const struct virtchnl2_rx_flex_desc_adv_nic_3 *rxd) +{ +#ifdef __LIBETH_WORD_ACCESS + desc->qw3 =3D ((const typeof(desc))rxd)->qw3; +#else + desc->qw3 =3D ((u64)le32_to_cpu(rxd->ts_high) << 32) | + ((u64)le16_to_cpu(rxd->fmd6) << 16) | + le16_to_cpu(rxd->l2tag1); +#endif +} + void idpf_xdp_set_features(const struct idpf_vport *vport); =20 int idpf_xdp(struct net_device *dev, struct netdev_bpf *xdp); base-commit: 8f7aa3d3c7323f4ca2768a9e74ebbe359c4f8f88 --=20 2.52.0.313.g674ac2bdf7-goog