diff mbox series

[v1] examples/vhost: fix ioat dependency issue

Message ID 20201111111957.46090-1-Cheng1.jiang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show
Series [v1] examples/vhost: fix ioat dependency issue | expand

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Cheng Jiang Nov. 11, 2020, 11:19 a.m. UTC
Fix vhost-switch compiling issue when ioat dependency is missing.
Change 'RTE_x86' check into 'RTE_RAW_IOAT' check in meson build file
and update Makefile.

Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
 examples/vhost/Makefile    | 5 +++++
 examples/vhost/ioat.h      | 2 +-
 examples/vhost/meson.build | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

Comments

David Marchand Nov. 11, 2020, 2:36 p.m. UTC | #1
On Wed, Nov 11, 2020 at 12:29 PM Cheng Jiang <Cheng1.jiang@intel.com> wrote:
>
> Fix vhost-switch compiling issue when ioat dependency is missing.
> Change 'RTE_x86' check into 'RTE_RAW_IOAT' check in meson build file
> and update Makefile.

Still failing for me.
98b4c65506 - (HEAD) examples/vhost: fix ioat dependency issue (28
seconds ago) <Cheng Jiang>
a8adac0bc0 - (origin/main) doc: add instructions for building 32-bit
DPDK (5 days ago) <Bruce Richardson>

Please try the reproducer I gave:

