From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 70CF6A0547; Wed, 29 Sep 2021 08:12:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAABF410D7; Wed, 29 Sep 2021 08:12:43 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id E0A0C4068F for ; Wed, 29 Sep 2021 08:12:41 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10121"; a="224524662" X-IronPort-AV: E=Sophos;i="5.85,331,1624345200"; d="scan'208";a="224524662" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2021 23:12:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,331,1624345200"; d="scan'208";a="519660344" Received: from irsmsx605.ger.corp.intel.com ([163.33.146.138]) by fmsmga008.fm.intel.com with ESMTP; 28 Sep 2021 23:12:40 -0700 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by IRSMSX605.ger.corp.intel.com (163.33.146.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 29 Sep 2021 07:12:38 +0100 Received: from shsmsx606.ccr.corp.intel.com ([10.109.6.216]) by SHSMSX606.ccr.corp.intel.com ([10.109.6.216]) with mapi id 15.01.2242.012; Wed, 29 Sep 2021 14:12:35 +0800 From: "Hu, Jiayu" To: "Ding, Xuan" , "dev@dpdk.org" , "Burakov, Anatoly" , "maxime.coquelin@redhat.com" , "Xia, Chenbo" CC: "Jiang, Cheng1" , "Richardson, Bruce" , "Pai G, Sunil" , "Wang, Yinan" , "Yang, YvonneX" Thread-Topic: [PATCH v6 2/2] vhost: enable IOMMU for async vhost Thread-Index: AQHXtNyfe5Aqmd3Ow0K6bTEBAJi7+Ku6grjg Date: Wed, 29 Sep 2021 06:12:35 +0000 Message-ID: References: <20210901053044.109901-1-xuan.ding@intel.com> <20210929024127.15547-1-xuan.ding@intel.com> <20210929024127.15547-3-xuan.ding@intel.com> In-Reply-To: <20210929024127.15547-3-xuan.ding@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v6 2/2] vhost: enable IOMMU for async vhost X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Hi Xuan, > -----Original Message----- > From: Ding, Xuan > Sent: Wednesday, September 29, 2021 10:41 AM > To: dev@dpdk.org; Burakov, Anatoly ; > maxime.coquelin@redhat.com; Xia, Chenbo > Cc: Hu, Jiayu ; Jiang, Cheng1 ; > Richardson, Bruce ; Pai G, Sunil > ; Wang, Yinan ; Yang, > YvonneX ; Ding, Xuan > Subject: [PATCH v6 2/2] vhost: enable IOMMU for async vhost >=20 > The use of IOMMU has many advantages, such as isolation and address > translation. This patch extends the capbility of DMA engine to use IOMMU = if > the DMA engine is bound to vfio. >=20 > When set memory table, the guest memory will be mapped into the default > container of DPDK. >=20 > Signed-off-by: Xuan Ding > --- > +async_dma_map(struct rte_vhost_mem_region *region, bool > +*dma_map_success, bool do_map) { > + uint64_t host_iova; > + int ret =3D 0; > + > + host_iova =3D rte_mem_virt2iova((void *)(uintptr_t)region- > >host_user_addr); > + if (do_map) { > + /* Add mapped region into the default container of DPDK. */ > + ret =3D > rte_vfio_container_dma_map(RTE_VFIO_DEFAULT_CONTAINER_FD, > + region->host_user_addr, > + host_iova, > + region->size); > + *dma_map_success =3D ret =3D=3D 0; > + > + if (ret) { > + /* > + * DMA device may bind with kernel driver, in this > case, > + * we don't need to program IOMMU manually. > However, if no > + * device is bound with vfio/uio in DPDK, and vfio > kernel > + * module is loaded, the API will still be called and > return > + * with ENODEV/ENOSUP. > + * > + * DPDK vfio only returns ENODEV/ENOSUP in very > similar > + * situations(vfio either unsupported, or supported > + * but no devices found). Either way, no mappings > could be > + * performed. We treat it as normal case in async > path. > + */ What do you mean by saying "vfio either unsupported"? Does it mean platform doesn't support iommu? Thanks, Jiayu