From patchwork Mon Jan 19 10:40:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 2368 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id E6F5C5AB1; Mon, 19 Jan 2015 11:41:23 +0100 (CET) Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by dpdk.org (Postfix) with ESMTP id 25BD65A9B for ; Mon, 19 Jan 2015 11:41:14 +0100 (CET) Received: by mail-pa0-f41.google.com with SMTP id rd3so38152116pab.0 for ; Mon, 19 Jan 2015 02:41:13 -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=f7wP47ai7Cg8OykXg0dFDNk7WjAuaDfCFkviORqIMv8=; b=HliLc7Ru5JEyw5Ubsz2F6aihrzT/+lIkG/+h40ctIweGe81VbJiyhXh19BeRk9uLGs zDUFtsnCrTF6XbDkopus+LhDxci1vpVJ6OlduwrzO+ofNNp9hUkpVYgAel78Wha7XzoN GQCIyJZpJtT9DiXYB8nSD/xmKt6lXU+5FHvtCock3EX17QOE4BKkcsvXaW+cwo8aTaQP KsYLJ9JwnCpdQmxtpDkN2WkwVDYkp+HDajRfniogJyC0lWT3tzc+CLD4i2o50GEKGIEn SgE8TIfJwAag3muz5yw7kGKWXmPqv3QW96X+ukEl3R8suLBKBbRZQekqMhJc9wt8TsJI 2owQ== X-Gm-Message-State: ALoCoQk3GgIK1iIPJmnyxPnCvq9EU7o/jn6914QVm06qS+S8oCz0E3R3mnVQkxMfs3kHJg0KIEWP X-Received: by 10.66.65.108 with SMTP id w12mr42881526pas.115.1421664073519; Mon, 19 Jan 2015 02:41:13 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id a13sm11337588pdm.44.2015.01.19.02.41.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Jan 2015 02:41:12 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Mon, 19 Jan 2015 19:40:19 +0900 Message-Id: <1421664027-17971-4-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421664027-17971-1-git-send-email-mukawa@igel.co.jp> References: <1418106629-22227-2-git-send-email-mukawa@igel.co.j> <1421664027-17971-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v4 03/11] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds rte_eth_dev_free(). The function is used for changing a attached status of the device that has specified name. v4: - Add paramerter checking. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 20 ++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 46cabaf..16f22c0 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -260,6 +260,26 @@ 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; + + if (name == NULL) + return NULL; + + 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 616a44a..fe64c78 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1653,6 +1653,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