rm -f build/vhost-switch build/vhost-switch-static build/vhost-switch-shared
test -d build && rmdir -p build || true
cc -O3 -I/home/dmarchan/dpdk/installdir/usr/local/include -include
rte_config.h -march=native -I/usr/usr/include
-DALLOW_EXPERIMENTAL_API main.c virtio_net.c -o
build/vhost-switch-shared -pthread -Wl,--as-needed
-L/home/dmarchan/dpdk/installdir/usr/local/lib64 -lrte_node
-lrte_graph -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table
-lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack
-lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_regexdev
-lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm
-lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso
-lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev
-lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev
-lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci
-lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu
-lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lbsd
/usr/bin/ld: /tmp/ccqE1W9S.o: in function `new_device':
main.c:(.text+0x173): undefined reference to `ioat_transfer_data_cb'
/usr/bin/ld: main.c:(.text+0x178): undefined reference to
`ioat_check_completed_copies_cb'
/usr/bin/ld: /tmp/ccqE1W9S.o: in function `main':
main.c:(.text.startup+0x25e): undefined reference to `open_ioat'
collect2: error: ld returned 1 exit status
make: *** [Makefile:39: build/vhost-switch-shared] Error 1


There are at least two problems:
- the code in main.c unconditionally expects the ioat stuff to be
available (this is why the link fails above),
- the Makefile unconditionally compiles ioat.c, which you fixed with this patch,

There is a potential additional problem:
I would expect a need for linking against the rte_raw_ioat driver, but
we are "lucky" that all that is used in this example are inlines.
So I guess it works without adding anything to LDFLAGS_SHARED.


>
> Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> ---
>  examples/vhost/Makefile    | 5 +++++
>  examples/vhost/ioat.h      | 2 +-
>  examples/vhost/meson.build | 2 +-
>  3 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
> index cec59d0e0f..505e443217 100644
> --- a/examples/vhost/Makefile
> +++ b/examples/vhost/Makefile
> @@ -5,7 +5,12 @@
>  APP = vhost-switch
>
>  # all source are stored in SRCS-y
> +IOAT_PATH = $(shell pkg-config --cflags-only-I libdpdk | sed -e "s/^..//")/rte_ioat_rawdev.h
> +ifeq ($(IOAT_PATH), $(wildcard $(IOAT_PATH)))
> +SRCS-y := main.c virtio_net.c ioat.c
> +else
>  SRCS-y := main.c virtio_net.c
> +endif

I'd rather rely on the driver define since the C code relies on it:
Something like:

 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
 LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
+
+HAS_RAW_IOAT=$(shell echo RTE_RAW_IOAT | $(CPP) $(CFLAGS) -P - | tail -1)
+ifeq ($(HAS_RAW_IOAT), 1)
+SRCS-y += ioat.c
+endif


>
>  # Build using pkg-config variables if possible
>  ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
> diff --git a/examples/vhost/ioat.h b/examples/vhost/ioat.h
> index 9664fcc3ac..d6d0f7c18a 100644
> --- a/examples/vhost/ioat.h
> +++ b/examples/vhost/ioat.h
> @@ -24,7 +24,7 @@ struct dma_for_vhost {
>         uint16_t nr;
>  };
>
> -#ifdef RTE_ARCH_X86
> +#ifdef RTE_RAW_IOAT
>  int open_ioat(const char *value);

main.c should check for RTE_RAW_IOAT before including ioat.h.
And then in this header, you can remove this stub too.


>  #else
>  static int open_ioat(const char *value __rte_unused)
Bruce Richardson Nov. 11, 2020, 3:03 p.m. UTC | #2
On Wed, Nov 11, 2020 at 03:36:25PM +0100, David Marchand wrote:
> On Wed, Nov 11, 2020 at 12:29 PM Cheng Jiang <Cheng1.jiang@intel.com> wrote:
> >
> > Fix vhost-switch compiling issue when ioat dependency is missing.
> > Change 'RTE_x86' check into 'RTE_RAW_IOAT' check in meson build file
> > and update Makefile.
> 
> Still failing for me.
> 98b4c65506 - (HEAD) examples/vhost: fix ioat dependency issue (28
> seconds ago) <Cheng Jiang>
> a8adac0bc0 - (origin/main) doc: add instructions for building 32-bit
> DPDK (5 days ago) <Bruce Richardson>
> 
> Please try the reproducer I gave:
> 
> rm -f build/vhost-switch build/vhost-switch-static build/vhost-switch-shared
> test -d build && rmdir -p build || true
> cc -O3 -I/home/dmarchan/dpdk/installdir/usr/local/include -include
> rte_config.h -march=native -I/usr/usr/include
> -DALLOW_EXPERIMENTAL_API main.c virtio_net.c -o
> build/vhost-switch-shared -pthread -Wl,--as-needed
> -L/home/dmarchan/dpdk/installdir/usr/local/lib64 -lrte_node
> -lrte_graph -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table
> -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack
> -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_regexdev
> -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm
> -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso
> -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev
> -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev
> -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci
> -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu
> -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lbsd
> /usr/bin/ld: /tmp/ccqE1W9S.o: in function `new_device':
> main.c:(.text+0x173): undefined reference to `ioat_transfer_data_cb'
> /usr/bin/ld: main.c:(.text+0x178): undefined reference to
> `ioat_check_completed_copies_cb'
> /usr/bin/ld: /tmp/ccqE1W9S.o: in function `main':
> main.c:(.text.startup+0x25e): undefined reference to `open_ioat'
> collect2: error: ld returned 1 exit status
> make: *** [Makefile:39: build/vhost-switch-shared] Error 1
> 
> 
> There are at least two problems:
> - the code in main.c unconditionally expects the ioat stuff to be
> available (this is why the link fails above),
> - the Makefile unconditionally compiles ioat.c, which you fixed with this patch,
> 
> There is a potential additional problem:
> I would expect a need for linking against the rte_raw_ioat driver, but
> we are "lucky" that all that is used in this example are inlines.
> So I guess it works without adding anything to LDFLAGS_SHARED.
> 

It's not actually luck! :-)

> 
> >
> > Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> > ---
> >  examples/vhost/Makefile    | 5 +++++
> >  examples/vhost/ioat.h      | 2 +-
> >  examples/vhost/meson.build | 2 +-
> >  3 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
> > index cec59d0e0f..505e443217 100644
> > --- a/examples/vhost/Makefile
> > +++ b/examples/vhost/Makefile
> > @@ -5,7 +5,12 @@
> >  APP = vhost-switch
> >
> >  # all source are stored in SRCS-y
> > +IOAT_PATH = $(shell pkg-config --cflags-only-I libdpdk | sed -e "s/^..//")/rte_ioat_rawdev.h
> > +ifeq ($(IOAT_PATH), $(wildcard $(IOAT_PATH)))
> > +SRCS-y := main.c virtio_net.c ioat.c
> > +else
> >  SRCS-y := main.c virtio_net.c
> > +endif
> 
> I'd rather rely on the driver define since the C code relies on it:
> Something like:
> 
>  PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
>  CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
>  LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
>  LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
> +
> +HAS_RAW_IOAT=$(shell echo RTE_RAW_IOAT | $(CPP) $(CFLAGS) -P - | tail -1)
> +ifeq ($(HAS_RAW_IOAT), 1)
> +SRCS-y += ioat.c
> +endif
> 

