DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Nipun Gupta <nipun.gupta@nxp.com>,
	Hemant Agrawal <hemant.agrawal@nxp.com>
Cc: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,
	Xiaoyun Li <xiaoyun.li@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>
Subject: [dpdk-dev] [PATCH v2 5/7] rawdev: allow queue default config query to return error
Date: Thu, 13 Aug 2020 12:28:03 +0100
Message-ID: <20200813112806.164578-6-bruce.richardson@intel.com> (raw)
In-Reply-To: <20200813112806.164578-1-bruce.richardson@intel.com>

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>
---
 drivers/raw/ntb/ntb.c                  |  6 ++++--
 drivers/raw/skeleton/skeleton_rawdev.c | 12 +++++++-----
 lib/librte_rawdev/rte_rawdev.c         |  3 +--
 lib/librte_rawdev/rte_rawdev_pmd.h     |  4 +++-
 4 files changed, 15 insertions(+), 10 deletions(-)

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);
-- 
2.25.1


  parent reply	other threads:[~2020-08-13 11:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 15:20 [dpdk-dev] [PATCH 20.11 0/5] Enhance rawdev APIs Bruce Richardson
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 1/5] rawdev: add private data length parameter to info fn Bruce Richardson
2020-07-12 14:13   ` Xu, Rosen
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 2/5] rawdev: allow drivers to return error from info function Bruce Richardson
2020-07-12 14:13   ` Xu, Rosen
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 3/5] rawdev: add private data length parameter to config fn Bruce Richardson
2020-07-12 14:13   ` Xu, Rosen
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 4/5] rawdev: add private data length parameter to queue fns Bruce Richardson
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 5/5] rawdev: allow queue default config query to return error Bruce Richardson
2020-08-13 11:27 ` [dpdk-dev] [PATCH v2 0/7] Enhance rawdev APIs Bruce Richardson
2020-08-13 11:27   ` [dpdk-dev] [PATCH v2 1/7] rawdev: add private data length parameter to info fn Bruce Richardson
2020-08-17  5:26     ` Xu, Rosen
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 2/7] rawdev: allow drivers to return error from info function Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 3/7] rawdev: add private data length parameter to config fn Bruce Richardson
2020-09-04 14:16     ` Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 4/7] rawdev: add private data length parameter to queue fns Bruce Richardson
2020-08-13 11:28   ` Bruce Richardson [this message]
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 6/7] rawdev: mark start and stop functions optional Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 7/7] doc: remove rawdev deprecation notice Bruce Richardson
2020-09-02 11:21   ` [dpdk-dev] [PATCH v2 0/7] Enhance rawdev APIs Nipun Gupta
2020-09-09  9:47   ` Thomas Monjalon
2020-09-10 14:36 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 1/7] rawdev: add private data length parameter to info fn Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 2/7] rawdev: allow drivers to return error from info function Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 3/7] rawdev: add private data length parameter to config fn Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 4/7] rawdev: add private data length parameter to queue fns Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 5/7] rawdev: allow queue config query to return error Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 6/7] rawdev: mark start and stop functions optional Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 7/7] doc: remove rawdev deprecation notice Bruce Richardson
2020-09-11  9:56   ` [dpdk-dev] [PATCH v3 0/7] Enhance rawdev APIs Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200813112806.164578-6-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=jingjing.wu@intel.com \
    --cc=nipun.gupta@nxp.com \
    --cc=xiaoyun.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git