diff mbox series

[v1,2/4] linux-gen: packet: optimize tcp parse

Message ID 1518102010-6353-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v1,1/4] linux-gen: packet: optimize parse ipv4 and udp | expand

Commit Message

Github ODP bot Feb. 8, 2018, 3 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 461 (psavol:master-parse-optim)
 ** https://github.com/Linaro/odp/pull/461
 ** Patch: https://github.com/Linaro/odp/pull/461.patch
 ** Base sha: 257b08b35ceea41bad5a7f1c626496cf111e657a
 ** Merge commit sha: e004cabc6971bf41b8674db708fd8eaa543f7dae
 **/
 .../include/odp/api/plat/packet_inline_types.h             |  1 -
 platform/linux-generic/odp_packet.c                        | 14 +++++---------
 2 files changed, 5 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
index 47ec821c9..984783d5d 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
@@ -101,7 +101,6 @@  typedef union {
 					   payload */
 		uint64_t udp:1;       /**< UDP */
 		uint64_t tcp:1;       /**< TCP */
-		uint64_t tcpopt:1;    /**< TCP options present */
 		uint64_t sctp:1;      /**< SCTP */
 		uint64_t icmp:1;      /**< ICMP */
 
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 92a64801f..480cea194 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2091,19 +2091,15 @@  static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr,
 /**
  * Parser helper function for TCP
  */
-static inline void parse_tcp(packet_parser_t *prs,
-			     const uint8_t **parseptr, uint32_t *offset)
+static inline void parse_tcp(packet_parser_t *prs, const uint8_t **parseptr)
 {
 	const _odp_tcphdr_t *tcp = (const _odp_tcphdr_t *)*parseptr;
+	uint32_t len = tcp->hl * 4;
 
-	if (tcp->hl < sizeof(_odp_tcphdr_t) / sizeof(uint32_t))
+	if (odp_unlikely(tcp->hl < sizeof(_odp_tcphdr_t) / sizeof(uint32_t)))
 		prs->error_flags.tcp_err = 1;
-	else if ((uint32_t)tcp->hl * 4 > sizeof(_odp_tcphdr_t))
-		prs->input_flags.tcpopt = 1;
 
-	if (offset)
-		*offset   += (uint32_t)tcp->hl * 4;
-	*parseptr += (uint32_t)tcp->hl * 4;
+	*parseptr += len;
 }
 
 /**
@@ -2195,7 +2191,7 @@  int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr,
 		if (odp_unlikely(offset + _ODP_TCPHDR_LEN > seg_len))
 			return -1;
 		prs->input_flags.tcp = 1;
-		parse_tcp(prs, &parseptr, NULL);
+		parse_tcp(prs, &parseptr);
 		break;
 
 	case _ODP_IPPROTO_UDP: