From patchwork Sat Jan 31 20:50:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44100 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 55E382359E for ; Sat, 31 Jan 2015 20:51:37 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gm9sf13575100lab.0 for ; Sat, 31 Jan 2015 12:51:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=3IopM1psKJFWy7nOCskRNnaURQY+d/KME+XMVY3VLmo=; b=DrNBuaPpcqIlEWYpDwtzthCnPboDKs+Vv/tVIERBSHNXqZr2R8ZCxgZLPWIMPvy56N ujcEr6BUzGFljwqRQ/3D/VGUjKE3kJ/QN6zTKIUg6IWqoDU0jwduyTIVS1b2LuIzgTAp wO1iJzGmVBH4qElTo2yF7fLAfJvPnwu5/97cnZ8S4fsjQFB8d2JnVZZMVggviSw8Jz9t L4JvpDDcXieylSynqNl0cTpwvN0DadbmGyHxvT8ONmYUHOwKkytzCJqAuaioQH/38PtO VwqMOkYJ8A02b0iuGCpOzfI/GGdy7BJ4IciDRI+crnHr1ezw7dWTNQUJuL0mXgyySqMi wIhg== X-Gm-Message-State: ALoCoQmmOHHZUAn+NsnJXgd9ykq6IS4B8cC7hNusUs6F+ecDuSln8J1TT64j1MkMaruWU7KNC/3W X-Received: by 10.112.137.70 with SMTP id qg6mr1520528lbb.14.1422737495557; Sat, 31 Jan 2015 12:51:35 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.239.165 with SMTP id vt5ls579690lac.0.gmail; Sat, 31 Jan 2015 12:51:35 -0800 (PST) X-Received: by 10.112.171.168 with SMTP id av8mr12401239lbc.88.1422737495408; Sat, 31 Jan 2015 12:51:35 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id gn3si2455328lbc.113.2015.01.31.12.51.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 12:51:35 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id s18so30706002lam.5 for ; Sat, 31 Jan 2015 12:51:35 -0800 (PST) X-Received: by 10.152.182.235 with SMTP id eh11mr12557294lac.9.1422737495282; Sat, 31 Jan 2015 12:51:35 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp450339lbj; Sat, 31 Jan 2015 12:51:34 -0800 (PST) X-Received: by 10.224.136.130 with SMTP id r2mr26371563qat.18.1422737493962; Sat, 31 Jan 2015 12:51:33 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id i8si19197304qas.93.2015.01.31.12.51.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 Jan 2015 12:51:33 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHf0s-0000wx-QW; Sat, 31 Jan 2015 20:51:30 +0000 Received: from mail-oi0-f50.google.com ([209.85.218.50]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHf0X-0000uA-Gj for lng-odp@lists.linaro.org; Sat, 31 Jan 2015 20:51:09 +0000 Received: by mail-oi0-f50.google.com with SMTP id h136so39530908oig.9 for ; Sat, 31 Jan 2015 12:51:04 -0800 (PST) X-Received: by 10.182.144.170 with SMTP id sn10mr7661749obb.52.1422737464239; Sat, 31 Jan 2015 12:51:04 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id uv10sm7202439obc.27.2015.01.31.12.51.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 12:51:03 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 31 Jan 2015 14:50:46 -0600 Message-Id: <1422737449-11540-7-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422737449-11540-1-git-send-email-bill.fischofer@linaro.org> References: <1422737449-11540-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 6/9] linux-generic: packet: add strong typing support X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Bill Fischofer --- include/odp/api/packet.h | 25 ++++++++++++++++++++++ .../linux-generic/include/odp/plat/packet_types.h | 24 +++++++++++++++------ platform/linux-generic/odp_packet.c | 8 +++---- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h index 3c1c646..7cc923e 100644 --- a/include/odp/api/packet.h +++ b/include/odp/api/packet.h @@ -869,6 +869,31 @@ void odp_packet_print(odp_packet_t pkt); */ int odp_packet_is_valid(odp_packet_t pkt); +/** + * Get printable value for an odp_packet_t + * + * @param hdl odp_packet_t handle to be printed + * @return uint64_t value that can be used to print/display this + * handle + * + * @note This routine is intended to be used for diagnostic purposes + * to enable applications to generate a printable value that represents + * an odp_packet_t handle. + */ +uint64_t odp_packet_t_print(odp_packet_t hdl); + +/** + * Get printable value for an odp_packet_seg_t + * + * @param hdl odp_packet_seg_t handle to be printed + * @return uint64_t value that can be used to print/display this + * handle + * + * @note This routine is intended to be used for diagnostic purposes + * to enable applications to generate a printable value that represents + * an odp_packet_seg_t handle. + */ +uint64_t odp_packet_seg_t_print(odp_packet_seg_t hdl); /** * @} diff --git a/platform/linux-generic/include/odp/plat/packet_types.h b/platform/linux-generic/include/odp/plat/packet_types.h index 60d6443..86f12a5 100644 --- a/platform/linux-generic/include/odp/plat/packet_types.h +++ b/platform/linux-generic/include/odp/plat/packet_types.h @@ -18,23 +18,35 @@ extern "C" { #endif - -#include +#include +#include /** @addtogroup odp_packet ODP PACKET * Operations on a packet. * @{ */ -typedef odp_buffer_t odp_packet_t; +typedef odp_handle_t odp_packet_t; -#define ODP_PACKET_INVALID ODP_BUFFER_INVALID +#define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0xffffffff) #define ODP_PACKET_OFFSET_INVALID (0x0fffffff) -typedef odp_buffer_t odp_packet_seg_t; +typedef odp_handle_t odp_packet_seg_t; + +#define ODP_PACKET_SEG_INVALID _odp_cast_scalar(odp_packet_seg_t, 0xffffffff) -#define ODP_PACKET_SEG_INVALID ODP_BUFFER_INVALID +/** Get printable format of odp_packet_t */ +static inline uint64_t odp_packet_t_print(odp_packet_t hdl) +{ + return _odp_pri(hdl); +} + +/** Get printable format of odp_packet_seg_t */ +static inline uint64_t odp_packet_seg_t_print(odp_packet_seg_t hdl) +{ + return _odp_pri(hdl); +} /** * @} diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 04787e8..b0f9771 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -193,10 +193,10 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, if (addr != NULL && seg != NULL) { odp_buffer_bits_t seghandle; - seghandle.handle = pkt; + seghandle.handle = (odp_buffer_t)pkt; seghandle.seg = (pkt_hdr->headroom + offset) / pkt_hdr->buf_hdr.segsize; - *seg = seghandle.handle; + *seg = (odp_packet_seg_t)seghandle.handle; } return addr; @@ -325,9 +325,9 @@ odp_packet_seg_t odp_packet_last_seg(odp_packet_t pkt) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); odp_buffer_bits_t seghandle; - seghandle.handle = pkt; + seghandle.handle = (odp_buffer_t)pkt; seghandle.seg = pkt_hdr->buf_hdr.segcount - 1; - return seghandle.handle; + return (odp_packet_seg_t)seghandle.handle; } odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg)