From: "Ammar Yasser" <aerosound161@gmail.com>
To: "David Gibson" <david@gibson.dropbear.id.au>,
"Ammar Yasser" <aerosound161@gmail.com>
Cc: passt-dev@passt.top, eperezma@redhat.com
Subject: Re: [RFC v3 5/8] virtio: Implement the pasta vhost functions
Date: Sun, 16 Aug 2026 20:48:24 +0300 [thread overview]
Message-ID: <DKQK2M69M04G.1YD2EPQPZ5T3M@gmail.com> (raw)
In-Reply-To: <an0dPMJd5q5ahKdb@zatzit>
>> >> + /* general purpose buffers */
>> >> + vhost_memory.mem.regions[0] = VHOST_MEMORY_REGION(pkt_buf);
>> >> + vhost_memory.mem.regions[1] = VHOST_MEMORY_REGION(eth_pad);
>> >> +
>> >> + /* tcp specific buffers */
>> >> + vhost_memory.mem.regions[2] = VHOST_MEMORY_REGION(tcp_payload_tap_hdr);
>> >> + vhost_memory.mem.regions[3] = VHOST_MEMORY_REGION(tcp4_payload_ip);
>> >> + vhost_memory.mem.regions[4] = VHOST_MEMORY_REGION(tcp6_payload_ip);
>> >> + vhost_memory.mem.regions[5] = VHOST_MEMORY_REGION(tcp_payload);
>> >> + vhost_memory.mem.regions[6] = VHOST_MEMORY_REGION(tcp_eth_hdr);
>> >> +
>> >> + /* udp specific buffers */
>> >> + vhost_memory.mem.regions[7] = VHOST_MEMORY_REGION(udp_payload);
>> >> + vhost_memory.mem.regions[8] = VHOST_MEMORY_REGION(udp_eth_hdr);
>> >> + vhost_memory.mem.regions[9] = VHOST_MEMORY_REGION(udp_iov_recv);
>> >> + vhost_memory.mem.regions[10] = VHOST_MEMORY_REGION(udp_mh_recv);
>> >> + vhost_memory.mem.regions[11] = VHOST_MEMORY_REGION(udp_meta);
>> >
>> > Not sure if there would be value in delegating these to helpers in
>> > tcp.c and udp.c
>>
>> You mean every protocol file registers its own memory regions through
>> calling the macro and taking as input the vhost_memory struct ?
>
> More or less, yes. Specifically I was thinking that this function
> would call, say, tcp_vhost_regions() etc.
>
>> It will be better in the sense that it will remove the need for making
>> those buffers public. But i think it will be harder to follow from a
>> readability perspective. WDYT ?
>
> It's a trade off. It's a bit harder to collate the complete set of
> memory regions. However it avoids making the buffers public and makes
> it clearer when looking at the TCP code that part of "its" memory is
> shared via vhost. It also makes it a little easier to keep the shared
> regions in sync if we change the data structures that (say) TCP uses
> internally.
The last point is pretty noteworthy. Yeah ok.. will go with functions
per protocol that register the dedicated regions
>
>> >> + * rx_descriptor_handoff() - Batch-announce freed RX descriptors to the kernel
>> >> + * @c: Execution context
>> >> + *
>> >> + * Bumps avail.idx by the number of descriptors accumulated in
>> >> + * vqs[0].num_free (from prior consume_one_rx_descriptor() calls),
>> >> + * then resets the counter to zero. The kernel will see the new
>> >> + * avail.idx and consume the freshly-available descriptors.
>> >> + *
>> >> + */
>> >> +void rx_descriptor_handoff(struct ctx *c)
>> >
>> > Can this be static? That's the sort of thing that's harder to review
>> > when signatures are split from implementations. If not, it should
>> > have a properly prefixed name.
>>
>> If by static you mean it gets defined in only one place and not exported
>> then its used in two places (virtio.c and tap.c). Unless you want a
>> duplicate definition which i personally am not in favor of.
>
> Right, again, because the uses in different places are split across
> patches, that makes it harder to see that it's used in multiple places.
>
>> Can you please clarify what you mean by a prefixed name ? Not sure i
>> understand what a proper prefix to a function like this would be
>
> Usually (though not always) functions exported from one module to be
> used in others have a name that starts with the module name. So in
> this case it would be vhost_something_something().
The prefixed name sounds like a good idea. I think it may be difficult
to restructure the series so that both uses of the function will be in
one patch without this patch becoming super blocky. Going with the
prefixed name solution
next prev parent reply other threads:[~2026-08-16 17:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 13:21 [RFC v3 0/8] Add vhost-net kernel support to pasta Ammar Yasser
2026-08-02 13:21 ` [RFC v3 1/8] tap: Move the tap_hdr file to a separate file Ammar Yasser
2026-08-07 5:40 ` David Gibson
2026-08-02 13:21 ` [RFC v3 2/8] udp,tcp: Make protocol specific buffers public Ammar Yasser
2026-08-07 5:56 ` David Gibson
2026-08-12 16:29 ` Ammar Yasser
2026-08-02 13:21 ` [RFC v3 3/8] conf: Add context fields, epoll types and the --vhost flag to pasta Ammar Yasser
2026-08-10 1:11 ` David Gibson
2026-08-12 16:36 ` Ammar Yasser
2026-08-02 13:21 ` [RFC v3 4/8] virtio: Define the pasta vhost interface Ammar Yasser
2026-08-10 2:06 ` David Gibson
2026-08-12 17:17 ` Ammar Yasser
2026-08-13 1:16 ` David Gibson
2026-08-16 17:39 ` Ammar Yasser
2026-08-17 0:30 ` David Gibson
2026-08-02 13:21 ` [RFC v3 5/8] virtio: Implement the pasta vhost functions Ammar Yasser
2026-08-10 6:34 ` David Gibson
2026-08-12 17:57 ` Ammar Yasser
2026-08-13 1:26 ` David Gibson
2026-08-16 17:48 ` Ammar Yasser [this message]
2026-08-02 13:21 ` [RFC v3 6/8] virtio: Implement pasta vhost acceleration guest->pasta path Ammar Yasser
2026-08-10 7:34 ` David Gibson
2026-08-12 18:17 ` Ammar Yasser
2026-08-13 1:35 ` David Gibson
2026-08-02 13:21 ` [RFC v3 7/8] pasta: Implement pasta vhost TX (pasta->guest) prerequisites Ammar Yasser
2026-08-10 9:01 ` David Gibson
2026-08-12 18:39 ` Ammar Yasser
2026-08-13 2:01 ` David Gibson
2026-08-16 17:55 ` Ammar Yasser
2026-08-02 13:21 ` [RFC v3 8/8] tap: Implement pasta vhost TX Ammar Yasser
2026-08-10 9:18 ` David Gibson
2026-08-12 18:45 ` Ammar Yasser
2026-08-13 2:09 ` David Gibson
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=DKQK2M69M04G.1YD2EPQPZ5T3M@gmail.com \
--to=aerosound161@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=eperezma@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).