From: Laurent Vivier <lvivier@redhat.com>
To: passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>
Subject: [PATCH v8 6/8] passt: rename tap_sock_init() to tap_backend_init()
Date: Thu, 10 Oct 2024 14:29:00 +0200 [thread overview]
Message-ID: <20241010122903.1188992-7-lvivier@redhat.com> (raw)
In-Reply-To: <20241010122903.1188992-1-lvivier@redhat.com>
Extract pool storage initialization loop to tap_sock_update_pool(),
extract QEMU hints to tap_backend_show_hints().
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
passt.c | 2 +-
tap.c | 56 +++++++++++++++++++++++++++++++++++++++++---------------
tap.h | 2 +-
3 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/passt.c b/passt.c
index ad6f0bc32df6..79093ee02d62 100644
--- a/passt.c
+++ b/passt.c
@@ -261,7 +261,7 @@ int main(int argc, char **argv)
pasta_netns_quit_init(&c);
- tap_sock_init(&c);
+ tap_backend_init(&c);
secret_init(&c);
diff --git a/tap.c b/tap.c
index c53a39b79e62..4b826fdf7adc 100644
--- a/tap.c
+++ b/tap.c
@@ -1188,11 +1188,31 @@ int tap_sock_unix_open(char *sock_path)
return fd;
}
+/**
+ * tap_backend_show_hints() - Give help information to start QEMU
+ * @c: Execution context
+ */
+static void tap_backend_show_hints(struct ctx *c)
+{
+ switch(c->mode) {
+ case MODE_PASTA:
+ /* No hints */
+ break;
+ case MODE_PASST:
+ info("\nYou can now start qemu (>= 7.2, with commit 13c6be96618c):");
+ info(" kvm ... -device virtio-net-pci,netdev=s -netdev stream,id=s,server=off,addr.type=unix,addr.path=%s",
+ c->sock_path);
+ info("or qrap, for earlier qemu versions:");
+ info(" ./qrap 5 kvm ... -net socket,fd=5 -net nic,model=virtio");
+ break;
+ }
+}
+
/**
* tap_sock_unix_init() - Start listening for connections on AF_UNIX socket
* @c: Execution context
*/
-static void tap_sock_unix_init(struct ctx *c)
+static void tap_sock_unix_init(const struct ctx *c)
{
union epoll_ref ref = { .type = EPOLL_TYPE_TAP_LISTEN };
struct epoll_event ev = { 0 };
@@ -1203,12 +1223,6 @@ static void tap_sock_unix_init(struct ctx *c)
ev.events = EPOLLIN | EPOLLET;
ev.data.u64 = ref.u64;
epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap_listen, &ev);
-
- info("\nYou can now start qemu (>= 7.2, with commit 13c6be96618c):");
- info(" kvm ... -device virtio-net-pci,netdev=s -netdev stream,id=s,server=off,addr.type=unix,addr.path=%s",
- c->sock_path);
- info("or qrap, for earlier qemu versions:");
- info(" ./qrap 5 kvm ... -net socket,fd=5 -net nic,model=virtio");
}
/**
@@ -1321,21 +1335,31 @@ static void tap_sock_tun_init(struct ctx *c)
}
/**
- * tap_sock_init() - Create and set up AF_UNIX socket or tuntap file descriptor
- * @c: Execution context
+ * tap_sock_update_pool() - Set the buffer base and size for the pool of packets
+ * @base: Buffer base
+ * @size Buffer size
*/
-void tap_sock_init(struct ctx *c)
+static void tap_sock_update_pool(void *base, size_t size)
{
- size_t sz = sizeof(pkt_buf);
int i;
- pool_tap4_storage = PACKET_INIT(pool_tap4, TAP_MSGS, pkt_buf, sz);
- pool_tap6_storage = PACKET_INIT(pool_tap6, TAP_MSGS, pkt_buf, sz);
+ pool_tap4_storage = PACKET_INIT(pool_tap4, TAP_MSGS, base, size);
+ pool_tap6_storage = PACKET_INIT(pool_tap6, TAP_MSGS, base, size);
for (i = 0; i < TAP_SEQS; i++) {
- tap4_l4[i].p = PACKET_INIT(pool_l4, UIO_MAXIOV, pkt_buf, sz);
- tap6_l4[i].p = PACKET_INIT(pool_l4, UIO_MAXIOV, pkt_buf, sz);
+ tap4_l4[i].p = PACKET_INIT(pool_l4, UIO_MAXIOV, base, size);
+ tap6_l4[i].p = PACKET_INIT(pool_l4, UIO_MAXIOV, base, size);
}
+}
+
+/**
+ * tap_backend_init() - Create and set up AF_UNIX socket or
+ * tuntap file descriptor
+ * @c: Execution context
+ */
+void tap_backend_init(struct ctx *c)
+{
+ tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
if (c->fd_tap != -1) { /* Passed as --fd */
struct epoll_event ev = { 0 };
@@ -1365,4 +1389,6 @@ void tap_sock_init(struct ctx *c)
*/
memset(&c->guest_mac, 0xff, sizeof(c->guest_mac));
}
+
+ tap_backend_show_hints(c);
}
diff --git a/tap.h b/tap.h
index 85f1e8473711..8728cc5c09c3 100644
--- a/tap.h
+++ b/tap.h
@@ -68,7 +68,7 @@ void tap_handler_pasta(struct ctx *c, uint32_t events,
void tap_handler_passt(struct ctx *c, uint32_t events,
const struct timespec *now);
int tap_sock_unix_open(char *sock_path);
-void tap_sock_init(struct ctx *c);
+void tap_backend_init(struct ctx *c);
void tap_flush_pools(void);
void tap_handler(struct ctx *c, const struct timespec *now);
void tap_add_packet(struct ctx *c, ssize_t l2len, char *p);
--
@@ -68,7 +68,7 @@ void tap_handler_pasta(struct ctx *c, uint32_t events,
void tap_handler_passt(struct ctx *c, uint32_t events,
const struct timespec *now);
int tap_sock_unix_open(char *sock_path);
-void tap_sock_init(struct ctx *c);
+void tap_backend_init(struct ctx *c);
void tap_flush_pools(void);
void tap_handler(struct ctx *c, const struct timespec *now);
void tap_add_packet(struct ctx *c, ssize_t l2len, char *p);
--
2.46.2
next prev parent reply other threads:[~2024-10-10 12:29 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 12:28 [PATCH v8 0/8] Add vhost-user support to passt. (part 3) Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 1/8] packet: replace struct desc by struct iovec Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 2/8] vhost-user: introduce virtio API Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 3/8] vhost-user: introduce vhost-user API Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 4/8] udp: Prepare udp.c to be shared with vhost-user Laurent Vivier
2024-10-14 4:29 ` David Gibson
2024-10-10 12:28 ` [PATCH v8 5/8] tcp: Export headers functions Laurent Vivier
2024-10-14 4:29 ` David Gibson
2024-10-10 12:29 ` Laurent Vivier [this message]
2024-10-14 4:30 ` [PATCH v8 6/8] passt: rename tap_sock_init() to tap_backend_init() David Gibson
2024-10-14 22:38 ` Stefano Brivio
2024-10-10 12:29 ` [PATCH v8 7/8] vhost-user: add vhost-user Laurent Vivier
2024-10-15 3:23 ` David Gibson
2024-10-16 10:07 ` Laurent Vivier
2024-10-16 16:26 ` Stefano Brivio
2024-10-15 19:54 ` Stefano Brivio
2024-10-16 0:41 ` David Gibson
2024-10-17 0:10 ` Stefano Brivio
2024-10-17 11:25 ` Stefano Brivio
2024-10-17 11:54 ` Laurent Vivier
2024-10-17 17:18 ` Laurent Vivier
2024-10-17 17:25 ` Laurent Vivier
2024-10-17 17:33 ` Stefano Brivio
2024-10-17 21:21 ` Stefano Brivio
2024-10-22 12:59 ` Laurent Vivier
2024-10-22 13:19 ` Stefano Brivio
2024-10-22 18:19 ` Stefano Brivio
2024-10-22 18:22 ` Stefano Brivio
2024-10-23 15:27 ` Laurent Vivier
2024-10-23 16:23 ` Stefano Brivio
2024-10-17 0:10 ` Stefano Brivio
2024-10-17 7:28 ` Laurent Vivier
2024-10-17 8:33 ` Stefano Brivio
2024-11-14 10:20 ` Laurent Vivier
2024-11-14 14:23 ` Stefano Brivio
2024-11-14 15:16 ` Laurent Vivier
2024-11-14 15:38 ` Stefano Brivio
2024-11-14 10:23 ` Laurent Vivier
2024-11-14 14:23 ` Stefano Brivio
2024-11-15 8:30 ` Laurent Vivier
2024-11-15 10:08 ` Stefano Brivio
2024-11-14 10:29 ` Laurent Vivier
2024-11-14 14:23 ` Stefano Brivio
2024-11-15 11:13 ` Laurent Vivier
2024-11-15 11:23 ` Stefano Brivio
2024-10-10 12:29 ` [PATCH v8 8/8] test: Add tests for passt in vhost-user mode Laurent Vivier
2024-10-15 3:40 ` David Gibson
2024-10-15 19:54 ` Stefano Brivio
2024-10-16 8:06 ` Laurent Vivier
2024-10-16 9:47 ` Stefano Brivio
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=20241010122903.1188992-7-lvivier@redhat.com \
--to=lvivier@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).