From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCHv2 3/4] ethdev: prevent from starting/stopping already started/stopped device
Date: Mon, 9 Jun 2014 18:26:16 +0100 [thread overview]
Message-ID: <1402334777-27379-4-git-send-email-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <1402334777-27379-1-git-send-email-konstantin.ananyev@intel.com>
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
lib/librte_ether/rte_ethdev.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 11e877b..47bcee1 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -764,6 +764,14 @@ rte_eth_dev_start(uint8_t port_id)
dev = &rte_eth_devices[port_id];
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
+
+ if (dev->data->dev_started != 0) {
+ PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+ " already started\n",
+ port_id);
+ return (0);
+ }
+
diag = (*dev->dev_ops->dev_start)(dev);
if (diag == 0)
dev->data->dev_started = 1;
@@ -791,6 +799,14 @@ rte_eth_dev_stop(uint8_t port_id)
dev = &rte_eth_devices[port_id];
FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
+
+ if (dev->data->dev_started == 0) {
+ PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+ " already stopped\n",
+ port_id);
+ return;
+ }
+
dev->data->dev_started = 0;
(*dev->dev_ops->dev_stop)(dev);
}
--
1.8.3.1
next prev parent reply other threads:[~2014-06-09 17:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-09 17:26 [dpdk-dev] [PATCHv2 0/4] fix for 2 consecutive rte_eth_dev_start() can cause a SIGSEGV Konstantin Ananyev
2014-06-09 17:26 ` [dpdk-dev] [PATCHv2 1/4] e1000: do not release queue on alloc error Konstantin Ananyev
2014-06-09 17:26 ` [dpdk-dev] [PATCHv2 2/4] igb/ixgbe: reset queue pointers after releasing Konstantin Ananyev
2014-06-09 17:26 ` Konstantin Ananyev [this message]
2014-06-09 17:26 ` [dpdk-dev] [PATCHv2 4/4] ethdev: fix compiler warning on PMD_DEBUG_TRACE formats Konstantin Ananyev
2014-06-11 10:06 ` [dpdk-dev] [PATCHv2 0/4] fix for 2 consecutive rte_eth_dev_start() can cause a SIGSEGV 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=1402334777-27379-4-git-send-email-konstantin.ananyev@intel.com \
--to=konstantin.ananyev@intel.com \
--cc=dev@dpdk.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).