[dpdk-dev] weak functions in some drivers

2016-07-14 Thread Zoltan Kiss
Hi,

On 01/07/16 11:19, Sergio Gonzalez Monroy wrote:
> On 01/07/2016 11:16, Elo, Matias (Nokia - FI/Espoo) wrote:
>>> -Original Message-
>>> From: Sergio Gonzalez Monroy [mailto:sergio.gonzalez.monroy at intel.com]
>>> Sent: Friday, July 01, 2016 1:05 PM
>>> To: Elo, Matias (Nokia - FI/Espoo) ;
>>> dev at dpdk.org
>>> Cc: ferruh.yigit at intel.com; damarion at cisco.com
>>> Subject: Re: [dpdk-dev] weak functions in some drivers
>>>
>>> On 01/07/2016 10:42, Elo, Matias (Nokia - FI/Espoo) wrote:
>>>>>>>>> What is not clear to me is motivation to use weak here instead
>>>>>>>>> of simply
>>>>>> using >CONFIG_RTE_I40E_INC_VECTOR
>>>>>>>>> macro to exclude stubs in i40e_rxtx.c. It will make library
>>>>>>>>> smaller and
>>> avoid
>>>>>> issues like this one
>>>>>>>>> which are quite hard to troubleshoot.
>>>>>>>> Since this issue seen in fd.io, I didn't investigated more, but
>>>>>>>> I don't
>>>>>>>> want to clock your valid question, this is an attempt to
>>>>>>>> resurrect the
>>>>>>>> question ...
>>>>>>> Hi,
>>>>>>>
>>>>>>> We are having exactly the same problem. For us the aforementioned
>>>>>> workaround doesn't seem to work and vector mode is always disabled
>>>>>> with
>>> the
>>>>>> i40e drivers. If I modify i40e_rxtx.c and exclude the stub
>>>>>> functions using
>>>>>> CONFIG_RTE_I40E_INC_VECTOR everything works as expected.
>>>>>>> We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option
>>>>>> enabled and link DPDK library to our application.
>>>>>>> Any other ideas how this could be fixed?
>>>>>>>
>>>>>>> Regards,
>>>>>>> Matias
>>>>>>>
>>>>>> So you have tried to link a combined static lib with --whole-archive
>>>>>> -ldpdk --no-whole-archive and still get the wrong/weak function
>>>>>> definition?
>>>>>>
>>>>>> Sergio
>>>>> I actually just managed to fix the problem. In our case I had to add
>>>>> '-Wl,--whole-archive,-ldpdk,--no-whole-archive'  to the end of
>>>>> AM_LDFLAGS.
>>>>>
>>>> It turned out that the problem actually wasn't fixed.
>>>>
>>>> DPDK is built with CONFIG_RTE_BUILD_COMBINE_LIBS=y and
>>> EXTRA_CFLAGS="-fPIC"
>>>> What we are linking originally:
>>>> -l:libdpdk.a
>>>>
>>>> This works otherwise but vector mode i40e is not enabled.
>>>>
>>>> When trying:
>>>> -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive
>>>>
>>>> Linking fails with ' undefined reference' errors to several dpdk
>>>> functions
>>> (rte_eal_init, rte_cpu_get_flag_enabled, rte_eth_stats_get...).
>>>> Btw. there seems to be a Stack Overflow question related to this:
>>> http://stackoverflow.com/questions/38064021/dpdk-include-libraries-in-dpdk-
>>>
>>> application-compiled-as-shared-library
>>>> -Matias
>>> What DPDK version are you using?
>> v16.04
>
> Ok. I was asking because there is no CONFIG_RTE_BUILD_COMBINE_LIBS in
> 16.04.
>
>
> Could you provide full link/compile command line? I'm not able to
> reproduce the issue so far

I've dug into this issue a bit, let me explain it with some example code:

main.c:
void bar(void);
void foo(void);

int main() {
bar();
//foo();
}
==
weak.c:
#include 

