diff options
author | Petri Savolainen <petri.savolainen@linaro.org> | 2017-12-01 14:44:18 +0200 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2017-12-27 21:58:43 +0300 |
commit | 39cbe8bd3cf8789caacf2579f74f081f70a05c69 (patch) | |
tree | 9526ea1248287acbc8dd3a048fb5f8dd88a894cb | |
parent | 2cf09b42f93c77210a8edc9a7e1607b491e7e176 (diff) |
api: event: filter and convert packets
This call optimizes into a single call the common case of
first checking that events are packets and then converting
those to packet handles.
while (1) {
num = odp_schedule_multi(NULL, 0, event, max_num);
if (num <= 0)
continue;
num_pkt = odp_event_filter_packet(event, packet, remain, num);
packet_foo(packet, num_pkt);
other_foo(remain, num - num_pkt);
...
}
Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r-- | include/odp/api/spec/event.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h index e5edaacc9..2228c596f 100644 --- a/include/odp/api/spec/event.h +++ b/include/odp/api/spec/event.h @@ -19,12 +19,13 @@ extern "C" { #endif +#include <odp/api/packet.h> + /** @defgroup odp_event ODP EVENT * Operations on an event. * @{ */ - /** * @typedef odp_event_t * ODP event @@ -142,6 +143,27 @@ int odp_event_type_multi(const odp_event_t event[], int num, odp_event_type_t *type); /** + * Filter and convert packet events + * + * Checks event type of all input events, converts all packet events and outputs + * packet handles. Returns the number packet handles outputted. Outputs the + * remaining, non-packet event handles to 'remain' array. Handles are outputted + * to both arrays in the same order those are stored in 'event' array. Both + * output arrays must fit 'num' elements. + * + * @param event Array of event handles + * @param[out] packet Packet handle array for output + * @param[out] remain Event handle array for output of remaining, non-packet + * events + * @param num Number of events (> 0) + * + * @return Number of packets outputted (0 ... num) + */ +int odp_event_filter_packet(const odp_event_t event[], + odp_packet_t packet[], + odp_event_t remain[], int num); + +/** * Get printable value for an odp_event_t * * @param hdl odp_event_t handle to be printed |