From patchwork Thu Mar 1 21:00:41 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: 130415 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp520549lja; Thu, 1 Mar 2018 13:02:49 -0800 (PST) X-Google-Smtp-Source: AG47ELt/Bt/OOCvIfboevszzTPhxQdbgWKQW/yd+M0xAPZCIY/odl3pw6UkpExBpdkqE1aTOsaQF X-Received: by 10.129.40.196 with SMTP id o187mr2336635ywo.497.1519938168892; Thu, 01 Mar 2018 13:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519938168; cv=none; d=google.com; s=arc-20160816; b=ih3YbuJweUJVcm2gF+TZE8OqoXsPxPGZWu9LVKMZOHP7b3JJh9iurDRlEPCSXLnwzu Mp0dflTyOn/AHkJkJ3ZuGoB139NomCSnPuSZshkSqZEIJ736pjVo/rX8+B/PWzqqbX/g 7ajw18CvOZ+S3P0/GX5dYuhyt4tRY/PByxrjwVhxP35bZ8XFE3q2rdw1QMqQ/NorRg/7 WOr6D35yQCJ1B6tBSSafgTQ5qO9Bf6/8JvYrdNKSW/+n0S0FDlYnNDFCFbjLZJzkh7bx e++Ruh109WpJOK+e+Ex0doHaz/yN+DxTT6hbasBs6WF49lLUpHcO2PW6ayH+QtnVLPe1 75/A== 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=U34JwlRRyDx1+TQdhvet07KJYeIDRQMp0m3rnnxWwmE=; b=1FLGGYMbxUZt0mKQoE4sRrik7+FsNGGm/P2NaISjcPrXlxLG334Ln+ejGeZfznrCsS l9fN5KDOwdZfs7mScHNPIFafXwQ4wCz/0GvkDaQ+2ceY2//B4Tzplv8MEqYlYRJEMlTo 1gAfytAl4MCRa5vr2yA4sxYTDTlvAmzCtvdkWottdAM6vW8O6ZEE2L3Njo/+iqmna1U5 jAdCUZ1Ic7TXrznmY0RaClQv+3XK1rYNb4LathdmAguPvFsi/2yBp6U1C3nPiec1dmBF 2jNVa/9amQCbdMGx9+WARC3/vWYGAEKfAZ5jlGrtPROBKb1LaN9EQ/ksLHXHNvxzsocD LNyA== 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 187si824227qko.286.2018.03.01.13.02.48; Thu, 01 Mar 2018 13:02:48 -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 4C980627DD; Thu, 1 Mar 2018 21:02:48 +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_H3, RCVD_IN_MSPIKE_WL 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 57117617D4; Thu, 1 Mar 2018 21: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 5F97261741; Thu, 1 Mar 2018 21:01:13 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id A49E161741 for ; Thu, 1 Mar 2018 21:01:01 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 4B4D42D84B74 for ; Fri, 2 Mar 2018 00:01:00 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id P9An5UgzZU-10vS6evq; Fri, 02 Mar 2018 00:01:00 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id BpjAadXdWb-0x2SFalk; Fri, 02 Mar 2018 00:00:59 +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: Fri, 2 Mar 2018 00:00:41 +0300 Message-Id: <1519938053-24031-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519938053-24031-1-git-send-email-odpbot@yandex.ru> References: <1519938053-24031-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 505 Subject: [lng-odp] [PATCH v2 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: 5da68bf06572d3d0651c37cbba03aa91995ec465 **/ 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; +}