A better solution again, I think, would be to handle this in C, and have
the file itself have #ifdef RTE_RAW_IOAT .. #endif around its contents.
Then it can just be blindly in the compilation list without make having to
do any dependency tracking, which starts us down quite a slippery slope.

> 
> >
> >  # Build using pkg-config variables if possible
> >  ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
> > diff --git a/examples/vhost/ioat.h b/examples/vhost/ioat.h
> > index 9664fcc3ac..d6d0f7c18a 100644
> > --- a/examples/vhost/ioat.h
> > +++ b/examples/vhost/ioat.h
> > @@ -24,7 +24,7 @@ struct dma_for_vhost {
> >         uint16_t nr;
> >  };
> >
> > -#ifdef RTE_ARCH_X86
> > +#ifdef RTE_RAW_IOAT
> >  int open_ioat(const char *value);
> 
> main.c should check for RTE_RAW_IOAT before including ioat.h.
> And then in this header, you can remove this stub too.
> 

+1 to this.
Cheng Jiang Nov. 12, 2020, 7:14 a.m. UTC | #3
Hi,

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Wednesday, November 11, 2020 10:36 PM
> To: Jiang, Cheng1 <cheng1.jiang@intel.com>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; Xia, Chenbo
> <chenbo.xia@intel.com>; dev <dev@dpdk.org>; Fu, Patrick
> <patrick.fu@intel.com>; Yang, YvonneX <yvonnex.yang@intel.com>; Hu,
> Jiayu <jiayu.hu@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [PATCH v1] examples/vhost: fix ioat dependency issue
> 
> On Wed, Nov 11, 2020 at 12:29 PM Cheng Jiang <Cheng1.jiang@intel.com>
> wrote:
> >
> > Fix vhost-switch compiling issue when ioat dependency is missing.
> > Change 'RTE_x86' check into 'RTE_RAW_IOAT' check in meson build file
> > and update Makefile.
> 
> Still failing for me.
> 98b4c65506 - (HEAD) examples/vhost: fix ioat dependency issue (28
> seconds ago) <Cheng Jiang>
> a8adac0bc0 - (origin/main) doc: add instructions for building 32-bit
> DPDK (5 days ago) <Bruce Richardson>
> 
> Please try the reproducer I gave:
> 
> rm -f build/vhost-switch build/vhost-switch-static build/vhost-switch-shared
> test -d build && rmdir -p build || true
> cc -O3 -I/home/dmarchan/dpdk/installdir/usr/local/include -include
> rte_config.h -march=native -I/usr/usr/include
> -DALLOW_EXPERIMENTAL_API main.c virtio_net.c -o
> build/vhost-switch-shared -pthread -Wl,--as-needed
> -L/home/dmarchan/dpdk/installdir/usr/local/lib64 -lrte_node
> -lrte_graph -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table
> -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack
> -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_regexdev
> -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm
> -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso
> -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev
> -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev
> -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci
> -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu
> -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lbsd
> /usr/bin/ld: /tmp/ccqE1W9S.o: in function `new_device':
> main.c:(.text+0x173): undefined reference to `ioat_transfer_data_cb'
> /usr/bin/ld: main.c:(.text+0x178): undefined reference to
> `ioat_check_completed_copies_cb'
> /usr/bin/ld: /tmp/ccqE1W9S.o: in function `main':
> main.c:(.text.startup+0x25e): undefined reference to `open_ioat'
> collect2: error: ld returned 1 exit status
> make: *** [Makefile:39: build/vhost-switch-shared] Error 1
> 
> 
> There are at least two problems:
> - the code in main.c unconditionally expects the ioat stuff to be
> available (this is why the link fails above),
> - the Makefile unconditionally compiles ioat.c, which you fixed with this patch,
> 
> There is a potential additional problem:
> I would expect a need for linking against the rte_raw_ioat driver, but
> we are "lucky" that all that is used in this example are inlines.
> So I guess it works without adding anything to LDFLAGS_SHARED.
> 
> 
> >
> > Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> > ---
> >  examples/vhost/Makefile    | 5 +++++
> >  examples/vhost/ioat.h      | 2 +-
> >  examples/vhost/meson.build | 2 +-
> >  3 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
> > index cec59d0e0f..505e443217 100644
> > --- a/examples/vhost/Makefile
> > +++ b/examples/vhost/Makefile
> > @@ -5,7 +5,12 @@
> >  APP = vhost-switch
> >
> >  # all source are stored in SRCS-y
> > +IOAT_PATH = $(shell pkg-config --cflags-only-I libdpdk | sed -e
> "s/^..//")/rte_ioat_rawdev.h
> > +ifeq ($(IOAT_PATH), $(wildcard $(IOAT_PATH)))
> > +SRCS-y := main.c virtio_net.c ioat.c
> > +else
> >  SRCS-y := main.c virtio_net.c
> > +endif
> 
> I'd rather rely on the driver define since the C code relies on it:
> Something like:
> 
>  PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
>  CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
>  LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
>  LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
> +
> +HAS_RAW_IOAT=$(shell echo RTE_RAW_IOAT | $(CPP) $(CFLAGS) -P - | tail
> -1)
> +ifeq ($(HAS_RAW_IOAT), 1)
> +SRCS-y += ioat.c
> +endif
> 

Sure, I will fix it in the next version, thanks a lot.

> 
> >
> >  # Build using pkg-config variables if possible
> >  ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
> > diff --git a/examples/vhost/ioat.h b/examples/vhost/ioat.h
> > index 9664fcc3ac..d6d0f7c18a 100644
> > --- a/examples/vhost/ioat.h
> > +++ b/examples/vhost/ioat.h
> > @@ -24,7 +24,7 @@ struct dma_for_vhost {
> >         uint16_t nr;
> >  };
> >
> > -#ifdef RTE_ARCH_X86
> > +#ifdef RTE_RAW_IOAT
> >  int open_ioat(const char *value);
> 
> main.c should check for RTE_RAW_IOAT before including ioat.h.
> And then in this header, you can remove this stub too.
> 

As for this one, ioat.h don't have dependency on IOAT driver, it is needed by the example regardless of whether the raw/ioat driver exists. And I added more RTE_RAW_IOAT check in ioat.h. Now it can be compiled.

Thanks,
Cheng

> 
> >  #else
> >  static int open_ioat(const char *value __rte_unused)
> 
> 
> --
> David Marchand
Bruce Richardson Nov. 12, 2020, 9:31 a.m. UTC | #4
On Thu, Nov 12, 2020 at 07:14:26AM +0000, Jiang, Cheng1 wrote:
> Hi,
> 
> > -----Original Message-----
> > From: David Marchand <david.marchand@redhat.com>
> > Sent: Wednesday, November 11, 2020 10:36 PM
> > To: Jiang, Cheng1 <cheng1.jiang@intel.com>
> > Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; Xia, Chenbo
> > <chenbo.xia@intel.com>; dev <dev@dpdk.org>; Fu, Patrick
> > <patrick.fu@intel.com>; Yang, YvonneX <yvonnex.yang@intel.com>; Hu,
> > Jiayu <jiayu.hu@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> > Yigit, Ferruh <ferruh.yigit@intel.com>
> > Subject: Re: [PATCH v1] examples/vhost: fix ioat dependency issue
> > 
> > On Wed, Nov 11, 2020 at 12:29 PM Cheng Jiang <Cheng1.jiang@intel.com>
> > wrote:
> > >
> > > Fix vhost-switch compiling issue when ioat dependency is missing.
> > > Change 'RTE_x86' check into 'RTE_RAW_IOAT' check in meson build file
> > > and update Makefile.
> > 
> > Still failing for me.
> > 98b4c65506 - (HEAD) examples/vhost: fix ioat dependency issue (28
> > seconds ago) <Cheng Jiang>
> > a8adac0bc0 - (origin/main) doc: add instructions for building 32-bit
> > DPDK (5 days ago) <Bruce Richardson>
> > 
> > Please try the reproducer I gave:
> > 
> > rm -f build/vhost-switch build/vhost-switch-static build/vhost-switch-shared
> > test -d build && rmdir -p build || true
> > cc -O3 -I/home/dmarchan/dpdk/installdir/usr/local/include -include
> > rte_config.h -march=native -I/usr/usr/include
> > -DALLOW_EXPERIMENTAL_API main.c virtio_net.c -o
> > build/vhost-switch-shared -pthread -Wl,--as-needed
> > -L/home/dmarchan/dpdk/installdir/usr/local/lib64 -lrte_node
> > -lrte_graph -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table
> > -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack
> > -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_regexdev
> > -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm
> > -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso
> > -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev
> > -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev
> > -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci
> > -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu
> > -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lbsd
> > /usr/bin/ld: /tmp/ccqE1W9S.o: in function `new_device':
> > main.c:(.text+0x173): undefined reference to `ioat_transfer_data_cb'
> > /usr/bin/ld: main.c:(.text+0x178): undefined reference to
> > `ioat_check_completed_copies_cb'
> > /usr/bin/ld: /tmp/ccqE1W9S.o: in function `main':
> > main.c:(.text.startup+0x25e): undefined reference to `open_ioat'
> > collect2: error: ld returned 1 exit status
> > make: *** [Makefile:39: build/vhost-switch-shared] Error 1
> > 
> > 
> > There are at least two problems:
> > - the code in main.c unconditionally expects the ioat stuff to be
> > available (this is why the link fails above),
> > - the Makefile unconditionally compiles ioat.c, which you fixed with this patch,
> > 
> > There is a potential additional problem:
> > I would expect a need for linking against the rte_raw_ioat driver, but
> > we are "lucky" that all that is used in this example are inlines.
> > So I guess it works without adding anything to LDFLAGS_SHARED.
> > 
> > 
> > >
> > > Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> > > ---
> > >  examples/vhost/Makefile    | 5 +++++
> > >  examples/vhost/ioat.h      | 2 +-
> > >  examples/vhost/meson.build | 2 +-
> > >  3 files changed, 7 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
> > > index cec59d0e0f..505e443217 100644
> > > --- a/examples/vhost/Makefile
> > > +++ b/examples/vhost/Makefile
> > > @@ -5,7 +5,12 @@
> > >  APP = vhost-switch
> > >
> > >  # all source are stored in SRCS-y
> > > +IOAT_PATH = $(shell pkg-config --cflags-only-I libdpdk | sed -e
> > "s/^..//")/rte_ioat_rawdev.h
> > > +ifeq ($(IOAT_PATH), $(wildcard $(IOAT_PATH)))
> > > +SRCS-y := main.c virtio_net.c ioat.c
> > > +else
> > >  SRCS-y := main.c virtio_net.c
> > > +endif
> > 
> > I'd rather rely on the driver define since the C code relies on it:
> > Something like:
> > 
> >  PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
> >  CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
> >  LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
> >  LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
> > +
> > +HAS_RAW_IOAT=$(shell echo RTE_RAW_IOAT | $(CPP) $(CFLAGS) -P - | tail
> > -1)
> > +ifeq ($(HAS_RAW_IOAT), 1)
> > +SRCS-y += ioat.c
> > +endif
> > 
> 
> Sure, I will fix it in the next version, thanks a lot.
> 
> > 
> > >
> > >  # Build using pkg-config variables if possible
> > >  ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
> > > diff --git a/examples/vhost/ioat.h b/examples/vhost/ioat.h
> > > index 9664fcc3ac..d6d0f7c18a 100644
> > > --- a/examples/vhost/ioat.h
> > > +++ b/examples/vhost/ioat.h
> > > @@ -24,7 +24,7 @@ struct dma_for_vhost {
> > >         uint16_t nr;
> > >  };
> > >
> > > -#ifdef RTE_ARCH_X86
> > > +#ifdef RTE_RAW_IOAT
> > >  int open_ioat(const char *value);
> > 
> > main.c should check for RTE_RAW_IOAT before including ioat.h.
> > And then in this header, you can remove this stub too.
> > 
> 
> As for this one, ioat.h don't have dependency on IOAT driver, it is needed by the example regardless of whether the raw/ioat driver exists. And I added more RTE_RAW_IOAT check in ioat.h. Now it can be compiled.
> 

