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; +} From patchwork Thu Feb 8 01:00:05 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: 127233 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1003171ljc; Wed, 7 Feb 2018 17:01:42 -0800 (PST) X-Google-Smtp-Source: AH8x224WuKdXND5sJqf6q2aX7B/68Cucrqlok2NLK64gdqYJgeeaL71jppHkrgG5yaPZGI4vjnK3 X-Received: by 10.237.56.9 with SMTP id j9mr12113167qte.32.1518051702630; Wed, 07 Feb 2018 17:01:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518051702; cv=none; d=google.com; s=arc-20160816; b=j0OpN3I2Za0L9hJmL+WBp4WPuXmRv6qmb+/Tpd2bavarxMl8LkTUevKQY5dM3Fd6Tv qdzVUmHyhxY77W14e4JnGkNmGMWzj7dtrzHfNWYPFAKU+SiyKmN+zEcsF1ceYjBpZuTI 9i7Dq3tykdeezJ+RWeSIKXNLN2Yt7q/Gr3xZqBuDpXWZBFCru3VaIOZufNNL8T0fiqb2 OJp9ecqaUEjEOutyiqyyLTvEpq7Mz9S9EK7Jd2e6wfFKaaecDOmnWC94NiA8IdE1cgkk ZwL1h4BLjb1nWC8Rq1FcVLcG0yIldQNPnNzo75c5YEsnOWGAx2k47a4rPx4nlN49NH9t 57Ww== 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=hSKz9tWJZuMnzDy8cmav1W3ghKanav+2ucqIx3xP5RU=; b=mvlmYLt28Si1jhyUQieBlyVIWjnY4HTJLZMl2Rgkmt/DkuxbGGki8zkh2QsSDFat2D QyJCIzpdTXry0kIExStznvuCdxv5oC3BQExnjUCywGy9EiYVU9BBaFcTuJiSPFfafXD7 Fq/lj7qXiCxfBtb86uToUsmt6tc2A18o11yGKpkLEDrDaXVQBVW65ig3mmTyqi10WlHK 3HAfDgb0kN/5+GYHdiKlP/rbBi4iQtkUNh4Rwrt6zMC8SPDgDGE5OrkQbtJns/4yu/ov MRRtgh5OP5vemMg9MjI7JxNEPJTkwaw8dWC0QDsS65qyVclN3J2uqYk9iW/wgiWlDr7H u/tw== 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 v123si2723044qki.351.2018.02.07.17.01.42; Wed, 07 Feb 2018 17:01:42 -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 53BFE61819; Thu, 8 Feb 2018 01:01:42 +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 6182B6173E; Thu, 8 Feb 2018 01:00:24 +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 9EF1C6176F; Thu, 8 Feb 2018 01:00:13 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 8A8346175E for ; Thu, 8 Feb 2018 01:00:11 +0000 (UTC) Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 0A11C1345B71 for ; Thu, 8 Feb 2018 04:00:10 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9G3VgN2EOF-09WWgNQC; Thu, 08 Feb 2018 04:00:09 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id dozPKnGPpm-091KTjRX; Thu, 08 Feb 2018 04:00:09 +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:05 +0300 Message-Id: <1518051607-20804-3-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 2/4] validation: api: check l3/l4 proto types after parsing 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 **/ test/validation/api/packet/packet.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 7d19e0125..f829d0cb1 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -2552,6 +2552,10 @@ void packet_test_parse(void) CU_ASSERT(odp_packet_has_udp(pkt[i])); CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]), + ODP_PROTO_L3_TYPE_IPV4); + CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]), + ODP_PROTO_L4_TYPE_UDP); } odp_packet_free_multi(pkt, num_pkt); @@ -2582,6 +2586,10 @@ void packet_test_parse(void) CU_ASSERT(odp_packet_has_udp(pkt[i])); CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]), + ODP_PROTO_L3_TYPE_IPV4); + CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]), + ODP_PROTO_L4_TYPE_UDP); } odp_packet_free_multi(pkt, num_pkt); @@ -2612,6 +2620,10 @@ void packet_test_parse(void) CU_ASSERT(odp_packet_has_tcp(pkt[i])); CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); CU_ASSERT(!odp_packet_has_udp(pkt[i])); + CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]), + ODP_PROTO_L3_TYPE_IPV4); + CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]), + ODP_PROTO_L4_TYPE_TCP); } odp_packet_free_multi(pkt, num_pkt); @@ -2643,6 +2655,10 @@ void packet_test_parse(void) CU_ASSERT(odp_packet_has_udp(pkt[i])); CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]), + ODP_PROTO_L3_TYPE_IPV6); + CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]), + ODP_PROTO_L4_TYPE_UDP); } odp_packet_free_multi(pkt, num_pkt); @@ -2674,6 +2690,10 @@ void packet_test_parse(void) CU_ASSERT(odp_packet_has_tcp(pkt[i])); CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); CU_ASSERT(!odp_packet_has_udp(pkt[i])); + CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]), + ODP_PROTO_L3_TYPE_IPV6); + CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]), + ODP_PROTO_L4_TYPE_TCP); } odp_packet_free_multi(pkt, num_pkt); From patchwork Thu Feb 8 01:00:06 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: 127234 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1003652ljc; Wed, 7 Feb 2018 17:02:29 -0800 (PST) X-Google-Smtp-Source: AH8x227CmN6yRyh8bIZ6FK5g3zkf33JHGEkyiTQemUi+T5jTMACRUoS4zljv5QMzEgOOfWGGD1re X-Received: by 10.55.119.198 with SMTP id s189mr11631656qkc.88.1518051749331; Wed, 07 Feb 2018 17:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518051749; cv=none; d=google.com; s=arc-20160816; b=zFv3TWk0weAIK1NyvkwTnQAY4u5WIZOmpRiaqF5T/cswyhhOKxH/XCngLynLmO8CNs 27Y13UE3OSBGWo6zrmRJ33d5X5nfQTxggbumhmkhvdsRcRxmAFPq0V8uKnYQ+3JpdjVB l57J3pj79jwSYipHmLYB0DjuyZW9LUxR5XyhzMOsJR3gYmh0J8g9tKA2+Lqcv6QmzPLJ au1srhGblcU2xCYJSfTS1R0cKh4pEhYg9b/A6UZ5sOsN+PoV4ttgOYaG8MqZ6vR6i7+M ypalRqCK9eB3m/t9NbZxowdk8jvqRDQ7OUGPUvDI09sNnsPySLZ6WZcW4ApoAQPoh5O6 rWyQ== 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=8EXrC/4eYky4EcgX9rtMd5g+K8sPIkQly6d3sMA2FsE=; b=ZI+qqVvDL7gsrkw+TqvW0zptOkLKYzCzDYlAY9pIbVy24km5pUBNc3tq7pwN+qjRww wNR9ZlGqYlWcRtoe3+vZWS9YXGPYUlylA2EqKdimg7/asUX5mLS7TQiwbbyX1C3Gr7u5 aQ4JuXP5827qhM7Xf/BR15S47HWqCDcCJVOwCSUStsXHSR6NyBTHjna22tFGUwYSlv1O 5md7vTrtsC4OgIyFCPPpijbIUvqxcOKYRN9jrMo/ymC4H6S5L7F9XcWOV6J7CjKKZlUr i19eJHc4VUokA0/xgRIvtnL6NsdiflZGSmT3DzLuGEzWn1VuAU9/X9Kpe/0FchbEsy/R zZzw== 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 y73si410378qky.49.2018.02.07.17.02.29; Wed, 07 Feb 2018 17:02:29 -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 E83B561822; Thu, 8 Feb 2018 01:02:28 +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 B41026092D; Thu, 8 Feb 2018 01:00:28 +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 A1F266062E; Thu, 8 Feb 2018 01:00:19 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id 51AFB61724 for ; Thu, 8 Feb 2018 01:00:12 +0000 (UTC) Received: from mxback9o.mail.yandex.net (mxback9o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::23]) by forward100j.mail.yandex.net (Yandex) with ESMTP id A565E5D83C4C for ; Thu, 8 Feb 2018 04:00:10 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback9o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Io7qBYXv8C-0AOSwVLi; Thu, 08 Feb 2018 04:00:10 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id dozPKnGPpm-0A18HK1j; Thu, 08 Feb 2018 04:00:10 +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:06 +0300 Message-Id: <1518051607-20804-4-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 3/4] linux-gen: use packet l3 type rather than ipv4/ipv6/arp input flags 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 -- .../include/odp_classification_inlines.h | 9 ++++-- .../linux-generic/include/odp_packet_internal.h | 7 ++++- platform/linux-generic/odp_classification.c | 8 ++--- platform/linux-generic/odp_packet.c | 3 -- platform/linux-generic/odp_packet_flags.c | 36 ++++++++++++++++++---- 6 files changed, 46 insertions(+), 20 deletions(-) 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 a190b45af..fb54e6402 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 @@ -72,10 +72,7 @@ typedef union { uint64_t vlan_qinq:1; /* Stacked VLAN found, QinQ */ uint64_t snap:1; /* SNAP */ - uint64_t arp:1; /* ARP */ - uint64_t ipv4:1; /* IPv4 */ - uint64_t ipv6:1; /* IPv6 */ uint64_t ip_bcast:1; /* IP broadcast */ uint64_t ip_mcast:1; /* IP multicast */ uint64_t ipfrag:1; /* IP fragment */ diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index 3f1d9ce6a..f9462e976 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -51,7 +51,8 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr, { const _odp_ipv4hdr_t *ip; uint8_t proto; - if (!pkt_hdr->p.input_flags.ipv4) + + if (!packet_hdr_has_ipv4(pkt_hdr)) return 0; ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); proto = ip->proto; @@ -67,7 +68,8 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t *pkt_addr, { const _odp_ipv4hdr_t *ip; uint32_t ipaddr; - if (!pkt_hdr->p.input_flags.ipv4) + + if (!packet_hdr_has_ipv4(pkt_hdr)) return 0; ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); ipaddr = _odp_be_to_cpu_32(ip->src_addr); @@ -83,7 +85,8 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t *pkt_addr, { const _odp_ipv4hdr_t *ip; uint32_t ipaddr; - if (!pkt_hdr->p.input_flags.ipv4) + + if (!packet_hdr_has_ipv4(pkt_hdr)) return 0; ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); ipaddr = _odp_be_to_cpu_32(ip->dst_addr); diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 83bc27b12..59cb9ded9 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -281,9 +281,14 @@ static inline int packet_hdr_has_eth(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->p.input_flags.eth; } +static inline int packet_hdr_has_ipv4(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV4; +} + static inline int packet_hdr_has_ipv6(odp_packet_hdr_t *pkt_hdr) { - return pkt_hdr->p.input_flags.ipv6; + return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV6; } static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts) diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 36358ab4a..5147db137 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -1026,7 +1026,7 @@ static uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr, tuple_len = 0; hash = 0; - if (pkt_hdr->p.input_flags.ipv4) { + if (packet_hdr_has_ipv4(pkt_hdr)) { if (hash_proto.ipv4) { /* add ipv4 */ ipv4 = (const _odp_ipv4hdr_t *)(base + @@ -1051,7 +1051,7 @@ static uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr, tuple.v4.dport = udp->dst_port; tuple_len += 1; } - } else if (pkt_hdr->p.input_flags.ipv6) { + } else if (packet_hdr_has_ipv6(pkt_hdr)) { if (hash_proto.ipv6) { /* add ipv6 */ ipv6 = (const _odp_ipv6hdr_t *)(base + @@ -1089,11 +1089,11 @@ cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr, const _odp_ipv4hdr_t *ipv4; const _odp_ipv6hdr_t *ipv6; - if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv4) { + if (hdr->p.input_flags.l3 && packet_hdr_has_ipv4(hdr)) { ipv4 = (const _odp_ipv4hdr_t *)(pkt_addr + hdr->p.l3_offset); dscp = _ODP_IPV4HDR_DSCP(ipv4->tos); cos = l3_cos->cos[dscp]; - } else if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv6) { + } else if (hdr->p.input_flags.l3 && packet_hdr_has_ipv6(hdr)) { ipv6 = (const _odp_ipv6hdr_t *)(pkt_addr + hdr->p.l3_offset); dscp = _ODP_IPV6HDR_DSCP(ipv6->ver_tc_flow); cos = l3_cos->cos[dscp]; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index f5151d293..065c22259 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2196,14 +2196,12 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, /* Parse Layer 3 headers */ 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); @@ -2211,7 +2209,6 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, break; 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; diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index 0c33666eb..a1d64ddce 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -83,17 +83,23 @@ int odp_packet_has_vlan_qinq(odp_packet_t pkt) int odp_packet_has_arp(odp_packet_t pkt) { - retflag(pkt, input_flags.arp); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_ARP; } int odp_packet_has_ipv4(odp_packet_t pkt) { - retflag(pkt, input_flags.ipv4); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV4; } int odp_packet_has_ipv6(odp_packet_t pkt) { - retflag(pkt, input_flags.ipv6); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV6; } int odp_packet_has_ip_bcast(odp_packet_t pkt) @@ -226,17 +232,35 @@ void odp_packet_has_vlan_qinq_set(odp_packet_t pkt, int val) void odp_packet_has_arp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.arp, val); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_proto_l3_type_t type = ODP_PROTO_L3_TYPE_ARP; + + if (val) + pkt_hdr->p.input_flags.l3_type = type; + else if (pkt_hdr->p.input_flags.l3_type == type) + pkt_hdr->p.input_flags.l3_type = ODP_PROTO_L3_TYPE_NONE; } void odp_packet_has_ipv4_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ipv4, val); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_proto_l3_type_t type = ODP_PROTO_L3_TYPE_IPV4; + + if (val) + pkt_hdr->p.input_flags.l3_type = type; + else if (pkt_hdr->p.input_flags.l3_type == type) + pkt_hdr->p.input_flags.l3_type = ODP_PROTO_L3_TYPE_NONE; } void odp_packet_has_ipv6_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.ipv6, val); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_proto_l3_type_t type = ODP_PROTO_L3_TYPE_IPV6; + + if (val) + pkt_hdr->p.input_flags.l3_type = type; + else if (pkt_hdr->p.input_flags.l3_type == type) + pkt_hdr->p.input_flags.l3_type = ODP_PROTO_L3_TYPE_NONE; } void odp_packet_has_ip_bcast_set(odp_packet_t pkt, int val) From patchwork Thu Feb 8 01:00:07 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: 127235 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1004333ljc; Wed, 7 Feb 2018 17:03:27 -0800 (PST) X-Google-Smtp-Source: AH8x2273EY5/Z/f4GlrQ9KJ8PdeaYiIUuS5uVquy2tn+teMhB0b8ovkMxeNC4SwLdTSo2gA6oJwX X-Received: by 10.55.56.84 with SMTP id f81mr5241377qka.25.1518051807153; Wed, 07 Feb 2018 17:03:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518051807; cv=none; d=google.com; s=arc-20160816; b=nAS9anbP8E31W4vtj1OeYgRxdF+HbDG11kbe1RG3psb2Xi7qxmuiJiUbCGlVI64jNQ CN/gcM9vDD+8DZnmZHO15U350QAezNYTvXg+LzPCgtxtMFjn9NS7yWFBpZCBebNV4iaK 7DnQsfv9gX6GW+/KUvlRipZ/YGpZ3sHn/U9wjvmbxLe4EFBOW3B9eztXUdn9M34uPFDb /u7534kjZlpPDR9XnpWtdRo3kOkFqg9NTuAHHS9YPKiqbZfOeCaFJNVZU4yeqfri3u7j MQb+o7fB97q0B57BdzvjXtFOv3a8fRjXfXfn6hSffyFQN+kM3Wz0C7UvuSpGHgfly6FC wlDg== 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=Q1yNNPhR8NBWgtw0NHQN74/arobPKAbCD8XdeMFssjA=; b=RnCMBXbWAwr6DxeJ01O3LeBizKNdk60PWsxNW9HceHhJ+enkQl36XIk///SSwTF/Cn syntKFdNoioZWFcAq+dtCkaAnxsB/fFawkykTvq9YIPH2vISulW5rOGFfsa57ZMz9h+M NdqFdvntfDg3EF/6mG3BEhH/nDcsmf0dLqaHFJ5+C3h8gpWeyCPckbovFz/+ZSeBUnCe bLwoNc/HdOJDFz9+zqlSG7Xrjgp4SfMBpbMlRlj6sj845YVQfOglSWmhc0lR6gus4bH8 rQGTTzNUMvdB9fz+yoHniaDvL7Dq4xyRojDeZFxxlE+XZ5FL9mqb8lcvcj9Mzc0TNGMZ 8f5w== 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 x4si983485qkl.113.2018.02.07.17.03.26; Wed, 07 Feb 2018 17:03: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 8C4BB60953; Thu, 8 Feb 2018 01:03:26 +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 1C36D61791; Thu, 8 Feb 2018 01:00:35 +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 9532A60928; Thu, 8 Feb 2018 01:00:21 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id 75E4661769 for ; Thu, 8 Feb 2018 01:00:12 +0000 (UTC) Received: from mxback7j.mail.yandex.net (mxback7j.mail.yandex.net [IPv6:2a02:6b8:0:1619::110]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 7D4005D85EDA for ; Thu, 8 Feb 2018 04:00:11 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback7j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id BHzpcRN3Co-0BjSwQSq; Thu, 08 Feb 2018 04:00:11 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id dozPKnGPpm-0A1WAvjE; Thu, 08 Feb 2018 04:00:10 +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:07 +0300 Message-Id: <1518051607-20804-5-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 4/4] linux-gen: use packet l4 type rather than individual input flags 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 | 7 --- .../include/odp_classification_inlines.h | 15 +++--- .../linux-generic/include/odp_packet_internal.h | 10 ++++ platform/linux-generic/odp_classification.c | 8 +-- platform/linux-generic/odp_packet.c | 11 ++-- platform/linux-generic/odp_packet_flags.c | 60 +++++++++++++++++++--- 6 files changed, 79 insertions(+), 32 deletions(-) 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 fb54e6402..008a06bff 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 @@ -80,14 +80,7 @@ typedef union { uint64_t ipsec:1; /* IPSec packet. Required by the odp_packet_has_ipsec_set() func. */ - uint64_t ipsec_ah:1; /* IPSec authentication header */ - uint64_t ipsec_esp:1; /* IPSec encapsulating security - payload */ - uint64_t udp:1; /* UDP */ - uint64_t tcp:1; /* TCP */ uint64_t tcpopt:1; /* TCP options present */ - uint64_t sctp:1; /* SCTP */ - uint64_t icmp:1; /* ICMP */ uint64_t color:2; /* Packet color for traffic mgmt */ uint64_t nodrop:1; /* Drop eligibility status */ diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index f9462e976..4d6472355 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -102,7 +102,8 @@ static inline int verify_pmr_tcp_sport(const uint8_t *pkt_addr, { uint16_t sport; const _odp_tcphdr_t *tcp; - if (!pkt_hdr->p.input_flags.tcp) + + if (!packet_hdr_has_tcp(pkt_hdr)) return 0; tcp = (const _odp_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); sport = _odp_be_to_cpu_16(tcp->src_port); @@ -118,7 +119,8 @@ static inline int verify_pmr_tcp_dport(const uint8_t *pkt_addr, { uint16_t dport; const _odp_tcphdr_t *tcp; - if (!pkt_hdr->p.input_flags.tcp) + + if (!packet_hdr_has_tcp(pkt_hdr)) return 0; tcp = (const _odp_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); dport = _odp_be_to_cpu_16(tcp->dst_port); @@ -134,7 +136,8 @@ static inline int verify_pmr_udp_dport(const uint8_t *pkt_addr, { uint16_t dport; const _odp_udphdr_t *udp; - if (!pkt_hdr->p.input_flags.udp) + + if (!packet_hdr_has_udp(pkt_hdr)) return 0; udp = (const _odp_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); dport = _odp_be_to_cpu_16(udp->dst_port); @@ -151,7 +154,7 @@ static inline int verify_pmr_udp_sport(const uint8_t *pkt_addr, uint16_t sport; const _odp_udphdr_t *udp; - if (!pkt_hdr->p.input_flags.udp) + if (!packet_hdr_has_udp(pkt_hdr)) return 0; udp = (const _odp_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); sport = _odp_be_to_cpu_16(udp->src_port); @@ -291,11 +294,11 @@ static inline int verify_pmr_ipsec_spi(const uint8_t *pkt_addr, pkt_addr += pkt_hdr->p.l4_offset; - if (pkt_hdr->p.input_flags.ipsec_ah) { + if (pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_AH) { const _odp_ahhdr_t *ahhdr = (const _odp_ahhdr_t *)pkt_addr; spi = _odp_be_to_cpu_32(ahhdr->spi); - } else if (pkt_hdr->p.input_flags.ipsec_esp) { + } else if (pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_ESP) { const _odp_esphdr_t *esphdr = (const _odp_esphdr_t *)pkt_addr; spi = _odp_be_to_cpu_32(esphdr->spi); diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 59cb9ded9..9ef11c677 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -291,6 +291,16 @@ static inline int packet_hdr_has_ipv6(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV6; } +static inline int packet_hdr_has_tcp(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_TCP; +} + +static inline int packet_hdr_has_udp(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_UDP; +} + static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts) { if (ts != NULL) { diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 5147db137..6937ac4b2 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -1036,14 +1036,14 @@ static uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr, tuple_len += 2; } - if (pkt_hdr->p.input_flags.tcp && hash_proto.tcp) { + if (packet_hdr_has_tcp(pkt_hdr) && hash_proto.tcp) { /* add tcp */ tcp = (const _odp_tcphdr_t *)(base + pkt_hdr->p.l4_offset); tuple.v4.sport = tcp->src_port; tuple.v4.dport = tcp->dst_port; tuple_len += 1; - } else if (pkt_hdr->p.input_flags.udp && hash_proto.udp) { + } else if (packet_hdr_has_udp(pkt_hdr) && hash_proto.udp) { /* add udp */ udp = (const _odp_udphdr_t *)(base + pkt_hdr->p.l4_offset); @@ -1059,13 +1059,13 @@ static uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr, thash_load_ipv6_addr(ipv6, &tuple); tuple_len += 8; } - if (pkt_hdr->p.input_flags.tcp && hash_proto.tcp) { + if (packet_hdr_has_tcp(pkt_hdr) && hash_proto.tcp) { tcp = (const _odp_tcphdr_t *)(base + pkt_hdr->p.l4_offset); tuple.v6.sport = tcp->src_port; tuple.v6.dport = tcp->dst_port; tuple_len += 1; - } else if (pkt_hdr->p.input_flags.udp && hash_proto.udp) { + } else if (packet_hdr_has_udp(pkt_hdr) && hash_proto.udp) { /* add udp */ udp = (const _odp_udphdr_t *)(base + pkt_hdr->p.l4_offset); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 065c22259..87bf23564 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2228,10 +2228,11 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, /* Parse Layer 4 headers */ switch (ip_proto) { case _ODP_IPPROTO_ICMPV4: - /* Fall through */ + /* Do nothing */ + break; case _ODP_IPPROTO_ICMPV6: - prs->input_flags.icmp = 1; + /* Do nothing */ break; case _ODP_IPPROTO_IPIP: @@ -2241,29 +2242,25 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, case _ODP_IPPROTO_TCP: if (odp_unlikely(offset + _ODP_TCPHDR_LEN > seg_len)) return -1; - prs->input_flags.tcp = 1; parse_tcp(prs, &parseptr, NULL); break; case _ODP_IPPROTO_UDP: if (odp_unlikely(offset + _ODP_UDPHDR_LEN > seg_len)) return -1; - prs->input_flags.udp = 1; parse_udp(prs, &parseptr, NULL); break; case _ODP_IPPROTO_AH: prs->input_flags.ipsec = 1; - prs->input_flags.ipsec_ah = 1; break; case _ODP_IPPROTO_ESP: prs->input_flags.ipsec = 1; - prs->input_flags.ipsec_esp = 1; break; case _ODP_IPPROTO_SCTP: - prs->input_flags.sctp = 1; + /* Do nothing */ break; default: diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index a1d64ddce..fdde865ee 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -9,6 +9,7 @@ #include #include #include +#include #define retflag(pkt, x) do { \ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \ @@ -129,22 +130,31 @@ int odp_packet_has_ipsec(odp_packet_t pkt) int odp_packet_has_udp(odp_packet_t pkt) { - retflag(pkt, input_flags.udp); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_UDP; } int odp_packet_has_tcp(odp_packet_t pkt) { - retflag(pkt, input_flags.tcp); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_TCP; } int odp_packet_has_sctp(odp_packet_t pkt) { - retflag(pkt, input_flags.sctp); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_SCTP; } int odp_packet_has_icmp(odp_packet_t pkt) { - retflag(pkt, input_flags.icmp); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_ICMPV4 || + pkt_hdr->p.input_flags.l4_type == ODP_PROTO_L4_TYPE_ICMPV6; } odp_packet_color_t odp_packet_color(odp_packet_t pkt) @@ -290,22 +300,56 @@ void odp_packet_has_ipsec_set(odp_packet_t pkt, int val) void odp_packet_has_udp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.udp, val); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_proto_l4_type_t type = ODP_PROTO_L4_TYPE_UDP; + + if (val) + pkt_hdr->p.input_flags.l4_type = type; + else if (pkt_hdr->p.input_flags.l4_type == type) + pkt_hdr->p.input_flags.l4_type = ODP_PROTO_L4_TYPE_NONE; } void odp_packet_has_tcp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.tcp, val); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_proto_l4_type_t type = ODP_PROTO_L4_TYPE_TCP; + + if (val) + pkt_hdr->p.input_flags.l4_type = type; + else if (pkt_hdr->p.input_flags.l4_type == type) + pkt_hdr->p.input_flags.l4_type = ODP_PROTO_L4_TYPE_NONE; } void odp_packet_has_sctp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.sctp, val); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_proto_l4_type_t type = ODP_PROTO_L4_TYPE_SCTP; + + if (val) + pkt_hdr->p.input_flags.l4_type = type; + else if (pkt_hdr->p.input_flags.l4_type == type) + pkt_hdr->p.input_flags.l4_type = ODP_PROTO_L4_TYPE_NONE; } void odp_packet_has_icmp_set(odp_packet_t pkt, int val) { - setflag(pkt, input_flags.icmp, val); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_proto_l3_type_t ip4 = ODP_PROTO_L3_TYPE_IPV4; + odp_proto_l3_type_t ip6 = ODP_PROTO_L3_TYPE_IPV6; + odp_proto_l4_type_t type4 = ODP_PROTO_L4_TYPE_ICMPV4; + odp_proto_l4_type_t type6 = ODP_PROTO_L4_TYPE_ICMPV6; + + if (val) { + if (pkt_hdr->p.input_flags.l3_type == ip4) + pkt_hdr->p.input_flags.l4_type = type4; + else if (pkt_hdr->p.input_flags.l3_type == ip6) + pkt_hdr->p.input_flags.l4_type = type6; + else + ODP_ERR("Setting ICMP flag for non-IPv4/IPv6 packet!\n"); + } else if (pkt_hdr->p.input_flags.l3_type == type4 || + pkt_hdr->p.input_flags.l3_type == type6) { + pkt_hdr->p.input_flags.l4_type = ODP_PROTO_L4_TYPE_NONE; + } } void odp_packet_has_flow_hash_clr(odp_packet_t pkt)