From patchwork Thu Mar 1 16:59:57 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: 130340 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3043133edc; Thu, 1 Mar 2018 09:01:23 -0800 (PST) X-Google-Smtp-Source: AG47ELsiy5tqahVhhf+HCT548ExBTeof6NSJKo5Q58OnqoVIApyMwJZuSmV9dPfiX86RTCRxCizx X-Received: by 10.13.202.150 with SMTP id m144mr1742103ywd.70.1519923683183; Thu, 01 Mar 2018 09:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519923683; cv=none; d=google.com; s=arc-20160816; b=N3uWq6wII2w8FCs6El3iVI7ECeMD4kZXOKsMigZV4/7EBk+HuvWqJMm1pOC2AN/8n1 6BCC2F0ie+pvIgmWd4rP0faQBc7O76BClHTKxR9HL1KgAOR9Eb9/XukliAa+qvGJ509+ odNtQBEswI05O1aVjynXXxgj2yCwdHzQToApAMsoRTznD0RBhSGf+VHTsu95aaN8y1Wl QGD9fvrTDVdqJz8WSTzZO2JeaBMDcfwVwJWOI9jG0+gVyii1W+W1qcDYw40FQielVSWz pOsfw7aNZV7QloBH2oZNYKBqrSP15SxDAzVFIaidaDTRUIiBEFoSQq3BH7r3ER6+2vmJ yWtA== 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=PIOVquqqkKSpJv2SoQL2mlCrXfBLLUX+lcotKl+Hm7o=; b=Yo84cnHR8lu+BkGM5plFWWOn94kZ83eZql15GeQbS2D+rs5Ha9NHBifNvmgklJ1UJB j0prQ1asR9GihdrVJUvtCojJ2PLqqI9GDlmM5Kel49+UvTC/VCfU7CWoJaZ4naHmbxRo 0+wd6zzjBzYJdcz2565beGJYwgnERfvsHK9vTWcf2K+NYoIpxGUMy4zDGJSJ2XAQFi7g LmBQpiuoa6UwPz4Yb4g+OBl6jIDq7lNvTeqrWNoMndkP9mdM0cqmaalLK1Uc6jkP3yj9 DjUP5jCw/G/XMAcs6YEcDxNOoco20gVUPQILb64Ym1tC3OooMlPtLPqlZPTV4zu37DQz 54QQ== 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 n189si485358qkc.479.2018.03.01.09.01.22; Thu, 01 Mar 2018 09:01:23 -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 BF28A617E4; Thu, 1 Mar 2018 17:01:22 +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 7791860632; Thu, 1 Mar 2018 17:00:33 +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 5FEF26178A; Thu, 1 Mar 2018 17: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 79489616FC for ; Thu, 1 Mar 2018 17:00:14 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward105o.mail.yandex.net (Yandex) with ESMTP id E45774444E80 for ; Thu, 1 Mar 2018 20:00:12 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FPP9dysXrY-0ClmKHTK; Thu, 01 Mar 2018 20:00:12 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 7MkXJ9JJAA-0BC4m4fb; Thu, 01 Mar 2018 20: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: Thu, 1 Mar 2018 19:59:57 +0300 Message-Id: <1519923609-31634-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519923609-31634-1-git-send-email-odpbot@yandex.ru> References: <1519923609-31634-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 505 Subject: [lng-odp] [PATCH v1 1/13] 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 Reviewed-by: Petri Savolainen Reviewed-by: Bill Fischofer Signed-off-by: Maxim Uvarov --- /** Email created from pull request 505 (muvarov:devel/master_merge_api-next) ** https://github.com/Linaro/odp/pull/505 ** Patch: https://github.com/Linaro/odp/pull/505.patch ** Base sha: 284f52d72ec19df3774c7409780f1f9eea33b8e6 ** Merge commit sha: e8f50fefcd57a92e0971dc1172c5402c56b8370a **/ platform/linux-generic/odp_packet.c | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index e24aa0c7a..8a5833ded 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2485,3 +2485,41 @@ 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 = packet_hdr(pkt); + + if (pkt_hdr->p.input_flags.ipv4) + return ODP_PROTO_L3_TYPE_IPV4; + else if (pkt_hdr->p.input_flags.ipv6) + return ODP_PROTO_L3_TYPE_IPV6; + else if (pkt_hdr->p.input_flags.arp) + return ODP_PROTO_L3_TYPE_ARP; + + return ODP_PROTO_L3_TYPE_NONE; +} + +odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + if (pkt_hdr->p.input_flags.tcp) + return ODP_PROTO_L4_TYPE_TCP; + else if (pkt_hdr->p.input_flags.udp) + return ODP_PROTO_L4_TYPE_UDP; + else if (pkt_hdr->p.input_flags.sctp) + return ODP_PROTO_L4_TYPE_SCTP; + else if (pkt_hdr->p.input_flags.ipsec_ah) + return ODP_PROTO_L4_TYPE_AH; + else if (pkt_hdr->p.input_flags.ipsec_esp) + return ODP_PROTO_L4_TYPE_ESP; + else if (pkt_hdr->p.input_flags.icmp && + pkt_hdr->p.input_flags.ipv4) + return ODP_PROTO_L4_TYPE_ICMPV4; + else if (pkt_hdr->p.input_flags.icmp && + pkt_hdr->p.input_flags.ipv6) + return ODP_PROTO_L4_TYPE_ICMPV6; + + return ODP_PROTO_L4_TYPE_NONE; +}