From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id B67CB5592 for ; Wed, 13 Feb 2019 12:38:41 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id w17so2063035wrn.12 for ; Wed, 13 Feb 2019 03:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=qD1Ra//QfyxtellHE++LFoQtSYp6MrrKEbuK4qKvC2Q=; b=E7AfldiJhN78ra+R5xrqNA2ZzGFZVdrEXPYUQVQoQaqEYX4hO4A4VNfjw4RAIY9Ulk CQXMDtzV0Wxfonq3X2HPPZkpdzTTfcUim/43VS3wOQfATiwapphecIHaOZMfAcQFK2vI 09cmwqkr7pTcq8iH94nRIUvRZKDQWedfQGpM1jhaymnASnymiTtOSCCcnyWhSu81S9Fh ETrI7gjqMmJVMBW0lEoIr47zPLphkhgELH2NFoH/FhHBm6juuX7XS0bZtnTKV9YE3xPQ JKlRk1K50/HZ2Gmt0hLo+qRVurQ9gUUlx0eYb/eqF9kPlQHz01UX7MAiAL9f9/MBU0ce evHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=qD1Ra//QfyxtellHE++LFoQtSYp6MrrKEbuK4qKvC2Q=; b=jm5/P5LArleTvIO8m6sQiRR4V75jOXwCoLVBH5E/vnDM3wXESRB6qleEVkohsZnFz3 1lrzlFadSjLN2g2sHS1fVuvxfXLIqW5C0g9NwNKMK7dLlGkjFg+3jhKpVcs1HDgcEz1s ru22iRO/w73Tmtn3lsyIH9jaOEYhdKLgCZJ/DW89XTmaFZ0QHyARUK0R7YoLVCMKLX3y lrpYqnAIlVUO6Y4RbfVZRiQ5sz6SSx+C/Gzyp4RqEHuk+LXLi0QxjPXywR157mWmujge AoeQjCNNBW+25Su61/mKd6X1jLTgX7nZfs+TR8Da9ckUoQaXQKZsQag1q0YwRlUfvL7E goBA== X-Gm-Message-State: AHQUAuZNuEYJ/cDPMijt3HdigbS7OCQznRx1SeX9JPFAJG0nt5Z6T7MY hmV21i6LtsFkA3hbiWCDIqBctQ== X-Google-Smtp-Source: AHgI3Ianw8xmRE2Ysix6Ycnl3eKNo45OXaCp4ZJcGlCOJcqNXhh5Mzsi3Z8lq3/d7F2SDxsp5uPADw== X-Received: by 2002:a5d:4a05:: with SMTP id m5mr77540wrq.46.1550057921322; Wed, 13 Feb 2019 03:38:41 -0800 (PST) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c9sm13168506wrs.84.2019.02.13.03.38.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 03:38:40 -0800 (PST) Date: Wed, 13 Feb 2019 12:38:19 +0100 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Shahaf Shuler Cc: anatoly.burakov@intel.com, yskoh@mellanox.com, thomas@monjalon.net, ferruh.yigit@intel.com, nhorman@tuxdriver.com, dev@dpdk.org Message-ID: <20190213113819.xkaybql2eeqmflpf@bidouze.vm.6wind.com> References: <0f98e0a06c535d58ac8d2c39645b07eb966ec5ec.1550048187.git.shahafs@mellanox.com> <20190213094505.d7ly2sundvmffiny@bidouze.vm.6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190213094505.d7ly2sundvmffiny@bidouze.vm.6wind.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH 1/6] vfio: allow DMA map of memory for the default vfio fd 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, 13 Feb 2019 11:38:41 -0000 On Wed, Feb 13, 2019 at 10:45:05AM +0100, Gaëtan Rivet wrote: > Hello Shahaf, > > On Wed, Feb 13, 2019 at 11:10:21AM +0200, Shahaf Shuler wrote: > > Enable users the option to call rte_vfio_dma_map with request to map > > to the default vfio fd. > > > > Signed-off-by: Shahaf Shuler > > --- > > lib/librte_eal/common/include/rte_vfio.h | 6 ++++-- > > lib/librte_eal/linuxapp/eal/eal_vfio.c | 14 ++++++++++++-- > > 2 files changed, 16 insertions(+), 4 deletions(-) > > > > diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h > > index cae96fab90..2a6827012f 100644 > > --- a/lib/librte_eal/common/include/rte_vfio.h > > +++ b/lib/librte_eal/common/include/rte_vfio.h > > @@ -347,7 +347,8 @@ rte_vfio_container_group_unbind(int container_fd, int iommu_group_num); > > * Perform DMA mapping for devices in a container. > > * > > * @param container_fd > > - * the specified container fd > > + * the specified container fd. In case of -1 the default container > > + * fd will be used. > > I think > > #define RTE_VFIO_DEFAULT_CONTAINER_FD (-1) > > might help reading the code that will later call these functions. > > > * > > * @param vaddr > > * Starting virtual address of memory to be mapped. > > @@ -370,7 +371,8 @@ rte_vfio_container_dma_map(int container_fd, uint64_t vaddr, > > * Perform DMA unmapping for devices in a container. > > * > > * @param container_fd > > - * the specified container fd > > + * the specified container fd. In case of -1 the default container > > + * fd will be used. > > * > > * @param vaddr > > * Starting virtual address of memory to be unmapped. > > diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c > > index c821e83826..48ca9465d4 100644 > > --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c > > +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c > > @@ -1897,7 +1897,12 @@ rte_vfio_container_dma_map(int container_fd, uint64_t vaddr, uint64_t iova, > > return -1; > > } > > > > - vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); > > + if (container_fd > 0) { > > Should it not be container_fd >= 0? This seems inconsistent with the doc > above. Reading the code quickly, it's not clear that the container_fd==0 > would be at vfio_cfgs[0], so this seems wrong. > > > + vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); > > + } else { > > + /* when no fd provided use the default. */ > > + vfio_cfg = &vfio_cfgs[0]; > > + } > > Can you use: > > vfio_cfg = default_vfio_cfg; > > instead? Then the comment is redundant. > Actually, to keep with my comment above, it might be better to simply > have > > if (container_fd == RTE_VFIO_DEFAULT_CONTAINER_FD) > vfio_cfg = default_vfio_cfg; > else > vfio_cfg = get_vfio_cfg_by_group_num(container_fd); > Errm, copy error, this line should be vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); of course. > > if (vfio_cfg == NULL) { > > RTE_LOG(ERR, EAL, "Invalid container fd\n"); > > return -1; > > @@ -1917,7 +1922,12 @@ rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova, > > return -1; > > } > > > > - vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); > > + if (container_fd > 0) { > > + vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); > > + } else { > > + /* when no fd provided use the default. */ > > + vfio_cfg = &vfio_cfgs[0]; > > + } > > if (vfio_cfg == NULL) { > > RTE_LOG(ERR, EAL, "Invalid container fd\n"); > > return -1; > > -- > > 2.12.0 > > > > -- > Gaëtan Rivet > 6WIND -- Gaëtan Rivet 6WIND