From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Ananyev Subject: [PATCHv2 3/4] ethdev: prevent from starting/stopping already started/stopped device Date: Mon, 9 Jun 2014 18:26:16 +0100 Message-ID: <1402334777-27379-4-git-send-email-konstantin.ananyev@intel.com> References: <1402334777-27379-1-git-send-email-konstantin.ananyev@intel.com> Return-path: To: dev-VfR2kkLFssw@public.gmane.org In-Reply-To: <1402334777-27379-1-git-send-email-konstantin.ananyev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> To: dev-VfR2kkLFssw@public.gmane.org List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" From: Konstantin Ananyev Signed-off-by: Konstantin Ananyev --- 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