From patchwork Thu Jan 28 12:39:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 60720 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp449564lbb; Thu, 28 Jan 2016 04:43:47 -0800 (PST) X-Received: by 10.140.241.147 with SMTP id m141mr3358111qhc.76.1453985027828; Thu, 28 Jan 2016 04:43:47 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p8si11988104qgp.99.2016.01.28.04.43.47; Thu, 28 Jan 2016 04:43:47 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 570D0619BD; Thu, 28 Jan 2016 12:43:47 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=Mts2R6IX; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED 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 955E8619E7; Thu, 28 Jan 2016 12:40:06 +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 E7224618CB; Thu, 28 Jan 2016 12:39:50 +0000 (UTC) Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by lists.linaro.org (Postfix) with ESMTPS id B7421617E0 for ; Thu, 28 Jan 2016 12:39:46 +0000 (UTC) Received: by mail-oi0-f46.google.com with SMTP id o124so25478106oia.3 for ; Thu, 28 Jan 2016 04:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CAwgWIr28hgUstgGLJdorRVPTR+9vev0fbgWuIbHKMM=; b=Mts2R6IXaSxNPh5awePintP3yClLd73q+8vAgxGhQYQ86MyjhvhTTotuzN98n3QeZF niRpYlkOlShs09PD3PouBThPzwtjYMIWsSMNXa3tDhDMGPKAvuGsnFAGOhLGwujFrGl/ 5k+oecIQYgmp+eQeCv3AkuCgHTFXmnv9BbUcc= 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:in-reply-to :references; bh=CAwgWIr28hgUstgGLJdorRVPTR+9vev0fbgWuIbHKMM=; b=j0OYqy8WIl9mb3xsAoD5wssHN/7knSJKg8UPEV7fPcaw9Xi/+P4h21fkOTZ5R7n5wh L0REyG6Q7JpF9FwrdZ2mzmoMnatFKi7ZeTroD8C2TtFuqIBxnkF8NmmrYl3vSJ9Bnnvp ACVc9evdO8vqki9Ak/03RHi38GZF1wGQcPePGv7z+Tgs/pj1AJ6giXI+m6K8gVCX+8qg n8+ifdAu98+UYA/JN8NvL2xdHLGyc1GrIoQbQwh9G6FO8wrH12qojU7VGpMfx50pnqTI pgivcBhzF+Dp/tVwR91mdGItOpdfMq56O7Qo0fUV7CHT6kN9QZEdHB6SVsDriYyx2zc2 6WzA== X-Gm-Message-State: AG10YOQRuUzde/V65QrIeojYHn/7ep28TgJG0kJ0GKzoV2MtHfY1zx0I+WYVwFkeQEHx2wM3v7Q= X-Received: by 10.202.78.19 with SMTP id c19mr1890829oib.71.1453984786246; Thu, 28 Jan 2016 04:39:46 -0800 (PST) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id 133sm5359632oid.5.2016.01.28.04.39.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jan 2016 04:39:45 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 28 Jan 2016 06:39:36 -0600 Message-Id: <1453984776-29674-7-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453984776-29674-1-git-send-email-bill.fischofer@linaro.org> References: <1453984776-29674-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 6/6] documentation: userguide: add packet processing description 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Bill Fischofer --- doc/users-guide/users-guide.adoc | 121 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/doc/users-guide/users-guide.adoc b/doc/users-guide/users-guide.adoc index b3c08a1..513f383 100644 --- a/doc/users-guide/users-guide.adoc +++ b/doc/users-guide/users-guide.adoc @@ -768,6 +768,127 @@ NOTE: Both ordered and parallel queues improve throughput over atomic queues due to parallel event processing, but require that the application take steps to ensure context data synchronization if needed. +== Packet Processing +ODP applications are designed to process packets, which are the basic unit of +data of interest in the data plane. To assist in processing packets, ODP +provides a set of APIs that enable applications to examine and manipulate +packet data and metadata. Packets are referenced by an abstract *odp_packet_t* +handle defined by each implementation. + +Packet objects are normally created at ingress when they arrive at a source +*odp_pktio_t* and are received by an application either directly or (more +typically) foa a scheduled receive queue. They MAY be implicitly freed when +they are transmitted to an output *odp_pktio_t* via an associated transmit +queue, or freed directly via the +odp_packet_free()+ API. + +Occasionally an application may originate a packet itself, either _de novo_ or +by deriving it from an existing packet, and APIs are provided to assist in +these cases as well. Application-created packets can be recycled back through +a _loopback interface_ to reparse and reclassify them, or the application can +do its own parsing as desired. + +Various attributes associated with a packet, such as parse results, are +stored as metadata and APIs are provided to permit applications to examing +and/or modify this information. + +=== Packet Structure and Concepts +A _packet_ consists of a sequence of octets conforming to an architectued +format, such as Ethernet, that can be received and transmitted via the ODP +*pktio* abstraction. Packets of a _length_, which is the number of bytes in +the packet. Packet data in ODP is referenced via _offsets_ since these reflect +the logical contents and structure of a packet independent of how particular +ODP implementations store that data. + +These concetps are shown in the following diagram: + +.ODP Packet Structure +image::../images/packet.svg[align="center"] + +Packet data consists of zero or more _headers_ followed by 0 or more bytes of +_payload_, followed by zero or more _trailers_. Shown here are various APIs +that permit applications to examine and navigate various parts of a packet and +to manipulate its structure. + +To support packet manipulation, predefined _headroom_ and _tailroom_ +areas are logically associated with a packet. Packets can be adjusted by +_pulling_ and _pushing_ these areas. Typical packet processing might consist +of stripping headers from a packet via +odp_pull_head()+ calls as part of +receive procesing and then replacing them with new headers via +odp_push_head()+ +calls as the packet is being prepared for transmit. + +=== Packet Segments and Addressing +ODP platforms use various methods and techniques to store and process packets +efficiently. These vary considerably from platform to platofrm, so to ensure +portability across them ODP adopts certain conventions for referencing +packets. + +ODP APIs use a handle of type *odp_packet_t* to refer to packet objects. +Associated with packets are various bits of system metadata that describe the +packet. By referring to the metadata, ODP applications accelerate packet +processin gby minimizing the need to examine packet data. This is because the +metadata is pupolated by parsing and classification functions that are coupled +to ingress processing that occur prior to a packet being presented to the +application via the ODP scheduler. + +When an ODP application needs to examine the contents of a packet, it requests +addressability to it via an API call that makes the packet (or a contiguously +addressable _segment_ of it) available for coherent access by the application. +To ensure portability, ODP applications assume that the underlying +implementation stores packets in _segments_ of implementation-defined +and managed size. These represent the contiguously addressable portaions of a +packet that the application may refer to via normal memory accesses. ODP +provides APIs that allow applications to operate on packet segments in an +efficient and portable manner as needed. By combining these with the metadata +provided by packets, ODP applications can operate in a fully +platform-independent manner while still achieving optimal performance across +the range of platforms that support DOP. + +The use of segments for packet addressing and their relationship to metadata +is shown in this diagram: + +.ODP Packet Segmentation +image::../images/segment.svg[align="center"] + +The packet metadata is set during parsing and identifies the starting offsets +of the various headers in the packet. The packet itself is physically stored +as a sequence of segments that area managed by the ODP implementation. +Segment 0 is the first segment ofthe packet and is where the packet's headroom +and headers typically reside. Depending on the length of the packet, +additional segmnets may be part of the packet and contain the remaining packet +payload and tailroom. The application need not concern itself with segments +except that when the application requires addressability to a packet it +understands that addressability is provided on a per-segment basis. So, for +example, if the application makes a call like +odp_packet_l4_ptr()+ to obtain +addressability to the packet's Layer 4 header, the returned length from that +call is the number of bytes from the start of the Layer 4 header that are +contiguously addressable to the application from the returned pointer address. +This is because the following byte occupies a different segment and may be +stored elsewhere. To obtain access to those bytes, the application simply +requests addressability to that offset and it will be able to address the +packet bytes that occupy the next segment, etc. Note that the returned +length for any packet addressability call is always the lesser of the remaining +packet length or size of its containing segment. So a mapping for segment 2 +in the above figure, for example, would return a length that extends only to +the end of the packet since the remaining bytes are part of the tailroom +reserved for the packet and are not usable by the application until made +avaialble to it by an appropriate API call. + +=== Metadata Processing +As noted, packet metadata is normally set by the parser as part of +classification that occurs during packet receive processing. It is important +to note that this metadata may be changed by the application to reflect +changes in the packet contents and/or structure as part of its processing of +the packet. While changing this metadata may effect some ODP APIs, changing +metadata is designed to _document_ application changes to the packet but +does not in itself _cause_ those changes to be made. For example, if an +application changes the Layer 3 offset by using the +odp_packet_l3_offset_set()+ +API, the subsequent calls to +odp_packet_l3_ptr()+ will reutrn an address +starting from that changed offset, changing an attribute like ++odp_packet_has_udp_set()+ will not, by itself, turn a non-UDP packet into +a valid UDP packet. Applications are expected to exercise appropriate care +when changing packet metadata to ensure that the resulting metadata changes +reflect the actual changed packet structure that the application has made. + == Cryptographic services ODP provides support for cryptographic operations required by various security