From patchwork Wed Jan 21 04:57:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 43437 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C900C2034D for ; Wed, 21 Jan 2015 04:58:40 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id x12sf720771wgg.0 for ; Tue, 20 Jan 2015 20:58:40 -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=V205ERdrZPoUVI09zSscvIohRm8lO8Ph05J+newCbDM=; b=JR9myeyZ7KVfkLzXcZKZF4KtoNWo8n7fcKEnn5cHEM62OvEsWvPyBpe+b95nC7MAQh v8rdg25mdi2JJJ16+o+0qgqLOMG716YpY6OtE+IJdD+WoHCSXTXAWuv9qprnavlUW0+Q Y8od5I9jsEoVvYCKvj6bDMp7yopWVTCLKHkLvTGq/06WRrtFvwA4p4z15mUc1NMLSvS2 xQZBdKS2rZSG5ZHCwia3rdwxWjwxI/mtZuFiqNmj1d28O7TZLW9ReCbdBuBP65KlQr5T 90hO2qqS++QfoD9qR3JGFWKQ6M3jHO2Qe116CbaQ4EtfCfVmTpIFDN/kHab6yE16iAwe HV9A== X-Gm-Message-State: ALoCoQlAbiExG2KQ95EMnOdxuhFaYojdOM1GTHxujQJ1GMQzKTqzaLHlZVODxppAtgZN4uQ5hLHd X-Received: by 10.194.109.129 with SMTP id hs1mr39289wjb.3.1421816320101; Tue, 20 Jan 2015 20:58:40 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.41 with SMTP id bd9ls269380lab.14.gmail; Tue, 20 Jan 2015 20:58:39 -0800 (PST) X-Received: by 10.112.172.167 with SMTP id bd7mr42450933lbc.14.1421816319749; Tue, 20 Jan 2015 20:58:39 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id zp10si16906705lbb.104.2015.01.20.20.58.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 20:58:39 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id 10so37240066lbg.5 for ; Tue, 20 Jan 2015 20:58:39 -0800 (PST) X-Received: by 10.152.234.35 with SMTP id ub3mr42405812lac.70.1421816319673; Tue, 20 Jan 2015 20:58:39 -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.9.200 with SMTP id c8csp1651611lbb; Tue, 20 Jan 2015 20:58:39 -0800 (PST) X-Received: by 10.224.80.67 with SMTP id s3mr64661058qak.84.1421816318436; Tue, 20 Jan 2015 20:58:38 -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 a8si25241128qga.3.2015.01.20.20.58.37 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 20 Jan 2015 20:58:38 -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 1YDnND-0002PA-7u; Wed, 21 Jan 2015 04:58:35 +0000 Received: from mail-ob0-f175.google.com ([209.85.214.175]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDnMq-0002GS-5k for lng-odp@lists.linaro.org; Wed, 21 Jan 2015 04:58:12 +0000 Received: by mail-ob0-f175.google.com with SMTP id wp4so17038193obc.6 for ; Tue, 20 Jan 2015 20:58:07 -0800 (PST) X-Received: by 10.60.161.208 with SMTP id xu16mr5906360oeb.39.1421816286957; Tue, 20 Jan 2015 20:58:06 -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 a15sm2891071oic.18.2015.01.20.20.58.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jan 2015 20:58:06 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 20 Jan 2015 22:57:45 -0600 Message-Id: <1421816266-31223-8-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1421816266-31223-1-git-send-email-bill.fischofer@linaro.org> References: <1421816266-31223-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 7/8] api: packet: expose new packet APIs for events 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.217.174 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 --- platform/linux-generic/include/api/odp_packet.h | 32 ++++++++++++++++++---- .../linux-generic/include/odp_packet_internal.h | 8 +++++- platform/linux-generic/odp_packet.c | 14 ++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/include/api/odp_packet.h b/platform/linux-generic/include/api/odp_packet.h index 920a593..cdbf217 100644 --- a/platform/linux-generic/include/api/odp_packet.h +++ b/platform/linux-generic/include/api/odp_packet.h @@ -51,7 +51,7 @@ extern "C" { * Allocate a packet from a buffer pool * * Allocates a packet of the requested length from the specified buffer pool. - * Pool must have been created with buffer type ODP_BUFFER_TYPE_PACKET. The + * Pool must have been created with ODP_POOL_PACKET type. The * packet is initialized with data pointers and lengths set according to the * specified len, and the default headroom and tailroom length settings. All * other packet metadata are set to their default values. @@ -66,7 +66,7 @@ extern "C" { * the ODP_CONFIG_PACKET_HEADROOM and ODP_CONFIG_PACKET_TAILROOM defines in * odp_config.h. */ -odp_packet_t odp_packet_alloc(odp_buffer_pool_t pool, uint32_t len); +odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len); /** * Free packet @@ -96,6 +96,28 @@ void odp_packet_free(odp_packet_t pkt); int odp_packet_reset(odp_packet_t pkt, uint32_t len); /** + * Get packet handle from event + * + * Converts an ODP_EVENT_PACKET type event to a packet. + * + * @param ev Event handle + * + * @return Packet handle + * + * @see odp_event_type() + */ +odp_packet_t odp_packet_from_event(odp_event_t ev); + +/** + * Convert packet handle to event + * + * @param buf Packet handle + * + * @return Event handle + */ +odp_event_t odp_packet_to_event(odp_packet_t pkt); + +/** * Convert a buffer handle to a packet handle * * @param buf Buffer handle @@ -380,7 +402,7 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, * * @return Buffer pool handle */ -odp_buffer_pool_t odp_packet_pool(odp_packet_t pkt); +odp_pool_t odp_packet_pool(odp_packet_t pkt); /** * Packet input interface @@ -771,14 +793,14 @@ odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset, * * Create a new copy of the packet. The new packet is exact copy of the source * packet (incl. data and metadata). The pool must have been created with - * buffer type ODP_BUFFER_TYPE_PACKET. + * ODP_POOL_PACKET type. * * @param pkt Packet handle * @param pool Buffer pool for allocation of the new packet. * * @return Handle to the copy of the packet, or ODP_PACKET_INVALID */ -odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_buffer_pool_t pool); +odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool); /** * Copy data from packet diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 179330c..0ebc14b 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -253,10 +253,16 @@ int _odp_packet_copy_to_packet(odp_packet_t srcpkt, uint32_t srcoffset, odp_packet_t dstpkt, uint32_t dstoffset, uint32_t len); -odp_packet_t _odp_packet_alloc(odp_buffer_pool_t pool_hdl); +odp_packet_t _odp_packet_alloc(odp_pool_t pool_hdl); int _odp_packet_parse(odp_packet_t pkt); +/* Convert a packet handle to a buffer handle */ +odp_buffer_t _odp_packet_to_buffer(odp_packet_t pkt); + +/* Convert a buffer handle to a packet handle */ +odp_packet_t _odp_packet_from_buffer(odp_buffer_t buf); + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 257abec..1345618 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -25,6 +25,7 @@ * */ +odp_packet_t odp_packet_alloc(odp_pool_t pool_hdl, uint32_t len) odp_packet_t odp_packet_alloc(odp_buffer_pool_t pool_hdl, uint32_t len) { pool_entry_t *pool = odp_pool_to_entry(pool_hdl); @@ -75,6 +76,16 @@ odp_buffer_t odp_packet_to_buffer(odp_packet_t pkt) return (odp_buffer_t)pkt; } +odp_packet_t odp_packet_from_event(odp_event_t ev) +{ + return (odp_packet_t)ev; +} + +odp_event_t odp_packet_to_event(odp_packet_t pkt) +{ + return (odp_event_t)pkt; +} + /* * * Pointers and lengths @@ -199,6 +210,7 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, * */ +odp_pool_t odp_packet_pool(odp_packet_t pkt) odp_buffer_pool_t odp_packet_pool(odp_packet_t pkt) { return odp_packet_hdr(pkt)->buf_hdr.pool_hdl; @@ -453,6 +465,7 @@ odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset, * */ +odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool) odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_buffer_pool_t pool) { odp_packet_hdr_t *srchdr = odp_packet_hdr(pkt); @@ -613,6 +626,7 @@ int _odp_packet_copy_to_packet(odp_packet_t srcpkt, uint32_t srcoffset, return 0; } +odp_packet_t _odp_packet_alloc(odp_pool_t pool_hdl) odp_packet_t _odp_packet_alloc(odp_buffer_pool_t pool_hdl) { pool_entry_t *pool = odp_pool_to_entry(pool_hdl);