public inbox for virtio-comment@lists.linux.dev
 help / color / mirror / Atom feed
From: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
To: virtio-comment@lists.linux.dev
Cc: Parav Pandit <parav@nvidia.com>,
	cohuck@redhat.com, mst@redhat.com,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Subject: [PATCH 06/13] virtio-net: Fix receive buffer size calculation text
Date: Tue,  1 Apr 2025 15:35:06 +0200	[thread overview]
Message-ID: <20250401133543.801184-7-mvaralar@redhat.com> (raw)
In-Reply-To: <20250401133543.801184-1-mvaralar@redhat.com>

From: Parav Pandit <parav@nvidia.com>

Receive buffer size calculation is based on the following
negotiated features.

The text has wrong calculation for IPv6 and also it has missed
VIRTIO_NET_F_HASH_REPORT.

The problem of igorance of VIRTIO_NET_F_HASH_REPORT is reported
in [1], however fix for ipv6 payload length must also be
considered.

Since for the both the fixes touching same requirements, a
new issue is created as [2].

This patch brings following fixes.

1. Fix annotating struct virtio_net_hdr as field
2. Fix receive buffer calculation for guest GSO cases to consider
   ipv6 payload length
3. small grammar corrections for article
4. reword the requirement to consider the virtio_ndr_hdr which is
   depends on the negotiated feature, hence first clarify the
   struct virtio_net_hdr size

[1] https://github.com/oasis-tcs/virtio-spec/issues/170
[2] https://github.com/oasis-tcs/virtio-spec/issues/183

Fixes: https://github.com/oasis-tcs/virtio-spec/issues/170
Fixes: https://github.com/oasis-tcs/virtio-spec/issues/183
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Parav Pandit <parav@nvidia.com>
Message-Id: <20240606102014.2103986-2-parav@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 00806815385340dd411cc67df3f6837935bb5e26)
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
---
 device-types/net/description.tex | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/device-types/net/description.tex b/device-types/net/description.tex
index 76585b0..0c7d361 100644
--- a/device-types/net/description.tex
+++ b/device-types/net/description.tex
@@ -654,10 +654,15 @@ \subsubsection{Setting Up Receive Buffers}\label{sec:Device Types / Network Devi
 If the VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
 VIRTIO_NET_F_GUEST_UFO, VIRTIO_NET_F_GUEST_USO4 or VIRTIO_NET_F_GUEST_USO6
 features are used, the maximum incoming packet
-will be to 65550 bytes long (the maximum size of a
-TCP or UDP packet, plus the 14 byte ethernet header), otherwise
-1514 bytes.  The 12-byte struct virtio_net_hdr is prepended to this,
-making for 65562 or 1526 bytes.
+will be 65589 bytes long (14 bytes of Ethernet header, plus 40 bytes of
+the IPv6 header, plus 65535 bytes of maximum IPv6 payload including any
+extension header), otherwise 1514 bytes.
+When VIRTIO_NET_F_HASH_REPORT is not negotiated, the required receive buffer
+size is either 65601 or 1526 bytes accounting for 20 bytes of
+\field{struct virtio_net_hdr} followed by receive packet.
+When VIRTIO_NET_F_HASH_REPORT is negotiated, the required receive buffer
+size is either 65609 or 1534 bytes accounting for 12 bytes of
+\field{struct virtio_net_hdr} followed by receive packet.
 
 \drivernormative{\paragraph}{Setting Up Receive Buffers}{Device Types / Network Device / Device Operation / Setting Up Receive Buffers}
 
@@ -666,18 +671,25 @@ \subsubsection{Setting Up Receive Buffers}\label{sec:Device Types / Network Devi
   \begin{itemize}
     \item If VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_UFO,
 	VIRTIO_NET_F_GUEST_USO4 or VIRTIO_NET_F_GUEST_USO6 are negotiated, the driver SHOULD populate
-      the receive queue(s) with buffers of at least 65562 bytes.
+      the receive queue(s) with buffers of at least 65609 bytes if
+      VIRTIO_NET_F_HASH_REPORT is negotiated, and of at least 65601 bytes if not.
     \item Otherwise, the driver SHOULD populate the receive queue(s)
-      with buffers of at least 1526 bytes.
+      with buffers of at least 1534 bytes if VIRTIO_NET_F_HASH_REPORT
+      is negotiated, and of at least 1526 bytes if not.
   \end{itemize}
 \item If VIRTIO_NET_F_MRG_RXBUF is negotiated, each buffer MUST be at
-least the size of the struct virtio_net_hdr.
+least size of \field{struct virtio_net_hdr},
+i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.
 \end{itemize}
 
 \begin{note}
 Obviously each buffer can be split across multiple descriptor elements.
 \end{note}
 
+When calculating the size of \field{struct virtio_net_hdr}, the driver
+MUST consider all the fields inclusive up to \field{padding_reserved},
+i.e. 20 bytes if VIRTIO_NET_F_HASH_REPORT is negotiated, and 12 bytes if not.
+
 If VIRTIO_NET_F_MQ is negotiated, each of receiveq1\ldots receiveqN
 that will be used SHOULD be populated with receive buffers.
 
-- 
2.42.0


  parent reply	other threads:[~2025-04-01 13:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 13:35 [PATCH 00/13] Backport 1.4 fixes to 1.3 Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 01/13] conformance: Add missing virtqueue reset conformance references Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 02/13] packed-ring: Change host,guest to device,driver Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 03/13] description: Avoid splitting the word virtqueue Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 04/13] content: Rename SPI master to SPI controller Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 05/13] virtio-blk: Fix data type of num_queues field Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` Matias Ezequiel Vara Larsen [this message]
2025-04-01 13:35 ` [PATCH 07/13] virtio-net: Clarify the size of the struct virtio_net_hdr for tx Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 08/13] virtio-net: Annotate virtio_net_hdr as field Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 09/13] virtio_pci_cap64: specify offset_hi, length_hi endianness Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 10/13] gpu: editorial: Fix spelling errors Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 11/13] virtio-net: clarify NEEDS_CSUM semantic for GSO packats Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 12/13] virtio-net: clarify DATA_VALID semantic for encap protos Matias Ezequiel Vara Larsen
2025-04-01 13:35 ` [PATCH 13/13] virtio-net: Fix receive buffer size typo Matias Ezequiel Vara Larsen
2025-04-02  7:02 ` [PATCH 00/13] Backport 1.4 fixes to 1.3 Michael S. Tsirkin
2025-04-02  9:22 ` Cornelia Huck
2025-04-02 10:25   ` Parav Pandit
2025-04-02 10:29     ` Matias Ezequiel Vara Larsen
2025-04-02 10:59       ` Parav Pandit
2025-04-02 15:24         ` Matias Ezequiel Vara Larsen
2025-04-03  8:14           ` Matias Ezequiel Vara Larsen
2025-04-03 12:48             ` Michael S. Tsirkin

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=20250401133543.801184-7-mvaralar@redhat.com \
    --to=mvaralar@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=mst@redhat.com \
    --cc=parav@nvidia.com \
    --cc=virtio-comment@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox