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 /**