void __attribute__((weak)) foo(void) {
printf("Weak\n");
}

void bar(void) {
foo();
printf("No call\n");
}
==
strong.c:
#include 

void foo(void) {
printf("Strong\n");
}

Compile the second two into a library and link it with main:

gcc -o strong.o -c strong.c
ar rcs libbar.a strong.o weak.o
gcc main.c -L. -lbar -o main

Then look which foo were used:

objdump -x libbar.a | grep foo
 g F .text  0010 foo
  wF .text  0010 foo
0015 R_X86_64_PC32 foo-0x0004

objdump -x main | grep foo
00400538 w F .text 0010 foo

So it got the weak version, 

[dpdk-dev] weak functions in some drivers

2016-07-01 Thread Sergio Gonzalez Monroy
On 01/07/2016 11:16, Elo, Matias (Nokia - FI/Espoo) wrote:
>> -Original Message-
>> From: Sergio Gonzalez Monroy [mailto:sergio.gonzalez.monroy at intel.com]
>> Sent: Friday, July 01, 2016 1:05 PM
>> To: Elo, Matias (Nokia - FI/Espoo) ;
>> dev at dpdk.org
>> Cc: ferruh.yigit at intel.com; damarion at cisco.com
>> Subject: Re: [dpdk-dev] weak functions in some drivers
>>
>> On 01/07/2016 10:42, Elo, Matias (Nokia - FI/Espoo) wrote:
>>>>>>>> What is not clear to me is motivation to use weak here instead of 
>>>>>>>> simply
>>>>> using >CONFIG_RTE_I40E_INC_VECTOR
>>>>>>>> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and
>> avoid
>>>>> issues like this one
>>>>>>>> which are quite hard to troubleshoot.
>>>>>>> Since this issue seen in fd.io, I didn't investigated more, but I don't
>>>>>>> want to clock your valid question, this is an attempt to resurrect the
>>>>>>> question ...
>>>>>> Hi,
>>>>>>
>>>>>> We are having exactly the same problem. For us the aforementioned
>>>>> workaround doesn't seem to work and vector mode is always disabled with
>> the
>>>>> i40e drivers. If I modify i40e_rxtx.c and exclude the stub functions using
>>>>> CONFIG_RTE_I40E_INC_VECTOR everything works as expected.
>>>>>> We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option
>>>>> enabled and link DPDK library to our application.
>>>>>> Any other ideas how this could be fixed?
>>>>>>
>>>>>> Regards,
>>>>>> Matias
>>>>>>
>>>>> So you have tried to link a combined static lib with --whole-archive
>>>>> -ldpdk --no-whole-archive and still get the wrong/weak function 
>>>>> definition?
>>>>>
>>>>> Sergio
>>>> I actually just managed to fix the problem. In our case I had to add
>>>> '-Wl,--whole-archive,-ldpdk,--no-whole-archive'  to the end of AM_LDFLAGS.
>>>>
>>> It turned out that the problem actually wasn't fixed.
>>>
>>> DPDK is built with CONFIG_RTE_BUILD_COMBINE_LIBS=y and
>> EXTRA_CFLAGS="-fPIC"
>>> What we are linking originally:
>>> -l:libdpdk.a
>>>
>>> This works otherwise but vector mode i40e is not enabled.
>>>
>>> When trying:
>>> -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive
>>>
>>> Linking fails with ' undefined reference' errors to several dpdk functions
>> (rte_eal_init, rte_cpu_get_flag_enabled, rte_eth_stats_get...).
>>> Btw. there seems to be a Stack Overflow question related to this:
>> http://stackoverflow.com/questions/38064021/dpdk-include-libraries-in-dpdk-
>> application-compiled-as-shared-library
>>> -Matias
>> What DPDK version are you using?
> v16.04

Ok. I was asking because there is no CONFIG_RTE_BUILD_COMBINE_LIBS in 16.04.


Could you provide full link/compile command line? I'm not able to 
reproduce the issue so far


