From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 274D63B29E for ; Wed, 16 Nov 2022 15:16:17 -0500 (EST) Received: by mail-wr1-x432.google.com with SMTP id bs21so31833675wrb.4 for ; Wed, 16 Nov 2022 12:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=Jwjnnruo6ZheYEK1kY3YSqCo4lZo+SaxxgF+0GFKvwc=; b=AGRrDU6GpMvTtRszHaujupSuBida4U+BeYg8jN7jCrCRcnW5aTyWnAqu3/kGjBVylj Toqmpq6/8IybtRzOwzUnlAEQChQb2HSDuY10lOfGRoshtXSWXm4od53QJ/eUNUEhJ3lo IIESeeo0eMCYncjQJ/HNWoQ4p1KgoEv9yUrJuHcjxJH7SxSUYVxCbbQ9ImKBTmyPlsXp lf8vkhn0vF5ZWIItRmEv5qHkWsfhq/VwdrOgffp3qbRnkKCkKUY1S28Rs5q9WQGndmHP nN6tndMC5V9SPfEUjh0ijFtlXtKlsd7YNvOzAZh+LRpRaSV7D60+PtOGuowwBEvIMg2U F9sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Jwjnnruo6ZheYEK1kY3YSqCo4lZo+SaxxgF+0GFKvwc=; b=gStajPksAcVw0XhNn2OpE4F6XoWvKtCwXmW9uW1LgkWy6tSbCrNq4bt8ykazDqYN5O XnMpL6vl5D9YMLszSSUHmQjC+syQwzwNQsVd/EOAV4MZlRT4cZxdFX4G/yfBeyO9lggY vxMPsbkkiN9tD0ZYxr+vYuIprs0KSJHt3V1FJr5/AuBwa6qSxEgTWDo8Hg4K2NAdNGh+ vdtbTne4t/9PN1N931B0rXXN6OyUkBa8IR0nv+tyZVX+++4p6iF58g45KXQeDFEJWLQ9 dDOpxk9nd3rdin0RNsdiT2MtXxnjKzSDBw7cyTb/19zSLjcI+dwAiHt07kdPq29inn48 e7Mw== X-Gm-Message-State: ANoB5pmsw2PpqF/wzoCKW9KQtVW/ttGlkZdXTQ1eGwYDhqxYqTIdRjnu +p6uGY9RTZ6ZbWHthLVjNWp2k/BMrIP4BDDwLPawUNJk X-Google-Smtp-Source: AA0mqf4K9nmQoiL1A28hJ/puIE788ByJ91YrjjrVxzgHJMO9Req3vcm/B1VNSfcrV7O9tGCWvIvoRf+yrjfH3m+02ko= X-Received: by 2002:adf:ce88:0:b0:23a:ce24:1bf0 with SMTP id r8-20020adfce88000000b0023ace241bf0mr14497658wrn.383.1668629775743; Wed, 16 Nov 2022 12:16:15 -0800 (PST) MIME-Version: 1.0 References: <20221115030210.3159213-1-sdf@google.com> <20221115030210.3159213-6-sdf@google.com> In-Reply-To: <20221115030210.3159213-6-sdf@google.com> From: Dave Taht Date: Wed, 16 Nov 2022 12:16:03 -0800 Message-ID: To: libreqos Content-Type: multipart/alternative; boundary="0000000000000b8b1105ed9c25b1" Subject: [LibreQoS] Fwd: [PATCH bpf-next 05/11] veth: Support rx timestamp metadata for xdp X-BeenThere: libreqos@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Many ISPs need the kinds of quality shaping cake can do List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Nov 2022 20:16:17 -0000 --0000000000000b8b1105ed9c25b1 Content-Type: text/plain; charset="UTF-8" We presently timestamp in cake. Faster to have the hw do it. ---------- Forwarded message --------- From: Stanislav Fomichev Date: Mon, Nov 14, 2022, 7:13 PM Subject: [PATCH bpf-next 05/11] veth: Support rx timestamp metadata for xdp To: Cc: , , , < martin.lau@linux.dev>, , , < john.fastabend@gmail.com>, , , < haoluo@google.com>, , David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov < anatoly.burakov@intel.com>, Alexander Lobakin , Magnus Karlsson , Maryam Tahhan < mtahhan@redhat.com>, , The goal is to enable end-to-end testing of the metadata for AF_XDP. Current rx_timestamp kfunc returns current time which should be enough to exercise this new functionality. Cc: John Fastabend Cc: David Ahern Cc: Martin KaFai Lau Cc: Jakub Kicinski Cc: Willem de Bruijn Cc: Jesper Dangaard Brouer Cc: Anatoly Burakov Cc: Alexander Lobakin Cc: Magnus Karlsson Cc: Maryam Tahhan Cc: xdp-hints@xdp-project.net Cc: netdev@vger.kernel.org Signed-off-by: Stanislav Fomichev --- drivers/net/veth.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 2a4592780141..c626580a2294 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #define DRV_NAME "veth" @@ -1659,6 +1660,18 @@ static int veth_xdp(struct net_device *dev, struct netdev_bpf *xdp) } } +static void veth_unroll_kfunc(const struct bpf_prog *prog, u32 func_id, + struct bpf_patch *patch) +{ + if (func_id == xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_TIMESTAMP_SUPPORTED)) { + /* return true; */ + bpf_patch_append(patch, BPF_MOV64_IMM(BPF_REG_0, 1)); + } else if (func_id == xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_TIMESTAMP)) { + /* return ktime_get_mono_fast_ns(); */ + bpf_patch_append(patch, BPF_EMIT_CALL(ktime_get_mono_fast_ns)); + } +} + static const struct net_device_ops veth_netdev_ops = { .ndo_init = veth_dev_init, .ndo_open = veth_open, @@ -1678,6 +1691,7 @@ static const struct net_device_ops veth_netdev_ops = { .ndo_bpf = veth_xdp, .ndo_xdp_xmit = veth_ndo_xdp_xmit, .ndo_get_peer_dev = veth_peer_dev, + .ndo_unroll_kfunc = veth_unroll_kfunc, }; #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \ -- 2.38.1.431.g37b22c650d-goog --0000000000000b8b1105ed9c25b1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
We presently timestamp in cake. Faster to have the hw do = it.=C2=A0

