From patchwork Thu Feb 8 15: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: 127671 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1567950ljc; Thu, 8 Feb 2018 07:01:51 -0800 (PST) X-Google-Smtp-Source: AH8x227LNJ+bMAoLH6AqKwRWyGRuRHe4hH02dOUdxp9gZBgGzEy1OkGeQctKpirGROkLUY9RXrBa X-Received: by 10.37.44.22 with SMTP id s22mr686674ybs.248.1518102111574; Thu, 08 Feb 2018 07:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518102111; cv=none; d=google.com; s=arc-20160816; b=VZxcI9qAha7PrSAO9uUhf766jhsrjdhZe826CWuk/349B+2BvKg+kKfOtdkuUPPDi+ rlD+B1jfMYgvBuC49iBM0TypGj369spq6KboToHIcFzgSZ6My9T4U6cw7sX7dHz6d62n Zau4zTeoMPyvqkNPl3ZDZ3f/AWWS/3M8BgPehkQkiWv+uiZ1sv6rECyc5UE/wiwZcFTK IOm+qjXui74Gp/rKZH4IM8lD1BASQlqueWydmxMDsF+Opp6LqDr+PkO1/zqqpq78WGBp qfVFESvhgKua+jWmP42qt/CHXdoRC0kNsqIDA7efnMqLssB412g49zPfnvhytnvwWha7 Khwg== 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=LFK5hQmIx3xdmRVNmWqTaDI03t1ErGiXjZywjyIaRgY=; b=VzCSwTV8rwlebTe2rd27GnEN4Y6T2N13lSd1A8lHkzgPmbqxTs0VPVC1apzDYjbYVJ WiC9y/uaPm+TXNvIi9GiC48xKShmHODAcyzXExOn3/0IMGFveXMwxTmjvXOmItoO4bhV ZlDqr84emN2QqCgkmaGCSEQs56Gs2JOFxVyxmol0rExEKfX7hA6qC8+I5isQz9BEbvbB 0tBD7A3z2bN8IL39v0OrNTaCIdFraQsYFWm9Dge5qhMg+Jwve58MUj2d/PRRsQdK9l8d 4JPhwYa8b/Gso/edUPiKLvn3Kqy0a+JBObrhu8xP1cz+Rjo3JFFMw/Yv+lvbGiAK5ckZ U6Jw== 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 205si93589qkn.388.2018.02.08.07.01.51; Thu, 08 Feb 2018 07:01:51 -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 344E7617F1; Thu, 8 Feb 2018 15:01:51 +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 2746F616E3; Thu, 8 Feb 2018 15:00:53 +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 B6FC7608C3; Thu, 8 Feb 2018 15:00:39 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id D9D68617EF for ; Thu, 8 Feb 2018 15:00:13 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 5F49D44463F4 for ; Thu, 8 Feb 2018 18:00:12 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jy2baiINo5-0C50Oj0m; Thu, 08 Feb 2018 18:00:12 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id gewqgjGlTb-0BnSjMU3; Thu, 08 Feb 2018 18:00:11 +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 18:00:07 +0300 Message-Id: <1518102010-6353-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> References: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 461 Subject: [lng-odp] [PATCH v1 1/4] linux-gen: packet: optimize parse ipv4 and udp 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: Petri Savolainen Optimize IPv4 and UDP parse functions. Signed-off-by: Petri Savolainen --- /** Email created from pull request 461 (psavol:master-parse-optim) ** https://github.com/Linaro/odp/pull/461 ** Patch: https://github.com/Linaro/odp/pull/461.patch ** Base sha: 257b08b35ceea41bad5a7f1c626496cf111e657a ** Merge commit sha: e004cabc6971bf41b8674db708fd8eaa543f7dae **/ platform/linux-generic/odp_packet.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 9c3be1bcc..92a64801f 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1988,15 +1988,15 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, uint32_t *offset, uint32_t frame_len) { const _odp_ipv4hdr_t *ipv4 = (const _odp_ipv4hdr_t *)*parseptr; - uint8_t ver = _ODP_IPV4HDR_VER(ipv4->ver_ihl); - uint8_t ihl = _ODP_IPV4HDR_IHL(ipv4->ver_ihl); - uint16_t frag_offset; uint32_t dstaddr = _odp_be_to_cpu_32(ipv4->dst_addr); uint32_t l3_len = _odp_be_to_cpu_16(ipv4->tot_len); + uint16_t frag_offset = _odp_be_to_cpu_16(ipv4->frag_offset); + uint8_t ver = _ODP_IPV4HDR_VER(ipv4->ver_ihl); + uint8_t ihl = _ODP_IPV4HDR_IHL(ipv4->ver_ihl); - if (odp_unlikely(ihl < _ODP_IPV4HDR_IHL_MIN) || - odp_unlikely(ver != 4) || - (l3_len > frame_len - *offset)) { + if (odp_unlikely(ihl < _ODP_IPV4HDR_IHL_MIN || + ver != 4 || + (l3_len > frame_len - *offset))) { prs->error_flags.ip_err = 1; return 0; } @@ -2012,13 +2012,15 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, * OR * "fragment offset" field is nonzero (all fragments except the first) */ - frag_offset = _odp_be_to_cpu_16(ipv4->frag_offset); if (odp_unlikely(_ODP_IPV4HDR_IS_FRAGMENT(frag_offset))) prs->input_flags.ipfrag = 1; /* Handle IPv4 broadcast / multicast */ - prs->input_flags.ip_bcast = (dstaddr == 0xffffffff); - prs->input_flags.ip_mcast = (dstaddr >> 28) == 0xd; + if (odp_unlikely(dstaddr == 0xffffffff)) + prs->input_flags.ip_bcast = 1; + + if (odp_unlikely((dstaddr >> 28) == 0xd)) + prs->input_flags.ip_mcast = 1; return ipv4->proto; } @@ -2107,17 +2109,16 @@ static inline void parse_tcp(packet_parser_t *prs, /** * Parser helper function for UDP */ -static inline void parse_udp(packet_parser_t *prs, - const uint8_t **parseptr, uint32_t *offset) +static inline void parse_udp(packet_parser_t *prs, const uint8_t **parseptr) { const _odp_udphdr_t *udp = (const _odp_udphdr_t *)*parseptr; uint32_t udplen = _odp_be_to_cpu_16(udp->length); + uint16_t ipsec_port = _odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT); if (odp_unlikely(udplen < sizeof(_odp_udphdr_t))) prs->error_flags.udp_err = 1; - if (_odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) == udp->dst_port && - udplen > 4) { + if (odp_unlikely(ipsec_port == udp->dst_port && udplen > 4)) { uint32_t val; memcpy(&val, udp + 1, 4); @@ -2127,8 +2128,6 @@ static inline void parse_udp(packet_parser_t *prs, } } - if (offset) - *offset += sizeof(_odp_udphdr_t); *parseptr += sizeof(_odp_udphdr_t); } @@ -2142,7 +2141,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, prs->l3_offset = offset; - if (layer <= ODP_PROTO_LAYER_L2) + if (odp_unlikely(layer <= ODP_PROTO_LAYER_L2)) return prs->error_flags.all != 0; /* Set l3 flag only for known ethtypes */ @@ -2203,7 +2202,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, if (odp_unlikely(offset + _ODP_UDPHDR_LEN > seg_len)) return -1; prs->input_flags.udp = 1; - parse_udp(prs, &parseptr, NULL); + parse_udp(prs, &parseptr); break; case _ODP_IPPROTO_AH: @@ -2232,7 +2231,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, * Parse common packet headers up to given layer * * The function expects at least PACKET_PARSE_SEG_LEN bytes of data to be - * available from the ptr. + * available from the ptr. Also parse metadata must be already initialized. */ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, uint32_t frame_len, uint32_t seg_len, From patchwork Thu Feb 8 15:00:08 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: 127672 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1569098ljc; Thu, 8 Feb 2018 07:02:47 -0800 (PST) X-Google-Smtp-Source: AH8x227YdKnk1fp+m0I0phPXgpA/PhIZgQL2vRIM8M+2VPBM5arUCwRuPHr7+9PzUtvMkOIJvCZ0 X-Received: by 10.200.8.15 with SMTP id u15mr1583064qth.315.1518102166847; Thu, 08 Feb 2018 07:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518102166; cv=none; d=google.com; s=arc-20160816; b=a/B4TOd3Dj45O/NEinlBvruPLYTsiQS8N1PM7V3HpdqOkhdFGVwPsbE4TN8GUFe6nM aAwZE63paNOE7W3vLg7BV5lkG1xoTV4wLTB2CmUp75bZEtL7m/fHV0r/ZRq0gf4QI9XL 8gbZMYfv4zdiUAySL9y9sKkbXGqrlT5udA3fHDu58eCF38X0m445LV7eZiZVOi0/OD7r Rv2bavaq55DvfJ6d3rHrKrLjf9Ui3JKAq0wcRq+YQTrcyLh4I5lskcTG8Lqlud3zIJbE LImWOpvM47qowPNLTAGfAeRv1+T/+0UNqtM0oo3q7MdUWrsbXIAz/hRkx3ozIHn79dyn gqGA== 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=Wco3Xg2hbNTcJX2+KuNYjqYFKFaOdXRQWIFFtO1IfyM=; b=R9VPCNKJDaxIoNZPbthJMAYMSurGC8CwhbGfpgkf6GvM7KqArvNcueF5Tu4EOJWNAw UWgPMWdPnrUsYt3YG6/Fo4ihWRP7TzgXhOWGxdauaVB07/Kxh1YJX+brGOqIe/5ktThC xc8eU7KP2Nc4F3bCLZEe15DIAcr4J2U4NR4ebX8J36/IU4PvEMwzR52yATgsj+4a9fbt LPHc3agIomq5QV0hv+f7y1JqPq3cYN4+ygFIORPFWqcE91fE3pFvIlnzYTJ1vRWP6WF/ HrXNr7If2lQgqAdrmEFh6g3N2Ir9W4L4fC+r6dpO+DB6b6yEuYcXkBQqBZVpxva4e9jd dEXg== 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 y12si94693qkl.428.2018.02.08.07.02.38; Thu, 08 Feb 2018 07:02:46 -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 676E0617ED; Thu, 8 Feb 2018 15:02:38 +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 739AF61761; Thu, 8 Feb 2018 15:00:57 +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 16234608C3; Thu, 8 Feb 2018 15:00:40 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id E4E69617F5 for ; Thu, 8 Feb 2018 15:00:14 +0000 (UTC) Received: from mxback4j.mail.yandex.net (mxback4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10d]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 248E85D85CCA for ; Thu, 8 Feb 2018 18:00:13 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback4j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id hhkloRyYwT-0CjWALjO; Thu, 08 Feb 2018 18:00:13 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id gewqgjGlTb-0CnekRBx; Thu, 08 Feb 2018 18:00:12 +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 18:00:08 +0300 Message-Id: <1518102010-6353-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> References: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 461 Subject: [lng-odp] [PATCH v1 2/4] linux-gen: packet: optimize tcp parse 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: Petri Savolainen Signed-off-by: Petri Savolainen --- /** Email created from pull request 461 (psavol:master-parse-optim) ** https://github.com/Linaro/odp/pull/461 ** Patch: https://github.com/Linaro/odp/pull/461.patch ** Base sha: 257b08b35ceea41bad5a7f1c626496cf111e657a ** Merge commit sha: e004cabc6971bf41b8674db708fd8eaa543f7dae **/ .../include/odp/api/plat/packet_inline_types.h | 1 - platform/linux-generic/odp_packet.c | 14 +++++--------- 2 files changed, 5 insertions(+), 10 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 47ec821c9..984783d5d 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 @@ -101,7 +101,6 @@ typedef union { 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 */ diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 92a64801f..480cea194 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2091,19 +2091,15 @@ static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr, /** * Parser helper function for TCP */ -static inline void parse_tcp(packet_parser_t *prs, - const uint8_t **parseptr, uint32_t *offset) +static inline void parse_tcp(packet_parser_t *prs, const uint8_t **parseptr) { const _odp_tcphdr_t *tcp = (const _odp_tcphdr_t *)*parseptr; + uint32_t len = tcp->hl * 4; - if (tcp->hl < sizeof(_odp_tcphdr_t) / sizeof(uint32_t)) + if (odp_unlikely(tcp->hl < sizeof(_odp_tcphdr_t) / sizeof(uint32_t))) prs->error_flags.tcp_err = 1; - else if ((uint32_t)tcp->hl * 4 > sizeof(_odp_tcphdr_t)) - prs->input_flags.tcpopt = 1; - if (offset) - *offset += (uint32_t)tcp->hl * 4; - *parseptr += (uint32_t)tcp->hl * 4; + *parseptr += len; } /** @@ -2195,7 +2191,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, if (odp_unlikely(offset + _ODP_TCPHDR_LEN > seg_len)) return -1; prs->input_flags.tcp = 1; - parse_tcp(prs, &parseptr, NULL); + parse_tcp(prs, &parseptr); break; case _ODP_IPPROTO_UDP: From patchwork Thu Feb 8 15:00:09 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: 127674 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1570359ljc; Thu, 8 Feb 2018 07:03:51 -0800 (PST) X-Google-Smtp-Source: AH8x226AMK/lzF0l4cPPKwkjkJpTzqdNXDm+fwMt7tZy/FHZzVgApvMUNowIPowLIFNOCgzfrXfW X-Received: by 10.37.65.197 with SMTP id o188mr730201yba.302.1518102231774; Thu, 08 Feb 2018 07:03:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518102231; cv=none; d=google.com; s=arc-20160816; b=OvP4/Jg6lGTNs4/Feex7oImyXn8mTVnHNqBP+TfTyAhKnDKVW1I5X0+oqi+apefX4n /NyKuxkKE8rNBoX7MNEpa6cRvn2jG7lZQQ5UfeKCSqIa9CcNaVDglLjGMVpuVzeMyie8 8dO2BgnvexZSLiUeHlF3oph4qMVzZP7hN3N3q176X/pDTSwLh5x6eDYpwiFemNRQybJD u2MWjSc02FKUf4AIjUQ+IaFECzT1MZnhc5Ntq9Q22dLoS9435KnqOjTWTGIbczCXqQLr v4XQsmv4TkiCEHkhnX5l0ql5dj3b/in+diZMOyAXs+LWiTmta5snHjmoEAutPkwmw1Sg oLDw== 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=svUbAsMYdL+gMEeyMebz/EyawLPn+7OHuM2qwqEkzho=; b=SOie3BUvyNB960pOULfkfpiUWSzxSRuoXU3SS+/CkjRwbYfJPi7+LjYZ2hrEAk7aAu enBnp3IxbnvTA70IO/QKXW8c2UzGupibdxlzsorCTAoOUw78CC1jctq+n8enh+CqNmiS wTqkABogaKpddx60KnuBwzKHqUGji/UOzYLeJSlWF2sezFLwwi6dnl8shrg7fq3d9H7g pZmPV7xLPiuPcrAth+zkXHzT2mOwgcSeNkfTL3s7eYuJS9ma54nrXC0O00wL3gfTRvKs AOPxXJp3/BZXH17+rTH8HUMJweN2YA65QBbEnNxeHXkV7boXdNT1qBMPLYtJnFO9MinD Nf4g== 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 h68si119113qkd.81.2018.02.08.07.03.50; Thu, 08 Feb 2018 07:03:51 -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 A749A61805; Thu, 8 Feb 2018 15:03:50 +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 05976617E2; Thu, 8 Feb 2018 15:01:04 +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 29CF76081B; Thu, 8 Feb 2018 15:00:46 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 432B2617F8 for ; Thu, 8 Feb 2018 15:00:15 +0000 (UTC) Received: from mxback5j.mail.yandex.net (mxback5j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10e]) by forward102p.mail.yandex.net (Yandex) with ESMTP id B0D94430616F for ; Thu, 8 Feb 2018 18:00:13 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback5j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id BH53hZt35l-0D5amXDG; Thu, 08 Feb 2018 18:00:13 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id gewqgjGlTb-0DnSRMIi; Thu, 08 Feb 2018 18:00:13 +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 18:00:09 +0300 Message-Id: <1518102010-6353-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> References: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 461 Subject: [lng-odp] [PATCH v1 3/4] linux-gen: packet: optimize parse eth 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: Petri Savolainen Optimize parse ethernet function. Signed-off-by: Petri Savolainen --- /** Email created from pull request 461 (psavol:master-parse-optim) ** https://github.com/Linaro/odp/pull/461 ** Patch: https://github.com/Linaro/odp/pull/461.patch ** Base sha: 257b08b35ceea41bad5a7f1c626496cf111e657a ** Merge commit sha: e004cabc6971bf41b8674db708fd8eaa543f7dae **/ platform/linux-generic/odp_packet.c | 46 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 480cea194..b2a22903c 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1917,28 +1917,33 @@ static inline uint16_t parse_eth(packet_parser_t *prs, const uint8_t **parseptr, const _odp_ethhdr_t *eth; uint16_t macaddr0, macaddr2, macaddr4; const _odp_vlanhdr_t *vlan; + _odp_packet_input_flags_t input_flags; - /* Detect jumbo frames */ - if (frame_len > _ODP_ETH_LEN_MAX) - prs->input_flags.jumbo = 1; + input_flags.all = 0; + input_flags.l2 = 1; + input_flags.eth = 1; eth = (const _odp_ethhdr_t *)*parseptr; + /* Detect jumbo frames */ + if (odp_unlikely(frame_len > _ODP_ETH_LEN_MAX)) + input_flags.jumbo = 1; + /* Handle Ethernet broadcast/multicast addresses */ macaddr0 = _odp_be_to_cpu_16(*((const uint16_t *)(const void *)eth)); - prs->input_flags.eth_mcast = (macaddr0 & 0x0100) == 0x0100; + if (odp_unlikely((macaddr0 & 0x0100) == 0x0100)) + input_flags.eth_mcast = 1; - if (macaddr0 == 0xffff) { + if (odp_unlikely(macaddr0 == 0xffff)) { macaddr2 = _odp_be_to_cpu_16(*((const uint16_t *) (const void *)eth + 1)); macaddr4 = _odp_be_to_cpu_16(*((const uint16_t *) (const void *)eth + 2)); - prs->input_flags.eth_bcast = - (macaddr2 == 0xffff) && (macaddr4 == 0xffff); - } else { - prs->input_flags.eth_bcast = 0; + + if ((macaddr2 == 0xffff) && (macaddr4 == 0xffff)) + input_flags.eth_bcast = 1; } /* Get Ethertype */ @@ -1947,11 +1952,12 @@ static inline uint16_t parse_eth(packet_parser_t *prs, const uint8_t **parseptr, *parseptr += sizeof(*eth); /* Check for SNAP vs. DIX */ - if (ethtype < _ODP_ETH_LEN_MAX) { - prs->input_flags.snap = 1; + if (odp_unlikely(ethtype < _ODP_ETH_LEN_MAX)) { + input_flags.snap = 1; if (ethtype > frame_len - *offset) { prs->error_flags.snap_len = 1; - return 0; + ethtype = 0; + goto error; } ethtype = _odp_be_to_cpu_16(*((const uint16_t *)(uintptr_t) (parseptr + 6))); @@ -1960,9 +1966,9 @@ static inline uint16_t parse_eth(packet_parser_t *prs, const uint8_t **parseptr, } /* Parse the VLAN header(s), if present */ - if (ethtype == _ODP_ETHTYPE_VLAN_OUTER) { - prs->input_flags.vlan_qinq = 1; - prs->input_flags.vlan = 1; + if (odp_unlikely(ethtype == _ODP_ETHTYPE_VLAN_OUTER)) { + input_flags.vlan_qinq = 1; + input_flags.vlan = 1; vlan = (const _odp_vlanhdr_t *)*parseptr; ethtype = _odp_be_to_cpu_16(vlan->type); @@ -1971,13 +1977,16 @@ static inline uint16_t parse_eth(packet_parser_t *prs, const uint8_t **parseptr, } if (ethtype == _ODP_ETHTYPE_VLAN) { - prs->input_flags.vlan = 1; + input_flags.vlan = 1; vlan = (const _odp_vlanhdr_t *)*parseptr; ethtype = _odp_be_to_cpu_16(vlan->type); *offset += sizeof(_odp_vlanhdr_t); *parseptr += sizeof(_odp_vlanhdr_t); } +error: + prs->input_flags.all |= input_flags.all; + return ethtype; } @@ -2240,14 +2249,11 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, parseptr = ptr; offset = 0; - if (layer == ODP_PROTO_LAYER_NONE) + if (odp_unlikely(layer == ODP_PROTO_LAYER_NONE)) return 0; /* Assume valid L2 header, no CRC/FCS check in SW */ prs->l2_offset = offset; - prs->input_flags.l2 = 1; - /* We only support Ethernet for now */ - prs->input_flags.eth = 1; ethtype = parse_eth(prs, &parseptr, &offset, frame_len); From patchwork Thu Feb 8 15:00:10 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: 127673 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1570112ljc; Thu, 8 Feb 2018 07:03:37 -0800 (PST) X-Google-Smtp-Source: AH8x225xrLzm2AzzmusmUERff8+8KFociBL3+cyk+UaJQuMWwb1utHCkCzUOAnuZwsT8wqFGrlAy X-Received: by 10.237.34.10 with SMTP id n10mr1617666qtc.105.1518102217149; Thu, 08 Feb 2018 07:03:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518102217; cv=none; d=google.com; s=arc-20160816; b=oSQZz70QQjf09PHarLyhGfc+NWiEXN40QKXdCH6CGrCCpC36/u8lGr/n0BS/O9ka0r bTGIgiA9P8T/MG+bDSmW32kpRdGjVGkwQrPYkRbbIOvxw8zJo9NSmCA5KzxtiVICTaES tqe3vYr+U1X1AaBBR8ANiSk37eAFb0y2KwBmdMycJ645zJc1WtQvjsysr1WVCtBEV4N1 L3Ky/oOQCxVi6JNhDaz4QM7kFwYLovHHKuKfFPgV+lIn69KMngaCG+/fp6JuE5sbhPVe b1QbSvx5BsJm5GsKi/w7wAHzKx3TPESIvoztJHWtIrkZzTpAdGrvYt+AumcHHdFPHNX8 uUzQ== 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=lvEPMmQxZJhSkc87bRzCQtVxVtI94maf4eM7eEqxD+w=; b=CyHAHPRlOryBMKo5+4DUULjei260un0s6/hu1Z2uGw9wj4zxhcJj6lqSK5xFpzsQDl /9+7jl8Cw7BOcrsle0xAayoVcV+iDqMbGtFZlVSv/05Y7yCF9/EdNx41zU/4Zr3q9mAb txa5WndsJ9gkAD3Q+KerUrPy8eGB4JMZQSR5yHATOlJLnA/5JcHTJ+lWA94LxeVkuATR l6hMxiU8F+ggKs7zFh3UenpM/zYxnwdBFuLawbQTXPhTSTB4NOYMDsir9ib/NHkfU1LK z/cX5KE7zJkpSwtJeJFMIV+YmO5hVccODU7RyBAImz9g/Enp4qbgIPYtWKteX1/WgW2f HQgg== 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 w41si143626qtc.292.2018.02.08.07.03.36; Thu, 08 Feb 2018 07:03:37 -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 6A4E0617AB; Thu, 8 Feb 2018 15:03:36 +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 B06E8617D4; Thu, 8 Feb 2018 15:00:58 +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 96B85608C3; Thu, 8 Feb 2018 15:00:45 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 14A076063B for ; Thu, 8 Feb 2018 15:00:16 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 66E585603017 for ; Thu, 8 Feb 2018 18:00:14 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id oUisX6ivS3-0EwaRRRI; Thu, 08 Feb 2018 18:00:14 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id gewqgjGlTb-0DniNCgs; Thu, 08 Feb 2018 18:00:13 +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 18:00:10 +0300 Message-Id: <1518102010-6353-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> References: <1518102010-6353-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 461 Subject: [lng-odp] [PATCH v1 4/4] linux-gen: dpdk: optimize mbuf_to_pkt 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: Petri Savolainen Optimize mbuf to packet functions. Read data from pktio structure only once. Prefetch data also in zero copy mode. Signed-off-by: Petri Savolainen --- /** Email created from pull request 461 (psavol:master-parse-optim) ** https://github.com/Linaro/odp/pull/461 ** Patch: https://github.com/Linaro/odp/pull/461.patch ** Base sha: 257b08b35ceea41bad5a7f1c626496cf111e657a ** Merge commit sha: e004cabc6971bf41b8674db708fd8eaa543f7dae **/ platform/linux-generic/pktio/dpdk.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index bd6920e6a..643a8e9b0 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -433,6 +433,8 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, int alloc_len, num; odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; + odp_proto_layer_t parse_layer = pktio_entry->s.config.parser.layer; + odp_pktio_t input = pktio_entry->s.handle; /* Allocate maximum sized packets */ alloc_len = pktio_entry->s.pkt_dpdk.data_room; @@ -474,13 +476,12 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, if (_odp_packet_copy_from_mem(pkt, 0, pkt_len, data) != 0) goto fail; - pkt_hdr->input = pktio_entry->s.handle; + pkt_hdr->input = input; if (pktio_cls_enabled(pktio_entry)) copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); - else if (pktio_entry->s.config.parser.layer) - packet_parse_layer(pkt_hdr, - pktio_entry->s.config.parser.layer); + else if (parse_layer != ODP_PROTO_LAYER_NONE) + packet_parse_layer(pkt_hdr, parse_layer); if (mbuf->ol_flags & PKT_RX_RSS_HASH) packet_set_flow_hash(pkt_hdr, mbuf->hash.rss); @@ -682,6 +683,8 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, int nb_pkts = 0; odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; + odp_proto_layer_t parse_layer = pktio_entry->s.config.parser.layer; + odp_pktio_t input = pktio_entry->s.handle; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -694,6 +697,8 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, } data = rte_pktmbuf_mtod(mbuf, char *); + odp_prefetch(data); + pkt_len = rte_pktmbuf_pkt_len(mbuf); pkt = (odp_packet_t)mbuf->userdata; @@ -714,13 +719,12 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, pkt_hdr->buf_hdr.seg[0].data = data; packet_init(pkt_hdr, pkt_len); - pkt_hdr->input = pktio_entry->s.handle; + pkt_hdr->input = input; if (pktio_cls_enabled(pktio_entry)) copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); - else if (pktio_entry->s.config.parser.layer) - packet_parse_layer(pkt_hdr, - pktio_entry->s.config.parser.layer); + else if (parse_layer != ODP_PROTO_LAYER_NONE) + packet_parse_layer(pkt_hdr, parse_layer); if (mbuf->ol_flags & PKT_RX_RSS_HASH) packet_set_flow_hash(pkt_hdr, mbuf->hash.rss);