From: Barry Spinney <spin...@ezchip.com> Signed-off-by: Barry Spinney <spin...@mellanox.com> --- helper/include/odp/helper/eth.h | 18 +++++++++++++++-- helper/include/odp/helper/ip.h | 44 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/helper/include/odp/helper/eth.h b/helper/include/odp/helper/eth.h index 60949d9..4597009 100644 --- a/helper/include/odp/helper/eth.h +++ b/helper/include/odp/helper/eth.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - /** * @file * @@ -32,6 +31,22 @@ extern "C" { #define ODPH_ETH_LEN_MAX 1514 /**< Max frame length (excl CRC 4 bytes) */ #define ODPH_ETH_LEN_MAX_CRC 1518 /**< Max frame length (incl CRC 4 bytes) */ +/* The two byte odph_vlanhdr_t tci field is composed of the following three + * subfields - a three bit Priority Code Point (PCP), a one bit Drop + * Eligibility Indicator (DEI) and a twelve bit VLAN Identifier (VID). The + * following constants can be used to extract or modify these subfields, once + * the tci field has been read in and converted to host byte order. Note + * that the DEI subfield used to be the CFI bit. + */ +#define ODPH_VLANHDR_MAX_PRIO 7 /**< Max value of the 3 bit priority */ +#define ODPH_VLANHDR_PCP_MASK 0xE000 /**< PCP field bit mask */ +#define ODPH_VLANHDR_PCP_SHIFT 13 /**< PCP field shift */ +#define ODPH_VLANHDR_DEI_MASK 0x1000 /**< DEI field bit mask */ +#define ODPH_VLANHDR_DEI_SHIFT 12 /**< DEI field shift */ +#define ODPH_VLANHDR_MAX_VID 0x0FFF /**< Max value of the 12 bit VID field */ +#define ODPH_VLANHDR_VID_MASK 0x0FFF /**< VID field bit mask */ +#define ODPH_VLANHDR_VID_SHIFT 0 /**< VID field shift */ + /** * Ethernet MAC address */ @@ -70,7 +85,6 @@ typedef struct ODP_PACKED { ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, "ODPH_VLANHDR_T__SIZE_ERROR"); - /* Ethernet header Ether Type ('type') values, a selected few */ #define ODPH_ETHTYPE_IPV4 0x0800 /**< Internet Protocol version 4 */ #define ODPH_ETHTYPE_ARP 0x0806 /**< Address Resolution Protocol */ diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index 4df41d9..11b2bde 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - /** * @file * @@ -32,6 +31,28 @@ extern "C" { #define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ #define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ +/** The one byte IPv4 tos or IPv6 tc field is composed of the following two + * subfields - a six bit Differentiated Service Code Point (DSCP) and a two + * bit Explicit Congestion Notification (ECN) subfield. The following + * constants can be used to extract or modify these fields. Despite the + * name prefix being ODPH_IP_TOS_* these constants apply equally well for + * the IPv6 Traffic Class (tc) field. + */ +#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value 63 */ +#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ +#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by 2 */ +#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value 3 */ +#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ +#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ + +/** The following constants give names to the four possible ECN values, + * as described in RFC 3168. + */ +#define ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN */ +#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ +#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ +#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion Experienced */ + /** @internal Returns IPv4 version */ #define ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) @@ -53,9 +74,6 @@ extern "C" { /** @internal Returns true if IPv4 packet is a fragment */ #define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) -/** @internal Returns IPv4 DSCP */ -#define ODPH_IPV6HDR_DSCP(ver_tc_flow) (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) - /** IPv4 header */ typedef struct ODP_PACKED { uint8_t ver_ihl; /**< Version / Header length */ @@ -134,6 +152,24 @@ static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) /** IPv6 header length */ #define ODPH_IPV6HDR_LEN 40 +/** The following constants can be used to access the three subfields + * of the 4 byte ver_tc_flow field - namely the four bit Version subfield, + * the eight bit Traffic Class subfield (TC) and the twenty bit Flow Label + * subfield. Note that the IPv6 TC field is analogous to the IPv4 TOS + * field and is composed of the DSCP and ECN subfields. Use the ODPH_IP_TOS_* + * constants above to access these subfields. + */ +#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit mask */ +#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift */ +#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ +#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ +#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask */ +#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ + +/** @internal Returns IPv6 DSCP */ +#define ODPH_IPV6HDR_DSCP(ver_tc_flow) \ + (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) + /** * IPv6 header */ -- 2.1.2 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp