From: Bruce Richardson Date: Thu, 10 Sep 2020 14:36:07 +0000 (+0100) Subject: rawdev: allow queue config query to return error X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=13f8e4a27ee5baab0b5778c8e0a3df656a81b87c;p=dpdk.git rawdev: allow queue config query to return error 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 Acked-by: Nipun Gupta --- diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index e79b88641b..667e3d54ad 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -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. diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c index ad10857991..bddb1f5916 100644 --- a/drivers/raw/ntb/ntb.c +++ b/drivers/raw/ntb/ntb.c @@ -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 diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c index 801c707fb9..f8b47a391a 100644 --- a/drivers/raw/skeleton/skeleton_rawdev.c +++ b/drivers/raw/skeleton/skeleton_rawdev.c @@ -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 diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index f48d8cf10b..fd123bb848 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -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 diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h index 34eb667f62..34dd7181b4 100644 --- a/lib/librte_rawdev/rte_rawdev_pmd.h +++ b/lib/librte_rawdev/rte_rawdev_pmd.h @@ -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);