From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id B34067CB3 for ; Thu, 29 Jun 2017 20:22:41 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id u23so4076179wma.2 for ; Thu, 29 Jun 2017 11:22:41 -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=oGggwqO0nUcJSwxp6wv6+eQ6J6WcCff4F5JaeBq43mmF3HO7DlqoqG/K9E1/J/CoNS HSQmpaYEoeR3fTb2fCWMJk4OJZOk6AI9tn5vxgT1IcYqkUY9dxFj4vgWtsuT1UuiHtg7 HP2BM+FFUdg9kLdOAydnxY9oMGf8YrkL+wGzmJl5nGem9uOsAQsKdAlaKddA6xY+BXoL l5GOi1o1WcAdZ3Rt+iM0F5U0bBS7+MYsaXszZBnc9f2tpfNyFg54xbyYi7bBiSO6Jbr5 P95CrC26vOaStHsul1ERjRjTnhhMiQAuDodkhGA6lkJ0Q957lBB92Gnqw3waRor36qmw qD5A== 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=l47CPPc0bfo27JiDbnMieA6MYpxnxHjhR8Zo51yihLy/OuXot/h+HrHj38lVtsHFDT isRqX5838nt6rEXNC6RzHf2oxX/5Tqt548KJ39ehbOXpDP9a/vOHztOADgCGidm2AcSW s1ZHX2K393cX8cwYJSOJBeyJU9hryi3Yw6ViZkTMyGAt0hFLA1wF6VGq5CrlbVEFUXix hqz2Yjnhw/q0gkSTSBq5YkLFw7eOk9PnHbONvZ1qfTwcfaTmuTwsyg58t2QdeYpYG3uT 8QjEC7TVrKEMP4/uUQyKO/+S/clDSlBtUGK6JEGo1vxdD485CXf9hvZRssbXLig35Lfm ICaw== X-Gm-Message-State: AKS2vOzbugjZuuLzKFm0cYjZuCmvsuPanEPoepQWVCGN4fWUoUukqJaK XYCwWV1bUVLEr/Rs X-Received: by 10.80.209.215 with SMTP id i23mr2632419edg.165.1498760561201; Thu, 29 Jun 2017 11:22:41 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id e28sm1446366ede.14.2017.06.29.11.22.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 11:22:40 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Thu, 29 Jun 2017 20:22:03 +0200 Message-Id: <20170629182206.1072-13-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170629182206.1072-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v7 12/15] 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: Thu, 29 Jun 2017 18:22:42 -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