From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by dpdk.org (Postfix) with ESMTP id 96A105A85 for ; Fri, 30 Jan 2015 06:44:51 +0100 (CET) Received: by mail-pa0-f46.google.com with SMTP id lj1so48074646pab.5 for ; Thu, 29 Jan 2015 21:44:51 -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=P0jKPhYFFEKhQVeKdcJBEjI6kC28FbPPfOijr2sXA9Q=; b=dM+DngXXYlB82PMGZnhcy5FHObz08s+D7w0fv2nhzTcYWc0MkCFgiLATgpbsvHlxVl edxyiKx5uRvBE+jmtJAOSX9coyyd78+hr3hkRc9/sgbKI47mNEreMCOLxLBU3hjseIkc jn5MIjOZfIjv1d4V7QByK6ju3D4HUz13/GXMj9mIsOlQlX8V+D5eLvblnEZPS6AE2Qwj HMyhzVtaBtm/7xRjiLy8OFvAbcJSBRZjOhdBPM4LRnfpR/VrqeNIY4HCu62cDyaIyBAN /mshS1nrfmIhOmUnXhzZziAK3a4V2eQHP34HnksLIbBZfBfvcpOCvYrKh/oEP4gWqGGy fUJQ== X-Gm-Message-State: ALoCoQneeVhHLSoSV1j727rLHmGhRzjtKQNty7bpOx6AY7U7yQ170ZvkbwIVM5JozfNDnQjEzY0d X-Received: by 10.70.32.195 with SMTP id l3mr6222975pdi.41.1422596690970; Thu, 29 Jan 2015 21:44:50 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id ki4sm9482266pdb.34.2015.01.29.21.44.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 21:44:50 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Fri, 30 Jan 2015 14:42:33 +0900 Message-Id: <1422596563-26310-6-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422596563-26310-1-git-send-email-mukawa@igel.co.jp> References: <1421664027-17971-9-git-send-email-mukawa@igel.co.jp> <1422596563-26310-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v5 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: Fri, 30 Jan 2015 05:44:52 -0000 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 d70854f..0f3094f 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 ca101f5..6add058 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1627,6 +1627,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