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 5EDDC9CF276 for ; Tue, 13 Dec 2022 03:36: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=X02gtD4d Received: by mail-pl1-x64a.google.com with SMTP id p6-20020a170902e74600b001896ba6837bso11963365plf.17 for ; Mon, 12 Dec 2022 18:36:21 -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=d8hcKXQLNNQ4WAgQXpWd59iukIOCYOBUZwXa1y2qCeI=; b=X02gtD4dAC/yQa/roDaEjtKXDqiYXTGbbQzFNXNkEXDcU0XIjrnb7WBa5AcE/ls0K4 wrl7BBUJ/9dpHFLA/zg+IGS9i2Y//8UE/UHzYgEh7z0cCMdX/vTMKkds7ihxeu0nxF1A 4Hyl758h2etOysY52RCSpNjHy5yslAJMdQSSqR47wDnNxpAW/vXu9uC5CIYrRu58JTn2 7SkCx7KVmusAbCGB6ZIInjrw7Lqk3z/Mq9/GbZBsHPXE1b7mCVC9WcWZMMyiG8nL6zsX k6xNL2utwZHIQv1FUs+bCqjA1LheiGrrIqwl3xiKOMFBtvEpuImE9aGIudpD8Tb5RVcJ xe6A== 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=d8hcKXQLNNQ4WAgQXpWd59iukIOCYOBUZwXa1y2qCeI=; b=N0FjKCeuDjDE22rA514wvgcFtWolocCisv4Boq6iG3pVezkPWIzOLnNciKjDXIDIEr B3cgcQLjdIDzL5tGw5EZCE3pJbaMRKRS/EXn95Wu/NzO7LvDvOYy28jH/AdkaKcKGDGb AEtYO+S3kDKBlEHDQs2WXJjsojPTxNzjWFgN7DHkNEsmq73tKo4U5PrH5pU+t6LUNyt4 N0LRY59hi/JHQlJ2ZUDwWh9Ud5kHPsv3HmC3vhjn/vqHFnDzDFgA5mY2iMih+c+V2ZHC Ji3pEVKCXDeGxxEbr2rg5x9pAqhqu8x9agfHP2Fz540ZcoNA86Hmndl3gwBFoXrVXOhb DACg== X-Gm-Message-State: ANoB5plrNbHcq+5HUy3BT2BapNVDQjsgQaJXK0m6p7173JxqndpPUqa3 cVkCQ9gbC009MjrBcMB9F9pfPRE= X-Google-Smtp-Source: AA0mqf6//DJzqTv5zHLOXNZ5ezU8ozVCcxgYuAbglp754hLu10S9H7MxyeauJF2EIfRBCIOMJi7vVvQ= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:90a:d358:b0:20d:d531:97cc with SMTP id i24-20020a17090ad35800b0020dd53197ccmr107286pjx.164.1670898980424; Mon, 12 Dec 2022 18:36:20 -0800 (PST) Date: Mon, 12 Dec 2022 18:35:58 -0800 In-Reply-To: <20221213023605.737383-1-sdf@google.com> Mime-Version: 1.0 References: <20221213023605.737383-1-sdf@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221213023605.737383-9-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: IFAXVMOCSTVV2AVXDDVHGAIOEASLSWL6 X-Message-ID-Hash: IFAXVMOCSTVV2AVXDDVHGAIOEASLSWL6 X-MailFrom: 3JOWXYwMKCXEhSUVddVaT.RdbmSe-WXcihmSe-egdYTRi.cTi@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 v4 08/15] 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 04ffd8cb2945..d5491e7a2798 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,21 @@ static int veth_xdp(struct net_device *dev, struct netdev_bpf *xdp) } } +static int veth_xdp_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp) +{ + *timestamp = ktime_get_mono_fast_ns(); + return 0; +} + +static int veth_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash) +{ + struct veth_xdp_buff *_ctx = (void *)ctx; + + if (_ctx->skb) + *hash = 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, @@ -1622,6 +1640,11 @@ static const struct net_device_ops veth_netdev_ops = { .ndo_get_peer_dev = veth_peer_dev, }; +static const struct xdp_metadata_ops veth_xdp_metadata_ops = { + .xmo_rx_timestamp = veth_xdp_rx_timestamp, + .xmo_rx_hash = veth_xdp_rx_hash, +}; + #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \ NETIF_F_RXCSUM | NETIF_F_SCTP_CRC | NETIF_F_HIGHDMA | \ NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL | \ @@ -1638,6 +1661,7 @@ static void veth_setup(struct net_device *dev) dev->priv_flags |= IFF_PHONY_HEADROOM; dev->netdev_ops = &veth_netdev_ops; + dev->xdp_metadata_ops = &veth_xdp_metadata_ops; dev->ethtool_ops = &veth_ethtool_ops; dev->features |= NETIF_F_LLTX; dev->features |= VETH_FEATURES; -- 2.39.0.rc1.256.g54fd8350bd-goog