From patchwork Thu Oct 12 08:18:24 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: 30190 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 55A9F1B232; Thu, 12 Oct 2017 10:18:54 +0200 (CEST) Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id 08C291D90 for ; Thu, 12 Oct 2017 10:18:49 +0200 (CEST) Received: by mail-wm0-f50.google.com with SMTP id f4so11007746wme.0 for ; Thu, 12 Oct 2017 01:18:49 -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=/F7ibE82Afk8aQYiaNcq1adXPrlh8Zqnh2jdKmbqPtU=; b=nryfIWUq5ltH+2V8z8zWckzi5CV5hJVPEHU08jMaIGU73SVXxdOLZeayBfNTEMJyf3 x1is9mo8ZGdaxfi1ZgKzWfOsaHjkNHQTCuHQ5EV5bqD0Qc1ErAZQ7ercvY5jp504YvC7 +/uI5tQH8me07WtBPVc2/hBeADhaBZRzDQITm7cdkunCnpkW+a96Qe2qG6JBeyo4S6uI veLbyCeuuY8dnsdyhkiWzcwvUEuZlmPPvHZLrteWCfT/b2SDixy8bMyYrnswXOA27vPd s3hlox5yMWhnHQOExn4CLt38+ENZ4RbzOBiSuvliRJ2dcIkPf5wwTfHKIxdDdVU7O74Q zn/w== 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=/F7ibE82Afk8aQYiaNcq1adXPrlh8Zqnh2jdKmbqPtU=; b=Ys8bM8AHbO4mU9/v/9UFGItxuwWYI6qsvf/PwKv89kZEYQ439ahmNacl6OodU3+a/I DsgAaGF2eV7/CGiAukZKZF/t/NH8LwfBJcabsGD1u5CtowIgSdf59J91BSgyc3eBs3yX yACiLHIzC5rsAHSlqwbgdBToX0IuJhOp78UxWY3la1/31z/DzScw++jabyhj1U0t9Mcr uiy6oWYYF37hQ7k+pDVVp9Bln+MqU5UpVwJcdt+AJWzkVABhFoFAkZ1IFRQC3BR4EUhs zYlzPROauukWGeACZiNoo8CflZMva6ikHFyt0Fss0Jq5GMgZXFzSq+TNQPq0+YBEbkcw hNGg== X-Gm-Message-State: AMCzsaX1PTfpEgIjEnUnZdPX0fOqTViCMnIPbsHdUdsu+lmJ2MUSHNx3 53PaTsupTVQO2VHcjUuO6hwBXcGT X-Google-Smtp-Source: AOwi7QDD5gVqvJJOv7lXsCSYGKnbWsuCSM2WtPd7/S9VfjHuksAJ9LyPZFRIDjEZFAcRK3lnhLfqrg== X-Received: by 10.28.149.204 with SMTP id x195mr1217694wmd.78.1507796329177; Thu, 12 Oct 2017 01:18:49 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 01:18:48 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 12 Oct 2017 10:18:24 +0200 Message-Id: <91106540c460d22dd23a30dc2903d7e238ff9a3b.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 2/8] bus: introduce opaque control framework 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" New configuration elements are added to the buses. They make the ABI unstable and will continue to do so. This new control scheme allows to add new bus operators without breaking the ABI and by only expanding the API. This helps having more stability in core EAL subsystems, while allowing flexibility for future evolutions. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_bus.c | 9 +++++++ lib/librte_eal/common/include/rte_bus.h | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 3c66a02..65d7229 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -42,6 +42,13 @@ struct rte_bus_list rte_bus_list = TAILQ_HEAD_INITIALIZER(rte_bus_list); +static rte_bus_ctrl_t +rte_bus_default_ctrl(enum rte_bus_ctrl_op op __rte_unused, + enum rte_bus_ctrl_item item __rte_unused) +{ + return NULL; +} + void rte_bus_register(struct rte_bus *bus) { @@ -53,6 +60,8 @@ rte_bus_register(struct rte_bus *bus) RTE_VERIFY(bus->find_device); /* Buses supporting driver plug also require unplug. */ RTE_VERIFY(!bus->plug || bus->unplug); + if (bus->ctrl == NULL) + bus->ctrl = &rte_bus_default_ctrl; TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name); diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 331d954..bd3c28e 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -183,6 +183,51 @@ struct rte_bus_conf { enum rte_bus_probe_mode probe_mode; /**< Probe policy. */ }; +/** + * Bus configuration items. + */ +enum rte_bus_ctrl_item { + RTE_BUS_CTRL_PROBE_MODE = 0, + RTE_BUS_CTRL_ITEM_MAX, +}; + +/** + * Bus configuration operations. + */ +enum rte_bus_ctrl_op { + RTE_BUS_CTRL_GET = 0, + RTE_BUS_CTRL_SET, + RTE_BUS_CTRL_RESET, + RTE_BUS_CTRL_OP_MAX, +}; + +/** + * Operator for a particular rte_bus configuration item. + * + * @param arg + * Operation parameter. + * + * @return + * 0 on success + * !0 otherwise + */ +typedef int (*rte_bus_ctrl_t)(void *arg); + +/** + * Accessor to bus configuration operators. + * + * @param op + * Operation type. + * + * @param item + * Operation element. + * + * @return + * Operator function on success. + * NULL if this item is not supported. + */ +typedef rte_bus_ctrl_t (*rte_bus_ctrl_get_t)(enum rte_bus_ctrl_op op, + enum rte_bus_ctrl_item item); /** * Get common iommu class of the all the devices on the bus. The bus may @@ -211,6 +256,7 @@ struct rte_bus { rte_bus_parse_t parse; /**< Parse a device name */ struct rte_bus_conf conf; /**< Bus configuration */ rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */ + rte_bus_ctrl_get_t ctrl; /**< Get control operators */ }; /**