From patchwork Sat Jan 31 16:14:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44087 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 59B332359E for ; Sat, 31 Jan 2015 16:15:17 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf7781744wiv.2 for ; Sat, 31 Jan 2015 08:15:16 -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=Ni2BsbTimLA57LBZKSzZhvVZsoa9afJnOMOO/pZ3/WvGL2fOVUPHhja/5Sd+9+KxyC bSFFoLwsTDCW4DRYLYnd3DLMDF8nr7O43p3QWxNaqg7Y4qFfP6JCYPEcf1V7eqWEw9Lt W//P+D2YSJW2aLKdcyoTESI4uf3JxPr9VmqvqxAOkVKTv81OfofaiDeufvLNq9MPzdG7 k4K/bvnPVDA3Ku1HH3cRJ/9z4qMpGY1fO4mApszzn/DxwSPRwqEYfGxHKaznftf+GXMu +a6BsBCMUZkp71PNe0vs5nKIPfaSR5drgZ69TNeh9a0kONJrtLYmHLlG7z5Wabl0Z0uR QnNw== X-Gm-Message-State: ALoCoQmrTFX9VBUZ8lzCwzhQY7LvKEeC1UoJhiCYaUlI95+yXS2BK18c59Xl7TwdXu6UqCO8Dqiy X-Received: by 10.180.13.83 with SMTP id f19mr281314wic.7.1422720916594; Sat, 31 Jan 2015 08:15:16 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.135 with SMTP id s7ls541799las.39.gmail; Sat, 31 Jan 2015 08:15:16 -0800 (PST) X-Received: by 10.152.179.41 with SMTP id dd9mr10132243lac.66.1422720916432; Sat, 31 Jan 2015 08:15:16 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id j6si12675405lab.20.2015.01.31.08.15.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 08:15:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so29486292lab.6 for ; Sat, 31 Jan 2015 08:15:16 -0800 (PST) X-Received: by 10.112.181.41 with SMTP id dt9mr11377451lbc.56.1422720916254; Sat, 31 Jan 2015 08:15:16 -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 h5csp352011lbj; Sat, 31 Jan 2015 08:15:15 -0800 (PST) X-Received: by 10.140.106.228 with SMTP id e91mr22457081qgf.19.1422720914869; Sat, 31 Jan 2015 08:15:14 -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 c17si18391903qgd.17.2015.01.31.08.15.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 Jan 2015 08:15:14 -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 1YHahR-00058k-5z; Sat, 31 Jan 2015 16:15:09 +0000 Received: from mail-oi0-f54.google.com ([209.85.218.54]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHah6-00055r-4Y for lng-odp@lists.linaro.org; Sat, 31 Jan 2015 16:14:48 +0000 Received: by mail-oi0-f54.google.com with SMTP id v63so38891243oia.13 for ; Sat, 31 Jan 2015 08:14:42 -0800 (PST) X-Received: by 10.202.183.138 with SMTP id h132mr6767482oif.132.1422720882822; Sat, 31 Jan 2015 08:14:42 -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 ur1sm6921411obc.3.2015.01.31.08.14.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 08:14:42 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 31 Jan 2015 10:14:23 -0600 Message-Id: <1422720866-22194-7-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422720866-22194-1-git-send-email-bill.fischofer@linaro.org> References: <1422720866-22194-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 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.47 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)