From patchwork Mon Dec 11 12:00:07 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: 121378 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2702036qgn; Mon, 11 Dec 2017 04:04:39 -0800 (PST) X-Google-Smtp-Source: ACJfBosqz2HnAb9lvcgylr4g07xGvLTB1P739xEPm7XHElHUthlApNFJGrv4fz6EPz8hJf9c/Yzd X-Received: by 10.55.82.84 with SMTP id g81mr173610qkb.263.1512993878936; Mon, 11 Dec 2017 04:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512993878; cv=none; d=google.com; s=arc-20160816; b=sa/jmpwIRDPowpbeU8/7PO8jIst39O5hPa/TalpLAET/8nFKSdJUBEiAM+PfLdnAws yVMAoxGTeiPjtFzEYMimXl8If4U2h4OiuOWpOKBz9+3TazLd4fHLeyuAOeTOI1zTzDFh qDXO+RbL1Q2gPQKMwAjnM4GgjohoNGNDPHHmgHuk1kjhJ2j6ZujNHsuaZG85AjZXkaYv 09zsrjJtrEoViLarmFFXOdqy9jktOzCezCYbN3NBgRdhr8uDUzj5N0bOkQtqUqIg61SO lFKIHxoMPRFc8QF5bx8vW4sJE756M6bciPhSu4zYbnmM+xh308cxMB469I6yJiK718A7 exIQ== 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=9P+pyddPfIqRByxqAjvPUolXP9FqGin6EwKdEBEbCtw=; b=lb6Yso/8z/56qmkVapcm++7zqQOYXHoI4+rdBjewzTajgiU6rzyhZ88Nezw5/8DoTj hOeQSrCkTfi26fawL5scu12YMHfP6OpTaiB3aGf5Ca3a6tRYMfQpCFyk6qO98whiFUfM zNsElQ0YC8g+pJKB6BNWB4smg2dMQZ+g5R6JYK5Yp2e7hppmyJjrlSpSUiwWPS6Z11D9 Zeci7k7EYa8HrxviU4AchRQnjMlQ/zr9AmYADau6vmH2fiHxQB8HRk2wuesKJiY/XeLV zQJWqGL6G7859/kmOwz0eRjxZ0f4br8O3B6/+Jg26ZeqVJsrzomif8l/5W/xyG2Cvzmm UtLg== 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 g4si9210233qkb.226.2017.12.11.04.04.38; Mon, 11 Dec 2017 04:04:38 -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 A25C1608FC; Mon, 11 Dec 2017 12:04:38 +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 B356E608FF; Mon, 11 Dec 2017 12:02:04 +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 7BF61608F2; Mon, 11 Dec 2017 12:01:43 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 67B8560927 for ; Mon, 11 Dec 2017 12:00:14 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 62FD32D829F1 for ; Mon, 11 Dec 2017 15:00:13 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 412MRA0mmb-0DfOtUNB; Mon, 11 Dec 2017 15:00:13 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 05zxW8uoau-0CkeutXB; Mon, 11 Dec 2017 15:00:12 +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:07 +0300 Message-Id: <1512993608-19038-5-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 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: 821e53e2ab0847f73ddb171a65e3e4fc5d28e64f **/ 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 d444c317a..ec8dca673 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);