The trouble is that the ioat header file won't be installed if the driver
is not built. They will be available for building inside the source tree,
but not on a system with dpdk installed using "ninja install"

/Bruce
David Marchand Nov. 12, 2020, 9:39 a.m. UTC | #5
On Thu, Nov 12, 2020 at 10:31 AM Bruce Richardson
<bruce.richardson@intel.com> wrote:
> > > main.c should check for RTE_RAW_IOAT before including ioat.h.
> > > And then in this header, you can remove this stub too.
> > >
> >
> > As for this one, ioat.h don't have dependency on IOAT driver, it is needed by the example regardless of whether the raw/ioat driver exists. And I added more RTE_RAW_IOAT check in ioat.h. Now it can be compiled.
> >
>
> The trouble is that the ioat header file won't be installed if the driver
> is not built. They will be available for building inside the source tree,
> but not on a system with dpdk installed using "ninja install"

I tested disabling the driver, and I can see:
installdir/usr/local/share/dpdk/examples/vhost/ioat.h
Bruce Richardson Nov. 12, 2020, 10:22 a.m. UTC | #6
On Thu, Nov 12, 2020 at 10:39:33AM +0100, David Marchand wrote:
> On Thu, Nov 12, 2020 at 10:31 AM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> > > > main.c should check for RTE_RAW_IOAT before including ioat.h.
> > > > And then in this header, you can remove this stub too.
> > > >
> > >
> > > As for this one, ioat.h don't have dependency on IOAT driver, it is needed by the example regardless of whether the raw/ioat driver exists. And I added more RTE_RAW_IOAT check in ioat.h. Now it can be compiled.
> > >
> >
> > The trouble is that the ioat header file won't be installed if the driver
> > is not built. They will be available for building inside the source tree,
> > but not on a system with dpdk installed using "ninja install"
> 
> I tested disabling the driver, and I can see:
> installdir/usr/local/share/dpdk/examples/vhost/ioat.h
> 
My mistake, I assumed the reference was to the rte_ioat_rawdev.h file from
the ioat driver.
Please ignore my comment so.
diff mbox series

