diff options
author | Matias Elo <matias.elo@nokia.com> | 2023-01-23 10:43:01 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2023-02-24 08:44:23 +0200 |
commit | 3f0a93e790849b69fc3a99649880f7c6821ebf4c (patch) | |
tree | cdeea0a7ffabc8ebbb996e1640634188676a1d6a /platform/linux-dpdk/include/odp | |
parent | ff05084f1eb44029112b206f01bf6fa502a10c40 (diff) |
Port a735a7131 "linux-gen: event: add event validation support"
Port original commit from linux-generic.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'platform/linux-dpdk/include/odp')
3 files changed, 19 insertions, 3 deletions
diff --git a/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h b/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h index 37a3bf296..396d78559 100644 --- a/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h +++ b/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2019-2022, Nokia +/* Copyright (c) 2019-2023, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -15,6 +15,7 @@ #include <odp/api/plat/buffer_inline_types.h> #include <odp/api/plat/debug_inlines.h> #include <odp/api/plat/event_inline_types.h> +#include <odp/api/plat/event_validation_external.h> #include <rte_mbuf.h> #include <rte_mempool.h> @@ -94,6 +95,8 @@ _ODP_INLINE void odp_buffer_free(odp_buffer_t buf) { struct rte_mbuf *mbuf = (struct rte_mbuf *)buf; + _odp_buffer_validate(buf, _ODP_EV_BUFFER_FREE); + rte_mempool_put(mbuf->pool, mbuf); } @@ -106,6 +109,8 @@ _ODP_INLINE void odp_buffer_free_multi(const odp_buffer_t buf[], int num) if (odp_unlikely(num <= 0)) return; + _odp_buffer_validate_multi(buf, num, _ODP_EV_BUFFER_FREE_MULTI); + mbuf_tbl[0] = (struct rte_mbuf *)buf[0]; mp_pending = mbuf_tbl[0]->pool; num_pending = 1; @@ -133,6 +138,9 @@ _ODP_INLINE int odp_buffer_is_valid(odp_buffer_t buf) if (odp_event_type(odp_buffer_to_event(buf)) != ODP_EVENT_BUFFER) return 0; + if (odp_unlikely(_odp_buffer_validate(buf, _ODP_EV_BUFFER_IS_VALID))) + return 0; + return 1; } diff --git a/platform/linux-dpdk/include/odp/api/plat/event_validation_external.h b/platform/linux-dpdk/include/odp/api/plat/event_validation_external.h new file mode 120000 index 000000000..001662d8b --- /dev/null +++ b/platform/linux-dpdk/include/odp/api/plat/event_validation_external.h @@ -0,0 +1 @@ +../../../../../linux-generic/include/odp/api/plat/event_validation_external.h
\ No newline at end of file diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h index 4347afb88..4ae53c7b3 100644 --- a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h @@ -1,5 +1,5 @@ /* Copyright (c) 2016-2018, Linaro Limited - * Copyright (c) 2019-2022, Nokia + * Copyright (c) 2019-2023, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -25,6 +25,7 @@ extern "C" { #include <odp/api/time.h> #include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/event_validation_external.h> #include <odp/api/plat/packet_io_inlines.h> #include <odp/api/plat/packet_inline_types.h> #include <odp/api/plat/pool_inline_types.h> @@ -663,17 +664,23 @@ _ODP_INLINE odp_event_t odp_packet_tx_compl_to_event(odp_packet_tx_compl_t tx_co _ODP_INLINE void odp_packet_free(odp_packet_t pkt) { + _odp_packet_validate(pkt, _ODP_EV_PACKET_FREE); + rte_pktmbuf_free((struct rte_mbuf *)pkt); } _ODP_INLINE void odp_packet_free_multi(const odp_packet_t pkt[], int num) { + _odp_packet_validate_multi(pkt, num, _ODP_EV_PACKET_FREE_MULTI); + rte_pktmbuf_free_bulk((struct rte_mbuf **)(uintptr_t)pkt, (unsigned int)num); } _ODP_INLINE void odp_packet_free_sp(const odp_packet_t pkt[], int num) { - odp_packet_free_multi(pkt, num); + _odp_packet_validate_multi(pkt, num, _ODP_EV_PACKET_FREE_SP); + + rte_pktmbuf_free_bulk((struct rte_mbuf **)(uintptr_t)pkt, (unsigned int)num); } _ODP_INLINE void *odp_packet_seg_data(odp_packet_t pkt ODP_UNUSED, |