---------- Forwarded message ---------
From: Stanislav Fomichev <sdf@google.com>
Da= te: Mon, Nov 14, 2022, 7:13 PM
Subject: [PATCH bpf-next 05/11] veth: Sup= port rx timestamp metadata for xdp
To: <bpf@vger.kernel.org>
Cc: <ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>, <ma= rtin.lau@linux.dev>, <song@ke= rnel.org>, <yhs@fb.com>, &= lt;john.fastabend@gmail.com= >, <kpsingh@kernel.org>= , <sdf@google.com>, <haoluo@google.com>, <jolsa@kernel.org>, David Ahern <dsahern@gmail.com>, Jakub Kicinski <= ;kuba@kernel.org>, Willem de Brui= jn <willemb@google.com>, Je= sper Dangaard Brouer <brouer@redhat= .com>, Anatoly Burakov <anatoly.burakov@intel.com>, Alexander Lobakin <alexandr.lobakin@intel.com>, Magnus = Karlsson <magnus.karlsson@g= mail.com>, Maryam Tahhan <m= tahhan@redhat.com>, <xdp-hints@xdp-project.net>, <netdev@vger.kernel.org>


The goal is to ena= ble end-to-end testing of the metadata
for AF_XDP. Current rx_timestamp kfunc returns current
time which should be enough to exercise this new functionality.

Cc: John Fastabend <john.fastabend@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Willem de Bruijn <willemb@google.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>
Cc: Magnus Karlsson <magnus.karlsson@gmail.com>
Cc: Maryam Tahhan <mtahhan@redhat.com>
Cc: xdp-hints@xdp-project.net
Cc: netdev@vger.kernel.org
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
=C2=A0drivers/net/veth.c | 14 ++++++++++++++
=C2=A01 file changed, 14 insertions(+)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 2a4592780141..c626580a2294 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -25,6 +25,7 @@
=C2=A0#include <linux/filter.h>
=C2=A0#include <linux/ptr_ring.h>
=C2=A0#include <linux/bpf_trace.h>
+#include <linux/bpf_patch.h>
=C2=A0#include <linux/net_tstamp.h>

=C2=A0#define DRV_NAME=C2=A0 =C2=A0 =C2=A0 =C2=A0"veth"
@@ -1659,6 +1660,18 @@ static int veth_xdp(struct net_device *dev, struct n= etdev_bpf *xdp)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0}

+static void veth_unroll_kfunc(const struct bpf_prog *prog, u32 func_id, +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct bpf_patch *patch)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (func_id =3D=3D xdp_metadata_kfunc_id(XDP_ME= TADATA_KFUNC_RX_TIMESTAMP_SUPPORTED)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* return true; */<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bpf_patch_append(pa= tch, BPF_MOV64_IMM(BPF_REG_0, 1));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0} else if (func_id =3D=3D xdp_metadata_kfunc_id= (XDP_METADATA_KFUNC_RX_TIMESTAMP)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* return ktime_get= _mono_fast_ns(); */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bpf_patch_append(pa= tch, BPF_EMIT_CALL(ktime_get_mono_fast_ns));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+}
+
=C2=A0static const struct net_device_ops veth_netdev_ops =3D {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .ndo_init=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =3D veth_dev_init,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .ndo_open=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =3D veth_open,
@@ -1678,6 +1691,7 @@ static const struct net_device_ops veth_netdev_ops = =3D {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .ndo_bpf=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =3D veth_xdp,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .ndo_xdp_xmit=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0=3D veth_ndo_xdp_xmit,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .ndo_get_peer_dev=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D= veth_peer_dev,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.ndo_unroll_kfunc=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D= veth_unroll_kfunc,
=C2=A0};

=C2=A0#define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSU= M | \
--
2.38.1.431.g37b22c650d-goog

--0000000000000b8b1105ed9c25b1--