From patchwork Mon Sep 14 08:17:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 77583 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ABA06A04C9; Mon, 14 Sep 2020 10:18:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 815FF2C36; Mon, 14 Sep 2020 10:18:02 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 3CBBA160 for ; Mon, 14 Sep 2020 10:18:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600071479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2PvzxxQhOcIfD0ZpsvnH73enWtBuR8pb3306L48y/nc=; b=WoOomW+bjxbLoMqbawmLLGqQD1VytmGkzQ9mZEKWqjrab1Y1Ev9x9cHNy8TWkhjLJuJd0L +andastJxVkx/fvzISdvqw9Ayy7ayZ8CguqMxEkDBcWvXB/Ve9Nelh3h3XpTXukhGCGNUV 6RcDBJ3qC7XwJwU9fgHE5RSDxa1nhrY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555-r31mHegvNY-0Ra9fovwUjA-1; Mon, 14 Sep 2020 04:17:55 -0400 X-MC-Unique: r31mHegvNY-0Ra9fovwUjA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 039A01007B00; Mon, 14 Sep 2020 08:17:53 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 758E375138; Mon, 14 Sep 2020 08:17:43 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ray Kinsella , Neil Horman , John McNamara , Marko Kovacevic , Ferruh Yigit , Ziyang Xuan , Xiaoyun Wang , Guoyang Zhou , "Wei Hu (Xavier)" , "Min Hu (Connor)" , Yisen Zhuang , Shijith Thotton , Srisivasubramanian Srinivasan , Heinrich Kuhn , Maxime Coquelin , Chenbo Xia , Zhihong Wang Date: Mon, 14 Sep 2020 10:17:23 +0200 Message-Id: <20200914081727.12215-2-david.marchand@redhat.com> In-Reply-To: <20200914081727.12215-1-david.marchand@redhat.com> References: <20200914081727.12215-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 1/5] bus/pci: switch to private kernel driver enum 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" The rte_kernel_driver enum actually only pointed at PCI drivers and is only used in the PCI subsystem. Remove it from the generic device API and use a private enum in the PCI code. Signed-off-by: David Marchand --- doc/guides/rel_notes/deprecation.rst | 4 -- doc/guides/rel_notes/release_20_11.rst | 3 ++ drivers/bus/pci/bsd/pci.c | 17 ++++--- drivers/bus/pci/linux/pci.c | 64 ++++++++++++------------- drivers/bus/pci/linux/pci_uio.c | 2 +- drivers/bus/pci/pci_common.c | 16 +++---- drivers/bus/pci/rte_bus_pci.h | 11 ++++- drivers/bus/pci/windows/pci.c | 6 +-- drivers/net/hinic/base/hinic_pmd_hwif.c | 2 +- drivers/net/hns3/hns3_ethdev_vf.c | 4 +- drivers/net/liquidio/lio_ethdev.c | 4 +- drivers/net/nfp/nfp_net.c | 2 +- drivers/net/virtio/virtio_pci.c | 2 +- lib/librte_eal/include/rte_dev.h | 12 ----- 14 files changed, 72 insertions(+), 77 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index f13248a0fe..d9357fa182 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -124,10 +124,6 @@ Deprecation Notices With this removal, there won't be a need for the mentioned workaround which will be reverted. -* pci: The ``rte_kernel_driver`` enum defined in rte_dev.h will be made private - to the PCI subsystem as it is used only by the PCI bus driver and PCI - drivers. - * mbuf: Some fields will be converted to dynamic API in DPDK 20.11 in order to reserve more space for the dynamic fields, as explained in `this presentation `_. diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index 442b201678..bffbe31947 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -87,6 +87,9 @@ API Changes * eal: The ``rte_logs`` struct and global symbol was made private and is no longer part of the API. +* pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and + replaced with a private enum in the PCI subsystem. + * ethdev: Removed the ``kdrv`` field in the ethdev ``rte_eth_dev_data`` structure as it gave no useful abstracted information to the applications. diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index 6ec27b4b5b..a07fc241fe 100644 --- a/drivers/bus/pci/bsd/pci.c +++ b/drivers/bus/pci/bsd/pci.c @@ -65,7 +65,7 @@ rte_pci_map_device(struct rte_pci_device *dev) /* try mapping the NIC resources */ switch (dev->kdrv) { - case RTE_KDRV_NIC_UIO: + case RTE_PCI_KDRV_NIC_UIO: /* map resources for devices that use uio */ ret = pci_uio_map_resource(dev); break; @@ -85,7 +85,7 @@ rte_pci_unmap_device(struct rte_pci_device *dev) { /* try unmapping the NIC resources */ switch (dev->kdrv) { - case RTE_KDRV_NIC_UIO: + case RTE_PCI_KDRV_NIC_UIO: /* unmap resources for devices that use uio */ pci_uio_unmap_resource(dev); break; @@ -255,7 +255,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) pci_name_set(dev); /* FreeBSD has only one pass through driver */ - dev->kdrv = RTE_KDRV_NIC_UIO; + dev->kdrv = RTE_PCI_KDRV_NIC_UIO; /* parse resources */ switch (conf->pc_hdr & PCIM_HDRTYPE) { @@ -395,8 +395,7 @@ enum rte_iova_mode pci_device_iova_mode(const struct rte_pci_driver *pdrv __rte_unused, const struct rte_pci_device *pdev) { - /* Supports only RTE_KDRV_NIC_UIO */ - if (pdev->kdrv != RTE_KDRV_NIC_UIO) + if (pdev->kdrv != RTE_PCI_KDRV_NIC_UIO) RTE_LOG(DEBUG, EAL, "Unsupported kernel driver? Defaulting to IOVA as 'PA'\n"); return RTE_IOVA_PA; @@ -548,7 +547,7 @@ rte_pci_ioport_map(struct rte_pci_device *dev, int bar, switch (dev->kdrv) { #if defined(RTE_ARCH_X86) - case RTE_KDRV_NIC_UIO: + case RTE_PCI_KDRV_NIC_UIO: if (rte_eal_iopl_init() != 0) { RTE_LOG(ERR, EAL, "%s(): insufficient ioport permissions for PCI device %s\n", __func__, dev->name); @@ -606,7 +605,7 @@ rte_pci_ioport_read(struct rte_pci_ioport *p, void *data, size_t len, off_t offset) { switch (p->dev->kdrv) { - case RTE_KDRV_NIC_UIO: + case RTE_PCI_KDRV_NIC_UIO: pci_uio_ioport_read(p, data, len, offset); break; default: @@ -648,7 +647,7 @@ rte_pci_ioport_write(struct rte_pci_ioport *p, const void *data, size_t len, off_t offset) { switch (p->dev->kdrv) { - case RTE_KDRV_NIC_UIO: + case RTE_PCI_KDRV_NIC_UIO: pci_uio_ioport_write(p, data, len, offset); break; default: @@ -663,7 +662,7 @@ rte_pci_ioport_unmap(struct rte_pci_ioport *p) switch (p->dev->kdrv) { #if defined(RTE_ARCH_X86) - case RTE_KDRV_NIC_UIO: + case RTE_PCI_KDRV_NIC_UIO: ret = 0; break; #endif diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index a2198abf43..bf275947f4 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -68,14 +68,14 @@ rte_pci_map_device(struct rte_pci_device *dev) /* try mapping the NIC resources using VFIO if it exists */ switch (dev->kdrv) { - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: #ifdef VFIO_PRESENT if (pci_vfio_is_enabled()) ret = pci_vfio_map_resource(dev); #endif break; - case RTE_KDRV_IGB_UIO: - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_IGB_UIO: + case RTE_PCI_KDRV_UIO_GENERIC: if (rte_eal_using_phys_addrs()) { /* map resources for devices that use uio */ ret = pci_uio_map_resource(dev); @@ -97,14 +97,14 @@ rte_pci_unmap_device(struct rte_pci_device *dev) { /* try unmapping the NIC resources using VFIO if it exists */ switch (dev->kdrv) { - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: #ifdef VFIO_PRESENT if (pci_vfio_is_enabled()) pci_vfio_unmap_resource(dev); #endif break; - case RTE_KDRV_IGB_UIO: - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_IGB_UIO: + case RTE_PCI_KDRV_UIO_GENERIC: /* unmap resources for devices that use uio */ pci_uio_unmap_resource(dev); break; @@ -323,15 +323,15 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) if (!ret) { if (!strcmp(driver, "vfio-pci")) - dev->kdrv = RTE_KDRV_VFIO; + dev->kdrv = RTE_PCI_KDRV_VFIO; else if (!strcmp(driver, "igb_uio")) - dev->kdrv = RTE_KDRV_IGB_UIO; + dev->kdrv = RTE_PCI_KDRV_IGB_UIO; else if (!strcmp(driver, "uio_pci_generic")) - dev->kdrv = RTE_KDRV_UIO_GENERIC; + dev->kdrv = RTE_PCI_KDRV_UIO_GENERIC; else - dev->kdrv = RTE_KDRV_UNKNOWN; + dev->kdrv = RTE_PCI_KDRV_UNKNOWN; } else { - dev->kdrv = RTE_KDRV_NONE; + dev->kdrv = RTE_PCI_KDRV_NONE; return 0; } /* device is valid, add in list (sorted) */ @@ -608,7 +608,7 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv, enum rte_iova_mode iova_mode = RTE_IOVA_DC; switch (pdev->kdrv) { - case RTE_KDRV_VFIO: { + case RTE_PCI_KDRV_VFIO: { #ifdef VFIO_PRESENT static int is_vfio_noiommu_enabled = -1; @@ -626,8 +626,8 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv, break; } - case RTE_KDRV_IGB_UIO: - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_IGB_UIO: + case RTE_PCI_KDRV_UIO_GENERIC: iova_mode = RTE_IOVA_PA; break; @@ -647,11 +647,11 @@ int rte_pci_read_config(const struct rte_pci_device *device, const struct rte_intr_handle *intr_handle = &device->intr_handle; switch (device->kdrv) { - case RTE_KDRV_IGB_UIO: - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_IGB_UIO: + case RTE_PCI_KDRV_UIO_GENERIC: return pci_uio_read_config(intr_handle, buf, len, offset); #ifdef VFIO_PRESENT - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: return pci_vfio_read_config(intr_handle, buf, len, offset); #endif default: @@ -671,11 +671,11 @@ int rte_pci_write_config(const struct rte_pci_device *device, const struct rte_intr_handle *intr_handle = &device->intr_handle; switch (device->kdrv) { - case RTE_KDRV_IGB_UIO: - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_IGB_UIO: + case RTE_PCI_KDRV_UIO_GENERIC: return pci_uio_write_config(intr_handle, buf, len, offset); #ifdef VFIO_PRESENT - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: return pci_vfio_write_config(intr_handle, buf, len, offset); #endif default: @@ -760,15 +760,15 @@ rte_pci_ioport_map(struct rte_pci_device *dev, int bar, switch (dev->kdrv) { #ifdef VFIO_PRESENT - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: if (pci_vfio_is_enabled()) ret = pci_vfio_ioport_map(dev, bar, p); break; #endif - case RTE_KDRV_IGB_UIO: + case RTE_PCI_KDRV_IGB_UIO: ret = pci_uio_ioport_map(dev, bar, p); break; - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_UIO_GENERIC: #if defined(RTE_ARCH_X86) ret = pci_ioport_map(dev, bar, p); #else @@ -791,14 +791,14 @@ rte_pci_ioport_read(struct rte_pci_ioport *p, { switch (p->dev->kdrv) { #ifdef VFIO_PRESENT - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: pci_vfio_ioport_read(p, data, len, offset); break; #endif - case RTE_KDRV_IGB_UIO: + case RTE_PCI_KDRV_IGB_UIO: pci_uio_ioport_read(p, data, len, offset); break; - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_UIO_GENERIC: pci_uio_ioport_read(p, data, len, offset); break; default: @@ -812,14 +812,14 @@ rte_pci_ioport_write(struct rte_pci_ioport *p, { switch (p->dev->kdrv) { #ifdef VFIO_PRESENT - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: pci_vfio_ioport_write(p, data, len, offset); break; #endif - case RTE_KDRV_IGB_UIO: + case RTE_PCI_KDRV_IGB_UIO: pci_uio_ioport_write(p, data, len, offset); break; - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_UIO_GENERIC: pci_uio_ioport_write(p, data, len, offset); break; default: @@ -834,15 +834,15 @@ rte_pci_ioport_unmap(struct rte_pci_ioport *p) switch (p->dev->kdrv) { #ifdef VFIO_PRESENT - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: if (pci_vfio_is_enabled()) ret = pci_vfio_ioport_unmap(p); break; #endif - case RTE_KDRV_IGB_UIO: + case RTE_PCI_KDRV_IGB_UIO: ret = pci_uio_ioport_unmap(p); break; - case RTE_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_UIO_GENERIC: #if defined(RTE_ARCH_X86) ret = 0; #else diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 097dc19225..a354920d5f 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -248,7 +248,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, goto error; } - if (dev->kdrv == RTE_KDRV_IGB_UIO) + if (dev->kdrv == RTE_PCI_KDRV_IGB_UIO) dev->intr_handle.type = RTE_INTR_HANDLE_UIO; else { dev->intr_handle.type = RTE_INTR_HANDLE_UIO_INTX; diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index a8e5fd52c1..dddf2b2aad 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -465,7 +465,7 @@ pci_hot_unplug_handler(struct rte_device *dev) switch (pdev->kdrv) { #ifdef HAVE_VFIO_DEV_REQ_INTERFACE - case RTE_KDRV_VFIO: + case RTE_PCI_KDRV_VFIO: /* * vfio kernel module guaranty the pci device would not be * deleted until the user space release the resource, so no @@ -476,9 +476,9 @@ pci_hot_unplug_handler(struct rte_device *dev) RTE_DEV_EVENT_REMOVE); break; #endif - case RTE_KDRV_IGB_UIO: - case RTE_KDRV_UIO_GENERIC: - case RTE_KDRV_NIC_UIO: + case RTE_PCI_KDRV_IGB_UIO: + case RTE_PCI_KDRV_UIO_GENERIC: + case RTE_PCI_KDRV_NIC_UIO: /* BARs resource is invalid, remap it to be safe. */ ret = pci_uio_remap_resource(pdev); break; @@ -552,7 +552,7 @@ pci_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) * In case driver don't provides any specific mapping * try fallback to VFIO. */ - if (pdev->kdrv == RTE_KDRV_VFIO) + if (pdev->kdrv == RTE_PCI_KDRV_VFIO) return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD, (uintptr_t)addr, iova, len); @@ -575,7 +575,7 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) * In case driver don't provides any specific mapping * try fallback to VFIO. */ - if (pdev->kdrv == RTE_KDRV_VFIO) + if (pdev->kdrv == RTE_PCI_KDRV_VFIO) return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD, (uintptr_t)addr, iova, len); @@ -622,8 +622,8 @@ rte_pci_get_iommu_class(void) iommu_no_va = pci_device_iommu_support_va(dev) ? 0 : 1; - if (dev->kdrv == RTE_KDRV_UNKNOWN || - dev->kdrv == RTE_KDRV_NONE) + if (dev->kdrv == RTE_PCI_KDRV_UNKNOWN || + dev->kdrv == RTE_PCI_KDRV_NONE) continue; FOREACH_DRIVER_ON_PCIBUS(drv) { enum rte_iova_mode dev_iova_mode; diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index 29bea6d70d..ff6f072470 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -51,6 +51,15 @@ TAILQ_HEAD(rte_pci_driver_list, rte_pci_driver); struct rte_devargs; +enum rte_pci_kernel_driver { + RTE_PCI_KDRV_UNKNOWN = 0, + RTE_PCI_KDRV_IGB_UIO, + RTE_PCI_KDRV_VFIO, + RTE_PCI_KDRV_UIO_GENERIC, + RTE_PCI_KDRV_NIC_UIO, + RTE_PCI_KDRV_NONE, +}; + /** * A structure describing a PCI device. */ @@ -64,7 +73,7 @@ struct rte_pci_device { struct rte_intr_handle intr_handle; /**< Interrupt handle */ struct rte_pci_driver *driver; /**< PCI driver used in probing */ uint16_t max_vfs; /**< sriov enable if not zero */ - enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */ + enum rte_pci_kernel_driver kdrv; /**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE+1]; /**< PCI location (ASCII) */ struct rte_intr_handle vfio_req_intr_handle; /**< Handler of VFIO request interrupt */ diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c index c80bd55716..9e5c8fafb0 100644 --- a/drivers/bus/pci/windows/pci.c +++ b/drivers/bus/pci/windows/pci.c @@ -211,7 +211,7 @@ get_device_resource_info(HDEVINFO dev_info, BOOL res; switch (dev->kdrv) { - case RTE_KDRV_NONE: + case RTE_PCI_KDRV_NONE: /* Get NUMA node using DEVPKEY_Device_Numa_Node */ res = SetupDiGetDevicePropertyW(dev_info, dev_info_data, &DEVPKEY_Device_Numa_Node, &property_type, @@ -223,7 +223,7 @@ get_device_resource_info(HDEVINFO dev_info, return -1; } dev->device.numa_node = numa_node; - /* mem_resource - Unneeded for RTE_KDRV_NONE */ + /* mem_resource - Unneeded for RTE_PCI_KDRV_NONE */ dev->mem_resource[0].phys_addr = 0; dev->mem_resource[0].len = 0; dev->mem_resource[0].addr = NULL; @@ -292,7 +292,7 @@ get_kernel_driver_type(struct rte_pci_device *dev) * If another kernel driver is supported the relevant checking * functions should be here */ - dev->kdrv = RTE_KDRV_NONE; + dev->kdrv = RTE_PCI_KDRV_NONE; } static int diff --git a/drivers/net/hinic/base/hinic_pmd_hwif.c b/drivers/net/hinic/base/hinic_pmd_hwif.c index d7fc1af707..26fa1e27d4 100644 --- a/drivers/net/hinic/base/hinic_pmd_hwif.c +++ b/drivers/net/hinic/base/hinic_pmd_hwif.c @@ -280,7 +280,7 @@ void hinic_set_msix_state(void *hwdev, u16 msix_idx, enum hinic_msix_state flag) /* vfio-pci does not mmap msi-x vector table to user space, * we can not access the space when kernel driver is vfio-pci */ - if (hw->pcidev_hdl->kdrv == RTE_KDRV_VFIO) + if (hw->pcidev_hdl->kdrv == RTE_PCI_KDRV_VFIO) return; mask_bits = readl(hwif->intr_regs_base + offset); diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 1d2941f0e3..63089d0bd4 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2425,8 +2425,8 @@ hns3vf_reinit_dev(struct hns3_adapter *hns) * UIO enables msix by writing the pcie configuration space * vfio_pci enables msix in rte_intr_enable. */ - if (pci_dev->kdrv == RTE_KDRV_IGB_UIO || - pci_dev->kdrv == RTE_KDRV_UIO_GENERIC) { + if (pci_dev->kdrv == RTE_PCI_KDRV_IGB_UIO || + pci_dev->kdrv == RTE_PCI_KDRV_UIO_GENERIC) { if (hns3vf_enable_msix(pci_dev, true)) hns3_err(hw, "Failed to enable msix"); } diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 2258838c4c..2c2b27e62a 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -1563,7 +1563,7 @@ lio_dev_close(struct rte_eth_dev *eth_dev) /* Reset ioq regs */ lio_dev->fn_list.setup_device_regs(lio_dev); - if (lio_dev->pci_dev->kdrv == RTE_KDRV_IGB_UIO) { + if (lio_dev->pci_dev->kdrv == RTE_PCI_KDRV_IGB_UIO) { cn23xx_vf_ask_pf_to_do_flr(lio_dev); rte_delay_ms(LIO_PCI_FLR_WAIT); } @@ -2012,7 +2012,7 @@ lio_first_time_init(struct lio_device *lio_dev, goto error; /* Request and wait for device reset. */ - if (pdev->kdrv == RTE_KDRV_IGB_UIO) { + if (pdev->kdrv == RTE_PCI_KDRV_IGB_UIO) { cn23xx_vf_ask_pf_to_do_flr(lio_dev); /* FLR wait time doubled as a precaution. */ rte_delay_ms(LIO_PCI_FLR_WAIT * 2); diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 99946279db..1cf949a9ab 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -3614,7 +3614,7 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, * interface. Here we avoid this telling to the CPP init code to * use a lock file if UIO is being used. */ - if (dev->kdrv == RTE_KDRV_VFIO) + if (dev->kdrv == RTE_PCI_KDRV_VFIO) cpp = nfp_cpp_from_device_name(dev, 0); else cpp = nfp_cpp_from_device_name(dev, 1); diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 29a354bf76..9915eabf68 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -704,7 +704,7 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw) PMD_INIT_LOG(INFO, "trying with legacy virtio pci."); if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) { rte_pci_unmap_device(dev); - if (dev->kdrv == RTE_KDRV_UNKNOWN && + if (dev->kdrv == RTE_PCI_KDRV_UNKNOWN && (!dev->device.devargs || dev->device.devargs->bus != rte_bus_find_by_name("pci"))) { diff --git a/lib/librte_eal/include/rte_dev.h b/lib/librte_eal/include/rte_dev.h index c8d985fb5c..53c8bc6fab 100644 --- a/lib/librte_eal/include/rte_dev.h +++ b/lib/librte_eal/include/rte_dev.h @@ -54,18 +54,6 @@ typedef void (*rte_dev_event_cb_fn)(const char *device_name, return; \ } while (0) -/** - * Device driver. - */ -enum rte_kernel_driver { - RTE_KDRV_UNKNOWN = 0, - RTE_KDRV_IGB_UIO, - RTE_KDRV_VFIO, - RTE_KDRV_UIO_GENERIC, - RTE_KDRV_NIC_UIO, - RTE_KDRV_NONE, -}; - /** * Device policies. */ From patchwork Mon Sep 14 08:17:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 77584 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB3A9A04C9; Mon, 14 Sep 2020 10:18:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C5511C0D8; Mon, 14 Sep 2020 10:18:06 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 215291C0DC for ; Mon, 14 Sep 2020 10:18:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600071484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JvCInaX7nJAH1TkFjHJ26d2h8myCHL2pjCawv4LrAqg=; b=IfGrBgIKmwmuILceC4h2yvsaulYWJUmlWQ4PdSzXrcTJukmo0J0lgmN139bvMvA96xz7cl U5elJtj1ThhPyQljNcbUfFY9bim98heXf2FnZYBTg6f57/yihvXY0I9VkEnwM3YkyplaZ+ VKGxl4TgBv5qmvlxMuY8zsslnRAU2ow= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-EULEa7HXMoGPB1cQzdANRg-1; Mon, 14 Sep 2020 04:17:59 -0400 X-MC-Unique: EULEa7HXMoGPB1cQzdANRg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A18E18B9F8E; Mon, 14 Sep 2020 08:17:58 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5214375120; Mon, 14 Sep 2020 08:17:55 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ray Kinsella , Neil Horman , John McNamara , Marko Kovacevic , Ferruh Yigit , Gaetan Rivet Date: Mon, 14 Sep 2020 10:17:24 +0200 Message-Id: <20200914081727.12215-3-david.marchand@redhat.com> In-Reply-To: <20200914081727.12215-1-david.marchand@redhat.com> References: <20200914081727.12215-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 2/5] pci: move resource mapping to the PCI bus 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" As reported during 20.08 work for Windows, the pci_map_resource API was built with the assumption that its flags would be passed to mmap(). This introduced a regression when adding the rte_mem_map API as reported in the workaround commit 9d2b24593724 ("pci: keep API compatibility with mmap values"). This API was only used in the PCI bus code, so move it there. With this move, there is no other user so no ambiguity anymore: the passed additional flags are documented as rte_mem_map API flags. Signed-off-by: David Marchand --- doc/guides/rel_notes/deprecation.rst | 11 ----- doc/guides/rel_notes/release_20_11.rst | 6 +++ drivers/bus/pci/linux/pci_init.h | 2 + drivers/bus/pci/linux/pci_uio.c | 1 + drivers/bus/pci/pci_common.c | 41 ++++++++++++++++ drivers/bus/pci/private.h | 66 ++++++++++++++++++++++++++ lib/librte_pci/rte_pci.c | 42 ---------------- lib/librte_pci/rte_pci.h | 66 -------------------------- lib/librte_pci/rte_pci_version.map | 2 - 9 files changed, 116 insertions(+), 121 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index d9357fa182..2c7ae1f51e 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -113,17 +113,6 @@ Deprecation Notices us extending existing enum/define. One solution can be using a fixed size array instead of ``.*MAX.*`` value. -* pci: The PCI resources map API (``pci_map_resource`` and - ``pci_unmap_resource``) was not abstracting the Unix mmap flags (see the - workaround for Windows support implemented in the commit - 9d2b24593724 ("pci: keep API compatibility with mmap values")). - This API will be removed from the public API in 20.11 and moved to the PCI - bus driver along with the PCI resources lists and associated structures - (``pci_map``, ``pci_msix_table``, ``mapped_pci_resource`` and - ``mapped_pci_res_list``). - With this removal, there won't be a need for the mentioned workaround which - will be reverted. - * mbuf: Some fields will be converted to dynamic API in DPDK 20.11 in order to reserve more space for the dynamic fields, as explained in `this presentation `_. diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index bffbe31947..0f6a557501 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -90,6 +90,12 @@ API Changes * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem. +* pci: Removed the PCI resources map API from the public API + (``pci_map_resource`` and ``pci_unmap_resource``) and moved it to the + PCI bus driver along with the PCI resources lists and associated structures + (``pci_map``, ``pci_msix_table``, ``mapped_pci_resource`` and + ``mapped_pci_res_list``). + * ethdev: Removed the ``kdrv`` field in the ethdev ``rte_eth_dev_data`` structure as it gave no useful abstracted information to the applications. diff --git a/drivers/bus/pci/linux/pci_init.h b/drivers/bus/pci/linux/pci_init.h index c2e603a374..dcea726186 100644 --- a/drivers/bus/pci/linux/pci_init.h +++ b/drivers/bus/pci/linux/pci_init.h @@ -7,6 +7,8 @@ #include +#include "private.h" + /** IO resource type: */ #define IORESOURCE_IO 0x00000100 #define IORESOURCE_MEM 0x00000200 diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index a354920d5f..9ab20a0b25 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -25,6 +25,7 @@ #include "eal_filesystem.h" #include "pci_init.h" +#include "private.h" void *pci_map_addr = NULL; diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index dddf2b2aad..3a2ae07958 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,46 @@ pci_name_set(struct rte_pci_device *dev) dev->device.name = dev->name; } +/* map a particular resource from a file */ +void * +pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, + int additional_flags) +{ + void *mapaddr; + + /* Map the PCI memory resource of device */ + mapaddr = rte_mem_map(requested_addr, size, + RTE_PROT_READ | RTE_PROT_WRITE, + RTE_MAP_SHARED | additional_flags, fd, offset); + if (mapaddr == NULL) { + RTE_LOG(ERR, EAL, + "%s(): cannot map resource(%d, %p, 0x%zx, 0x%llx): %s (%p)\n", + __func__, fd, requested_addr, size, + (unsigned long long)offset, + rte_strerror(rte_errno), mapaddr); + mapaddr = MAP_FAILED; /* API uses mmap error code */ + } else + RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr); + + return mapaddr; +} + +/* unmap a particular resource */ +void +pci_unmap_resource(void *requested_addr, size_t size) +{ + if (requested_addr == NULL) + return; + + /* Unmap the PCI memory resource of device */ + if (rte_mem_unmap(requested_addr, size)) { + RTE_LOG(ERR, EAL, "%s(): cannot mem unmap(%p, %#zx): %s\n", + __func__, requested_addr, size, + rte_strerror(rte_errno)); + } else + RTE_LOG(DEBUG, EAL, " PCI memory unmapped at %p\n", + requested_addr); +} /* * Match the PCI Driver and Device using the ID Table */ diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index 367cdd9a65..9617268024 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -81,6 +81,72 @@ void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev, */ int pci_update_device(const struct rte_pci_addr *addr); +/** + * A structure describing a PCI mapping. + */ +struct pci_map { + void *addr; + char *path; + uint64_t offset; + uint64_t size; + uint64_t phaddr; +}; + +struct pci_msix_table { + int bar_index; + uint32_t offset; + uint32_t size; +}; + +/** + * A structure describing a mapped PCI resource. + * For multi-process we need to reproduce all PCI mappings in secondary + * processes, so save them in a tailq. + */ +struct mapped_pci_resource { + TAILQ_ENTRY(mapped_pci_resource) next; + + struct rte_pci_addr pci_addr; + char path[PATH_MAX]; + int nb_maps; + struct pci_map maps[PCI_MAX_RESOURCE]; + struct pci_msix_table msix_table; +}; + + +/** mapped pci device list */ +TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource); + +/** + * Map a particular resource from a file. + * + * @param requested_addr + * The starting address for the new mapping range. + * @param fd + * The file descriptor. + * @param offset + * The offset for the mapping range. + * @param size + * The size for the mapping range. + * @param additional_flags + * The additional rte_mem_map() flags for the mapping range. + * @return + * - On success, the function returns a pointer to the mapped area. + * - On error, MAP_FAILED is returned. + */ +void *pci_map_resource(void *requested_addr, int fd, off_t offset, + size_t size, int additional_flags); + +/** + * Unmap a particular resource. + * + * @param requested_addr + * The address for the unmapping range. + * @param size + * The size for the unmapping range. + */ +void pci_unmap_resource(void *requested_addr, size_t size); + /** * Map the PCI resource of a PCI device in virtual memory * diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c index 1d1cbc75ac..c91be8b167 100644 --- a/lib/librte_pci/rte_pci.c +++ b/lib/librte_pci/rte_pci.c @@ -144,45 +144,3 @@ rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr) return 0; return -1; } - - -/* map a particular resource from a file */ -void * -pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, - int additional_flags) -{ - void *mapaddr; - - /* Map the PCI memory resource of device */ - mapaddr = rte_mem_map(requested_addr, size, - RTE_PROT_READ | RTE_PROT_WRITE, - RTE_MAP_SHARED | additional_flags, fd, offset); - if (mapaddr == NULL) { - RTE_LOG(ERR, EAL, - "%s(): cannot map resource(%d, %p, 0x%zx, 0x%llx): %s (%p)\n", - __func__, fd, requested_addr, size, - (unsigned long long)offset, - rte_strerror(rte_errno), mapaddr); - mapaddr = MAP_FAILED; /* API uses mmap error code */ - } else - RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr); - - return mapaddr; -} - -/* unmap a particular resource */ -void -pci_unmap_resource(void *requested_addr, size_t size) -{ - if (requested_addr == NULL) - return; - - /* Unmap the PCI memory resource of device */ - if (rte_mem_unmap(requested_addr, size)) { - RTE_LOG(ERR, EAL, "%s(): cannot mem unmap(%p, %#zx): %s\n", - __func__, requested_addr, size, - rte_strerror(rte_errno)); - } else - RTE_LOG(DEBUG, EAL, " PCI memory unmapped at %p\n", - requested_addr); -} diff --git a/lib/librte_pci/rte_pci.h b/lib/librte_pci/rte_pci.h index a03235da1f..567c8cd68d 100644 --- a/lib/librte_pci/rte_pci.h +++ b/lib/librte_pci/rte_pci.h @@ -64,42 +64,6 @@ struct rte_pci_addr { #define PCI_ANY_ID (0xffff) #define RTE_CLASS_ANY_ID (0xffffff) -/** - * A structure describing a PCI mapping. - */ -struct pci_map { - void *addr; - char *path; - uint64_t offset; - uint64_t size; - uint64_t phaddr; -}; - -struct pci_msix_table { - int bar_index; - uint32_t offset; - uint32_t size; -}; - -/** - * A structure describing a mapped PCI resource. - * For multi-process we need to reproduce all PCI mappings in secondary - * processes, so save them in a tailq. - */ -struct mapped_pci_resource { - TAILQ_ENTRY(mapped_pci_resource) next; - - struct rte_pci_addr pci_addr; - char path[PATH_MAX]; - int nb_maps; - struct pci_map maps[PCI_MAX_RESOURCE]; - struct pci_msix_table msix_table; -}; - - -/** mapped pci device list */ -TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource); - /** * Utility function to write a pci device name, this device name can later be * used to retrieve the corresponding rte_pci_addr using eal_parse_pci_* @@ -145,36 +109,6 @@ int rte_pci_addr_cmp(const struct rte_pci_addr *addr, */ int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr); -/** - * Map a particular resource from a file. - * - * @param requested_addr - * The starting address for the new mapping range. - * @param fd - * The file descriptor. - * @param offset - * The offset for the mapping range. - * @param size - * The size for the mapping range. - * @param additional_flags - * The additional flags for the mapping range. - * @return - * - On success, the function returns a pointer to the mapped area. - * - On error, MAP_FAILED is returned. - */ -void *pci_map_resource(void *requested_addr, int fd, off_t offset, - size_t size, int additional_flags); - -/** - * Unmap a particular resource. - * - * @param requested_addr - * The address for the unmapping range. - * @param size - * The size for the unmapping range. - */ -void pci_unmap_resource(void *requested_addr, size_t size); - #ifdef __cplusplus } #endif diff --git a/lib/librte_pci/rte_pci_version.map b/lib/librte_pci/rte_pci_version.map index cd77c9dc9e..1db19a5122 100644 --- a/lib/librte_pci/rte_pci_version.map +++ b/lib/librte_pci/rte_pci_version.map @@ -1,8 +1,6 @@ DPDK_21 { global: - pci_map_resource; - pci_unmap_resource; rte_pci_addr_cmp; rte_pci_addr_parse; rte_pci_device_name; From patchwork Mon Sep 14 08:17:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 77585 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5932BA04C9; Mon, 14 Sep 2020 10:18:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 694E61C10F; Mon, 14 Sep 2020 10:18:09 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 4E98B1C10D for ; Mon, 14 Sep 2020 10:18:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600071486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=04AkxNZqwp5rIP3kc+v/jKT5RnkE9K0ua857j0hJm6c=; b=L01m7J37rhwDJBoVp04FqRrIdXPx4kIuhygyZgMI91447rVsY4dBO2ggQKqQtC61hBenP7 uJDqDXre2z3EsfuUlZrPPhlF/qJ50tI49SnVIV6RLBUhyA3RREqnBF9JYbGwS6cuIdv2wx XItPJStK59+l4YzemWmY5j1RsHbWmUQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-D_a1IzQmObi-fhJi3qUUmg-1; Mon, 14 Sep 2020 04:18:04 -0400 X-MC-Unique: D_a1IzQmObi-fhJi3qUUmg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7306356B2A; Mon, 14 Sep 2020 08:18:03 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6FDB75120; Mon, 14 Sep 2020 08:18:00 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Anatoly Burakov , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Mon, 14 Sep 2020 10:17:25 +0200 Message-Id: <20200914081727.12215-4-david.marchand@redhat.com> In-Reply-To: <20200914081727.12215-1-david.marchand@redhat.com> References: <20200914081727.12215-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 3/5] mem: drop mapping API workaround 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" Now that the pci_map_resource API is private to the PCI bus, we can drop the compatibility workaround we had implemented in 20.08. Signed-off-by: David Marchand --- drivers/bus/pci/bsd/pci.c | 2 +- drivers/bus/pci/linux/pci_uio.c | 2 +- drivers/bus/pci/linux/pci_vfio.c | 4 ++-- drivers/bus/pci/pci_common.c | 1 - drivers/bus/pci/pci_common_uio.c | 2 +- drivers/bus/pci/private.h | 2 +- lib/librte_eal/include/rte_eal_paging.h | 10 ---------- lib/librte_eal/windows/include/rte_os.h | 6 ------ 8 files changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index a07fc241fe..2ed8261349 100644 --- a/drivers/bus/pci/bsd/pci.c +++ b/drivers/bus/pci/bsd/pci.c @@ -192,7 +192,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, mapaddr = pci_map_resource(NULL, fd, (off_t)offset, (size_t)dev->mem_resource[res_idx].len, 0); close(fd); - if (mapaddr == MAP_FAILED) + if (mapaddr == NULL) goto error; maps[map_idx].phaddr = dev->mem_resource[res_idx].phys_addr; diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 9ab20a0b25..f3305a2f28 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -346,7 +346,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, mapaddr = pci_map_resource(pci_map_addr, fd, 0, (size_t)dev->mem_resource[res_idx].len, 0); close(fd); - if (mapaddr == MAP_FAILED) + if (mapaddr == NULL) goto error; pci_map_addr = RTE_PTR_ADD(mapaddr, diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index c15ed3bade..34b5da80df 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -565,7 +565,7 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res, } /* if there's a second part, try to map it */ - if (map_addr != MAP_FAILED + if (map_addr != NULL && memreg[1].offset && memreg[1].size) { void *second_addr = RTE_PTR_ADD(bar_addr, (uintptr_t)(memreg[1].offset - @@ -577,7 +577,7 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res, RTE_MAP_FORCE_ADDRESS); } - if (map_addr == NULL || map_addr == MAP_FAILED) { + if (map_addr == NULL) { munmap(bar_addr, bar->size); bar_addr = MAP_FAILED; RTE_LOG(ERR, EAL, "Failed to map pci BAR%d\n", diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 3a2ae07958..62d45041bb 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -97,7 +97,6 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, __func__, fd, requested_addr, size, (unsigned long long)offset, rte_strerror(rte_errno), mapaddr); - mapaddr = MAP_FAILED; /* API uses mmap error code */ } else RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr); diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c index f4dca9da91..793dfd0a7c 100644 --- a/drivers/bus/pci/pci_common_uio.c +++ b/drivers/bus/pci/pci_common_uio.c @@ -58,7 +58,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev) "Cannot mmap device resource file %s to address: %p\n", uio_res->maps[i].path, uio_res->maps[i].addr); - if (mapaddr != MAP_FAILED) { + if (mapaddr != NULL) { /* unmap addrs correctly mapped */ for (j = 0; j < i; j++) pci_unmap_resource( diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index 9617268024..530123767b 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -132,7 +132,7 @@ TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource); * The additional rte_mem_map() flags for the mapping range. * @return * - On success, the function returns a pointer to the mapped area. - * - On error, MAP_FAILED is returned. + * - On error, NULL is returned. */ void *pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, int additional_flags); diff --git a/lib/librte_eal/include/rte_eal_paging.h b/lib/librte_eal/include/rte_eal_paging.h index 429f896c8c..ed98e70e9e 100644 --- a/lib/librte_eal/include/rte_eal_paging.h +++ b/lib/librte_eal/include/rte_eal_paging.h @@ -3,9 +3,6 @@ */ #include -#ifndef RTE_EXEC_ENV_WINDOWS -#include -#endif #include @@ -25,7 +22,6 @@ enum rte_mem_prot { /** Additional flags for memory mapping. */ enum rte_map_flags { -#ifdef RTE_EXEC_ENV_WINDOWS /** Changes to the mapped memory are visible to other processes. */ RTE_MAP_SHARED = 1 << 0, /** Mapping is not backed by a regular file. */ @@ -39,12 +35,6 @@ enum rte_map_flags { * it is not required to do so, thus mapping with this flag may fail. */ RTE_MAP_FORCE_ADDRESS = 1 << 3 -#else /* map mmap flags because they are exposed in pci_map_resource() API */ - RTE_MAP_SHARED = MAP_SHARED, - RTE_MAP_ANONYMOUS = MAP_ANONYMOUS, - RTE_MAP_PRIVATE = MAP_PRIVATE, - RTE_MAP_FORCE_ADDRESS = MAP_FIXED, -#endif }; /** diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h index 2881bf2224..569ed92d51 100644 --- a/lib/librte_eal/windows/include/rte_os.h +++ b/lib/librte_eal/windows/include/rte_os.h @@ -25,12 +25,6 @@ extern "C" { #define PATH_MAX _MAX_PATH #endif -/* sys/mman.h - * The syscall mmap does not exist on Windows, - * but this error code is used in a badly defined DPDK API for PCI mapping. - */ -#define MAP_FAILED ((void *) -1) - #define sleep(x) Sleep(1000 * (x)) #define strerror_r(a, b, c) strerror_s(b, c, a) From patchwork Mon Sep 14 08:17:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 77586 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E999A04C9; Mon, 14 Sep 2020 10:18:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B0F4C1C0D7; Mon, 14 Sep 2020 10:18:15 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 5BB491C0D7 for ; Mon, 14 Sep 2020 10:18:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600071493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QB43mvOIVZ4dqvl75WQZrX68LpBwqrwAzJXfX4CoVwM=; b=ILZTi8l3uRKXsLB6pWG3+Kr6LLEYdMdOK98TSSdnqObDmQl89+xnQ6JdOvaWLTIhZwU/DR HaSLmM58hodkqg6cifv4gQqKgR73WlkH9E/f8cZwzQZcbAoGAG78UXjbEHVV+dWRhRKqb6 a3OJD2aOBBILLU6ID43mvk+wDmh+1NU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-ycjEYEiUO5m4EARdH9sZBg-1; Mon, 14 Sep 2020 04:18:10 -0400 X-MC-Unique: ycjEYEiUO5m4EARdH9sZBg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9C021007B00; Mon, 14 Sep 2020 08:18:08 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD1BE75138; Mon, 14 Sep 2020 08:18:05 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ray Kinsella , Neil Horman , John McNamara , Marko Kovacevic , Jianfeng Tan , Jeff Guo Date: Mon, 14 Sep 2020 10:17:26 +0200 Message-Id: <20200914081727.12215-5-david.marchand@redhat.com> In-Reply-To: <20200914081727.12215-1-david.marchand@redhat.com> References: <20200914081727.12215-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 4/5] eal: hide internal device event structure 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" This structure is not used in the public API. Fixes: a753e53d517b ("eal: add device event monitor framework") Signed-off-by: David Marchand --- doc/guides/rel_notes/deprecation.rst | 3 --- doc/guides/rel_notes/release_20_11.rst | 3 +++ lib/librte_eal/include/rte_dev.h | 6 ------ lib/librte_eal/linux/eal_dev.c | 6 ++++++ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 2c7ae1f51e..3bd3abd7f8 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -70,9 +70,6 @@ Deprecation Notices * eal: The function ``rte_eal_remote_launch`` will return new error codes after read or write error on the pipe, instead of calling ``rte_panic``. -* eal: The ``rte_dev_event`` structure will be made private to the EAL as no - public API makes use of it. - * rte_atomicNN_xxx: These APIs do not take memory order parameter. This does not allow for writing optimized code for all the CPU architectures supported in DPDK. DPDK will adopt C11 atomic operations semantics and provide wrappers diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index 0f6a557501..8397046988 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -87,6 +87,9 @@ API Changes * eal: The ``rte_logs`` struct and global symbol was made private and is no longer part of the API. +* eal: Made the ``rte_dev_event`` structure private to the EAL as no public API + used it. + * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and replaced with a private enum in the PCI subsystem. diff --git a/lib/librte_eal/include/rte_dev.h b/lib/librte_eal/include/rte_dev.h index 53c8bc6fab..81905b3ae3 100644 --- a/lib/librte_eal/include/rte_dev.h +++ b/lib/librte_eal/include/rte_dev.h @@ -33,12 +33,6 @@ enum rte_dev_event_type { RTE_DEV_EVENT_MAX /**< max value of this enum */ }; -struct rte_dev_event { - enum rte_dev_event_type type; /**< device event type */ - int subsystem; /**< subsystem id */ - char *devname; /**< device name */ -}; - typedef void (*rte_dev_event_cb_fn)(const char *device_name, enum rte_dev_event_type event, void *cb_arg); diff --git a/lib/librte_eal/linux/eal_dev.c b/lib/librte_eal/linux/eal_dev.c index 83c9cd6607..c8dd77c049 100644 --- a/lib/librte_eal/linux/eal_dev.c +++ b/lib/librte_eal/linux/eal_dev.c @@ -133,6 +133,12 @@ dev_uev_socket_fd_create(void) return ret; } +struct rte_dev_event { + enum rte_dev_event_type type; /**< device event type */ + int subsystem; /**< subsystem id */ + char *devname; /**< device name */ +}; + static int dev_uev_parse(const char *buf, struct rte_dev_event *event, int length) { From patchwork Mon Sep 14 08:17:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 77587 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C11BA04C9; Mon, 14 Sep 2020 10:18:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0A2AC1C11B; Mon, 14 Sep 2020 10:18:21 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id C94541C119 for ; Mon, 14 Sep 2020 10:18:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600071499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kArIWgo//OD5CeYHDmEhGI/pkU9OBaSGT5NXQLamPoc=; b=LEefXw1F8/zmNCeK/uMPQZx+2WtoEmDZJfZDMCMtK7MDG5lgT2hOszC0+wS9OrGebCxljV xYJod5oHGmbCcUuAW+XwoQ7BU7mgbOUPKtg+6izYM5EP7W1XZ/FCXCRN12tJTI7cyDkIVz XLmUSLsTDim9W0PZzrhq3OJMMNPNovw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-444-916a3RL2MJuLoiwN0roBtA-1; Mon, 14 Sep 2020 04:18:17 -0400 X-MC-Unique: 916a3RL2MJuLoiwN0roBtA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 123ED56B2A; Mon, 14 Sep 2020 08:18:16 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA0257512C; Mon, 14 Sep 2020 08:18:13 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Stephen Hemminger , Gaetan Rivet , Thomas Monjalon Date: Mon, 14 Sep 2020 10:17:27 +0200 Message-Id: <20200914081727.12215-6-david.marchand@redhat.com> In-Reply-To: <20200914081727.12215-1-david.marchand@redhat.com> References: <20200914081727.12215-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 5/5] bus/pci: remove duplicate declaration 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" This declaration is the same as the one a few lines before. Fixes: 6844d146ff39 ("eal: add bus pointer in device structure") Cc: stable@dpdk.org Signed-off-by: David Marchand --- drivers/bus/pci/private.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index 530123767b..9aa7e67c73 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -15,8 +15,6 @@ extern struct rte_pci_bus rte_pci_bus; struct rte_pci_driver; struct rte_pci_device; -extern struct rte_pci_bus rte_pci_bus; - /** * Scan the content of the PCI bus, and the devices in the devices * list