Reordered the odph_vlanhdr_t to be more aligned with how fast path code parses headers like this. This change then required a change to odp_classification_common.c.
Signed-off-by: Barry Spinney <[email protected]> --- helper/include/odp/helper/eth.h | 12 ++++++++---- helper/include/odp/helper/ip.h | 3 +++ .../classification/odp_classification_common.c | 16 ++++++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/helper/include/odp/helper/eth.h b/helper/include/odp/helper/eth.h index 4597009..9f47ddf 100644 --- a/helper/include/odp/helper/eth.h +++ b/helper/include/odp/helper/eth.h @@ -64,7 +64,7 @@ ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, typedef struct ODP_PACKED { odph_ethaddr_t dst; /**< Destination address */ odph_ethaddr_t src; /**< Source address */ - odp_u16be_t type; /**< Type */ + odp_u16be_t type; /**< EtherType */ } odph_ethhdr_t; /** @internal Compile time assert */ @@ -72,13 +72,17 @@ ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, "ODPH_ETHHDR_T__SIZE_ERROR"); /** - * VLAN header + * IEEE 802.1Q VLAN header * - * @todo Check usage of tpid vs ethertype. Check outer VLAN TPID. + * This field is present when the EtherType (the odph_ethhdr_t type field) of + * the preceding ethernet header is ODPH_ETHTYPE_VLAN. The inner EtherType + * (the odph_vlanhdr_t type field) then indicates what comes next. Note that + * the so called TPID field isn't here because it overlaps with the + * odph_ethhdr_t type field. */ typedef struct ODP_PACKED { - odp_u16be_t tpid; /**< Tag protocol ID (located after ethhdr.src) */ odp_u16be_t tci; /**< Priority / CFI / VLAN ID */ + odp_u16be_t type; /**< Inner EtherType */ } odph_vlanhdr_t; /** @internal Compile time assert */ diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index f1f8cab..4cfc00f 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -152,6 +152,9 @@ static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) /** IPv6 header length */ #define ODPH_IPV6HDR_LEN 40 +/** IPv6 address length in bytes */ +#define ODPH_IPV6ADDR_LEN 16 + /** 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 diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index c1afd00..72fe07d 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -269,19 +269,15 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan, offset += sizeof(odph_ethhdr_t); if (vlan) { /* Default vlan header */ - uint8_t *parseptr; - odph_vlanhdr_t *vlan; + odph_vlanhdr_t *vlan_hdr; - vlan = (odph_vlanhdr_t *)(ðhdr->type); - parseptr = (uint8_t *)vlan; - vlan->tci = odp_cpu_to_be_16(0); - vlan->tpid = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN); + ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN); + vlan_hdr = (odph_vlanhdr_t *)(ethhdr + 1); + vlan_hdr->tci = odp_cpu_to_be_16(0); + vlan_hdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); offset += sizeof(odph_vlanhdr_t); - parseptr += sizeof(odph_vlanhdr_t); - odp_u16be_t *type = (odp_u16be_t *)(void *)parseptr; - *type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); } else { - ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); + ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); } odp_packet_l3_offset_set(pkt, offset); -- 2.7.2 _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
