From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 48CEB2C00 for ; Thu, 15 Jun 2017 17:49:11 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id m125so3390317wmm.1 for ; Thu, 15 Jun 2017 08:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wU6AeAXqfMF8hKsBjvTCHOYfZOFjy2H+VSHi8K0dHLc=; b=OJoG6ULYTQbIwSoJaOHQPOctfEM1Qsfn45YSrFylkQbon6Zsr/jONxnr7FU6MxN7uL 7vGlZPG7NcoGUgt9/NBIURPi4DfBCPJqoRrvQX14pWYAY+3hNZP70IjqXRysRrBeJHXW J6IPu7S3LcCpyT3ygC0z12KsKjPyBtpVCrnJ0JDpKAdgHrMjRHC8Vo85KFDofQBnLyiH SFG7H5ugQUfit6ZSXwIjWYlSJcEuPVf57bDpNEOtBwhDJcwvLp0mi4NInf5Rq9FPulOY Do2B7OLcvVcZEov7zht7qT+SZ0vy4FAYwC/66RnsYPqB3e+9tDj7CfeSUbquJhNl8CU5 fQDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wU6AeAXqfMF8hKsBjvTCHOYfZOFjy2H+VSHi8K0dHLc=; b=mOubKUiUlL/EwtioJ+n2U7eLoCKhdYnc7s6d2T6b4QLmfj624VjgjRISq3ke+Ft51V C/F5CWJJTAv/p4xxLxQeZYStV8QK1DatSCb7orL3m7UG+i/j9wfN0mGDuThWMghLHd5c YPPe9aZGLvQq25wyoDgyzCfH3Rry904iBf0F0oP8vheUMInsycRedQRtWnUq++9lXLYi MVm/8b1tkK0rM0bIFdW+hzATCoSk8CQN8AseeoCNBzLP+T4AWU+H9Wxva6RGgUf1W4Wu 2Ehsn+4GoT9Cxy9NveqETxg+ixUk2j7JeUr1QIEzKGnz7mx2zANeRUnPLELPlwslpjOL lVXg== X-Gm-Message-State: AKS2vOzeTDgY51NHXPWzVg8xEEtIXVRe/t0aOFSWbb1shd7cTECb696z cGcZ+PXDKFh90q6Bd2o= X-Received: by 10.28.156.17 with SMTP id f17mr4109182wme.17.1497541750654; Thu, 15 Jun 2017 08:49:10 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id k12sm566786wrc.10.2017.06.15.08.49.09 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 15 Jun 2017 08:49:09 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Cc: Thomas Monjalon Date: Thu, 15 Jun 2017 17:48:59 +0200 Message-Id: <32ef2bc4d2c54203bd58988e55897a05a8bc469c.1497541557.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <840342851720fc237214aeb30d38565615293b58.1495101988.git.adrien.mazarguil@6wind.com> References: <840342851720fc237214aeb30d38565615293b58.1495101988.git.adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH v2 3/3] ethdev: tidy up endianness handling in flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jun 2017 15:49:11 -0000 The flow API defines several structures whose fields must be specified in network order. This commit documents them using explicit type names and related endianness conversion macros. No ABI change. Signed-off-by: Adrien Mazarguil --- lib/librte_ether/rte_flow.h | 52 ++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 34a5876..057f7e7 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -429,7 +429,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { struct rte_flow_item_eth { struct ether_addr dst; /**< Destination MAC. */ struct ether_addr src; /**< Source MAC. */ - uint16_t type; /**< EtherType. */ + rte_be16_t type; /**< EtherType. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -437,7 +437,7 @@ struct rte_flow_item_eth { static const struct rte_flow_item_eth rte_flow_item_eth_mask = { .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", .src.addr_bytes = "\xff\xff\xff\xff\xff\xff", - .type = 0x0000, + .type = RTE_BE16(0x0000), }; #endif @@ -450,15 +450,15 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * RTE_FLOW_ITEM_TYPE_VLAN. */ struct rte_flow_item_vlan { - uint16_t tpid; /**< Tag protocol identifier. */ - uint16_t tci; /**< Tag control information. */ + rte_be16_t tpid; /**< Tag protocol identifier. */ + rte_be16_t tci; /**< Tag control information. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ #ifndef __cplusplus static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { - .tpid = 0x0000, - .tci = 0xffff, + .tpid = RTE_BE16(0x0000), + .tci = RTE_BE16(0xffff), }; #endif @@ -477,8 +477,8 @@ struct rte_flow_item_ipv4 { #ifndef __cplusplus static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = { .hdr = { - .src_addr = 0xffffffff, - .dst_addr = 0xffffffff, + .src_addr = RTE_BE32(0xffffffff), + .dst_addr = RTE_BE32(0xffffffff), }, }; #endif @@ -540,8 +540,8 @@ struct rte_flow_item_udp { #ifndef __cplusplus static const struct rte_flow_item_udp rte_flow_item_udp_mask = { .hdr = { - .src_port = 0xffff, - .dst_port = 0xffff, + .src_port = RTE_BE16(0xffff), + .dst_port = RTE_BE16(0xffff), }, }; #endif @@ -559,8 +559,8 @@ struct rte_flow_item_tcp { #ifndef __cplusplus static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = { .hdr = { - .src_port = 0xffff, - .dst_port = 0xffff, + .src_port = RTE_BE16(0xffff), + .dst_port = RTE_BE16(0xffff), }, }; #endif @@ -578,8 +578,8 @@ struct rte_flow_item_sctp { #ifndef __cplusplus static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = { .hdr = { - .src_port = 0xffff, - .dst_port = 0xffff, + .src_port = RTE_BE16(0xffff), + .dst_port = RTE_BE16(0xffff), }, }; #endif @@ -609,14 +609,14 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * Matches a E-tag header. */ struct rte_flow_item_e_tag { - uint16_t tpid; /**< Tag protocol identifier (0x893F). */ + rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */ /** * E-Tag control information (E-TCI). * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b). */ - uint16_t epcp_edei_in_ecid_b; + rte_be16_t epcp_edei_in_ecid_b; /** Reserved (2b), GRP (2b), E-CID base (12b). */ - uint16_t rsvd_grp_ecid_b; + rte_be16_t rsvd_grp_ecid_b; uint8_t in_ecid_e; /**< Ingress E-CID ext. */ uint8_t ecid_e; /**< E-CID ext. */ }; @@ -624,13 +624,7 @@ struct rte_flow_item_e_tag { /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */ #ifndef __cplusplus static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - .rsvd_grp_ecid_b = 0x3fff, -#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - .rsvd_grp_ecid_b = 0xff3f, -#else -#error Unsupported endianness. -#endif + .rsvd_grp_ecid_b = RTE_BE16(0x3fff), }; #endif @@ -646,8 +640,8 @@ struct rte_flow_item_nvgre { * * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637. */ - uint16_t c_k_s_rsvd0_ver; - uint16_t protocol; /**< Protocol type (0x6558). */ + rte_be16_t c_k_s_rsvd0_ver; + rte_be16_t protocol; /**< Protocol type (0x6558). */ uint8_t tni[3]; /**< Virtual subnet ID. */ uint8_t flow_id; /**< Flow ID. */ }; @@ -689,14 +683,14 @@ struct rte_flow_item_gre { * Checksum (1b), reserved 0 (12b), version (3b). * Refer to RFC 2784. */ - uint16_t c_rsvd0_ver; - uint16_t protocol; /**< Protocol type. */ + rte_be16_t c_rsvd0_ver; + rte_be16_t protocol; /**< Protocol type. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */ #ifndef __cplusplus static const struct rte_flow_item_gre rte_flow_item_gre_mask = { - .protocol = 0xffff, + .protocol = RTE_BE16(0xffff), }; #endif -- 2.1.4