From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by mail.toke.dk (Postfix) with ESMTPS id D15119CB5F3 for ; Tue, 6 Dec 2022 03:46:06 +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=fE3/mCQD Received: by mail-pl1-x649.google.com with SMTP id h7-20020a170902f54700b00189deebdb91so3064516plf.9 for ; Mon, 05 Dec 2022 18:46:06 -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=SzXogjIzoRMtGz3qf2OXFTX6uh6o2Pg0lmLXO515upU=; b=fE3/mCQDWTHc0cieBS6LWbwMD2MaY4GiFErL7T7VZ6K81vosuugj2NU/GpHtiJxs6y SgXd5y2wZfNfpF39ZosNx8XBsJX/XjeYlNI2dArNBzsCADJ2rWiMsRXHLiEOgodGNeOp vYJAE6BlyrkNJhZpcJtvUWlPbp73s+FTzyWMD7WEkKX6FzB5SLCRpshAhT2JqEYH2j+Y PKK9ZKbI/CJLZ664AK+Ar6liYAT/2OKSlmAxCgtUUoKJYseXn2GnfpJB2gRs41RJA1eJ mTZIVmk+weDwBkFd0hzSMWiFyXM7oKMVDS3oTUmuPvdYZbQ0TMrbzW16vciZGxOrNh8p NsTA== 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=SzXogjIzoRMtGz3qf2OXFTX6uh6o2Pg0lmLXO515upU=; b=1BxOG6l+bQzdfbj7ip4khrNIuZyFHFFN3gPwG2N74Iq6kGypy1r6Uko9nHdvQWymKG Uh4IVGQqwgdtzfCMBxmZXZqM14UMUB0t575ah1QsL3OD34l/Q+QC6PNY2WRCuQZsa8HE DB6N2b9fkZJTZvnfcWAv1Vu35Hv9hf8rp6gvTN7vM7k+PjSJ4NzEl8YX3Vc/z9o7kGa3 wo6HVJfD7FmvU9YoPFfISdC5Q5pY+GRAkp1+YJjYZjjZo+FweCZ4FcyXwE3EyN9NCZ37 J4ay4hzV7xVteSuzUO9E5y1fC9Wfn2Beop27gvAjXk2bN2bNODarNqnhNK3Au8hJDmHq zbaw== X-Gm-Message-State: ANoB5pmN876AqZpUNcyMVAWqaIr+zwnuHsbKGPPenggA8jm6NOd2XeL/ AU683vduBqyYEMuQiPNfX98/OAw= X-Google-Smtp-Source: AA0mqf5p0oPGMegJ4tB/4oONpYIL3mMpGTuIbSrRWseQ31uO04j4I0O78cVXjTtPKiGmLD3jGFDXhpY= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:90b:f89:b0:219:5b3b:2b9f with SMTP id ft9-20020a17090b0f8900b002195b3b2b9fmr3170949pjb.2.1670294764176; Mon, 05 Dec 2022 18:46:04 -0800 (PST) Date: Mon, 5 Dec 2022 18:45:47 -0800 In-Reply-To: <20221206024554.3826186-1-sdf@google.com> Mime-Version: 1.0 References: <20221206024554.3826186-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog Message-ID: <20221206024554.3826186-6-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: UJYV55XTVX26DRF27B4B7CG4WTDRM4SC X-Message-ID-Hash: UJYV55XTVX26DRF27B4B7CG4WTDRM4SC X-MailFrom: 37KyOYwMKCaMVGIJRRJOH.FRPaGS-KLQWVaGS-SURMHFW.QHW@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 05/12] 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 04ffd8cb2945..d15302672493 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; @@ -1601,6 +1604,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, @@ -1620,6 +1647,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.39.0.rc0.267.gcb52ba06e7-goog