@@ -44,6 +44,7 @@ typedef struct _odp_packet_inline_offset_t {
uint16_t flow_hash;
uint16_t timestamp;
uint16_t input_flags;
+ uint16_t flags;
} _odp_packet_inline_offset_t;
@@ -109,7 +110,12 @@ typedef union {
uint32_t all_flags;
struct {
- uint32_t reserved1: 12;
+ uint32_t reserved1: 11;
+
+ /*
+ * Init flags
+ */
+ uint32_t user_ptr_set: 1; /* User has set a non-NULL value */
/*
* Packet output flags
@@ -135,8 +141,8 @@ typedef union {
/* Flag groups */
struct {
- uint32_t reserved2: 12;
- uint32_t other: 12; /* All other flags */
+ uint32_t reserved2: 11;
+ uint32_t other: 13; /* All other flags */
uint32_t error: 8; /* All error flags */
} all;
@@ -102,6 +102,13 @@ static inline int _odp_packet_num_segs(odp_packet_t pkt)
/** @internal Inline function @param pkt @return */
static inline void *_odp_packet_user_ptr(odp_packet_t pkt)
{
+ _odp_packet_flags_t flags;
+
+ flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags);
+
+ if (flags.user_ptr_set == 0)
+ return NULL;
+
return _odp_pkt_get(pkt, void *, user_ptr);
}
@@ -43,7 +43,8 @@ const _odp_packet_inline_offset_t ODP_ALIGNED_CACHE _odp_packet_inline = {
.l4_offset = offsetof(odp_packet_hdr_t, p.l4_offset),
.flow_hash = offsetof(odp_packet_hdr_t, flow_hash),
.timestamp = offsetof(odp_packet_hdr_t, timestamp),
- .input_flags = offsetof(odp_packet_hdr_t, p.input_flags)
+ .input_flags = offsetof(odp_packet_hdr_t, p.input_flags),
+ .flags = offsetof(odp_packet_hdr_t, p.flags)
};
@@ -1260,7 +1261,15 @@ int odp_packet_input_index(odp_packet_t pkt)
void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ptr)
{
- packet_hdr(pkt)->buf_hdr.user_ptr = ptr;
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ if (odp_unlikely(ptr == NULL)) {
+ pkt_hdr->p.flags.user_ptr_set = 0;
+ return;
+ }
+
+ pkt_hdr->buf_hdr.user_ptr = ptr;
+ pkt_hdr->p.flags.user_ptr_set = 1;
}
int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset)