public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v4 1/6] tap: Remove pool parameter from tap4_handler() and tap6_handler()
Date: Mon, 15 Dec 2025 13:40:02 +0100	[thread overview]
Message-ID: <20251215124007.1549660-2-lvivier@redhat.com> (raw)
In-Reply-To: <20251215124007.1549660-1-lvivier@redhat.com>

These handlers only ever operate on their respective global pools
(pool_tap4 and pool_tap6). The pool parameter was always passed the
same value, making it unnecessary indirection.

Access the global pools directly instead, simplifying the function
signatures.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 tap.c | 46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/tap.c b/tap.c
index e3ea61cbc7ef..62e2faa77675 100644
--- a/tap.c
+++ b/tap.c
@@ -705,23 +705,21 @@ static bool tap4_is_fragment(const struct iphdr *iph,
 /**
  * tap4_handler() - IPv4 and ARP packet handler for tap file descriptor
  * @c:		Execution context
- * @in:		Ingress packet pool, packets with Ethernet headers
  * @now:	Current timestamp
  *
  * Return: count of packets consumed by handlers
  */
-static int tap4_handler(struct ctx *c, const struct pool *in,
-			const struct timespec *now)
+static int tap4_handler(struct ctx *c, const struct timespec *now)
 {
 	unsigned int i, j, seq_count;
 	struct tap4_l4_t *seq;
 
-	if (!c->ifi4 || !in->count)
-		return in->count;
+	if (!c->ifi4 || !pool_tap4->count)
+		return pool_tap4->count;
 
 	i = 0;
 resume:
-	for (seq_count = 0, seq = NULL; i < in->count; i++) {
+	for (seq_count = 0, seq = NULL; i < pool_tap4->count; i++) {
 		size_t l3len, hlen, l4len;
 		struct ethhdr eh_storage;
 		struct iphdr iph_storage;
@@ -731,7 +729,7 @@ resume:
 		struct iov_tail data;
 		struct iphdr *iph;
 
-		if (!packet_get(in, i, &data))
+		if (!packet_get(pool_tap4, i, &data))
 			continue;
 
 		eh = IOV_PEEK_HEADER(&data, eh_storage);
@@ -798,7 +796,7 @@ resume:
 		if (iph->protocol == IPPROTO_UDP) {
 			struct iov_tail eh_data;
 
-			packet_get(in, i, &eh_data);
+			packet_get(pool_tap4, i, &eh_data);
 			if (dhcp(c, &eh_data))
 				continue;
 		}
@@ -829,7 +827,7 @@ resume:
 			goto append;
 
 		if (seq_count == TAP_SEQS)
-			break;	/* Resume after flushing if i < in->count */
+			break;	/* Resume after flushing if i < pool_tap4->count */
 
 		for (seq = tap4_l4 + seq_count - 1; seq >= tap4_l4; seq--) {
 			if (L4_MATCH(iph, uh, seq)) {
@@ -875,32 +873,30 @@ append:
 		}
 	}
 
-	if (i < in->count)
+	if (i < pool_tap4->count)
 		goto resume;
 
-	return in->count;
+	return pool_tap4->count;
 }
 
 /**
  * tap6_handler() - IPv6 packet handler for tap file descriptor
  * @c:		Execution context
- * @in:		Ingress packet pool, packets with Ethernet headers
  * @now:	Current timestamp
  *
  * Return: count of packets consumed by handlers
  */
-static int tap6_handler(struct ctx *c, const struct pool *in,
-			const struct timespec *now)
+static int tap6_handler(struct ctx *c, const struct timespec *now)
 {
 	unsigned int i, j, seq_count = 0;
 	struct tap6_l4_t *seq;
 
-	if (!c->ifi6 || !in->count)
-		return in->count;
+	if (!c->ifi6 || !pool_tap6->count)
+		return pool_tap6->count;
 
 	i = 0;
 resume:
-	for (seq_count = 0, seq = NULL; i < in->count; i++) {
+	for (seq_count = 0, seq = NULL; i < pool_tap6->count; i++) {
 		size_t l4len, plen, check;
 		struct in6_addr *saddr, *daddr;
 		struct ipv6hdr ip6h_storage;
@@ -912,7 +908,7 @@ resume:
 		struct ipv6hdr *ip6h;
 		uint8_t proto;
 
-		if (!packet_get(in, i, &data))
+		if (!packet_get(pool_tap6, i, &data))
 			return -1;
 
 		eh = IOV_REMOVE_HEADER(&data, eh_storage);
@@ -1020,7 +1016,7 @@ resume:
 			goto append;
 
 		if (seq_count == TAP_SEQS)
-			break;	/* Resume after flushing if i < in->count */
+			break;	/* Resume after flushing if i < pool_tap6->count */
 
 		for (seq = tap6_l4 + seq_count - 1; seq >= tap6_l4; seq--) {
 			if (L4_MATCH(ip6h, proto, uh, seq)) {
@@ -1067,10 +1063,10 @@ append:
 		}
 	}
 
-	if (i < in->count)
+	if (i < pool_tap6->count)
 		goto resume;
 
-	return in->count;
+	return pool_tap6->count;
 }
 
 /**
@@ -1089,8 +1085,8 @@ void tap_flush_pools(void)
  */
 void tap_handler(struct ctx *c, const struct timespec *now)
 {
-	tap4_handler(c, pool_tap4, now);
-	tap6_handler(c, pool_tap6, now);
+	tap4_handler(c, now);
+	tap6_handler(c, now);
 }
 
 /**
@@ -1124,14 +1120,14 @@ void tap_add_packet(struct ctx *c, struct iov_tail *data,
 	case ETH_P_ARP:
 	case ETH_P_IP:
 		if (!pool_can_fit(pool_tap4, data)) {
-			tap4_handler(c, pool_tap4, now);
+			tap4_handler(c, now);
 			pool_flush(pool_tap4);
 		}
 		packet_add(pool_tap4, data);
 		break;
 	case ETH_P_IPV6:
 		if (!pool_can_fit(pool_tap6, data)) {
-			tap6_handler(c, pool_tap6, now);
+			tap6_handler(c, now);
 			pool_flush(pool_tap6);
 		}
 		packet_add(pool_tap6, data);
-- 
2.51.1


  reply	other threads:[~2025-12-15 12:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 12:40 [PATCH v4 0/6] vhost-user: Add multiqueue support Laurent Vivier
2025-12-15 12:40 ` Laurent Vivier [this message]
2025-12-15 12:40 ` [PATCH v4 2/6] vhost-user: Enable multiqueue Laurent Vivier
2025-12-15 12:40 ` [PATCH v4 3/6] test: Add multiqueue support to vhost-user test infrastructure Laurent Vivier
2025-12-15 12:40 ` [PATCH v4 4/6] vhost-user: Add queue pair parameter throughout the network stack Laurent Vivier
2025-12-15 12:40 ` [PATCH v4 5/6] tap: Convert packet pools to per-queue-pair arrays for multiqueue Laurent Vivier
2025-12-15 12:40 ` [PATCH v4 6/6] flow: Add queue pair tracking to flow management Laurent Vivier

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=20251215124007.1549660-2-lvivier@redhat.com \
    --to=lvivier@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --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).