DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] EAL PCI dev problem when using .a file to compile app
@ 2015-06-18  8:07 Umar Farooq
  2015-06-18 10:06 ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Umar Farooq @ 2015-06-18  8:07 UTC (permalink / raw)
  To: dev

Hi

I am trying to write an application "abc" using DPDK 2.0.0 that calls
rte_eal_init to test if EAL is setup correctly. I have run "helloworld" and
"l2fwd" applications and they run fine on my setup.

A new thing that i am trying is to create a libdpdk.a file using build
target "x86_64-native-linuxapp-gcc" and use it to compile my application.
The application simply calls "rte_eal_init(argc, argv)" and exits. It
compiles successfully and runs but the EAL doesn't initialize the PCI
devices.

The flow is this:

1. The method to create libdpdk.a is by using this shell script:
#bin/bash
rm -f libdpdk.a
cp /path_to/dpdk/x86_64-native-linuxapp-gcc/lib/* .
DPDK_LIBS=$(ls *.a)
for file in *.a; do
    ar -x "$file"
done
ar -rcs libdpdk.a *.o

2. Application is compiled using the command:
gcc abc.c /path_to/dpdk/libdpdk.a
-I/path_to/dpdk/x86_64-native-linuxapp-gcc/include -lpthread -lrt -ldl
-mssse3 -lm -o abc

3. After the successful compilation, the app is run using the command:
./abc -c c -n 4 -b 00:03.0

4. Application calls rte_eal_init(argc, argv), which calls
rte_eal_pci_probe(), which calls pci_probe_all_drivers().

5. In the last function called, pci_probe_all_drivers(struct rte_pci_device
*dev) in
dpdk/lib/librte_eal/common/eal_common_pci.c file, the control never enters
the loop:
TAILQ_FOREACH(dr, &pci_driver_list, next) {
                rc = rte_eal_pci_probe_one_driver(dr, dev);
                if (rc < 0)
                        /* negative value is an error */
                        return -1;
                if (rc > 0)
                        /* positive value means driver not found */
                        continue;
                return 0;
        }

and the function always returns 1.

If the application is compiled using normal Makefile as used by l2fwd or
helloworld example apps, this problem doesn't occur and application calls
the "rte_eal_pci_probe_one_driver(dr, dev)" in "TAILQ_FOREACH" loop.

The question is what am I missing while creating the libdpdk.a and
compiling application using it?

Thanks for your time.

Regards
Umar

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] EAL PCI dev problem when using .a file to compile app
  2015-06-18  8:07 [dpdk-dev] EAL PCI dev problem when using .a file to compile app Umar Farooq
@ 2015-06-18 10:06 ` Bruce Richardson
  2015-06-19  5:15   ` Umar Farooq
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2015-06-18 10:06 UTC (permalink / raw)
  To: Umar Farooq; +Cc: dev

On Thu, Jun 18, 2015 at 01:07:33PM +0500, Umar Farooq wrote:
> Hi
> 
> I am trying to write an application "abc" using DPDK 2.0.0 that calls
> rte_eal_init to test if EAL is setup correctly. I have run "helloworld" and
> "l2fwd" applications and they run fine on my setup.
> 
> A new thing that i am trying is to create a libdpdk.a file using build
> target "x86_64-native-linuxapp-gcc" and use it to compile my application.
> The application simply calls "rte_eal_init(argc, argv)" and exits. It
> compiles successfully and runs but the EAL doesn't initialize the PCI
> devices.
> 
> The flow is this:
> 
> 1. The method to create libdpdk.a is by using this shell script:
> #bin/bash
> rm -f libdpdk.a
> cp /path_to/dpdk/x86_64-native-linuxapp-gcc/lib/* .
> DPDK_LIBS=$(ls *.a)
> for file in *.a; do
>     ar -x "$file"
> done
> ar -rcs libdpdk.a *.o
> 
> 2. Application is compiled using the command:
> gcc abc.c /path_to/dpdk/libdpdk.a
> -I/path_to/dpdk/x86_64-native-linuxapp-gcc/include -lpthread -lrt -ldl
> -mssse3 -lm -o abc
> 
> 3. After the successful compilation, the app is run using the command:
> ./abc -c c -n 4 -b 00:03.0
> 
> 4. Application calls rte_eal_init(argc, argv), which calls
> rte_eal_pci_probe(), which calls pci_probe_all_drivers().
> 
> 5. In the last function called, pci_probe_all_drivers(struct rte_pci_device
> *dev) in
> dpdk/lib/librte_eal/common/eal_common_pci.c file, the control never enters
> the loop:
> TAILQ_FOREACH(dr, &pci_driver_list, next) {
>                 rc = rte_eal_pci_probe_one_driver(dr, dev);
>                 if (rc < 0)
>                         /* negative value is an error */
>                         return -1;
>                 if (rc > 0)
>                         /* positive value means driver not found */
>                         continue;
>                 return 0;
>         }
> 
> and the function always returns 1.
> 
> If the application is compiled using normal Makefile as used by l2fwd or
> helloworld example apps, this problem doesn't occur and application calls
> the "rte_eal_pci_probe_one_driver(dr, dev)" in "TAILQ_FOREACH" loop.
> 
> The question is what am I missing while creating the libdpdk.a and
> compiling application using it?
> 
> Thanks for your time.
> 
> Regards
> Umar

