From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N6bEt7x2; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id C22D85A0278 for ; Mon, 28 Jul 2025 18:38:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753720689; 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=xM1YZl2t3C7v0on3bbc/UAZTnpHTC4Wwu5tnbetM+HM=; b=N6bEt7x2We9EtsLCoUF6ES3/T1uGirKyI6Zel52zo2b9pOeNlODVbTY3O3YfDWSDbV/rtk k0lmdQDwI7PMVQNaae8QS7DzUIRoQhydrCnEuHLV5t17fCCHVBCww24L7bZnzPuPI0Aokl Yo/7IfL5D4NBKh1awIFNDz5yVggibCo= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-6bCwZEq_OKOZKpgFcHoqow-1; Mon, 28 Jul 2025 12:38:07 -0400 X-MC-Unique: 6bCwZEq_OKOZKpgFcHoqow-1 X-Mimecast-MFC-AGG-ID: 6bCwZEq_OKOZKpgFcHoqow_1753720686 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-315af08594fso4476603a91.2 for ; Mon, 28 Jul 2025 09:38:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753720686; x=1754325486; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xM1YZl2t3C7v0on3bbc/UAZTnpHTC4Wwu5tnbetM+HM=; b=qX2uiPZYLeCeciNNcnfCuZBV/y0qiR/CDCpwdMou1Xsfs3Y7PM9XFKuSxKOdV0V8WX hs4FMD2c1GfsQctHQe/FZfQ/qLz+7jIYZacPBRlFCeWecJaUpGMDiMzIpqsjskUzW1oX TRne5qNm0UIokiJGfUnJIUjIGRDqUzFXIgMtpV2cBqPxqdNnT1krxxSW3I1DYv2tIZR7 poWAJ3vydogGbe3GvY54EPcXOWrxS8rM1gnv7qiERdiBa1U0Cvzf7Lv/0F6DULRTzeqU bfHhoXkKDbCXa/Mhqe+It8j1eNRowDk3wAaQXvNQvt8ZdgH0FbNl1HP/Y0XxxqFvHoFi g4xw== X-Gm-Message-State: AOJu0YxPjHfdFLUAk6PpjR8RbjKupBPsoTvMVD1pxgNFb2cRcUB+9l/B /7xV7xPa4Kb9kCEy8dF4Fnefv8BK31SE2Dj6XzayWGy0fdAgdnnM2p35KQx1mwCDfe9v5qBxcqA vNbq3QRNHZ03nukAXbcw3V4x963BhyN0L+3u5tziDeMTwszRzaURNfHA9x380+bN/goSRpVUepj FFhluf6IosVxfyyTji9oOTK3o14abGWZR8zWUhdoU= X-Gm-Gg: ASbGncu/R6HTpqoRaUszAIs9QFrpqtyH0fe5r8uMt+2SYt1RHSEaMfw0dKAG/0XWBDi M7RLzSKKKIi4+arjH7Mlwi+pGValqdKYVHMujsA5pFiS2BaNYaH9k878RUqJrEQaF4f02Jl3Fvp /r+NbgMjJFxOxdtHySj3gc X-Received: by 2002:a17:90b:58cb:b0:313:f6fa:5bb5 with SMTP id 98e67ed59e1d1-31e77a012a1mr22249352a91.18.1753720685944; Mon, 28 Jul 2025 09:38:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdLC1dKZgCOF+tETbpT1KNyLVxJzYU4g5Ds6N41iqt2zSI0zy136vo8VPgpr4PFUmaWrb0MtbqvHi4vmhWNsc= X-Received: by 2002:a17:90b:58cb:b0:313:f6fa:5bb5 with SMTP id 98e67ed59e1d1-31e77a012a1mr22249300a91.18.1753720685478; Mon, 28 Jul 2025 09:38:05 -0700 (PDT) MIME-Version: 1.0 References: <20250709174748.3514693-1-eperezma@redhat.com> <20250709174748.3514693-4-eperezma@redhat.com> In-Reply-To: From: Eugenio Perez Martin Date: Mon, 28 Jul 2025 18:37:29 +0200 X-Gm-Features: Ac12FXzIeOLE0tH7AJlzG7phCzneaeL2BblTsHFzjITDwc3caW71MZE6mf_4WsM Message-ID: Subject: Re: [RFC v2 03/11] tap: replace tx tap hdr with virtio_nethdr_mrg_rxbuf To: David Gibson X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: o0cUZW4JHahDELSEdiJylA5iysdhFbF9wuNvGyyESXk_1753720686 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GHLPOBE65HLWQTHQ5VYDOYMRUV5MRAKU X-Message-ID-Hash: GHLPOBE65HLWQTHQ5VYDOYMRUV5MRAKU X-MailFrom: eperezma@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: passt-dev@passt.top, jasowang@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, Jul 24, 2025 at 2:25=E2=80=AFAM David Gibson wrote: > > On Wed, Jul 09, 2025 at 07:47:40PM +0200, Eugenio P=C3=A9rez wrote: > > vhost kernel expects this as the first data of the frame. > > > > Signed-off-by: Eugenio P=C3=A9rez > > --- > > 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 s= truct iovec *iov, > > nframes - m, nframes); > > > > pcap_multiple(iov, bufs_per_frame, m, > > - c->mode =3D=3D MODE_PASST ? sizeof(uint32_t) : 0); > > + c->mode =3D=3D MODE_PASST ? sizeof(uint32_t) : size= of(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(). > Yes, the plan was to add all of these conditionals in a later version but I failed to document it properly :). > > > > 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 > > > > +#include > > + > > #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_ME= M]; > > +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. > Right. > > /* 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, c= onst 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_mr= g_rxbuf *hdr) > > +{ > > + return (struct iovec){ > > + .iov_base =3D hdr, > > + .iov_len =3D 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 =3D L2_BUF_IP4_INIT(IPPROTO_TCP); > > int i; > > > > + (void)c; > > tcp6_eth_src.h_proto =3D htons_constant(ETH_P_IPV6); > > tcp4_eth_src.h_proto =3D htons_constant(ETH_P_IP); > > > > @@ -96,7 +107,7 @@ void tcp_sock_iov_init(const struct ctx *c) > > for (i =3D 0; i < TCP_FRAMES_MEM; i++) { > > struct iovec *iov =3D tcp_l2_iov[i]; > > > > - iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp_payload_tap_hdr[= i]); > > + iov[TCP_IOV_TAP] =3D virtio_net_hdr_iov(&tcp_payload_tap_= hdr[i]); > > iov[TCP_IOV_ETH].iov_len =3D sizeof(struct ethhdr); > > iov[TCP_IOV_PAYLOAD].iov_base =3D &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 wa= y > | around. > http://www.ozlabs.org/~dgibson