[dpdk-dev] weak functions in some drivers

2016-07-01 Thread Sergio Gonzalez Monroy
On 01/07/2016 10:42, Elo, Matias (Nokia - FI/Espoo) wrote:
>> What is not clear to me is motivation to use weak here instead of simply
>>> using >CONFIG_RTE_I40E_INC_VECTOR
>> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and 
>> avoid
>>> issues like this one
>> which are quite hard to troubleshoot.
> Since this issue seen in fd.io, I didn't investigated more, but I don't
> want to clock your valid question, this is an attempt to resurrect the
> question ...
 Hi,

 We are having exactly the same problem. For us the aforementioned
>>> workaround doesn't seem to work and vector mode is always disabled with the
>>> i40e drivers. If I modify i40e_rxtx.c and exclude the stub functions using
>>> CONFIG_RTE_I40E_INC_VECTOR everything works as expected.
 We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option
>>> enabled and link DPDK library to our application.
 Any other ideas how this could be fixed?

 Regards,
 Matias

>>> So you have tried to link a combined static lib with --whole-archive
>>> -ldpdk --no-whole-archive and still get the wrong/weak function definition?
>>>
>>> Sergio
>> I actually just managed to fix the problem. In our case I had to add
>> '-Wl,--whole-archive,-ldpdk,--no-whole-archive'  to the end of AM_LDFLAGS.
>>
> It turned out that the problem actually wasn't fixed.
>
> DPDK is built with CONFIG_RTE_BUILD_COMBINE_LIBS=y and EXTRA_CFLAGS="-fPIC"
>
> What we are linking originally:
>   -l:libdpdk.a
>
> This works otherwise but vector mode i40e is not enabled.
>
> When trying:
>   -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive
>
> Linking fails with ' undefined reference' errors to several dpdk functions 
> (rte_eal_init, rte_cpu_get_flag_enabled, rte_eth_stats_get...).
>
> Btw. there seems to be a Stack Overflow question related to this: 
> http://stackoverflow.com/questions/38064021/dpdk-include-libraries-in-dpdk-application-compiled-as-shared-library
>
> -Matias

What DPDK version are you using?


[dpdk-dev] weak functions in some drivers

2016-07-01 Thread Elo, Matias (Nokia - FI/Espoo)
> -Original Message-
> From: Sergio Gonzalez Monroy [mailto:sergio.gonzalez.monroy at intel.com]
> Sent: Friday, July 01, 2016 1:05 PM
> To: Elo, Matias (Nokia - FI/Espoo) ;
> dev at dpdk.org
> Cc: ferruh.yigit at intel.com; damarion at cisco.com
> Subject: Re: [dpdk-dev] weak functions in some drivers
> 
> On 01/07/2016 10:42, Elo, Matias (Nokia - FI/Espoo) wrote:
> >>>>>> What is not clear to me is motivation to use weak here instead of 
> >>>>>> simply
> >>> using >CONFIG_RTE_I40E_INC_VECTOR
> >>>>>> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and
> avoid
> >>> issues like this one
> >>>>>> which are quite hard to troubleshoot.
> >>>>> Since this issue seen in fd.io, I didn't investigated more, but I don't
> >>>>> want to clock your valid question, this is an attempt to resurrect the
> >>>>> question ...
> >>>> Hi,
> >>>>
> >>>> We are having exactly the same problem. For us the aforementioned
> >>> workaround doesn't seem to work and vector mode is always disabled with
> the
> >>> i40e drivers. If I modify i40e_rxtx.c and exclude the stub functions using
> >>> CONFIG_RTE_I40E_INC_VECTOR everything works as expected.
> >>>> We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option
> >>> enabled and link DPDK library to our application.
> >>>> Any other ideas how this could be fixed?
> >>>>
> >>>> Regards,
> >>>> Matias
> >>>>
> >>> So you have tried to link a combined static lib with --whole-archive
> >>> -ldpdk --no-whole-archive and still get the wrong/weak function 
> >>> definition?
> >>>
> >>> Sergio
> >> I actually just managed to fix the problem. In our case I had to add
> >> '-Wl,--whole-archive,-ldpdk,--no-whole-archive'  to the end of AM_LDFLAGS.
> >>
> > It turned out that the problem actually wasn't fixed.
> >
> > DPDK is built with CONFIG_RTE_BUILD_COMBINE_LIBS=y and
> EXTRA_CFLAGS="-fPIC"
> >
> > What we are linking originally:
> > -l:libdpdk.a
> >
> > This works otherwise but vector mode i40e is not enabled.
> >
> > When trying:
> > -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive
> >
> > Linking fails with ' undefined reference' errors to several dpdk functions
> (rte_eal_init, rte_cpu_get_flag_enabled, rte_eth_stats_get...).
> >
> > Btw. there seems to be a Stack Overflow question related to this:
> http://stackoverflow.com/questions/38064021/dpdk-include-libraries-in-dpdk-
> application-compiled-as-shared-library
> >
> > -Matias
> 
> What DPDK version are you using?

