From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0059.outbound.protection.outlook.com [104.47.34.59]) by dpdk.org (Postfix) with ESMTP id E3C33FAC8 for ; Wed, 15 Feb 2017 20:07:46 +0100 (CET) Received: from DM2PR03CA0042.namprd03.prod.outlook.com (10.141.96.41) by BN6PR03MB2948.namprd03.prod.outlook.com (10.175.126.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Wed, 15 Feb 2017 19:07:43 +0000 Received: from BY2FFO11FD001.protection.gbl (2a01:111:f400:7c0c::163) by DM2PR03CA0042.outlook.office365.com (2a01:111:e400:2428::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Wed, 15 Feb 2017 19:07:44 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; caviumnetworks.com; dkim=none (message not signed) header.d=none;caviumnetworks.com; dmarc=fail action=none header.from=nxp.com;caviumnetworks.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD001.mail.protection.outlook.com (10.1.14.123) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.904.16 via Frontend Transport; Wed, 15 Feb 2017 19:07:42 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v1FJ5fMA020023; Wed, 15 Feb 2017 12:07:39 -0700 From: Hemant Agrawal To: CC: , , , , , Date: Thu, 16 Feb 2017 06:09:39 +0530 Message-ID: <1487205586-6785-41-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1487205586-6785-1-git-send-email-hemant.agrawal@nxp.com> References: <1485172803-17288-1-git-send-email-hemant.agrawal@nxp.com> <1487205586-6785-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131316592629997980; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(336005)(39410400002)(39860400002)(39840400002)(39380400002)(39850400002)(39400400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(38730400002)(33646002)(110136004)(8676002)(81166006)(81156014)(36756003)(8656002)(92566002)(2950100002)(6916009)(305945005)(47776003)(86362001)(50986999)(85426001)(76176999)(50226002)(189998001)(106466001)(8936002)(54906002)(356003)(105606002)(53936002)(50466002)(97736004)(104016004)(77096006)(2351001)(389900002)(68736007)(2906002)(5660300001)(48376002)(626004)(4326007)(5003940100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2948; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD001; 1:hIbiXDl9iwoicEWVEhwVbDeimikonQTkuMFRdaFynRxp1G4aVQwTpnsSAy4r6dmbEmq6dswQBMGfU1sTxhaCMsyP1ZU0bHRrZdYr8LTfvHRgb8ISLAjwFlWkbDokAd7sg+fINVSDjj4HbAuNDRHEmnkgkXAEa1K/kdVDOU1RkB0UULqdF9OsBwlv1MC5gjXs8VdSesLfUs71y/cLLk6C+eplzKLMSw2kE6DqQs1d4nUxjUde01o4mFfv5ObrvqpcixE3jXm9U7vh2l2PeKaNRDWzs1m+ppZcVPYpd3E5GLRY8xyxid4ukPoyqEM30y2c5o+szyyr2Y9YPJvVlOvNvScTisYl1g+Fs0E7u9jchvjcRj3B//S6tIqdUF9y7ZgZ7TOFKIDehWXJ3ikfzLFtrdN3a85w1ntgzIS5YjFZAIJ/Ank3SIrcLx9UwuT54m/ljhM+Ro7qcuZSPoLZtmZk5qNYHtBH3xKggdlIbH3I7Y445z+hdRC4xTv6I+gAi1U3XWrkDk/4JYJDTHAT7CqA3PvzaSy42fpzayO8ZqBie87uuZjIDKkcTN1eNEZS9ZyyShkcOewrsPYaAJu3H8pKJnqCsRmXqR2L2vKaL5tKj9a9jeDjvCl4s9dTYh5H2nXXDZ76uQ6vH4J8RTS4HtFzkA== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 390395f5-f7c1-417f-619c-08d455d5eb4a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR03MB2948; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2948; 3:gEirl573GPIrhWkoKS0SsRBHBus6jr+EN0o3FBsezbXFfNUvvewbvgLm3+lwI/2mSqyOSWIPRQOfAhLxVaG1rNcnYcK9AtEqtrnRgfB8cIo9mUN9T4MoyEXarQQ+uFinNCYKI5UNH23PM/bL+arx6wwPD24AJh8NwVz1STn/N2G1AZJ8dxm4s0M6qFp20aDLZdSzJCSA9w33JNY2ZkiRzaNhxy0Wdaj1iqaCdV2RQqRuKFQ1br/T6R5zCbhZ2ZyKyjrJwXOS5sl6D5RDOQRyhfZ6WCOlT6uPI7YYKRzTASDfnep+xpXEdbTmpyHItvmaDgimwxI2tH7jjeCdHv4zbZWZlao9GTrZCa3KMXM1qeKM+4fHtRG4fZw6anMfXQH2; 25:yLaFQwTa4l5gWcUwLnj7aAAm7qTHul7hAllZv+GoXL6tNEel1Dv/lv+FWi+ymdZU3qulMQ0HsX+L1wLpmTODLxktjhBl1fXkglCtgxom/8/2kc47ombRX/QqV7QnBV9RNQAkIJybT9rdjd16DtDOFMfkpF5zef93xiEMgYtFbzZBsJoJFrCvq2b7Lvk5v0VUF2LY74Ydg4LxNJWjg99gIgPDDvRB63Pad1grCwSw5jyVIqoKpBC1dpiLqqQUpXe3OGqChsJrjn6UL4AkpLU/t68hLWDiWpG/F4xJO5pSWy+dgi6PBRtPQWCJ0QuN/3KI49bSYYiz0KQKCq5KqxjKuGp/DYyjgwUMHLLhJ1rxvn66+mwhGAjfRCM66uB4+Gjm6M83jQPo8PyXpdTlMv/MUAr06TNgN9JcrrOmrePdsNUEJ4BD31IweXHS/65b1DcOuZYpywliIh9SfMGlxTMsvg== X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2948; 31:/Sb2pDR48xhX0HcZolDvBCh0sLqFBndTBNVaeRUklYrHVOq7xzjwP0LJG8U8YqSDkht5hCDXqpSMK2bb9/xgX95/YHKf7Iz1yVm+hx0Jr3kIYx7M82kRwBPVpOLq8VSNveErjlHMDsNYaoAIhrmUMLvw5OxKWGpdVe4TQQCxH6YsBTsCHMvX93IySiEEVyoSV/TL0TrcJC9fpVA8IRq/E53BaCVfCBsPKNnGOujbEF7r7Mhuc6hM0LhW67nqwGNYf/hqW37283Al5KVj5zsuGw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(8121501046)(5005006)(13018025)(13023025)(13024025)(13017025)(13015025)(3002001)(10201501046)(6055026)(6096035)(20161123559025)(20161123565025)(20161123563025)(20161123561025)(20161123556025); SRVR:BN6PR03MB2948; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2948; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2948; 4:uQ4MJCBSqEfBOBcB1nHr+3SdDAEPzbWTyy3Ny05hQTQuJW1tREgRCrQSCQHDapJ+c5LIxf+hhBntxn4b4R/PQecFJ+OBKRUNeTAZiX70gSA4C9K2xjfIRCNftQ0aAXDSnwF4JjygJYOnPqkSnQvuiRZSa2a1XlfInLp6R0YbJK3IKf7g8uKyNDhaHzPtjaZlVXIVhCoAAVfXF8rG7Mi50I3wnmY5WftHXJ+NrWxth6BJyR05eQPLaCWBP0tq04oQiA2VjQ2RJZdHITq1OtVx4mPn68bUV6PjiZtC+clnOb1nYyDwKglteI8gKoV5h5yfCWtkJ53qNUYsZwb18JW3PR7m7zGUY7Juubr0amdu29MbSo8AHiQEFU0MFgf3aNkZtnImt+gp2tI6klgFBy9uKP9Yzosl2QTI/WPyTPxOTANhEJ6vmp2v5d7dYq0D7qNDR6e0KNYJEut957uXTlKhLfV5rysiS4WUJWo2gOeeHSujibbIaEwzhL3o2IKyI8yDWEBlJdhchuvBlw3o65wHnMccDqO7mYBahm0SUvBFsXQhlvpNWFowDuhIUsmg9v15b8gFTOUqZCCqKJ/7bGuw/jDacnde+VmLBmwN8SBnTrJX/rcCSQ3P3UD19w8jsHjrvGoUnriaMevlAxxfhqxfUCNgXSDWPGkgmZmlZhLawS5zof2lecusFtop9xQlEptiW9HTVIfh+44cIzAK8bhfks+6wy0yeT70f4N3mU9PSFLpRprr2NsXKY5wM9xxBz30PiWg6FesT4CbagAaBPxt6g== X-Forefront-PRVS: 021975AE46 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2948; 23:kTLjSlSGkTE/L+XPFqKSOUcRF39kEhy0+SfxnGv8h?= =?us-ascii?Q?dOtu8XzH77EKHuvyPOiL0/igF16c4uofb2F/HqlbRSOCBOl3OMQCLTWWGwLu?= =?us-ascii?Q?D4r34HCkLUsQuEJyq7cmNNH0dYg65iCCTYUmtS+Vd+g6/GRdnK/B+hUGUKMo?= =?us-ascii?Q?bWCa3gqYgnXCjvVc13rLOF4H+bdYWl3HPeK9G8Ja4sbcaCmF4MZNnRfUYfXf?= =?us-ascii?Q?oJdHqCT2HcJJVHWKrEZJpfWEWPUhNFXCH36Jso0xIqBi7mwosyf7QWSyeNeT?= =?us-ascii?Q?qcOW6UueksDSmHairAF1QfshLJz64Szgd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?Q?foPy1RTKC3I4vwV2WngdRpqOrzxSp8Z6jsv3JghrfQ4gW8OZl/wCOxRIRY44?= =?us-ascii?Q?eaIzbbKdjNUFqWzSPcSQ3l5O6cFm66jmBs1Viu7nZ/LkUFbGQveclPmxTGwS?= =?us-ascii?Q?YXL9PvFRIrp9CETO+s2zpo=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2948; 6:1H/eYM343KRmK2Q0AkKTmVhUsDuU8NHjJ1dDco9kjT/K4FFiG8lNpl+IMGeDdIj/6JEoynRoCHv3jPgGRUuMirxfrvBLvVxSuxcjVJnRDRlEyY19hDkBveaTQ4L18BgHnhj9CIez5BEElGJDgHaUnpbq0aoS/7juswsHatMW1d0tQdJYre2AThGIBdFeLI57zZSGtoM2gKqXhE5amk4cAZD+1mWaijNYxSNfCmIWe8e8yTfpRc4VW9ZhGCLFdYdlyi8GkFoSQl66u333tE+p7eCUGksVYnSLrd4fT23wWryNOW8C09RA7G0yO5JeqWWzIXY+Scm1pGLN8VtLKj6E7T8O9AjGGACNRxptB8NcWVCZhyEK/LfbxMAlEjhxI2dIzO2NsYtUKm7vvl4lTshUk09VVEx70co33rK3dr7D4t8=; 5:T53Od4POQIP6PROUyJ7n3K+eoJpMw3ACgsZPSW2tTn30W/zDumrBS3lRbN/sN+ycwfyChc61GsO0KKeQguvOdiOoYz3Sqn+lndI2J/qlr2Q0j8yoiEWCbwsUHKF4LZidurEMn/dm+rNICeOUFTbkXcUMH4Pl5B7FMVEuSbLezJef+ffVL4+UtQVemMBRtlef; 24:BZ9p8nFsbxxcIYQ2CVsAoJ8hhhjj4BlKMyV8sjSNXzad+kaxl3l3JN7pHnMyH+do7JXHIUD1UVWdV8wsJwKpgPdtrpf/Ftz/w7M/MsLgGmI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2948; 7:zEzLd+/QecavxP8kkSVpGqjRqIiqWZv/iKNFW/7gzPLMww1KF5uM6PpzkimgZ3B5cmhztTOFC2tBzs4EQIpQjk8qma7CKF5WCeduOw/iqsfaLf42yMQ8/GI7s4uqhSRihebtelT+xriYvS1d9IRFqShh41e/TFE4zy2UgUs1a8kawc9+z1YulI9iXTpLkh6f8wMpssGXl9a3dAmWhXru//LM6OlM9zB1bVwGdqGRKYQgsdujCOmoirJng2G07xeIY1r65wXvtHYVRSd9dqrM6xDcTtVJrw39n+AnlAnxLLfheOh0HEZBvTi/mfrgjh1DdE9UQx2dWJY2A+stUUfMEw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2017 19:07:42.7657 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2948 Subject: [dpdk-dev] [PATCHv7 40/47] bus/fslmc: add physical-virtual address translation helpers 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: Wed, 15 Feb 2017 19:07:47 -0000 Signed-off-by: Hemant Agrawal --- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h index c26360d3..ad8a22f 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h @@ -175,6 +175,72 @@ struct qbman_fle { */ #define DPAA2_EQ_RESP_ALWAYS 1 +#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA +static void *dpaa2_mem_ptov(phys_addr_t paddr) __attribute__((unused)); +/* todo - this is costly, need to write a fast coversion routine */ +static void *dpaa2_mem_ptov(phys_addr_t paddr) +{ + const struct rte_memseg *memseg = rte_eal_get_physmem_layout(); + int i; + + for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) { + if (paddr >= memseg[i].phys_addr && + (char *)paddr < (char *)memseg[i].phys_addr + memseg[i].len) + return (void *)(memseg[i].addr_64 + + (paddr - memseg[i].phys_addr)); + } + return NULL; +} + +static phys_addr_t dpaa2_mem_vtop(uint64_t vaddr) __attribute__((unused)); +static phys_addr_t dpaa2_mem_vtop(uint64_t vaddr) +{ + const struct rte_memseg *memseg = rte_eal_get_physmem_layout(); + int i; + + for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) { + if (vaddr >= memseg[i].addr_64 && + vaddr < memseg[i].addr_64 + memseg[i].len) + return memseg[i].phys_addr + + (vaddr - memseg[i].addr_64); + } + return (phys_addr_t)(NULL); +} + +/** + * When we are using Physical addresses as IO Virtual Addresses, + * Need to call conversion routines dpaa2_mem_vtop & dpaa2_mem_ptov + * whereever required. + * These routines are called with help of below MACRO's + */ + +#define DPAA2_MBUF_VADDR_TO_IOVA(mbuf) ((mbuf)->buf_physaddr) + +/** + * macro to convert Virtual address to IOVA + */ +#define DPAA2_VADDR_TO_IOVA(_vaddr) dpaa2_mem_vtop((uint64_t)(_vaddr)) + +/** + * macro to convert IOVA to Virtual address + */ +#define DPAA2_IOVA_TO_VADDR(_iova) dpaa2_mem_ptov((phys_addr_t)(_iova)) + +/** + * macro to convert modify the memory containing IOVA to Virtual address + */ +#define DPAA2_MODIFY_IOVA_TO_VADDR(_mem, _type) \ + {_mem = (_type)(dpaa2_mem_ptov((phys_addr_t)(_mem))); } + +#else /* RTE_LIBRTE_DPAA2_USE_PHYS_IOVA */ + +#define DPAA2_MBUF_VADDR_TO_IOVA(mbuf) ((mbuf)->buf_addr) +#define DPAA2_VADDR_TO_IOVA(_vaddr) (_vaddr) +#define DPAA2_IOVA_TO_VADDR(_iova) (_iova) +#define DPAA2_MODIFY_IOVA_TO_VADDR(_mem, _type) + +#endif /* RTE_LIBRTE_DPAA2_USE_PHYS_IOVA */ + struct dpaa2_dpbp_dev *dpaa2_alloc_dpbp_dev(void); void dpaa2_free_dpbp_dev(struct dpaa2_dpbp_dev *dpbp); -- 1.9.1