From patchwork Tue Jan 30 16:00:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 126274 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp3493917ljd; Tue, 30 Jan 2018 08:10:18 -0800 (PST) X-Google-Smtp-Source: AH8x226eSJejo1V+F4dAuWPbur3St6qoXoI2kgA0EDKLdDPgkJQJmajH6qrkpqiweG6BTiihl4R2 X-Received: by 10.200.3.150 with SMTP id t22mr44573160qtg.19.1517328618035; Tue, 30 Jan 2018 08:10:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517328618; cv=none; d=google.com; s=arc-20160816; b=nQR1cnoCvs0R9w5hpzGtAPthCaPi0gZeVv8ghRjEDwIsKWnOz260E8gVyI+H2z5PMN zLHkKyITKkaH8IY2biwRWkCqYQjnyohEBYBjkzZ2zrpJn6oy3Ea01CKUwkjIpNPCC83E TkVKxWBRbFinX4+ZpkBX0htorO1JuOO+pkRyLd4dOoMDDeZbi91KRtD50+wP/NfkZnQ/ 4D+yoiE9AGvQ4C0UGmBWu2qnHSbohn4Sfkb5AkRtbTlRMvszYqLH9+M2uNZqYvuCEEVl UXRYJGv/tjlLBoUDDtJX11nnPXm5ZN4ueu7QkVCGEHtCLvUIG6L7AViHmJwHyxS3Vb9Z H0mQ== 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=wMUEmg/IEiQqe+wkdDnc3fB3VQJBNC/WJYwD4EhwA8g=; b=01mDCMlSkH4opSSKWC104FZmb7BMoh2JgkxGNb5bw8pGkli/TZFmyEy2h/RlrFNVJi tkDSrVHEmlYsIOFjCWI0+DQYZQY4skMd719kexOf+qbKQyX6I971cHs7TTNWPq39gnOH EvnU8k/X7FvrWV4KloTWdPyhxV/9g1a76f62WIUTKJtDEU438Jc5DAkMwwKtvFRqImjX DqcC9sBTEbvdydT2g9X5Zz8Sqa0rdv3xrHnoS5LNbMQFvdFOhK9Sq6mL2gdqN1y4zkfD h5rBPQVeG+cDjwQMBXMlWyt7iENP6pcTrOiEhjCXrmg9rwIiBssH4v0LV7VbVRulyqHm 1MkQ== 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 e12si2618688qtk.68.2018.01.30.08.10.17; Tue, 30 Jan 2018 08:10:18 -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 A665A616E1; Tue, 30 Jan 2018 16:10:17 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 0C4B261775; Tue, 30 Jan 2018 16:01:23 +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 4BD1660C5E; Tue, 30 Jan 2018 16:00:31 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id CDE1F6104E for ; Tue, 30 Jan 2018 16:00:17 +0000 (UTC) Received: from mxback2g.mail.yandex.net (mxback2g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:163]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 59F574081AE1 for ; Tue, 30 Jan 2018 19:00:16 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback2g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id y54mKcCO1d-0Gd8QFbq; Tue, 30 Jan 2018 19:00:16 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Nz8CQ597Mi-0FRWcAbR; Tue, 30 Jan 2018 19:00:15 +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: Tue, 30 Jan 2018 19:00:05 +0300 Message-Id: <1517328009-16379-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517328009-16379-1-git-send-email-odpbot@yandex.ru> References: <1517328009-16379-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 437 Subject: [lng-odp] [PATCH v1 7/11] linux-gen: packet: inline conversions between packet and event 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 Inline implementation of packet_from_event and packet_to_event functions. Signed-off-by: Petri Savolainen --- /** Email created from pull request 437 (psavol:master-packet-optim) ** https://github.com/Linaro/odp/pull/437 ** Patch: https://github.com/Linaro/odp/pull/437.patch ** Base sha: b95ccd3db6eeb7358a877541747e06354429acdd ** Merge commit sha: ab7875c186fe80cfe103c5be5634b0eda312aed4 **/ include/odp/api/abi-default/buffer.h | 2 +- include/odp/api/abi-default/event.h | 2 +- include/odp/api/abi-default/packet.h | 2 +- .../linux-generic/include-abi/odp/api/abi/buffer.h | 2 +- .../linux-generic/include-abi/odp/api/abi/event.h | 2 +- .../include/odp/api/plat/packet_inlines.h | 29 ++++++++++++ .../include/odp/api/plat/packet_inlines_api.h | 21 +++++++++ platform/linux-generic/odp_packet.c | 51 ++++------------------ 8 files changed, 63 insertions(+), 48 deletions(-) diff --git a/include/odp/api/abi-default/buffer.h b/include/odp/api/abi-default/buffer.h index d8bfc9131..980528ba7 100644 --- a/include/odp/api/abi-default/buffer.h +++ b/include/odp/api/abi-default/buffer.h @@ -20,7 +20,7 @@ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_buffer_t; typedef _odp_abi_buffer_t *odp_buffer_t; -#define ODP_BUFFER_INVALID ((odp_buffer_t)NULL) +#define ODP_BUFFER_INVALID ((odp_buffer_t)0) /** * @} diff --git a/include/odp/api/abi-default/event.h b/include/odp/api/abi-default/event.h index b52a1a222..0ed6dd094 100644 --- a/include/odp/api/abi-default/event.h +++ b/include/odp/api/abi-default/event.h @@ -22,7 +22,7 @@ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_event_t; typedef _odp_abi_event_t *odp_event_t; -#define ODP_EVENT_INVALID ((odp_event_t)NULL) +#define ODP_EVENT_INVALID ((odp_event_t)0) typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, diff --git a/include/odp/api/abi-default/packet.h b/include/odp/api/abi-default/packet.h index 15cf081bf..086c4d3bd 100644 --- a/include/odp/api/abi-default/packet.h +++ b/include/odp/api/abi-default/packet.h @@ -26,7 +26,7 @@ typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_seg_t; typedef _odp_abi_packet_t *odp_packet_t; typedef _odp_abi_packet_seg_t *odp_packet_seg_t; -#define ODP_PACKET_INVALID ((odp_packet_t)0xffffffff) +#define ODP_PACKET_INVALID ((odp_packet_t)0) #define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)0xffffffff) #define ODP_PACKET_OFFSET_INVALID 0xffff diff --git a/platform/linux-generic/include-abi/odp/api/abi/buffer.h b/platform/linux-generic/include-abi/odp/api/abi/buffer.h index 90b6653a6..879c88afa 100644 --- a/platform/linux-generic/include-abi/odp/api/abi/buffer.h +++ b/platform/linux-generic/include-abi/odp/api/abi/buffer.h @@ -26,7 +26,7 @@ extern "C" { typedef ODP_HANDLE_T(odp_buffer_t); -#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, NULL) +#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0) /** * @} diff --git a/platform/linux-generic/include-abi/odp/api/abi/event.h b/platform/linux-generic/include-abi/odp/api/abi/event.h index 802e431f3..49dde956c 100644 --- a/platform/linux-generic/include-abi/odp/api/abi/event.h +++ b/platform/linux-generic/include-abi/odp/api/abi/event.h @@ -26,7 +26,7 @@ extern "C" { typedef ODP_HANDLE_T(odp_event_t); -#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, NULL) +#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0) typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 4c0f88aa2..dc7d464f2 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -263,6 +263,35 @@ static inline int _odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, return 0; } +static inline odp_packet_t _odp_packet_from_event(odp_event_t ev) +{ + return (odp_packet_t)ev; +} + +static inline odp_event_t _odp_packet_to_event(odp_packet_t pkt) +{ + return (odp_event_t)pkt; +} + +static inline void _odp_packet_from_event_multi(odp_packet_t pkt[], + const odp_event_t ev[], + int num) +{ + int i; + + for (i = 0; i < num; i++) + pkt[i] = _odp_packet_from_event(ev[i]); +} + +static inline void _odp_packet_to_event_multi(const odp_packet_t pkt[], + odp_event_t ev[], int num) +{ + int i; + + for (i = 0; i < num; i++) + ev[i] = _odp_packet_to_event(pkt[i]); +} + /** @endcond */ #endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h index 9b31c923f..95adec66f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h @@ -152,4 +152,25 @@ _ODP_INLINE int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, return _odp_packet_copy_to_mem(pkt, offset, len, dst); } +_ODP_INLINE odp_packet_t odp_packet_from_event(odp_event_t ev) +{ + return _odp_packet_from_event(ev); +} + +_ODP_INLINE odp_event_t odp_packet_to_event(odp_packet_t pkt) +{ + return _odp_packet_to_event(pkt); +} + +_ODP_INLINE void odp_packet_from_event_multi(odp_packet_t pkt[], + const odp_event_t ev[], int num) +{ + return _odp_packet_from_event_multi(pkt, ev, num); +} + +_ODP_INLINE void odp_packet_to_event_multi(const odp_packet_t pkt[], + odp_event_t ev[], int num) +{ + return _odp_packet_to_event_multi(pkt, ev, num); +} #endif diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 043e4cb5c..488dcbddf 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -49,15 +49,14 @@ const _odp_packet_inline_offset_t ODP_ALIGNED_CACHE _odp_packet_inline = { #include -static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr) -{ - return (odp_buffer_t)pkt_hdr; -} - -static inline odp_packet_hdr_t *buf_to_packet_hdr(odp_buffer_t buf) -{ - return (odp_packet_hdr_t *)buf_hdl_to_hdr(buf); -} +/* Check that invalid values are the same. Some versions of Clang have trouble + * with the strong type casting, and complain that these invalid values are not + * integral constants. */ +#ifndef __clang__ +ODP_STATIC_ASSERT(ODP_PACKET_INVALID == 0, "Packet invalid not 0"); +ODP_STATIC_ASSERT(ODP_BUFFER_INVALID == 0, "Buffer invalid not 0"); +ODP_STATIC_ASSERT(ODP_EVENT_INVALID == 0, "Event invalid not 0"); +#endif odp_packet_t _odp_packet_from_buf_hdr(odp_buffer_hdr_t *buf_hdr) { @@ -998,40 +997,6 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len) return 0; } -odp_packet_t odp_packet_from_event(odp_event_t ev) -{ - if (odp_unlikely(ev == ODP_EVENT_INVALID)) - return ODP_PACKET_INVALID; - - return (odp_packet_t)buf_to_packet_hdr((odp_buffer_t)ev); -} - -odp_event_t odp_packet_to_event(odp_packet_t pkt) -{ - if (odp_unlikely(pkt == ODP_PACKET_INVALID)) - return ODP_EVENT_INVALID; - - return (odp_event_t)buffer_handle(packet_hdr(pkt)); -} - -void odp_packet_from_event_multi(odp_packet_t pkt[], const odp_event_t ev[], - int num) -{ - int i; - - for (i = 0; i < num; i++) - pkt[i] = odp_packet_from_event(ev[i]); -} - -void odp_packet_to_event_multi(const odp_packet_t pkt[], odp_event_t ev[], - int num) -{ - int i; - - for (i = 0; i < num; i++) - ev[i] = odp_packet_to_event(pkt[i]); -} - int odp_event_filter_packet(const odp_event_t event[], odp_packet_t packet[], odp_event_t remain[], int num)