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 21915A2F67 for ; Fri, 4 Oct 2019 23:48:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F35A11C2F2; Fri, 4 Oct 2019 23:47:54 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id A0E791C2E9 for ; Fri, 4 Oct 2019 23:47:52 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id p30so2409477pgl.2 for ; Fri, 04 Oct 2019 14:47:52 -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=GBnlB6HE4E1BFlysCOhAlSDaD0wf14GC+LLwu+S5Axw=; b=r1usrnjdb61jHweUUTw7NEREFvVogDXf7V4TREaOQ4Uq6AARShPNVqLnC44q7wluqd Jl8QL4e0tA0u9recUGTTyiqn31eRSc1r9/XRILiZ9qR/vFW69CakSiPhTMJE9Syw0M9o r1yAIUZ5ysFWDXKMz8agZcPOAY/b46X0wVKLx+5tiV+uXmw3aTReubtSusQ7dK/dQ4Ie Ix7CLMiG6XSkfPMTD5Q37p/ckskX+A/JWW0uz8hTokFIh/GOjrOpNpNkrXYTRz83aOpI 3dJ5QhGuwiCUxqet759Gs/lPVlcNwksDDpLwiAWa83fWmeiqY83vnxf+yQ+ZbbJsiux3 B85w== 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=GBnlB6HE4E1BFlysCOhAlSDaD0wf14GC+LLwu+S5Axw=; b=Jlj4n4orJQ+QB2eaa8i3DZRQ5wopYu5+9Wu2AOUIFv68Z98Gdsl25mgbmWHA+ZjrWU oFr9Wg+khDTVKnMoP30HndTdcZaQB3EVSU39xqet0hdLT/DbFxMNJpgBX1Kh5eq9mLy2 bnFfs6EdPbOGC2A3ni8TNKLNc6XrsJ4ToOuDJxqdOZ8z6YW9wdF3DrJlizktJ7jpn4xB D1sCvwckTGV2ARIKe9A18wq7jXIMN4FadteJB+C4cy+XzpARFWlUCOqG8STBRTR1clNh jcOd5IdwOEZBoYnIybzpXHpT1QeFsRmJu2T+0kbhOMo5WFtmeYNMl3A8CIH/hoHI9wdv k+Yw== X-Gm-Message-State: APjAAAW8HuDOxqU60VPAkxykkwnoLs7UyD58t/TZ94l9fzZouHBts5jB LsV5+bRKRNgQlMHqfFVSPwKX6PWxPoeKcA== X-Google-Smtp-Source: APXvYqz6clsgW7ZCBDfR7vzyWfnBquPxyZjKBBDh6OdIUGrIroZauiANhYVV633154sRDvPpnF95gw== X-Received: by 2002:a63:7b16:: with SMTP id w22mr17636511pgc.328.1570225671413; Fri, 04 Oct 2019 14:47:51 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q71sm6191355pjb.26.2019.10.04.14.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2019 14:47:50 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko Date: Fri, 4 Oct 2019 14:47:41 -0700 Message-Id: <20191004214743.24686-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191004214743.24686-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20191004214743.24686-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 2/4] 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 copy part of 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 Acked-by: Andrew Rybchenko --- lib/librte_mbuf/rte_mbuf.c | 37 +++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf.h | 38 +++++----------------------- lib/librte_mbuf/rte_mbuf_version.map | 6 +++++ 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 37718d49c148..e2c661c97522 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -245,6 +245,43 @@ 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; + + /* 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..bffda1c81fbd 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -2400,6 +2400,11 @@ rte_validate_tx_offload(const struct rte_mbuf *m) return 0; } +/** + * @internal used by rte_pktmbuf_linearize(). + */ +int __rte_pktmbuf_linearize(struct rte_mbuf *mbuf); + /** * Linearize data in mbuf. * @@ -2415,40 +2420,9 @@ rte_validate_tx_offload(const struct rte_mbuf *m) 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; + return __rte_pktmbuf_linearize(mbuf); } /** diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map index 2662a37bf674..4d0bc9772769 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