diff mbox series

ethdev: fix VXLAN mask initialization value

Message ID 20210408064823.12130-1-getelson@nvidia.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers show
Series ethdev: fix VXLAN mask initialization value | expand

Checks

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

Commit Message

Gregory Etelson April 8, 2021, 6:48 a.m. UTC
In GCC compiler, __builtin_constant_p(exp) is a function.
The function returns the integer 1 if the argument is known to be
a compile-time constant.
Therefore, __builtin_constant_p(0xffffff << 8) returned 1.
As the result, rte_flow_item_vxlan_mask was initiated to
{{
  {flags = 0x0, rsvd0 = {0x0, 0x0, 0x0},
   vni = {0x0, 0x0, 0x0}, rsvd1 = 0x1},
  hdr = {vx_flags = 0x0, vx_vni = 0x1000000}}}
}}
GCC fails initialization
rte_flow_item_vxlan_mask.hdr.vni = (0xffffff << 8)
with "initializer element is not a constant expression" error.
Use immediate 0xffffff00 value instead.

Cc: stable@dpdk.org
Fixes: 43af98e687cf ("ethdev: reuse VXLAN header definition in flow item")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 lib/librte_ethdev/rte_flow.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ferruh Yigit April 8, 2021, 3:35 p.m. UTC | #1
On 4/8/2021 7:48 AM, Gregory Etelson wrote:
> In GCC compiler, __builtin_constant_p(exp) is a function.
> The function returns the integer 1 if the argument is known to be
> a compile-time constant.
> Therefore, __builtin_constant_p(0xffffff << 8) returned 1.
> As the result, rte_flow_item_vxlan_mask was initiated to
> {{
>    {flags = 0x0, rsvd0 = {0x0, 0x0, 0x0},
>     vni = {0x0, 0x0, 0x0}, rsvd1 = 0x1},
>    hdr = {vx_flags = 0x0, vx_vni = 0x1000000}}}
> }}
> GCC fails initialization
> rte_flow_item_vxlan_mask.hdr.vni = (0xffffff << 8)
> with "initializer element is not a constant expression" error.
> Use immediate 0xffffff00 value instead.
> 
> Cc: stable@dpdk.org
> Fixes: 43af98e687cf ("ethdev: reuse VXLAN header definition in flow item")
> 
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Ivan Malov April 8, 2021, 4:31 p.m. UTC | #2
On 4/8/2021 7:48 AM, Gregory Etelson wrote:
 > In GCC compiler, __builtin_constant_p(exp) is a function.
 > The function returns the integer 1 if the argument is known to be
 > a compile-time constant.
 > Therefore, __builtin_constant_p(0xffffff << 8) returned 1.
 > As the result, rte_flow_item_vxlan_mask was initiated to
 > {{
 >    {flags = 0x0, rsvd0 = {0x0, 0x0, 0x0},
 >     vni = {0x0, 0x0, 0x0}, rsvd1 = 0x1},
 >    hdr = {vx_flags = 0x0, vx_vni = 0x1000000}}}
 > }}
 > GCC fails initialization
 > rte_flow_item_vxlan_mask.hdr.vni = (0xffffff << 8)
 > with "initializer element is not a constant expression" error.
 > Use immediate 0xffffff00 value instead.
 >
 > Cc: stable@dpdk.org
 > Fixes: 43af98e687cf ("ethdev: reuse VXLAN header definition in flow 
item")
 >
 > Signed-off-by: Gregory Etelson <getelson@nvidia.com>
 > Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Ferruh Yigit April 9, 2021, 9:28 a.m. UTC | #3
On 4/8/2021 5:31 PM, Ivan Malov wrote:
> On 4/8/2021 7:48 AM, Gregory Etelson wrote:
>> In GCC compiler, __builtin_constant_p(exp) is a function.
>> The function returns the integer 1 if the argument is known to be
>> a compile-time constant.
>> Therefore, __builtin_constant_p(0xffffff << 8) returned 1.
>> As the result, rte_flow_item_vxlan_mask was initiated to
>> {{
>>    {flags = 0x0, rsvd0 = {0x0, 0x0, 0x0},
>>     vni = {0x0, 0x0, 0x0}, rsvd1 = 0x1},
>>    hdr = {vx_flags = 0x0, vx_vni = 0x1000000}}}
>> }}
>> GCC fails initialization
>> rte_flow_item_vxlan_mask.hdr.vni = (0xffffff << 8)
>> with "initializer element is not a constant expression" error.
>> Use immediate 0xffffff00 value instead.
>>
>> Cc: stable@dpdk.org
>> Fixes: 43af98e687cf ("ethdev: reuse VXLAN header definition in flow 
> item")
>>
>> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
>> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> 
> Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> 

Applied to dpdk-next-net/main, thanks.
diff mbox series

Patch

diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index 6cc57136ac..c476a0f59d 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -976,7 +976,7 @@  struct rte_flow_item_vxlan {
 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
 #ifndef __cplusplus
 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
-	.hdr.vx_vni = RTE_BE32(__builtin_constant_p(0xffffff << 8)),
+	.hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
 };
 #endif