From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0078.outbound.protection.outlook.com [104.47.41.78]) by dpdk.org (Postfix) with ESMTP id 0589D199AE for ; Mon, 18 Sep 2017 12:43:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=C+4/U2E0ufPFtjlpVgFSEm1kFpmChzsWj/MmgbzEF5I=; b=G+ziyZA5bF4nfr+8+yDjwRMzVUg8Mr2utgdO/UZE87mnYD3KhxASDBuOeCuw3WljrHdYKVVIo01pqyzDOwaT4YQ5dgraJuL5wkFcW2kiN5+P7GiXRqMpmluEB8Z00yI3vygEsnulNiPsItF24e5YqEM11BOHvTq4Mv0jAcV7K0U= Received: from localhost.localdomain (14.140.2.178) by DM5PR07MB3097.namprd07.prod.outlook.com (10.172.85.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.9; Mon, 18 Sep 2017 10:43:36 +0000 From: Santosh Shukla To: dev@dpdk.org Cc: olivier.matz@6wind.com, thomas@monjalon.net, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, aconole@redhat.com, stephen@networkplumber.org, anatoly.burakov@intel.com, gaetan.rivet@6wind.com, shreyansh.jain@nxp.com, bruce.richardson@intel.com, sergio.gonzalez.monroy@intel.com, maxime.coquelin@redhat.com, Santosh Shukla Date: Mon, 18 Sep 2017 16:12:29 +0530 Message-Id: <20170918104234.9149-5-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170918104234.9149-1-santosh.shukla@caviumnetworks.com> References: <20170831032618.7120-1-santosh.shukla@caviumnetworks.com> <20170918104234.9149-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: PN1PR01CA0093.INDPRD01.PROD.OUTLOOK.COM (10.174.144.161) To DM5PR07MB3097.namprd07.prod.outlook.com (10.172.85.7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ebc70e7-db5f-4b4f-51db-08d4fe8221ed X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3097; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3097; 3:yojqhRozIoubJspq9JhzFuzuUjCqDLDEYt+UEO/Qv9SMvQ44JWkp6fmO6vYe4tcMLuZUOC0mUVlnVSLubGzveiRf4B9pCC7j/syhR2giDgsrNHTCEOLsf13UUugKO4RTsOqlwJE5FKxK5U5lwav8Dq/+hFnrTUTvBj7bqAjcw4Dgl64yTyQzvEYVRJe12p/jlcQqJV2qxOdNREVvYnav3+Bjc2rH2uo6kk94XXGZ7afxMPceXLlmlSRDepRcvszK; 25:vRqFsd7Bux9p4AM7u75tA2VHRrYQrjGYyHRx1l5cEKBwDERIx/8QNav5iv7N7e0sJQHPCzzWBo9EPRDymBI9eoTpCiqr5iKoxkR20YU2uaEF5m+mDJ5Egst+BG5J+AI7WyCa9A3QTRse2Tc5JxZHbT7gOZezo9VJDEDiFEtr+jHgLbhWiJJUe5qLteDTQBWPI9jbea0K/paL2rAtHvirwfpF7ZkQ4EDMAsb417gRwMz80GBM7xajNaCwwTHoBO0va6Ougd/1nq8kaRjvxiE59JDjmXdiveognUpSbogZsXA9Y+rbduWgHSppQRMdMDQHk7UVEJb/zGJVBALZZGXO3w==; 31:/GKt3FFnYVj4vrE2Qr67Zel59Rrei1gfGFdmqHcnuW5CqKRsIwTSn6cjXHdDy7NOjS5ENBVEXLqH6BDCW0TWsm3k5uRYeJ2pnsY803jt3xpqXOvQp+ddazzSCKDh8ywQqACS+qJNtuuqzwGIuvCEfRiN1wCPhJoXSIXoBb48j5iQ7oCrb15V1e8Swa6DHulwy6qUrLn+nJSdgl+VgQxBlbOUHpeZEK/ynrOraSgGSM4= X-MS-TrafficTypeDiagnostic: DM5PR07MB3097: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3097; 20:/M0agkHur2+T4tawi5+ov7TkGDVJKuy2LhrK+0EklE6M5LtqfYHA7yQcYV5OPlxvVn7pnU+4USmb6+DerO5kOv+pZlg+qWxNieV0I7YWAemGsPIXqP6IN1nURu6AR1oJYwDKu1wJbY0t8sdp8zRDDizlbXE9FXM8Hr+M9UHMq5oeA2onzZJ96mgveL5cy95X0cJNhAaAt81q5Eh5fbStIIS1RAvCw2K8sgpm16c58ZEbVI55azW9DM4VUcZXUgdTSx25oXw2t9SdfI3chv0LD2vNpl7RvmpdCNZa4XOT4bhFhw5/2y82fZIBDcFcaaVieMpA+OmAHASV0+zmLqt+laFuGSb/RDiki68odSevj/QEWAPRMLAaETKm5RBKOnLqP0wZs/KR7xcZzIl/UtjGxZtnNom895I9nrGXlDz1PothwqkW/fEqCHZ4fzK62OPmjV1U1/F+8j6xlhK044e77A0CEsRxxwdPeSUOVaQZ3y6SVZ5eSoEhmZTe0AZ8VndGN5QrCl2Rx2QSWmOi4T5jlrstihzLKekKPe1ohOK8TrVlADSzEWbbDnOTWEETB/irvI7WNMTluBMLmnJLfWiOI1tk7VxRHTFoFuun14Nu9Ik= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(10201501046)(100000703101)(100105400095)(6041248)(20161123560025)(20161123558100)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3097; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3097; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3097; 4:jJx0vVIrOpyLby5fPKlKXET4ccinVWNdJUvyZ1GV+tJsZR/rrWHcgsapuUB5mpAL/xFCswhpqcKNweixxwYbAym3wBN/EnurL/noP1MI8H2gsT0lXsTm8dpyKRReuglOB/fIYt2W3t3NMQifOJEf1j7oDqhnDllvRjjaA3Kv6ZezJMEp/sAseg2UxSgyoBSiZJfluEUVtJjSkJijR317JVo0UngT2UCR3H9Q2YuaI3ilhIK20VIviH7tJ6UT0XZ0svRjihzwHUcjtt0eiQx8aDOEvGfXCEdoNsZBR7JqcXs6waYET/ajsvNRgDX+gdzx3ju6oZgSE/FMqSmc/NaNrg== X-Forefront-PRVS: 04347F8039 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(346002)(376002)(199003)(189002)(6486002)(76176999)(6506006)(48376002)(50466002)(25786009)(5003940100001)(107886003)(110136004)(53936002)(4326008)(101416001)(97736004)(6512007)(16586007)(106356001)(105586002)(2351001)(47776003)(305945005)(189998001)(33646002)(478600001)(5660300001)(2361001)(42882006)(6916009)(6666003)(2950100002)(7416002)(5890100001)(36756003)(66066001)(2906002)(7736002)(81156014)(68736007)(50986999)(8656003)(81166006)(50226002)(316002)(575784001)(8676002)(3846002)(5009440100003)(8936002)(16526017)(6116002)(1076002)(72206003)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3097; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3097; 23:b7SFjFB9pN7CZVB2IxJsjuEEnQxaktPj+D/Mtmznj?= =?us-ascii?Q?3M/z6Q8grvlrH64LaUS2BqjQzBAD05OH1IDEi8g0YE9bWZ8EnM8Rn7Y6dr2L?= =?us-ascii?Q?MXP9IX0M03d1wyQC73EIRt6y6teKCJHLY93UwAbV3C1CKNq/2BSLw7xGcvXF?= =?us-ascii?Q?iry7x0BilsrKCYR+z/+mXip9FE8/1RwA8bwtNrGR403ySWfsp2LFr7ANa/N8?= =?us-ascii?Q?xfuNMlevR5Z84wRP+iLXZjO6b0w3VCAmUZbaxSRGXSvxEzD9F54m2fMNkCo8?= =?us-ascii?Q?Ym4r1ITG3Ob4U8moXwq8dJbYfXg5VIwNFekwHUX88xEYYkGvBVqClBAVe7R6?= =?us-ascii?Q?DZnNJqNfSxcAIj7Sjmc+2DCC0yaIFlTGsYdJQVgpNDlMs5mbhYiyYzLR48ze?= =?us-ascii?Q?oWh8m39NqDTs7rL7fZo4rm8XJhItKIOrgTCKNvMzDKLdIvtH2g9yBakfM6Oa?= =?us-ascii?Q?5QF0NreCsPwkd/di5onQirfPRwfJewKk/w4sD3aKRdzmmS+B4WaVJ+FFDL7s?= =?us-ascii?Q?hMWyoH2fqpUJUlhMIpNPuqz0t8l2zNoxdXAgaN2DVFccdh9TG4G9ekjOzVDy?= =?us-ascii?Q?KnuA02VQgPTpC8Mu3MtPXgtrNHGOb2FOazm5AioZV7U72SSsBgeLUdy0Iy9/?= =?us-ascii?Q?xqytqmhxxKN1RwfS5OoeQgUHbSb/NF2owx3UVtMTzcD/LitzGmGuwQeyEJ8m?= =?us-ascii?Q?gFjPELnEFUwy6OZyHbW3xg8UNrjhRAS17w0fQx4CH5Cw9+XZRMV96lVCYZ2D?= =?us-ascii?Q?frmvBvxqUCWMlifFJbycFQKoy+IHesujz6gtp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xparvbnac08Q==; 5:gR8oU0EOG8zKyLcRMre5mO6ywdBLgaV7ARqtvStNOBn94iLvYEv//H1ogvdqaPIASrPuN4jn4BlaGnsKtG6ZwU3TRKtyiXRUOG6FZG7CD1/a4zTMI33usKxQJ0MV5Rbgo3EmiipoAJm62HjR0O+rUQ==; 24:GnggnE1JKgojgyhR6B4QldsHHtZMvOr7Z3wt6BpLt7SMg8SNrdraD6eEiTEeuy7qohXL5cQy7zM6O2D6tzP3bbGCVUFja449vTajoGOMEtk=; 7:19en4rS+K62OsuFL8iQDiz17zb2qF5NJjw2Sb7WJ8rPcnb+wA92uI/EIwLjqUo/FMET8ruDaGUauwO3gIscZRtJNud36+zMcwzS4KaBrrQL/CRtOTcsbWWVhA6TIfVGchKawBxAlPZ2+YLAXxg3nZyqxSKpoMarwRPWmx52j8nQxnIgbJvHcvhg2ynlkzXUnAH/xqV14A4eZv7rsj1+11cdvCxmZEC78KygxUvpIII0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2017 10:43:36.6986 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3097 Subject: [dpdk-dev] [PATCH v8 4/9] bus: get iommu class 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: , X-List-Received-Date: Mon, 18 Sep 2017 10:43:45 -0000 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 Reviewed-by: Maxime Coquelin Acked-by: Hemant Agrawal Reviewed-by: Anatoly Burakov --- 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 | 25 +++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 5 files changed, 51 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index c6ffd9399..3466eaf20 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -244,5 +244,6 @@ DPDK_17.11 { rte_pci_match; rte_pci_get_iommu_class; + rte_bus_get_iommu_class; } DPDK_17.08; 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 3b7d0a0ee..0f0e4b93b 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -564,6 +564,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 9e40687e5..70a291a4d 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -178,6 +178,20 @@ struct rte_bus_conf { enum rte_bus_scan_mode scan_mode; /**< Scan policy. */ }; + +/** + * Get common iommu class of the all the devices on the bus. The bus may + * check that those devices are attached to iommu driver. + * If no devices are attached to the bus. The bus may return with don't care + * (_DC) value. + * Otherwise, The bus will return appropriate _pa or _va iova mode. + * + * @return + * enum rte_iova_mode value. + */ +typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void); + + /** * A structure describing a generic bus. */ @@ -191,6 +205,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 */ }; /** @@ -290,6 +305,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 the common iommu class of devices bound on to buses available in the + * system. The default mode is PA. + * + * @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 a8c8ea4f4..9115aa3e9 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -249,5 +249,6 @@ DPDK_17.11 { rte_pci_match; rte_pci_get_iommu_class; + rte_bus_get_iommu_class; } DPDK_17.08; -- 2.14.1