From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 15AF1C406 for ; Tue, 30 Jun 2015 10:25:33 +0200 (CEST) Received: by pdcu2 with SMTP id u2so2161479pdc.3 for ; Tue, 30 Jun 2015 01:25:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0QeWQnjxFN97V6YO1Jerq69flgbskOVs97TokTnisik=; b=d25vYFUS+j4SGalZGiJGmKHV0Y3wBp+onUplakzNkO3XU3ZIehzdoZnqGbZ4aZ2Dm0 B1aeHO3Sf50+wRZOa5pwtB7IQAzUMUzREQ4yIJxetT9i1lbQdXKup9QysA/TL9oRmJ5d jD6Wf7wTw9KqNVSUq48s9GkdtmqenFl58S879Euv9AdjfCg+U1DHKlC4JRruPTil+sCP xgscnHj6ARKUdBYa6qtjcup6QtMcjDcjysaccpBHSexZ1KkM7Eqp7WvhBWkzapHYo91/ NsUKZTPNZWvdpb5NmTtuqYEF/pDYu1LTUo1GtEKlGer5R2vxI4m9HqC8ZtTRAVqzTtRY TplA== X-Gm-Message-State: ALoCoQl+1wdidCPMj/JEYmIqLcCjq4f9xU70g6p0JcmgIhIvaDvwMRMooHkkY8AhMGRONyv4n9Yv X-Received: by 10.66.142.199 with SMTP id ry7mr41130002pab.14.1435652732495; Tue, 30 Jun 2015 01:25:32 -0700 (PDT) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id k9sm44733339pdp.60.2015.06.30.01.25.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jun 2015 01:25:31 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 30 Jun 2015 17:24:27 +0900 Message-Id: <1435652668-3380-12-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435652668-3380-1-git-send-email-mukawa@igel.co.jp> References: <1435306705-11645-4-git-send-email-mukawa@igel.co.jp> <1435652668-3380-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v7 11/12] eal: Consolidate pci_map/unmap_device() of linuxapp and bsdapp X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2015 08:25:33 -0000 From: "Tetsuya.Mukawa" The patch consolidates below functions, and implemented in common eal code. - pci_map_device() - pci_unmap_device() Signed-off-by: Tetsuya Mukawa --- lib/librte_eal/bsdapp/eal/eal_pci.c | 3 ++ lib/librte_eal/common/eal_common_pci.c | 57 +++++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 19 +++++++++++ lib/librte_eal/common/include/rte_pci.h | 1 + lib/librte_eal/linuxapp/eal/eal_pci.c | 53 ------------------------------ lib/librte_ether/rte_ethdev.c | 1 + 6 files changed, 81 insertions(+), 53 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 329c268..c057f6a 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -238,6 +238,9 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) /* FreeBSD has no NUMA support (yet) */ dev->numa_node = 0; + /* FreeBSD has only one pass through driver */ + dev->kdrv = RTE_KDRV_NIC_UIO; + /* parse resources */ switch (conf->pc_hdr & PCIM_HDRTYPE) { case PCIM_HDRTYPE_NORMAL: diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 81b8fd6..c0be292 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -137,6 +137,63 @@ pci_unmap_resource(void *requested_addr, size_t size) requested_addr); } +/* Map pci device */ +int +pci_map_device(struct rte_pci_device *dev) +{ + int ret = -1; + + /* try mapping the NIC resources using VFIO if it exists */ + switch (dev->kdrv) { + case RTE_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_KDRV_NIC_UIO: + /* map resources for devices that use uio */ + ret = pci_uio_map_resource(dev); + break; + default: + RTE_LOG(DEBUG, EAL, " Not managed by a supported kernel driver," + " skipped\n"); + ret = 1; + break; + } + + return ret; +} + +#ifdef RTE_LIBRTE_EAL_HOTPLUG +/* Unmap pci device */ +void +pci_unmap_device(struct rte_pci_device *dev) +{ + if (dev == NULL) + return; + + /* try unmapping the NIC resources using VFIO if it exists */ + switch (dev->kdrv) { + case RTE_KDRV_VFIO: + RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n"); + break; + case RTE_KDRV_IGB_UIO: + case RTE_KDRV_UIO_GENERIC: + case RTE_KDRV_NIC_UIO: + /* unmap resources for devices that use uio */ + pci_uio_unmap_resource(dev); + break; + default: + RTE_LOG(DEBUG, EAL, " Not managed by a supported kernel driver," + " skipped\n"); + break; + } +} +#endif /* RTE_LIBRTE_EAL_HOTPLUG */ + /* * If vendor/device ID match, call the devinit() function of all * registered driver for the given device. Return -1 if initialization diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index c3a3fe4..eec396c 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -162,6 +162,25 @@ struct rte_pci_device; * @return * 0 on success, negative on error */ +int pci_map_device(struct rte_pci_device *dev); + +#ifdef RTE_LIBRTE_EAL_HOTPLUG +/** + * Unmap this device + * + * This function is private to EAL. + */ +void pci_unmap_device(struct rte_pci_device *dev); +#endif /* RTE_LIBRTE_EAL_HOTPLUG */ + +/** + * Map this device + * + * This function is private to EAL. + * + * @return + * 0 on success, negative on error + */ int pci_uio_map_resource(struct rte_pci_device *dev); #ifdef RTE_LIBRTE_EAL_HOTPLUG diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 56dcb46..475d2dc 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -148,6 +148,7 @@ enum rte_kernel_driver { RTE_KDRV_IGB_UIO, RTE_KDRV_VFIO, RTE_KDRV_UIO_GENERIC, + RTE_KDRV_NIC_UIO, }; /** diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index fc99eaa..7e8df7d 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -522,59 +522,6 @@ pci_config_space_set(struct rte_pci_device *dev) } #endif -static int -pci_map_device(struct rte_pci_device *dev) -{ - int ret = -1; - - /* try mapping the NIC resources using VFIO if it exists */ - switch (dev->kdrv) { - case RTE_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: - /* map resources for devices that use uio */ - ret = pci_uio_map_resource(dev); - break; - default: - RTE_LOG(DEBUG, EAL, " Not managed by a supported kernel driver," - " skipped\n"); - ret = 1; - break; - } - - return ret; -} - -#ifdef RTE_LIBRTE_EAL_HOTPLUG -static void -pci_unmap_device(struct rte_pci_device *dev) -{ - if (dev == NULL) - return; - - /* try unmapping the NIC resources using VFIO if it exists */ - switch (dev->kdrv) { - case RTE_KDRV_VFIO: - RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n"); - break; - case RTE_KDRV_IGB_UIO: - case RTE_KDRV_UIO_GENERIC: - /* unmap resources for devices that use uio */ - pci_uio_unmap_resource(dev); - break; - default: - RTE_LOG(DEBUG, EAL, " Not managed by a supported kernel driver," - " skipped\n"); - break; - } -} -#endif /* RTE_LIBRTE_EAL_HOTPLUG */ - /* * If vendor/device ID match, call the devinit() function of the * driver. diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 02cd07f..1822258 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -515,6 +515,7 @@ rte_eth_dev_is_detachable(uint8_t port_id) switch (rte_eth_devices[port_id].pci_dev->kdrv) { case RTE_KDRV_IGB_UIO: case RTE_KDRV_UIO_GENERIC: + case RTE_KDRV_NIC_UIO: break; case RTE_KDRV_VFIO: default: -- 2.1.4