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 84295A0613 for ; Sat, 28 Sep 2019 02:38:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 293E31BE85; Sat, 28 Sep 2019 02:38:10 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 6EAF12C4F for ; Sat, 28 Sep 2019 02:38:04 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id q5so2414941pfg.13 for ; Fri, 27 Sep 2019 17:38:04 -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=cSmw8GHMDLE+3FOC4N1l6sIkSxQJSZTYxYZ1VcOa21w=; b=ZesqafY2yWDOlPIvftGz6kWYsSK0jXgErr9/ERq9zKfOFlhUFEfNy9ZpfSqd8IkCFY hsTCkbQ6ZNK0sIFoonm2Y0VtiDQgIoj8n3z3089OYQ/Oz5QxviXVf4mX/TosNzI8xbPd W/cZtD6CWFhl4EzoOLqCtIzBE9EL+GPlvRGqmQ7of7QNU0Sk1E4jYrTbbYgm2zJXRhxf aWm7FL2X/ticbV/OyiGoy3KMKpRYYQTmsMqW+/xxSOw81Km8up5AFSGvwJ8UwQD67Qxe oeyG2UQ93dH7WO8zAJFg0WgmqfeLzSYB0t96TQhm7MkW1Zz4rJ8raqDE4ryKqPu7qLVQ mcPw== 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=cSmw8GHMDLE+3FOC4N1l6sIkSxQJSZTYxYZ1VcOa21w=; b=RKwGgFzWUntUfVYZ4mod0LF0YLJ2ybJ81fCe/7j+b+Y6a6ZQrzH0ySJUJosTrPvJa+ ri39XEMUvIz/uohGXYMELG/6baNVTnoEM7w6G73ySD8hBNRhogRTtqX2JvWJdbQ6uB6/ o4NmDhsTvH4mTzV8mPwrrRXWTjYNySA5W6jsUn3l02teONnWIXGkOLGmlmQOOcnxajV7 KJ+73bGW0PGjiG9pT08UYQXw2WEiEutYLcgWx8iggX6s4kZ2aSEZpUR0BOeM13MMKHqf 84KZePvWJLH1jE/K0MByJVLBuyOEjNSpTNEhapANDEV/EKbmdgKE9A+fWauuRC0QxJOq 19/A== X-Gm-Message-State: APjAAAXqprZAU7VDaojxGoE7LqANF58z3xyCOiFX0ir9h0C3K0Zhpgwm c/mWzEPmIlW/kT7X+FWYxTHaBN/mqkc= X-Google-Smtp-Source: APXvYqzC0TiCdNU2j8wpFlQEGnSIMRTvPiEHVEVZyEHyxuPmVPKYCV3yJVhgMQtBU/a2tDQrB6Ti3A== X-Received: by 2002:a62:83cb:: with SMTP id h194mr7759567pfe.66.1569631083296; Fri, 27 Sep 2019 17:38:03 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t13sm3494942pfh.12.2019.09.27.17.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 17:38:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 27 Sep 2019 17:37:55 -0700 Message-Id: <20190928003758.18489-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190928003758.18489-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/5] 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..7af410a4f687 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_18.11 { + global: + + rte_pktmbuf_linearize; +} DPDK_18.08; + EXPERIMENTAL { global: -- 2.20.1