From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by mail.toke.dk (Postfix) with ESMTPS id 395FB9C225C for ; Tue, 15 Nov 2022 04:02:22 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=IJf/QnwP Received: by mail-pl1-x64a.google.com with SMTP id u6-20020a170903124600b00188cd4769bcso2434054plh.0 for ; Mon, 14 Nov 2022 19:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uak+AW+U5N4YbNn9buxZQp6UdtaFEKD9ZsMrNaxGG78=; b=IJf/QnwPGrSOWHjPA+9ALOSOh1NqTsi7DNF5o+Ei0MEPHu3z8rVErhbWDW95Xosh6Q uIBw9AgpUELCuBvp7NE8jOywhhD14OWbd78fEpD6KxeVYeOJoAmeyT0cCxCKVBRoR43c /6xdh7hMjmO+XCoGDf8FglKZERcU0WkoRUeHblmrOArJDbR8R6Ss6ko8vZDfltoFJS2M HIf4E/Rd05rwvEfBTnJTl9AYs3HcQrTnW7JJ8cVq+HBocflxY2Z1/iM46aeDi/Xb7xm4 eFMvBRDWXPWdAaEwFcbd4HsFoNUByfHnFSyu8YxGlhbGhjJXdZGHki+EooWK7TxPBQsf Q7Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uak+AW+U5N4YbNn9buxZQp6UdtaFEKD9ZsMrNaxGG78=; b=w9tNBmQ3Tz8Rwfw0lTBNdHTX+rs5eH5dIQFqqMkMatVQH/5yW2upkTnn0W3jW1zvPa Mu0fpSHsLbXJcrb9pKulQfPF3SeCeMMHLhr7gYcCEdk4oSIZNJOZwY+Yz8mKV2b6HClP pbnvxUrq1HQHXSRzXEpFydz9xbQyAyxUnzPOzz1lAOPp0lFBc7CZzSCLBmCpNrfUWrPh yEhnskbJo/626HU19iR316LtNKvgc58LtD4PJgbEoLV9orGT54ANGQ8OMTqpoAb8ZN4D emRt7wSDUe4fHGOrIAXqsBZP2ZqU0pmauhnOhCMjEkX9wC5TcyVnbG9DQ9xz+7WkDBg/ Sz4w== X-Gm-Message-State: ANoB5pk0lZKfTuZvzJwsGpW0y3ExEPfgimykaIhKKde08NzyClzNxM12 aIceH0s/XeLWMUyLprpgcjju+NY= X-Google-Smtp-Source: AA0mqf7XuKdCJk8xpjbtBEno+Sz5is/P53QXTUKvG4x+k1O80lInCyELmD/UVxjXkUNmhMxob/eWiBA= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:e546:b0:186:c56d:4950 with SMTP id n6-20020a170902e54600b00186c56d4950mr2116464plf.69.1668481341128; Mon, 14 Nov 2022 19:02:21 -0800 (PST) Date: Mon, 14 Nov 2022 19:02:04 -0800 In-Reply-To: <20221115030210.3159213-1-sdf@google.com> Mime-Version: 1.0 References: <20221115030210.3159213-1-sdf@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221115030210.3159213-6-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: TUBTBJZNFUESEABORQ7GDSKR4N6G6YTA X-Message-ID-Hash: TUBTBJZNFUESEABORQ7GDSKR4N6G6YTA X-MailFrom: 3PQFzYwMKCS4cNPQYYQVO.MYWhNZ-RSXdchNZ-ZbYTOMd.XOd@flex--sdf.bounces.google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.6 Precedence: list Subject: [xdp-hints] [PATCH bpf-next 05/11] veth: Support rx timestamp metadata for xdp List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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