From patchwork Fri Dec 8 14:00:03 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: 121160 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp692358qgn; Fri, 8 Dec 2017 06:00:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMaevRXlxmzDxp06DTTyiL3oK0JdPV2uLYuvNhSuqZWuTfOXyeSpHJZBcYNUsjiD6BEZcMor X-Received: by 10.55.17.150 with SMTP id 22mr35530842qkr.208.1512741627390; Fri, 08 Dec 2017 06:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512741627; cv=none; d=google.com; s=arc-20160816; b=GaFIOil/Xo2qOKrOhGbQymT4GwCgkm77hqsEIUFsZ5BSPEU85e6VDVOGG6aa/NbPKr ei6FO1ABMd8NX9qsUa2eZvP94UrNieCWG36tVYr9f69bvaNX46xD/vKj+AtmR/Zbugh7 Yt0tFS1nwhpk8YSes9PhfM+eOrocsUg0lGjQjEVuZm+xsb7dpGbOLFrbRV5xb0FojrkK rRzWcnophjZcnIdVQnjNzbcxDoWUAqt3SCZjuu9L6IT48Of9xCU3bvqQnoGS28EAr/Nn Q4v8ha5Rs2qi1Xkq+xrI330b1EEDYPbY/1FZ18oQ+ZKOGEKf9Iu8gktqkgnL81Z14sWn AxsQ== 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=8REF6al3KEaOi7qBdrqW0P1GhPydwp7lk7JBZcW/zqM=; b=eiwNMrWjPzakDebZgbznqRpV3r6bhO+MuEtFeKZIz0LR9BKhzgcxGcdZ2LbEVYhIGt g8uGVk/KP6jW90Rzhx3KA2PXOHvB4z6ZrZDtnegNsgcd361K2ySCByqBDJpNrpi0xebU djUy9D7imNSimSvdiqCv3Y8H92ED4ISnZcRlT+ZkL+C2VVrcUj1XdUguTVd4cOIv01h6 s+7R+RIu1Nwqre3e1pUlxAcrnn2QIeLTLnNulrzGkS+5PR8VFPYPPccyORttOL3BNmP+ ORt6VPjgp2s8MsnU73hWrw6kP/oo7zr1DJ8UEvts3RaO96a7ts3FbtVub5dNcHZJ4xGd 89MQ== 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 w10si4785237qti.366.2017.12.08.06.00.26; Fri, 08 Dec 2017 06:00:27 -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 77A9F609AB; Fri, 8 Dec 2017 14:00:26 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 11C3D6097C; Fri, 8 Dec 2017 14:00:20 +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 2B6EC6097C; Fri, 8 Dec 2017 14:00:13 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 7084960957 for ; Fri, 8 Dec 2017 14:00:11 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward101o.mail.yandex.net (Yandex) with ESMTP id CD1751344D65 for ; Fri, 8 Dec 2017 17:00:09 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id S30xuaaq8T-09DC8500; Fri, 08 Dec 2017 17:00:09 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bhVzcDRW4Y-09dGrE1Z; Fri, 08 Dec 2017 17:00:09 +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: Fri, 8 Dec 2017 17:00:03 +0300 Message-Id: <1512741607-12425-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512741607-12425-1-git-send-email-odpbot@yandex.ru> References: <1512741607-12425-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 332 Subject: [lng-odp] [PATCH API-NEXT v1 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: cd9b8173d9b3bfc056941b52dd6bb50af9c698b9 **/ include/odp/api/spec/packet.h | 81 ++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index b897c9d3c..149ba4970 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 the 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 the 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 + * Set offset to the start of the layer 2. 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. + * 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 the 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 the 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 + * Set offset to the start of the layer 3. 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. + * 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 the 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 the 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 + * Set offset to the start of the layer 4. 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. + * 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)