You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/06 00:38:14 UTC
(nuttx) 14/16: virtio/virtio-net: calculate the correct buffer number
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c0edb0f4024e782695e0d660644cb67012c0f192
Author: Bowen Wang <wa...@xiaomi.com>
AuthorDate: Thu Jun 20 21:17:11 2024 +0800
virtio/virtio-net: calculate the correct buffer number
Avoid exceed the virtqueue length limit when adding buffer to the
virtqueue.
Signed-off-by: Bowen Wang <wa...@xiaomi.com>
---
drivers/virtio/virtio-net.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/virtio/virtio-net.c b/drivers/virtio/virtio-net.c
index 3493db607a..914b76616b 100644
--- a/drivers/virtio/virtio-net.c
+++ b/drivers/virtio/virtio-net.c
@@ -579,10 +579,10 @@ static int virtio_net_init(FAR struct virtio_net_priv_s *priv,
priv->bufnum = CONFIG_IOB_NBUFFERS / VIRTIO_NET_MAX_NIOB / 4;
#endif
- priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_RX].info.num_descs,
- priv->bufnum);
- priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_TX].info.num_descs,
- priv->bufnum);
+ priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_RX].info.num_descs /
+ (VIRTIO_NET_MAX_NIOB + 1), priv->bufnum);
+ priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_TX].info.num_descs /
+ (VIRTIO_NET_MAX_NIOB + 1), priv->bufnum);
return OK;
}