From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tetsuya Mukawa Subject: [PATCH v12 06/13] ethdev: Add rte_eth_dev_release_port to release specified port Date: Mon, 23 Feb 2015 21:45:55 +0900 Message-ID: <1424695564-3913-7-git-send-email-mukawa@igel.co.jp> References: <1424060073-23484-2-git-send-email-mukawa@igel.co.jp> <1424695564-3913-1-git-send-email-mukawa@igel.co.jp> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1424695564-3913-1-git-send-email-mukawa-AlSX/UN32fvPDbFq/vQRIQ@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" This patch adds rte_eth_dev_release_port(). The function is used for changing an attached status of the device that has specified name. v9: - rte_eth_dev_free() is replaced by rte_eth_dev_release_port(). (Thanks to Thomas Monjalon) v6: - Use rte_eth_dev structure as the paramter of rte_eth_dev_free(). v4: - Add parameter checking. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 11 +++++++++++ lib/librte_ether/rte_ethdev.h | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0e1e5c9..8d271ae 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -255,6 +255,17 @@ rte_eth_dev_allocate(const char *name) return eth_dev; } +int +rte_eth_dev_release_port(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 ef31bda..8016a51 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1487,6 +1487,18 @@ 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. + * Release the specified ethdev port. + * + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure. + * @return + * - 0 on success, negative on error + */ +int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev); + struct eth_driver; /** * @internal -- 1.9.1