On 8/18/26 4:53 PM, Zhuoying Cai wrote:
> The virtio-net device used a fixed header size that did not account for
> the num_buffers field used in VirtIO 1.0 or for the mergeable receive
> buffers feature.
> 
> Use dynamic header sizing: 10 bytes for legacy mode and 12 bytes for
> VirtIO 1.0 or when VIRTIO_NET_F_MRG_RXBUF is enabled. This ensures
> correct packet handling across different VirtIO configurations.
> 
> Signed-off-by: Zhuoying Cai <[email protected]>
> ---
>  pc-bios/s390-ccw/virtio-net.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/pc-bios/s390-ccw/virtio-net.c b/pc-bios/s390-ccw/virtio-net.c
> index 0ee51653ab..3a9ae789cf 100644
> --- a/pc-bios/s390-ccw/virtio-net.c
> +++ b/pc-bios/s390-ccw/virtio-net.c
> @@ -20,6 +20,7 @@
>  #include "s390-ccw.h"
>  #include "virtio.h"
>  #include "virtio-ccw.h"
> +#include "virtio-pci.h"
>  #include "s390-time.h"
>  #include "helper.h"
>  
> @@ -28,10 +29,15 @@
>  #endif
>  
>  #define VIRTIO_NET_F_MAC_BIT  (1 << 5)
> +#define VIRTIO_NET_F_MRG_RXBUF_BIT (1 << 15)
>  
>  #define VQ_RX 0         /* Receive queue */
>  #define VQ_TX 1         /* Transmit queue */
>  
> +/* Header sizes for different modes */
> +#define VIRTIO_NET_HDR_SIZE_LEGACY  10  /* Without num_buffers */
> +#define VIRTIO_NET_HDR_SIZE_V1      12  /* With num_buffers */
> +

See my comment on Jared virtio-scsi series; you already have a structure
defined for this, and this would just be a versioned variation on it;
can you basically make a split structure and then calculate these
constants using the sizeof() each struct, rather than using constant
values here that circumstantially match the size of well-defined structures?

FWIW, this looks to be exactly what the kernel does with virtio_net_hdr
vs virtio_net_hdr_mrg_rxbuf in linux/uapi/linux/virtio_net.h (or
qemu/include/standard-headers/linux/virtio_net.h)

I am not suggesting we pull the standard-headers into s390-ccw, but I
would recommend using that layout as a basis of the structures in this
patch.

Thanks,
Matt


Reply via email to