From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by dpdk.org (Postfix) with ESMTP id 290365A81 for ; Sun, 1 Feb 2015 05:02:32 +0100 (CET) Received: by mail-pa0-f49.google.com with SMTP id fa1so68365228pad.8 for ; Sat, 31 Jan 2015 20:02:31 -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=uHwknEkos0v8uvRwCURKR/+L830vgq5+H9IQaCIqZIk=; b=Sr2Pu4E8CG72ou2wEYgPQ1AiOAZYbnDc3X3HcF7d8ENiY1JRWI8BgyCGRwDjg/EepS Wruazeb3+J6J5HXgSOghim3LiX2Xg8PMeAOfHgmfqZZ68w6wjJP1UgFkG0nUdFkdnJ8p Iig/QtxZDUx2l8xy9wb8jgK1dzAQslld15GOoDGhAGgUKiD0gkPnwNs5DQIIfYUtikhV m/Igj0RXcwMWQU40+H46ZhDhHBpWjZs/CKVkfpzBQuRWNr/ykiuXqEget0UqsH1CrCJ8 QZ9HFBCvMBvdqssMSz5IyiS1mjz+GlM/9Gt5/4c4bnMDTNgpxrs5oBvuMvp2TglCmzSY aMBg== X-Gm-Message-State: ALoCoQlmNfL/CfHHOLjAHdUjoWI/ozZl4Jmt85R+CppMqsKfr6SqOPsMhdurvZYzuK2xn9okKyW9 X-Received: by 10.68.189.167 with SMTP id gj7mr20237187pbc.58.1422763351551; Sat, 31 Jan 2015 20:02:31 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id hd4sm5369241pbc.86.2015.01.31.20.02.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 20:02:30 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Sun, 1 Feb 2015 13:01:52 +0900 Message-Id: <1422763322-13742-6-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422763322-13742-1-git-send-email-mukawa@igel.co.jp> References: <1421664027-17971-9-git-send-email-mukawa@igel.co.jp> <1422763322-13742-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v6 05/13] 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: Sun, 01 Feb 2015 04:02:32 -0000 This patch adds rte_eth_dev_free(). The function is used for changing a attached status of the device that has specified name. v6: - Use rte_eth_dev structure as the paramter of rte_eth_dev_free(). v4: - Add paramerter checking. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 11 +++++++++++ lib/librte_ether/rte_ethdev.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index d70854f..b58bab3 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -260,6 +260,17 @@ rte_eth_dev_allocate(const char *name) return eth_dev; } +int +rte_eth_dev_free(struct rte_eth_dev *eth_dev) +{ + if (eth_dev == NULL) + return -EINVAL; + + eth_dev->attached = 0; + nb_ports--; + return 0; +} + 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 ca101f5..fbe7ac1 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1627,6 +1627,20 @@ 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. + * + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure + * associated with the matching device and which have been [automatically] + * allocated in the *rte_eth_devices* array. + * @return + * - 0 on success, negative on error + */ +int rte_eth_dev_free(struct rte_eth_dev *eth_dev); + struct eth_driver; /** * @internal -- 1.9.1