[dpdk-dev] [PATCH] eal: add option --iso-cmem for external custom memory
Burakov, Anatoly
anatoly.burakov at intel.com
Thu Oct 24 13:43:50 CEST 2019
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 <rajesh.ravi at broadcom.com
> <mailto:rajesh.ravi at broadcom.com>> 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
More information about the dev
mailing list