rawdev: allow queue config query to return error
authorBruce Richardson <bruce.richardson@intel.com>
Thu, 10 Sep 2020 14:36:07 +0000 (15:36 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 11 Sep 2020 09:51:15 +0000 (11:51 +0200)
The driver APIs for returning the queue default config can fail if the
parameters are invalid, or other reasons, so allow them to return error
codes to the rawdev layer and from hence to the app.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
doc/guides/rel_notes/release_20_11.rst
drivers/raw/ntb/ntb.c
drivers/raw/skeleton/skeleton_rawdev.c
lib/librte_rawdev/rte_rawdev.c
lib/librte_rawdev/rte_rawdev_pmd.h

index e79b886..667e3d5 100644 (file)
@@ -90,6 +90,7 @@ API Changes
   allowing limited driver type-checking and ABI compatibility.
 
 * rawdev: Changed the return type of the function ``rte_dev_info_get()``
+  and the function ``rte_rawdev_queue_conf_get()``
   from ``void`` to ``int`` allowing the return of error codes from drivers.
 
 
index ad10857..bddb1f5 100644 (file)
@@ -246,7 +246,7 @@ ntb_dev_intr_handler(void *param)
        }
 }
 
-static void
+static int
 ntb_queue_conf_get(struct rte_rawdev *dev,
                   uint16_t queue_id,
                   rte_rawdev_obj_t queue_conf,
@@ -256,11 +256,13 @@ ntb_queue_conf_get(struct rte_rawdev *dev,
        struct ntb_hw *hw = dev->dev_private;
 
        if (conf_size != sizeof(*q_conf))
-               return;
+               return -EINVAL;
 
        q_conf->tx_free_thresh = hw->tx_queues[queue_id]->tx_free_thresh;
        q_conf->nb_desc = hw->rx_queues[queue_id]->nb_rx_desc;
        q_conf->rx_mp = hw->rx_queues[queue_id]->mpool;
+
+       return 0;
 }
 
 static void
index 801c707..f8b47a3 100644 (file)
@@ -220,10 +220,10 @@ static int skeleton_rawdev_reset(struct rte_rawdev *dev)
        return 0;
 }
 
-static void skeleton_rawdev_queue_def_conf(struct rte_rawdev *dev,
-                                          uint16_t queue_id,
-                                          rte_rawdev_obj_t queue_conf,
-                                          size_t conf_size)
+static int skeleton_rawdev_queue_def_conf(struct rte_rawdev *dev,
+                                         uint16_t queue_id,
+                                         rte_rawdev_obj_t queue_conf,
+                                         size_t conf_size)
 {
        struct skeleton_rawdev *skeldev;
        struct skeleton_rawdev_queue *skelq;
@@ -232,7 +232,7 @@ static void skeleton_rawdev_queue_def_conf(struct rte_rawdev *dev,
 
        if (!dev || !queue_conf ||
                        conf_size != sizeof(struct skeleton_rawdev_queue))
-               return;
+               return -EINVAL;
 
        skeldev = skeleton_rawdev_get_priv(dev);
        skelq = &skeldev->queues[queue_id];
@@ -240,6 +240,8 @@ static void skeleton_rawdev_queue_def_conf(struct rte_rawdev *dev,
        if (queue_id < SKELETON_MAX_QUEUES)
                rte_memcpy(queue_conf, skelq,
                        sizeof(struct skeleton_rawdev_queue));
+
+       return 0;
 }
 
 static void
index f48d8cf..fd123bb 100644 (file)
@@ -146,9 +146,8 @@ rte_rawdev_queue_conf_get(uint16_t dev_id,
        dev = &rte_rawdevs[dev_id];
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_def_conf, -ENOTSUP);
-       (*dev->dev_ops->queue_def_conf)(dev, queue_id, queue_conf,
+       return (*dev->dev_ops->queue_def_conf)(dev, queue_id, queue_conf,
                        queue_conf_size);
-       return 0;
 }
 
 int
index 34eb667..34dd718 100644 (file)
@@ -215,8 +215,10 @@ typedef int (*rawdev_reset_t)(struct rte_rawdev *dev);
  * @param[out] queue_conf
  *   Raw device queue configuration structure
  *
+ * @return
+ *   Returns 0 on success, negative errno on failure
  */
-typedef void (*rawdev_queue_conf_get_t)(struct rte_rawdev *dev,
+typedef int (*rawdev_queue_conf_get_t)(struct rte_rawdev *dev,
                                        uint16_t queue_id,
                                        rte_rawdev_obj_t queue_conf,
                                        size_t queue_conf_size);