From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by dpdk.org (Postfix) with ESMTP id 3EBE6567E for ; Tue, 27 Jun 2017 18:11:44 +0200 (CEST) Received: by mail-wr0-f178.google.com with SMTP id r103so161828907wrb.0 for ; Tue, 27 Jun 2017 09:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=g0lG71tWVBWsPb9vsaltWZaxVTyhc6+nltsPYtOQizI=; b=s8gM+WDZj8sPocJpDOi5hSNvZNMqd0GL8liTHdGvQCtzsxkqkYFE6NeI0vhLeHspj0 9YoOdOA0y/iaDZBIUwl9KtRFxt+pjUFXaCNhdjeXK1/Y4EVztGz8RXd/WeJz5iNrxsKA g15RWHE5CwRxvc9aTFIU1uBGybY+YHTzdJ6VxsORxScnMCmsqSlGRkx6VWR1rBmFYEQ2 gprBf50sFaar2zghRsmdoUgUB5OYAkaRKJOQmAn2PRlw90f1IPGQ2bolZlABJnFxbrt5 W5MHgFRzo/CJNHdBv439ITx6t117RXUc49NjS9uNSdBFHg5j3tFSduj8I8Om1Dv7YuIa gykQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=g0lG71tWVBWsPb9vsaltWZaxVTyhc6+nltsPYtOQizI=; b=QgE2/mqo0HCH09tmAKT0hW2IpyRnWe4L3kXHjbDGk/8tK82qN4r6B5zn4NrDv0Eiej Zheru822eFmT6z8iRWSlGis53jPkIxMKhxchan9pY7tfXZQlGs1h3M36zWVNKqDbLC3n 135VJ4JvIGBjpbLCFd0p8mplk5600rWzpvBhf3AMiOqxqZn4vWgZuE1QsHvEWkbKfQkc 3U+AfuyZ7PIKkyciBzW22ZNyYcLUMJWeDKrbpwM7hHi9V7cTCNv1VfABhMtYI/Ewfhj9 cDzxzWTlJ/KF90FSTPBOKVkfe/c/mlwFT9t97mZkBnoqO+AcXju0Q2moJOHkrDtpP7LN XqWg== X-Gm-Message-State: AKS2vOz/hC+JJGLGxn+0XQw0pu5ofwv+pfOKtVEpRPQCpP/pSm2Eem6Q KTV8fHuGIbLPoMIbHd8= X-Received: by 10.223.161.138 with SMTP id u10mr16882954wru.191.1498579904370; Tue, 27 Jun 2017 09:11:44 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id v13sm4080465wmd.5.2017.06.27.09.11.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 09:11:43 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 27 Jun 2017 18:11:17 +0200 Message-Id: <7bfff124f11d27694c3d318ff3aad9b33247906a.1498577192.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 10/11] pci: implement hotplug bus operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jun 2017 16:11:45 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_pci.c | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index ab55041..e30d2d1 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -508,11 +509,54 @@ pci_find_device(rte_dev_cmp_t cmp, return NULL; } +static struct rte_device * +pci_plug(struct rte_devargs *da) +{ + struct rte_pci_device *pdev; + struct rte_pci_addr *addr; + + addr = &da->pci.addr; + /* + * Update eventual pci device in global list. + * Insert it if none was found. + */ + if (pci_update_device(addr) < 0) { + rte_errno = EIO; + return NULL; + } + /* Find the current device holding this address in the bus. */ + FOREACH_DEVICE_ON_PCIBUS(pdev) { + if (rte_eal_compare_pci_addr(&pdev->addr, addr) == 0) { + if (rte_pci_probe_one(addr) != 0) { + rte_errno = ENODEV; + return NULL; + } + break; + } + } + return (pdev != NULL) ? &pdev->device : NULL; +} + +static int +pci_unplug(struct rte_device *dev) +{ + struct rte_pci_device *pdev; + + pdev = RTE_DEV_TO_PCI(dev); + if (rte_pci_detach(&pdev->addr) != 0) { + rte_errno = ENODEV; + return -1; + } + return 0; +} + struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan, .probe = rte_pci_probe, .find_device = pci_find_device, + .plug = pci_plug, + .unplug = pci_unplug, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), -- 2.1.4