From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 674718D9F for ; Thu, 14 Jan 2016 14:29:24 +0100 (CET) Received: by mail-pf0-f178.google.com with SMTP id q63so102924067pfb.1 for ; Thu, 14 Jan 2016 05:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mvista-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FIiKZa+QKp67ihHPO2gba8oypXNgo2jCFmCFYfIjf7E=; b=P6TvyzKjB1QqIuwjmVSUNQXNFZYqJyQm+0fU2nxmO9e6JhLq6FYcSdXrI0BXNXjhhx WkT73PirzKwkZ2A99z6WoUjcXn8mqi8gETPnvoKC8MP3cgAjv+UV13hLwPl0fy2P0KCY il5NznVhN4fh1qbHWahE9AnCG1sbKHsuc6ZapW3JnBqPY+NOGidBGZ96P2Qg2Dc7Hgzm AqZyx3u4fqMZUcz161+UTvGfsStszajvy0V808dSPAmFwEsZOR9YPxwEj9I/e6W/UuTm aY/Lt+FfyV2TVC+rjhvmXWPp4U9nKnzTq453sJtqZF2jBK8Y2f5msGrMErNj6RTEavFX pLIg== 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=FIiKZa+QKp67ihHPO2gba8oypXNgo2jCFmCFYfIjf7E=; b=VAojEamefPyiOrhp5BWNuAF9cjLRsYtVBXJqao2Pn/gMLJ6jZ8AnZqVkHlXo8uUtCV GBqHoCgwVU34gSfQ2pSnlCbHVBJ23ec8Gq50PutL3SYEg15fbMF37c2f/qzqpHG0e9Tm 69+geRh2wc1WpzNhcdehFbECM0IW6fezmBlG5d5jSfaZwit7IWtBCTHROQEPVA8Xa35o A6a5XQ0quTem4ApSX9JHEizg57pDBvgwxBZV5aN0KUGGFiLG1fE6NAoUDhyUGxa4CkvO F+eBwExCC92kAxCFJ71WfdjDfwXzu04nZJJD/YDM81yVFj87CjKQUAahGaYbqT4K4Id3 YTSA== X-Gm-Message-State: ALoCoQnJ+Ni/mFidv/TmHIgRRAdpRiTBJN1kovtYSWRPjAyH1jlw89U21FOzW5vJc9aoJLF1/Q9AyS9ePQA0klBLA7Y1MuSr2Q== X-Received: by 10.98.19.93 with SMTP id b90mr5943435pfj.34.1452778163768; Thu, 14 Jan 2016 05:29:23 -0800 (PST) Received: from santosh-Latitude-E5530-non-vPro.mvista.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id v71sm9438472pfi.91.2016.01.14.05.29.21 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jan 2016 05:29:22 -0800 (PST) From: Santosh Shukla To: dev@dpdk.org Date: Thu, 14 Jan 2016 18:58:35 +0530 Message-Id: <1452778117-30178-13-git-send-email-sshukla@mvista.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1452778117-30178-1-git-send-email-sshukla@mvista.com> References: <1452778117-30178-1-git-send-email-sshukla@mvista.com> Subject: [dpdk-dev] [PATCH v4 12/14] eal: pci: export pci_[un]map_device 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: Thu, 14 Jan 2016 13:29:24 -0000 From: Yuanhan Liu Normally we could set RTE_PCI_DRV_NEED_MAPPING flag so that eal will invoke pci_map_device internally for us. From that point view, there is no need to export pci_map_device. However, for virtio pmd driver, which is designed to work without binding UIO (or something similar first), pci_map_device() will fail, which ends up with virtio pmd driver being skipped. Therefore, we can not set RTE_PCI_DRV_NEED_MAPPING blindly at virtio pmd driver. Therefore, this patch exports pci_map_device, and let virtio pmd call it when necessary. Cc: David Marchand Signed-off-by: Yuanhan Liu Tested-by: Santosh Shukla --- - Pulled Yuan v3 patch, just for testing and other user to try out complete set and test it on HW i.e. x86 and non-x86 both. It works for VFIO mode seemlessly. lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 7 ++++++ lib/librte_eal/common/eal_common_pci.c | 4 ++-- lib/librte_eal/common/eal_private.h | 18 --------------- lib/librte_eal/common/include/rte_pci.h | 27 +++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 4 ++-- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 7 ++++++ 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 6c21fbd..95c32c1 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -93,7 +93,7 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused) /* Map pci device */ int -pci_map_device(struct rte_pci_device *dev) +rte_eal_pci_map_device(struct rte_pci_device *dev) { int ret = -1; @@ -115,7 +115,7 @@ pci_map_device(struct rte_pci_device *dev) /* Unmap pci device */ void -pci_unmap_device(struct rte_pci_device *dev) +rte_eal_pci_unmap_device(struct rte_pci_device *dev) { /* try unmapping the NIC resources */ switch (dev->kdrv) { diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 9d7adf1..1b28170 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -135,3 +135,10 @@ DPDK_2.2 { rte_xen_dom0_supported; } DPDK_2.1; + +DPDK_2.3 { + global: + + rte_eal_pci_map_device; + rte_eal_pci_unmap_device; +} DPDK_2.2; diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index dcfe947..96d5113 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -188,7 +188,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d pci_config_space_set(dev); #endif /* map resources for devices that use igb_uio */ - ret = pci_map_device(dev); + ret = rte_eal_pci_map_device(dev); if (ret != 0) return ret; } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && @@ -254,7 +254,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr, if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) /* unmap resources for devices that use igb_uio */ - pci_unmap_device(dev); + rte_eal_pci_unmap_device(dev); return 0; } diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 072e672..2342fa1 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -165,24 +165,6 @@ struct rte_pci_device; int pci_unbind_kernel_driver(struct rte_pci_device *dev); /** - * Map this device - * - * This function is private to EAL. - * - * @return - * 0 on success, negative on error and positive if no driver - * is found for the device. - */ -int pci_map_device(struct rte_pci_device *dev); - -/** - * Unmap this device - * - * This function is private to EAL. - */ -void pci_unmap_device(struct rte_pci_device *dev); - -/** * 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 53437cc..0c667ff 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -523,6 +523,33 @@ int rte_eal_pci_write_bar(const struct rte_pci_device *device, */ int rte_eal_pci_write_config(const struct rte_pci_device *device, const void *buf, size_t len, off_t offset); +/** + * Map the PCI device resources in user space virtual memory address + * + * Note that driver should not call this function when flag + * RTE_PCI_DRV_NEED_MAPPING is set, as EAL will do that for + * you when it's on. + * + * @param dev + * A pointer to a rte_pci_device structure describing the device + * to use + * + * @return + * 0 on success, negative on error and positive if no driver + * is found for the device. + */ +int rte_eal_pci_map_device(struct rte_pci_device *dev); + +/** + * Unmap this device + * + * @param dev + * A pointer to a rte_pci_device structure describing the device + * to use + */ +void rte_eal_pci_unmap_device(struct rte_pci_device *dev); + + #ifdef RTE_PCI_CONFIG /** diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 8c1a49d..39e0650 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -124,7 +124,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name) /* Map pci device */ int -pci_map_device(struct rte_pci_device *dev) +rte_eal_pci_map_device(struct rte_pci_device *dev) { int ret = -1; @@ -153,7 +153,7 @@ pci_map_device(struct rte_pci_device *dev) /* Unmap pci device */ void -pci_unmap_device(struct rte_pci_device *dev) +rte_eal_pci_unmap_device(struct rte_pci_device *dev) { /* try unmapping the NIC resources using VFIO if it exists */ switch (dev->kdrv) { diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index cbe175f..b9937c4 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -138,3 +138,10 @@ DPDK_2.2 { rte_xen_dom0_supported; } DPDK_2.1; + +DPDK_2.3 { + global: + + rte_eal_pci_map_device; + rte_eal_pci_unmap_device; +} DPDK_2.2; -- 1.7.9.5