By default OVS configures 2048 descriptors for tx and rx queues
on DPDK devices. It also allows the user to configure those values.

If the values used are not acceptable to the device then queue setup
would fail.

The device exposes it's max/min/alignment requirements and OVS
applies some limits also. Use these to ensure an acceptable value
is used for the number of descriptors on a device tx/rx.

If the default or user value is not acceptable, adjust to a suitable
value and log.

Reported-at: https://bugzilla.redhat.com/2119876
Reviewed-by: David Marchand <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Kevin Traynor <[email protected]>
---
 lib/netdev-dpdk.c | 60 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 49 insertions(+), 11 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 2d9afc493..6bf672d43 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1911,8 +1911,29 @@ dpdk_set_rxq_config(struct netdev_dpdk *dev, const 
struct smap *args)
 static void
 dpdk_process_queue_size(struct netdev *netdev, const struct smap *args,
-                        const char *flag, int default_size, int *new_size)
+                        struct rte_eth_dev_info *info, bool is_rx)
 {
-    int queue_size = smap_get_int(args, flag, default_size);
+    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
+    struct rte_eth_desc_lim *lim;
+    int default_size, queue_size, cur_size, new_requested_size;
+    int *cur_requested_size;
+    bool reconfig = false;
 
+    if (is_rx) {
+        default_size = NIC_PORT_DEFAULT_RXQ_SIZE;
+        new_requested_size = smap_get_int(args, "n_rxq_desc", default_size);
+        cur_size = dev->rxq_size;
+        cur_requested_size = &dev->requested_rxq_size;
+        lim = info ? &info->rx_desc_lim : NULL;
+    } else {
+        default_size = NIC_PORT_DEFAULT_TXQ_SIZE;
+        new_requested_size = smap_get_int(args, "n_txq_desc", default_size);
+        cur_size = dev->txq_size;
+        cur_requested_size = &dev->requested_txq_size;
+        lim = info ? &info->tx_desc_lim : NULL;
+    }
+
+    queue_size = new_requested_size;
+
+    /* Check for OVS limits. */
     if (queue_size <= 0 || queue_size > NIC_PORT_MAX_Q_SIZE
             || !is_pow2(queue_size)) {
@@ -1920,7 +1941,24 @@ dpdk_process_queue_size(struct netdev *netdev, const 
struct smap *args,
     }
 
-    if (queue_size != *new_size) {
-        *new_size = queue_size;
+    if (lim) {
+        /* Check for device limits. */
+        if (lim->nb_align) {
+            queue_size = ROUND_UP(queue_size, lim->nb_align);
+        }
+        queue_size = MIN(queue_size, lim->nb_max);
+        queue_size = MAX(queue_size, lim->nb_min);
+    }
+
+    *cur_requested_size = queue_size;
+
+    if (cur_size != queue_size) {
         netdev_request_reconfigure(netdev);
+        reconfig = true;
+    }
+    if (new_requested_size != queue_size) {
+        VLOG(reconfig ? VLL_INFO : VLL_DBG,
+             "%s: Unable to set the number of %s descriptors to %d. "
+             "Adjusted to %d.", netdev_get_name(netdev),
+             is_rx ? "rx": "tx", new_requested_size, queue_size);
     }
 }
@@ -1938,7 +1976,9 @@ netdev_dpdk_set_config(struct netdev *netdev, const 
struct smap *args,
         {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL    }
     };
+    struct rte_eth_dev_info info;
     const char *new_devargs;
     const char *vf_mac;
     int err = 0;
+    int ret;
 
     ovs_mutex_lock(&dpdk_mutex);
@@ -1947,11 +1987,4 @@ netdev_dpdk_set_config(struct netdev *netdev, const 
struct smap *args,
     dpdk_set_rxq_config(dev, args);
 
-    dpdk_process_queue_size(netdev, args, "n_rxq_desc",
-                            NIC_PORT_DEFAULT_RXQ_SIZE,
-                            &dev->requested_rxq_size);
-    dpdk_process_queue_size(netdev, args, "n_txq_desc",
-                            NIC_PORT_DEFAULT_TXQ_SIZE,
-                            &dev->requested_txq_size);
-
     new_devargs = smap_get(args, "dpdk-devargs");
 
@@ -2009,4 +2042,9 @@ netdev_dpdk_set_config(struct netdev *netdev, const 
struct smap *args,
     }
 
+    ret = rte_eth_dev_info_get(dev->port_id, &info);
+
+    dpdk_process_queue_size(netdev, args, !ret ? &info : NULL, true);
+    dpdk_process_queue_size(netdev, args, !ret ? &info : NULL, false);
+
     vf_mac = smap_get(args, "dpdk-vf-mac");
     if (vf_mac) {
-- 
2.40.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to