From patchwork Fri Jul 4 10:31:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 33084 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AF8EB20DCC for ; Fri, 4 Jul 2014 10:33:14 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id v10sf8558085pde.7 for ; Fri, 04 Jul 2014 03:33:14 -0700 (PDT) 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:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=7CwSAMIWQAADUDCgPav0eebpbAO1yxD+NUV5Lh9g8GA=; b=HBJn00zSMILBjO9z3iQo0Ia5iNgFls13Se7X5i8Bx8KFxwWrNYWv8XOC696jukeNf6 6xgdQeoxh28GQXi2Hs6poNhrQoBVu21w8EPDnr8dFotuMgGa+BWgyYw9KHEDAIkoqh4u 6Eq14wqgNrL/Fbc31wzUqDibj0X/tTXOSmYr/AAfedZjUurtz8t0H6zZtHskv9va701T K2GD0fU6Cw6cV3yoS20GZwg8/eHEmDsQJJA17lPKpa/tMEFGjNJtUnHBMlHq6iEhZshV Z19TMwjY+LNlJ5XuWtbVrNxeqK7v6r1o7RGKIAsLp3O/gXqkOd5ejs96dX2RVqOT/eGF DOzQ== X-Gm-Message-State: ALoCoQmwu6UO3T+1FdgCeavfBK+4jjdaYtF2IK9zXteJwkeLxF6cpk2noJnZVDJGgNcA1G0HuqDp X-Received: by 10.68.133.138 with SMTP id pc10mr5188026pbb.5.1404469994032; Fri, 04 Jul 2014 03:33:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.225 with SMTP id o88ls822640qge.88.gmail; Fri, 04 Jul 2014 03:33:13 -0700 (PDT) X-Received: by 10.52.123.232 with SMTP id md8mr7689053vdb.10.1404469993903; Fri, 04 Jul 2014 03:33:13 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id ym12si15324909vdc.19.2014.07.04.03.33.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Jul 2014 03:33:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id il7so1431254vcb.12 for ; Fri, 04 Jul 2014 03:33:13 -0700 (PDT) X-Received: by 10.52.117.209 with SMTP id kg17mr7630001vdb.28.1404469993813; Fri, 04 Jul 2014 03:33:13 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp455680vcb; Fri, 4 Jul 2014 03:33:13 -0700 (PDT) X-Received: by 10.140.109.135 with SMTP id l7mr6599932qgf.72.1404469992863; Fri, 04 Jul 2014 03:33:12 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id cg4si18450794qcb.2.2014.07.04.03.33.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 04 Jul 2014 03:33:12 -0700 (PDT) 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-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1X30lj-0006uF-QP; Fri, 04 Jul 2014 10:31:03 +0000 Received: from mail-qg0-f54.google.com ([209.85.192.54]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1X30le-0006uA-67 for lng-odp@lists.linaro.org; Fri, 04 Jul 2014 10:30:58 +0000 Received: by mail-qg0-f54.google.com with SMTP id q107so1319778qgd.13 for ; Fri, 04 Jul 2014 03:33:01 -0700 (PDT) X-Received: by 10.224.80.67 with SMTP id s3mr16864017qak.92.1404469980967; Fri, 04 Jul 2014 03:33:00 -0700 (PDT) Received: from localhost.localdomain (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id c8sm21369024qam.41.2014.07.04.03.32.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Jul 2014 03:32:59 -0700 (PDT) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Fri, 4 Jul 2014 13:31:56 +0300 Message-Id: <1404469916-16180-1-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.0.1 X-Topics: patch Subject: [lng-odp] [PATCH] Packet segment API continued 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: petri.savolainen@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.220.181 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 Replaced segment index with handle. Segment handle is always coupled with packet handle. Added functions to get segment handle from index and from current handle (iterate to next seg). Added segment info function. Signed-off-by: Petri Savolainen --- include/odp_packet.h | 103 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 21 deletions(-) diff --git a/include/odp_packet.h b/include/odp_packet.h index 8ae6410..ef4be9e 100644 --- a/include/odp_packet.h +++ b/include/odp_packet.h @@ -34,6 +34,25 @@ typedef odp_buffer_t odp_packet_t; /** + * ODP packet segment handle + */ +typedef int odp_packet_seg_t; + +/** Invalid packet segment */ +#define ODP_PACKET_SEG_INVALID -1 + +/** + * ODP packet segment info + */ +typedef struct odp_packet_seg_info_t { + void *addr; /**< Segment start address */ + size_t size; /**< Segment maximum data size */ + void *data; /**< Segment data address */ + size_t data_len; /**< Segment data length */ +} odp_packet_seg_info_t; + + +/** * Initialize the packet * * Needs to be called if the user allocates a packet buffer, i.e. the packet @@ -242,44 +261,78 @@ int odp_packet_is_segmented(odp_packet_t pkt); int odp_packet_seg_count(odp_packet_t pkt); /** + * Get segment by index + * + * @param pkt Packet handle + * @param index Segment index (0 ... seg_count-1) + * + * @return Segment handle, or ODP_PACKET_SEG_INVALID on an error + */ +odp_packet_seg_t odp_packet_seg(odp_packet_t pkt, int index); + +/** + * Get next segment + * + * @param pkt Packet handle + * @param seg Current segment handle + * + * @return Handle to next segment, or ODP_PACKET_SEG_INVALID on an error + */ +odp_packet_seg_t odp_packet_seg_next(odp_packet_t pkt, odp_packet_seg_t seg); + +/** + * Segment info + * + * Copies segment parameters into the info structure. + * + * @param pkt Packet handle + * @param seg Segment handle + * @param info Pointer to segment info structure + * + * @return 0 if successful, otherwise non-zero + */ +int odp_packet_seg_info(odp_packet_t pkt, odp_packet_seg_t seg, + odp_packet_seg_info_t *info); + +/** * Segment start address * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * - * @return Segment start address + * @return Segment start address, or NULL on an error */ -void *odp_packet_seg_addr(odp_packet_t pkt, int seg); +void *odp_packet_seg_addr(odp_packet_t pkt, odp_packet_seg_t seg); /** * Segment maximum data size * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * * @return Segment maximum data size */ -size_t odp_packet_seg_size(odp_packet_t pkt, int seg); +size_t odp_packet_seg_size(odp_packet_t pkt, odp_packet_seg_t seg); /** * Segment data address * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * * @return Segment data address */ -void *odp_packet_seg_data(odp_packet_t pkt, int seg); +void *odp_packet_seg_data(odp_packet_t pkt, odp_packet_seg_t seg); /** * Segment data length * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * * @return Segment data length */ -size_t odp_packet_seg_data_len(odp_packet_t pkt, int seg); +size_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg); /** * Segment headroom @@ -287,11 +340,11 @@ size_t odp_packet_seg_data_len(odp_packet_t pkt, int seg); * seg_headroom = seg_data - seg_addr * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * * @return Number of octets from seg_addr to seg_data */ -size_t odp_packet_seg_headroom(odp_packet_t pkt, int seg); +size_t odp_packet_seg_headroom(odp_packet_t pkt, odp_packet_seg_t seg); /** * Segment tailroom @@ -299,73 +352,81 @@ size_t odp_packet_seg_headroom(odp_packet_t pkt, int seg); * seg_tailroom = seg_size - seg_headroom - seg_data_len * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * * @return Number of octets from end-of-data to end-of-segment */ -size_t odp_packet_seg_tailroom(odp_packet_t pkt, int seg); +size_t odp_packet_seg_tailroom(odp_packet_t pkt, odp_packet_seg_t seg); /** * Push out segment head * * Push out segment data address (away from data) and increase data length. + * Does not modify packet in case of an error. * * seg_data -= len * seg_data_len += len * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * @param len Number of octets to push head (0 ... seg_headroom) * * @return New segment data address, or NULL on an error */ -void *odp_packet_seg_push_head(odp_packet_t pkt, int seg, size_t len); +void *odp_packet_seg_push_head(odp_packet_t pkt, odp_packet_seg_t seg, + size_t len); /** * Pull in segment head * * Pull in segment data address (towards data) and decrease data length. + * Does not modify packet in case of an error. * * seg_data += len * seg_data_len -= len * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * @param len Number of octets to pull head (0 ... seg_data_len) * * @return New segment data address, or NULL on an error */ -void *odp_packet_seg_pull_head(odp_packet_t pkt, int seg, size_t len); +void *odp_packet_seg_pull_head(odp_packet_t pkt, odp_packet_seg_t seg, + size_t len); /** * Push out segment tail * * Increase segment data length. + * Does not modify packet in case of an error. * * seg_data_len += len * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * @param len Number of octets to push tail (0 ... seg_tailroom) * * @return New segment data length, or -1 on an error */ -int odp_packet_seg_push_tail(odp_packet_t pkt, int seg, size_t len); +int odp_packet_seg_push_tail(odp_packet_t pkt, odp_packet_seg_t seg, + size_t len); /** * Pull in segment tail * * Decrease segment data length. + * Does not modify packet in case of an error. * * seg_data_len -= len * * @param pkt Packet handle - * @param seg Segment index (0 ... seg_count-1) + * @param seg Segment handle * @param len Number of octets to pull tail (0 ... seg_data_len) * * @return New segment data length, or -1 on an error */ -int odp_packet_seg_pull_tail(odp_packet_t pkt, int seg, size_t len); +int odp_packet_seg_pull_tail(odp_packet_t pkt, odp_packet_seg_t seg, + size_t len); #ifdef __cplusplus