From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 17364A052A;
	Fri, 10 Jul 2020 23:07:08 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id F314A1DA61;
	Fri, 10 Jul 2020 23:07:06 +0200 (CEST)
Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com
 [209.85.167.66]) by dpdk.org (Postfix) with ESMTP id E1CBC1D6B0
 for <dev@dpdk.org>; Fri, 10 Jul 2020 23:07:04 +0200 (CEST)
Received: by mail-lf1-f66.google.com with SMTP id g2so3950293lfb.0
 for <dev@dpdk.org>; Fri, 10 Jul 2020 14:07:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=date:from:to:cc:subject:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=dH4AsUW5QvOTobx5ANJFTyaLh5YkRhSsHZQpNiiXAiE=;
 b=q6R000Bq2M//7Y7TS7Zk5CufCHxpniHW5t0zaegsux2qakZZm3n2x8EJiWVptM5uso
 RchDAYq6rfBGRCVHMPrlmqeBJfa7PIkUJ8f/rCQgej9bzO+j0PFfBPmxrUimSwnp0cnG
 NrqUrIY5gl4K2rtA8cFBaIbU5qVxcWEGjypJGeiVpx3q9I6jLo6iw0W8r5GVgHTllqDS
 pBjcd11tWIcRyZ9x05jHgOZdb2mXZNny9fVnmDq0pQEOBOzFfdlOVc2ruhVgmYCs8VTY
 RuVijwNK8kbMXrDzqAhu+KPKEU4It9GxZhkv3cN8CLBEqGNtLy1BFeafum0B+ILLSYUP
 7hLA==
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:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=dH4AsUW5QvOTobx5ANJFTyaLh5YkRhSsHZQpNiiXAiE=;
 b=RnpIt8adNM+O4nNyxeUO8RgqE0Vqpd/C2wEyrM2FSFNOfjpk8PPdH0vY9tXao3WsFG
 L5NcZ5bqYLJ8fiucRfgGIDtbkcfPtGU3cGdleOrPnJwZNAih7T+U4744EgRvZJVyWqtM
 pwMrPcBr5EA5s+Nn8A3YfvynmaX72P+HARtfqfbSOTF6PX2ufl0YRzASRJOCxqgLAa9z
 cPuqk2zMbcYfVa3876O9XcGztqWomx2+eWLuLqDNEGKScOapaIP/iaODnYKza7vGURLJ
 uZ2FMYgJw7sDV2JSd2ip7IztHzypeHLFCYGr5Fa62TEnwLStLSU8qdxcrzjLEwhGd3Rw
 RJhQ==
X-Gm-Message-State: AOAM530oachfL1beprQ2IqYu7HhHf7O91X1vDBwV60a5XbFycA2I7PDR
 48b5k7WdkhH54hLfpB/qdBA=
X-Google-Smtp-Source: ABdhPJytPoAfOFAD8Z1xpWHtcKEmpiWpj62WhU8ZAWpweKj/JxzLyZbQv/WO4Y2cPmuxBl/R7Mys5A==
X-Received: by 2002:a19:604f:: with SMTP id p15mr45837332lfk.59.1594415224331; 
 Fri, 10 Jul 2020 14:07:04 -0700 (PDT)
Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru.
 [37.110.65.23])
 by smtp.gmail.com with ESMTPSA id a20sm2577456lfl.20.2020.07.10.14.07.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 10 Jul 2020 14:07:03 -0700 (PDT)
Date: Sat, 11 Jul 2020 00:07:02 +0300
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org, david.marchand@redhat.com, ferruh.yigit@intel.com,
 grive@u256.net, alvinx.zhang@intel.com, beilei.xing@intel.com,
 jia.guo@intel.com, anatoly.burakov@intel.com, bruce.richardson@intel.com,
 navasile@linux.microsoft.com, dmitrym@microsoft.com,
 pallavi.kadam@intel.com, talshn@mellanox.com
Message-ID: <20200711000702.26e70084@sovereign>
In-Reply-To: <20200710204034.4158330-1-thomas@monjalon.net>
References: <20200710115324.3902559-1-thomas@monjalon.net>
 <20200710204034.4158330-1-thomas@monjalon.net>
X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [PATCH v2] pci: keep API compatibility with mmap
	values
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On Fri, 10 Jul 2020 22:40:34 +0200, Thomas Monjalon wrote:
> The function pci_map_resource() returns MAP_FAILED in case of error.
> When replacing the call to mmap() by rte_mem_map(),
> the error code became NULL, breaking the API.
> This function is probably not used outside of DPDK,
> but it is still a problem for two reasons:
> 	- the deprecation process was not followed
> 	- the Linux function pci_vfio_mmap_bar() is broken for i40e
> 
> The error code is reverted to the Unix value MAP_FAILED.
> Windows needs to define this special value (-1 as in Unix).
> After proper deprecation process, the API could be changed again
> if really needed.
> 
> Because of the switch from mmap() to rte_mem_map(),
> another part of the API was changed: "int additional_flags"
> are defined as "additional flags for the mapping range"
> without mentioning it was directly used in mmap().
> Currently it is directly used in rte_mem_map(),
> that's why the values rte_map_flags must be mapped (sic) on the mmap ones
> in case of Unix OS.
> 
> These are side effects of a badly defined API using Unix values.
> 
> Bugzilla ID: 503
> Fixes: 2fd3567e5425 ("pci: use OS generic memory mapping functions")
> Cc: talshn@mellanox.com
> 
> Reported-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v2: move MAP_FAILED from sys/mman.h to rte_os.h
> ---
>  drivers/bus/pci/bsd/pci.c               |  2 +-
>  drivers/bus/pci/linux/pci_uio.c         |  2 +-
>  drivers/bus/pci/linux/pci_vfio.c        |  4 ++--
>  drivers/bus/pci/pci_common_uio.c        |  2 +-
>  lib/librte_eal/include/rte_eal_paging.h | 10 ++++++++++
>  lib/librte_eal/windows/include/rte_os.h |  6 ++++++
>  lib/librte_pci/rte_pci.c                |  1 +
>  lib/librte_pci/rte_pci.h                |  2 +-
>  8 files changed, 23 insertions(+), 6 deletions(-)

Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

No Intel NIC to test, but LGTM and compiles OK for Windows.