From mboxrd@z Thu Jan 1 00:00:00 1970 From: santosh Subject: Re: [PATCH v4 06/12] bus: get iommu class Date: Tue, 18 Jul 2017 16:46:39 +0530 Message-ID: <31c5f217-56b4-c3bd-0a10-6a1318a63ff3@caviumnetworks.com> References: <20170711061631.5018-1-santosh.shukla@caviumnetworks.com> <20170718055950.10208-1-santosh.shukla@caviumnetworks.com> <20170718055950.10208-7-santosh.shukla@caviumnetworks.com> <92ed2020-3e46-a705-f065-233073085d74@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: bruce.richardson@intel.com, jerin.jacob@caviumnetworks.com, shreyansh.jain@nxp.com, gaetan.rivet@6wind.com, sergio.gonzalez.monroy@intel.com, anatoly.burakov@intel.com, stephen@networkplumber.org, maxime.coquelin@redhat.com, olivier.matz@6wind.com To: Hemant Agrawal , thomas@monjalon.net, dev@dpdk.org Return-path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0081.outbound.protection.outlook.com [104.47.32.81]) by dpdk.org (Postfix) with ESMTP id 414153253 for ; Tue, 18 Jul 2017 13:16:59 +0200 (CEST) In-Reply-To: <92ed2020-3e46-a705-f065-233073085d74@nxp.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Hemant, On Tuesday 18 July 2017 04:35 PM, Hemant Agrawal wrote: > On 7/18/2017 11:29 AM, Santosh Shukla wrote: >> API(rte_bus_get_iommu_class) helps to automatically detect and select >> appropriate iova mapping scheme for iommu capable device on that bus. >> >> Algorithm for iova scheme selection for bus: >> 0. Iterate through bus_list. >> 1. Collect each bus iova mode value and update into 'mode' var. >> 2. Mode selection scheme is: >> if mode == 0 then iova mode is _pa, >> if mode == 1 then iova mode is _pa, >> if mode == 2 then iova mode is _va, >> if mode == 3 then iova mode ia _pa. >> >> So mode !=2 will be default iova mode (_pa). >> >> Signed-off-by: Santosh Shukla >> Signed-off-by: Jerin Jacob >> --- >> v3 --> v4: >> - Initialized mode to RTE_IOVA_DC in rte_bus_get_iommu_class. >> >> lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + >> lib/librte_eal/common/eal_common_bus.c | 23 +++++++++++++++++++++++ >> lib/librte_eal/common/eal_common_pci.c | 1 + >> lib/librte_eal/common/include/rte_bus.h | 22 ++++++++++++++++++++++ >> lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + >> 5 files changed, 48 insertions(+) >> >> diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map >> index 4b25318be..b9ee82b6b 100644 >> --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map >> +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map >> @@ -202,6 +202,7 @@ DPDK_17.08 { >> rte_bus_find_by_name; >> rte_pci_match; >> rte_pci_get_iommu_class; >> + rte_bus_get_iommu_class; >> >> } DPDK_17.05; >> >> diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c >> index 08bec2d93..a30a8982e 100644 >> --- a/lib/librte_eal/common/eal_common_bus.c >> +++ b/lib/librte_eal/common/eal_common_bus.c >> @@ -222,3 +222,26 @@ rte_bus_find_by_device_name(const char *str) >> c[0] = '\0'; >> return rte_bus_find(NULL, bus_can_parse, name); >> } >> + >> + >> +/* >> + * Get iommu class of devices on the bus. >> + */ >> +enum rte_iova_mode >> +rte_bus_get_iommu_class(void) >> +{ >> + int mode = RTE_IOVA_DC; >> + struct rte_bus *bus; >> + >> + TAILQ_FOREACH(bus, &rte_bus_list, next) { >> + >> + if (bus->get_iommu_class) >> + mode |= bus->get_iommu_class(); >> + } >> + >> + if (mode != RTE_IOVA_VA) { >> + /* Use default IOVA mode */ >> + mode = RTE_IOVA_PA; >> + } >> + return mode; >> +} >> diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c >> index 8b6ecebd6..bdf2e7c3a 100644 >> --- a/lib/librte_eal/common/eal_common_pci.c >> +++ b/lib/librte_eal/common/eal_common_pci.c >> @@ -552,6 +552,7 @@ struct rte_pci_bus rte_pci_bus = { >> .plug = pci_plug, >> .unplug = pci_unplug, >> .parse = pci_parse, >> + .get_iommu_class = rte_pci_get_iommu_class, >> }, >> .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), >> .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), >> diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h >> index e06084253..94f1fdfca 100644 >> --- a/lib/librte_eal/common/include/rte_bus.h >> +++ b/lib/librte_eal/common/include/rte_bus.h >> @@ -182,6 +182,17 @@ struct rte_bus_conf { >> enum rte_bus_scan_mode scan_mode; /**< Scan policy. */ >> }; >> >> + >> +/** >> + * Get iommu class of devices on the bus. >> + * Check that those devices are attached to iommu driver. > > Can we try to improve this description. > " Get common iommu class of the all the devices on the bus. Bus may check that those devices are attached to iommu driver. > If not devices are attached to the bus. Bus may return with don't core value." > > otherwise > Acked-by: Hemant Agrawal > We'll reword description in v5. Thanks for suggestion. >> + * >> + * @return >> + * enum rte_iova_mode value. >> + */ >> +typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void); >> + >> + >> /** >> * A structure describing a generic bus. >> */ >> @@ -195,6 +206,7 @@ struct rte_bus { >> rte_bus_unplug_t unplug; /**< Remove single device from driver */ >> rte_bus_parse_t parse; /**< Parse a device name */ >> struct rte_bus_conf conf; /**< Bus configuration */ >> + rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */ >> }; >> >> /** >> @@ -294,6 +306,16 @@ struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); >> */ >> struct rte_bus *rte_bus_find_by_name(const char *busname); >> >> + >> +/** >> + * Get iommu class of devices on the bus. >> + * Check that those devices are attached to iommu driver. > > Get the common iommu class of devices bound on to buses available in the system. The default mode is PA. > ditto... in v5. >> + * >> + * @return >> + * enum rte_iova_mode value. >> + */ >> +enum rte_iova_mode rte_bus_get_iommu_class(void); >> + >> /** >> * Helper for Bus registration. >> * The constructor has higher priority than PMD constructors. >> diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map >> index 5dd40f948..705af3adc 100644 >> --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map >> +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map >> @@ -207,6 +207,7 @@ DPDK_17.08 { >> rte_bus_find_by_name; >> rte_pci_match; >> rte_pci_get_iommu_class; >> + rte_bus_get_iommu_class; >> >> } DPDK_17.05; >> >> > >