From patchwork Fri Dec 8 14:00:06 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: 121165 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp699095qgn; Fri, 8 Dec 2017 06:04:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMbY2oyuHakvzeEFyIDCW6CebjlhdFysXG1srVLyT5Md9WGanHUGHrk/eKkr07odSHQbe2+M X-Received: by 10.36.70.195 with SMTP id j186mr5759207itb.32.1512741882025; Fri, 08 Dec 2017 06:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512741882; cv=none; d=google.com; s=arc-20160816; b=DPRmCRoZrmVfLg3P7vpsf/qkN/ZZu/ar+2cTHr6Pcv07oXWGWIUbzD3cyLHQRxd4SN Kzru1Lof4Zg4fVZeV8GxY3sRPBwS8cxpdmyUz1uXWLCT5PDWV+H1K51RhLVElMUc4x46 mENdlEa3yHUUcEl+z4zZr1ebqlQiX2njZjvVBLebwYynnfYCND5+mJrkTorJjrmm5SJZ Xbra/ViTwr9/DxKjTAdNTKSYX7D21G2eVK+7xn1llqI57C77IMQQoNH68PvPfnN95+69 avYJzrPQ8doMSeqasBbwftO30ZtIedXSktB/lsdZ4wq+ZQbRBKkasYd2I71WWZ1+x7Qg 2SXg== 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=7jxaU9GOUwsGhh+5xTTGRTmch7yDtcvanSKfDLIhk0o=; b=aUnZV/UXWoubNVeGR6hHqWvSFcbXpxO1Wg1zkm8CAJDoc/agv68MhdYDBL9JoU3nbS +SE9yMkTkcqBzxISN6aoAEhVWneFMzfQ2tyhxUeJJDGrMwczBS7OvN2UcM38f2ptoL0V pJgC2sSkhAAMXmeUMhz3GK+aYXXPUfDbGs6TJia+KkNqL2NlJt2DgRvESSJiv4rLuKLd zp70vl3oX1NU+vF14f72Uz87batS5EexNwWXMvNyuN6xgJtKzvO4Kk0gZINLW/HKWtzI HhCW/Kj1c0+AD4hYpcIxzMFh1Umvju0JzptYNdxiKZctSbJ6lcx/n0gGYdTZ/VwvpOvi 0Dpg== 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 m63si1218960ite.48.2017.12.08.06.04.41; Fri, 08 Dec 2017 06:04:42 -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 8FD8C60A0B; Fri, 8 Dec 2017 14:04:41 +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 D9BAD609F5; Fri, 8 Dec 2017 14:00:55 +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 26FA760978; Fri, 8 Dec 2017 14:00:21 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 8C6DC60978 for ; Fri, 8 Dec 2017 14:00:13 +0000 (UTC) Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward103j.mail.yandex.net (Yandex) with ESMTP id EFAEB34C45DF for ; Fri, 8 Dec 2017 17:00:11 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Hk3FEadFEe-0BfO46iu; Fri, 08 Dec 2017 17:00:11 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bhVzcDRW4Y-0Bd4NlNI; Fri, 08 Dec 2017 17:00:11 +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:06 +0300 Message-Id: <1512741607-12425-5-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 4/5] api: parse: set next layer offset 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 Explicitly require that implementation sets the next layer offset after user defined last parse layer. Next layer offset can be set without checking the layer itself. For example: l4_offset = l3_offset + l3_hdr_len Also renamed packet_parse_param 'layer' to 'last_layer' since it's documenting the usage better: parse.proto = ODP_PROTO_IPV4; parse.last_layer = ODP_PROTO_LAYER_L4; 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/ipsec.h | 13 +++++++++---- include/odp/api/spec/packet.h | 32 +++++++++++++++++--------------- include/odp/api/spec/packet_io.h | 9 +++++++-- platform/linux-generic/odp_packet.c | 2 +- test/validation/api/packet/packet.c | 10 +++++----- 5 files changed, 39 insertions(+), 27 deletions(-) diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h index d57815ed2..8a52c9ff6 100644 --- a/include/odp/api/spec/ipsec.h +++ b/include/odp/api/spec/ipsec.h @@ -148,10 +148,15 @@ typedef struct odp_ipsec_inbound_config_t { /** Parse packet headers after IPSEC transformation * * Select header parsing level after inbound processing. Headers of the - * resulting packet must be parsed (at least) up to this level. Parsing - * starts from IP (layer 3). Each successfully transformed packet has - * a valid value for L3 offset regardless of the parse configuration. - * Default value is ODP_IPSEC_LAYER_NONE. + * resulting packet must be checked (at least) up to this level. + * Parsing starts from IP (layer 3). Packet metadata from IP to this + * layer is set. In addition, offset (and pointer) to the next layer + * is set. Other layer/protocol specific metadata have undefined + * values. + * + * Each successfully transformed packet has a valid value for L3 offset + * regardless of the parse configuration. Default value is + * ODP_IPSEC_LAYER_NONE. ODP_IPSEC_LAYER_L2 is not a valid value. */ odp_ipsec_proto_layer_t parse; diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 149ba4970..134a5f01c 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1188,7 +1188,7 @@ typedef struct odp_packet_parse_param_t { /** Continue parsing until this layer. Must be the same or higher * layer than the layer of 'proto'. */ - odp_proto_layer_t layer; + odp_proto_layer_t last_layer; /** Flags to control payload data checks up to the selected parse * layer. Checksum checking status can be queried for each packet with @@ -1220,19 +1220,21 @@ typedef struct odp_packet_parse_param_t { /** * Parse packet * - * Parse protocol headers in packet data. Parsing starts at 'offset', which - * is the first header byte of protocol 'param.proto'. Parameter 'param.layer' - * defines the last layer application is interested about. - * Use ODP_PROTO_LAYER_ALL for all layers. A successful operation sets or resets - * packet metadata for all layers from the layer of 'param.proto' to the - * application defined last layer. Metadata of other layers have undefined - * values. When operation fails, metadata of all protocol layers have undefined - * values. + * Parse protocol headers in packet data and update layer/protocol specific + * metadata (e.g. offsets, errors, protocols, checksum statuses, etc). Parsing + * starts at 'offset', which is the first header byte of protocol 'param.proto'. + * Parameter 'param.last_layer' defines the last layer application requests + * to check. Use ODP_PROTO_LAYER_ALL for all layers. A successful operation + * sets (or resets) packet metadata for all layers from the layer of + * 'param.proto' to the application defined last layer. In addition, offset + * (and pointer) to the next layer is set. Other layer/protocol specific + * metadata have undefined values. When operation fails, all layer/protocol + * specific metadata have undefined values. * * @param pkt Packet handle * @param offset Byte offset into the packet - * @param param Parse parameters. Proto and layer fields must be set. Clear - * all check bits that are not used. + * @param param Parse parameters. Proto and last_layer fields must be set. + * Clear all check bits that are not used. * * @retval 0 on success * @retval <0 on failure @@ -1244,14 +1246,14 @@ int odp_packet_parse(odp_packet_t pkt, uint32_t offset, * Parse multiple packets * * Otherwise like odp_packet_parse(), but parses multiple packets. Packets may - * have unique offsets, but must start with the same protocol. Also, packets are - * parsed up to the same protocol layer. + * have unique offsets, but must start with the same protocol. The same + * parse parameters are applied to all packets. * * @param pkt Packet handle array * @param offset Byte offsets into the packets * @param num Number of packets and offsets - * @param param Parse parameters. Proto and layer fields must be set. Clear - * all check bits that are not used. + * @param param Parse parameters. Proto and last_layer fields must be set. + * Clear all check bits that are not used. * * @return Number of packets parsed successfully (0 ... num) * @retval <0 on failure diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h index 60d13043d..9f7305c2c 100644 --- a/include/odp/api/spec/packet_io.h +++ b/include/odp/api/spec/packet_io.h @@ -404,8 +404,13 @@ typedef enum odp_pktio_parser_layer_t { typedef struct odp_pktio_parser_config_t { /** Protocol parsing level in packet input * - * Parse protocol layers in minimum up to this level during packet - * input. The default value is ODP_PKTIO_PARSER_LAYER_ALL. */ + * Application requires that protocol headers in a packet are checked + * up to this layer during packet input. Use ODP_PROTO_LAYER_ALL for + * all layers. Packet metadata for this and all preceding layers are + * set. In addition, offset (and pointer) to the next layer is set. + * Other layer/protocol specific metadata have undefined values. + * + * The default value is ODP_PKTIO_PARSER_LAYER_ALL. */ odp_pktio_parser_layer_t layer; } odp_pktio_parser_config_t; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index bdcb482fa..55f59178b 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2311,7 +2311,7 @@ int odp_packet_parse(odp_packet_t pkt, uint32_t offset, uint32_t seg_len; uint32_t packet_len = pkt_hdr->frame_len; odp_proto_t proto = param->proto; - odp_proto_layer_t layer = param->layer; + odp_proto_layer_t layer = param->last_layer; int ret; uint16_t ethtype; diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index ce4d66c0b..210ce9059 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -2450,7 +2450,7 @@ void packet_test_parse(void) } parse.proto = ODP_PROTO_ETH; - parse.layer = ODP_PROTO_LAYER_ALL; + parse.last_layer = ODP_PROTO_LAYER_ALL; parse.all_check = 0; CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); @@ -2481,7 +2481,7 @@ void packet_test_parse(void) } parse.proto = ODP_PROTO_IPV4; - parse.layer = ODP_PROTO_LAYER_L4; + parse.last_layer = ODP_PROTO_LAYER_L4; parse.all_check = 0; CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); @@ -2511,7 +2511,7 @@ void packet_test_parse(void) } parse.proto = ODP_PROTO_ETH; - parse.layer = ODP_PROTO_LAYER_L4; + parse.last_layer = ODP_PROTO_LAYER_L4; parse.all_check = 0; CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); @@ -2541,7 +2541,7 @@ void packet_test_parse(void) } parse.proto = ODP_PROTO_ETH; - parse.layer = ODP_PROTO_LAYER_L4; + parse.last_layer = ODP_PROTO_LAYER_L4; parse.all_check = 0; CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); @@ -2572,7 +2572,7 @@ void packet_test_parse(void) } parse.proto = ODP_PROTO_ETH; - parse.layer = ODP_PROTO_LAYER_ALL; + parse.last_layer = ODP_PROTO_LAYER_ALL; parse.all_check = 0; CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0);