From patchwork Wed Apr 12 22:06:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 97346 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp462202qgf; Wed, 12 Apr 2017 15:06:13 -0700 (PDT) X-Received: by 10.237.61.174 with SMTP id i43mr20828068qtf.103.1492034773358; Wed, 12 Apr 2017 15:06:13 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c190si9033286qkg.302.2017.04.12.15.06.12; Wed, 12 Apr 2017 15:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D18D664835; Wed, 12 Apr 2017 22:06:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id BF1DE63545; Wed, 12 Apr 2017 22:06:10 +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 65CDA63671; Wed, 12 Apr 2017 22:06:09 +0000 (UTC) Received: from mail-oi0-f49.google.com (mail-oi0-f49.google.com [209.85.218.49]) by lists.linaro.org (Postfix) with ESMTPS id 4865B6353D for ; Wed, 12 Apr 2017 22:06:07 +0000 (UTC) Received: by mail-oi0-f49.google.com with SMTP id g204so47710591oib.1 for ; Wed, 12 Apr 2017 15:06:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/pFmZnHYgA5heVN8YTJAxv0mQf2yMpwF7/CtCQycXGg=; b=E24bR5xGK18BJhPZJ9nm5lkHKcUZK/vtTpeXj+LVD7bD3DT912kUQ+09KF5q155wKr 8BzODE5yQhh4sjRqrPsipHirmQrk1fPj1zlpXMj1gH34Iv2mb6JjmJ5pi1hX/YAdHDx6 PfYPavlAz+9zNapdoykyZu3284z5I0hBt4RDKZ63cjWL8VlsjswNtIHAD2llQsPtnRrU 6x5WOQVMtIMD3zyESc/DDH+P8y7FgpWgU+4h14wZypDYjB5/jHudnkamCn0RkSNvgfdh agoAK7xo3hl1BPxol+F0yJagVc7aCAYAuqYQhnTrvw8zAvAoNp90uyZ28TxuNetkUf6y m6jQ== X-Gm-Message-State: AN3rC/6+4zI7es+QgU7A6/06nDWP6KcV5GgRMZIwtcqxXWiOxk1e/JiUUIqEOXxhOICyeEVVSpM= X-Received: by 10.157.15.177 with SMTP id d46mr17454760otd.136.1492034766625; Wed, 12 Apr 2017 15:06:06 -0700 (PDT) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id b10sm964667ote.22.2017.04.12.15.06.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 15:06:05 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 12 Apr 2017 17:06:02 -0500 Message-Id: <20170412220602.9079-1-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [lng-odp] [PATCH] abi: packet: restore abi compatibility for odp_packet_seg_t type 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" When running in --enable-abi-compat=yes mode, all ODP types need to be of pointer width in the default ABI definition. The optimization of the odp_packet_seg_t type to uint8_t can only be supported when running in --enable-abi-compate=no mode. Change the ODP packet routines to use type converter routines that have varying definitions based on whether we're running in ABI compatibility mode and provide these variant definitions to enable proper ABI compatibility while still supporting an optimized typedef for non-ABI mode. This resolves Bug https://bugs.linaro.org/show_bug.cgi?id=2940 Signed-off-by: Bill Fischofer --- include/odp/arch/default/api/abi/packet.h | 7 +++++-- .../include/odp/api/plat/packet_inlines.h | 21 ++++++++++++++++++--- .../include/odp/api/plat/packet_types.h | 10 ++++++++++ platform/linux-generic/odp_packet.c | 12 +++++++----- 4 files changed, 40 insertions(+), 10 deletions(-) -- 2.9.3 diff --git a/include/odp/arch/default/api/abi/packet.h b/include/odp/arch/default/api/abi/packet.h index 60a41b8..4aac75b 100644 --- a/include/odp/arch/default/api/abi/packet.h +++ b/include/odp/arch/default/api/abi/packet.h @@ -16,15 +16,18 @@ extern "C" { /** @internal Dummy type for strong typing */ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_packet_t; +/** @internal Dummy type for strong typing */ +typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_seg_t; + /** @ingroup odp_packet * @{ */ typedef _odp_abi_packet_t *odp_packet_t; -typedef uint8_t odp_packet_seg_t; +typedef _odp_abi_packet_seg_t *odp_packet_seg_t; #define ODP_PACKET_INVALID ((odp_packet_t)0xffffffff) -#define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)-1) +#define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)0xffffffff) #define ODP_PACKET_OFFSET_INVALID (0x0fffffff) typedef enum { 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 eb36aa9..bd735c1 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -21,6 +21,20 @@ /** @internal Inline function offsets */ extern const _odp_packet_inline_offset_t _odp_packet_inline; +#if ODP_ABI_COMPAT +/** @internal Inline function @param seg @return */ +static inline int _odp_packet_seg_to_ndx(odp_packet_seg_t seg) +{ + return _odp_typeval(seg); +} + +/** @internal Inline function @param ndx @return */ +static inline odp_packet_seg_t _odp_packet_seg_from_ndx(int ndx) +{ + return _odp_cast_scalar(odp_packet_seg_t, ndx); +} +#endif + /** @internal Inline function @param pkt @return */ static inline void *_odp_packet_data(odp_packet_t pkt) { @@ -128,20 +142,21 @@ static inline odp_packet_seg_t _odp_packet_first_seg(odp_packet_t pkt) { (void)pkt; - return 0; + return _odp_packet_seg_from_ndx(0); } /** @internal Inline function @param pkt @return */ static inline odp_packet_seg_t _odp_packet_last_seg(odp_packet_t pkt) { - return _odp_packet_num_segs(pkt) - 1; + return _odp_packet_seg_from_ndx(_odp_packet_num_segs(pkt) - 1); } /** @internal Inline function @param pkt @param seg @return */ static inline odp_packet_seg_t _odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg) { - if (odp_unlikely(seg >= _odp_packet_last_seg(pkt))) + if (odp_unlikely(_odp_packet_seg_to_ndx(seg) >= + _odp_packet_seg_to_ndx(_odp_packet_last_seg(pkt)))) return ODP_PACKET_SEG_INVALID; return seg + 1; diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h index b8f665d..59e8b2f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -40,6 +40,16 @@ typedef ODP_HANDLE_T(odp_packet_t); typedef uint8_t odp_packet_seg_t; +static inline int _odp_packet_seg_to_ndx(odp_packet_seg_t seg) +{ + return (int)seg; +} + +static inline odp_packet_seg_t _odp_packet_seg_from_ndx(int ndx) +{ + return (odp_packet_seg_t)ndx; +} + #define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)-1) typedef enum { diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index b8aac6b..e99e8b8 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1185,7 +1185,7 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, void *addr = packet_map(pkt_hdr, offset, len, &seg_idx); if (addr != NULL && seg != NULL) - *seg = seg_idx; + *seg = _odp_packet_seg_from_ndx(seg_idx); return addr; } @@ -1326,20 +1326,22 @@ void *odp_packet_seg_data(odp_packet_t pkt, odp_packet_seg_t seg) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - if (odp_unlikely(seg >= pkt_hdr->buf_hdr.segcount)) + if (odp_unlikely(_odp_packet_seg_to_ndx(seg) >= + pkt_hdr->buf_hdr.segcount)) return NULL; - return packet_seg_data(pkt_hdr, seg); + return packet_seg_data(pkt_hdr, _odp_packet_seg_to_ndx(seg)); } uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - if (odp_unlikely(seg >= pkt_hdr->buf_hdr.segcount)) + if (odp_unlikely(_odp_packet_seg_to_ndx(seg) >= + pkt_hdr->buf_hdr.segcount)) return 0; - return packet_seg_len(pkt_hdr, seg); + return packet_seg_len(pkt_hdr, _odp_packet_seg_to_ndx(seg)); } /*