[dpdk-dev] bus/pci: fix vfio mode

Message ID 20171030080654.GF10890@bidouze.vm.6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Gaëtan Rivet Oct. 30, 2017, 8:06 a.m. UTC
  Hi Jerin,

On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
> The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
> include eal_vfio.h will result in disabling vfio.
> 
> Fixes: 279b581c897d ("vfio: expose functions")
> 

Thanks for the fix, sorry for VFIO.
I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
not do a good-enough job.

Instead of reinstating the dependency on the private eal_vfio.h header,
I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
the linux Makefile. Something like:

---8<---

grep -rl VFIO_PRESENT drivers/bus/pci/linux/ |while read -r file
do sed -i 's;VFIO_PRESENT;RTE_EAL_VFIO;' $file
done

patch -p1 <<___HERE
___HERE

--->8---

Do you think it could work? If so, I think it would be preferable
to re-including eal_vfio.h. Private EAL headers are bound to be removed
from other subsystems at some point. I tried to start with VFIO, others
should follow.

> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  drivers/bus/pci/linux/pci.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
> index cdf810693..d0ce0207a 100644
> --- a/drivers/bus/pci/linux/pci.c
> +++ b/drivers/bus/pci/linux/pci.c
> @@ -46,6 +46,7 @@
>  
>  #include "eal_private.h"
>  #include "eal_filesystem.h"
> +#include "eal_vfio.h"
>  
>  #include "private.h"
>  #include "pci_init.h"
> -- 
> 2.14.3
>
  

Comments

Ferruh Yigit Oct. 30, 2017, 9 a.m. UTC | #1
On 10/30/2017 1:06 AM, Gaëtan Rivet wrote:
> Hi Jerin,
> 
> On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
>> The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
>> include eal_vfio.h will result in disabling vfio.
>>
>> Fixes: 279b581c897d ("vfio: expose functions")
>>
> 
> Thanks for the fix, sorry for VFIO.
> I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
> not do a good-enough job.
> 
> Instead of reinstating the dependency on the private eal_vfio.h header,
> I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
> RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
> the linux Makefile. Something like:
> 
> ---8<---
> 
> grep -rl VFIO_PRESENT drivers/bus/pci/linux/ |while read -r file
> do sed -i 's;VFIO_PRESENT;RTE_EAL_VFIO;' $file
> done

VFIO_PRESENT is the combination of the if user enabled VFIO and if Linux kernel
supports it.

Why not add same check and VFIO_PRESENT definition to rte_vfio.h:

  --- a/lib/librte_eal/common/include/rte_vfio.h
  +++ b/lib/librte_eal/common/include/rte_vfio.h
  @@ -34,7 +34,13 @@
   #ifndef _RTE_VFIO_H_
   #define _RTE_VFIO_H_

  +#if !defined(VFIO_PRESENT) && defined(RTE_EAL_VFIO)
  +#include <linux/version.h>
  +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
   #include <linux/vfio.h>
  +#define VFIO_PRESENT
  +#endif /* >= 3.6.0 */
  +#endif
  +
  +#ifdef VFIO_PRESENT

  ... Need to wrap here in case VFIO disabled ...

  #endif

> 
> patch -p1 <<___HERE
> diff --git a/drivers/bus/pci/linux/Makefile b/drivers/bus/pci/linux/Makefile
> index 77c5f97..b5b9c54 100644
> --- a/drivers/bus/pci/linux/Makefile
> +++ b/drivers/bus/pci/linux/Makefile
> @@ -31,6 +31,8 @@
> 
>  SRCS += pci.c
>  SRCS += pci_uio.c
> +ifeq (\$(CONFIG_RTE_EAL_VFIO),y)
>  SRCS += pci_vfio.c
> +endif

+1

Also ?
  +ifeq ($(CONFIG_RTE_EAL_VFIO),y)
   SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio.c
   SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c
  +endif

Build shouldn't broken when VFIO disabled form config

