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:
parent
280538adc6
commit
c0edb0f402
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue