From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 38FEDAB06 for ; Mon, 9 Jun 2014 19:26:57 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 09 Jun 2014 10:21:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,1003,1392192000"; d="scan'208";a="554602682" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 09 Jun 2014 10:26:51 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s59HQodh020323; Mon, 9 Jun 2014 18:26:50 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s59HQogG027920; Mon, 9 Jun 2014 18:26:50 +0100 Received: (from kananye1@localhost) by sivswdev02.ir.intel.com with id s59HQoj8027916; Mon, 9 Jun 2014 18:26:50 +0100 From: Konstantin Ananyev To: dev@dpdk.org Date: Mon, 9 Jun 2014 18:26:16 +0100 Message-Id: <1402334777-27379-4-git-send-email-konstantin.ananyev@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1402334777-27379-1-git-send-email-konstantin.ananyev@intel.com> References: <1402334777-27379-1-git-send-email-konstantin.ananyev@intel.com> To: dev@dpdk.org Subject: [dpdk-dev] [PATCHv2 3/4] ethdev: prevent from starting/stopping already started/stopped device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2014 17:26:57 -0000 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