From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ACECAA2EDB for ; Mon, 30 Sep 2019 17:27:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5FD01BECC; Mon, 30 Sep 2019 17:27:37 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 077351BE9C for ; Mon, 30 Sep 2019 17:27:31 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id e5so4042354pls.9 for ; Mon, 30 Sep 2019 08:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gRflN8H9eElX6H7evRBTF7Kb/KaGOFgABWhGCuz163Y=; b=fSIn+IcqONwmPLsJ5hCNKfAnrU5Nt4EmnwHOapCBl+bickLfs2iBdIf64tIUsZml09 aOfzt8+rwjXGUJc8NEQTehSo92/o/eWb7nOSXc3Lmwy8HImORdahTs7bTmC+0mJUkh0K pYKxJtOy2goYF0WIRMIa9bOiKHLV+LaFniQWn4wsEAeVv4vsWTWDyWASwSQrEnxaaqQZ Q770TukwInmt0i0eGvVeCxnnNEw4hV/frHo/pfhjFGpKdFJ6EB89Pgq0VB0DW3gB44KK 9jBFikv00a1JlO7HIcqg7iCfwsBPPhhZpbgwzYUImFGYJH2tLdD/S73W/Xh8X51pKHR8 IuSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gRflN8H9eElX6H7evRBTF7Kb/KaGOFgABWhGCuz163Y=; b=qUMif+AGaGpWMBd+mTzDEqRRjrr7IeHqNdEbrToOmWOLw5S1TLKzwXjLjPFC9KHh0b bsIB7cMCtqZkfZUmFtvbWgpBs3gQy3rrm5uKmf5FM4Ji3bjOjA2/DpawgphHUzzL9BNx iYkN6EqgN+GCd2vzxF+Extyha+nHSiV7jVXBu+V1jZPpKGiIkbjn8MzUG5E1qC/zS54n XWGUP/ZIy3gAVMpAT37KpoNQ3rd7hXx4jTvj8X943oXi/SBoEzjRZtB7e0qcQUL0ocp5 7SBzDLg8ToAKPOPFPuJxN/5Q++GUwS+LnReOVFf2Wk0POzgdBI746DC7D91mQK902IMh NEgg== X-Gm-Message-State: APjAAAW/wJ7tQ4+AKRcdSiG3eGtHrqPiKnqCKcy374S3F3oATd3dARi/ PuNYaP/bCpx8Am5wJ5BXazxV71iYU+E= X-Google-Smtp-Source: APXvYqzv77gjgLV+EUp75B2c1/eK9Crc3J0KO628JLrNdSpt+hAZh9GyWAF2c/qutOCkwnIW/aYudA== X-Received: by 2002:a17:902:7045:: with SMTP id h5mr20458784plt.161.1569857250798; Mon, 30 Sep 2019 08:27:30 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id w14sm30521021pge.56.2019.09.30.08.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:27:29 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 30 Sep 2019 08:27:17 -0700 Message-Id: <20190930152721.8029-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930152721.8029-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20190930152721.8029-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 2/6] mbuf: delinline rte_pktmbuf_linearize X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This function is too big to be put inline. The places it is used are only in special exception paths where a highly fragmented mbuf arrives at a device that can't handle it. Signed-off-by: Stephen Hemminger --- lib/librte_mbuf/rte_mbuf.c | 40 ++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf.h | 40 ++-------------------------- lib/librte_mbuf/rte_mbuf_version.map | 6 +++++ 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 37718d49c148..922bce6f0f93 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -245,6 +245,46 @@ int rte_mbuf_check(const struct rte_mbuf *m, int is_header, return 0; } +/* convert multi-segment mbuf to single mbuf */ +int +rte_pktmbuf_linearize(struct rte_mbuf *mbuf) +{ + size_t seg_len, copy_len; + struct rte_mbuf *m; + struct rte_mbuf *m_next; + char *buffer; + + if (rte_pktmbuf_is_contiguous(mbuf)) + return 0; + + /* Extend first segment to the total packet length */ + copy_len = rte_pktmbuf_pkt_len(mbuf) - rte_pktmbuf_data_len(mbuf); + + if (unlikely(copy_len > rte_pktmbuf_tailroom(mbuf))) + return -1; + + buffer = rte_pktmbuf_mtod_offset(mbuf, char *, mbuf->data_len); + mbuf->data_len = (uint16_t)(mbuf->pkt_len); + + /* Append data from next segments to the first one */ + m = mbuf->next; + while (m != NULL) { + m_next = m->next; + + seg_len = rte_pktmbuf_data_len(m); + rte_memcpy(buffer, rte_pktmbuf_mtod(m, char *), seg_len); + buffer += seg_len; + + rte_pktmbuf_free_seg(m); + m = m_next; + } + + mbuf->next = NULL; + mbuf->nb_segs = 1; + + return 0; +} + /* dump a mbuf on console */ void rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 98225ec80bf1..d25356b58cba 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -2412,44 +2412,8 @@ rte_validate_tx_offload(const struct rte_mbuf *m) * - 0, on success * - -1, on error */ -static inline int -rte_pktmbuf_linearize(struct rte_mbuf *mbuf) -{ - size_t seg_len, copy_len; - struct rte_mbuf *m; - struct rte_mbuf *m_next; - char *buffer; - - if (rte_pktmbuf_is_contiguous(mbuf)) - return 0; - - /* Extend first segment to the total packet length */ - copy_len = rte_pktmbuf_pkt_len(mbuf) - rte_pktmbuf_data_len(mbuf); - - if (unlikely(copy_len > rte_pktmbuf_tailroom(mbuf))) - return -1; - - buffer = rte_pktmbuf_mtod_offset(mbuf, char *, mbuf->data_len); - mbuf->data_len = (uint16_t)(mbuf->pkt_len); - - /* Append data from next segments to the first one */ - m = mbuf->next; - while (m != NULL) { - m_next = m->next; - - seg_len = rte_pktmbuf_data_len(m); - rte_memcpy(buffer, rte_pktmbuf_mtod(m, char *), seg_len); - buffer += seg_len; - - rte_pktmbuf_free_seg(m); - m = m_next; - } - - mbuf->next = NULL; - mbuf->nb_segs = 1; - - return 0; -} +int +rte_pktmbuf_linearize(struct rte_mbuf *mbuf); /** * Dump an mbuf structure to a file. diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map index 2662a37bf674..528681ba263a 100644 --- a/lib/librte_mbuf/rte_mbuf_version.map +++ b/lib/librte_mbuf/rte_mbuf_version.map @@ -46,6 +46,12 @@ DPDK_18.08 { rte_pktmbuf_pool_create_by_ops; } DPDK_16.11; +DPDK_19.11 { + global: + + rte_pktmbuf_linearize; +} DPDK_18.08; + EXPERIMENTAL { global: -- 2.20.1