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 <wangbowen6@xiaomi.com>
This commit is contained in:
Bowen Wang 2024-06-20 21:17:11 +08:00 committed by Xiang Xiao
parent 280538adc6
commit c0edb0f402
1 changed files with 4 additions and 4 deletions

View File

@ -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; priv->bufnum = CONFIG_IOB_NBUFFERS / VIRTIO_NET_MAX_NIOB / 4;
#endif #endif
priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_RX].info.num_descs, priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_RX].info.num_descs /
priv->bufnum); (VIRTIO_NET_MAX_NIOB + 1), priv->bufnum);
priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_TX].info.num_descs, priv->bufnum = MIN(vdev->vrings_info[VIRTIO_NET_TX].info.num_descs /
priv->bufnum); (VIRTIO_NET_MAX_NIOB + 1), priv->bufnum);
return OK; return OK;
} }