From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id BFD885B32 for ; Wed, 14 Nov 2018 12:19:10 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2018 03:19:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,232,1539673200"; d="scan'208";a="104280536" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.124]) ([10.237.220.124]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2018 03:19:07 -0800 To: Shahaf Shuler , dev@dpdk.org Cc: olgas@mellanox.com, yskoh@mellanox.com, pawelx.wodkowski@intel.com, gowrishankar.m@linux.vnet.ibm.com, ferruh.yigit@intel.com, thomas@monjalon.net, arybchenko@solarflare.com, shreyansh.jain@nxp.com References: From: "Burakov, Anatoly" Message-ID: Date: Wed, 14 Nov 2018 11:19:06 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [RFC] ethdev: introduce DMA memory mapping for external 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: , X-List-Received-Date: Wed, 14 Nov 2018 11:19:11 -0000 Hi Shahaf, Great to see such effort! Few comments below. Note: halfway through writing my comments i realized that i am starting with an assumption that this API is a replacement for current VFIO DMA mapping API's. So, if my comments seem out of left field, this is probably why :) On 04-Nov-18 12:41 PM, Shahaf Shuler wrote: > Request for comment on the high level changes present on this patch. > > The need to use external memory (memory belong to application and not > part of the DPDK hugepages) is allready present. > Starting from storage apps which prefer to manage their own memory blocks > for efficient use of the storage device. Continue with GPU based > application which strives to achieve zero copy while processing the packet > payload on the GPU core. And finally by vSwitch/vRouter application who > just prefer to have a full control over the memory in use (e.g. VPP). > > Recent work[1] in the DPDK enabled the use of external memory, however > it mostly focus on VFIO as the only way to map memory. > While VFIO is common, there are other vendors which use different ways > to map memory (e.g. Mellanox and NXP[2]). > > The work in this patch moves the DMA mapping to vendor agnostic APIs > located under ethdev. The choice in ethdev was because memory map should > be associated with a specific port(s). Otherwise the memory is being > mapped multiple times to different frameworks and ends up with memory > being wasted on redundant translation table in the host or in the device. So, anything other than ethdev (e.g. cryptodev) will not be able to map memory for DMA? I have thought about this for some length of time, and i think DMA mapping belongs in EAL (more specifically, somewhere at the bus layer), rather than at device level. Placing this functionality at device level comes with more work to support different device types and puts a burden on device driver developers to implement their own mapping functions. However, i have no familiarity with how MLX/NXP devices do their DMA mapping, so maybe the device-centric approach would be better. We could provide "standard" mapping functions at the bus level (such as VFIO mapping functions for PCI bus), so that this could would not have to be reimplemented in the devices. Moreover, i'm not sure how this is going to work for VFIO. If this is to be called for each NIC that needs access to the memory, then we'll end up with double mappings for any NIC that uses VFIO, unless you want each NIC to be in a separate container. > > For example, consider a host with Mellanox and Intel devices. Mapping a > memory without specifying to which port will end up with IOMMU > registration and Verbs (Mellanox DMA map) registration. > Another example can be two Mellanox devices on the same host. The memory > will be mapped for both, even though application will use mempool per > device. > > To use the suggested APIs the application will allocate a memory block > and will call rte_eth_dma_map. It will map it to every port that needs > DMA access to this memory. This bit is unclear to me. What do you mean "map it to every port that needs DMA access to this memory"? I don't see how this API solves the above problem of mapping the same memory to all devices. How does a device know which memory it will need? Does the user specifically have to call this API for each and every NIC they're using? For DPDK-managed memory, everything will still get mapped to every device automatically, correct? If so, then such a manual approach for external memory will be bad for both usability and drop-in replacement of internal-to-external memory, because it introduces inconsistency between using internal and external memory. From my point of view, either we do *everything* manually (i.e. register all memory for DMA explicitly) and thereby avoid this problem but keep the consistency, or we do *everything* automatically and deal with duplication of mappings somehow (say, by MLX/NXP drivers sharing their mappings through bus interface). > Later on the application could use this memory to populate a mempool or > to attach mbuf with external buffer. > When the memory should no longer be used by the device the application > will call rte_eth_dma_unmap from every port it did registration to. > > The Drivers will implement the DMA map/unmap, and it is very likely they > will use the help of the existing VFIO mapping. > > Support for hotplug/unplug of device is out of the scope for this patch, > however can be implemented in the same way it is done on VFIO. > > Cc: pawelx.wodkowski@intel.com > Cc: anatoly.burakov@intel.com > Cc: gowrishankar.m@linux.vnet.ibm.com > Cc: ferruh.yigit@intel.com > Cc: thomas@monjalon.net > Cc: arybchenko@solarflare.com > Cc: shreyansh.jain@nxp.com > > Signed-off-by: Shahaf Shuler > > [1] > commit 73a639085938 ("vfio: allow to map other memory regions") > [2] > http://mails.dpdk.org/archives/dev/2018-September/111978.html > --- -- Thanks, Anatoly