[PATCH v2] app/testpmd: fix lcore ID restriction
Ferruh Yigit
ferruh.yigit at amd.com
Thu Jun 13 18:51:14 CEST 2024
On 4/19/2024 12:30 PM, Ferruh Yigit wrote:
> On 4/16/2024 10:55 AM, Sivaprasad Tummala wrote:
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index ba1007ace6..6b28c22c96 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -4785,9 +4785,9 @@ fwd_stream_on_other_lcores(uint16_t domain_id, lcoreid_t src_lc,
>> continue;
>> printf("Shared Rx queue group %u queue %hu can't be scheduled on different cores:\n",
>> share_group, share_rxq);
>> - printf(" lcore %hhu Port %hu queue %hu\n",
>> + printf(" lcore %u Port %hu queue %hu\n",
>> src_lc, src_port, src_rxq);
>> - printf(" lcore %hhu Port %hu queue %hu\n",
>> + printf(" lcore %u Port %hu queue %hu\n",
>> lc_id, fs->rx_port, fs->rx_queue);
>> printf("Please use --nb-cores=%hu to limit number of forwarding cores\n",
>> nb_rxq);
>> @@ -5159,7 +5159,7 @@ icmp_echo_config_setup(void)
>> lcoreid_t lc_id;
>> uint16_t sm_id;
>>
>> - if ((nb_txq * nb_fwd_ports) < nb_fwd_lcores)
>> + if ((lcoreid_t)(nb_txq * nb_fwd_ports) < nb_fwd_lcores)
>> cur_fwd_config.nb_fwd_lcores = (lcoreid_t)
>> (nb_txq * nb_fwd_ports);
>>
>
> Hi Sivaprasad,
>
> Is this '(lcoreid_t)' cast required? Because of integer promotion I
> think result will be correct without casting.
>
> (And without integer promotion considered, casting needs to be done on
> one of the variables, not to the result, because result may be already
> cast down I think. Anyway this is not required for this case since
> variables are u16.)
>
Why casing required (for record) is,
'nb_txq' -> uint16_t, promoted to 'int'
'nb_fwd_ports' -> uint16_t, promoted to 'int'
(nb_txq * nb_fwd_ports) -> result 'int'
nb_fwd_lcores -> 'uint32_t'
comparison between 'int' & 'uint32_t' gives warning. After some compiler
version it is smart enough to not give a warning, but casting is
required for old compilers.
And back to my comment above, casting one of the parameter to
'lcoreid_t' also works, as it forcing promotion to 'unsigned int'
instead. But logically casting looks odd, so keeping casting result.
More information about the dev
mailing list