From patchwork Thu Oct 12 08:18:29 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: 30210 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 ADE2D1B25A; Thu, 12 Oct 2017 10:19:00 +0200 (CEST) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id A597F2BF7 for ; Thu, 12 Oct 2017 10:18:56 +0200 (CEST) Received: by mail-wm0-f45.google.com with SMTP id t69so10855824wmt.2 for ; Thu, 12 Oct 2017 01:18:56 -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=Z9NblqbY1bOS6KuBlaigpQCIRfnku3bFbACJtIu4Q68=; b=jRxDLnNIGG/dntE3ru8LtLENxqUEOVSoN1bsoEQguG6P/3cG+FQwHp7vSecidJm/lR tv9QKzP0vcH6/5jC2coxt3VW5lHDGrL2xWabR5CZqMcI4Aa/UItRJBbHUpSFzmWilao9 LE80JvXf9ogWYIT4vS/TCPV9hBaYET2RUNuKLCS0w7AH+ZUDJ30YW7hh7nsetgb1q7mH 5g9jqcEV0EImZed09QZ/vNHgLwuSFf5uq/Ka3apkOo92Dq6lmiSvRPNTSTX25iBZRACj iKvrwqxNK05zSTDYEDDRo1+L3BHe9nSw61QG7DWXmnIgYEIZO2vn353+NTcyScAePWFO NMCg== 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=Z9NblqbY1bOS6KuBlaigpQCIRfnku3bFbACJtIu4Q68=; b=ruvll6jsaqdDuJqaVzZ7MsMGjNOl5xN4vge6kpOLGBVdisnmt4mAKouBrRsCZtMrKC E5ZRQjqJ+bDOZOAlwtE+GAjkS1llz3n0BI2hXGPjd6bPqPiVpEUkYBhIks+/J9mstIw1 U8GsTI+cV3yRruF9rNoZAwDwkDdHChY3WSHMxqusAojU3q0PUwmdcOimZ+YC5rO5TiZ1 Qk0jRsVfZ5EpBatpVX7cPWySq8P8CG1gPLAREAY8hzCFMsRuSGdM3leTgCo/lMcsrbVx NB+DPyRpACHGob3HZaAMrl9JN5TEtlH77Ws7NVrzwifOTb6Ubbivx/+Mbx0rA077bfOY qQ4Q== X-Gm-Message-State: AMCzsaVKv2rLwXkntPB+JzdIVyrGRihHVcxfOQIKIXhlMk3PMIcaKcQW 0YL/KSJqfjuvnPKxw6go/T+9CMeD X-Google-Smtp-Source: AOwi7QBp2D/KMXKgZjLcbm4oAeQBDl1VIdJThpOH/oIVD6mxXdNWFbSOB/8fgshY8fRbwagQu9dKeg== X-Received: by 10.28.184.141 with SMTP id i135mr1243952wmf.143.1507796335532; Thu, 12 Oct 2017 01:18:55 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 01:18:54 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 12 Oct 2017 10:18:29 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 7/8] bus/pci: implement IOVA mode getter 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" Implement the ctrl operator for the IOVA mode configuration item. The previous functionality is kept identical, only the new control framework is used. All operators are made private as there is no reason to expose them. Signed-off-by: Gaetan Rivet --- drivers/bus/pci/bsd/pci.c | 9 ++++++--- drivers/bus/pci/include/rte_bus_pci.h | 11 ----------- drivers/bus/pci/linux/pci.c | 20 +++++++++++++------- drivers/bus/pci/pci_common.c | 4 +++- drivers/bus/pci/private.h | 13 +++++++++++++ 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index 753d914..ffb159f 100644 --- a/drivers/bus/pci/bsd/pci.c +++ b/drivers/bus/pci/bsd/pci.c @@ -407,11 +407,14 @@ rte_pci_scan(void) /* * Get iommu class of PCI devices on the bus. */ -enum rte_iova_mode -rte_pci_get_iommu_class(void) +int +pci_iommu_class_get(void *_mode) { + enum rte_iova_mode *mode = _mode; + /* Supports only RTE_KDRV_NIC_UIO */ - return RTE_IOVA_PA; + *mode = RTE_IOVA_PA; + return 0; } int diff --git a/drivers/bus/pci/include/rte_bus_pci.h b/drivers/bus/pci/include/rte_bus_pci.h index f662705..a120b70 100644 --- a/drivers/bus/pci/include/rte_bus_pci.h +++ b/drivers/bus/pci/include/rte_bus_pci.h @@ -205,17 +205,6 @@ int rte_pci_match(const struct rte_pci_driver *pci_drv, const struct rte_pci_device *pci_dev); - -/** - * Get iommu class of PCI devices on the bus. - * And return their preferred iova mapping mode. - * - * @return - * - enum rte_iova_mode. - */ -enum rte_iova_mode -rte_pci_get_iommu_class(void); - /** * Map the PCI device resources in user space virtual memory address * diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index 422579f..b711cdf 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -553,17 +553,20 @@ pci_one_device_has_iova_va(void) /* * Get iommu class of PCI devices on the bus. */ -enum rte_iova_mode -rte_pci_get_iommu_class(void) +int +pci_iommu_class_get(void *_mode) { + enum rte_iova_mode *mode = _mode; bool is_bound; bool is_vfio_noiommu_enabled = true; bool has_iova_va; bool is_bound_uio; is_bound = pci_one_device_is_bound(); - if (!is_bound) - return RTE_IOVA_DC; + if (!is_bound) { + *mode = RTE_IOVA_DC; + return 0; + } has_iova_va = pci_one_device_has_iova_va(); is_bound_uio = pci_one_device_bound_uio(); @@ -572,8 +575,10 @@ rte_pci_get_iommu_class(void) true : false; #endif - if (has_iova_va && !is_bound_uio && !is_vfio_noiommu_enabled) - return RTE_IOVA_VA; + if (has_iova_va && !is_bound_uio && !is_vfio_noiommu_enabled) { + *mode = RTE_IOVA_VA; + return 0; + } if (has_iova_va) { RTE_LOG(WARNING, EAL, "Some devices want iova as va but pa will be used because.. "); @@ -583,7 +588,8 @@ rte_pci_get_iommu_class(void) RTE_LOG(WARNING, EAL, "few device bound to UIO\n"); } - return RTE_IOVA_PA; + *mode = RTE_IOVA_PA; + return 0; } /* Read PCI config space. */ diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 358e232..bbe862b 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -550,6 +550,9 @@ static rte_bus_ctrl_t pci_ctrl_ops[][RTE_BUS_CTRL_OP_MAX] = { [RTE_BUS_CTRL_GET] = pci_probe_mode_get, [RTE_BUS_CTRL_SET] = pci_probe_mode_set, }, + [RTE_BUS_CTRL_IOVA_MODE] = { + [RTE_BUS_CTRL_GET] = pci_iommu_class_get, + }, }; static rte_bus_ctrl_t @@ -571,7 +574,6 @@ struct rte_pci_bus rte_pci_bus = { .plug = pci_plug, .unplug = pci_unplug, .parse = pci_parse, - .get_iommu_class = rte_pci_get_iommu_class, .ctrl = pci_ctrl, }, .probe_mode = RTE_BUS_PROBE_BLACKLIST, diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index fdc2c81..ee13855 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -171,4 +171,17 @@ void pci_uio_free_resource(struct rte_pci_device *dev, int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, struct mapped_pci_resource *uio_res, int map_idx); +/** + * Get iommu class of PCI devices on the bus. + * Return their preferred iova mapping mode. + * + * @param _mode + * Generic address to an (enum rte_iova_mode) + * @return + * 0 on success + * !0 otherwise + */ +int +pci_iommu_class_get(void *_mode); + #endif /* _PCI_PRIVATE_H_ */