From: David Gibson <david@gibson.dropbear.id.au>
To: "Eugenio Pérez" <eperezma@redhat.com>
Cc: passt-dev@passt.top, jasowang@redhat.com
Subject: Re: [RFC v2 03/11] tap: replace tx tap hdr with virtio_nethdr_mrg_rxbuf
Date: Thu, 24 Jul 2025 10:17:00 +1000 [thread overview]
Message-ID: <aIF7fAebeRD7Sxf9@zatzit> (raw)
In-Reply-To: <20250709174748.3514693-4-eperezma@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3834 bytes --]
On Wed, Jul 09, 2025 at 07:47:40PM +0200, Eugenio Pérez wrote:
> vhost kernel expects this as the first data of the frame.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
> tap.c | 2 +-
> tcp_buf.c | 15 +++++++++++++--
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/tap.c b/tap.c
> index 0c49e6d..0656294 100644
> --- a/tap.c
> +++ b/tap.c
> @@ -593,7 +593,7 @@ size_t tap_send_frames(const struct ctx *c, const struct iovec *iov,
> nframes - m, nframes);
>
> pcap_multiple(iov, bufs_per_frame, m,
> - c->mode == MODE_PASST ? sizeof(uint32_t) : 0);
> + c->mode == MODE_PASST ? sizeof(uint32_t) : sizeof(struct virtio_net_hdr_mrg_rxbuf));
If I understand correctly, you're always considering
virtio_net_hdr_mrg_rxbuf part of the extended frame in PASTA mode,
it's just unused when you're not using the vhost path. Is that correct?
We probably want a helper that returns the correct tap header length,
a companion to tap_hdr_iov().
>
> return m;
> }
> diff --git a/tcp_buf.c b/tcp_buf.c
> index d1fca67..2fbd056 100644
> --- a/tcp_buf.c
> +++ b/tcp_buf.c
> @@ -22,6 +22,8 @@
>
> #include <netinet/tcp.h>
>
> +#include <linux/virtio_net.h>
> +
> #include "util.h"
> #include "ip.h"
> #include "iov.h"
> @@ -43,7 +45,7 @@
> static struct ethhdr tcp4_eth_src;
> static struct ethhdr tcp6_eth_src;
>
> -static struct tap_hdr tcp_payload_tap_hdr[TCP_FRAMES_MEM];
> +static struct virtio_net_hdr_mrg_rxbuf tcp_payload_tap_hdr[TCP_FRAMES_MEM];
The intention is that struct tap_hdr can store whatever sort of "below
L2" header we need - it's just that so far we only had the trivial
qemu socket header or nothing. Now we're adding another option, so it
should be a union branch of tap_hdr, rather than a separate structure.
> /* IP headers for IPv4 and IPv6 */
> struct iphdr tcp4_payload_ip[TCP_FRAMES_MEM];
> @@ -75,6 +77,14 @@ void tcp_update_l2_buf(const unsigned char *eth_d, const unsigned char *eth_s)
> eth_update_mac(&tcp6_eth_src, eth_d, eth_s);
> }
>
> +static inline struct iovec virtio_net_hdr_iov(struct virtio_net_hdr_mrg_rxbuf *hdr)
> +{
> + return (struct iovec){
> + .iov_base = hdr,
> + .iov_len = sizeof(*hdr),
> + };
> +}
With that unification of tap_hdr_iov(), this should be a branch in
tap_hdr_iov(), rather than a separate function. tap_hdr_update() will
also need to be updated to only update vnet_len in PASST (qemu socket)
mode.
It is now occurring to me that adding vhost is highlighting an
existing ambiguity in our terminology: "tap" can mean either "the
guest facing interface, of whatever mechanics", or specifically the
kernel tuntap device. Maybe we need to look at a great renaming.
> +
> /**
> * tcp_sock_iov_init() - Initialise scatter-gather L2 buffers for IPv4 sockets
> * @c: Execution context
> @@ -85,6 +95,7 @@ void tcp_sock_iov_init(const struct ctx *c)
> struct iphdr iph = L2_BUF_IP4_INIT(IPPROTO_TCP);
> int i;
>
> + (void)c;
> tcp6_eth_src.h_proto = htons_constant(ETH_P_IPV6);
> tcp4_eth_src.h_proto = htons_constant(ETH_P_IP);
>
> @@ -96,7 +107,7 @@ void tcp_sock_iov_init(const struct ctx *c)
> for (i = 0; i < TCP_FRAMES_MEM; i++) {
> struct iovec *iov = tcp_l2_iov[i];
>
> - iov[TCP_IOV_TAP] = tap_hdr_iov(c, &tcp_payload_tap_hdr[i]);
> + iov[TCP_IOV_TAP] = virtio_net_hdr_iov(&tcp_payload_tap_hdr[i]);
> iov[TCP_IOV_ETH].iov_len = sizeof(struct ethhdr);
> iov[TCP_IOV_PAYLOAD].iov_base = &tcp_payload[i];
> }
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-07-24 0:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 17:47 [RFC v2 00/11] Add vhost-net kernel support Eugenio Pérez
2025-07-09 17:47 ` [RFC v2 01/11] tap: implement vhost_call_cb Eugenio Pérez
2025-07-23 6:56 ` David Gibson
2025-07-09 17:47 ` [RFC v2 02/11] tap: add die() on vhost error Eugenio Pérez
2025-07-23 6:58 ` David Gibson
2025-07-09 17:47 ` [RFC v2 03/11] tap: replace tx tap hdr with virtio_nethdr_mrg_rxbuf Eugenio Pérez
2025-07-24 0:17 ` David Gibson [this message]
2025-07-09 17:47 ` [RFC v2 04/11] tcp: export memory regions to vhost Eugenio Pérez
2025-07-23 7:06 ` David Gibson
2025-07-09 17:47 ` [RFC v2 05/11] virtio: Fill .next in tx queue Eugenio Pérez
2025-07-23 7:07 ` David Gibson
2025-07-09 17:47 ` [RFC v2 06/11] tap: move static iov_sock to tcp_buf_data_from_sock Eugenio Pérez
2025-07-23 7:09 ` David Gibson
2025-07-09 17:47 ` [RFC v2 07/11] tap: support tx through vhost Eugenio Pérez
2025-07-24 0:24 ` David Gibson
2025-07-24 14:30 ` Stefano Brivio
2025-07-25 0:23 ` David Gibson
2025-07-09 17:47 ` [RFC v2 08/11] tap: add tap_free_old_xmit Eugenio Pérez
2025-07-24 0:32 ` David Gibson
2025-07-09 17:47 ` [RFC v2 09/11] tcp: start conversion to circular buffer Eugenio Pérez
2025-07-24 1:03 ` David Gibson
2025-07-09 17:47 ` [RFC v2 10/11] tap: add poll(2) to used_idx Eugenio Pérez
2025-07-24 1:20 ` David Gibson
2025-07-09 17:47 ` [RFC v2 11/11] tcp_buf: adding TCP tx circular buffer Eugenio Pérez
2025-07-24 1:33 ` David Gibson
2025-07-10 9:46 ` [RFC v2 00/11] Add vhost-net kernel support Eugenio Perez Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aIF7fAebeRD7Sxf9@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).