From patchwork Wed Oct 26 01:56:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 79303 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp177197qge; Tue, 25 Oct 2016 18:57:07 -0700 (PDT) X-Received: by 10.159.38.11 with SMTP id 11mr5173541uag.26.1477447027741; Tue, 25 Oct 2016 18:57:07 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e12si6059674vkd.36.2016.10.25.18.57.07; Tue, 25 Oct 2016 18:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E4CC0617A3; Wed, 26 Oct 2016 01:57:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1A66760F16; Wed, 26 Oct 2016 01:57:01 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 68FF560F2E; Wed, 26 Oct 2016 01:56:58 +0000 (UTC) Received: from mail-oi0-f54.google.com (mail-oi0-f54.google.com [209.85.218.54]) by lists.linaro.org (Postfix) with ESMTPS id 6580960E7E for ; Wed, 26 Oct 2016 01:56:57 +0000 (UTC) Received: by mail-oi0-f54.google.com with SMTP id t73so130247527oie.1 for ; Tue, 25 Oct 2016 18:56:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=T1r552xLLGtSbDXvfzwWHi3NFuuY3ndmgqR8hnwNNYI=; b=hNUC6TNpbG0Vrhcvek0Dc+I79xGh59GCYtLnSHOFW/asqNy515jbiBxwrylPkYwNdv 2qD24WgVTCI7LiN+81bZ19JF8vfdrhPWWyZzt/sjgy8+hV5WIvGSY9/Qhu4UqzVvRxAp nZ86BDdGhf6pwpsu5vJhZxvcfV89P/ajmJAb965VBhDyp2dycfOMwJ9xF6V7DtrFndnp qpmRgmvRLE3s4cXlr0ptOgYCQIs8yzYhK+nCzi5qHiOwiz6OKSPd/kM3j6V9zSTz8FP/ zJr+xwf+wcKgurK1yaCRmWwfMq7AS5AfRn7SEv9EyqnkeRyF5ySQo6awsbbUG0ToIjKv 9Kfw== X-Gm-Message-State: ABUngvcHiv37brTDf+T5el+OgqzmObdECvwkiqwjXsBtaH1yUaJtqvwOKAqpcPx5PAWiFUR3WRI= X-Received: by 10.157.33.166 with SMTP id s35mr7376719otb.92.1477447016567; Tue, 25 Oct 2016 18:56:56 -0700 (PDT) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id w68sm7726051otb.29.2016.10.25.18.56.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 18:56:55 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 25 Oct 2016 20:56:54 -0500 Message-Id: <1477447014-700-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [RFC API-NEXT PATCH] api: packet: add packet reference apis X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Add the following five packet APIs: - odp_packet_ref_static() - odp_packet_ref() - odp_packet_ref_pkt() - odp_packet_is_a_ref() - odp_packet_is_referenced() Signed-off-by: Bill Fischofer --- include/odp/api/spec/packet.h | 143 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) -- 2.7.4 diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 4a14f2d..7e347c5 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -846,6 +846,149 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, odp_packet_t *tail); /* * + * References + * ******************************************************** + * + */ + +/** + * Create a static reference to a packet + * + * Create a (shared) reference to a base packet. A static reference is used to + * retain a copy of the packet so that the storage behind it is not freed + * until all references to the packet are freed. This can be used, for + * example, to support efficient retransmission processing. + * + * @param pkt Handle of the base packet for which a static reference is + * to be created. + * + * @return Handle of the reference packet + * @retval ODP_PACKET_INVALID Operation failed. Base packet remains unchanged. + * + * @note The intent of a static reference is that both the base packet and the + * returned reference should be treated as read-only after this + * call. Results are unpredictable if this restriction is not observed. + * + * @note Static references have restrictions but may have performance + * advantages on some platforms if the caller does not intend to modify + * the reference packet. If modification is needed (e.g., to prefix a + * unique header onto the packet) then odp_packet_ref() should be used. + */ +odp_packet_t odp_packet_ref_static(odp_packet_t pkt); + +/** + * Create a reference to a packet + * + * Create a (shared) reference to a base packet starting at a specified byte + * offset. This reference may be used as an argument to header manipulation + * APIs to prefix a unique header onto the shared base. The storage associated + * with the base packet is not freed until all references to it are freed, + * which permits easy multicasting or retransmission processing to be + * performed. + * + * @param pkt Handle of the base packet for which a reference is to be + * created. + * + * @param offset Byte offset in the base packet at which the shared reference + * is to begin. Must be in the range 0..odp_packet_len(pkt)-1. + * + * @return Handle of the reference packet + * @retval ODP_PACKET_INVALID Operation failed. Base packet remains unchanged. + * + * @note This operation prepends a zero-length header onto the base packet + * beginning at the specified offset. This header is always drawn from + * the same pool as the base packet. + * + * @note Because references are unique packets, any bytes pushed onto the head + * of a reference via odp_packet_push_head() or odp_packet_extend_head() + * are unique to this reference and are not seen by any other reference + * to the same base packet. + * + * @note The base pkt used as input to this routine may itself by a reference + * to some other base packet. Implementations MAY restrict the ability + * to create such compound references. Attempts to exceed any + * implementation limits in this regard will result in this call failing + * and returning ODP_PACKET_INVALID. + * + * @note If the caller does not indend to push a header onto the returned + * reference, the odp_packet_ref_static() API may be used. This may be a + * more efficient means of obtaining another reference to a base packet + * that will be treated as read-only. + */ +odp_packet_t odp_packet_ref(odp_packet_t pkt, uint32_t offset); + +/** + * Create a reference to another packet from a header packet + * + * Create a (shared) reference to a base packet starting at a specified byte + * offset by prepending a header packet. The resulting reference consists of + * the unshared header followed by the shared base packet starting at the + * specified offset. This shared portion should be regarded as read-only. The + * storage associated with the shared portion of the reference is not freed + * until all references to it are freed, which permits easy multicasting or + * retransmission processing to be performed. + * + * @param pkt Handle of the base packet for which a reference is to be + * created. + * + * @param offset Byte offset in the base packet at which the shared reference + * to begin. Must be in the range 0..odp_packet_len(pkt)-1. + * + * @param hdr Handle of the header packet to be prefixed onto the base + * packet to create the reference. If this is specified as + * ODP_PACKET_INVALID, this call is equivalent to + * odp_packet_ref(). + * + * @return Handle of the reference packet. This may or may not be the + * same as the input hdr packet. The caller should only use this + * handle since the original hdr packet no longer has any + * independent existence. + * + * @retval ODP_PACKET_INVALID If the reference failed. In this case both pkt + * and hdr are unchanged. + * + * @note Either packet input to this routine may itself be a reference, + * however individual implementations MAY impose limits on how deeply + * splices may be nested and fail the call if those limits are exceeded. + * + * @note The packets used as input to this routine may reside in different + * pools, however individual implementations MAY require that both + * reside in the same pool and fail the call if this restriction is not + * observed. odp_packet_pool() on the returned reference returns the + * pool id of the header packet. + */ +odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset, + odp_packet_t hdr); + +/** + * Test if a packet is a reference + * + * A packet is a reference if it was created by odp_packet_ref_xxx(). + * Note that a reference created from another reference is considered + * a compound reference. + * + * @param pkt Packet handle + * + * @retval 0 Packet is not a reference + * @retval >0 Packet is a reference consisting of N individual packets. + */ +int odp_packet_is_a_ref(odp_packet_t pkt); + +/** + * Test if a packet is referenced + * + * A packet is referenced if a reference was created on it by + * odp_packet_ref_xxx(). + * + * @param pkt Packet handle + * + * @retval 0 Packet is not referenced + * @retval >0 Packet is N references based on it + */ +int odp_packet_is_referenced(odp_packet_t pkt); + +/* + * * Copy * ******************************************************** *