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 3825CA2EEB for ; Mon, 7 Oct 2019 17:44:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 68E641C1F8; Mon, 7 Oct 2019 17:43:59 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id ACCE41C1C3 for ; Mon, 7 Oct 2019 17:43:54 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id d26so8449300pgl.7 for ; Mon, 07 Oct 2019 08:43:54 -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=CpjYU4SBhIc8K+UDywy/k8cBUWhZQho2tWWs49bLhJdkjYi79WySMDe8hN7t5Di3ee ggChoAcF/ZdTXnFtixrzqH+Exm4kQcxCMLmDdFSb3yl6wshN8w28UTJgl4bH/AXfEzCE Df2VtOPHp/VjJfIJLUPaCAHsyWaoi/bCLvMViLa2Ue6enteXO/xmH7fS1chDkPZZ12zV o4t2FKpJXrJP8cn16qvk/MULP+sUt3/tkfEVWCCWbciiS408qKIteUsO49UJ3XRk1vh8 utBWkiaZGfHhhwY5OIvFMIK5Ev6KBOBDLEwjktrzOzoppYfpWC232LRq9AJ2AX+YY5qV YreQ== 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=Yl4mZpquPC0xrVRwV5A0cZBb9MBmVgvUWrzYZNDZxEjlKJrnlrUsO0MDY8KfMeY/xW B0Yx6UOBJks+Se6o+FEkrxap8QpS4nVPNu8OblLheor0UcKOzmFnHuT/ZThsOjkB1NvB rNK8IfPNeJgnQFsaxSyXlnw5+Aka4bScuLgGYRGTMw138hfsIyK9fDj+6UHO5OW/iRef K4PcQNsi/dtul8aKa+3L+XjJ/2+Z4ztqSt5Why7gL+iFNJNXYUhgADjT1k+R/HXIbIH+ jWeZhSNfSPsh6FondaYWHAdYGMhcHTy8Re2fDSuKedodXeddklV2e7cCsFs8RBv3MmH4 44oA== X-Gm-Message-State: APjAAAXevfam0Jb8fyYZn3f3RReq/mnS6n+olQXrpd5GiT9uNmyIKIHz htTMaRkvNdqyWRvNr1qV2+f6m1ffi+DkBQ== X-Google-Smtp-Source: APXvYqw4Hm+VsPnnrUaOAzjNtz9f/iNVqJwlY2/jKS/AkegWIP3tcZ384gAMiG4cZ8p6GsF7r9Myug== X-Received: by 2002:a63:500e:: with SMTP id e14mr30950091pgb.176.1570463033251; Mon, 07 Oct 2019 08:43:53 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id k5sm20779345pfp.109.2019.10.07.08.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:43:52 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko Date: Mon, 7 Oct 2019 08:43:40 -0700 Message-Id: <20191007154343.8556-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191007154343.8556-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20191007154343.8556-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 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 --- 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