From: Mattias Rönnblom <[email protected]>

The first word of the Remote Memory Access message header (type #4) is
described with host byte order bit fields, but unlike the common header
it had no integer alias, leaving no clean way to convert it from network
byte order before accessing the fields.

Add a u32 alias, mirroring struct rte_ecpri_common_hdr. The new union
and struct are anonymous, so the layout, the size and the field access
are all unchanged.

Signed-off-by: Mattias Rönnblom <[email protected]>
---
 lib/net/rte_ecpri.h | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/lib/net/rte_ecpri.h b/lib/net/rte_ecpri.h
index c147cb7b64..5fcc4e5853 100644
--- a/lib/net/rte_ecpri.h
+++ b/lib/net/rte_ecpri.h
@@ -168,17 +168,22 @@ struct rte_ecpri_msg_gen_data {
  * eCPRI Message Header of Type #4: Remote Memory Access
  */
 struct rte_ecpri_msg_rm_access {
+       union {
+               rte_be32_t u32;         /**< 4B first word in BE */
+               struct {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
-       uint32_t ele_id:16;             /**< Element ID */
-       uint32_t rr:4;                  /**< Req/Resp */
-       uint32_t rw:4;                  /**< Read/Write */
-       uint32_t rma_id:8;              /**< Remote Memory Access ID */
+                       uint32_t ele_id:16;     /**< Element ID */
+                       uint32_t rr:4;          /**< Req/Resp */
+                       uint32_t rw:4;          /**< Read/Write */
+                       uint32_t rma_id:8;      /**< Remote Memory Access ID */
 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
-       uint32_t rma_id:8;              /**< Remote Memory Access ID */
-       uint32_t rw:4;                  /**< Read/Write */
-       uint32_t rr:4;                  /**< Req/Resp */
-       uint32_t ele_id:16;             /**< Element ID */
+                       uint32_t rma_id:8;      /**< Remote Memory Access ID */
+                       uint32_t rw:4;          /**< Read/Write */
+                       uint32_t rr:4;          /**< Req/Resp */
+                       uint32_t ele_id:16;     /**< Element ID */
 #endif
+               };
+       };
        uint8_t addr[6];                /**< 48-bits address */
        rte_be16_t length;              /**< number of bytes */
 };
-- 
2.43.0

Reply via email to