From patchwork Sun Mar 5 12:21:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 94899 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp988439qgd; Sun, 5 Mar 2017 04:23:13 -0800 (PST) X-Received: by 10.55.133.1 with SMTP id h1mr4991883qkd.266.1488716593373; Sun, 05 Mar 2017 04:23:13 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l45si13395366qtf.37.2017.03.05.04.23.13; Sun, 05 Mar 2017 04:23:13 -0800 (PST) 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 0DE3C63D09; Sun, 5 Mar 2017 12:23:13 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 00BEA6362B; Sun, 5 Mar 2017 12:21:46 +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 5154163D0B; Sun, 5 Mar 2017 12:21:40 +0000 (UTC) Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by lists.linaro.org (Postfix) with ESMTPS id F11A860AC7 for ; Sun, 5 Mar 2017 12:21:31 +0000 (UTC) Received: by mail-wr0-f182.google.com with SMTP id g10so99597182wrg.2 for ; Sun, 05 Mar 2017 04:21:31 -0800 (PST) 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:in-reply-to :references; bh=JT5hQ82J8jYqTixSyzcRndadOLBQ4AYgRQH6TOO7occ=; b=NtiLv6tAVUTuNnCHotUZwq+YuUTUyCp5Fsx0lhhUcCFtB9VNLAjvhYz4lETZlxd7v9 tnFO0PpGqP0e/etLF8KoO+JX6VYlPlnSQ4bAyvqfeffxgirYipcJoL6p2flC0agunJ0y qCfZm3sJsZA9gKe+W5lRdreiMjGyncSVJVVAacsQEH8QTfpGUtrpomPsgDLMHFKSa3Mt S8gqCy6rbId7MlzyI/Z6SJG/eYdQTvDUWMdxMGWlSYNd5al5wKq3YsjqRJdijL2bvEHJ Kqu8dkBn6n/lFBnH5Hr2L66Ja+1TMpAzbR8QV4UlR8ySV/VDgSmVFU7bIJaoZXUXzPbN k2xw== X-Gm-Message-State: AMke39mxUWg7+kdu+MxTE7YBTZBnfpKLsmhmSjxn7FjZ8S5ID1Pd62hA8SUBjqZG5S4KRsQuT4gMcg== X-Received: by 10.223.149.37 with SMTP id 34mr10592471wrs.107.1488716490832; Sun, 05 Mar 2017 04:21:30 -0800 (PST) Received: from Ubuntu15.localdomain ([109.74.56.122]) by smtp.gmail.com with ESMTPSA id 127sm10686971wmt.20.2017.03.05.04.21.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Mar 2017 04:21:30 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 5 Mar 2017 13:21:17 +0100 Message-Id: <1488716485-15002-4-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1488716485-15002-1-git-send-email-bill.fischofer@linaro.org> References: <1488716485-15002-1-git-send-email-bill.fischofer@linaro.org> Subject: [lng-odp] [PATCH 03/11] linux-generic: packet: restructure inline routines to use macros 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" Use an internal macro for accessing inline fields in preparation for introducing packet reference support. Signed-off-by: Bill Fischofer --- .../include/odp/api/plat/packet_flag_inlines.h | 7 +++- .../include/odp/api/plat/packet_inlines.h | 44 +++++++++------------- 2 files changed, 23 insertions(+), 28 deletions(-) -- 2.5.0 diff --git a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h index 2de04c8..738fced 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h @@ -16,14 +16,17 @@ #include #include +/** @internal Packet field accessor */ +#define _odp_pkt_get(pkt, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.field)) + /** @internal Inline function offsets */ extern const _odp_packet_inline_offset_t _odp_packet_inline; /** @internal Inline function @param pkt @return */ static inline uint64_t _odp_packet_input_flags(odp_packet_t pkt) { - return *(uint64_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.input_flags); + return _odp_pkt_get(pkt, uint64_t, input_flags); } /** @internal Inline function @param pkt @return */ 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..02295b0 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -18,97 +18,89 @@ #include #include +/** @internal Packet field accessor */ +#define _odp_pkt_get(pkt, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.field)) + /** @internal Inline function offsets */ extern const _odp_packet_inline_offset_t _odp_packet_inline; /** @internal Inline function @param pkt @return */ static inline void *_odp_packet_data(odp_packet_t pkt) { - return *(void **)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.data); + return _odp_pkt_get(pkt, void *, data); } /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_seg_len(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.seg_len); + return _odp_pkt_get(pkt, uint32_t, seg_len); } /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_len(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.frame_len); + return _odp_pkt_get(pkt, uint32_t, frame_len); } /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_headroom(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.headroom); + return _odp_pkt_get(pkt, uint32_t, headroom); } /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_tailroom(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.tailroom); + return _odp_pkt_get(pkt, uint32_t, tailroom); } /** @internal Inline function @param pkt @return */ static inline odp_pool_t _odp_packet_pool(odp_packet_t pkt) { - return *(odp_pool_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.pool); + return _odp_pkt_get(pkt, odp_pool_t, pool); } /** @internal Inline function @param pkt @return */ static inline odp_pktio_t _odp_packet_input(odp_packet_t pkt) { - return *(odp_pktio_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.input); + return _odp_pkt_get(pkt, odp_pktio_t, input); } /** @internal Inline function @param pkt @return */ static inline int _odp_packet_num_segs(odp_packet_t pkt) { - return *(uint8_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.segcount); + return _odp_pkt_get(pkt, uint8_t, segcount); } /** @internal Inline function @param pkt @return */ static inline void *_odp_packet_user_ptr(odp_packet_t pkt) { - return *(void **)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.user_ptr); + return _odp_pkt_get(pkt, void *, user_ptr); } /** @internal Inline function @param pkt @return */ static inline void *_odp_packet_user_area(odp_packet_t pkt) { - return *(void **)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.user_area); + return _odp_pkt_get(pkt, void *, user_area); } /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_user_area_size(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.user_area_size); + return _odp_pkt_get(pkt, uint32_t, user_area_size); } /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.flow_hash); + return _odp_pkt_get(pkt, uint32_t, flow_hash); } /** @internal Inline function @param pkt @return */ static inline odp_time_t _odp_packet_ts(odp_packet_t pkt) { - return *(odp_time_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.timestamp); + return _odp_pkt_get(pkt, odp_time_t, timestamp); } /** @internal Inline function @param pkt @return */ @@ -120,7 +112,7 @@ static inline void *_odp_packet_head(odp_packet_t pkt) /** @internal Inline function @param pkt @return */ static inline int _odp_packet_is_segmented(odp_packet_t pkt) { - return _odp_packet_num_segs(pkt) > 1; + return _odp_pkt_get(pkt, uint8_t, segcount) > 1; } /** @internal Inline function @param pkt @return */