From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 998B47CA9 for ; Fri, 30 Jun 2017 20:20:14 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id j85so9319203wmj.0 for ; Fri, 30 Jun 2017 11:20:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=joHQLX7xH7/1IBZcW6TpKiD7Hp2Do1v0yy6bosJKAco=; b=gJzBn82XybjLjGUfLZxNJqPuq2qoESuAUui8sX0L/6fjMJbsWvFdI/bQAIhqD5Ho8s 9OVS9w62UKiqSVBVfMLk7d2/YJA1insHmIG3WIo98k8Q33Tfg+PTZkdxt59OSTipG/0r 8HYvkmtfauI2AKwoMCb0A2kBMesYk8IIYjYhx1fvFy3RaHbvbgc9yp+tkQRiBIjS8fdw 6E+WBSNLGYznnr9QpWL2LW5tvRFadghTsvLP5Fl62zw3IbcXFvR25z04U151pMOLj5Bl sJkapzAiQxmEYAFgHyPK+fHNmis90VdrWMTs4p45H2rsuXtqFjjJ57k3/8Kr/EygrZEK bXoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=joHQLX7xH7/1IBZcW6TpKiD7Hp2Do1v0yy6bosJKAco=; b=kRlYs9T6MhY2UYwhrefbHiEK54YIDGLKQuwwBDpBIeF+EwyNNJrxD2xjOHiIKmyMbw JrSjniW9Dh7kH+wXKK/4YfKm2+zCv2+5EdgykwqdYRn6TDiJWelcnA2Yb0QNBDlSGbdG mysfVsATL9KxarSZS3mDpMr7eaItt2lqekwV+WUbyuW8elU8WdTyHkWihS+e0rebVOZW 7ohvxUj5pooijWVxs/hC3PAjfPz+jRjT4XmcvyfhbZFah0aoPyTBTxWkWuvA372fxzD/ 51Vr0vRTBE4JnzxFmhIRrPspQ8INhxa8YPDugXQ7bU1CnLYRd42DXdglsnfHI+BY+1EL EmeA== X-Gm-Message-State: AKS2vOy7TAtFr51eGJFkaGr66CWowXafJk47S7mVuiqMlRhioSYr2bPe vMmtNC4ivcQ6u/sm X-Received: by 10.80.167.65 with SMTP id h59mr6366414edc.124.1498846813870; Fri, 30 Jun 2017 11:20:13 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id r28sm2826940edd.33.2017.06.30.11.20.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 11:20:12 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Fri, 30 Jun 2017 20:19:40 +0200 Message-Id: <20170630181943.23929-12-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> <20170630181943.23929-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v8 11/14] 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: Fri, 30 Jun 2017 18:20:15 -0000 From: Gaetan Rivet Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_pci.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index e449758..5ee100e 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 @@ -505,11 +506,44 @@ pci_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, return NULL; } +static int +pci_plug(struct rte_device *dev, const char *devargs __rte_unused) +{ + struct rte_pci_device *pdev; + struct rte_pci_addr *addr; + + addr = &RTE_DEV_TO_PCI(dev)->addr; + + /* 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) + return rte_pci_probe_one(addr); + } + + rte_errno = ENODEV; + return -1; +} + +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.9.4