From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0068.outbound.protection.outlook.com [104.47.38.68]) by dpdk.org (Postfix) with ESMTP id 293E6CFA0 for ; Sun, 9 Apr 2017 09:49:10 +0200 (CEST) Received: from CY1PR03CA0034.namprd03.prod.outlook.com (10.174.128.44) by DM2PR03MB400.namprd03.prod.outlook.com (10.141.84.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1005.10; Sun, 9 Apr 2017 07:49:07 +0000 Received: from BN1BFFO11FD010.protection.gbl (2a01:111:f400:7c10::1:106) by CY1PR03CA0034.outlook.office365.com (2603:10b6:600::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17 via Frontend Transport; Sun, 9 Apr 2017 07:49:07 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=fail action=none header.from=nxp.com; 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 BN1BFFO11FD010.mail.protection.outlook.com (10.58.144.73) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Sun, 9 Apr 2017 07:49:06 +0000 Received: from DTS-02.ap.freescale.net (DTS-02.ap.freescale.net [10.232.132.223]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v397mBLc024015; Sun, 9 Apr 2017 00:49:03 -0700 From: Hemant Agrawal To: , CC: , , Date: Sun, 9 Apr 2017 13:20:22 +0530 Message-ID: <1491724224-6319-20-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491724224-6319-1-git-send-email-hemant.agrawal@nxp.com> References: <1489754838-1455-1-git-send-email-hemant.agrawal@nxp.com> <1491724224-6319-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131361977466007969; (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)(336005)(39400400002)(39860400002)(39850400002)(39380400002)(39410400002)(39840400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(3190300001)(189002)(199003)(9170700003)(33646002)(105606002)(106466001)(8676002)(4326008)(76176999)(50226002)(8936002)(50986999)(5003940100001)(81166006)(86362001)(356003)(38730400002)(104016004)(305945005)(47776003)(85426001)(189998001)(5660300001)(6666003)(2950100002)(48376002)(53936002)(8656002)(50466002)(54906002)(77096006)(36756003)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR03MB400; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD010; 1:xyg/d33nxF9CZJvm0Mfu+PjM7f4PVhldiHK1ey+CkKQ8lT3hMVz3Gnpj9EsM5qteVOE22qHXI0Gs5A6z7zBHCLfUQr4BsMDB7p/4EW01XSZWMVhswz5Kf3yY3/OG1dIU9YdR2EwMlBLGCAE6g8IYPYmQRSLTLn5aPoHp0XBbg3h251mQ+cNqPybuTkRZ6niyZlEYZKfXxH/NxfM5E3RatYar223QyRxZfLQTm+dY62uiTjUoTDEzI/mzZFsRp1HK/OEwZxprhboBNbbJvjHlk6LFDpfE0MiXYFKXBKdcuWcKY4AxkjMLTDjcjA9g/KYfEmU5mUjy0ejOPNDF3S1mzSEwAbx90CF9KpyxWcxNsTKmmZMLOMsuST6WDziJYfZWL+wE0fnA2YgGyrSzylTc63sIhosEspmQJyIy4VfQ2gjEC5bDKJqhNrc5N4KnzBlNZ/tbwUlKCYdidKuFKi7pa+7/BGfGfDqV27b2LWUCm2xf9o7WqJpYYdlJxZt+Kdk7lgdjIppzVr/GpGuZ7kPfVM8ejjzKIHiPkSxjiljCJwvRJpl+GnFJ8tc0LbzADu3nbH8NMjc/v+vQk6MjlHr4a08mq3/+E7aVRVbE9e0Sse/x1DVBK1vYc81caL68a31F7FC1xCObVL2mpRebQ1pv6Uq9+KIjJ3IDwj6Ml5BYR/uqv/PY49S8IOgeal76IPex MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 348f4ecf-a441-4957-5041-08d47f1ce64f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:DM2PR03MB400; X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB400; 3:0ILkSuqES1WAzuI+xkO9McTt4CMygsM+tx2qhFNFLqWlRuQJaalqks4C5MKSpbZDNpeQoc6cwLVfG6cGIN49vHdBtCFYr3KC7PGz9EtT2iRvjaba65RkUBNSr/PF8/BnPaq/2MY3unruUQaTwWx2+zUWQmw1bYovXrlmUatJSOmpzndtdYcOrFplcgKeEu9vIeR041ZBJcWqorJFHcQx5WFZq7D6CNIJm3Tt/8Mt4XCwyrH/tSTwg/sIj/qpMP6AjEMryPpDD7uDoO8+zlAb6LvUnRz3bqmF2A8IhTvm8JCcc9RlkEtcW22gLHVfGRjU+3YWo+nYqcHVAFHjCKs4tEmfMdBjxs2XQj01VkmuVXWD+TaAIh4Zd0+9ihp8zF4gfIFPk5nMpoEtquESkrAZ1hARiMcXFQt1u7+3DJ3CDYwcfbs7HKZlV9pP8yLLRCVm; 25:P9lxJCQVOKFSYX7xdH6jYp03pyO3ipegZmfX45umRuqeld/Xp7XtTYUBoBT0Cfs56ne0NMXtxLdtctY6cQTcB+53TFVyi3m52Or3GZ1UVwwhxa99Vv3pF9ef3ic+P9mtSHcARjkWh7hQYbrAZuHrJ6Y8NC8mMSvAAMlj2jSXwn4pQzXhuOer4MFnEMCRYlR1N2L9WfcstiwuzsVh6uFjmxnb1wclF2OqAvN4dPFlljCDvijvGQHmVBJw8oelhoyAn95h7G2CkGTsQtnnA8B5LFj1v3c4RAh/Xt5GNM5arNuF63hHok45Xu7zHm66FDs32bi5Onz8TOQX0RyT7HulOJGgLAwONydjK4Xncf0TlDyu/jTNg/nCtPCtzDap/XluYHhnEBcTSz7Hn3sNDW/GjRZR4rM8QgiDty8HMi4jn/Yp4oiDdYFJJZRe+55wM3T0dmPRwhk8U9fK+WczpRORsQ== X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB400; 31:GBNpPFTjMo7FT0FLp34FNSG8VV9IWq7Nkq3MG67eUB+sFwTL57wAfAnRF1thr9hT+3p8Ty4z98Fr++nkDhrGtIkesrZnr9N6JuIv2wG9NyXFe4BXi4oqHu83Iyfzthwc4yT+OOqlk/gwoOdgWeE6jHUSvWXLz+AxRZ0n0HuTzORBD8W9IYiIw3U7OuAENVLTWoNdG9E8bNw5Ky1j9K8/J692E9JPZJMdmPZh7xuvthHPOd/4+hBC7LKuVfIQ4owZ8WWoVgu6cd84hZgpwb1mKx01zGmoBA6eBl0Y1sUOfQ0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13023025)(13024025)(13018025)(8121501046)(5005006)(13015025)(13017025)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123561025)(20161123565025)(201703131430075)(201703131433075)(201703131448075)(201703161259075)(20161123563025)(20161123556025); SRVR:DM2PR03MB400; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR03MB400; X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB400; 4:GCFH+/9if+uS4FcmrdKj5UCnopJXbS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YEzjbeQLkd0G5YZ9IhoVbvCrq8y/ddU7GZ2XP4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB400; 7:/p1VWoNFqPKVNMdXUlZTt7leLg7LK0HDOso6c5GFfDGlgnJnCM1+e7VdYY1+Idi/niCZLLXuH2x7Q+fdazMtuQ6fBiLRB977P3vfuOLIkwhUxgUaD1hbLYjASseCB8O9YoRYAQrDwMUlaTXedMd1pBf/J6Ps9Q+VCQ3zKlW3WGUhozeOfNX4PivTc6OjiEvfe5ZnFZZ2thW4sdVxuapqRU0cki+9COGRhMhfd0bUMcNLFv/gzlUFRtQOZv3rmxGb8xZLIknLI9m40Uwcit3NDJozq4HBKljJCJzyc7E9SKAMuWh1LdpDvikDCfUmhPF1ChUkGEW+kl9TBHu4D21kGw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2017 07:49:06.3979 (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: DM2PR03MB400 Subject: [dpdk-dev] [PATCH v3 19/21] 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: Sun, 09 Apr 2017 07:49:11 -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 b405af8..41bcf03 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h @@ -173,6 +173,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); -- 2.1.4