> 
>  CFLAGS += -D_GNU_SOURCE
> ___HERE
> 
> --->8---
> 
> Do you think it could work? If so, I think it would be preferable
> to re-including eal_vfio.h. Private EAL headers are bound to be removed
> from other subsystems at some point. I tried to start with VFIO, others
> should follow.
> 
>> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
>>
>> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>> ---
>>  drivers/bus/pci/linux/pci.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
>> index cdf810693..d0ce0207a 100644
>> --- a/drivers/bus/pci/linux/pci.c
>> +++ b/drivers/bus/pci/linux/pci.c
>> @@ -46,6 +46,7 @@
>>  
>>  #include "eal_private.h"
>>  #include "eal_filesystem.h"
>> +#include "eal_vfio.h"
>>  
>>  #include "private.h"
>>  #include "pci_init.h"
>> -- 
>> 2.14.3
>>
>
  
Jerin Jacob Oct. 30, 2017, 9:10 a.m. UTC | #2
-----Original Message-----
> Date: Mon, 30 Oct 2017 09:06:54 +0100
> From: Gaëtan Rivet <gaetan.rivet@6wind.com>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Cc: dev@dpdk.org, thomas@monjalon.net
> Subject: Re: [dpdk-dev] [PATCH] bus/pci: fix vfio mode
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> Hi Jerin,

Hi Gaëtan,

> 
> On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
> > The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
> > include eal_vfio.h will result in disabling vfio.
> > 
> > Fixes: 279b581c897d ("vfio: expose functions")
> > 
> 
> Thanks for the fix, sorry for VFIO.
> I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
> not do a good-enough job.
> 
> Instead of reinstating the dependency on the private eal_vfio.h header,
> I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
> RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
> the linux Makefile. Something like:

That will work. But, I think, We can push this patch as a hot fix as master is
broken now.
  
Gaëtan Rivet Oct. 30, 2017, 9:17 a.m. UTC | #3
Hi Ferruh,

On Mon, Oct 30, 2017 at 02:00:43AM -0700, Ferruh Yigit wrote:
> On 10/30/2017 1:06 AM, Gaëtan Rivet wrote:
> > Hi Jerin,
> > 
> > On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
> >> The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
> >> include eal_vfio.h will result in disabling vfio.
> >>
> >> Fixes: 279b581c897d ("vfio: expose functions")
> >>
> > 
> > Thanks for the fix, sorry for VFIO.
> > I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
> > not do a good-enough job.
> > 
> > Instead of reinstating the dependency on the private eal_vfio.h header,
> > I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
> > RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
> > the linux Makefile. Something like:
> > 
> > ---8<---
> > 
> > grep -rl VFIO_PRESENT drivers/bus/pci/linux/ |while read -r file
> > do sed -i 's;VFIO_PRESENT;RTE_EAL_VFIO;' $file
> > done
> 
> VFIO_PRESENT is the combination of the if user enabled VFIO and if Linux kernel
> supports it.
> 
> Why not add same check and VFIO_PRESENT definition to rte_vfio.h:
> 
>   --- a/lib/librte_eal/common/include/rte_vfio.h
>   +++ b/lib/librte_eal/common/include/rte_vfio.h
>   @@ -34,7 +34,13 @@
>    #ifndef _RTE_VFIO_H_
>    #define _RTE_VFIO_H_
> 
>   +#if !defined(VFIO_PRESENT) && defined(RTE_EAL_VFIO)
>   +#include <linux/version.h>
>   +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
>    #include <linux/vfio.h>
>   +#define VFIO_PRESENT
>   +#endif /* >= 3.6.0 */
>   +#endif
>   +
>   +#ifdef VFIO_PRESENT
> 
>   ... Need to wrap here in case VFIO disabled ...
> 
>   #endif
> 

It would work indeed.

I mostly dislike having whole compilation units disabled silently on a
linux version check. I think that if someone wanted to support kernels <
3.6, they ought to do the work of disabling RTE_EAL_VFIO.

