aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/odp_event.c
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2022-06-29 16:36:22 +0300
committerMatias Elo <matias.elo@nokia.com>2023-01-18 10:12:09 +0200
commita735a7131bceadb87c25b553446e4829923bcc1c (patch)
tree06fb66a46a0d1b1251bbfe96ac7c43887a546011 /platform/linux-generic/odp_event.c
parent8782c99a6cb53af57316e66271e0a1c6b951fa2b (diff)
linux-gen: event: add event validation support
Add support for runtime event validation (initially buffer endmark checking). Event validation can be enabled during configure with '--enable-event-validation' [warn/abort] or with --enabled-debug=full. When event validation is enabled, endmarks are checked in: - odp_buffer_free() / odp_buffer_free_multi() - odp_buffer_is_valid() - odp_event_free() / odp_event_free_multi() / odp_event_free_sp() - odp_event_is_valid() - odp_packet_free() / odp_packet_free_multi() / odp_packet_free_sp() - odp_packet_is_valid() Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'platform/linux-generic/odp_event.c')
-rw-r--r--platform/linux-generic/odp_event.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c
index c4e0f2c9d..edf77e2dc 100644
--- a/platform/linux-generic/odp_event.c
+++ b/platform/linux-generic/odp_event.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
+ * Copyright (c) 2020-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -18,6 +18,7 @@
#include <odp_debug_internal.h>
#include <odp_packet_internal.h>
#include <odp_event_internal.h>
+#include <odp_event_validation_internal.h>
#include <odp_event_vector_internal.h>
/* Inlined API functions */
@@ -41,13 +42,15 @@ _odp_event_inline_offset ODP_ALIGNED_CACHE = {
#include <odp/visibility_end.h>
-void odp_event_free(odp_event_t event)
+static inline void event_free(odp_event_t event, _odp_ev_id_t id)
{
switch (odp_event_type(event)) {
case ODP_EVENT_BUFFER:
+ _odp_buffer_validate(odp_buffer_from_event(event), id);
odp_buffer_free(odp_buffer_from_event(event));
break;
case ODP_EVENT_PACKET:
+ _odp_packet_validate(odp_packet_from_event(event), id);
odp_packet_free(odp_packet_from_event(event));
break;
case ODP_EVENT_PACKET_VECTOR:
@@ -75,17 +78,21 @@ void odp_event_free(odp_event_t event)
}
}
-void odp_event_free_multi(const odp_event_t event[], int num)
+void odp_event_free(odp_event_t event)
{
- int i;
+ event_free(event, _ODP_EV_EVENT_FREE);
+}
- for (i = 0; i < num; i++)
- odp_event_free(event[i]);
+void odp_event_free_multi(const odp_event_t event[], int num)
+{
+ for (int i = 0; i < num; i++)
+ event_free(event[i], _ODP_EV_EVENT_FREE_MULTI);
}
void odp_event_free_sp(const odp_event_t event[], int num)
{
- odp_event_free_multi(event, num);
+ for (int i = 0; i < num; i++)
+ event_free(event[i], _ODP_EV_EVENT_FREE_SP);
}
uint64_t odp_event_to_u64(odp_event_t hdl)
@@ -103,9 +110,9 @@ int odp_event_is_valid(odp_event_t event)
switch (odp_event_type(event)) {
case ODP_EVENT_BUFFER:
- /* Fall through */
+ return !_odp_buffer_validate(odp_buffer_from_event(event), _ODP_EV_EVENT_IS_VALID);
case ODP_EVENT_PACKET:
- /* Fall through */
+ return !_odp_packet_validate(odp_packet_from_event(event), _ODP_EV_EVENT_IS_VALID);
case ODP_EVENT_TIMEOUT:
/* Fall through */
#if ODP_DEPRECATED_API