Skip to content

Commit

Permalink
linux-gen: event: optimize odp_event_free_sp() implementation
Browse files Browse the repository at this point in the history
Optimize odp_event_free_sp() implementation for buffer, packet, and timeout
events.

Signed-off-by: Matias Elo <[email protected]>
  • Loading branch information
MatiasElo committed Jan 10, 2025
1 parent a21d6bf commit 15a6093
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
11 changes: 9 additions & 2 deletions platform/linux-generic/include/odp_buffer_internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
* Copyright (c) 2019-2024 Nokia
* Copyright (c) 2019-2025 Nokia
*/

/**
Expand All @@ -22,11 +22,13 @@ extern "C" {
#include <odp/api/buffer.h>
#include <odp/api/debug.h>
#include <odp/api/align.h>
#include <odp_config_internal.h>
#include <odp/api/byteorder.h>
#include <odp/api/thread.h>
#include <odp/api/event.h>

#include <odp_config_internal.h>
#include <odp_event_internal.h>
#include <odp_pool_internal.h>

#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -65,6 +67,11 @@ static inline uint32_t _odp_buffer_index(odp_buffer_t buf)
return _odp_buf_hdr(buf)->event_hdr.index.event;
}

static inline void _odp_buffer_free_sp(const odp_buffer_t buf[], int num)
{
_odp_event_free_sp((_odp_event_hdr_t **)(uintptr_t)buf, num);
}

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 0 additions & 1 deletion platform/linux-generic/include/odp_pool_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern "C" {
#include <odp/api/ticketlock.h>
#include <odp/api/align.h>

#include <odp_buffer_internal.h>
#include <odp_event_internal.h>
#include <odp_config_internal.h>
#include <odp_ring_ptr_internal.h>
Expand Down
5 changes: 5 additions & 0 deletions platform/linux-generic/include/odp_timer_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ static inline uint64_t timer_run(int dec)
return UINT64_MAX;
}

static inline void _odp_timeout_free_sp(odp_timeout_t tmo[], int num)
{
_odp_event_free_sp((_odp_event_hdr_t **)(uintptr_t)tmo, num);
}

#endif
40 changes: 38 additions & 2 deletions platform/linux-generic/odp_event.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2015-2018 Linaro Limited
* Copyright (c) 2020-2024 Nokia
* Copyright (c) 2020-2025 Nokia
*/

#include <odp/autoheader_external.h>
Expand All @@ -19,6 +19,7 @@
#include <odp_debug_internal.h>
#include <odp_packet_internal.h>
#include <odp_event_internal.h>
#include <odp_timer_internal.h>
#include <odp_event_validation_internal.h>
#include <odp_event_vector_internal.h>

Expand Down Expand Up @@ -127,6 +128,41 @@ static inline void event_free_multi(const odp_event_t event[], int num, odp_even
}
}

static inline void event_free_sp(const odp_event_t event[], int num, odp_event_type_t type,
_odp_ev_id_t id)
{
switch (type) {
case ODP_EVENT_BUFFER:
_odp_buffer_validate_multi((odp_buffer_t *)(uintptr_t)event, num, id);
_odp_buffer_free_sp((odp_buffer_t *)(uintptr_t)event, num);
break;
case ODP_EVENT_PACKET:
_odp_packet_validate_multi((odp_packet_t *)(uintptr_t)event, num, id);
odp_packet_free_sp((odp_packet_t *)(uintptr_t)event, num);
break;
case ODP_EVENT_PACKET_VECTOR:
packet_vector_free_full_multi((odp_packet_vector_t *)(uintptr_t)event, num);
break;
case ODP_EVENT_TIMEOUT:
_odp_timeout_free_sp((odp_timeout_t *)(uintptr_t)event, num);
break;
case ODP_EVENT_IPSEC_STATUS:
ipsec_status_free_multi((ipsec_status_t *)(uintptr_t)event, num);
break;
case ODP_EVENT_PACKET_TX_COMPL:
packet_tx_compl_free_multi((odp_packet_tx_compl_t *)(uintptr_t)event, num);
break;
case ODP_EVENT_DMA_COMPL:
dma_compl_free_multi((odp_dma_compl_t *)(uintptr_t)event, num);
break;
case ODP_EVENT_ML_COMPL:
ml_compl_free_multi((odp_ml_compl_t *)(uintptr_t)event, num);
break;
default:
_ODP_ABORT("Invalid event type: %d\n", type);
}
}

void odp_event_free_multi(const odp_event_t event[], int num)
{
const odp_event_t *burst_start;
Expand Down Expand Up @@ -170,7 +206,7 @@ void odp_event_free_sp(const odp_event_t event[], int num)
_ODP_ASSERT(_odp_event_pool(event[i]) == pool);
}

event_free_multi(event, num, odp_event_type(event[0]), _ODP_EV_EVENT_FREE_SP);
event_free_sp(event, num, odp_event_type(event[0]), _ODP_EV_EVENT_FREE_SP);
}

uint64_t odp_event_to_u64(odp_event_t hdl)
Expand Down
1 change: 1 addition & 0 deletions platform/linux-generic/odp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <odp/autoheader_external.h>

#include <odp/api/buffer.h>
#include <odp/api/byteorder.h>
#include <odp/api/hash.h>
#include <odp/api/hints.h>
Expand Down
1 change: 1 addition & 0 deletions platform/linux-generic/pktio/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <odp/api/deprecated.h>
#include <odp/api/hints.h>
#include <odp/api/pool.h>
#include <odp/api/system_info.h>

#include <odp_debug_internal.h>
Expand Down

0 comments on commit 15a6093

Please sign in to comment.