aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2024-04-25 16:24:08 +0300
committerMatias Elo <matias.elo@nokia.com>2024-04-30 18:22:33 +0300
commit19cf17d2f9794a7c02a8b9b8aa2bec27a105e7d2 (patch)
treec47049c59804b334179942f92bbd8b1e372593be
parentc10e3e4152007b1ad763b2881fd4ae68db10aedd (diff)
linux-gen: packet: implement new odp_packet_reset_meta()
Add implementation for the new odp_packet_reset_meta() function. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
-rw-r--r--platform/linux-generic/include/odp_packet_internal.h32
-rw-r--r--platform/linux-generic/odp_packet.c7
2 files changed, 27 insertions, 12 deletions
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 3cea245ae..60b49a89b 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -217,6 +217,25 @@ static inline void packet_subtype_set(odp_packet_t pkt, int subtype)
}
/**
+ * Reset packet metadata
+ */
+static inline void _odp_packet_reset_md(odp_packet_hdr_t *pkt_hdr)
+{
+ /* Clear all flags. Resets also return value of cls_mark, user_ptr, etc. */
+ pkt_hdr->p.input_flags.all = 0;
+ pkt_hdr->p.flags.all_flags = 0;
+
+ pkt_hdr->p.l2_offset = 0;
+ pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
+ pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID;
+
+ if (odp_unlikely(pkt_hdr->event_hdr.subtype != ODP_EVENT_PACKET_BASIC))
+ pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;
+
+ pkt_hdr->input = ODP_PKTIO_INVALID;
+}
+
+/**
* Initialize packet
*/
static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
@@ -238,14 +257,6 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
last->seg_len = seg_len;
}
- /* Clear all flags. Resets also return value of cls_mark, user_ptr, etc. */
- pkt_hdr->p.input_flags.all = 0;
- pkt_hdr->p.flags.all_flags = 0;
-
- pkt_hdr->p.l2_offset = 0;
- pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID;
-
/*
* Packet headroom is set from the pool's headroom
* Packet tailroom is rounded up to fill the last
@@ -255,10 +266,7 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
pkt_hdr->headroom = pool->headroom;
pkt_hdr->tailroom = pool->seg_len - seg_len + pool->tailroom;
- if (odp_unlikely(pkt_hdr->event_hdr.subtype != ODP_EVENT_PACKET_BASIC))
- pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;
-
- pkt_hdr->input = ODP_PKTIO_INVALID;
+ _odp_packet_reset_md(pkt_hdr);
}
/**
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 5540f4c3e..6559ba606 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -766,6 +766,13 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len)
return 0;
}
+void odp_packet_reset_meta(odp_packet_t pkt)
+{
+ _ODP_ASSERT(pkt != ODP_PACKET_INVALID);
+
+ _odp_packet_reset_md(packet_hdr(pkt));
+}
+
int odp_event_filter_packet(const odp_event_t event[],
odp_packet_t packet[],
odp_event_t remain[], int num)