From patchwork Wed Feb 7 10:59:55 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: 127144 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp353833ljc; Wed, 7 Feb 2018 03:01:27 -0800 (PST) X-Google-Smtp-Source: AH8x224CKnSQdUSKeRk/eCgQtah24x8896HN3R2kuAa6iFBNWEfFvyn2qPsB4OAR+iJS53KQQvQe X-Received: by 10.55.79.68 with SMTP id d65mr8437472qkb.153.1518001287389; Wed, 07 Feb 2018 03:01:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518001287; cv=none; d=google.com; s=arc-20160816; b=e7MQjkhn7Ou9Locd1KNplk2sAufaEGponmexO5jbb+4U+/w6sXD7Jrma96SQ9zjzqC wrhkPpHJQZqlxZtwcIkd/Sjdq8pSvREIN4YwpWg91IOQLdBytWrEKUEKRMxJ75I9KVD6 Ey6ilaZZn5NHzpAOFu15r7RGVk+/3XWUcpb6ogJ6Bdfn7uMGTMf/FRCgXALLFAN4FAb1 mAGwaQNfKfujnuYXWNqH1RXvV9KkLMm5ZGAGzxSYCY5F5AUnfusSLs6Ncqt+rSVqHiCk 3jy4YbQxlsJN/VtfFAL4fxAh/YzSFErro0wsP3whrNGk0scH8dnIXnEhELulthOSVmrX VUcg== 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=b55NfiCkT5s4UwhE3kbuojHeC/oPD48ffKxtbc0Vn+E=; b=OphOVcbZNl/fPkWDQBcsFVjw1B0yLcHJhiQL2FsFEBi2zc4SwpxQfJOBPoNnq9yHgb nQ1uckc+YGtK6MFds99zg3wZWvwNH5GyxT6QA2J+8NqGWgYbzcwx73pCVI5ybgg3Uko1 X2ylZOOIVbQcjMW21nBCYzVTm4hjSggJ4K8UEFxqJomaEibu5sXOgP8IoBS+2WNG3CLv PD2hRw0p7bL5YpFRKnT7RGWcbfdby6me7teI0BYSJ3Wwblyvk/01IcAuHRFQTUsejarW lpFs/ngEbA04tP8mWADr3YJP7YWBikRTCioYeXKy1qm5n1M3lhm99Lih3oFQIavoO3sJ T9pg== 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 d13si827296qta.452.2018.02.07.03.01.27; Wed, 07 Feb 2018 03:01: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 04303617AF; Wed, 7 Feb 2018 11:01:27 +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_H2 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 979E5616FC; Wed, 7 Feb 2018 11:00:45 +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 A192561555; Wed, 7 Feb 2018 11:00:32 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id 9584B607D5 for ; Wed, 7 Feb 2018 11:00:26 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 805CA4499D for ; Wed, 7 Feb 2018 14:00:22 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id mpUaYFWw7k-0Mn8e9Hs; Wed, 07 Feb 2018 14:00:22 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id LVw23zZMqp-0FVWvxeP; Wed, 07 Feb 2018 14:00:15 +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: Wed, 7 Feb 2018 13:59:55 +0300 Message-Id: <1518001208-29529-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518001208-29529-1-git-send-email-odpbot@yandex.ru> References: <1518001208-29529-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 457 Subject: [lng-odp] [PATCH API-NEXT v1 1/14] linux-gen: packet: implement packet l3/l4 proto types 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: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 457 (lumag:packet-types) ** https://github.com/Linaro/odp/pull/457 ** Patch: https://github.com/Linaro/odp/pull/457.patch ** Base sha: e1175d5a69c65bb465022c9f1381c40fdb5c4069 ** Merge commit sha: 802ddfc5ea6f47a8935993bf6f8c1675a4c94930 **/ .../include/odp/api/plat/packet_inline_types.h | 3 +++ platform/linux-generic/odp_packet.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h index e8ebdabb1..a190b45af 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h @@ -98,6 +98,9 @@ typedef union { uint64_t l3_chksum_done:1; /* L3 checksum validation done */ uint64_t l4_chksum_done:1; /* L4 checksum validation done */ uint64_t ipsec_udp:1; /* UDP-encapsulated IPsec packet */ + + uint64_t l3_type : 8; /* L3 packet type */ + uint64_t l4_type : 8; /* L4 packet type */ }; } _odp_packet_input_flags_t; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index dc16e9be4..f5151d293 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2197,12 +2197,14 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, switch (ethtype) { case _ODP_ETHTYPE_IPV4: prs->input_flags.ipv4 = 1; + prs->input_flags.l3_type = ODP_PROTO_L3_TYPE_IPV4; ip_proto = parse_ipv4(prs, &parseptr, &offset, frame_len); prs->l4_offset = offset; break; case _ODP_ETHTYPE_IPV6: prs->input_flags.ipv6 = 1; + prs->input_flags.l3_type = ODP_PROTO_L3_TYPE_IPV6; ip_proto = parse_ipv6(prs, &parseptr, &offset, frame_len, seg_len); prs->l4_offset = offset; @@ -2210,6 +2212,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, case _ODP_ETHTYPE_ARP: prs->input_flags.arp = 1; + prs->input_flags.l3_type = ODP_PROTO_L3_TYPE_ARP; ip_proto = 255; /* Reserved invalid by IANA */ break; @@ -2223,6 +2226,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, /* Set l4 flag only for known ip_proto */ prs->input_flags.l4 = 1; + prs->input_flags.l4_type = ip_proto; /* Parse Layer 4 headers */ switch (ip_proto) { @@ -2267,6 +2271,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, default: prs->input_flags.l4 = 0; + prs->input_flags.l4_type = ODP_PROTO_L4_TYPE_NONE; break; } @@ -2544,3 +2549,17 @@ int odp_packet_has_ref(odp_packet_t pkt) return 0; } + +odp_proto_l3_type_t odp_packet_l3_type(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l3_type; +} + +odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l4_type; +}