From patchwork Tue Nov 4 03:45:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1090 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 8AA7A7F3C; Tue, 4 Nov 2014 04:37:17 +0100 (CET) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by dpdk.org (Postfix) with ESMTP id 8BE447E75 for ; Tue, 4 Nov 2014 04:37:05 +0100 (CET) Received: by mail-pd0-f180.google.com with SMTP id ft15so12841059pdb.39 for ; Mon, 03 Nov 2014 19:46:21 -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=HqBoSTtMdVJ7EgqBvnkp2RSLhpdhncaIlVQwyP8LWwI=; b=TDJhtixpMmbwvaGPA2+rL2qphXi6oNJ1/bBz6KWqOSA+Z/FS2K4HcnBmapqWjD5OLP CWEF5rxDoLw2szmcIQw93/toE1pQbLt6v6bg1DFpaJicvbyxs4nGuvL9Q6xHy+uCz9HC UvzVNhZ1ByBUg6k+PuRyr4KWaa+R3oD8eeAyd6E4t+JlCtbxiyluwFwgMIf5HrAh0C4O q2yqrrAX4PtMN2cNByQhQKedAnlWd2D0dedB5Kr08JSd1u6JOYa3E2xBD0uENjGGus66 f92vTW1Xzoj8Mv8u8dcvD5MpVs3KekG+NmMi4XUF3qJ2cXCIzm6lgfRNgYWHyFpY+V0W fhNg== X-Gm-Message-State: ALoCoQk3ODAIuGYrXGY7xQ4278SQ2pWqPMn/75zlUjyyRzwbzottdz7CibGHo4PS5zUjhernoeUO X-Received: by 10.68.209.230 with SMTP id mp6mr46968282pbc.27.1415072781672; Mon, 03 Nov 2014 19:46:21 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id jc3sm18430580pbb.49.2014.11.03.19.46.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Nov 2014 19:46:21 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 4 Nov 2014 12:45:24 +0900 Message-Id: <1415072748-31937-5-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415072748-31937-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> <1415072748-31937-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [RFC PATCH v2 04/28] 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. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 16 ++++++++++++++++ lib/librte_ether/rte_ethdev.h | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index e37a25a..efd631b 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -248,6 +248,22 @@ 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; + 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 5d3956a..dfaeaee 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1629,6 +1629,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