From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id E74CA7F60 for ; Thu, 20 Nov 2014 09:56:55 +0100 (CET) Received: by mail-pa0-f50.google.com with SMTP id bj1so2158210pad.23 for ; Thu, 20 Nov 2014 01:07:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jQhowij4vXNjLfhYc7by3co9qiWOdsnG+YwkNzN77MI=; b=k/2bIVUMjfxE8ee+uxU28y366yM7Og/CnImTGTxCZChN5x1NgWtwmUcpVGOE0eGRYE OAV/OakDo6wbvVkYKzWGIp6lQcPgz2xZGn+AuoAoWGdrQy3/1NdMDNBj8UHLiWidSmpk v0G1jVI0WucvwB0x1owr06iUhM6hHTkv40U1P+8ULIBbORAvkNsY9Rw1d7Wxp2eYgSRA GGPlHrSuCNfnSfXVxwwBPFJmI/dHti9aKUeYp6/AdjAqP7BRtPlGtKpoy2M7oXOpSyI2 L0E6TY/Kk2subkGWqog7cYnD0JBR39A+DMCJAUkAAlgyXFNLiwyCjCDkig18Jlyoh+eh /fcw== X-Gm-Message-State: ALoCoQma/Q1o/XmLI6Tv4o+0JaqDITDc7WleQkdLgbcr3a0HSvZRfmoCosm+cJJsMsDADfan1kcC X-Received: by 10.69.16.69 with SMTP id fu5mr27191491pbd.159.1416474444693; Thu, 20 Nov 2014 01:07:24 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id a6sm1432407pbu.64.2014.11.20.01.07.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 01:07:24 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 20 Nov 2014 18:06:18 +0900 Message-Id: <1416474399-16851-5-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [PATCH 04/25] ethdev: Add rte_eth_dev_free to free specified 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: Thu, 20 Nov 2014 08:56:57 -0000 This patch adds rte_eth_dev_free(). The function is used for changing a attached status of the device that has specified name. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 446c53a..f217e14 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -249,6 +249,23 @@ rte_eth_dev_allocate(const char *name) return eth_dev; } +struct rte_eth_dev * +rte_eth_dev_free(const char *name) +{ + struct rte_eth_dev *eth_dev; + + eth_dev = rte_eth_dev_allocated(name); + if (eth_dev == NULL) { + PMD_DEBUG_TRACE("Ethernet Device with name %s doesn't exist!\n", + name); + return NULL; + } + + eth_dev->attached = 0; + nb_ports--; + return eth_dev; +} + static int rte_eth_dev_init(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 2cd1c43..548467c 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1649,6 +1649,17 @@ extern uint8_t rte_eth_dev_count(void); */ struct rte_eth_dev *rte_eth_dev_allocate(const char *name); +/** + * Function for internal use by dummy drivers primarily, e.g. ring-based + * driver. + * Free the specified ethdev and returns the pointer to that slot. + * + * @param name Unique identifier name for each Ethernet device + * @return + * - Slot in the rte_dev_devices array for the freed device; + */ +struct rte_eth_dev *rte_eth_dev_free(const char *name); + struct eth_driver; /** * @internal -- 1.9.1