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 80309A0C4B; Wed, 16 Jun 2021 21:13:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 470EB40683; Wed, 16 Jun 2021 21:13:39 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 267EC4067A for ; Wed, 16 Jun 2021 21:13:37 +0200 (CEST) IronPort-SDR: KIVTlEgvvoOipO7vDkSnjJFWihO6IkjxQQLObjxE//WTMGAeGmyek0muY4DficAunILbhLDA8q Abgby3bfjEdg== X-IronPort-AV: E=McAfee;i="6200,9189,10016"; a="193363589" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193363589" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 12:13:37 -0700 IronPort-SDR: gCoBxIwTnm/e2+v6TtgXyKq5G+FIslaewSTjpw6BGxUfJluL3ryU2S0ITacJM1vOCLi9KkRgrw CoruylLpHCwA== X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="404403515" Received: from mwhelan-mobl2.ger.corp.intel.com (HELO bricha3-MOBL.ger.corp.intel.com) ([10.252.12.169]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 16 Jun 2021 12:13:33 -0700 Date: Wed, 16 Jun 2021 20:13:30 +0100 From: Bruce Richardson To: Jerin Jacob Cc: fengchengwen , Thomas Monjalon , Ferruh Yigit , dpdk-dev , Nipun Gupta , Hemant Agrawal , Maxime Coquelin , Honnappa Nagarahalli , Jerin Jacob , David Marchand Message-ID: References: <1623763327-30987-1-git-send-email-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [dpdk-dev] [RFC PATCH] dmadev: introduce DMA device library 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" On Wed, Jun 16, 2021 at 11:38:08PM +0530, Jerin Jacob wrote: > On Wed, Jun 16, 2021 at 11:01 PM Bruce Richardson > wrote: > > > > On Wed, Jun 16, 2021 at 05:41:45PM +0800, fengchengwen wrote: > > > On 2021/6/16 0:38, Bruce Richardson wrote: > > > > On Tue, Jun 15, 2021 at 09:22:07PM +0800, Chengwen Feng wrote: > > > >> This patch introduces 'dmadevice' which is a generic type of DMA > > > >> device. > > > >> > > > >> The APIs of dmadev library exposes some generic operations which can > > > >> enable configuration and I/O with the DMA devices. > > > >> > > > >> Signed-off-by: Chengwen Feng > > > >> --- > > > > Thanks for sending this. > > > > > > > > Of most interest to me right now are the key data-plane APIs. While we are > > > > still in the prototyping phase, below is a draft of what we are thinking > > > > for the key enqueue/perform_ops/completed_ops APIs. > > > > > > > > Some key differences I note in below vs your original RFC: > > > > * Use of void pointers rather than iova addresses. While using iova's makes > > > > sense in the general case when using hardware, in that it can work with > > > > both physical addresses and virtual addresses, if we change the APIs to use > > > > void pointers instead it will still work for DPDK in VA mode, while at the > > > > same time allow use of software fallbacks in error cases, and also a stub > > > > driver than uses memcpy in the background. Finally, using iova's makes the > > > > APIs a lot more awkward to use with anything but mbufs or similar buffers > > > > where we already have a pre-computed physical address. > > > > > > The iova is an hint to application, and widely used in DPDK. > > > If switch to void, how to pass the address (iova or just va ?) > > > this may introduce implementation dependencies here. > > > > > > Or always pass the va, and the driver performs address translation, and this > > > translation may cost too much cpu I think. > > > > > > > On the latter point, about driver doing address translation I would agree. > > However, we probably need more discussion about the use of iova vs just > > virtual addresses. My thinking on this is that if we specify the API using > > iovas it will severely hurt usability of the API, since it forces the user > > to take more inefficient codepaths in a large number of cases. Given a > > pointer to the middle of an mbuf, one cannot just pass that straight as an > > iova but must instead do a translation into offset from mbuf pointer and > > then readd the offset to the mbuf base address. > > > > My preference therefore is to require the use of an IOMMU when using a > > dmadev, so that it can be a much closer analog of memcpy. Once an iommu is > > present, DPDK will run in VA mode, allowing virtual addresses to our > > hugepage memory to be sent directly to hardware. Also, when using > > dmadevs on top of an in-kernel driver, that kernel driver may do all iommu > > management for the app, removing further the restrictions on what memory > > can be addressed by hardware. > > > One issue of keeping void * is that memory can come from stack or heap . > which HW can not really operate it on. when kernel driver is managing the IOMMU all process memory can be worked on, not just hugepage memory, so using iova is wrong in these cases. As I previously said, using iova prevents the creation of a pure software dummy driver too using memcpy in the background. /Bruce