From patchwork Thu Dec 27 06:23:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 154565 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6606313ljp; Wed, 26 Dec 2018 22:26:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/WUbhLUM60ThFeNQqpNFmbBkQ9L2WI5vNT0Lx7lrlXB2C/StVTOBWYDWJ4P2ua8S0kSv24m X-Received: by 2002:a1c:7a16:: with SMTP id v22mr18956025wmc.131.1545891987902; Wed, 26 Dec 2018 22:26:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545891987; cv=none; d=google.com; s=arc-20160816; b=bm5+BuR+V3xXpDWoIsP8ZtJAjRvyIdpYE9RM4iX1Ogod0tdxEGd+nsv4M4H7i5ZK1J 2YBOh0zZMuPo3sxWmQyCu6bUb/YQdUtLvkrECgSOC84Jo229i/0o1/RyacdfaAKCNcd9 yQYj4yDBbx8uy6hg7EzdV9rZ2n6cRedMNtTZk3+/sQ0Tn5LrRqDOn9W+ZSfAQYHbe6Fp +EbvXvkhE9b1FAyzPwsNiY+Zay4A0Z9NT/sc6CLS9ZRXKxX/L+KlBzqkdy8DF7g7qx7S XoM+q806wBGG0vhc9XUEoB25PdjnEljk6eS0tkliQNY+UkAgNt3ZZPPLGY126rC4m2/J WZPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version :content-transfer-encoding:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:cc:to:from :dkim-signature; bh=mxbYGZFRdATfKdI4q+52DKlAgIfXLpKWmaVRjjfTUzs=; b=K4Q+Oshoz8c6a813Hk5rYz86ZST+qJBmrFpWlIzk88uj6m0oO111Wq5Wk/ZHaMeyYc w6M6BbP6TTUIinApWVYjZYhnLKtpSmCNZPOS3NoBaQBFmtjGEZjPD17K5Tc4QqPWUYhv rF1Jj/Hdt9fT10+PmeCHrxVU5bbPzWHFkssCq4LfB38dtfMW3qIxAqetnids+Kl09Ns5 PsZAcYTbsMS3PPvOGCSgE1KDiXR53cxcnVZlOi+zdJjznfCIOVm0zApvT/rGBCBUeqjF gqqZmEh9kVzPHr8Jbw2H0FNee4eSI0u2pMuvnS1kTDceW48tamyeJA7FsyfxnGtKa128 7lXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nxp.com header.s=selector1 header.b=D8bPCHuV; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id n131si17566838wmb.30.2018.12.26.22.26.27; Wed, 26 Dec 2018 22:26:27 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; dkim=fail header.i=@nxp.com header.s=selector1 header.b=D8bPCHuV; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 599091B108; Thu, 27 Dec 2018 07:23:38 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50081.outbound.protection.outlook.com [40.107.5.81]) by dpdk.org (Postfix) with ESMTP id C41F25424 for ; Thu, 27 Dec 2018 07:23:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mxbYGZFRdATfKdI4q+52DKlAgIfXLpKWmaVRjjfTUzs=; b=D8bPCHuVkXUv3Lsym0owm1u4Y7gYktcCQidE5dbAMJwu8miGoxqoXOA4X7cGM4BDBFwbONBlcT/m9WF21+2sJ535X90Wlt0gqBGdYosjD5AlUC3/jCst4c7TJz6Nz4YgxIztAJQssWfH1WOYFRKFEIbW8OhepMGhXHV357jL9ms= Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com (10.168.65.19) by VI1PR0401MB2285.eurprd04.prod.outlook.com (10.169.133.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1471.20; Thu, 27 Dec 2018 06:23:21 +0000 Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::555e:164:f8f0:dbb4]) by VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::555e:164:f8f0:dbb4%2]) with mapi id 15.20.1471.019; Thu, 27 Dec 2018 06:23:21 +0000 From: Hemant Agrawal To: "dev@dpdk.org" CC: "ferruh.yigit@intel.com" , Shreyansh Jain , Pankaj Chauhan , "M.h. Lian" Thread-Topic: [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO Thread-Index: AQHUnayq6dNh6ksZAkOb8Dh+m1inyw== Date: Thu, 27 Dec 2018 06:23:21 +0000 Message-ID: <20181227062233.30781-21-hemant.agrawal@nxp.com> References: <20181227062233.30781-1-hemant.agrawal@nxp.com> In-Reply-To: <20181227062233.30781-1-hemant.agrawal@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [14.143.30.134] x-mailer: git-send-email 2.17.1 x-clientproxiedby: BM1PR01CA0120.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:40::14) To VI1PR0401MB2541.eurprd04.prod.outlook.com (2603:10a6:800:56::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0401MB2285; 6:mujg29rzIAPTQfVodti7yAl1gKTM+4igNUrfkCyptiWb+4mZ0Zf+RBqAI++jSSQLMi08G+nwmNJRiKIxhvt9YAGtlbCzhtIMZt2xOPKLsa2jGsMY89eOriaAxlAHInIpp9X/+3UdtF29C0wOkKWvKhvSMgKLtkRXoCqZjO6173eDIuATv1K7OgKxwerTdQFIY0ifEh245Ux1Y1Z+xu3WW25470Vpbb68ccd/X3QlvE6sBcLEGuSLP29nOtHHMwZsuTsWYdB+SEZTG4kKy3Kmip5DZG/d/RKfMWFPbHh1iSu2tBKW5ppEedqG8mFPP7dWIPZcwZTIDW8kvmKPqiPLEmp//TAnd07583pbv6bpB3T4BHJKAV+0PULVnSdQZK2FwQw9WIzukGOZN4LuFKpYRkDvmTqTLn/chs4cTD4hs8u0WZipizqx4OxCj7Ztox7G63nZwcp4WMNQz4dnmgR27Q==; 5:AbjpgOdEnWMFbTdcOgLzybctSPxBeQzMb1Rtm4WjtiqAhvl4vgeGyHrOcqLifdjw5PnzOsY7JAUSEwzP3fjSmVhMSnUhBehV18uJQfaHv9BK2MHri9SvykpgimZpw8yAexcRPx5p/Y08APKC/FOAcXuRs+0nh40g3hy/EIwxYQU=; 7:cc16qnzUL18bxjaEL5TIfhBDNN72Mkin/38ntVLoZauaY1jtHDgqM3bcSG8Ojz+b4Agu/eN2F7FQAQLAcykqCXhPQBo0+Rox69PmRBtDlrC3rIkHXt6O7W4SMhbD6MSoGtFR1Jr7fDSA+lGfPc1rng== x-ms-office365-filtering-correlation-id: 4c05e7a7-afb9-4d7d-7696-08d66bc3cc69 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0401MB2285; x-ms-traffictypediagnostic: VI1PR0401MB2285: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:VI1PR0401MB2285; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB2285; x-forefront-prvs: 0899B47777 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(346002)(376002)(39860400002)(396003)(199004)(189003)(2501003)(2351001)(6916009)(53936002)(36756003)(86362001)(105586002)(102836004)(6506007)(106356001)(386003)(25786009)(68736007)(4326008)(11346002)(26005)(446003)(2616005)(476003)(2906002)(186003)(66066001)(5660300001)(256004)(6116002)(44832011)(3846002)(8936002)(6436002)(54906003)(81156014)(316002)(1730700003)(97736004)(8676002)(81166006)(50226002)(99286004)(71200400001)(71190400001)(486006)(78486014)(305945005)(76176011)(52116002)(6512007)(55236004)(6486002)(14454004)(7736002)(5640700003)(478600001)(1076003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2285; H:VI1PR0401MB2541.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: L8cEGMPiLVtQ7iQz6rYielPPwOWW5kt2RQrLXztviJFGin9lDeZiz3Qp+EYYd4RwEvY1ftp5T86IKe9APod+nCoh+X6gsAvGjrif0K8n2pCX6TaGKI6ObAahciQYV3KxYwZ0wZs0SBhhVJO+6ZL9521fQMruT/RzEP/ZLtzJ9MXKq5ETTJ4KAy41rQb2E2Gt2ZctjlOdSWBxbMlRCiGxk51soESkqyvHnhuaRLUHdQT7Le9piqstzxmEKEi2nnZjTSXWyGAwpglqivdOPzpoPMh6FeVp9zd6ehu3F6a6TN8lO6guwrTAcDDNIGK/OiuZ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c05e7a7-afb9-4d7d-7696-08d66bc3cc69 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Dec 2018 06:23:21.4887 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2285 Subject: [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pankaj Chauhan This is required to map any accelerator memory and PCI address to VFIO using QDMA. Signed-off-by: Minghuan Lian Signed-off-by: Pankaj Chauhan --- drivers/bus/fslmc/fslmc_vfio.c | 42 +++++++++++++++++++++ drivers/bus/fslmc/fslmc_vfio.h | 1 + drivers/bus/fslmc/rte_bus_fslmc_version.map | 7 ++++ 3 files changed, 50 insertions(+) -- 2.17.1 diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 1aae56fa9..9befc8087 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -50,6 +50,7 @@ static struct fslmc_vfio_group vfio_group; static struct fslmc_vfio_container vfio_container; static int container_device_fd; static char *g_container; +static int fslmc_iommu_type; static uint32_t *msi_intr_vaddr; void *(*rte_mcp_ptr_list); @@ -90,6 +91,9 @@ fslmc_get_container_group(int *groupid) } } + fslmc_iommu_type = (rte_vfio_noiommu_is_enabled() == 1) ? + RTE_VFIO_NOIOMMU : VFIO_TYPE1_IOMMU; + /* get group number */ ret = rte_vfio_get_group_num(SYSFS_FSL_MC_DEVICES, g_container, groupid); @@ -344,6 +348,44 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused, return ret; } +int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size) +{ + int ret; + struct fslmc_vfio_group *group; + struct vfio_iommu_type1_dma_map dma_map = { + .argsz = sizeof(struct vfio_iommu_type1_dma_map), + .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE, + }; + + if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) { + DPAA2_BUS_DEBUG("Running in NOIOMMU mode"); + return 0; + } + + /* SET DMA MAP for IOMMU */ + group = &vfio_group; + if (!group->container) { + DPAA2_BUS_ERR("Container is not connected"); + return -1; + } + + dma_map.size = size; + dma_map.vaddr = vaddr; + dma_map.iova = iova; + + printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr, + dma_map.iova, dma_map.size); + ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, + &dma_map); + if (ret) { + printf("Unable to map DMA address (errno = %d)\n", + errno); + return ret; + } + + return 0; +} + int rte_fslmc_vfio_dmamap(void) { int i = 0, ret; diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h index 9e2c4feef..4e750d623 100644 --- a/drivers/bus/fslmc/fslmc_vfio.h +++ b/drivers/bus/fslmc/fslmc_vfio.h @@ -50,5 +50,6 @@ int fslmc_vfio_process_group(void); char *fslmc_get_container(void); int fslmc_get_container_group(int *gropuid); int rte_fslmc_vfio_dmamap(void); +int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size); #endif /* _FSLMC_VFIO_H_ */ diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map index dcc4e082e..c4192d978 100644 --- a/drivers/bus/fslmc/rte_bus_fslmc_version.map +++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map @@ -129,3 +129,10 @@ DPDK_18.11 { dpci_set_opr; } DPDK_18.05; + +DPDK_19.02 { + global: + + rte_fslmc_vfio_mem_dmamap; + +} DPDK_18.11;