From patchwork Thu Jan 28 12:47:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 60732 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp472251lbb; Thu, 28 Jan 2016 05:25:44 -0800 (PST) X-Received: by 10.50.4.3 with SMTP id g3mr3384590igg.49.1453987544672; Thu, 28 Jan 2016 05:25:44 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d76si11373201ioe.209.2016.01.28.05.25.44; Thu, 28 Jan 2016 05:25:44 -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 ED0B26176E; Thu, 28 Jan 2016 13:25:43 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=VuG8x+Qb; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 41AF161D2C; Thu, 28 Jan 2016 13:04:07 +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 4812C615CF; Thu, 28 Jan 2016 13:02:47 +0000 (UTC) Received: from mail-oi0-f48.google.com (mail-oi0-f48.google.com [209.85.218.48]) by lists.linaro.org (Postfix) with ESMTPS id 8965D61971 for ; Thu, 28 Jan 2016 12:47:56 +0000 (UTC) Received: by mail-oi0-f48.google.com with SMTP id o124so25591536oia.3 for ; Thu, 28 Jan 2016 04:47:56 -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=VuG8x+Qbee9dcNWT7BOyjvOlvZC5KzsSLgYa4/kr3jfhwojwHu4LGXRg23mJHXcikm fOp7iDsHxNnKz9zvu0aN/18UvsK+MdNAtUfi8qEuF4OC0OrWPzfy789j/gaEKHQrnslx 14bnpV71hKMuZg1qgeeHBsMQ0G6D9DDxAqG08= 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=O3Rxbnfog6uV5xwNujVVGR6u2jh4cYBfSevY3cRmXWWrRidIYhJGauCQyB1UC4JL5Q l+nk6fmZ3RUxbOXEWjMp+VMl6/5lZ77TJZV+cuWaG6Hgk99P9OpBEEvl9vgXL4YCmO/6 nUqnI+7HihaFwA0y/nj+4ZeMtGQ3+yAtIOMoH83Pe36OdhYixIkN8qvHyw2RXV0uFgRL GGdVrpDmqGB61jHwE4vW0zQYcVmgMPI9aXm+Df4NRlDy9VvC0XLzHGet+4nR8oO30FX/ IPIoQvMHxrR32RANeABqr1/dZtpUWi/GgkqAU+Gc+RI/EIy6c5W7e3eSG8YmWhWIs+vT S4nA== X-Gm-Message-State: AG10YORe8YltWrcMCJu2/AhKovLnttGrhH3KFOoaZE/3h7XX81UrSCZ+gq1qWoDoy5HpBuC/FN4= X-Received: by 10.202.212.68 with SMTP id l65mr1925455oig.66.1453985276092; Thu, 28 Jan 2016 04:47:56 -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 u18sm5343302oie.9.2016.01.28.04.47.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jan 2016 04:47:55 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 28 Jan 2016 06:47:44 -0600 Message-Id: <1453985264-3807-7-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453985264-3807-1-git-send-email-bill.fischofer@linaro.org> References: <1453985264-3807-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 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