From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 71A84689B for ; Fri, 2 Dec 2016 18:07:56 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 02 Dec 2016 09:07:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,287,1477983600"; d="scan'208";a="1093750022" Received: from unknown (HELO Sent) ([10.103.102.79]) by fmsmga002.fm.intel.com with SMTP; 02 Dec 2016 09:07:54 -0800 Received: by Sent (sSMTP sendmail emulation); Fri, 02 Dec 2016 18:07:53 +0100 From: Tomasz Kulasek To: dev@dpdk.org Date: Fri, 2 Dec 2016 18:07:43 +0100 Message-Id: <1480698466-17620-2-git-send-email-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1480698466-17620-1-git-send-email-tomaszx.kulasek@intel.com> References: <1480698466-17620-1-git-send-email-tomaszx.kulasek@intel.com> Subject: [dpdk-dev] [PATCH 1/4] rte_mbuf: add rte_pktmbuf_coalesce 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: , X-List-Received-Date: Fri, 02 Dec 2016 17:07:56 -0000 This patch adds function rte_pktmbuf_coalesce to let crypto PMD coalesce chained mbuf before crypto operation and extend their capabilities to support segmented mbufs when device cannot handle them natively. Signed-off-by: Tomasz Kulasek --- lib/librte_mbuf/rte_mbuf.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index ead7c6e..f048681 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -1647,6 +1647,40 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail } /** + * Coalesce data from mbuf to the continuous buffer. + * + * @param mbuf_dst + * Contiguous destination mbuf + * @param mbuf_src + * Uncontiguous source mbuf + * + * @return + * - 0, on success + * - -EINVAL, on error + */ + +#include + +static inline int +rte_pktmbuf_coalesce(struct rte_mbuf *mbuf_dst, struct rte_mbuf *mbuf_src) +{ + char *dst; + + if (!rte_pktmbuf_is_contiguous(mbuf_dst) || + rte_pktmbuf_data_len(mbuf_dst) >= + rte_pktmbuf_pkt_len(mbuf_src)) + return -EINVAL; + + dst = rte_pktmbuf_mtod(mbuf_dst, char *); + + if (!__rte_pktmbuf_read(mbuf_src, 0, rte_pktmbuf_pkt_len(mbuf_src), + dst)) + return -EINVAL; + + return 0; +} + +/** * Dump an mbuf structure to a file. * * Dump all fields for the given packet mbuf and all its associated -- 1.7.9.5