From patchwork Thu Oct 12 08:18:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 30208 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 963F11B246; Thu, 12 Oct 2017 10:18:58 +0200 (CEST) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id D24DE1B22D for ; Thu, 12 Oct 2017 10:18:53 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id k4so10985541wmc.1 for ; Thu, 12 Oct 2017 01:18:53 -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=HpYL9kTDMlOyaLsEDb7pnMKfxFZApqYXFvJ42p0opg8=; b=svmGhjEU089JwRz2853CQQ7c2/Cho6dvdF4H0B4q29hgG5JlgHW/1xTIe/BOSLE+dE qnUPmqte8bEXG3Jyd1k3iwtdRY0pDCEiEAWf2a9Vbam9QWfklAScxPzCybREr+3hm9T+ FVB4ihcYFrVlgPjdVXKg5cWYDQydYY+beyJSwwf6ue6umo3U453fxn35O6c0F0x+fdhZ FUqbNAnWqMRUiiH91Y92UkXNDA8zvY2rzizJfTinNAtCpY4uxOy/EFWBwE6Sn/JOxTcs zaXN3Da+rYc/iJJjmZC0wxqQHzXPkGM38lMZaLWe3v9MieLc/Jle3XClP+inangWAm+E nw9A== 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=HpYL9kTDMlOyaLsEDb7pnMKfxFZApqYXFvJ42p0opg8=; b=p13OBLxkQVHJd+RkDZi8tLV86WTflq9RwRq8H8Q+EVz7TwM2lZoL4tYKBAgNPgghpi lrwKzPIEMxOmh4AHEQLO9VPYUBSV6DMV5ueEKf18ar8X+LzIlj7ENr+GytFzQ31VQhBM AKOjip7cuF8kLRlPyAfHw5M7yhWOBHPHYYYGgKG1gMdfCHa8kLw7A6JxjcPES0whHHSK 3WyfSoG+tHp5+coU4XZo9aQLY/XgxR3JfkPPQmRWieJJlzSi8iaMATYWGd/TpW4NGFlf qjj9ObBfvot1nAkypXiGsnyjfSGpWhvwgHrihL+PkGgpW3FQopi+aSEfZpCFMuqLxtA5 XHWw== X-Gm-Message-State: AMCzsaWcl7uExaiydl9mx+hCz6By6BZb1ZKI2U+7/nffeBAmPlAV6SyI FujlQZkqti2gPzGRj9xyDzPMqWsM X-Google-Smtp-Source: ABhQp+SsBb/ntpAp0sxQZxX84o6sf+J8fprBcMzPb4OOaho9g4/X2WlDgLUL9miR2LLGWyJOxnPE4A== X-Received: by 10.28.32.136 with SMTP id g130mr1239211wmg.102.1507796333055; Thu, 12 Oct 2017 01:18:53 -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 i76sm39971757wmd.2.2017.10.12.01.18.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 01:18:52 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 12 Oct 2017 10:18:27 +0200 Message-Id: <6e6c6a656646fb834400030518193bbc7fda86b0.1507796085.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 v1 5/8] bus/pci: implement ctrl operator 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add the PCI bus control operator. This operator gives access to the probe policy setting, allowing to read and write this configuration item. The previous existing functionality is thus restored to the same level. Probe policy is blacklist mode by default for the PCI bus. Configuration is allowed once, and is then considered immutable. Signed-off-by: Gaetan Rivet --- drivers/bus/pci/include/rte_bus_pci.h | 1 + drivers/bus/pci/pci_common.c | 52 ++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/bus/pci/include/rte_bus_pci.h b/drivers/bus/pci/include/rte_bus_pci.h index e6a7998..f662705 100644 --- a/drivers/bus/pci/include/rte_bus_pci.h +++ b/drivers/bus/pci/include/rte_bus_pci.h @@ -155,6 +155,7 @@ struct rte_pci_driver { */ struct rte_pci_bus { struct rte_bus bus; /**< Inherit the generic class */ + enum rte_bus_probe_mode probe_mode; /**< Probe policy */ struct rte_pci_device_list device_list; /**< List of PCI devices */ struct rte_pci_driver_list driver_list; /**< List of PCI drivers */ }; diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index dc69113..358e232 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -370,9 +370,12 @@ rte_pci_probe(void) struct rte_pci_device *dev = NULL; size_t probed = 0, failed = 0; struct rte_devargs *devargs; - int probe_all = 1; + int probe_all = 0; int ret = 0; + if (rte_pci_bus.probe_mode != RTE_BUS_PROBE_WHITELIST) + probe_all = 1; + FOREACH_DEVICE_ON_PCIBUS(dev) { probed++; @@ -515,6 +518,51 @@ pci_unplug(struct rte_device *dev) return ret; } +static int +pci_probe_mode_get(void *_mode) +{ + enum rte_bus_probe_mode *mode = _mode; + + *mode = rte_pci_bus.probe_mode; + return 0; +} + +static int +pci_probe_mode_set(void *_mode) +{ + enum rte_bus_probe_mode *mode = _mode; + static int conf_done; + + if (conf_done && + *mode != rte_pci_bus.probe_mode) { + RTE_LOG(ERR, EAL, "Cannot set PCI to %s mode, bus is already configured.\n", + (*mode == RTE_BUS_PROBE_BLACKLIST) ? + "blacklist" : "whitelist"); + return -1; + } + rte_pci_bus.probe_mode = *mode; + conf_done = 1; + return 0; +} + +static rte_bus_ctrl_t pci_ctrl_ops[][RTE_BUS_CTRL_OP_MAX] = { + [RTE_BUS_CTRL_PROBE_MODE] = { + [RTE_BUS_CTRL_GET] = pci_probe_mode_get, + [RTE_BUS_CTRL_SET] = pci_probe_mode_set, + }, +}; + +static rte_bus_ctrl_t +pci_ctrl(enum rte_bus_ctrl_op op, + enum rte_bus_ctrl_item item) +{ + if (item > RTE_DIM(pci_ctrl_ops)) + return NULL; + if (op > RTE_DIM(pci_ctrl_ops[item])) + return NULL; + return pci_ctrl_ops[item][op]; +} + struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan, @@ -524,7 +572,9 @@ struct rte_pci_bus rte_pci_bus = { .unplug = pci_unplug, .parse = pci_parse, .get_iommu_class = rte_pci_get_iommu_class, + .ctrl = pci_ctrl, }, + .probe_mode = RTE_BUS_PROBE_BLACKLIST, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), };