From patchwork Thu Feb 8 01:00:04 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: 127232 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1002556ljc; Wed, 7 Feb 2018 17:00:56 -0800 (PST) X-Google-Smtp-Source: AH8x224wRp+2Z6sMCslnbkxj6Eagmar4T7okAHhKflI3B+K4k9AgFDJ2yLwYgUq5cDklQ3ddVLGU X-Received: by 10.200.40.165 with SMTP id i34mr11995036qti.176.1518051656014; Wed, 07 Feb 2018 17:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518051656; cv=none; d=google.com; s=arc-20160816; b=bqIRCudr9RWXNl/jlzMHMnIDfmmgAXJ3Ti8DV0+t8xd1PwT3NINghGsolZLZBL/ytF +UwToPOWll9CK9Ctr78+4PszEzUBF/Nu+SA7bHQQUvxOZ0/1Z8gUP6qH+ND5pZGilwWj u40YdNeBETiDpKitlM2r3oCSGjQNaoFSY1u9FEhrNzcPQ1iGubLRLvrVlPDRAf0z7JlK DufX+kNAbBDeqIe/iMgaZ7HCMPtJYL18B/iNVwpEbJH7yuHae2PbJAP8owq8vvs17jzJ 8RIvf6uzeWxA38+e04bOcJ4vz9caB21wRtvllj2QNkDj3u39g2TfjyZT4+n7SzFg5D+8 o9LQ== 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=sIwT2M2jStnFpGvBFRDSRYAhMrZPmwoibgb2iIg3+Z0=; b=H+bKhCAa/22drnC+DixbEB3HdhLNhmiIRqQMGbA/Jcrulqk48b7iOnmu6hEwY3c+xv zzyRqOlHp5YnqwfWv/WwghFg82buB2boGLzV8B7kNPQrzz4pk9lLYf+zNcVz6up5amor 9yRFM4wHy6OlVhqcvDW+HY4Vam/NICazcRMH9e0CAEmkXHYb+2ixjLWwB7euw3CiZC3L u46tz8iFP5xSW/mcrkTISWvXUfyYXPZd4fqxoCWaa9BoC3O77q3N1k9dniHl2ui7bl6J uTzXiZZGLHK4szOBvrX31Fr24QFhyN5y2xC4DJNK8iwP6l2DbosIj5/ZSQIG3093nfz5 l3ew== 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 o188si2681784qkc.54.2018.02.07.17.00.55; Wed, 07 Feb 2018 17:00:55 -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 858AE6176F; Thu, 8 Feb 2018 01:00:55 +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 E42886062E; Thu, 8 Feb 2018 01:00:19 +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 066B06177D; Thu, 8 Feb 2018 01:00:13 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id 2C17C6175A for ; Thu, 8 Feb 2018 01:00:11 +0000 (UTC) Received: from mxback18j.mail.yandex.net (mxback18j.mail.yandex.net [IPv6:2a02:6b8:0:1619::94]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 7E2275A06187 for ; Thu, 8 Feb 2018 04:00:09 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback18j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id sJj3QBSHPy-09s0HIm8; Thu, 08 Feb 2018 04:00:09 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id dozPKnGPpm-081K9TOw; Thu, 08 Feb 2018 04:00:08 +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, 8 Feb 2018 04:00:04 +0300 Message-Id: <1518051607-20804-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518051607-20804-1-git-send-email-odpbot@yandex.ru> References: <1518051607-20804-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 459 Subject: [lng-odp] [PATCH API-NEXT v1 1/4] 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 459 (lumag:packet-types-2) ** https://github.com/Linaro/odp/pull/459 ** Patch: https://github.com/Linaro/odp/pull/459.patch ** Base sha: af7be638ef9ac98bdb1f2e4917f152889eb1850f ** Merge commit sha: 714954eb283fbb69b44b8dc12b02f5cfbcf17577 **/ .../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; +}