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 5CE82A2EDB for ; Mon, 30 Sep 2019 21:21:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D0E231BE8D; Mon, 30 Sep 2019 21:21:07 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id AAADF5B3C for ; Mon, 30 Sep 2019 21:21:03 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id y22so6155117pfr.3 for ; Mon, 30 Sep 2019 12:21:03 -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=DMtaGL54rpYbgFJ3Nj6b9u9VO3VzDh2cf0qWrQrQF2o=; b=TFrCo3jQfqxkmEgeXH0cild2G5Z1HDH2IQvUruSY0J812hdIVJ48PiRdx3w4URgOjK +izl3LrO1xRHCxdKuwgoeC5GTn48y1nOaHjrMZOjHF/PQ1Hi8PUwNUDX8kqrfoB5p/m/ 9WZmCyyy1GKCTlLREXX20NfoqQdG81QkuiICxywvOQ8H7y4613UZsvfwTdXR7W0naRg4 u1GmUt1SuA3dTdoICkd+OnkDdRiTIzLOhu7mRVdzXRPvBL/WDiioNbZaoOLJWQjPYsPb 6HAeS3Wh80/J7ANcoVSCykXMGzsVTAGWbAVQ32PNlY2aRMfsghHa9nv9Lb0uqcfbgQE3 j8oQ== 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=DMtaGL54rpYbgFJ3Nj6b9u9VO3VzDh2cf0qWrQrQF2o=; b=JJTf7VNLCt2qWm2r6/D2KDV9T1oboUCQ2MRRMBmXW0uqLtZdJx5O60Fu/G3ByAOq7Q eROMAs3FmiEr7vszcd9BdHODeYUIQH3JVlBsOchrTuUIc8AHrWhwLaWgh+a9iNg7ls17 iAlstnsomR0ypIMbV+1kZIHZAXFfi2KRGSLSGVhkQIZ7Pto6wiShCuu97x5zciyGGvxH MaJNb5Y/GyoRUKB525BeHBq5heX+C6/HClgHr+a2N/9O2rvD7wxmDH2YTncmPuXTRh4w xiUJ2/iBIX8O5EHoDEg3HrosLlViC3wteFCMdu378CBr3NJjKYni0KtIumXdz0FqDmP4 7C7w== X-Gm-Message-State: APjAAAXyk4qt0boWzOVBvX2haGXQC4W1GJQUM1CDvtyfqLkbHzMRYmOd Qllee4BiH4Hw5s+WuoQ91RBSAmngZFZXuA== X-Google-Smtp-Source: APXvYqzCn3zgu5pbuWcOk2ubLg9YZk4cx1hGf6GT74C9ITHswInAL3LO5vfoCjXSqCkUSQVvK6MT9w== X-Received: by 2002:a65:6147:: with SMTP id o7mr24742918pgv.97.1569871262322; Mon, 30 Sep 2019 12:21:02 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c64sm14788304pfc.19.2019.09.30.12.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 12:21:01 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 30 Sep 2019 12:20:52 -0700 Message-Id: <20190930192056.26828-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930192056.26828-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20190930192056.26828-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 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 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 --- 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