@@ -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;
@@ -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
@@ -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;
}
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(-)