From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mail.toke.dk (Postfix) with ESMTPS id E63019CF73D for ; Tue, 13 Dec 2022 16:55:22 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Tn9ipNi1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670946920; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vN2b3MLF2n3ZPMSxXyjvxdcqBR/2NjegKSPQ6Yvcl1c=; b=Tn9ipNi1UR0P9JzgXlT4z8w3GdRbfMZBJuX5VH9m6HQeMTI0XVrbTULUwSRPts2bgePJNM m4e9pi7BTkQfZttiVWTMmisZ4zedlHg1nCJfmEYNEaKJiRSPziQfvIIDIDcMHHriAwsGfY rJEjN0ZSilov1HvRdpccmC2aE2sENX4= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-318-5rlkTK87NvunvDAfiUTB8w-1; Tue, 13 Dec 2022 10:55:19 -0500 X-MC-Unique: 5rlkTK87NvunvDAfiUTB8w-1 Received: by mail-ed1-f70.google.com with SMTP id v4-20020a056402348400b0046cbbc786bdso7464908edc.7 for ; Tue, 13 Dec 2022 07:55:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :to:subject:cc:user-agent:mime-version:date:message-id:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vN2b3MLF2n3ZPMSxXyjvxdcqBR/2NjegKSPQ6Yvcl1c=; b=uKDUb7ZIumOggwa8k+Mbh+3kn/yAcEPE6iSk7JmsOxx0bdXDTps/lWyzEatSENlEL6 PY8f+S3mI0oJmPUWfrSx0FcxGXF/IUnyau9U57qv/8j8H9iT5d7s/nKk3syIbubto0x8 xuH+Y1qGRYBwY/OY/uQ/Oi1cwFmO9QhjaBquskHE8slf0MtqtOWI9ciSYWDVUENdmHzy 5wvmLFV9xpUwXyYWcdV5WLUBWGoDXSHWb6J0I4BhlD63yBbuC7jW43BUEgMWqn3Jyn5s /2u58G4yNi25PxcpTZuJEQBwgNZLWtQiRpZIHQjx8nZ0b/jsgN+08CiN8JytqafDsIkq 6qsg== X-Gm-Message-State: ANoB5pnnmfgd0g1seDSyDZdNB9XfJshlp4lMYd+nsKEJUA2PomrWeALp KIMMur+4bYqSdYP5k4a7+VSfXU3/5BFZCjUBlEdsrwt2LrkRb73vJAlbySVbE/D2uB8kZlzqsFN fD6RmggQb0iW1Vvr/H2UD X-Received: by 2002:a17:906:3ac1:b0:7b2:7aef:5a05 with SMTP id z1-20020a1709063ac100b007b27aef5a05mr17767909ejd.70.1670946918077; Tue, 13 Dec 2022 07:55:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf4QTFgaMGnkWUrT0vpdDp0RoPxFQ54W+5L1LBpoDF64UzHXcp7WiI/oyElkDcFBreUG86tosg== X-Received: by 2002:a17:906:3ac1:b0:7b2:7aef:5a05 with SMTP id z1-20020a1709063ac100b007b27aef5a05mr17767870ejd.70.1670946917628; Tue, 13 Dec 2022 07:55:17 -0800 (PST) Received: from [192.168.41.200] (83-90-141-187-cable.dk.customer.tdc.net. [83.90.141.187]) by smtp.gmail.com with ESMTPSA id f13-20020a17090631cd00b0073c8d4c9f38sm4839077ejf.177.2022.12.13.07.55.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Dec 2022 07:55:16 -0800 (PST) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: <7ca8ac2c-7c07-a52f-ec17-d1ba86fa45ab@redhat.com> Date: Tue, 13 Dec 2022 16:55:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 To: Stanislav Fomichev , bpf@vger.kernel.org References: <20221213023605.737383-1-sdf@google.com> <20221213023605.737383-9-sdf@google.com> In-Reply-To: <20221213023605.737383-9-sdf@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: JSQ3KZTZBRGBWOF76KBDZKW3445ZNMGB X-Message-ID-Hash: JSQ3KZTZBRGBWOF76KBDZKW3445ZNMGB X-MailFrom: jbrouer@redhat.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: brouer@redhat.com, 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, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , 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] Re: [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: On 13/12/2022 03.35, Stanislav Fomichev wrote: > 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(); This should be reading the hardware timestamp in the SKB. Details: This hardware timestamp in the SKB is located in skb_shared_info area, which is also available for xdp_frame (currently used for multi-buffer purposes). Thus, when adding xdp-hints "store" functionality, it would be natural to store the HW TS in the same place. Making the veth skb/xdp_frame code paths able to share code. > + 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;