From patchwork Thu Oct 12 08:18:26 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: 30192 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 2AF9E1B20A; Thu, 12 Oct 2017 10:18:57 +0200 (CEST) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id 811F929C6 for ; Thu, 12 Oct 2017 10:18:52 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id k4so10985405wmc.1 for ; Thu, 12 Oct 2017 01:18:52 -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=CG4UpxboK3f52zaIs8MWlawr3hZ46GuL4D1CGA0+EKI=; b=bhcJual59QXTjanDYEN52ELtv1NKkii8H5wcjxA89cyUC3sLCL4D3LxzTvN28jXYWy M/sedZwhK4SmY0gk++wMxVosPw4XDoQVDgXEdoIwCGfdOzV0gt/kZMYjNpn51inIWFbv IS0VSkrZUp6FEXcsjSE8Ch2Y+AuLzTgve83sKh9u+SpGGVBwEPuWpnY+HykV0DAwlsCj gaFk0H+2esVYw3EkEGQug0icqLTNDMcooJ/RdbV9kfIgjMAuG9uM2ynsoySmhJS7lAf/ czacqWLqw4S3Uj1WmzA0ZoIyh/sdPsn9w0m6T2WrsGgr7vJvwiwzi7tyNG335G0oG+ah 23eA== 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=CG4UpxboK3f52zaIs8MWlawr3hZ46GuL4D1CGA0+EKI=; b=BpPTiqk+hfmHgScrkiU7pbyTvyRSWUzWhiaw1Q7od5OV3HU9wiMi4aLc6pvtn1qlft 7DFos3zqiXoZ91ZCAHJTdy0/XLD3DS04xEvK8ia3p01PN5I/aQP235yesxiXTYqLPYPy cayg5h7zRZrgpapav/M+cOnPo7zGn6+iPWo/kc0fXGxlD/NC2YlKzE7+v9jw2xfcoysd PUADNrN6dy5HFqCcFB2LHT1tLI79OJbrt3FldDBollO9xPTnPGYwE/byRLPc7ACY0z03 zO/4v+QIqbgsZPBsrJTWWQNGX+HkGx8mjxeUFS0oW4u9xdQ9lUBt3urbOVqnaKRdmqYX Bcfg== X-Gm-Message-State: AMCzsaVzQTh1mrf2OCDK5gR2YDE6LSlquYvOwE6We4lhGDdfdFC3M3ir VAOKBzz2hqnGRF8hI9LPg7MKFlcb X-Google-Smtp-Source: AOwi7QCvMoHBAqOzflesOoM3XTJTnp+USMZCFYlD4siJ7LPjTgDEPmz2df6E35e1UoXHHOUvi1jK2Q== X-Received: by 10.223.129.228 with SMTP id 91mr1410693wra.233.1507796331756; Thu, 12 Oct 2017 01:18:51 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 01:18:50 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 12 Oct 2017 10:18:26 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 4/8] bus: add probe mode setter 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" Introduce new rte_bus operation to configure the probe policy. Implementation is required from buses interested in supporting this configuration element. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_bus.c | 24 ++++++++++++++++++++++++ lib/librte_eal/common/eal_common_options.c | 17 ++++------------- lib/librte_eal/common/include/rte_bus.h | 16 ++++++++++++++++ 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 65d7229..5b155c6 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -120,6 +120,30 @@ rte_bus_probe(void) return 0; } +/* Configure the probing policy of a bus */ +int +rte_bus_probe_mode_set(const char *busname, + enum rte_bus_probe_mode mode) +{ + struct rte_bus *bus; + rte_bus_ctrl_t probe_mode_set; + + bus = rte_bus_find_by_name(busname); + if (bus == NULL) { + RTE_LOG(ERR, EAL, "Bus %s not found.\n", + busname); + return -EFAULT; + } + probe_mode_set = bus->ctrl(RTE_BUS_CTRL_SET, + RTE_BUS_CTRL_PROBE_MODE); + if (probe_mode_set == NULL) { + RTE_LOG(ERR, EAL, "Bus %s: probe policy cannot be configured.\n", + busname); + return -ENOTSUP; + } + return probe_mode_set(&mode); +} + /* Dump information of a single bus */ static int bus_dump_one(FILE *f, struct rte_bus *bus) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index e40c049..630c9d2 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -997,29 +997,24 @@ int eal_parse_common_option(int opt, const char *optarg, struct internal_config *conf) { - static int b_used; - static int w_used; - switch (opt) { /* blacklist */ case 'b': - if (w_used) - goto bw_used; + if (rte_bus_probe_mode_set("pci", RTE_BUS_PROBE_BLACKLIST) < 0) + return -1; if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI, optarg) < 0) { return -1; } - b_used = 1; break; /* whitelist */ case 'w': - if (b_used) - goto bw_used; + if (rte_bus_probe_mode_set("pci", RTE_BUS_PROBE_WHITELIST) < 0) + return -1; if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI, optarg) < 0) { return -1; } - w_used = 1; break; /* coremask */ case 'c': @@ -1165,10 +1160,6 @@ eal_parse_common_option(int opt, const char *optarg, } return 0; -bw_used: - RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) " - "cannot be used at the same time\n"); - return -1; } static void diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index a8fb6b1..93108ce 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -289,6 +289,22 @@ int rte_bus_scan(void); int rte_bus_probe(void); /** + * Configure bus probe policy. + * + * @param busname + * Name of the bus to configure. + * + * @param mode + * Configure the designated bus probe policy to this value. + * + * @return + * 0 on success + * !0 otherwise + */ +int rte_bus_probe_mode_set(const char *busname, + enum rte_bus_probe_mode mode); + +/** * Dump information of all the buses registered with EAL. * * @param f