From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by dpdk.org (Postfix) with ESMTP id 57C85C36E for ; Wed, 8 Jul 2015 12:36:01 +0200 (CEST) Received: by pdrg1 with SMTP id g1so12214060pdr.2 for ; Wed, 08 Jul 2015 03:36:00 -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=OvJ9C6s9/f9+2/oEDWpxLqgMMDJKTpJPfmoU5S+66bM=; b=kyNlJ55kcgclaTObhonlEx7rmuTOPO5WMktnUQnxeByg3hZ7mpFCOmIZ13kRi8vgBe lO52nZIWz2QgNF7dDaBiiKCjW52nyU1z4ExNneh9LyaOOIhaz0GhXGGT7+TCtP6uwRQX V4PYGLUGvYt52BAM08jkTwpylhqO+l4Pj9+Izh6DwOuAO7CZGIU/5cmXZrw1m2dz+duk ocP27K3zq5yt9QbrfskhMtNprjRFyvRLDW38WQHxNgmhbWHA95rEeAOcK3KNtW5FXo73 dSDwIBEbvujUSoMO4yXAWf7ivjRsVE2dsr63t/1aRAeoSQfCs6yrDKVaSr3h0QqNIMQE 8N7g== X-Gm-Message-State: ALoCoQmQbXOAv0x3VcwggfPBUs96WHGGny9Vl4JaG6bV1YrgySopdl6xadqvH6RrNFLPOXU/TqsZ X-Received: by 10.70.42.101 with SMTP id n5mr19330067pdl.93.1436351760767; Wed, 08 Jul 2015 03:36:00 -0700 (PDT) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id xf2sm2043139pab.25.2015.07.08.03.35.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jul 2015 03:36:00 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Wed, 8 Jul 2015 19:34:52 +0900 Message-Id: <1436351693-2349-12-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436351693-2349-1-git-send-email-mukawa@igel.co.jp> References: <1435652668-3380-12-git-send-email-mukawa@igel.co.jp> <1436351693-2349-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v9 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: Wed, 08 Jul 2015 10:36:01 -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 Acked-by: Bernard Iremonger --- 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 | 2 ++ 6 files changed, 82 insertions(+), 53 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 42cf87e..d790d1f 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -242,6 +242,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 eab147a..afd14ec 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -138,6 +138,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 c0b62b7..cc022be 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -156,6 +156,25 @@ struct rte_pci_driver; struct rte_pci_device; /** + * Map this device + * + * This function is private to EAL. + * + * @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 the PCI resource of a PCI device in virtual memory * * This function is private to EAL. diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 4a4641c..1f09252 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -149,6 +149,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 da915db..7b24e26 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2,6 +2,7 @@ * BSD LICENSE * * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2015 IGEL Co., Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -527,6 +528,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