From patchwork Wed Feb 7 13: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: 127184 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp462653ljc; Wed, 7 Feb 2018 05:17:42 -0800 (PST) X-Google-Smtp-Source: AH8x224EenwMjYpifLmYh38v29Qrl/mi7+rAL3D/nt4SrHVv252tGse9agrp+TX9VF/EwOg/lXaP X-Received: by 10.200.34.194 with SMTP id g2mr8854073qta.302.1518009462750; Wed, 07 Feb 2018 05:17:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518009462; cv=none; d=google.com; s=arc-20160816; b=RAnr97dbpJmjdjjL+ov3850+QxFbtjHEx3RKZHXY2IZ291nmgAGdjxP1WBfnaE+cRV HDYP3i90dfs7kuqODCua7vxLpzUQvIo+AldrkYXzGckd3SU/6raeS+3DggATeYBtLtnr n6ecmgdUMC6jZxSBjOdGHfDbO93hZvvB0Tu1OXcuTDdDWAo2U9efHlZEMgJSEsEMp2u4 71x8I7M7bwTDuAtwmgIw0dbs0U9MGRNFpHUNPIhTCtAUyJF8KbQq9QQdZBhO0gwgnbco IGha3095k2e4Od/LKjvdPiW5DujpQRhnQ4hB5OxnTJc4bzKEq1vPC90lknYi+ffs5AUc 1f5w== 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=79nT2Cs268Jw8v4sUB4rR2MtGbo/ualT5z0ss3Scsfs=; b=Og3PFtMb3y8Z6q6Bwn3TNLbFf+u4d/rEyF7nlIyYbZqbnJB+8KfKV5xMkqitgfHm7+ fq362Uk78PdKHvMsUjZ7PwrQRumG7U6zcOqhk5E5prfWT8mj7CkleUF1BLYIrp7yA2zI /auv0rsk+jIeWU52w/KfL+C0LdQ8SQZ/kl+5DPuLsIK4BdDfYIeCw6WQ2yQljS4tJ+dQ k+LxAIVBBHTyA7FCZ2cnjn1j2fq/Y6af37yB0AgC9qc7B6vDIJaf0wi27dNvbCpyHWAa 6nygdKuQtApyoG6sd9jIMdv1AOUhKyK1yxwqT+cdgiM6uh+1kIadEGFZZeWzRdlTvTtL xuww== 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 r18si1439890qtr.424.2018.02.07.05.17.42; Wed, 07 Feb 2018 05:17: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 4E68E62799; Wed, 7 Feb 2018 13:17: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_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 BE04F627B9; Wed, 7 Feb 2018 13:02:26 +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 208B460B0E; Wed, 7 Feb 2018 13:00:45 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id D308860C4C for ; Wed, 7 Feb 2018 13:00:18 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 92EA4783887 for ; Wed, 7 Feb 2018 16:00:17 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Oqc1Kxmj3O-0HTK12Ra; Wed, 07 Feb 2018 16:00:17 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2XfrietnG0-0GZatfNC; Wed, 07 Feb 2018 16:00:16 +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: Wed, 7 Feb 2018 16:00:07 +0300 Message-Id: <1518008409-31750-13-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518008409-31750-1-git-send-email-odpbot@yandex.ru> References: <1518008409-31750-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 457 Subject: [lng-odp] [PATCH API-NEXT v3 12/14] 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 457 (lumag:packet-types) ** https://github.com/Linaro/odp/pull/457 ** Patch: https://github.com/Linaro/odp/pull/457.patch ** Base sha: e1175d5a69c65bb465022c9f1381c40fdb5c4069 ** Merge commit sha: 86fcf3650d33f5dd82712dda131fb8ca66a3bdf8 **/ .../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 | 16 ++----- platform/linux-generic/odp_packet_flags.c | 49 ++++++++++++++++++---- 6 files changed, 68 insertions(+), 37 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 14ed13bca..cc6ab008f 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: @@ -2573,9 +2570,4 @@ void odp_packet_l4_type_set(odp_packet_t pkt, odp_proto_l4_type_t val) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); pkt_hdr->p.input_flags.l4_type = val; - pkt_hdr->p.input_flags.tcp = (val == ODP_PROTO_L4_TYPE_TCP); - pkt_hdr->p.input_flags.udp = (val == ODP_PROTO_L4_TYPE_UDP); - pkt_hdr->p.input_flags.sctp = (val == ODP_PROTO_L4_TYPE_SCTP); - pkt_hdr->p.input_flags.icmp = (val == ODP_PROTO_L4_TYPE_ICMPV4) || - (val == ODP_PROTO_L4_TYPE_ICMPV6); } diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index ab34d0950..ce140e600 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -129,22 +129,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) @@ -287,22 +296,46 @@ 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); + + if (val) + odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_UDP); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L4_TYPE_UDP) + odp_packet_l4_type_set(pkt, 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); + + if (val) + odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_TCP); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L4_TYPE_TCP) + odp_packet_l4_type_set(pkt, 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); + + if (val) + odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_SCTP); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L4_TYPE_SCTP) + odp_packet_l4_type_set(pkt, 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); + + if (val && odp_packet_has_ipv6(pkt)) + odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_ICMPV6); + else if (val) + odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_ICMPV4); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L4_TYPE_ICMPV4) + odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_NONE); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L4_TYPE_ICMPV6) + odp_packet_l4_type_set(pkt, ODP_PROTO_L4_TYPE_NONE); } void odp_packet_has_flow_hash_clr(odp_packet_t pkt)