From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0068.outbound.protection.outlook.com [104.47.41.68]) by dpdk.org (Postfix) with ESMTP id AA516FADE for ; Fri, 3 Mar 2017 08:15:06 +0100 (CET) Received: from BN3PR0301CA0084.namprd03.prod.outlook.com (10.160.152.180) by BN6PR03MB2945.namprd03.prod.outlook.com (10.175.126.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Fri, 3 Mar 2017 07:15:05 +0000 Received: from BL2FFO11OLC004.protection.gbl (2a01:111:f400:7c09::188) by BN3PR0301CA0084.outlook.office365.com (2a01:111:e400:401e::52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12 via Frontend Transport; Fri, 3 Mar 2017 07:15:05 +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; 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 BL2FFO11OLC004.mail.protection.outlook.com (10.173.161.188) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.933.11 via Frontend Transport; Fri, 3 Mar 2017 07:15:05 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v237D50g005035; Fri, 3 Mar 2017 00:15:02 -0700 From: Hemant Agrawal To: CC: , , , , , Date: Fri, 3 Mar 2017 18:16:56 +0530 Message-ID: <1488545223-25739-40-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1488545223-25739-1-git-send-email-hemant.agrawal@nxp.com> References: <1487205586-6785-1-git-send-email-hemant.agrawal@nxp.com> <1488545223-25739-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131329989054475653; (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)(39400400002)(39850400002)(39450400003)(39840400002)(39860400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(33646002)(38730400002)(8656002)(110136004)(4326008)(626004)(36756003)(92566002)(53936002)(5660300001)(305945005)(6666003)(2950100002)(6916009)(189998001)(356003)(54906002)(2906002)(48376002)(50466002)(2351001)(50226002)(81166006)(8676002)(104016004)(8936002)(47776003)(5003940100001)(76176999)(86362001)(50986999)(106466001)(105606002)(85426001)(77096006); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2945; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC004; 1:utF1h8Zec1Z2InY9DQ809pJKOJJQQLiXI6sc4nK0k0xEd1d7sR3olqm4Mw9CN7bputY2YTs+LNF/phsd9GJCmYafLQw2vM15QjEiyqS+Yae2INYYxIz4FpokJkb23QgeMFipjNPBF0K8pygtQqwJykOG7JbFqpnu2sQqEuCrQybijVnXNKH8lGOKTKFBdrEGsd5IbKXZ52V9MtRfz5ixVD9SjIeApU4k9BJwRKn2y0d5N39m3BSvtY1qjImoXgYMob6hNY1ieWyFL/UOKbUoT+AjbIzLoKMUePrjYbQzlNE47hCtUHzSGTCY/hYrM08tS4GAMoTQHbr8JnVrNZzLV6HJ8Bd3IsG2kZuj+d/c+noqGEcEJvcYx6TPlvi02YgEyFGY70d5pfBzRjsl4QzSSKC/DsHa+RVvFkpoSXUvS35r2Woyjmp++WxHGTli/EgqU7H2hs59e42VKbpW+AmDae2MqktqHD/GFibKJLXNVtAKqCdIM9BI3AKoXZCRBlTqPDUoNnR7LseSu7WyZXnYBIW3oFwouclYYztxlVZ36DPZvyjXz7UTIrsCm7jlb/ZRvmSTwSvieb1ATAOV4LfupP9cPpWbiv/a/N6LdQQg02ztSdDEwa5bP5NtONNer5am2NZBHv7wFq2672R5eHJBpQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ce2a74be-df5d-4ab5-4152-08d462050454 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR03MB2945; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2945; 3:6T13CK6ftm6uGwOxUQcj1T8jfqjGH3kNujHpgWhZwAb9PgmBk4vm0ggcFsv9i1gTkj493kxfsZbZvPBHL/gXNsEhsapAvcHzG24oI9axHuv3p4ZVCYnQZWlJjbtdd7qcpPliUyElCyoUgvNRzhMrBwVDESCnJ4Wo77mctvsUH1okTtWnBppNe6AH7O2t07dnGoA0R3OQP322rbM+deaGol/cNJZM0I+OXxYKwyMEd6iJJp+tnb5iYGbw7CPtSXxd6enp5NB+w13Nf5XdfjXyYJFqebSm4ZNyW5E0zwFBt2DnA8A59GHaQgZowQ/OlS3pvtMMewmky1DJkAG+NPi438kOt+jZkFl7jNN2N3w2bPvHs3ubFL9MOppm1fXJOveV; 25:ays9RIIH1l1BjSksKupgidoARzm8XHCXjCZctp/l2vK3WFFnim0q1DQccC78eqFKnM8y+xt1qpxy40qN//bXuO4753wd/Q3xUqMZ3ZEYUjFF9jyVh9B8PLh7Sj7L6SzGCubQcZVfx0Yxq4X/+x3wC0OscHff+/WoxdsXCE6iRnXd6Rc1VS0zhkl1DktRbnnEDglOYp5uPdVJ3U/QCBVegMi0Ogr+zatZwGEy6t28/mcfkwu/jfx5G5UhV2b22dNXkJcbr7guI+a4g1smS8QvxqVzvXdLBmZ//NXiJNxtwk2lws9Abij4SfAU/QbTK+BY82Tn8Gz+MzWwS0KhqpX66r9qCBZJhQnornk/DmZiE1eCSBCvqIaHuwDwzMOnbuLZRQYqp9Sh/30mKfPWIMty7duNJ4tivpujqudKKxf1Ng965Y/Lzl2408Vx0S1rWG/6LpuLH9r6fNm08VLEehu2TA== X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2945; 31:hD6zXw21C6LR6ne1vYZQEdUie+A0sLNdVx0a1rCP3gOw1mk5a3rcgTpZtK+hbhYuyumkQUuwkDu5nWTXQcJLr4znikLyYNuVAl1uVy+BvApXkK4e6ha1QLdyFADnpLLV8iETy1gAXkWsZ8iBak+EO2Rgg7mhN3tq0dhI50lLqwPtiUT2SPoNsnNyZ8mcFBjW9ruDztaud595V3DZchDoFOiRycsiyAiPds5HiXrrml6GD+7I84CCkANgStkCtMmWijw6VGDCHEOEGonUOh36Zg== 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)(13017025)(13015025)(13024025)(13018025)(13023025)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123565025)(20161123563025); SRVR:BN6PR03MB2945; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2945; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2945; 4:YhJvqis/E9yHAzn+G3DGTd+vqwRYWcdByVKWmOw3ksQ6/KkwF61+D29KMWpmW2Uu5MhU+rr9c/tVoOEdBBVE534tmpX3qhjzZ4i/ZllCYDZyt+BUR7he5TQ5CdB8geIb/FXcizFLGSBlyaRHgAvKIDGLeFV4YQCp2Y6r3ImalgG+lzh9Y05lCzw1Ol6kXcjkfd931RMlfbGfE6TZKj4jpAcMFHJv4KsAevpUvIHwL3Bdc3u2PaMwr1s4VDK2RRKvslmasAIk/hTj6cRWT4OSd0gA9brH+i7j1xssQtYUULk6Qgo31+7jXNXfnogruyMUMDMJKjSKc00bb/ISpMHSGXwVVi9stIsCEDfyPr4aIi5H2LFhBrwS3bfiL8Es4o/QMayxDfAlC2LNilhZaRCwUwp+HxA7paVCv6plDhiWRfPjYgJ+5zboQb55v+rBw870NGiGqeHslANSBdsJiSDQQ+CuOP5hbQW6gaRU9FQg9SoMo3klA3yCtvqFoaJZdESSg3vqZWn4Rw5WXdDcRv0cH3hT5jIe9Dv18pkirgqIa0DtmBESz3mnpKIVvehkchQdKwybIc/b1bdmzH1wA1z2sASYmYQ6GR2k40bb9zkdybAtlWCYsseeUZ+ZHyoJ30jJzd65H0fHg7Me0A6jW+0T/Fsi0bL2Vnkb64wIWZCzPy258RYc9mUgYp6otOd69BM5FVp1/6TuvyrBO4lSeLtmPG2j7vVBQ4855bDj7nyckqsndsAW5qw0rEWiAmRcHXQL0gqavDIekM6bxX1B1I+jLg== X-Forefront-PRVS: 0235CBE7D0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2945; 23:+agUKxHwS1wPEUfNSOP361rD4hzRzuITXZlhhDcw2?= =?us-ascii?Q?JoseP1bwT+JbfoIKruIp7lLxCT5hq0MsCZDmz3QU0Q31orE+ITajVVwkhBNg?= =?us-ascii?Q?2QkxexS/WMNxw0OsA4UH0kt/tU2aD9NROfPlg9ApPh7NXcpSTRgts7paez49?= =?us-ascii?Q?P9Zn8JQLS4eap1XvzpFARaRX/FpB8+PxnvLi7NVmiEKm79N6WROs1pfZWPC+?= =?us-ascii?Q?RhdV8zptyzTJUlueFk6bLlWGglZLl6fqsIgqjfKQWIW8Bhz/G54u9SBEBwpW?= =?us-ascii?Q?EG7xELNRloMBGXWlyNjWMiU3RFHWwjFM+oS9Z5L6AGDY1jJz+JRasQ2bqiER?= =?us-ascii?Q?yt5K8+A8vIKjEPLl91/B42Lwzyacx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?Q?gmRp2/iEb3mQz94WYUkyd9EVHBYqspzXNp5IZjr?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2945; 6:GOUTLUBkHgqAZhUecrMBMW5dxyhoJnPLrMUTJh+eM1xM8Ph6uY4n1oESTTCRFYPAJNzBtQDh0z+XR8AqfhfNBipdmKwY1Yz0C4DV9EjhFuSfN7yaokb33Z9qxSembXN4HXu3GZ3gf1kE1bBvTQCMlq7YHe/I89HqE/EVco2OwthzZKZtQna588C/vIfjLrHWx+Sq8389Ym2PePmyzWE59cqbJvrcEa5dCqY5knmf4NWTzxGD85SxvpqjtLy9UlhiHO/gL6umnr3RUSYxEMT8TMsvhmIPOjU8351FeFQ6P6lNHUV6XKKtwXmgtPaf4vzWMs9/gws2vltOejpULHmLiQ3PrW3jB/haFZRepuM6nj0q5eaRc1plMPbCBGTyh7CP3HxgAQxy1sFchnY0Lc05mW8LCZbJcf57bXHKVbBGC2o=; 5:vAy2KmzbT6S6xI5zanKYlkMBjnKEc4XnjF5pPc2+qwDyPFN1QgmdjHZdhev+Hbx/IMrqbzSiuve0a5nrD5X8/gh4JqnskDkK51W7UOeBB7W3ksIhD4ZvrZV5iJNFs0xfFsq7G8ztSvemVKYNVGpZD+GdeGrIJBLggNkg5odnNBmr6b0lf3W4AmTQ6qSAD7CL; 24:Ej+3D37tm6B9yx9H8em5bKFR4GKI0qr9yHJ9oLUYZXUkVuSCDGdSeO8Bcr5nE2hwC0wyb345BfF10m9iQDEYTlru7Qc9lGpCTT/Rg++f3uw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2945; 7:9OcAz6VPPsdGrAbAa5ZerOD5BPkbidnwYLxqipQyMdAEsYQHMhBil7iBT28E/f8faei/ztR9o16YarV9lp6sMEiS+nqDWme2CPVpM01UfCgyI/KdeUNhur7wBbYpaaTDyaAy4XNcT+78ckIZTOMXUm4lTwipS+T0SIoVxToRgH6BGGON5nCb7qtSPoxNkQnibrCBh+8ydXx+Gs8hZHTqSRdb4UCnEUuPHFv4hoLXoe4HGEdtXn97C5f8pBdFTaqQfS52p1++f9zK58S4hnA5q6lt0Vd7hJS82hgy4bHpb1WfAPHqXBXw64ilQKQnIBKYyPmAP9gev6lfqyVXbgjldA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 07:15:05.1355 (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: BN6PR03MB2945 Subject: [dpdk-dev] [PATCHv8 39/46] 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: Fri, 03 Mar 2017 07:15:07 -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