From patchwork Thu Oct 12 08:18:28 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: 30209 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 7D5B31B24E; Thu, 12 Oct 2017 10:18:59 +0200 (CEST) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 3911E1B235 for ; Thu, 12 Oct 2017 10:18:55 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id i124so10755653wmf.3 for ; Thu, 12 Oct 2017 01:18:55 -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=/OIln8fkqDI95Q3OKmW/j2O5XluuHfzuk7d3CgzAZxs=; b=Yl+Bjb4hslvR1wzGN2gNDA8TN/YCLjiBVHe1LWxvY11BF9NGElENqzAgpyqVJxZsNI p0Y2UKCzDmhz+cgUtaQgGGJ4J2Y244kBM0KgvPu6dUA2h5jQDT1RgPUs3KHQCyRS4hVn dA4gLOz6uZOvu9fV9LLtLpwBmYKeffEqvuiN88U6+8oKJ97RSiMJUbjV0Oc9ADB7C380 pCmxNakqljczmg2QOE4dTdCVdWu72aJWlqzE9P/oOBpZ+jKfg4Uun7JhsDLHqkZeDzYU hTBlkBQRpu2KnC+ajdEr88rhs0JvCz9MfFrYekzWbmV+3maj+WVusTdxxhOD4S5JkGhc bj1w== 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=/OIln8fkqDI95Q3OKmW/j2O5XluuHfzuk7d3CgzAZxs=; b=hTSRqsRnipnXF4SSTWS6N3BSaps4Em4vTD49qKUmxylo/1Kp+cJF5HKYPOBRq0wVtC 2zbQKhbt4OsCLnhKA0udFYvn7/50sn7fQuv4e9UiH29Cj9QHodXCFfwMtrXYWN8sTJiF dim8VD9SiRBzPnZau5iIPHhhj9JpTt9KFYvAf9wenVNrJs+lMySAofnxR79QuoJzd9yw +RzWx4STKxsae4kHuObQqxfI9f40db8W/vW+4OO4XFguAga2wm2nP9xU5MiR8PwlMjAA QqcGgn6ROSZ3QeETe5/brI9jSmSNuc6piGYpuvu6SubQdVIjeRqs7Mz0XGcVWslwCb6H JK1Q== X-Gm-Message-State: AMCzsaU6owTZbOsUMSG3j3nviWnpT2hysBFXWWTIKFn9vGbwyS2pIkqY i/EnImDaWhLGAlNytFoV+VGJpLVz X-Google-Smtp-Source: AOwi7QD3Sea5LDn2owxJJgt3VVIjnawD/+N84H85Co+xKi2UyA6Cz+axtkO9F5i9jMkgxypT+ICQFw== X-Received: by 10.28.165.4 with SMTP id o4mr711139wme.68.1507796334248; Thu, 12 Oct 2017 01:18:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 01:18:53 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 12 Oct 2017 10:18:28 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 6/8] bus: add IOVA mode as a ctrl 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Leverage the new bus control framework for the IOVA mode configuration item. The previous version is left for the transition in drivers implementation and will be removed afterward. Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 - lib/librte_eal/common/eal_common_bus.c | 24 +++++++++++------ lib/librte_eal/common/include/rte_bus.h | 34 ++++++++++++++----------- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 - 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 97b3918..573869a 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -228,7 +228,6 @@ DPDK_17.11 { rte_eal_iova_mode; rte_eal_mbuf_default_mempool_ops; rte_lcore_has_role; - rte_pci_get_iommu_class; rte_pci_match; } DPDK_17.08; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 5b155c6..3627733 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -258,18 +258,26 @@ rte_bus_find_by_device_name(const char *str) enum rte_iova_mode rte_bus_get_iommu_class(void) { - int mode = RTE_IOVA_DC; + enum rte_iova_mode result; struct rte_bus *bus; + result = RTE_IOVA_DC; TAILQ_FOREACH(bus, &rte_bus_list, next) { + rte_bus_ctrl_t iova_mode_get; + enum rte_iova_mode mode; - if (bus->get_iommu_class) - mode |= bus->get_iommu_class(); + iova_mode_get = bus->ctrl(RTE_BUS_CTRL_GET, + RTE_BUS_CTRL_IOVA_MODE); + if (iova_mode_get != NULL) { + if (iova_mode_get(&mode)) + RTE_LOG(ERR, EAL, "Bus %s: error reading IOMMU class\n", + bus->name); + else + result |= mode; + } } - - if (mode != RTE_IOVA_VA) { + if (result != RTE_IOVA_VA) /* Use default IOVA mode */ - mode = RTE_IOVA_PA; - } - return mode; + result = RTE_IOVA_PA; + return result; } diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 93108ce..bb02d9d 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -55,21 +55,6 @@ extern "C" { /** Double linked list of buses */ TAILQ_HEAD(rte_bus_list, rte_bus); - -/** - * IOVA mapping mode. - * - * IOVA mapping mode is iommu programming mode of a device. - * That device (for example: IOMMU backed DMA device) based - * on rte_iova_mode will generate physical or virtual address. - * - */ -enum rte_iova_mode { - RTE_IOVA_DC = 0, /* Don't care mode */ - RTE_IOVA_PA = (1 << 0), /* DMA using physical address */ - RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */ -}; - /** * Bus specific scan for devices attached on the bus. * For each bus object, the scan would be responsible for finding devices and @@ -177,10 +162,29 @@ enum rte_bus_probe_mode { }; /** + * IOVA mapping mode. + * + * IOVA mapping mode is iommu programming mode of a device. + * That device (for example: IOMMU backed DMA device) based + * on rte_iova_mode will generate physical or virtual address. + * + */ +enum rte_iova_mode { + RTE_IOVA_DC = 0, /* Don't care mode */ + RTE_IOVA_PA = (1 << 0), /* DMA using physical address */ + RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */ +}; + +/** * Bus configuration items. */ enum rte_bus_ctrl_item { RTE_BUS_CTRL_PROBE_MODE = 0, + /** + * IOMMU class common to all devices on the bus. + * If irrelevant, the bus may return RTE_IOVA_DC. + */ + RTE_BUS_CTRL_IOVA_MODE, RTE_BUS_CTRL_ITEM_MAX, }; diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index a8ea4ea..a2709e3 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -232,7 +232,6 @@ DPDK_17.11 { rte_eal_iova_mode; rte_eal_mbuf_default_mempool_ops; rte_lcore_has_role; - rte_pci_get_iommu_class; rte_pci_match; } DPDK_17.08;