From patchwork Fri Feb 16 21:00:24 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: 128641 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp981017ljc; Fri, 16 Feb 2018 13:07:23 -0800 (PST) X-Google-Smtp-Source: AH8x2277Ps9xOwdydHbJtZMPYxTxOBuG+PLPH/s8xAU2lVsd8VzFoPeWd+0qvuRpYt58SiDFo5eb X-Received: by 10.233.235.8 with SMTP id b8mr12031003qkg.250.1518815243633; Fri, 16 Feb 2018 13:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518815243; cv=none; d=google.com; s=arc-20160816; b=udwG8yjxOp3bIoRhQF4GRs+Fnnu+99S88LJq8WesE22DjBlu8ov3TpPMYjlSJr7XjJ +2D60G/x5dAqLPiwWjqgL3fJfdU2YqJTO9UjXYhW7TyKqM92xpRhBfkKyItDb8Mi1h+a XV9Vx1LalTRvFaTdprQYwM/+7LrTnqH06Jllvp0DrTGVL8U8Z9rAof87Uhp1nw6+bTpP q3n11pl0GeLi4Gdsyc8KUwzcNG4UA+sMBRPSUzyUD9n0ITOB4JN/Akoro6HYB5l9Oq91 TtAj7pAsR8//KcIiPCgYI+HW8US/28R6o4zQiutfk1zyHWCpdOhT+l8C0t15yhw10k+A BGvw== 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=OAv3l6Jj7HmFcnrMoSw40DmmxPrlMSfTGVLcr2OPvv4=; b=q1cr6YgrPHhIaaAL/T1gfMD0SwR1dG79Mfc2wvILtYmpJQACWd0Kk1dF4R9CkWPZ/D AsWqQaRw/g0a5BufFgLCFOje2CnUF9y3pp85R+fpWBupe+SEuq0t0VClO0uCB3Sz8Aha e6lfLosUnpZvXLY33CCUThzrpJrM+R73YbPo/MXRj+baXKNP/YONuXYjzK0ST2AcpxpZ BGMYWv+T7CUNGgE2XELKVVvM3FmW9BUpKeEZV2dZDMv5+UKjR65IWMao2EFmr/tV+i7c /vUwAWTqMM1MApt3PGjsXbgIjhkk7hJLbPBG081bHUXEbn4Hj9Q4onEQGlnbJ2vuoZzF PI7g== 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 t10si6188510qth.211.2018.02.16.13.07.23; Fri, 16 Feb 2018 13:07: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 29D0061777; Fri, 16 Feb 2018 21:07:23 +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 1445D60C56; Fri, 16 Feb 2018 21:01:09 +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 91B58617BF; Fri, 16 Feb 2018 21:01:05 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 15D6960C56 for ; Fri, 16 Feb 2018 21:00:29 +0000 (UTC) Received: from mxback3g.mail.yandex.net (mxback3g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:164]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 379C52D80E5F for ; Sat, 17 Feb 2018 00:00:27 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback3g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id DK5oy3AQZr-0RsSddtf; Sat, 17 Feb 2018 00:00:27 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 27bQJSNy22-0QJ43rcL; Sat, 17 Feb 2018 00:00:26 +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: Sat, 17 Feb 2018 00:00:24 +0300 Message-Id: <1518814825-27180-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518814825-27180-1-git-send-email-odpbot@yandex.ru> References: <1518814825-27180-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 463 Subject: [lng-odp] [PATCH API-NEXT v1 1/2] 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 463 (lumag:packet-types-3) ** https://github.com/Linaro/odp/pull/463 ** Patch: https://github.com/Linaro/odp/pull/463.patch ** Base sha: af7be638ef9ac98bdb1f2e4917f152889eb1850f ** Merge commit sha: 35498cf7080f84be804702cc9c2d471808f5f3fb **/ 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 dc16e9be4..ad4fd3bb6 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2544,3 +2544,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 = odp_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 = odp_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; +}