diff mbox

[v2,3/5] linux-generic: packet: remove payload_offset member from odp_packet_hdr_t

Message ID 1463392220-22856-4-git-send-email-matias.elo@nokia.com
State Accepted
Commit d0d4fa461ea1d6dbb9228fea7e11e49ece4bc14b
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) May 16, 2016, 9:50 a.m. UTC
There is no way to read payload_offset in the ODP API, so
don't save it.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
 platform/linux-generic/include/odp_packet_internal.h |  2 --
 platform/linux-generic/odp_packet.c                  | 20 ++++++--------------
 2 files changed, 6 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 2a12503..1306b05 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -141,7 +141,6 @@  typedef struct {
 	uint32_t l2_offset; /**< offset to L2 hdr, e.g. Eth */
 	uint32_t l3_offset; /**< offset to L3 hdr, e.g. IPv4, IPv6 */
 	uint32_t l4_offset; /**< offset to L4 hdr (TCP, UDP, SCTP, also ICMP) */
-	uint32_t payload_offset; /**< offset to payload */
 
 	uint32_t l3_len;         /**< Layer 3 length */
 	uint32_t l4_len;         /**< Layer 4 length */
@@ -180,7 +179,6 @@  static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr,
 	dst_hdr->l2_offset      = src_hdr->l2_offset;
 	dst_hdr->l3_offset      = src_hdr->l3_offset;
 	dst_hdr->l4_offset      = src_hdr->l4_offset;
-	dst_hdr->payload_offset = src_hdr->payload_offset;
 
 	dst_hdr->l3_len         = src_hdr->l3_len;
 	dst_hdr->l4_len         = src_hdr->l4_len;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 436265e..4f523c9 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -41,7 +41,6 @@  void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
 	pkt_hdr->l2_offset        = 0;
 	pkt_hdr->l3_offset        = ODP_PACKET_OFFSET_INVALID;
 	pkt_hdr->l4_offset        = ODP_PACKET_OFFSET_INVALID;
-	pkt_hdr->payload_offset   = ODP_PACKET_OFFSET_INVALID;
 }
 
 /**
@@ -65,7 +64,6 @@  static void packet_init(pool_entry_t *pool, odp_packet_hdr_t *pkt_hdr,
 	/* Set metadata items that initialize to non-zero values */
 	pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID;
 	pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID;
-	pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID;
 
 	/* Disable lazy parsing on user allocated packets */
 	if (!parse)
@@ -1118,7 +1116,8 @@  static inline void parse_tcp(odp_packet_hdr_t *pkt_hdr,
 	pkt_hdr->l4_len = pkt_hdr->l3_len +
 		pkt_hdr->l3_offset - pkt_hdr->l4_offset;
 
-	*offset   += (uint32_t)tcp->hl * 4;
+	if (offset)
+		*offset   += (uint32_t)tcp->hl * 4;
 	*parseptr += (uint32_t)tcp->hl * 4;
 }
 
@@ -1139,7 +1138,8 @@  static inline void parse_udp(odp_packet_hdr_t *pkt_hdr,
 
 	pkt_hdr->l4_len = udplen;
 
-	*offset   += sizeof(odph_udphdr_t);
+	if (offset)
+		*offset   += sizeof(odph_udphdr_t);
 	*parseptr += sizeof(odph_udphdr_t);
 }
 
@@ -1272,12 +1272,12 @@  int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr)
 
 	case ODPH_IPPROTO_TCP:
 		pkt_hdr->input_flags.tcp = 1;
-		parse_tcp(pkt_hdr, &parseptr, &offset);
+		parse_tcp(pkt_hdr, &parseptr, NULL);
 		break;
 
 	case ODPH_IPPROTO_UDP:
 		pkt_hdr->input_flags.udp = 1;
-		parse_udp(pkt_hdr, &parseptr, &offset);
+		parse_udp(pkt_hdr, &parseptr, NULL);
 		break;
 
 	case ODPH_IPPROTO_AH:
@@ -1296,14 +1296,6 @@  int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr)
 		break;
 	}
 
-       /*
-	* Anything beyond what we parse here is considered payload.
-	* Note: Payload is really only relevant for TCP and UDP.  For
-	* all other protocols, the payload offset will point to the
-	* final header (ARP, ICMP, AH, ESP, or IP Fragment).
-	*/
-	pkt_hdr->payload_offset = offset;
-
 parse_exit:
 	pkt_hdr->input_flags.parsed_all = 1;
 	return pkt_hdr->error_flags.all != 0;