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)