diff mbox

linux-generic: packet: add ODP_PACKET_OFFSET_INVALID

Message ID 1418909935-4935-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit 006e196b9c717ffe73a629f7432e1abf0cc8f909
Headers show

Commit Message

Bill Fischofer Dec. 18, 2014, 1:38 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/include/api/odp_platform_types.h |  3 +++
 platform/linux-generic/include/odp_packet_internal.h    |  6 ++++++
 platform/linux-generic/odp_packet.c                     | 10 ++++++----
 3 files changed, 15 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_platform_types.h b/platform/linux-generic/include/api/odp_platform_types.h
index 2cfba87..8671b42 100644
--- a/platform/linux-generic/include/api/odp_platform_types.h
+++ b/platform/linux-generic/include/api/odp_platform_types.h
@@ -47,6 +47,9 @@  typedef odp_buffer_t odp_packet_t;
 /** Invalid packet */
 #define ODP_PACKET_INVALID ODP_BUFFER_INVALID
 
+/** Invalid packet offset */
+#define ODP_PACKET_OFFSET_INVALID (0x0fffffff)
+
 /** ODP packet segment */
 typedef odp_buffer_t odp_packet_seg_t;
 
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index a0eff30..a36d1b6 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -169,6 +169,12 @@  static inline void packet_init(pool_entry_t *pool,
 	len = sizeof(odp_packet_hdr_t) - start_offset;
 	memset(start, 0, len);
 
+	/* Set metadata items that initialize to non-zero values */
+	pkt_hdr->l2_offset = ODP_PACKET_OFFSET_INVALID;
+	pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID;
+	pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID;
+	pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID;
+
        /*
 	* Packet headroom is set from the pool's headroom
 	* Packet tailroom is rounded up to fill the last
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 0ab9866..65e6288 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -776,10 +776,10 @@  int _odp_packet_parse(odp_packet_t pkt)
 	pkt_hdr->error_flags.all  = 0;
 	pkt_hdr->input_flags.all  = 0;
 	pkt_hdr->output_flags.all = 0;
-	pkt_hdr->l2_offset        = 0;
-	pkt_hdr->l3_offset        = 0;
-	pkt_hdr->l4_offset        = 0;
-	pkt_hdr->payload_offset   = 0;
+	pkt_hdr->l2_offset        = ODP_PACKET_OFFSET_INVALID;
+	pkt_hdr->l3_offset        = ODP_PACKET_OFFSET_INVALID;
+	pkt_hdr->l4_offset        = ODP_PACKET_OFFSET_INVALID;
+	pkt_hdr->payload_offset   = ODP_PACKET_OFFSET_INVALID;
 	pkt_hdr->vlan_s_tag       = 0;
 	pkt_hdr->vlan_c_tag       = 0;
 	pkt_hdr->l3_protocol      = 0;
@@ -861,6 +861,7 @@  int _odp_packet_parse(odp_packet_t pkt)
 
 	default:
 		pkt_hdr->input_flags.l3 = 0;
+		pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID;
 		ip_proto = 255;  /* Reserved invalid by IANA */
 	}
 
@@ -892,6 +893,7 @@  int _odp_packet_parse(odp_packet_t pkt)
 
 	default:
 		pkt_hdr->input_flags.l4 = 0;
+		pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID;
 		break;
 	}