From b7b2e94a64cf27024d9d7b0827620778b106880e Mon Sep 17 00:00:00 2001 From: Zoltan Kiss Date: Tue, 5 Apr 2016 12:13:06 +0100 Subject: linux-dpdk: packet: fix L2 parsing This is an extension of this patch: https://lists.linaro.org/pipermail/lng-odp-dpdk/2016-February/001292.html But it also executes the L2 parsing when received from a pktio interface, and remove the parse check for l2 and jumbo flags, as well as from handling L2 offset. When DPDK finally fixes its issues around packet parsing we can start using that. Original-by: Bill Fischofer Signed-off-by: Zoltan Kiss Conflicts: platform/linux-dpdk/odp_packet.c --- platform/linux-dpdk/include/odp_packet_internal.h | 23 +++++++++++++++++++- platform/linux-dpdk/odp_packet.c | 26 ----------------------- platform/linux-dpdk/odp_packet_flags.c | 12 ++++++++--- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h index 72b026e72..729a45d17 100644 --- a/platform/linux-dpdk/include/odp_packet_internal.h +++ b/platform/linux-dpdk/include/odp_packet_internal.h @@ -28,6 +28,7 @@ extern "C" { #include #include #include +#include #include @@ -154,11 +155,31 @@ static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt) */ void odp_packet_parse(odp_packet_t pkt, size_t len, size_t l2_offset); +/** + * Initialize L2 related parser flags and metadata + */ +static inline void packet_parse_l2(odp_packet_hdr_t *pkt_hdr) +{ + /* Packet alloc or reset have already init other offsets and flags */ + + /* We only support Ethernet for now */ + pkt_hdr->input_flags.eth = 1; + + /* Detect jumbo frames */ + if (odp_packet_len((odp_packet_t)pkt_hdr) > ODPH_ETH_LEN_MAX) + pkt_hdr->input_flags.jumbo = 1; + + /* Assume valid L2 header, no CRC/FCS check in SW */ + pkt_hdr->input_flags.l2 = 1; + + pkt_hdr->input_flags.parsed_l2 = 1; +} + static inline void _odp_packet_reset_parse(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - pkt_hdr->input_flags.parsed_l2 = 0; pkt_hdr->input_flags.parsed_all = 0; + packet_parse_l2(pkt_hdr); } static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr, diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c index 0e996dde2..9a9d9533e 100644 --- a/platform/linux-dpdk/odp_packet.c +++ b/platform/linux-dpdk/odp_packet.c @@ -317,8 +317,6 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); if (!odp_packet_hdr_has_l2(pkt_hdr)) return NULL; - if (packet_parse_not_complete(pkt_hdr)) - _odp_packet_parse(pkt_hdr); return packet_offset_to_ptr(pkt, len, offset); } @@ -327,8 +325,6 @@ uint32_t odp_packet_l2_offset(odp_packet_t pkt) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); if (!odp_packet_hdr_has_l2(pkt_hdr)) return ODP_PACKET_OFFSET_INVALID; - if (packet_parse_not_complete(pkt_hdr)) - _odp_packet_parse(pkt_hdr); return pkt_hdr->l2_offset; } @@ -337,8 +333,6 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); if (odp_unlikely(offset >= (odp_packet_len(pkt) - 1))) return -1; - if (packet_parse_not_complete(pkt_hdr)) - _odp_packet_parse(pkt_hdr); odp_packet_hdr_has_l2_set(pkt_hdr, 1); pkt_hdr->l2_offset = offset; return 0; @@ -666,26 +660,6 @@ static inline void parse_udp(odp_packet_hdr_t *pkt_hdr, *parseptr += sizeof(odph_udphdr_t); } -/** - * Initialize L2 related parser flags and metadata - */ -void packet_parse_l2(odp_packet_hdr_t *pkt_hdr) -{ - /* Packet alloc or reset have already init other offsets and flags */ - - /* We only support Ethernet for now */ - pkt_hdr->input_flags.eth = 1; - - /* Detect jumbo frames */ - if (odp_packet_len((odp_packet_t)pkt_hdr) > ODPH_ETH_LEN_MAX) - pkt_hdr->input_flags.jumbo = 1; - - /* Assume valid L2 header, no CRC/FCS check in SW */ - pkt_hdr->input_flags.l2 = 1; - - pkt_hdr->input_flags.parsed_l2 = 1; -} - /** * Simple packet parser: eth, VLAN, IP, TCP/UDP/ICMP * diff --git a/platform/linux-dpdk/odp_packet_flags.c b/platform/linux-dpdk/odp_packet_flags.c index 83a4006e5..199e88173 100644 --- a/platform/linux-dpdk/odp_packet_flags.c +++ b/platform/linux-dpdk/odp_packet_flags.c @@ -33,7 +33,9 @@ int odp_packet_has_error(odp_packet_t pkt) int odp_packet_has_l2(odp_packet_t pkt) { - retflag(pkt, input_flags.l2); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->input_flags.l2; } int odp_packet_has_l3(odp_packet_t pkt) @@ -48,12 +50,16 @@ int odp_packet_has_l4(odp_packet_t pkt) int odp_packet_has_eth(odp_packet_t pkt) { - retflag(pkt, input_flags.eth); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->input_flags.eth; } int odp_packet_has_jumbo(odp_packet_t pkt) { - retflag(pkt, input_flags.jumbo); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->input_flags.jumbo; } int odp_packet_has_vlan(odp_packet_t pkt) -- cgit v1.2.3