A build error could be thrown to help those users toward the right
solution, but I think that the meaning of having this option enabled
should be enforced: if it is enabled, it is compiled. If dependencies
are not met, then the option should be disabled.

> > 
> > patch -p1 <<___HERE
> > diff --git a/drivers/bus/pci/linux/Makefile b/drivers/bus/pci/linux/Makefile
> > index 77c5f97..b5b9c54 100644
> > --- a/drivers/bus/pci/linux/Makefile
> > +++ b/drivers/bus/pci/linux/Makefile
> > @@ -31,6 +31,8 @@
> > 
> >  SRCS += pci.c
> >  SRCS += pci_uio.c
> > +ifeq (\$(CONFIG_RTE_EAL_VFIO),y)
> >  SRCS += pci_vfio.c
> > +endif
> 
> +1
> 
> Also ?
>   +ifeq ($(CONFIG_RTE_EAL_VFIO),y)
>    SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio.c
>    SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c
>   +endif
> 
> Build shouldn't broken when VFIO disabled form config
> 
> > 
> >  CFLAGS += -D_GNU_SOURCE
> > ___HERE
> > 
> > --->8---
> > 
> > Do you think it could work? If so, I think it would be preferable
> > to re-including eal_vfio.h. Private EAL headers are bound to be removed
> > from other subsystems at some point. I tried to start with VFIO, others
> > should follow.
> > 
> >> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> >>
> >> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> >> ---
> >>  drivers/bus/pci/linux/pci.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
> >> index cdf810693..d0ce0207a 100644
> >> --- a/drivers/bus/pci/linux/pci.c
> >> +++ b/drivers/bus/pci/linux/pci.c
> >> @@ -46,6 +46,7 @@
> >>  
> >>  #include "eal_private.h"
> >>  #include "eal_filesystem.h"
> >> +#include "eal_vfio.h"
> >>  
> >>  #include "private.h"
> >>  #include "pci_init.h"
> >> -- 
> >> 2.14.3
> >>
> > 
>
  
Thomas Monjalon Oct. 30, 2017, 9:27 a.m. UTC | #4
30/10/2017 10:17, Gaëtan Rivet:
> Hi Ferruh,
> 
> On Mon, Oct 30, 2017 at 02:00:43AM -0700, Ferruh Yigit wrote:
> > On 10/30/2017 1:06 AM, Gaëtan Rivet wrote:
> > > Hi Jerin,
> > > 
> > > On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
> > >> The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
> > >> include eal_vfio.h will result in disabling vfio.
> > >>
> > >> Fixes: 279b581c897d ("vfio: expose functions")
> > >>
> > > 
> > > Thanks for the fix, sorry for VFIO.
> > > I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
> > > not do a good-enough job.
> > > 
> > > Instead of reinstating the dependency on the private eal_vfio.h header,
> > > I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
> > > RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
> > > the linux Makefile. Something like:
> > > 
> > > ---8<---
> > > 
> > > grep -rl VFIO_PRESENT drivers/bus/pci/linux/ |while read -r file
> > > do sed -i 's;VFIO_PRESENT;RTE_EAL_VFIO;' $file
> > > done
> > 
> > VFIO_PRESENT is the combination of the if user enabled VFIO and if Linux kernel
> > supports it.
> > 
> > Why not add same check and VFIO_PRESENT definition to rte_vfio.h:
> > 
> >   --- a/lib/librte_eal/common/include/rte_vfio.h
> >   +++ b/lib/librte_eal/common/include/rte_vfio.h
> >   @@ -34,7 +34,13 @@
> >    #ifndef _RTE_VFIO_H_
> >    #define _RTE_VFIO_H_
> > 
> >   +#if !defined(VFIO_PRESENT) && defined(RTE_EAL_VFIO)
> >   +#include <linux/version.h>
> >   +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
> >    #include <linux/vfio.h>
> >   +#define VFIO_PRESENT
> >   +#endif /* >= 3.6.0 */
> >   +#endif
> >   +
> >   +#ifdef VFIO_PRESENT
> > 
> >   ... Need to wrap here in case VFIO disabled ...
> > 
> >   #endif
> > 
> 
> It would work indeed.
> 
> I mostly dislike having whole compilation units disabled silently on a
> linux version check. I think that if someone wanted to support kernels <
> 3.6, they ought to do the work of disabling RTE_EAL_VFIO.
> 
> A build error could be thrown to help those users toward the right
> solution, but I think that the meaning of having this option enabled
> should be enforced: if it is enabled, it is compiled. If dependencies
> are not met, then the option should be disabled.

+1 to avoid implicit disabling.
  
Thomas Monjalon Oct. 30, 2017, 11:24 a.m. UTC | #5
30/10/2017 10:27, Thomas Monjalon:
> 30/10/2017 10:17, Gaëtan Rivet:
> > Hi Ferruh,
> > 
> > On Mon, Oct 30, 2017 at 02:00:43AM -0700, Ferruh Yigit wrote:
> > > On 10/30/2017 1:06 AM, Gaëtan Rivet wrote:
> > > > Hi Jerin,
> > > > 
> > > > On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
> > > >> The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
> > > >> include eal_vfio.h will result in disabling vfio.
> > > >>
> > > >> Fixes: 279b581c897d ("vfio: expose functions")
> > > >>
> > > > 
> > > > Thanks for the fix, sorry for VFIO.
> > > > I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
> > > > not do a good-enough job.
> > > > 
> > > > Instead of reinstating the dependency on the private eal_vfio.h header,
> > > > I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
> > > > RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
> > > > the linux Makefile. Something like:
> > > > 
> > > > ---8<---
> > > > 
> > > > grep -rl VFIO_PRESENT drivers/bus/pci/linux/ |while read -r file
> > > > do sed -i 's;VFIO_PRESENT;RTE_EAL_VFIO;' $file
> > > > done
> > > 
> > > VFIO_PRESENT is the combination of the if user enabled VFIO and if Linux kernel
> > > supports it.
> > > 
> > > Why not add same check and VFIO_PRESENT definition to rte_vfio.h:
> > > 
> > >   --- a/lib/librte_eal/common/include/rte_vfio.h
> > >   +++ b/lib/librte_eal/common/include/rte_vfio.h
> > >   @@ -34,7 +34,13 @@
> > >    #ifndef _RTE_VFIO_H_
> > >    #define _RTE_VFIO_H_
> > > 
> > >   +#if !defined(VFIO_PRESENT) && defined(RTE_EAL_VFIO)
> > >   +#include <linux/version.h>
> > >   +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
> > >    #include <linux/vfio.h>
> > >   +#define VFIO_PRESENT
> > >   +#endif /* >= 3.6.0 */
> > >   +#endif
> > >   +
> > >   +#ifdef VFIO_PRESENT
> > > 
> > >   ... Need to wrap here in case VFIO disabled ...
> > > 
> > >   #endif
> > > 
> > 
> > It would work indeed.
> > 
> > I mostly dislike having whole compilation units disabled silently on a
> > linux version check. I think that if someone wanted to support kernels <
> > 3.6, they ought to do the work of disabling RTE_EAL_VFIO.
> > 
> > A build error could be thrown to help those users toward the right
> > solution, but I think that the meaning of having this option enabled
> > should be enforced: if it is enabled, it is compiled. If dependencies
> > are not met, then the option should be disabled.
> 
> +1 to avoid implicit disabling.

To make it clear, we can disable VFIO automatically if not supported by
the kernel at compilation time, but there should be a warning.
  
