From patchwork Fri Dec 1 15:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 120348 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1257596qgn; Fri, 1 Dec 2017 07:08:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMY7Ph9lqA0rwcBTXCdk7fZFOPo4iW9SvMDAfL7ZXQD254t1v7RQ6SeEm2GsvTirjc65+M/S X-Received: by 10.55.141.195 with SMTP id p186mr8315336qkd.313.1512140914415; Fri, 01 Dec 2017 07:08:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512140914; cv=none; d=google.com; s=arc-20160816; b=FMjiHK8Nm/J2oVlK/tVwXyGYJL+HrVGM51TzZ9MxGRJhKcxNdAcO3qtLHD367mVKjv rUAvKCQKCgfSGaWoy5wop2+s9FBWdqdqT/F1Cf+sIUhfb+4Kh4B+gY4v6nErcuu9TeVy RKuO+/3rX+zGLAr/v14M/zzjgnO86DLxqeAkhbp2bywyNSMAUMrqWvA9FevbxH1F7jd+ NdaWA/RDU8j36H28cMRK/1PUNx480+HSMnTY62OI7qrOas+en/0oXY5iZTgmiBJb0+yg ozptmJGrtyEgurF6qQwfT0wvH3Jz/acYIpYYTMBPXf+YW7mj3r9aCj2qGZyLcdB1yfab abWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Hj/S8VxvyXqNoeYHzFx4KynwmU8X60s4+L+vLhO3g8M=; b=nK6ATeJ5Q8E4wbYU4l5rquspoOGG5lL63+FaDW+u+mqDXoM0F9wsnS6R44FTB56Dm8 07SAfXD526vAW4byUzbAAtn+iuqbPBlCgrRNi/Wv5vWU2juj+G1PBm17mE+34y3UayIl tYmHH0mfWR/UXMN4u078mJ90JeA8y+hddRE+vD+V8khy54AEfFfPDMomvDYxCSPCCUcz h/VUN7yq3POl+uogCaLCQNeTNnKFFsEG4yXu+fay1IiI6jL4xtcW7ysYppFM/J63kX99 klhBGzQZC28a5gsOVoRw+Z6z58OYJfSIni5pO29n+DsooUf7Zqz9muNBraXYE+9Fwuo4 6oVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id i11si2466099qtc.438.2017.12.01.07.08.34; Fri, 01 Dec 2017 07:08:34 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 0CE676098B; Fri, 1 Dec 2017 15:08:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A76D4609D8; Fri, 1 Dec 2017 15:01:16 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id F23EA604C8; Fri, 1 Dec 2017 15:00:34 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 5026D6096D for ; Fri, 1 Dec 2017 15:00:22 +0000 (UTC) Received: from mxback10g.mail.yandex.net (mxback10g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:171]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 9DF9E2D86B51 for ; Fri, 1 Dec 2017 18:00:20 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback10g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id vw2Sikdgh8-0KbKmNst; Fri, 01 Dec 2017 18:00:20 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id I6qrBsStkX-0Ke8kmHx; Fri, 01 Dec 2017 18:00:20 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 1 Dec 2017 18:00:05 +0300 Message-Id: <1512140407-13534-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512140407-13534-1-git-send-email-odpbot@yandex.ru> References: <1512140407-13534-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 318 Subject: [lng-odp] [PATCH API-NEXT v1 10/12] api: event: filter and convert packets X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen 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 --- /** 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 --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 + /** @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 *