From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by mail.toke.dk (Postfix) with ESMTPS id CD44E9C4580 for ; Mon, 21 Nov 2022 19:26: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=nGfSDe2D Received: by mail-yb1-xb4a.google.com with SMTP id p188-20020a2542c5000000b006ea37a57e20so5770473yba.13 for ; Mon, 21 Nov 2022 10:26: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=nGfSDe2DYoxrfRJM92Demm7pOqfd7RPX22MBlXes4IY7HfiP5o0gVQa4NY18BS7O3V ijUK8jdXFdYCL01B3H5kIIo9vRVZ8bvATKG4HhZAEp28q0uOFHHbgjfPTY1agIOjyQJy CiUwKVBs92/QDd48/cZYuDFWrUCVsBkCfYXQLatyNh56Bps4QCp+83aXOaEq4CLrf+1q FpFx+jw3f5Hxrgn/yLI9tKsF1+Dw4lWFkEcBvCaJKW50nrqHN2PuBKfIopRRoKLak24J qCC6r2WODR39cXj0X8pj0gkBrSR+A/KeplR8T90XKvkqVxycIHUna7tm/9z9gQhxaRVN 2Kaw== 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=xFUD3/J11C2H6NVzALN3n69xF30GFPRJRo6/CWLmp06w80BW1KeRUnJ240nH7SIe7N A5eyk7EahQZze3TX2Qc6+WnCE6lu4Wd1z6i3AmpJFMFTfqNADX02op/3/9pCFgO+VEfW bv2xsZXkOxhIYgq6ZJ0bAyOALAyKQEkRRiKelx3QFEnwStCgK5vLbBZNkuKI6aqTiwub ZWY1osIFKFb9BHhSb/B3Q47U+XXOSRh8mYOTHeUaD2NheMPkqAeluix4C9UgRNbyYN7v cRCbEJhHw/vrjTVDf+D/G5DyuQxrk56Ek15ZD17wlh1YoV20vwJEFq62G3v0+aruNTiM eCPw== X-Gm-Message-State: ANoB5pmRTRbnQu1S/fV3oa4BIql3z37yxhZedSFD8l1i9HNX9KkP2F6p RZ0mWxjtOL5HVc7c14SvG5inGW8= X-Google-Smtp-Source: AA0mqf7Zvrdzts6EXSee4UxjaQCvfRToP6ufXZ+7H0SjWmKi3dLmD4QUHbSFIPNlx2zeDuusPo3f0KU= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a25:2355:0:b0:6dd:c522:e3ba with SMTP id j82-20020a252355000000b006ddc522e3bamr18834148ybj.8.1669055160955; Mon, 21 Nov 2022 10:26:00 -0800 (PST) Date: Mon, 21 Nov 2022 10:25:48 -0800 In-Reply-To: <20221121182552.2152891-1-sdf@google.com> Mime-Version: 1.0 References: <20221121182552.2152891-1-sdf@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221121182552.2152891-5-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 2IDCDPSEQYYOXVGPF6BTKKTVACA44C7O X-Message-ID-Hash: 2IDCDPSEQYYOXVGPF6BTKKTVACA44C7O X-MailFrom: 3uMJ7YwMKCU89uwx55x2v.t53Eu6-yz4A9Eu6-6850vtA.4vA@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 v2 4/8] 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