From patchwork Wed Jan 31 14:00:07 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: 126337 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp762753ljc; Wed, 31 Jan 2018 06:07:28 -0800 (PST) X-Google-Smtp-Source: AH8x224tIp7D76kGKihBM9NdEC+05zQCEq1vsD767qYzoXGszecohRG3yg7yRVCFNDSVJDwU2WoM X-Received: by 10.37.74.201 with SMTP id x192mr21292663yba.204.1517407647868; Wed, 31 Jan 2018 06:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517407647; cv=none; d=google.com; s=arc-20160816; b=tDRJpDyG4FuCR4nmd/CGf9Ee1gUmDC+zoThyW0ddC0LYy/VPRp3m4KWCBqVfBDilsi 7//0InfGQ4ucB3OOy9tUPI1uxvL8022jXF6X9VIBjccp+HAUfvjMWrLgby7b8uLk3ptH 7sJip7iLXLFrqurUBK78Ow4BHa8SjCF5NFP4b52zW9hSo5DCpNjcwDPLHkIyJ6hESVcY tq9WWQ3t06E+Obto6bbPpsCuzomgqQ1/VN7cBB2wIXV5HHTXaWWDuk12vZ3aRClz34Xj iKd+R3/9Ak0uOe7VS4hy/cpo3W1wtvEqcer+hH86bpTILRLwyENHvOQFDjOV32OgK21S v0rg== 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=PcJ/E3M++D9mac8cQmmeX/F/g0UVFOcSEEgTSpsQoW8=; b=jmploXjkFw3eufqU+QJsV0QQbjG9GiR8/6H/VwJwEwoxMLnepJRJA8EzQHeGlYJSXZ zYew9X6MAIAQpi6nb7wcBaB/q7J+S4OGVobkDi9rK3vQOwqhn3ZbRcjsjSOXdLRnbs72 ttmpwsLK16qnWh8QjPCJjRbAXtgDUjbTLsYDgiCuDiWxil8fmCAhniz6acdezjdQ+msX 3Sw24amz8Fswes0ZdSzOuVm3MW1Uy4xmt5nQqz3m/y8jo5LyZLcoUj9GlvxTEGKYLRTA FP3H/1IMQAFFXd5cQ4AVzva8WZ0OdSgDcnErlNzVIrtP3wt5hFlQJWV1lWzQu9X3hn9B qzlA== 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 c141si4383057qke.375.2018.01.31.06.07.27; Wed, 31 Jan 2018 06:07:27 -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 7EDF661817; Wed, 31 Jan 2018 14:07:27 +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 E7B6C617A1; Wed, 31 Jan 2018 14:01:02 +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 6DDEB6176F; Wed, 31 Jan 2018 14:00:32 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id CA75261502 for ; Wed, 31 Jan 2018 14:00:19 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward102o.mail.yandex.net (Yandex) with ESMTP id E78645A0475B for ; Wed, 31 Jan 2018 17:00:17 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9pK8Np38eF-0HB4XQka; Wed, 31 Jan 2018 17:00:17 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0HVKFw8f; Wed, 31 Jan 2018 17:00:17 +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: Wed, 31 Jan 2018 17:00:07 +0300 Message-Id: <1517407211-19105-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517407211-19105-1-git-send-email-odpbot@yandex.ru> References: <1517407211-19105-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 437 Subject: [lng-odp] [PATCH v2 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: 3c2134ecc18e4fd52cd526b5c067815ca73864cc **/ 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)