From patchwork Wed Feb 7 11:00:02 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: 127149 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp358328ljc; Wed, 7 Feb 2018 03:05:54 -0800 (PST) X-Google-Smtp-Source: AH8x226s6MUUX3aFEhNLF8GTatIhpQKYzcnV/6VamnT0S/EbvbLmGtYOg1zAJ4Dmkw05dVUNqgv1 X-Received: by 10.55.3.132 with SMTP id 126mr8471023qkd.95.1518001554479; Wed, 07 Feb 2018 03:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518001554; cv=none; d=google.com; s=arc-20160816; b=ZLEpzAunDoWOsk50lPxT/YkNG2ze9rzi8CpNFCEB7Gq6f0QCfCfrGacD88Smo3CTPV jKp43NlqAWlbzMKYKfR4pDcu71FARrtGVm8F8VII19zxZsyX6w8AKSeVYCcX69gfM3CD xGFRZ1G1fh+0vUOklw2DI7OMeIz11eruKUW9oVg62G3eYx0GnN88JNjj3vl958SPzqfq /bIhb2kLO70YHa4SKzKpUCKIUhqPFOhLzYfdL51YEEv2jdJPZEPbp3N9ymbNyDBQvLD6 CByHg90201Q96tYwbRzF+88rEizY/Pjx7pzUCaMZUWhb/vtqr26dxEGkd9S2AeWCYceN iU9g== 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=8tBNoNN4fFm5w7yIC9eGenGj4qyQVe6MSA5S+sUrohw=; b=gOeD2WehzpwFYB7LlSQmVA3tM+uTGWMQeilFfVQZDLFa8Yg2KsC3ZrwvlzfonvXjMj S823nY4/C2DpkQlscQafXemMw7/cHEkBVfZkzmQNLp1rkvRN7Tv7pcy19Nfo0T8tmueZ AoBQkr6Q0imgatOkXFN3jEpKhr0AVLZyXZ5TT08km34CJ9lN6lxnCmdxCGo2nnb6z35e XNRNw1L81cdXYIj/8a2f7nKoqItf6borQcJTMKpU+a7uy0psHlkK04NR09I7xS49C+EP TMlgKOhbbtmYSZIftQkyA1YZEJOMS8HZwnWVFV6tmQpwmkMSoulu1aSdrZB5SYTRuTdN cd8g== 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 d81si1297806qkc.60.2018.02.07.03.05.54; Wed, 07 Feb 2018 03:05:54 -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 E4AED616FF; Wed, 7 Feb 2018 11:05:53 +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 E904162771; Wed, 7 Feb 2018 11:02:39 +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 EFCD5607D5; Wed, 7 Feb 2018 11:02:26 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 9F4DE607D5 for ; Wed, 7 Feb 2018 11:01:28 +0000 (UTC) Received: from mxback3j.mail.yandex.net (mxback3j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10c]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 704AD34C0C96 for ; Wed, 7 Feb 2018 14:01:27 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback3j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id AbNPxrhSo4-1R2WM0sP; Wed, 07 Feb 2018 14:01:27 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id LVw23zZMqp-1KVWeuVn; Wed, 07 Feb 2018 14:01:20 +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 14:00:02 +0300 Message-Id: <1518001208-29529-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518001208-29529-1-git-send-email-odpbot@yandex.ru> References: <1518001208-29529-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 457 Subject: [lng-odp] [PATCH API-NEXT v1 8/14] 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 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: 802ddfc5ea6f47a8935993bf6f8c1675a4c94930 **/ .../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 | 5 ---- platform/linux-generic/odp_packet_flags.c | 33 ++++++++++++++++++---- 6 files changed, 43 insertions(+), 22 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 fce5a730b..14ed13bca 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; @@ -2562,8 +2559,6 @@ void odp_packet_l3_type_set(odp_packet_t pkt, odp_proto_l3_type_t val) odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); pkt_hdr->p.input_flags.l3_type = val; - pkt_hdr->p.input_flags.ipv4 = (val == ODP_PROTO_L3_TYPE_IPV4); - pkt_hdr->p.input_flags.ipv6 = (val == ODP_PROTO_L3_TYPE_IPV6); } odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt) diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index 0c33666eb..ab34d0950 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,32 @@ 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); + + if (val) + odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_ARP); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_ARP) + odp_packet_l3_type_set(pkt, 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); + + if (val) + odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV4); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV4) + odp_packet_l3_type_set(pkt, 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); + + if (val) + odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV6); + else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV6) + odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_NONE); } void odp_packet_has_ip_bcast_set(odp_packet_t pkt, int val)