From patchwork Sun Feb 1 00:16:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44113 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8AB552359E for ; Sun, 1 Feb 2015 00:17:54 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id ge10sf13705716lab.1 for ; Sat, 31 Jan 2015 16:17:52 -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=Fj/oMt0dYrImJ4PnoYaMAk0h4Bx2KN46j9j9RdoEBHJqk2eiBUDL1jMx7zcntYjObt 74AiO+hTgOLUxigFyQveqz5nA0bh/rde3ak1aM7ukobRk21waxnjhcMxv3URitr19Jwe BtBU/zz4lVjTLUcscI3ZTjnD0cu19AsVCJFr83DOJ2G48Lbc1SK3n74xHaflVTjgOcIl tc9KMT80Lmb1xKb57tPW+zZ27pexwShKQrUfe6+HhCOnFMmczwlgDxUr0x8XEYBeKXKV tuzbCWE+XTuhGEWtyx6P58rzEUkIftIBUQgSbceMQfjxgoGR8E9VQC5aaP8TXVtv8bk/ Ka8A== X-Gm-Message-State: ALoCoQleB5t/kFoAT3XytD1zEIdZKegOJrLthQdPYAttkfHMqYu960IKZADhU/gSz/fbF004cAx5 X-Received: by 10.112.163.42 with SMTP id yf10mr1571331lbb.8.1422749872512; Sat, 31 Jan 2015 16:17:52 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.35 with SMTP id p3ls616149lap.49.gmail; Sat, 31 Jan 2015 16:17:52 -0800 (PST) X-Received: by 10.152.5.193 with SMTP id u1mr12665296lau.96.1422749872375; Sat, 31 Jan 2015 16:17:52 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id c6si1372620lag.104.2015.01.31.16.17.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 16:17:52 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id gf13so31074381lab.8 for ; Sat, 31 Jan 2015 16:17:52 -0800 (PST) X-Received: by 10.152.203.230 with SMTP id kt6mr12606105lac.38.1422749872276; Sat, 31 Jan 2015 16:17:52 -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 h5csp507795lbj; Sat, 31 Jan 2015 16:17:51 -0800 (PST) X-Received: by 10.140.92.138 with SMTP id b10mr25747056qge.59.1422749871010; Sat, 31 Jan 2015 16:17:51 -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 p1si19902220qas.45.2015.01.31.16.17.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 Jan 2015 16:17:50 -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 1YHiEV-0002PI-Va; Sun, 01 Feb 2015 00:17:48 +0000 Received: from mail-ob0-f173.google.com ([209.85.214.173]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHiDw-0002J0-LE for lng-odp@lists.linaro.org; Sun, 01 Feb 2015 00:17:12 +0000 Received: by mail-ob0-f173.google.com with SMTP id uy5so18656362obc.4 for ; Sat, 31 Jan 2015 16:17:07 -0800 (PST) X-Received: by 10.202.56.133 with SMTP id f127mr7300817oia.101.1422749827400; Sat, 31 Jan 2015 16:17:07 -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 xr17sm5945905oeb.12.2015.01.31.16.17.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 16:17:07 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 31 Jan 2015 18:16:41 -0600 Message-Id: <1422749807-20228-11-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422749807-20228-1-git-send-email-bill.fischofer@linaro.org> References: <1422749807-20228-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv4 07/10] 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.49 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)