v16.04


[dpdk-dev] weak functions in some drivers

2016-07-01 Thread Elo, Matias (Nokia - FI/Espoo)
> > >>> What is not clear to me is motivation to use weak here instead of simply
> > using >CONFIG_RTE_I40E_INC_VECTOR
> > >>> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and 
> > >>> avoid
> > issues like this one
> > >>> which are quite hard to troubleshoot.
> > >> Since this issue seen in fd.io, I didn't investigated more, but I don't
> > >> want to clock your valid question, this is an attempt to resurrect the
> > >> question ...
> > > Hi,
> > >
> > > We are having exactly the same problem. For us the aforementioned
> > workaround doesn't seem to work and vector mode is always disabled with the
> > i40e drivers. If I modify i40e_rxtx.c and exclude the stub functions using
> > CONFIG_RTE_I40E_INC_VECTOR everything works as expected.
> > >
> > > We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option
> > enabled and link DPDK library to our application.
> > >
> > > Any other ideas how this could be fixed?
> > >
> > > Regards,
> > > Matias
> > >
> >
> > So you have tried to link a combined static lib with --whole-archive
> > -ldpdk --no-whole-archive and still get the wrong/weak function definition?
> >
> > Sergio
> 
> I actually just managed to fix the problem. In our case I had to add
> '-Wl,--whole-archive,-ldpdk,--no-whole-archive'  to the end of AM_LDFLAGS.
> 

It turned out that the problem actually wasn't fixed.

DPDK is built with CONFIG_RTE_BUILD_COMBINE_LIBS=y and EXTRA_CFLAGS="-fPIC"

What we are linking originally:
-l:libdpdk.a

This works otherwise but vector mode i40e is not enabled.

When trying:
-Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive

Linking fails with ' undefined reference' errors to several dpdk functions 
(rte_eal_init, rte_cpu_get_flag_enabled, rte_eth_stats_get...).

Btw. there seems to be a Stack Overflow question related to this: 
http://stackoverflow.com/questions/38064021/dpdk-include-libraries-in-dpdk-application-compiled-as-shared-library
 

-Matias


[dpdk-dev] weak functions in some drivers

2016-06-30 Thread Sergio Gonzalez Monroy
On 29/06/2016 14:26, Elo, Matias (Nokia - FI/Espoo) wrote:
>>> What is not clear to me is motivation to use weak here instead of simply 
>>> using >CONFIG_RTE_I40E_INC_VECTOR
>>> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and 
>>> avoid issues like this one
>>> which are quite hard to troubleshoot.
>> Since this issue seen in fd.io, I didn't investigated more, but I don't
>> want to clock your valid question, this is an attempt to resurrect the
>> question ...
> Hi,
>
> We are having exactly the same problem. For us the aforementioned workaround 
> doesn't seem to work and vector mode is always disabled with the i40e 
> drivers. If I modify i40e_rxtx.c and exclude the stub functions using 
> CONFIG_RTE_I40E_INC_VECTOR everything works as expected.
>
> We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option enabled 
> and link DPDK library to our application.
>
> Any other ideas how this could be fixed?
>
> Regards,
> Matias
>

So you have tried to link a combined static lib with --whole-archive 
-ldpdk --no-whole-archive and still get the wrong/weak function definition?

Sergio


[dpdk-dev] weak functions in some drivers

2016-06-30 Thread Elo, Matias (Nokia - FI/Espoo)
> >>> What is not clear to me is motivation to use weak here instead of simply
> using >CONFIG_RTE_I40E_INC_VECTOR
> >>> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and 
> >>> avoid
> issues like this one
> >>> which are quite hard to troubleshoot.
> >> Since this issue seen in fd.io, I didn't investigated more, but I don't
> >> want to clock your valid question, this is an attempt to resurrect the
> >> question ...
> > Hi,
> >
> > We are having exactly the same problem. For us the aforementioned
> workaround doesn't seem to work and vector mode is always disabled with the
> i40e drivers. If I modify i40e_rxtx.c and exclude the stub functions using
> CONFIG_RTE_I40E_INC_VECTOR everything works as expected.
> >
> > We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option
> enabled and link DPDK library to our application.
> >
> > Any other ideas how this could be fixed?
> >
> > Regards,
> > Matias
> >
> 
> So you have tried to link a combined static lib with --whole-archive
> -ldpdk --no-whole-archive and still get the wrong/weak function definition?
> 
> Sergio

I actually just managed to fix the problem. In our case I had to add
'-Wl,--whole-archive,-ldpdk,--no-whole-archive'  to the end of AM_LDFLAGS.

-Matias


[dpdk-dev] weak functions in some drivers

2016-06-29 Thread Elo, Matias (Nokia - FI/Espoo)
>> What is not clear to me is motivation to use weak here instead of simply 
>> using >CONFIG_RTE_I40E_INC_VECTOR
>> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and 
>> avoid issues like this one
>> which are quite hard to troubleshoot.
>
>Since this issue seen in fd.io, I didn't investigated more, but I don't
>want to clock your valid question, this is an attempt to resurrect the
>question ...

Hi,

We are having exactly the same problem. For us the aforementioned workaround 
doesn't seem to work and vector mode is always disabled with the i40e drivers. 
If I modify i40e_rxtx.c and exclude the stub functions using 
CONFIG_RTE_I40E_INC_VECTOR everything works as expected.

We are building DPDK with the CONFIG_RTE_BUILD_COMBINE_LIBS option enabled and 
link DPDK library to our application.

Any other ideas how this could be fixed?

Regards,
Matias



[dpdk-dev] weak functions in some drivers

2016-06-27 Thread Ferruh Yigit
On 6/21/2016 4:01 PM, Damjan Marion (damarion) wrote:
> 
> Hello,
> 

...

> 
> What is not clear to me is motivation to use weak here instead of simply 
> using CONFIG_RTE_I40E_INC_VECTOR
> macro to exclude stubs in i40e_rxtx.c. It will make library smaller and avoid 
> issues like this one
> which are quite hard to troubleshoot.

Since this issue seen in fd.io, I didn't investigated more, but I don't
want to clock your valid question, this is an attempt to resurrect the
question ...

> 
> BTW Looks like same issue is happening with fm10k driver.
> 



[dpdk-dev] weak functions in some drivers

2016-06-21 Thread Ferruh Yigit
Hi Damjan,

