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 AC3E1A2F6B for ; Tue, 8 Oct 2019 18:34:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6742C1D454; Tue, 8 Oct 2019 18:34:07 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 4D50B1D176 for ; Tue, 8 Oct 2019 18:34:01 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id t3so4697572pga.8 for ; Tue, 08 Oct 2019 09:34:01 -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=yQh5p5nD1cVmY52VYrUOKE5OPsSsIwvktFX/RNjf88c=; b=peazpEMQ1Na5ZsoDlayFDr9w0z3KUge8hYOsS0188jYXxQJlTf/JHWuyDJUVlZMasC Hmnxc5uxIeCVU87Ke4s1fclFgfuySe+Bs3MxoqegItEKmYlSfBE3A62osJS5clo/ZwB1 /5ktBiWPM1tz+BbvzHk1VJ5Pt7j+kuA5s61NTWqXYLqdA81ZEoUvmb0ZVXeX+X/hu+UM MGWCxh87plc0VMAdvidaIVDgngCZqhUsFdXJBSRNtKn/D7o2nCnnyiLQF0LgyATVSCPB 8QuskOtckoPuN1YYHvO33BwHGVDzXCnPE2mGMFBl8Nt/0E7QTVEBO1LLAsRJU/Y6Ap81 RnQA== 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=yQh5p5nD1cVmY52VYrUOKE5OPsSsIwvktFX/RNjf88c=; b=odN2SrzTgTfjvboM0DLg/J1IhKYcZpJz9ydzeD8M/sBtEP/yBmlnwX+ocRVV0D8aDN TLXeltE1ITRKZrMtAjykNY5pLxeFw+jAF/n4+wxmSKTyqkNSDUauRQCZCGP7kV/QjAXx e+WhRZmEzKt99wla/PfqAew4VwT7F7LGv1SgWc4WVAy8TEWXTiUCXiUf5PwYC4f9AXg8 NQVjXSyVaV+dhTaeNEmZSIAnmtsoYQV8gTmmIdPxfmYXgza7/DY0y5EI2H9KFe7tJGqS XGGobzXPyDE9Hov/v95MFBmE0Huf7TOfd8vOKULlq5QL9yU7seLKBFgi108yaIUT0XjL amUQ== X-Gm-Message-State: APjAAAWNbsuCQm0pJJ44FTmJzjOKv/UERk8b6UMFp2XJgl5gRTnKuFoF SJN8/cJ9pyjbu3AvnUWjuGpC6Ftd4Ev84Q== X-Google-Smtp-Source: APXvYqzGVC6mhXaEkbVU9L/B8rH0keT04ag/Fgv57zkHeKCnYeOWYJdV99DS4Jpn/PTYDAnwlIbJBg== X-Received: by 2002:a17:90a:bc49:: with SMTP id t9mr6739197pjv.93.1570552439671; Tue, 08 Oct 2019 09:33:59 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 18sm17702551pfp.100.2019.10.08.09.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 09:33:58 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko , Olivier Matz Date: Tue, 8 Oct 2019 09:33:47 -0700 Message-Id: <20191008163350.20779-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191008163350.20779-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20191008163350.20779-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 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 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 Acked-by: Olivier Matz --- 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