From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id B290B567E for ; Mon, 26 Jun 2017 02:22:37 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id r103so131769926wrb.0 for ; Sun, 25 Jun 2017 17:22:37 -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=aB9rZmbDCyHiTsWNGpBrb9v+otOBpf5iRbIhBMU7yzQ=; b=nEmmJi34vMbh7+Bdmwn2BO9RInAWkGpdSXJEjK3bz0wikkWjdkNvbtsjjPJd/rKSXU P0NPubLqNn6tHANgO2yQrnBdTKcv1agndq/UWHNeD6tBgOZG7yNKiMU9xX+8fszjW7FT mdEd8kq4G8yrTTbVCDLPndc01l1P6zfZa1tHSQq+oAD77GwzP9Nck76HxOcl3y7Rqtc2 BVnhaYb3PjUjbM08b5yAABw9IffKRlaue45tqJ7qAzQGbkUFBhHiRSdfUwQ0mtLe1d1W ZEy23iOHEnQ5QRoxdm0xKzfi1QHibpHX6NdV0Hc8gO3BZ1YRL2KmePfpDGlHafBAcY4R RfqA== 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=aB9rZmbDCyHiTsWNGpBrb9v+otOBpf5iRbIhBMU7yzQ=; b=pc3zYmwv7Me+iKEhihnZJk5RQrV7bGvWyx9sUWK6yEAYur0VxRuyjbIf6YBx0oexga p8r36ujy/n1CJ3XnFtWQx5bjziZ70eHYD1XSIQ7aVP7wLgjfoRIGoxHCYLRB3kLHnG8Z +1XNGXOdWjgoKjl/VUEopRhLXuDQQpqqmDNAGnm1nWf/YSvc+T7qOq+rqHQ11ry+Y4AA CybT+ln8ZBhaagJRCifBlv9cIciuBBsIWXQdYRR09Pu3/csHFrQ7+OOcPc+UvDmiMbtS kDO+gYlx6TFcHf4Z9PpI4uH6XDqnpuWyz8LJD70QmHl/XzSQJDT6iGUEaff2BxTTFAuN 1rcA== X-Gm-Message-State: AKS2vOyrxcvZrUBACRyAeoRjNwm8Y1kYfV/F0lDnsqeLgnXJREFwB7gy QtW+N7Ve7HmS+Mp7JwE= X-Received: by 10.223.173.140 with SMTP id w12mr13159844wrc.4.1498436557173; Sun, 25 Jun 2017 17:22:37 -0700 (PDT) Received: from bidouze.dev.6wind.com ([62.23.145.78]) by smtp.gmail.com with ESMTPSA id 19sm16061626wrx.26.2017.06.25.17.22.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jun 2017 17:22:36 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Mon, 26 Jun 2017 02:22:09 +0200 Message-Id: <98e3e67ce4b581325398aa6167e4a9a3ab20a6e8.1498436062.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 v5 11/12] 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: Mon, 26 Jun 2017 00:22:38 -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 00d48d9..286357d 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 @@ -500,11 +501,54 @@ pci_find_device(rte_dev_cmp_t cmp, const void *data) 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)) { + rte_errno = ENODEV; + return NULL; + } + break; + } + } + return pdev ? &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)) { + 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