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);