@@ -42,6 +42,7 @@ typedef union {
uint32_t parsed_all:1;/**< Parsing complete */
uint32_t flow_hash:1; /**< Flow hash present */
+ uint32_t timestamp:1; /**< Timestamp present */
uint32_t l2:1; /**< known L2 protocol present */
uint32_t l3:1; /**< known L3 protocol present */
@@ -152,6 +153,7 @@ typedef struct {
odp_pktio_t input;
uint32_t flow_hash; /**< Flow hash value */
+ odp_time_t timestamp; /**< Timestamp value */
odp_crypto_generic_op_result_t op_result; /**< Result for crypto */
} odp_packet_hdr_t;
@@ -451,6 +451,21 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash)
pkt_hdr->input_flags.flow_hash = 1;
}
+odp_time_t odp_packet_ts(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->timestamp;
+}
+
+void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp)
+{
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ pkt_hdr->timestamp = timestamp;
+ pkt_hdr->input_flags.timestamp = 1;
+}
+
int odp_packet_is_segmented(odp_packet_t pkt)
{
return odp_packet_hdr(pkt)->buf_hdr.segcount > 1;
@@ -179,6 +179,13 @@ int odp_packet_has_flow_hash(odp_packet_t pkt)
return pkt_hdr->input_flags.flow_hash;
}
+int odp_packet_has_ts(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->input_flags.timestamp;
+}
+
odp_packet_color_t odp_packet_color(odp_packet_t pkt)
{
retflag(pkt, input_flags.color);
@@ -337,3 +344,10 @@ void odp_packet_has_flow_hash_clr(odp_packet_t pkt)
pkt_hdr->input_flags.flow_hash = 0;
}
+
+void odp_packet_has_ts_clr(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ pkt_hdr->input_flags.timestamp = 0;
+}
@@ -245,6 +245,7 @@ void packet_test_event_conversion(void)
void packet_test_basic_metadata(void)
{
odp_packet_t pkt = test_packet;
+ odp_time_t ts;
CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt));
CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt));
@@ -258,6 +259,13 @@ void packet_test_basic_metadata(void)
CU_ASSERT(odp_packet_flow_hash(pkt) == UINT32_MAX);
odp_packet_has_flow_hash_clr(pkt);
CU_ASSERT(!odp_packet_has_flow_hash(pkt));
+
+ ts = odp_time_global();
+ odp_packet_ts_set(pkt, ts);
+ CU_ASSERT_FATAL(odp_packet_has_ts(pkt));
+ CU_ASSERT(!odp_time_cmp(ts, odp_packet_ts(pkt)));
+ odp_packet_has_ts_clr(pkt);
+ CU_ASSERT(!odp_packet_has_ts(pkt));
}
void packet_test_length(void)
Implements support for packet timestamps and adds related validation tests. Signed-off-by: Matias Elo <matias.elo@nokia.com> --- platform/linux-generic/include/odp_packet_internal.h | 2 ++ platform/linux-generic/odp_packet.c | 15 +++++++++++++++ platform/linux-generic/odp_packet_flags.c | 14 ++++++++++++++ test/validation/packet/packet.c | 8 ++++++++ 4 files changed, 39 insertions(+)