On 2024-09-03 20:18, DUO Labs wrote:
*Note: As it turns out, I posted this on the wrong mailing list at
first, so I'm reposting it here*
I've been studying the example given in `contrib/vhost-user-blk`, and
trying to match the code to what is in the standard
(https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.html#x1-3050002),
so I can use the code to create my own vhost-user-vsock server.
I think I almost understand it, but I don't get exactly how do you
correlate out_sg and in_sg to the header and ancillary data (for
virtio-blk, it would either be the data to be written or a buffer to
read data into, and vsock would be similar), respectively.
In virtio-blk, I see that there's an inhdr, and outhdr, but vsock
doesn't have that, so I'm not sure how to map the same concept.
Similarly, does `elem->out_sg[0]` always map to the header, and
`elem->out_sg[1]` always map to the ancillary data? What about when
you are reading into a buffer --- should it always be read into
`elem->in_sg[0]`, or is that only for virtio-blk?
If you are trying to make a custom virtio network adapter, please note
that the splitting of packets in network adapter I/O tends to vary
largely by packet origin, OS and driver. Historically, MS-DOS drivers
would often make the first fragment of incoming packets contain just
enough data to make initial processing decisions for 99% of packets,
while the first fragment of locally generated packets would reflect
the steps the packet generation passed through, so it might include
the HTTP header, the TCP header, just the IP header or even just the
MAC header or even reflect. However for reliability, any network
adapter design needs to deal with absolutely arbitrary splitting by
the software running above it in the network stack.
Split I/O is mainly a DMA optimization to save byte copies in software,
this even applies to block devices. The hardware that would output a
fixed speed bit stream to a disk or network would queue up the bits to
be output with no pause at the buffer split point, and vice versa at
the receive end.
Enjoy
Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S. https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark. Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded