From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8085AA32A2 for ; Thu, 24 Oct 2019 13:43:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D779C1E87A; Thu, 24 Oct 2019 13:43:56 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E38D91E56B for ; Thu, 24 Oct 2019 13:43:54 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2019 04:43:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,224,1569308400"; d="scan'208";a="210139439" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.252.8.129]) ([10.252.8.129]) by fmsmga001.fm.intel.com with ESMTP; 24 Oct 2019 04:43:51 -0700 To: Rajesh Ravi Cc: Ajit Khaparde , dev@dpdk.org, Jonathan Richardson , Scott Branden , Vikram Mysore Prakash , Srinath Mannam References: <20191015053047.52260-1-ajit.khaparde@broadcom.com> <83009bb3-1e0c-a22e-eff8-41a437817cb7@intel.com> From: "Burakov, Anatoly" Message-ID: <64edebee-3686-beca-2b30-c6ec1f26c162@intel.com> Date: Thu, 24 Oct 2019 12:43:50 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] eal: add option --iso-cmem for external custom memory 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" On 22-Oct-19 8:56 AM, Rajesh Ravi wrote: > Hi Anatoly, > I tried calling rte_vfio_dma_map() but, it  failed for me because > > vfio_dma_mem_map() failed with error:VFIO support not initialized > because: default_vfio_cfg->vfio_iommu_type=NULL ( container_dma_map > calls vfio_dma_mem_map  with vfio_cfg = default_vfio_cfg ) > > call sequence: rte_vfio_dma_map() -->container_dma_map() > --> vfio_dma_mem_map > > Regards, > Rajesh > > On Mon, Oct 21, 2019 at 9:16 PM Rajesh Ravi > wrote: > > Thanks Anatoly for prompt response. Sorry for the delayed response, > I took some time to reverify with SPDK. > > Infact, I do want the iommu mapping to be performed. I don't want it > to be bypassed by type1_map() > [lib/librte_eal/linuxapp/eal/eal_vfio.c] for external memory. > > Then, if I understood correctly, you suggested to call > rte_vfio_dma_map() as an alternative. > > _Context & clarification_ > > 1) We 're using DPDK to manage/allocate memory for SPDK through heap > API. > >   The only DPDK APIs we 're calling are: >   A)rte_malloc_heap_memory_add() to add external memory to heap. >   B)rte_malloc_heap_get_socket() & rte_malloc_socket() to allocate > memory > > /Are you suggesting to make a call to rte_vfio_dma_map() from spdk, > in addition to the APIs listed under 1)A & 1)B instead of modifying > DPDK vfio functions?/ >    Please confirm, Probably I missed the context and might not have > understood fully. > > > 2) .dma_user_map_func=vfio_type1_dma_mem_map() is called from 2 > paths in dpdk. In either case call to dma_user_map_func() is skipped. >    A) _During the startup, as you said before:_ >      rte_vfio_setup_device() --> type1_map() > >    B)During allocation event: >         vfio_mem_event_callback()  (type=RTE_MEM_EVENT_ALLOC,..) > -->vfio_dma_mem_map() -->dma_user_map_func() > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- > _Conclusion_ > > So we have 2 alternatives: > > A) make additional call to rte_vfio_dma_map() API after adding > external memory using rte_malloc_heap_memory_add()  API. > > B) remove msl->external check which bypasses call to > dma_user_map_func() in DPDK. > > I modified DPDK functions [Option B) ]. I guess you 're > suggesting option A) > > Please confirm. > > Regards, > Rajesh Hi Rajesh, Apologies for delayed response. I'm still not sure i understand your problem. When adding memory with rte_malloc_heap_memory_add(), this memory is, as far as i can tell, automatically mapped for DMA mapping with VFIO. This happens because: rte_malloc_heap_memory_add() -> malloc_heap_add_external_memory() -> eal_memalloc_mem_event_notify() -> vfio_mem_event_callback() -> vfio_dma_mem_map() VFIO registers itself for mem event callbacks in eal_vfio.c:rte_vfio_setup_device():791. So, there is no need to map anything for DMA when you're creating external heaps - it is being mapped automatically by EAL. For an example implementation have a look at testpmd, specifically testpmd.c:mbuf_pool_create() for MP_ALLOC_XMEM type. This calls testpmd.c:setup_extmem(), which creates an external heap. Notice how it doesn't do anything to map the memory for DMA, because that is already done by EAL. You can verify this working by adding --mp-alloc=xmem argument to testpmd to force it to use external memory for its mempools. So, what is the actual issue here, given that the memory is mapped for DMA by EAL automatically when it is added? -- Thanks, Anatoly