Patch

diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index cec59d0e0f..505e443217 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -5,7 +5,12 @@ 
 APP = vhost-switch
 
 # all source are stored in SRCS-y
+IOAT_PATH = $(shell pkg-config --cflags-only-I libdpdk | sed -e "s/^..//")/rte_ioat_rawdev.h
+ifeq ($(IOAT_PATH), $(wildcard $(IOAT_PATH)))
+SRCS-y := main.c virtio_net.c ioat.c
+else
 SRCS-y := main.c virtio_net.c
+endif
 
 # Build using pkg-config variables if possible
 ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
diff --git a/examples/vhost/ioat.h b/examples/vhost/ioat.h
index 9664fcc3ac..d6d0f7c18a 100644
--- a/examples/vhost/ioat.h
+++ b/examples/vhost/ioat.h
@@ -24,7 +24,7 @@  struct dma_for_vhost {
 	uint16_t nr;
 };
 
-#ifdef RTE_ARCH_X86
+#ifdef RTE_RAW_IOAT
 int open_ioat(const char *value);
 #else
 static int open_ioat(const char *value __rte_unused)
diff --git a/examples/vhost/meson.build b/examples/vhost/meson.build
index 24f1f71313..d5388a795a 100644
--- a/examples/vhost/meson.build
+++ b/examples/vhost/meson.build
@@ -15,7 +15,7 @@  sources = files(
 	'main.c', 'virtio_net.c'
 )
 
-if dpdk_conf.has('RTE_ARCH_X86')
+if dpdk_conf.has('RTE_RAW_IOAT')
 	deps += 'raw_ioat'
 	sources += files('ioat.c')
 endif