From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <bruce.richardson@intel.com>
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id F08E39E7
 for <dev@dpdk.org>; Wed, 16 Dec 2015 14:15:51 +0100 (CET)
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by fmsmga103.fm.intel.com with ESMTP; 16 Dec 2015 05:15:43 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.20,437,1444719600"; d="scan'208";a="872705278"
Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.208.64])
 by orsmga002.jf.intel.com with SMTP; 16 Dec 2015 05:15:41 -0800
Received: by  (sSMTP sendmail emulation); Wed, 16 Dec 2015 13:15:41 +0025
Date: Wed, 16 Dec 2015 13:15:41 +0000
From: Bruce Richardson <bruce.richardson@intel.com>
To: David Marchand <david.marchand@6wind.com>
Message-ID: <20151216131540.GD10020@bricha3-MOBL3>
References: <CAAyOgsaMO7V1K8Yxh=Zf-E4iodDevMFG+rRBPgZXBysca9JopA@mail.gmail.com>
 <1450269064-23608-1-git-send-email-david.marchand@6wind.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1450269064-23608-1-git-send-email-david.marchand@6wind.com>
Organization: Intel Shannon Ltd.
User-Agent: Mutt/1.5.23 (2014-03-12)
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] eal: map io resources for non x86
 architectures
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 16 Dec 2015 13:15:52 -0000

On Wed, Dec 16, 2015 at 01:31:04PM +0100, David Marchand wrote:
> x86 requires a special set of instructions to access ioports, but other
> architectures let you remap io resources.
> So let eal remap io resources by accepting IORESOURCE_IO flag for
> architectures other than x86.
> 
> Signed-off-by: David Marchand <david.marchand@6wind.com>
> ---
>  lib/librte_eal/common/include/rte_pci.h |    3 ++-
>  lib/librte_eal/linuxapp/eal/eal_pci.c   |   21 +++++++++++++++------
>  2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
> index 334c12e..8aaab4a 100644
> --- a/lib/librte_eal/common/include/rte_pci.h
> +++ b/lib/librte_eal/common/include/rte_pci.h
> @@ -105,7 +105,8 @@ extern struct pci_device_list pci_device_list; /**< Global list of PCI devices.
>  /** Nb. of values in PCI resource format. */
>  #define PCI_RESOURCE_FMT_NVAL 3
>  
> -/** IO resource type: memory address space */
> +/** IO resource type: */
> +#define IORESOURCE_IO         0x00000100
>  #define IORESOURCE_MEM        0x00000200
>  
>  /**
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index bc5b5be..9c4651d 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -236,12 +236,21 @@ pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
>  			goto error;
>  		}
>  
> -		if (flags & IORESOURCE_MEM) {
> -			dev->mem_resource[i].phys_addr = phys_addr;
> -			dev->mem_resource[i].len = end_addr - phys_addr + 1;
> -			/* not mapped for now */
> -			dev->mem_resource[i].addr = NULL;
> -		}
> +		/* we only care about IORESOURCE_IO or IORESOURCE_MEM */
> +		if (!(flags & IORESOURCE_IO) &&
> +		    !(flags & IORESOURCE_MEM))
> +			continue;
> +
> +#if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
> +		/* x86 can not remap ioports, so skip it, remapping code will
> +		 * look at dev->mem_resource[i].phys_addr == 0 and skip it */
> +		if (flags & IORESOURCE_IO)
> +			continue;
> +#endif

As a tangential comment: We maybe could look to make certain preprocessor
defines available as C globals as well. There is no reason that the ifdef here
could not be implemented as a runtime check in C code.

/Bruce