aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Kiss <zoltan.kiss@linaro.org>2016-04-05 12:13:06 +0100
committerZoltan Kiss <zoltan.kiss@linaro.org>2016-04-05 14:24:06 +0100
commitb7b2e94a64cf27024d9d7b0827620778b106880e (patch)
tree8084d07ca5578e24b71979fe142724e450e50cea
parent16fe86ae0d3b3f4011ab24f0666256ee7a7cb802 (diff)
downloadodp-dpdk-odp_dpdp_1.7.tar.gz
linux-dpdk: packet: fix L2 parsingodp_dpdp_1.7
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 <bill.fischofer at linaro.org> Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> Conflicts: platform/linux-dpdk/odp_packet.c
-rw-r--r--platform/linux-dpdk/include/odp_packet_internal.h23
-rw-r--r--platform/linux-dpdk/odp_packet.c26
-rw-r--r--platform/linux-dpdk/odp_packet_flags.c12
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 72b026e7..729a45d1 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 <odp/packet_io.h>
#include <odp/crypto.h>
#include <odp_crypto_internal.h>
+#include <odp/helper/eth.h>
#include <rte_acl_osdep.h>
@@ -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 0e996dde..9a9d9533 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;
@@ -667,26 +661,6 @@ static inline void parse_udp(odp_packet_hdr_t *pkt_hdr,
}
/**
- * 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
*
* Internal function: caller is resposible for passing only valid packet handles
diff --git a/platform/linux-dpdk/odp_packet_flags.c b/platform/linux-dpdk/odp_packet_flags.c
index 83a4006e..199e8817 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)