diff mbox series

[API-NEXT,v1,10/12] api: event: filter and convert packets

Message ID 1512140407-13534-11-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v1,1/12] api: event: add free multiple | expand

Commit Message

Github ODP bot Dec. 1, 2017, 3 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


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>

---
/** Email created from pull request 318 (psavol:next-multi-apis)
 ** https://github.com/Linaro/odp/pull/318
 ** Patch: https://github.com/Linaro/odp/pull/318.patch
 ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: aee2bcc574d2a8efdfcecc3b8e681ce391119798
 **/
 include/odp/api/spec/event.h | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
diff mbox series

Patch

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
@@ -141,6 +142,27 @@  odp_event_type_t odp_event_types(odp_event_t event,
 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
  *