From patchwork Mon Aug 20 10:00:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144556 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3765553ljj; Mon, 20 Aug 2018 03:00:38 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb1Q+JDUNXLq5/LBduFtU/yZowQrU50g9szGcEcTeMiYCkYXLTC2fvcvt/vWAlkP+Nqhpje X-Received: by 2002:a0c:9523:: with SMTP id l32-v6mr5476228qvl.219.1534759238445; Mon, 20 Aug 2018 03:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534759238; cv=none; d=google.com; s=arc-20160816; b=se5PjXotqheoEa33VWRajp028FOXj/c9ad+UsMnaWTaMGfySLhWZSrW2xIdZLHQDzE uQ1HWWfdummf642dOhYd0q/anVa4V/CmkL1jq1om5AMoQWuysOHjeeiiXpTD1HVPESyA qz7k8SxHafx1t8z6NzaC9ZvNnTT3crYYRhtn7SguJw9gvquQl+M82qmTzoOJt2+CoI/1 uirxZqwZQDFX5GfuSu+4bdw63iQccf/jMiszGV1Cwi613FbIYe708Dn9dkclybZeDN7Y wOhrzi/6AQ5TaieHBlvDwRv0SMDNUfGF2YkpR/1altM9HKvNEfM990HkvWPOAIQsTvhR VFWA== 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=uz8Z0QHC4P5rsgP+Px+e+a5bYG9FibUK+ILuBHTmWsU=; b=stBmq67A9Nq7EpmsRkiPvTwUOoE3TSsYDez9zUwnWjS05L1kNgweMzZ1Ux1OSm5ZXq CUCvU8/Pi01Di2KGUDm1vv7vo52LJzvDF0eWYXcwgJnul3bADLWZQ8TFs7OKQBjBlrfg FJWrplg4vsMZ8rCCrXGHILgK9x9KCoQeeKXCdjHxK/+PsPnMZYU9BvQZb9oDns1Mlbnw MSnMtGhTLD6EGnHz8rv1PbPCmxIAOo8r8u41u4NkrrqVBRICbg088MiAde5Q+4F7KAYP gNz3odvakliRWRWMI3mh9YfwHCRiqTDdRWhVTx93cO7P3ID70Zyadq+sv5KA4erMNfkh hoyQ== 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 l31-v6si1566549qva.232.2018.08.20.03.00.38; Mon, 20 Aug 2018 03:00:38 -0700 (PDT) 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 C7F486862D; Mon, 20 Aug 2018 10:00:37 +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=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW 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 F02D16095C; Mon, 20 Aug 2018 10:00:27 +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 F3FDC61706; Mon, 20 Aug 2018 10:00:19 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 5861A6095C for ; Mon, 20 Aug 2018 10:00:18 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward105o.mail.yandex.net (Yandex) with ESMTP id C97B34444EF9 for ; Mon, 20 Aug 2018 13:00:16 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FOs9yRWDjI-0GfO7ORp; Mon, 20 Aug 2018 13:00:16 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id mI7U2yzlYn-0FP8rqhP; Mon, 20 Aug 2018 13:00:16 +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, 20 Aug 2018 10:00:05 +0000 Message-Id: <1534759208-15203-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> References: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 672 Subject: [lng-odp] [PATCH API-NEXT v3 1/4] api: packet: add parse result call 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 This enables application to read all commonly used packet parser results with a single function call. This may improve performance when multiple results are needed, especially in ABI compatible builds where function inlining is likely disabled. Signed-off-by: Petri Savolainen --- /** Email created from pull request 672 (psavol:next-packet-metadata) ** https://github.com/Linaro/odp/pull/672 ** Patch: https://github.com/Linaro/odp/pull/672.patch ** Base sha: 2722279b31b075586551801eb2860687ff966ea8 ** Merge commit sha: e76448d8a8f2575ab3a4c445be84d19f055cbf2d **/ include/odp/api/abi-default/packet.h | 64 +++++++++++++++++++ include/odp/api/spec/packet.h | 56 ++++++++++++++++ .../include-abi/odp/api/abi/packet.h | 35 ++++++++++ 3 files changed, 155 insertions(+) diff --git a/include/odp/api/abi-default/packet.h b/include/odp/api/abi-default/packet.h index 97c0d0883..d3bd5f6e4 100644 --- a/include/odp/api/abi-default/packet.h +++ b/include/odp/api/abi-default/packet.h @@ -72,6 +72,70 @@ typedef enum { #define ODP_NUM_PACKET_COLORS 3 +/** Parse result flags */ +typedef struct odp_packet_parse_result_flag_t { + /** Flags union */ + union { + /** All flags as a 64 bit word */ + uint64_t all; + + /** Flags as a bitfield struct */ + struct { + /** @see odp_packet_has_error() */ + uint64_t has_error : 1; + /** @see odp_packet_has_l2_error() */ + uint64_t has_l2_error : 1; + /** @see odp_packet_has_l3_error() */ + uint64_t has_l3_error : 1; + /** @see odp_packet_has_l4_error() */ + uint64_t has_l4_error : 1; + /** @see odp_packet_has_l2() */ + uint64_t has_l2 : 1; + /** @see odp_packet_has_l3() */ + uint64_t has_l3 : 1; + /** @see odp_packet_has_l4() */ + uint64_t has_l4 : 1; + /** @see odp_packet_has_eth() */ + uint64_t has_eth : 1; + /** @see odp_packet_has_eth_bcast() */ + uint64_t has_eth_bcast : 1; + /** @see odp_packet_has_eth_mcast() */ + uint64_t has_eth_mcast : 1; + /** @see odp_packet_has_jumbo() */ + uint64_t has_jumbo : 1; + /** @see odp_packet_has_vlan() */ + uint64_t has_vlan : 1; + /** @see odp_packet_has_vlan_qinq() */ + uint64_t has_vlan_qinq : 1; + /** @see odp_packet_has_arp() */ + uint64_t has_arp : 1; + /** @see odp_packet_has_ipv4() */ + uint64_t has_ipv4 : 1; + /** @see odp_packet_has_ipv6() */ + uint64_t has_ipv6 : 1; + /** @see odp_packet_has_ip_bcast() */ + uint64_t has_ip_bcast : 1; + /** @see odp_packet_has_ip_mcast() */ + uint64_t has_ip_mcast : 1; + /** @see odp_packet_has_ipfrag() */ + uint64_t has_ipfrag : 1; + /** @see odp_packet_has_ipopt() */ + uint64_t has_ipopt : 1; + /** @see odp_packet_has_ipsec() */ + uint64_t has_ipsec : 1; + /** @see odp_packet_has_udp() */ + uint64_t has_udp : 1; + /** @see odp_packet_has_tcp() */ + uint64_t has_tcp : 1; + /** @see odp_packet_has_sctp() */ + uint64_t has_sctp : 1; + /** @see odp_packet_has_icmp() */ + uint64_t has_icmp : 1; + }; + }; + +} odp_packet_parse_result_flag_t; + /** * @} */ diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 78e519ac3..3fd571a38 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1428,6 +1428,62 @@ int odp_packet_parse(odp_packet_t pkt, uint32_t offset, int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[], int num, const odp_packet_parse_param_t *param); +/** Packet parse results */ +typedef struct odp_packet_parse_result_t { + /** Parse result flags */ + odp_packet_parse_result_flag_t flag; + + /** @see odp_packet_len() */ + uint32_t packet_len; + + /** @see odp_packet_l2_offset() */ + uint32_t l2_offset; + /** @see odp_packet_l3_offset() */ + uint32_t l3_offset; + /** @see odp_packet_l4_offset() */ + uint32_t l4_offset; + + /** @see odp_packet_l3_chksum_status() */ + odp_packet_chksum_status_t l3_chksum_status; + /** @see odp_packet_l4_chksum_status() */ + odp_packet_chksum_status_t l4_chksum_status; + + /** @see odp_packet_l2_type() */ + odp_proto_l2_type_t l2_type; + /** @see odp_packet_l3_type() */ + odp_proto_l3_type_t l3_type; + /** @see odp_packet_l4_type() */ + odp_proto_l4_type_t l4_type; + +} odp_packet_parse_result_t; + +/** + * Read parse results + * + * Read out the most commonly used packet parse results. The same information is + * available through individual function calls, but this call may be more + * efficient when reading multiple results from a packet. + * + * @param pkt Packet handle + * @param[out] result Pointer for parse result output + */ +void odp_packet_parse_result(odp_packet_t pkt, + odp_packet_parse_result_t *result); + +/** + * Read parse results from multiple packets + * + * Otherwise same functionality as odp_packet_parse_result() but handles + * multiple packets. + * + * @param pkt Packet handle array + * @param[out] result Parse result array for output + * @param num Number of packets and results + */ +void odp_packet_parse_result_multi(const odp_packet_t pkt[], + odp_packet_parse_result_t *result[], + int num); + /** * Packet pool * diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet.h b/platform/linux-generic/include-abi/odp/api/abi/packet.h index fe21c7d9f..e11aed978 100644 --- a/platform/linux-generic/include-abi/odp/api/abi/packet.h +++ b/platform/linux-generic/include-abi/odp/api/abi/packet.h @@ -89,6 +89,41 @@ typedef enum { #define ODP_NUM_PACKET_COLORS 3 +typedef struct odp_packet_parse_result_flag_t { + union { + uint64_t all; + + struct { + uint64_t has_error : 1; + uint64_t has_l2_error : 1; + uint64_t has_l3_error : 1; + uint64_t has_l4_error : 1; + uint64_t has_l2 : 1; + uint64_t has_l3 : 1; + uint64_t has_l4 : 1; + uint64_t has_eth : 1; + uint64_t has_eth_bcast : 1; + uint64_t has_eth_mcast : 1; + uint64_t has_jumbo : 1; + uint64_t has_vlan : 1; + uint64_t has_vlan_qinq : 1; + uint64_t has_arp : 1; + uint64_t has_ipv4 : 1; + uint64_t has_ipv6 : 1; + uint64_t has_ip_bcast : 1; + uint64_t has_ip_mcast : 1; + uint64_t has_ipfrag : 1; + uint64_t has_ipopt : 1; + uint64_t has_ipsec : 1; + uint64_t has_udp : 1; + uint64_t has_tcp : 1; + uint64_t has_sctp : 1; + uint64_t has_icmp : 1; + }; + }; + +} odp_packet_parse_result_flag_t; + #include /** From patchwork Mon Aug 20 10:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144559 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3770254ljj; Mon, 20 Aug 2018 03:04:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZzuu8ffHqZul2qzdG14T9E/LpITtF6Qnmwi8xZqgySkQRjIbMoaBl8WSYTab0fP9i5xbPN X-Received: by 2002:ac8:2d2e:: with SMTP id n43-v6mr3753592qta.38.1534759445409; Mon, 20 Aug 2018 03:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534759445; cv=none; d=google.com; s=arc-20160816; b=jXljus2bMB+rHNbxmy0zys74RaKQ0KNghZC3ybzEIzImuFEGUjIII2T6TzEB/IQDx+ qOlKJL0Nlri1kY3085Wwve4aT6Kr+fz16i9TVWXsjA2+daG2SRrYIWP0eZ+dtpekPX6l ZFtn3xeav07zh8VnmJGPu4dlDfSI9b9PFk6J8rkDB3xLFz1rS1bJZYx+m4fIzMDToE3m iN0CvK/InuR35SqkH7ckUaSYxf50OQkVjZi2kaUv+/mDo4xvpsTY2FfDMUhs4JVv7GPq 1Hr0+Jf/ChP9PLZGOd5QHmPPhiJq1FEMqN1wYhgzAJCBxmKWd5j253sMOxHXBgzJ01cj hPpw== 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=Kk3M+EOIH2X8P1a2bP8RDeR4ENvm0LTA64XYd73thGo=; b=LMdnEd4xeONAJ9Ka6GSI7tNmIxDJxAzmcnLt5jP/FDWwslp0rGz8oS7jkDoQ7Afv4/ iN9kNEXPhXV9Lz9oS2FIoKGAvmar+wRmE4WElulLVBgJR9so7GBmv2M+rPAgj0jjd58R XAnRbB5cX9glICG7LOcP1O52bm+814Lt79lClfxvSjsh11vaBr8+wNtmtuS+r+octoZ1 /REvnCK4ivnkcfGzMZc8dT49Rd7ijl4r0ZBaHa2z3qAg0n+JEkGw0YeJBLz1vDBfLdLp EP2rFrPV2wjvlSdBWNG4yfDQR0Ml5+J7kCkuMGOmA6YT5kLGEBgAS+9J/v3KQ6XfhTjd rusA== 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 l37-v6si2492006qtl.321.2018.08.20.03.04.05; Mon, 20 Aug 2018 03:04:05 -0700 (PDT) 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 0A0626863A; Mon, 20 Aug 2018 10:04:05 +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=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW 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 755D7685E1; Mon, 20 Aug 2018 10:01:22 +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 0F59568643; Mon, 20 Aug 2018 10:01:15 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 6540A685E1 for ; Mon, 20 Aug 2018 10:00:28 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward100p.mail.yandex.net (Yandex) with ESMTP id BA6D75101C91 for ; Mon, 20 Aug 2018 13:00:17 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id X5TOkwKkSS-0HOaFD9e; Mon, 20 Aug 2018 13:00:17 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id mI7U2yzlYn-0GPuq2ZG; Mon, 20 Aug 2018 13:00:16 +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, 20 Aug 2018 10:00:06 +0000 Message-Id: <1534759208-15203-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> References: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 672 Subject: [lng-odp] [PATCH API-NEXT v3 2/4] linux-gen: packet: implement packet result calls 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 Simple implementation of the new packet result calls. Especially, flag copy needs to be optimized by storing flag bits directly into API defined format (packet_parse_result_flag_t) in the packet header. Signed-off-by: Petri Savolainen --- /** Email created from pull request 672 (psavol:next-packet-metadata) ** https://github.com/Linaro/odp/pull/672 ** Patch: https://github.com/Linaro/odp/pull/672.patch ** Base sha: 2722279b31b075586551801eb2860687ff966ea8 ** Merge commit sha: e76448d8a8f2575ab3a4c445be84d19f055cbf2d **/ platform/linux-generic/odp_packet.c | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 7bb93e1e1..0df32d1c8 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2732,6 +2732,59 @@ int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[], return num; } +void odp_packet_parse_result(odp_packet_t pkt, + odp_packet_parse_result_t *result) +{ + /* TODO: optimize to single word copy when packet header stores bits + * directly into odp_packet_parse_result_flag_t */ + result->flag.all = 0; + result->flag.has_error = odp_packet_has_error(pkt); + result->flag.has_l2_error = odp_packet_has_l2_error(pkt); + result->flag.has_l3_error = odp_packet_has_l3_error(pkt); + result->flag.has_l4_error = odp_packet_has_l4_error(pkt); + result->flag.has_l2 = odp_packet_has_l2(pkt); + result->flag.has_l3 = odp_packet_has_l3(pkt); + result->flag.has_l4 = odp_packet_has_l4(pkt); + result->flag.has_eth = odp_packet_has_eth(pkt); + result->flag.has_eth_bcast = odp_packet_has_eth_bcast(pkt); + result->flag.has_eth_mcast = odp_packet_has_eth_mcast(pkt); + result->flag.has_jumbo = odp_packet_has_jumbo(pkt); + result->flag.has_vlan = odp_packet_has_vlan(pkt); + result->flag.has_vlan_qinq = odp_packet_has_vlan_qinq(pkt); + result->flag.has_arp = odp_packet_has_arp(pkt); + result->flag.has_ipv4 = odp_packet_has_ipv4(pkt); + result->flag.has_ipv6 = odp_packet_has_ipv6(pkt); + result->flag.has_ip_bcast = odp_packet_has_ip_bcast(pkt); + result->flag.has_ip_mcast = odp_packet_has_ip_mcast(pkt); + result->flag.has_ipfrag = odp_packet_has_ipfrag(pkt); + result->flag.has_ipopt = odp_packet_has_ipopt(pkt); + result->flag.has_ipsec = odp_packet_has_ipsec(pkt); + result->flag.has_udp = odp_packet_has_udp(pkt); + result->flag.has_tcp = odp_packet_has_tcp(pkt); + result->flag.has_sctp = odp_packet_has_sctp(pkt); + result->flag.has_icmp = odp_packet_has_icmp(pkt); + + result->packet_len = odp_packet_len(pkt); + result->l2_offset = odp_packet_l2_offset(pkt); + result->l3_offset = odp_packet_l3_offset(pkt); + result->l4_offset = odp_packet_l4_offset(pkt); + result->l3_chksum_status = odp_packet_l3_chksum_status(pkt); + result->l4_chksum_status = odp_packet_l4_chksum_status(pkt); + result->l2_type = odp_packet_l2_type(pkt); + result->l3_type = odp_packet_l3_type(pkt); + result->l4_type = odp_packet_l4_type(pkt); +} + +void odp_packet_parse_result_multi(const odp_packet_t pkt[], + odp_packet_parse_result_t *result[], + int num) +{ + int i; + + for (i = 0; i < num; i++) + odp_packet_parse_result(pkt[i], result[i]); +} + uint64_t odp_packet_to_u64(odp_packet_t hdl) { return _odp_pri(hdl); From patchwork Mon Aug 20 10:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144557 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3766605ljj; Mon, 20 Aug 2018 03:01:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz3kZkMzGYkPaZwTR4JBeq4mnU4Jy6/3s1avdhY2SXDqK0KBgGf2aa/nhhUapGa6GrzT4zu X-Received: by 2002:a0c:f7d2:: with SMTP id f18-v6mr40180221qvo.175.1534759288650; Mon, 20 Aug 2018 03:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534759288; cv=none; d=google.com; s=arc-20160816; b=bBPWz8fcP0fnjbl9N5pSMHCNBgvRC21kAExY6Z9gSZe/V7Nvs/aqQix0My0s8WqMx3 Yup4EdNCtEiEozAG8UQnxqSIaLTWiFEVA2rOoAFISLhFyKe0JEEGtzE8UHWJHz0fsOjP 6KT5X1Dx/wJ31aHbel5nbNSvTFh88kYc9zKV5tYg2To7KoclXthKZN7dt2Cmma/c5atE sNaC3y2rjMrfL9T+onioU7tgKlAubQIoCJ4/OJnk746Qk9apvGK0iCJTeCSSZ+eocMfk 9KvRys5i1AETJlpyimQCGfuoOfLMDam+4b3cOvbtGLFFErlez03QUqhdC8cvtjOfMYxR Nvgg== 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=bopDw/y524t9mb4/oyY3kKP4hdQ1Vx0f9960mKnUbrU=; b=fUd+S8FgyQj1/sav6UD3o5znkuRU11vNWGyhS/IhPb6kOZHztYWAdAVDPuoM+WKOSs U4qlnVMih3jKR6OxZEZpQY/x7NZTRnA2UCZwXbW8UdITxaokPjEalR2STut3CXEkCqD7 MEy8wcNjtaiy1V1so8ZTX1FX0iAH2DEE6cECxIGZOI4/ebRzjnXDRa2wBdnSc7Wk1GSC Exh/RHyCAquD/jnCrrueE9VqJ31DUrTg1W6YkuSomlDmrmJio9LtB78q7Xp5wlQJE4eN F3z5Wat3o3kXlmldY5+OcGZ6I5NzX578FVzBeDlKv8Eo2q6OgDGeaUSa4hQsWTyVmDdv IIDw== 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 h6-v6si697015qke.235.2018.08.20.03.01.28; Mon, 20 Aug 2018 03:01:28 -0700 (PDT) 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 4DB5A685F8; Mon, 20 Aug 2018 10:01:28 +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=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW 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 48FDF685FE; Mon, 20 Aug 2018 10:00:34 +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 69A54685E0; Mon, 20 Aug 2018 10:00:27 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id CC8D16095C for ; Mon, 20 Aug 2018 10:00:20 +0000 (UTC) Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward103p.mail.yandex.net (Yandex) with ESMTP id A53002183B02 for ; Mon, 20 Aug 2018 13:00:18 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id wtwBp2cqXN-0IjicQkr; Mon, 20 Aug 2018 13:00:18 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id mI7U2yzlYn-0HPGS4xZ; Mon, 20 Aug 2018 13:00:17 +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, 20 Aug 2018 10:00:07 +0000 Message-Id: <1534759208-15203-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> References: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 672 Subject: [lng-odp] [PATCH API-NEXT v3 3/4] validation: packet: add num_pkt parameter to parse_test_alloc 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 It's more robust to use a parameter instead of assuming that a fixed number of packets are allocated. Signed-off-by: Petri Savolainen --- /** Email created from pull request 672 (psavol:next-packet-metadata) ** https://github.com/Linaro/odp/pull/672 ** Patch: https://github.com/Linaro/odp/pull/672.patch ** Base sha: 2722279b31b075586551801eb2860687ff966ea8 ** Merge commit sha: e76448d8a8f2575ab3a4c445be84d19f055cbf2d **/ test/validation/api/packet/packet.c | 47 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index fa7ce8b82..280e5c829 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -2561,10 +2561,9 @@ static int packet_parse_suite_term(void) } static void parse_test_alloc(odp_packet_t pkt[], const uint8_t test_packet[], - uint32_t len) + uint32_t len, int num_pkt) { int ret, i; - int num_pkt = PARSE_TEST_NUM_PKT; ret = odp_packet_alloc_multi(parse_test.pool, len, pkt, num_pkt); CU_ASSERT_FATAL(ret == num_pkt); @@ -2585,7 +2584,7 @@ static void parse_eth_ipv4_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_udp, - sizeof(test_packet_ipv4_udp)); + sizeof(test_packet_ipv4_udp), num_pkt); for (i = 0; i < num_pkt; i++) { chksum_status = odp_packet_l3_chksum_status(pkt[i]); @@ -2629,7 +2628,7 @@ static void parse_ipv4_udp(void) uint32_t offset[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_udp, - sizeof(test_packet_ipv4_udp)); + sizeof(test_packet_ipv4_udp), num_pkt); for (i = 0; i < num_pkt; i++) offset[i] = 14; @@ -2665,7 +2664,7 @@ static void parse_eth_ipv4_tcp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_tcp, - sizeof(test_packet_ipv4_tcp)); + sizeof(test_packet_ipv4_tcp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2701,7 +2700,7 @@ static void parse_eth_ipv6_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv6_udp, - sizeof(test_packet_ipv6_udp)); + sizeof(test_packet_ipv6_udp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2731,7 +2730,7 @@ static void parse_eth_ipv6_tcp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv6_tcp, - sizeof(test_packet_ipv6_tcp)); + sizeof(test_packet_ipv6_tcp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_ALL; @@ -2761,7 +2760,7 @@ static void parse_eth_vlan_ipv4_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_vlan_ipv4_udp, - sizeof(test_packet_vlan_ipv4_udp)); + sizeof(test_packet_vlan_ipv4_udp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2792,7 +2791,7 @@ static void parse_eth_vlan_ipv6_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_vlan_ipv6_udp, - sizeof(test_packet_vlan_ipv6_udp)); + sizeof(test_packet_vlan_ipv6_udp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2829,7 +2828,7 @@ static void parse_eth_vlan_qinq_ipv4_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_vlan_qinq_ipv4_udp, - sizeof(test_packet_vlan_qinq_ipv4_udp)); + sizeof(test_packet_vlan_qinq_ipv4_udp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2861,7 +2860,7 @@ static void parse_eth_arp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_arp, - sizeof(test_packet_arp)); + sizeof(test_packet_arp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2893,7 +2892,7 @@ static void parse_eth_ipv4_icmp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_icmp, - sizeof(test_packet_ipv4_icmp)); + sizeof(test_packet_ipv4_icmp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2924,7 +2923,7 @@ static void parse_eth_ipv6_icmp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv6_icmp, - sizeof(test_packet_ipv6_icmp)); + sizeof(test_packet_ipv6_icmp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2955,7 +2954,7 @@ static void parse_eth_ipv4_sctp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_sctp, - sizeof(test_packet_ipv4_sctp)); + sizeof(test_packet_ipv4_sctp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2986,7 +2985,7 @@ static void parse_eth_ipv4_ipsec_ah(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_ipsec_ah, - sizeof(test_packet_ipv4_ipsec_ah)); + sizeof(test_packet_ipv4_ipsec_ah), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3017,7 +3016,7 @@ static void parse_eth_ipv4_ipsec_esp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_ipsec_esp, - sizeof(test_packet_ipv4_ipsec_esp)); + sizeof(test_packet_ipv4_ipsec_esp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3048,7 +3047,7 @@ static void parse_eth_ipv6_ipsec_ah(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv6_ipsec_ah, - sizeof(test_packet_ipv6_ipsec_ah)); + sizeof(test_packet_ipv6_ipsec_ah), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3085,7 +3084,7 @@ static void parse_eth_ipv6_ipsec_esp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv6_ipsec_esp, - sizeof(test_packet_ipv6_ipsec_esp)); + sizeof(test_packet_ipv6_ipsec_esp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3116,7 +3115,7 @@ static void parse_mcast_eth_ipv4_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_mcast_eth_ipv4_udp, - sizeof(test_packet_mcast_eth_ipv4_udp)); + sizeof(test_packet_mcast_eth_ipv4_udp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3150,7 +3149,7 @@ static void parse_bcast_eth_ipv4_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_bcast_eth_ipv4_udp, - sizeof(test_packet_bcast_eth_ipv4_udp)); + sizeof(test_packet_bcast_eth_ipv4_udp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3185,7 +3184,7 @@ static void parse_mcast_eth_ipv6_udp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_mcast_eth_ipv6_udp, - sizeof(test_packet_mcast_eth_ipv6_udp)); + sizeof(test_packet_mcast_eth_ipv6_udp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3219,7 +3218,7 @@ static void parse_eth_ipv4_udp_first_frag(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_udp_first_frag, - sizeof(test_packet_ipv4_udp_first_frag)); + sizeof(test_packet_ipv4_udp_first_frag), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3251,7 +3250,7 @@ static void parse_eth_ipv4_udp_last_frag(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_udp_last_frag, - sizeof(test_packet_ipv4_udp_last_frag)); + sizeof(test_packet_ipv4_udp_last_frag), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -3283,7 +3282,7 @@ static void parse_eth_ipv4_rr_nop_icmp(void) odp_packet_t pkt[num_pkt]; parse_test_alloc(pkt, test_packet_ipv4_rr_nop_icmp, - sizeof(test_packet_ipv4_rr_nop_icmp)); + sizeof(test_packet_ipv4_rr_nop_icmp), num_pkt); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; From patchwork Mon Aug 20 10:00:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144558 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3768051ljj; Mon, 20 Aug 2018 03:02:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw9qLdqDoXukkFtoJm0Ur8HawpO2pL1Hg1/PQduykNl+pEbwyfrObwT2Wk28D9W8OgSt9VL X-Received: by 2002:a37:93c6:: with SMTP id v189-v6mr40529459qkd.140.1534759352233; Mon, 20 Aug 2018 03:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534759352; cv=none; d=google.com; s=arc-20160816; b=W3PUh36m7Mixdl1Nkjwhy3+xvK0zrRxc29/0fnZRkuvHbMXDGXs47xjyxAAMZElrHz nA4p9JCpVOU3KhpDhW5rA4nptPlE41W544TMcq94Hp9bWEUHJ5591xBqZYiCyJ+b0gK1 gFVJQa7rTDJs0CG0/eTpYxXj/AHmxWEAfDb2MPorh87xkHyVl+/C2+OudN03sV/gR0Tm u1M1tA9VLPlAy9dTpLAkwFnKTmn/echEkMrb8t1xbGujX8ztcA5PYYfZOGwMHY/FstlT 5yG+7LC2SP7yNC6aLuciaBHeW5/PbkDDSBPBfRvm6CNI8uX8D5hJpnKp4frsc7QB0mB5 aU7g== 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=vAOvbMKf+HydWxoQKKN6+0t5NEMWu0DRIAzlk2Oxn7E=; b=pJViUBrIai9O5wc0szGLeEnXlwPlEZd0s2hk1grKryH1vrRJukL8+9Q/ax/7h+CUNP /Du2z2YDeven6RwTN5jaqNdw1Vhhp09WV6+WR97ek20ORQ17TKvXSq7MJRl+WlD0LZVb dsuv5k0/5H7UJ/ozAvQm7VYa6gCtjObElkFQGmET0o1gq/lWLxmXAVs/301eslvEJzxk LDRjtjGbz2zxiAG8TZKqMwN6NjeWu1aKIGxdzo7WHKdPsK4FqbvfLxefp1qtnArCQYlu 9iYvrelYy258e0AkjsEaAMNLCkJ0pIvXOWdNwfL7tKUkLGPLRCt8EwQjhjjfYcSgA9De KYzg== 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 p25-v6si2196679qtl.303.2018.08.20.03.02.32; Mon, 20 Aug 2018 03:02:32 -0700 (PDT) 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 EFA836863F; Mon, 20 Aug 2018 10:02:31 +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=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW 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 E42186095C; Mon, 20 Aug 2018 10:00:40 +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 250B260AA8; Mon, 20 Aug 2018 10:00:31 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 36F3460AA8 for ; Mon, 20 Aug 2018 10:00:22 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 9A8A65605A9C for ; Mon, 20 Aug 2018 13:00:19 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id rlngf35Vwo-0JdiAC2u; Mon, 20 Aug 2018 13:00:19 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id mI7U2yzlYn-0IPGIOMK; Mon, 20 Aug 2018 13:00:18 +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, 20 Aug 2018 10:00:08 +0000 Message-Id: <1534759208-15203-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> References: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 672 Subject: [lng-odp] [PATCH API-NEXT v3 4/4] validation: packet: add parse result test 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 Test new parse result functions. Signed-off-by: Petri Savolainen --- /** Email created from pull request 672 (psavol:next-packet-metadata) ** https://github.com/Linaro/odp/pull/672 ** Patch: https://github.com/Linaro/odp/pull/672.patch ** Base sha: 2722279b31b075586551801eb2860687ff966ea8 ** Merge commit sha: e76448d8a8f2575ab3a4c445be84d19f055cbf2d **/ test/validation/api/packet/packet.c | 109 ++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 280e5c829..0c86b0510 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -3306,6 +3306,114 @@ static void parse_eth_ipv4_rr_nop_icmp(void) odp_packet_free_multi(pkt, num_pkt); } +static void parse_result(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + odp_packet_parse_result_t result[num_pkt]; + odp_packet_parse_result_t *result_ptr[num_pkt]; + + /* Ethernet/VLAN/IPv6/UDP */ + parse_test_alloc(pkt, test_packet_vlan_ipv6_udp, + sizeof(test_packet_vlan_ipv6_udp), num_pkt); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_ALL; + parse.chksums.all_chksum = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], 0, &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], parse_test.offset_zero, + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + result_ptr[i] = &result[i]; + memset(&result[i], 0, sizeof(odp_packet_parse_result_t)); + } + + odp_packet_parse_result(pkt[0], result_ptr[0]); + odp_packet_parse_result_multi(&pkt[1], &result_ptr[1], num_pkt - 1); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_vlan(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH); + CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV6); + CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_UDP); + + CU_ASSERT(result[i].flag.all != 0); + CU_ASSERT(result[i].flag.has_error == + odp_packet_has_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l2_error == + odp_packet_has_l2_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l3_error == + odp_packet_has_l3_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l4_error == + odp_packet_has_l4_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l2 == + odp_packet_has_l2(pkt[i])); + CU_ASSERT(result[i].flag.has_l3 == + odp_packet_has_l3(pkt[i])); + CU_ASSERT(result[i].flag.has_l4 == + odp_packet_has_l4(pkt[i])); + CU_ASSERT(result[i].flag.has_eth == + odp_packet_has_eth(pkt[i])); + CU_ASSERT(result[i].flag.has_eth_bcast == + odp_packet_has_eth_bcast(pkt[i])); + CU_ASSERT(result[i].flag.has_eth_mcast == + odp_packet_has_eth_mcast(pkt[i])); + CU_ASSERT(result[i].flag.has_jumbo == + odp_packet_has_jumbo(pkt[i])); + CU_ASSERT(result[i].flag.has_vlan == + odp_packet_has_vlan(pkt[i])); + CU_ASSERT(result[i].flag.has_vlan_qinq == + odp_packet_has_vlan_qinq(pkt[i])); + CU_ASSERT(result[i].flag.has_arp == + odp_packet_has_arp(pkt[i])); + CU_ASSERT(result[i].flag.has_ipv4 == + odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(result[i].flag.has_ipv6 == + odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(result[i].flag.has_ip_bcast == + odp_packet_has_ip_bcast(pkt[i])); + CU_ASSERT(result[i].flag.has_ip_mcast == + odp_packet_has_ip_mcast(pkt[i])); + CU_ASSERT(result[i].flag.has_ipfrag == + odp_packet_has_ipfrag(pkt[i])); + CU_ASSERT(result[i].flag.has_ipopt == + odp_packet_has_ipopt(pkt[i])); + CU_ASSERT(result[i].flag.has_ipsec == + odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(result[i].flag.has_udp == + odp_packet_has_udp(pkt[i])); + CU_ASSERT(result[i].flag.has_tcp == + odp_packet_has_tcp(pkt[i])); + CU_ASSERT(result[i].flag.has_sctp == + odp_packet_has_sctp(pkt[i])); + CU_ASSERT(result[i].flag.has_icmp == + odp_packet_has_icmp(pkt[i])); + + CU_ASSERT(result[i].packet_len == odp_packet_len(pkt[i])); + CU_ASSERT(result[i].l2_offset == odp_packet_l2_offset(pkt[i])); + CU_ASSERT(result[i].l3_offset == odp_packet_l3_offset(pkt[i])); + CU_ASSERT(result[i].l4_offset == odp_packet_l4_offset(pkt[i])); + CU_ASSERT(result[i].l3_chksum_status == + odp_packet_l3_chksum_status(pkt[i])); + CU_ASSERT(result[i].l4_chksum_status == + odp_packet_l4_chksum_status(pkt[i])); + CU_ASSERT(result[i].l2_type == odp_packet_l2_type(pkt[i])); + CU_ASSERT(result[i].l3_type == odp_packet_l3_type(pkt[i])); + CU_ASSERT(result[i].l4_type == odp_packet_l4_type(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_alloc_free), ODP_TEST_INFO(packet_test_alloc_free_multi), @@ -3363,6 +3471,7 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_ipv4_udp_first_frag), ODP_TEST_INFO(parse_eth_ipv4_udp_last_frag), ODP_TEST_INFO(parse_eth_ipv4_rr_nop_icmp), + ODP_TEST_INFO(parse_result), ODP_TEST_INFO_NULL, };