From patchwork Mon Dec 11 12:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121377 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2700514qgn; Mon, 11 Dec 2017 04:03:30 -0800 (PST) X-Google-Smtp-Source: ACJfBotH3k8nD7RrXy8EEpg3GnWtLGBAgR+Y83QfiseLRjbU9vRR62Zf/vhBvI888Ptw4tE90EYp X-Received: by 10.55.43.156 with SMTP id r28mr205286qkr.316.1512993810659; Mon, 11 Dec 2017 04:03:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512993810; cv=none; d=google.com; s=arc-20160816; b=y+dYzqw/xCmleKKlIbuadDc/WvSnDdCgCp4mWAugeEkHeXaunUPv0einVusYXJO0qN GlB+RNIZTaJ/dV6DsOQF4X5U9hwqsODxpr2j2k08+8NXkai+w5HaWVDEYIPYt4vhUAwt JmzUx/DL02TLvU6ubA2chYI32V2aegk1klbwxmZ5TbMg7A++SmT5AaUcoFfcvQFRdSpj 1cnivXbO0kcVqcueBsAzNUItsWTnxaJ6OB/00wQRhlfLC3wwzsdFxol8OB4YWhvC05OF TkeFgpjLzsjgPPU1Mlx5azdlp/pb2R2A0AK8FyiWs/e/IO/rgeVwvj1eg1wBVvNBaW8X uw+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=NFjL9WKRqmuIxrihJYCRyUdDTDYY9UIPmBJlIQWG7xY=; b=NlfUpKQcmMn+xL1tOifr1h7DDS3Sswoqoljn5Kmj/tmrqrUbZcYxrXxIy9tjcWHX22 HElJbgSJyN24SKGG0832Ev4C4bVpk0nFmcsf/VqpRbgDv5wleqO9bufFRLzJ5OB30G1+ KgNd5mdQX/+X4LDhLoIfIo3AkDl7AMM8PMX22GRfFgMpml100mppShPmiju/mSMBPasZ 4iI8H6rFB657ZsyvoVFTe6tRsEQBmt/0a/00v85ZThBbR3O1z/o1ICXqjf8Mzsv+YsXa eFkCnEQ9EpvcsWUEA7LG0Hnt2btffqMgt3xV1NDtWbmCzyqyi415sc6PwBXAuYhBfqDr pewg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id 131si2165039qkh.455.2017.12.11.04.03.30; Mon, 11 Dec 2017 04:03:30 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 566AB60880; Mon, 11 Dec 2017 12:03:30 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 51AA9608DF; Mon, 11 Dec 2017 12:01:56 +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 E2FC2608F2; Mon, 11 Dec 2017 12:01:41 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id D92C060907 for ; Mon, 11 Dec 2017 12:00:12 +0000 (UTC) Received: from mxback6j.mail.yandex.net (mxback6j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10f]) by forward106p.mail.yandex.net (Yandex) with ESMTP id F40DD2D829BC for ; Mon, 11 Dec 2017 15:00:10 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback6j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 615nBQL5wC-0A6GYlAH; Mon, 11 Dec 2017 15:00:10 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 05zxW8uoau-09keVt2g; Mon, 11 Dec 2017 15:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 11 Dec 2017 15:00:04 +0300 Message-Id: <1512993608-19038-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512993608-19038-1-git-send-email-odpbot@yandex.ru> References: <1512993608-19038-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 332 Subject: [lng-odp] [PATCH API-NEXT v2 1/5] api: packet: refine layer offset specification 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" From: Petri Savolainen Offset functions just point to the start of an layer. Offsets may be set also when a layer does not have a known header or a known header has an error. For example, L4 offset may be set always after a successful parse of L3 (IP) layer. There are other API calls to check if L4 is a known protocol (e.g. packet_has_l4, packet_has_udp), or if it contain errors (e.g. packet_has_l4_error). Signed-off-by: Petri Savolainen --- /** Email created from pull request 332 (psavol:next-l4-offset) ** https://github.com/Linaro/odp/pull/332 ** Patch: https://github.com/Linaro/odp/pull/332.patch ** Base sha: 0980001e33b4190133d478a0aa2e718fd1e3c164 ** Merge commit sha: 821e53e2ab0847f73ddb171a65e3e4fc5d28e64f **/ include/odp/api/spec/packet.h | 87 ++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index b897c9d3c..d444c317a 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1347,15 +1347,16 @@ uint32_t odp_packet_user_area_size(odp_packet_t pkt); /** * Layer 2 start pointer * - * Returns pointer to the start of the layer 2 header. Optionally, outputs - * number of data bytes in the segment following the pointer. + * Returns pointer to the start of layer 2. Optionally, outputs number of data + * bytes in the segment following the pointer. The pointer value is generated + * from the current layer 2 offset. * * @param pkt Packet handle * @param[out] len Number of data bytes remaining in the segment (output). * Ignored when NULL. * - * @return Layer 2 start pointer - * @retval NULL packet does not contain a valid L2 header + * @return Layer 2 start pointer + * @retval NULL Layer 2 offset has not been set * * @see odp_packet_l2_offset(), odp_packet_l2_offset_set(), odp_packet_has_l2() */ @@ -1364,16 +1365,16 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len); /** * Layer 2 start offset * - * Returns offset to the start of the layer 2 header. The offset is calculated - * from the current odp_packet_data() position in bytes. - * - * User is responsible to update the offset when modifying the packet data - * pointer position. + * Returns offset to the start of layer 2. The offset is calculated from the + * current odp_packet_data() position in bytes. Packet parsing sets the offset + * according to parse configuration and layers recognized in the packet. Data + * start position updating functions (e.g. odp_packet_push_head()) do not modify + * the offset, but user sets a new value when needed. * * @param pkt Packet handle * - * @return Layer 2 start offset - * @retval ODP_PACKET_OFFSET_INVALID packet does not contain a valid L2 header + * @return Layer 2 start offset + * @retval ODP_PACKET_OFFSET_INVALID Layer 2 offset has not been set * * @see odp_packet_l2_offset_set(), odp_packet_has_l2() */ @@ -1382,9 +1383,9 @@ uint32_t odp_packet_l2_offset(odp_packet_t pkt); /** * Set layer 2 start offset * - * Set offset to the start of the layer 2 header. The offset is calculated from - * the current odp_packet_data() position in bytes. Offset must not exceed - * packet data length. Packet is not modified on an error. + * Set offset to the start of layer 2. The offset is calculated from the current + * odp_packet_data() position in bytes. Offset must not exceed packet data + * length. Offset is not modified on an error. * * @param pkt Packet handle * @param offset Layer 2 start offset (0 ... odp_packet_len()-1) @@ -1397,15 +1398,16 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset); /** * Layer 3 start pointer * - * Returns pointer to the start of the layer 3 header. Optionally, outputs - * number of data bytes in the segment following the pointer. + * Returns pointer to the start of layer 3. Optionally, outputs number of data + * bytes in the segment following the pointer. The pointer value is generated + * from the current layer 3 offset. * * @param pkt Packet handle * @param[out] len Number of data bytes remaining in the segment (output). * Ignored when NULL. * - * @return Layer 3 start pointer - * @retval NULL packet does not contain a valid L3 header + * @return Layer 3 start pointer + * @retval NULL Layer 3 offset has not been set * * @see odp_packet_l3_offset(), odp_packet_l3_offset_set(), odp_packet_has_l3() */ @@ -1414,16 +1416,16 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len); /** * Layer 3 start offset * - * Returns offset to the start of the layer 3 header. The offset is calculated - * from the current odp_packet_data() position in bytes. - * - * User is responsible to update the offset when modifying the packet data - * pointer position. + * Returns offset to the start of layer 3. The offset is calculated from the + * current odp_packet_data() position in bytes. Packet parsing sets the offset + * according to parse configuration and layers recognized in the packet. Data + * start position updating functions (e.g. odp_packet_push_head()) do not modify + * the offset, but user sets a new value when needed. * * @param pkt Packet handle * - * @return Layer 3 start offset, or ODP_PACKET_OFFSET_INVALID when packet does - * not contain a valid L3 header. + * @return Layer 3 start offset + * @retval ODP_PACKET_OFFSET_INVALID Layer 3 offset has not been set * * @see odp_packet_l3_offset_set(), odp_packet_has_l3() */ @@ -1432,9 +1434,9 @@ uint32_t odp_packet_l3_offset(odp_packet_t pkt); /** * Set layer 3 start offset * - * Set offset to the start of the layer 3 header. The offset is calculated from - * the current odp_packet_data() position in bytes. Offset must not exceed - * packet data length. Packet is not modified on an error. + * Set offset to the start of layer 3. The offset is calculated from the current + * odp_packet_data() position in bytes. Offset must not exceed packet data + * length. Offset is not modified on an error. * * @param pkt Packet handle * @param offset Layer 3 start offset (0 ... odp_packet_len()-1) @@ -1447,15 +1449,16 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset); /** * Layer 4 start pointer * - * Returns pointer to the start of the layer 4 header. Optionally, outputs - * number of data bytes in the segment following the pointer. + * Returns pointer to the start of layer 4. Optionally, outputs number of data + * bytes in the segment following the pointer. The pointer value is generated + * from the current layer 4 offset. * * @param pkt Packet handle * @param[out] len Number of data bytes remaining in the segment (output). * Ignored when NULL. * - * @return Layer 4 start pointer - * @retval NULL packet does not contain a valid L4 header + * @return Layer 4 start pointer + * @retval NULL Layer 4 offset has not been set * * @see odp_packet_l4_offset(), odp_packet_l4_offset_set(), odp_packet_has_l4() */ @@ -1464,16 +1467,16 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len); /** * Layer 4 start offset * - * Returns offset to the start of the layer 4 header. The offset is calculated - * from the current odp_packet_data() position in bytes. - * - * User is responsible to update the offset when modifying the packet data - * pointer position. + * Returns offset to the start of layer 4. The offset is calculated from the + * current odp_packet_data() position in bytes. Packet parsing sets the offset + * according to parse configuration and layers recognized in the packet. Data + * start position updating functions (e.g. odp_packet_push_head()) do not modify + * the offset, but user sets a new value when needed. * * @param pkt Packet handle * - * @return Layer 4 start offset - * @retval ODP_PACKET_OFFSET_INVALID packet does not contain a valid L4 header + * @return Layer 4 start offset + * @retval ODP_PACKET_OFFSET_INVALID Layer 4 offset has not been set * * @see odp_packet_l4_offset_set(), odp_packet_has_l4() */ @@ -1482,9 +1485,9 @@ uint32_t odp_packet_l4_offset(odp_packet_t pkt); /** * Set layer 4 start offset * - * Set offset to the start of the layer 4 header. The offset is calculated from - * the current odp_packet_data() position in bytes. Offset must not exceed - * packet data length. Packet is not modified on an error. + * Set offset to the start of layer 4. The offset is calculated from the current + * odp_packet_data() position in bytes. Offset must not exceed packet data + * length. Offset is not modified on an error. * * @param pkt Packet handle * @param offset Layer 4 start offset (0 ... odp_packet_len()-1)