[v7,7/7] net: mark all big endian types

Message ID 20230203164854.602595-8-ferruh.yigit@amd.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series start cleanup of rte_flow_item_* |

Checks

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

Commit Message

Ferruh Yigit Feb. 3, 2023, 4:48 p.m. UTC
  From: Thomas Monjalon <thomas@monjalon.net>

Some protocols (ARP, MPLS and HIGIG2) were using uint16_t and uint32_t
types for their 16 and 32-bit fields.
It was correct but not conveying the big endian nature of these fields.

As for other protocols defined in this directory,
all types are explicitly marked as big endian fields.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 lib/ethdev/rte_flow.h |  4 ++--
 lib/net/rte_arp.h     | 28 ++++++++++++++--------------
 lib/net/rte_gre.h     |  2 +-
 lib/net/rte_higig.h   |  6 +++---
 lib/net/rte_mpls.h    |  2 +-
 5 files changed, 21 insertions(+), 21 deletions(-)
  

Patch

diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index b8f66d668cac..7b780f70a56f 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -642,8 +642,8 @@  struct rte_flow_item_higig2_hdr {
 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
 	.hdr = {
 		.ppt1 = {
-			.classification = 0xffff,
-			.vid = 0xfff,
+			.classification = RTE_BE16(UINT16_MAX),
+			.vid = RTE_BE16(0xfff),
 		},
 	},
 };
diff --git a/lib/net/rte_arp.h b/lib/net/rte_arp.h
index 076c8ab314ee..c3cd0afb5ca8 100644
--- a/lib/net/rte_arp.h
+++ b/lib/net/rte_arp.h
@@ -23,28 +23,28 @@  extern "C" {
  */
 struct rte_arp_ipv4 {
 	struct rte_ether_addr arp_sha;  /**< sender hardware address */
-	uint32_t          arp_sip;  /**< sender IP address */
+	rte_be32_t            arp_sip;  /**< sender IP address */
 	struct rte_ether_addr arp_tha;  /**< target hardware address */
-	uint32_t          arp_tip;  /**< target IP address */
+	rte_be32_t            arp_tip;  /**< target IP address */
 } __rte_packed __rte_aligned(2);
 
 /**
  * ARP header.
  */
 struct rte_arp_hdr {
-	uint16_t arp_hardware;    /* format of hardware address */
-#define RTE_ARP_HRD_ETHER     1  /* ARP Ethernet address format */
+	rte_be16_t arp_hardware; /**< format of hardware address */
+#define RTE_ARP_HRD_ETHER     1  /**< ARP Ethernet address format */
 
-	uint16_t arp_protocol;    /* format of protocol address */
-	uint8_t  arp_hlen;    /* length of hardware address */
-	uint8_t  arp_plen;    /* length of protocol address */
-	uint16_t arp_opcode;     /* ARP opcode (command) */
-#define	RTE_ARP_OP_REQUEST    1 /* request to resolve address */
-#define	RTE_ARP_OP_REPLY      2 /* response to previous request */
-#define	RTE_ARP_OP_REVREQUEST 3 /* request proto addr given hardware */
-#define	RTE_ARP_OP_REVREPLY   4 /* response giving protocol address */
-#define	RTE_ARP_OP_INVREQUEST 8 /* request to identify peer */
-#define	RTE_ARP_OP_INVREPLY   9 /* response identifying peer */
+	rte_be16_t arp_protocol; /**< format of protocol address */
+	uint8_t    arp_hlen;     /**< length of hardware address */
+	uint8_t    arp_plen;     /**< length of protocol address */
+	rte_be16_t arp_opcode;   /**< ARP opcode (command) */
+#define	RTE_ARP_OP_REQUEST    1  /**< request to resolve address */
+#define	RTE_ARP_OP_REPLY      2  /**< response to previous request */
+#define	RTE_ARP_OP_REVREQUEST 3  /**< request proto addr given hardware */
+#define	RTE_ARP_OP_REVREPLY   4  /**< response giving protocol address */
+#define	RTE_ARP_OP_INVREQUEST 8  /**< request to identify peer */
+#define	RTE_ARP_OP_INVREPLY   9  /**< response identifying peer */
 
 	struct rte_arp_ipv4 arp_data;
 } __rte_packed __rte_aligned(2);
diff --git a/lib/net/rte_gre.h b/lib/net/rte_gre.h
index 6c6aef6fcaa0..8da8027b43da 100644
--- a/lib/net/rte_gre.h
+++ b/lib/net/rte_gre.h
@@ -45,7 +45,7 @@  struct rte_gre_hdr {
 	uint16_t res3:5; /**< Reserved */
 	uint16_t ver:3;  /**< Version Number */
 #endif
-	uint16_t proto;  /**< Protocol Type */
+	rte_be16_t proto;  /**< Protocol Type */
 } __rte_packed;
 
 /**
diff --git a/lib/net/rte_higig.h b/lib/net/rte_higig.h
index b55fb1a7db44..bba3898a883f 100644
--- a/lib/net/rte_higig.h
+++ b/lib/net/rte_higig.h
@@ -112,9 +112,9 @@  struct rte_higig2_ppt_type0 {
  */
 __extension__
 struct rte_higig2_ppt_type1 {
-	uint16_t classification;
-	uint16_t resv;
-	uint16_t vid;
+	rte_be16_t classification;
+	rte_be16_t resv;
+	rte_be16_t vid;
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 	uint16_t opcode:3;
 	uint16_t resv1:2;
diff --git a/lib/net/rte_mpls.h b/lib/net/rte_mpls.h
index 3e8cb90ec383..51523e7a1188 100644
--- a/lib/net/rte_mpls.h
+++ b/lib/net/rte_mpls.h
@@ -23,7 +23,7 @@  extern "C" {
  */
 __extension__
 struct rte_mpls_hdr {
-	uint16_t tag_msb;   /**< Label(msb). */
+	rte_be16_t tag_msb; /**< Label(msb). */
 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
 	uint8_t tag_lsb:4;  /**< Label(lsb). */
 	uint8_t tc:3;       /**< Traffic class. */