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 passt.top (Postfix) with ESMTP id 3EE1B5A02D1 for ; Tue, 30 Apr 2024 22:16:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714508175; 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=FjqUL9rWN/NORF5m3n0nb7xdNQkLsQeRZRyqH7ubGWo=; b=L+kXCQ08/pIAp+jLRO+BuOWqgSgEcjI/irnVy6jg7OUCoXuP/ogAhEbtXTCnMx6tjmnugP ExwPuwcCrwMvoMIPXqip76jdnX56c+O14weD1tcJR73OVhNaQPDRl+WtmEb4K3wc9oDB8V q+PQvc6qR+3Fan8uXiJya++YhSFtj84= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-bAfyJT2TPCKecuAEF1jhZw-1; Tue, 30 Apr 2024 16:16:12 -0400 X-MC-Unique: bAfyJT2TPCKecuAEF1jhZw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a58bca80981so326817366b.0 for ; Tue, 30 Apr 2024 13:16:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714508169; x=1715112969; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FjqUL9rWN/NORF5m3n0nb7xdNQkLsQeRZRyqH7ubGWo=; b=K8uux40ncxwhA7Dr05LJr6JO1/JUryy5WOC5/v8qbe1kgDlClYqbdlmzyGqj/EahVQ pID0hPl04sxy+C+4gKzqVXcOoYXnsWpQDerokPQ7er/r+UNyh9pVuIfvxyAGTXxnqugf cB8Mi1kEeHsX1FKwKGtd3pzZ/6TuSAgl2IyRTR4lzplb2N2QxZtsQ9Hn2QV1kxoEtxtP 2MRki17246SgnB1a9tXMSnpHNZaS7+OOkQfL7jsk0akTjWRw3ZGXyU/hzf1pju9lXbDU SHevuWn8ybwYG+xzYiN7oW+ukrEXTzQHVREnYHztk6MrhrqnVkMFdzmrfUjrJ7p6ntHV gzHQ== X-Gm-Message-State: AOJu0Yzm8T3cp2uqan7DpEZSKBD8CaeRAEHp8RTTxky7CEku4d/eiTIh vzgAdOvx7dFTr059MB6yG8XcsmoxfZKBuVr6422jcl7d0VulhfQYu0MjtmIR7wNs1SSKYZVs8Cm RxDXi2XT2NtzNVx25Rk9naEYeCHkD1UuH726zWPNMBiU6Ju2F7HSJURbY/3EJ X-Received: by 2002:a17:906:5a8b:b0:a59:3331:1e with SMTP id l11-20020a1709065a8b00b00a593331001emr510341ejq.0.1714508168948; Tue, 30 Apr 2024 13:16:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdPeyn1PA48k/kFip88eiODKhslXhfOigJP1eKzBhr8LmDXYfG4ewK86pzYTB6C0jtjZWIxw== X-Received: by 2002:a17:906:5a8b:b0:a59:3331:1e with SMTP id l11-20020a1709065a8b00b00a593331001emr510332ejq.0.1714508168441; Tue, 30 Apr 2024 13:16:08 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id i27-20020a17090639db00b00a58eab2bf0fsm4352916eje.179.2024.04.30.13.16.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2024 13:16:07 -0700 (PDT) Date: Tue, 30 Apr 2024 22:15:34 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/7] udp: Split tap-bound UDP packets into multiple buffers using io vector Message-ID: <20240430221534.70dc88ef@elisabeth> In-Reply-To: <20240430100541.381350-3-david@gibson.dropbear.id.au> References: <20240430100541.381350-1-david@gibson.dropbear.id.au> <20240430100541.381350-3-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 35XNPSZZIIWJTGCVXRFKX2WYMMLOHE6X X-Message-ID-Hash: 35XNPSZZIIWJTGCVXRFKX2WYMMLOHE6X X-MailFrom: sbrivio@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 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 Tue, 30 Apr 2024 20:05:36 +1000 David Gibson wrote: > When sending to the tap device, currently we assemble the headers and > payload into a single contiguous buffer. Those are described by a single > struct iovec, then a batch of frames is sent to the device with > tap_send_frames(). > > In order to better integrate the IPv4 and IPv6 paths, we want the IP > header in a different buffer that might not be contiguous with the > payload. To prepare for that, split the UDP packet into an iovec of > buffers. We use the same split that Laurent recently introduced for > TCP for convenience. > > This removes the last use of tap_hdr_len_(), tap_frame_base() and > tap_frame_len(), so remove those too. > > Signed-off-by: David Gibson > --- > tap.h | 38 ------------------------------ > udp.c | 74 +++++++++++++++++++++++++++++++++++++++-------------------- > 2 files changed, 49 insertions(+), 63 deletions(-) > > diff --git a/tap.h b/tap.h > index 75aa3f03..754703d2 100644 > --- a/tap.h > +++ b/tap.h > @@ -43,44 +43,6 @@ static inline void tap_hdr_update(struct tap_hdr *thdr, size_t l2len) > thdr->vnet_len = htonl(l2len); > } > > -static inline size_t tap_hdr_len_(const struct ctx *c) > -{ > - if (c->mode == MODE_PASST) > - return sizeof(struct tap_hdr); > - else > - return 0; > -} > - > -/** > - * tap_frame_base() - Find start of tap frame > - * @c: Execution context > - * @taph: Pointer to tap specific header buffer > - * > - * Returns: pointer to the start of tap frame - suitable for an > - * iov_base to be passed to tap_send_frames()) > - */ > -static inline void *tap_frame_base(const struct ctx *c, struct tap_hdr *taph) > -{ > - return (char *)(taph + 1) - tap_hdr_len_(c); > -} > - > -/** > - * tap_frame_len() - Finalize tap frame and return total length > - * @c: Execution context > - * @taph: Tap header to finalize > - * @plen: L2 packet length (includes L2, excludes tap specific headers) > - * > - * Returns: length of the tap frame including tap specific headers - suitable > - * for an iov_len to be passed to tap_send_frames() > - */ > -static inline size_t tap_frame_len(const struct ctx *c, struct tap_hdr *taph, > - size_t plen) > -{ > - if (c->mode == MODE_PASST) > - taph->vnet_len = htonl(plen); > - return plen + tap_hdr_len_(c); > -} > - > struct in_addr tap_ip4_daddr(const struct ctx *c); > void tap_udp4_send(const struct ctx *c, struct in_addr src, in_port_t sport, > struct in_addr dst, in_port_t dport, > diff --git a/udp.c b/udp.c > index 545212c5..4650b366 100644 > --- a/udp.c > +++ b/udp.c > @@ -222,12 +222,28 @@ struct udp6_l2_buf_t { > #endif > udp6_l2_buf[UDP_MAX_FRAMES]; > > +/** > + * enum udp_iov_idx - Indices for the buffers making up a single UDP frame > + * @UDP_IOV_TAP TAP specific header Nits: s/TAP/tap/ and > + * @UDP_IOV_ETH ethernet header s/ethernet/Ethernet. -- Stefano