Ferruh Yigit Oct. 30, 2017, 4:57 p.m. UTC | #6
On 10/30/2017 4:24 AM, Thomas Monjalon wrote:
> 30/10/2017 10:27, Thomas Monjalon:
>> 30/10/2017 10:17, Gaëtan Rivet:
>>> Hi Ferruh,
>>>
>>> On Mon, Oct 30, 2017 at 02:00:43AM -0700, Ferruh Yigit wrote:
>>>> On 10/30/2017 1:06 AM, Gaëtan Rivet wrote:
>>>>> Hi Jerin,
>>>>>
>>>>> On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
>>>>>> The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
>>>>>> include eal_vfio.h will result in disabling vfio.
>>>>>>
>>>>>> Fixes: 279b581c897d ("vfio: expose functions")
>>>>>>
>>>>>
>>>>> Thanks for the fix, sorry for VFIO.
>>>>> I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
>>>>> not do a good-enough job.
>>>>>
>>>>> Instead of reinstating the dependency on the private eal_vfio.h header,
>>>>> I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
>>>>> RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
>>>>> the linux Makefile. Something like:
>>>>>
>>>>> ---8<---
>>>>>
>>>>> grep -rl VFIO_PRESENT drivers/bus/pci/linux/ |while read -r file
>>>>> do sed -i 's;VFIO_PRESENT;RTE_EAL_VFIO;' $file
>>>>> done
>>>>
>>>> VFIO_PRESENT is the combination of the if user enabled VFIO and if Linux kernel
>>>> supports it.
>>>>
>>>> Why not add same check and VFIO_PRESENT definition to rte_vfio.h:
>>>>
>>>>   --- a/lib/librte_eal/common/include/rte_vfio.h
>>>>   +++ b/lib/librte_eal/common/include/rte_vfio.h
>>>>   @@ -34,7 +34,13 @@
>>>>    #ifndef _RTE_VFIO_H_
>>>>    #define _RTE_VFIO_H_
>>>>
>>>>   +#if !defined(VFIO_PRESENT) && defined(RTE_EAL_VFIO)
>>>>   +#include <linux/version.h>
>>>>   +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
>>>>    #include <linux/vfio.h>
>>>>   +#define VFIO_PRESENT
>>>>   +#endif /* >= 3.6.0 */
>>>>   +#endif
>>>>   +
>>>>   +#ifdef VFIO_PRESENT
>>>>
>>>>   ... Need to wrap here in case VFIO disabled ...
>>>>
>>>>   #endif
>>>>
>>>
>>> It would work indeed.
>>>
>>> I mostly dislike having whole compilation units disabled silently on a
>>> linux version check. I think that if someone wanted to support kernels <
>>> 3.6, they ought to do the work of disabling RTE_EAL_VFIO.
>>>
>>> A build error could be thrown to help those users toward the right
>>> solution, but I think that the meaning of having this option enabled
>>> should be enforced: if it is enabled, it is compiled. If dependencies
>>> are not met, then the option should be disabled.
>>
>> +1 to avoid implicit disabling.
> 
> To make it clear, we can disable VFIO automatically if not supported by
> the kernel at compilation time, but there should be a warning.

Gaetan suggest letting build error and push user to disable the feature. If we
let the build error, I think feature should be disabled by default.

And for VFIO, instead of disabling it by default I am for auto disable it if
kernel requirement not met, and +1 for adding a warning.

btw, that kernel version check is already in eal_vfio.h, we are already
disabling some vfio code based on kernel version check, weather add here or not.

Thanks,
ferruh
  
