[v2] net: fix build with sparse on L2TPv2 bitfields

Message ID 20211028101428.15007-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net: fix build with sparse on L2TPv2 bitfields |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

David Marchand Oct. 28, 2021, 10:14 a.m. UTC
  An external project that wants to do additional checks on fields
endianness can remap rte_beXX types to instrumented types and use
sparse.

The current code breaks OVS build with sparse:
../../lib/ofp-packet.c: note: in included file (through
  .../ovs/dpdk-dir/build/include/rte_flow.h, ../../lib/netdev-dpdk.h,
  ../../lib/dp-packet.h):
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:92:37:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:93:37:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:94:40:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:95:37:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:96:40:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:97:37:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:98:37:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:99:40:
  error: invalid bitfield specifier for type restricted ovs_be16.
.../ovs/dpdk-dir/build/include/rte_l2tpv2.h:100:39:
  error: invalid bitfield specifier for type restricted ovs_be16.
make[3]: *** [lib/ofp-packet.lo] Error 1

Use simple uint16_t types for bitfields in L2TPv2 struct.

Fixes: 3a929df1f286 ("ethdev: support L2TPv2 and PPP procotol")

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/net/rte_l2tpv2.h | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
  

Comments

Ferruh Yigit Oct. 28, 2021, 6:44 p.m. UTC | #1
On 10/28/2021 11:14 AM, David Marchand wrote:
> An external project that wants to do additional checks on fields
> endianness can remap rte_beXX types to instrumented types and use
> sparse.
> 
> The current code breaks OVS build with sparse:
> ../../lib/ofp-packet.c: note: in included file (through
>    .../ovs/dpdk-dir/build/include/rte_flow.h, ../../lib/netdev-dpdk.h,
>    ../../lib/dp-packet.h):
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:92:37:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:93:37:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:94:40:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:95:37:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:96:40:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:97:37:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:98:37:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:99:40:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> .../ovs/dpdk-dir/build/include/rte_l2tpv2.h:100:39:
>    error: invalid bitfield specifier for type restricted ovs_be16.
> make[3]: *** [lib/ofp-packet.lo] Error 1
> 
> Use simple uint16_t types for bitfields in L2TPv2 struct.
> 
> Fixes: 3a929df1f286 ("ethdev: support L2TPv2 and PPP procotol")
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/lib/net/rte_l2tpv2.h b/lib/net/rte_l2tpv2.h
index 670fe5470e..b90e36cf12 100644
--- a/lib/net/rte_l2tpv2.h
+++ b/lib/net/rte_l2tpv2.h
@@ -89,25 +89,25 @@  struct rte_l2tpv2_common_hdr {
 		__extension__
 		struct {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
-			rte_be16_t t:1;		/**< message Type */
-			rte_be16_t l:1;		/**< length option bit */
-			rte_be16_t res1:2;	/**< reserved */
-			rte_be16_t s:1;		/**< ns/nr option bit */
-			rte_be16_t res2:1;	/**< reserved */
-			rte_be16_t o:1;		/**< offset option bit */
-			rte_be16_t p:1;		/**< priority option bit */
-			rte_be16_t res3:4;	/**< reserved */
-			rte_be16_t ver:4;	/**< protocol version */
+			uint16_t t:1;		/**< message Type */
+			uint16_t l:1;		/**< length option bit */
+			uint16_t res1:2;	/**< reserved */
+			uint16_t s:1;		/**< ns/nr option bit */
+			uint16_t res2:1;	/**< reserved */
+			uint16_t o:1;		/**< offset option bit */
+			uint16_t p:1;		/**< priority option bit */
+			uint16_t res3:4;	/**< reserved */
+			uint16_t ver:4;		/**< protocol version */
 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
-			rte_be16_t ver:4;	/**< protocol version */
-			rte_be16_t res3:4;	/**< reserved */
-			rte_be16_t p:1;		/**< priority option bit */
-			rte_be16_t o:1;		/**< offset option bit */
-			rte_be16_t res2:1;	/**< reserved */
-			rte_be16_t s:1;		/**< ns/nr option bit */
-			rte_be16_t res1:2;	/**< reserved */
-			rte_be16_t l:1;		/**< length option bit */
-			rte_be16_t t:1;		/**< message Type */
+			uint16_t ver:4;		/**< protocol version */
+			uint16_t res3:4;	/**< reserved */
+			uint16_t p:1;		/**< priority option bit */
+			uint16_t o:1;		/**< offset option bit */
+			uint16_t res2:1;	/**< reserved */
+			uint16_t s:1;		/**< ns/nr option bit */
+			uint16_t res1:2;	/**< reserved */
+			uint16_t l:1;		/**< length option bit */
+			uint16_t t:1;		/**< message Type */
 #endif
 		};
 	};