On 6/21/2016 4:01 PM, Damjan Marion (damarion) wrote:
> 
> Hello,
> 
> We just spent few hours troubleshooting why vPMD is not working
> in i40e driver. Conclusion was that problem is caused by linker 
> linking the wrong instance of the i40e_rx_vec_dev_conf_condition_check(...).
> 
> That function is defined 2 times, once in i40e_rxtx.c and once in 
> i40e_rxtx_vec.c. First one is defined as weak and it just returns -1.
> 
> librte_pmd_i40e.a contains both versions:
> 
> $ objdump -x librte_pmd_i40e.a| grep i40e_rx_vec_dev_conf_condition_check
> 6ca0  wF .text0006 
> i40e_rx_vec_dev_conf_condition_check
> 07c1 g F .text.unlikely   001c 
> i40e_rx_vec_dev_conf_condition_check
> 
> However when we are linking our app, linker was picking 1st (weak) one and 
> vPMD init was failing.
App is linking with correct instance of the function for me, how can I
reproduce this linkage issue?

> 
> Workaround we applied to get int working:  -Wl,--whole-archive  
> -Wl,?no-whole-archive
These flags already wraps PMD libraries, can you please give more detail
about workaround?

Thanks,
ferruh


[dpdk-dev] weak functions in some drivers

2016-06-21 Thread Damjan Marion (damarion)


> On 21 Jun 2016, at 09:01, Ferruh Yigit  wrote:
> 
> Hi Damjan,
> 
> On 6/21/2016 4:01 PM, Damjan Marion (damarion) wrote:
>> 
>> Hello,
>> 
>> We just spent few hours troubleshooting why vPMD is not working
>> in i40e driver. Conclusion was that problem is caused by linker 
>> linking the wrong instance of the i40e_rx_vec_dev_conf_condition_check(...).
>> 
>> That function is defined 2 times, once in i40e_rxtx.c and once in 
>> i40e_rxtx_vec.c. First one is defined as weak and it just returns -1.
>> 
>> librte_pmd_i40e.a contains both versions:
>> 
>> $ objdump -x librte_pmd_i40e.a| grep i40e_rx_vec_dev_conf_condition_check
>> 6ca0  wF .text   0006 
>> i40e_rx_vec_dev_conf_condition_check
>> 07c1 g F .text.unlikely  001c 
>> i40e_rx_vec_dev_conf_condition_check
>> 
>> However when we are linking our app, linker was picking 1st (weak) one and 
>> vPMD init was failing.
> App is linking with correct instance of the function for me, how can I
> reproduce this linkage issue?
> 
>> 
>> Workaround we applied to get int working:  -Wl,--whole-archive  
>> -Wl,?no-whole-archive
> These flags already wraps PMD libraries, can you please give more detail
> about workaround?
> 

You can see our exact fix here:

https://git.fd.io/cgit/vpp/commit/?id=0977e4baabd97d1de711a3d7a0f285364a84159c

If you want to repro just pick the commit before this one?

Thanks,

Damjan




[dpdk-dev] weak functions in some drivers

2016-06-21 Thread Damjan Marion (damarion)

Hello,

We just spent few hours troubleshooting why vPMD is not working
in i40e driver. Conclusion was that problem is caused by linker 
linking the wrong instance of the i40e_rx_vec_dev_conf_condition_check(...).

That function is defined 2 times, once in i40e_rxtx.c and once in 
i40e_rxtx_vec.c. First one is defined as weak and it just returns -1.

librte_pmd_i40e.a contains both versions:

$ objdump -x librte_pmd_i40e.a| grep i40e_rx_vec_dev_conf_condition_check
6ca0  wF .text  0006 
i40e_rx_vec_dev_conf_condition_check
07c1 g F .text.unlikely 001c 
i40e_rx_vec_dev_conf_condition_check

However when we are linking our app, linker was picking 1st (weak) one and vPMD 
init was failing.

Workaround we applied to get int working:  -Wl,--whole-archive  
-Wl,?no-whole-archive

What is not clear to me is motivation to use weak here instead of simply using 
CONFIG_RTE_I40E_INC_VECTOR
macro to exclude stubs in i40e_rxtx.c. It will make library smaller and avoid 
issues like this one
which are quite hard to troubleshoot.

BTW Looks like same issue is happening with fm10k driver.

Thanks,

Damjan