From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by mail.toke.dk (Postfix) with ESMTPS id 56CDD9C8050 for ; Tue, 29 Nov 2022 20:35:02 +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=MNY8BvZ0 Received: by mail-pj1-x104a.google.com with SMTP id r10-20020a17090a1bca00b002137a500398so10409345pjr.5 for ; Tue, 29 Nov 2022 11:35:02 -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=wPmPkc5zN4giDUb/1je/PGUtX+no8JSv+Kak++hjwtw=; b=MNY8BvZ09pHzqv0MGpyAb2uDcgHShpvSuC9lTAmNeh1Fs963q9LxEASSeJ71yjwa8k F+C15Q+WAe+R50x9nXYu8STSpM/n4LPeF71xU0f60rx5ac7QBwYYW5T5WJ9OQmw+INFu tMuV2+14BrTrpuT76neAOrMuRurHqFOPXezTw8s8ND91WrURg4pjUCsOpU8XrdgAA65Q gkE7lBJfxIUC++xnvLi2dboa2aruzMrURfzV+hrmoVoCBZ8JutLps+CiKdLSbre6BgVt 7jc3i4/F6WeWXlcA/6KcylDI55gm3Ap8yrfPjblwFsB+HizGNkHmvRkneYZyrmzVoDtE isDQ== 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=wPmPkc5zN4giDUb/1je/PGUtX+no8JSv+Kak++hjwtw=; b=fWP6Z0NAd/mqQZo9ORQydbIF6OPakxAj7SnRSOSXt5yILNbDJRcVDXIPKGfPK0emH8 zYUVIj2tXX9Z1T6SpbOVvpi3z5YVYK4BsbO1oUcWkgOo5HVB52LawrcLWbC+PrD1zpey mOHJcpz9hZYGN+FR2k+iJyrKy16GOh8O6aUbeaFaNHFap6+F6waVlZizaq8NjmC6l3Wx Pr6DXkMUXiPjkKxetOoemF7D/OHFW87YN8wWQsb8yOyh8KsrvObW/CWUsRIGK7MOa3B+ 66deHV5Tewkg9VZzBTMd5cVt1iooQQxPXvzWzFRmw5DWcJWTXVtbnnV38HPqJwWk2NF3 UOtQ== X-Gm-Message-State: ANoB5pmpUUcAiViBC4BxOCVO9/QIVNxCnwyUW9eqW/ONkwWmFpfpAwg4 40xofvoRUEDlVkiiRnJiGYZH78U= X-Google-Smtp-Source: AA0mqf7hDYXc10wDSV6aDgnImYUx4Ev4XgaVuwQ0D8DNXI8+yJt2K8vAMnUY2g5A2FXR24jzrU+iAxg= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:cf0e:b0:186:6723:9217 with SMTP id i14-20020a170902cf0e00b0018667239217mr38917968plg.160.1669750500886; Tue, 29 Nov 2022 11:35:00 -0800 (PST) Date: Tue, 29 Nov 2022 11:34:45 -0800 In-Reply-To: <20221129193452.3448944-1-sdf@google.com> Mime-Version: 1.0 References: <20221129193452.3448944-1-sdf@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221129193452.3448944-5-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: BFNEF34YI6WS3T7YRZFIXYXISKGSL5KH X-Message-ID-Hash: BFNEF34YI6WS3T7YRZFIXYXISKGSL5KH X-MailFrom: 35F6GYwMKCd0RCEFNNFKD.BNLWCO-GHMSRWCO-OQNIDBS.MDS@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.7 Precedence: list Subject: [xdp-hints] [PATCH bpf-next v3 04/11] veth: Support RX XDP metadata 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. 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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index bbabc592d431..fdbca2aee33a 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -118,6 +118,7 @@ static struct { struct veth_xdp_buff { struct xdp_buff xdp; + struct sk_buff *skb; }; static int veth_get_link_ksettings(struct net_device *dev, @@ -602,6 +603,7 @@ static struct xdp_frame *veth_xdp_rcv_one(struct veth_rq *rq, xdp_convert_frame_to_buff(frame, xdp); xdp->rxq = &rq->xdp_rxq; + vxbuf.skb = NULL; act = bpf_prog_run_xdp(xdp_prog, xdp); @@ -823,6 +825,7 @@ static struct sk_buff *veth_xdp_rcv_skb(struct veth_rq *rq, __skb_push(skb, skb->data - skb_mac_header(skb)); if (veth_convert_skb_to_xdp_buff(rq, xdp, &skb)) goto drop; + vxbuf.skb = skb; orig_data = xdp->data; orig_data_end = xdp->data_end; @@ -1665,6 +1668,30 @@ static int veth_xdp(struct net_device *dev, struct netdev_bpf *xdp) } } +static bool veth_xdp_rx_timestamp_supported(const struct xdp_md *ctx) +{ + return true; +} + +static u64 veth_xdp_rx_timestamp(const struct xdp_md *ctx) +{ + return ktime_get_mono_fast_ns(); +} + +static bool veth_xdp_rx_hash_supported(const struct xdp_md *ctx) +{ + return true; +} + +static u32 veth_xdp_rx_hash(const struct xdp_md *ctx) +{ + struct veth_xdp_buff *_ctx = (void *)ctx; + + if (_ctx->skb) + return skb_get_hash(_ctx->skb); + return 0; +} + static const struct net_device_ops veth_netdev_ops = { .ndo_init = veth_dev_init, .ndo_open = veth_open, @@ -1684,6 +1711,11 @@ 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_xdp_rx_timestamp_supported = veth_xdp_rx_timestamp_supported, + .ndo_xdp_rx_timestamp = veth_xdp_rx_timestamp, + .ndo_xdp_rx_hash_supported = veth_xdp_rx_hash_supported, + .ndo_xdp_rx_hash = veth_xdp_rx_hash, }; #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \ -- 2.38.1.584.g0f3c55d4c2-goog