Gaëtan Rivet Oct. 30, 2017, 5:13 p.m. UTC | #7
On Mon, Oct 30, 2017 at 09:57:08AM -0700, Ferruh Yigit wrote:
> On 10/30/2017 4:24 AM, Thomas Monjalon wrote:
> > 30/10/2017 10:27, Thomas Monjalon:
> >> 30/10/2017 10:17, Gaëtan Rivet:
> >>> Hi Ferruh,
> >>>
> >>> On Mon, Oct 30, 2017 at 02:00:43AM -0700, Ferruh Yigit wrote:
> >>>> On 10/30/2017 1:06 AM, Gaëtan Rivet wrote:
> >>>>> Hi Jerin,
> >>>>>
> >>>>> On Sat, Oct 28, 2017 at 11:50:52AM +0530, Jerin Jacob wrote:
> >>>>>> The definition of VFIO_PRESENT is "eal_vfio.h", Fail to
> >>>>>> include eal_vfio.h will result in disabling vfio.
> >>>>>>
> >>>>>> Fixes: 279b581c897d ("vfio: expose functions")
> >>>>>>
> >>>>>
> >>>>> Thanks for the fix, sorry for VFIO.
> >>>>> I tried to let go of VFIO_PRESENT in the PCI patchset, unfortunately I did
> >>>>> not do a good-enough job.
> >>>>>
> >>>>> Instead of reinstating the dependency on the private eal_vfio.h header,
> >>>>> I'd suggest replacing all VFIO_PRESENT references within the PCI bus by
> >>>>> RTE_EAL_VFIO, and make the pci_vfio.c compilation depend on it within
> >>>>> the linux Makefile. Something like:
> >>>>>
> >>>>> ---8<---
> >>>>>
> >>>>> grep -rl VFIO_PRESENT drivers/bus/pci/linux/ |while read -r file
> >>>>> do sed -i 's;VFIO_PRESENT;RTE_EAL_VFIO;' $file
> >>>>> done
> >>>>
> >>>> VFIO_PRESENT is the combination of the if user enabled VFIO and if Linux kernel
> >>>> supports it.
> >>>>
> >>>> Why not add same check and VFIO_PRESENT definition to rte_vfio.h:
> >>>>
> >>>>   --- a/lib/librte_eal/common/include/rte_vfio.h
> >>>>   +++ b/lib/librte_eal/common/include/rte_vfio.h
> >>>>   @@ -34,7 +34,13 @@
> >>>>    #ifndef _RTE_VFIO_H_
> >>>>    #define _RTE_VFIO_H_
> >>>>
> >>>>   +#if !defined(VFIO_PRESENT) && defined(RTE_EAL_VFIO)
> >>>>   +#include <linux/version.h>
> >>>>   +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
> >>>>    #include <linux/vfio.h>
> >>>>   +#define VFIO_PRESENT
> >>>>   +#endif /* >= 3.6.0 */
> >>>>   +#endif
> >>>>   +
> >>>>   +#ifdef VFIO_PRESENT
> >>>>
> >>>>   ... Need to wrap here in case VFIO disabled ...
> >>>>
> >>>>   #endif
> >>>>
> >>>
> >>> It would work indeed.
> >>>
> >>> I mostly dislike having whole compilation units disabled silently on a
> >>> linux version check. I think that if someone wanted to support kernels <
> >>> 3.6, they ought to do the work of disabling RTE_EAL_VFIO.
> >>>
> >>> A build error could be thrown to help those users toward the right
> >>> solution, but I think that the meaning of having this option enabled
> >>> should be enforced: if it is enabled, it is compiled. If dependencies
> >>> are not met, then the option should be disabled.
> >>
> >> +1 to avoid implicit disabling.
> > 
> > To make it clear, we can disable VFIO automatically if not supported by
> > the kernel at compilation time, but there should be a warning.
> 
> Gaetan suggest letting build error and push user to disable the feature. If we
> let the build error, I think feature should be disabled by default.
> 
> And for VFIO, instead of disabling it by default I am for auto disable it if
> kernel requirement not met, and +1 for adding a warning.
> 
> btw, that kernel version check is already in eal_vfio.h, we are already
> disabling some vfio code based on kernel version check, weather add here or not.
> 
> Thanks,
> ferruh

The new version of the patches should behave like you described :) .

I still think VFIO_PRESENT should be changed, but not now.
  

Patch

diff --git a/drivers/bus/pci/linux/Makefile b/drivers/bus/pci/linux/Makefile
index 77c5f97..b5b9c54 100644
--- a/drivers/bus/pci/linux/Makefile
+++ b/drivers/bus/pci/linux/Makefile
@@ -31,6 +31,8 @@ 

 SRCS += pci.c
 SRCS += pci_uio.c
+ifeq (\$(CONFIG_RTE_EAL_VFIO),y)
 SRCS += pci_vfio.c
+endif

 CFLAGS += -D_GNU_SOURCE