This may be due to a missing "--no-as-needed" flag in the link stage of your
application. If so, the drivers are not getting registered at startup, so pci
probing fails to find your devices.

/Bruce

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] EAL PCI dev problem when using .a file to compile app
  2015-06-18 10:06 ` Bruce Richardson
@ 2015-06-19  5:15   ` Umar Farooq
  0 siblings, 0 replies; 3+ messages in thread
From: Umar Farooq @ 2015-06-19  5:15 UTC (permalink / raw)
  To: dev

Thanks Bruce. In application compilation command, after adding the
"--no-as-needed" flag and some additional flags including

"-Wl,-lrte_pmd_bond -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_pmd_virtio_uio
-Wl,-lrte_pmd_enic -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_fm10k
-Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ring
-Wl,-lrte_pmd_af_packet"

solved the issue.

On Thu, Jun 18, 2015 at 3:06 PM, Bruce Richardson <
bruce.richardson@intel.com> wrote:

> On Thu, Jun 18, 2015 at 01:07:33PM +0500, Umar Farooq wrote:
> > Hi
> >
> > I am trying to write an application "abc" using DPDK 2.0.0 that calls
> > rte_eal_init to test if EAL is setup correctly. I have run "helloworld"
> and
> > "l2fwd" applications and they run fine on my setup.
> >
> > A new thing that i am trying is to create a libdpdk.a file using build
> > target "x86_64-native-linuxapp-gcc" and use it to compile my application.
> > The application simply calls "rte_eal_init(argc, argv)" and exits. It
> > compiles successfully and runs but the EAL doesn't initialize the PCI
> > devices.
> >
> > The flow is this:
> >
> > 1. The method to create libdpdk.a is by using this shell script:
> > #bin/bash
> > rm -f libdpdk.a
> > cp /path_to/dpdk/x86_64-native-linuxapp-gcc/lib/* .
> > DPDK_LIBS=$(ls *.a)
> > for file in *.a; do
> >     ar -x "$file"
> > done
> > ar -rcs libdpdk.a *.o
> >
> > 2. Application is compiled using the command:
> > gcc abc.c /path_to/dpdk/libdpdk.a
> > -I/path_to/dpdk/x86_64-native-linuxapp-gcc/include -lpthread -lrt -ldl
> > -mssse3 -lm -o abc
> >
> > 3. After the successful compilation, the app is run using the command:
> > ./abc -c c -n 4 -b 00:03.0
> >
> > 4. Application calls rte_eal_init(argc, argv), which calls
> > rte_eal_pci_probe(), which calls pci_probe_all_drivers().
> >
> > 5. In the last function called, pci_probe_all_drivers(struct
> rte_pci_device
> > *dev) in
> > dpdk/lib/librte_eal/common/eal_common_pci.c file, the control never
> enters
> > the loop:
> > TAILQ_FOREACH(dr, &pci_driver_list, next) {
> >                 rc = rte_eal_pci_probe_one_driver(dr, dev);
> >                 if (rc < 0)
> >                         /* negative value is an error */
> >                         return -1;
> >                 if (rc > 0)
> >                         /* positive value means driver not found */
> >                         continue;
> >                 return 0;
> >         }
> >
> > and the function always returns 1.
> >
> > If the application is compiled using normal Makefile as used by l2fwd or
> > helloworld example apps, this problem doesn't occur and application calls
> > the "rte_eal_pci_probe_one_driver(dr, dev)" in "TAILQ_FOREACH" loop.
> >
> > The question is what am I missing while creating the libdpdk.a and
> > compiling application using it?
> >
> > Thanks for your time.
> >
> > Regards
> > Umar
>
> This may be due to a missing "--no-as-needed" flag in the link stage of
> your
> application. If so, the drivers are not getting registered at startup, so
> pci
> probing fails to find your devices.
>
> /Bruce
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-19  5:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18  8:07 [dpdk-dev] EAL PCI dev problem when using .a file to compile app Umar Farooq
2015-06-18 10:06 ` Bruce Richardson
2015-06-19  5:15   ` Umar Farooq

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).