From patchwork Tue Dec 9 03:42:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1832 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 F413A8048; Tue, 9 Dec 2014 04:43:28 +0100 (CET) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by dpdk.org (Postfix) with ESMTP id E0C7A3F9 for ; Tue, 9 Dec 2014 04:43:23 +0100 (CET) Received: by mail-pa0-f42.google.com with SMTP id et14so6520233pad.15 for ; Mon, 08 Dec 2014 19:43:23 -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=i1sqCWQu7AL1tlZ2598rLpPPiTJXOTIa+FUw5QcLYyA=; b=XTK8+UxnJCfIug4iZ/6Cq1/JkjnzMa1CCJPdL+TZmrqcJliG5/vRG3v0at5xgqLVkV fBFPEH5GQaTri+e97r00ztY12Uu3XJU3oVhmmIDzVUidqskHqUWwjSoGes3uZbE1i8Mg 4uxyWsW640RgJDtU+5PZe7i2Y8BQjO2XR71TO3i4YBe3LnzoOiu6KsaSHj31ceUgtOiY V0lJwqPNBAPAmq9f6voQbyAPfMqtayWWUnxQd7OMZEvCkjSQc5xSjINsRpLTnuWLyrqg hDFVwQ/alpfcx1tWZcV84wntTs7cK5T+hMz9Mh5EVO96qczM+bDLeXyLRH8lyJde/hPo 93iw== X-Gm-Message-State: ALoCoQnhupYFVYcpbEOjoTv3oZE0uL0++4brKkBz3sDKrX74lzkVfDhNHwIH+dF1DHpwa996PtOK X-Received: by 10.66.246.130 with SMTP id xw2mr1260817pac.55.1418096603245; Mon, 08 Dec 2014 19:43:23 -0800 (PST) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id xx2sm2185pab.17.2014.12.08.19.43.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 19:43:22 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 9 Dec 2014 12:42:29 +0900 Message-Id: <1418096571-27531-7-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418096571-27531-1-git-send-email-mukawa@igel.co.jp> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418096571-27531-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [PATCH v2 06/28] ethdev: Add rte_eth_dev_shutdown for closing PCI devices. 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" rte_eth_dev_shutdown() is called when PCI device is closed. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index d5fdb03..51697e1 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -332,6 +332,42 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv, return diag; } +static int +rte_eth_dev_shutdown(struct rte_pci_driver *pci_drv, + struct rte_pci_device *pci_dev) +{ + struct eth_driver *eth_drv; + struct rte_eth_dev *eth_dev; + char ethdev_name[RTE_ETH_NAME_MAX_LEN]; + + /* Create unique Ethernet device name using PCI address */ + snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d", + pci_dev->addr.bus, pci_dev->addr.devid, + pci_dev->addr.function); + + eth_dev = rte_eth_dev_free(ethdev_name); + if (eth_dev == NULL) + return -ENODEV; + + eth_drv = (struct eth_driver *)pci_drv; + + /* Invoke PMD device shutdown function */ + if (*eth_drv->eth_dev_shutdown) + (*eth_drv->eth_dev_shutdown)(eth_drv, eth_dev); + + /* init user callbacks */ + TAILQ_INIT(&(eth_dev->callbacks)); + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + rte_free(eth_dev->data->dev_private); + + eth_dev->pci_dev = NULL; + eth_dev->driver = NULL; + eth_dev->data = NULL; + + return 0; +} + /** * Register an Ethernet [Poll Mode] driver. * @@ -350,6 +386,7 @@ void rte_eth_driver_register(struct eth_driver *eth_drv) { eth_drv->pci_drv.devinit = rte_eth_dev_init; + eth_drv->pci_drv.devshutdown = rte_eth_dev_shutdown; rte_eal_pci_register(ð_drv->pci_drv); }