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>,
	Kevin Laatz <kevin.laatz@intel.com>
Subject: [dpdk-dev] [PATCH v2 6/7] rawdev: mark start and stop functions optional
Date: Thu, 13 Aug 2020 12:28:04 +0100
Message-ID: <20200813112806.164578-7-bruce.richardson@intel.com> (raw)
In-Reply-To: <20200813112806.164578-1-bruce.richardson@intel.com>

Not all rawdevs will require a device start/stop function, so rather than
requiring such drivers to provide dummy functions, just set the
started/stopped rawdev flag from the rawdev layer and return success.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_rawdev/rte_rawdev.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index fd123bb848..36f3acf2b7 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -398,20 +398,21 @@ rte_rawdev_start(uint16_t dev_id)
 
 	RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
 	dev = &rte_rawdevs[dev_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
-
 	if (dev->started != 0) {
 		RTE_RDEV_ERR("Device with dev_id=%" PRIu8 "already started",
 			     dev_id);
 		return 0;
 	}
 
+	if (dev->dev_ops->dev_start == NULL)
+		goto mark_started;
+
 	diag = (*dev->dev_ops->dev_start)(dev);
-	if (diag == 0)
-		dev->started = 1;
-	else
+	if (diag != 0)
 		return diag;
 
+mark_started:
+	dev->started = 1;
 	return 0;
 }
 
@@ -425,15 +426,18 @@ rte_rawdev_stop(uint16_t dev_id)
 	RTE_RAWDEV_VALID_DEVID_OR_RET(dev_id);
 	dev = &rte_rawdevs[dev_id];
 
-	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
-
 	if (dev->started == 0) {
 		RTE_RDEV_ERR("Device with dev_id=%" PRIu8 "already stopped",
 			dev_id);
 		return;
 	}
 
+	if (dev->dev_ops->dev_stop == NULL)
+		goto mark_stopped;
+
 	(*dev->dev_ops->dev_stop)(dev);
+
+mark_stopped:
 	dev->started = 0;
 }
 
-- 
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   ` [dpdk-dev] [PATCH v2 5/7] rawdev: allow queue default config query to return error Bruce Richardson
2020-08-13 11:28   ` Bruce Richardson [this message]
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-7-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=kevin.laatz@intel.com \
    --cc=nipun.gupta@nxp.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