net/virtio: report max/min/align Rx descriptor limits
authorIvan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Fri, 20 Aug 2021 12:48:12 +0000 (15:48 +0300)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Tue, 14 Sep 2021 11:21:57 +0000 (13:21 +0200)
Report max/min/align descriptors limits in device info get callback.
Before calling the callback, rte_eth_dev_info_get() provides
default values of nb_min as zero and nb_max as UINT16_MAX that are
not correct for the driver, so one can't rely on them.

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_ethdev.c

index 9ca8bae..9690eb4 100644 (file)
@@ -33,6 +33,7 @@
 #include "virtio_logs.h"
 #include "virtqueue.h"
 #include "virtio_rxtx.h"
+#include "virtio_rxtx_simple.h"
 #include "virtio_user/virtio_user_dev.h"
 
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
@@ -2536,6 +2537,30 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        if ((host_features & tso_mask) == tso_mask)
                dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
 
+       if (host_features & (1ULL << VIRTIO_F_RING_PACKED)) {
+               /*
+                * According to 2.7 Packed Virtqueues,
+                * 2.7.10.1 Structure Size and Alignment:
+                * The Queue Size value does not have to be a power of 2.
+                */
+               dev_info->rx_desc_lim.nb_max = UINT16_MAX;
+       } else {
+               /*
+                * According to 2.6 Split Virtqueues:
+                * Queue Size value is always a power of 2. The maximum Queue
+                * Size value is 32768.
+                */
+               dev_info->rx_desc_lim.nb_max = 32768;
+       }
+       /*
+        * Actual minimum is not the same for virtqueues of different kinds,
+        * but to avoid tangling the code with separate branches, rely on
+        * default thresholds since desc number must be at least of their size.
+        */
+       dev_info->rx_desc_lim.nb_min = RTE_MAX(DEFAULT_RX_FREE_THRESH,
+                                              RTE_VIRTIO_VPMD_RX_REARM_THRESH);
+       dev_info->rx_desc_lim.nb_align = 1;
+
        return 0;
 }