From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id D388C7E75 for ; Fri, 24 Oct 2014 10:02:10 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 24 Oct 2014 01:10:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,779,1406617200"; d="scan'208";a="619683165" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 24 Oct 2014 01:10:18 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9O8AFcw004320; Fri, 24 Oct 2014 16:10:15 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s9O8ADYQ024472; Fri, 24 Oct 2014 16:10:15 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9O8AD6j024468; Fri, 24 Oct 2014 16:10:13 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Fri, 24 Oct 2014 16:10:07 +0800 Message-Id: <1414138209-24431-2-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1414138209-24431-1-git-send-email-changchun.ouyang@intel.com> References: <1414138209-24431-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH 1/3] mbuf: Use EXTERNAL_MBUF to indicate external buffer X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Oct 2014 08:02:11 -0000 mbuf uses EXTERNAL_MBUF in ol_flags to indicate it is an external buffer, when freeing such kind of mbuf, just need put mbuf itself back into mempool, doesn't free the attached external buffer, user/caller need take care of detaching and freeing the external buffer. Signed-off-by: Changchun Ouyang --- lib/librte_mbuf/rte_mbuf.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index ddadc21..8cee8fa 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -114,6 +114,9 @@ extern "C" { /* Bit 51 - IEEE1588*/ #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to timestamp. */ +/* Bit 62 - Indicate it is external buffer */ +#define EXTERNAL_MBUF (1ULL << 62) /**< External buffer. */ + /* Use final bit of flags to indicate a control mbuf */ #define CTRL_MBUF_FLAG (1ULL << 63) /**< Mbuf contains control data */ @@ -670,7 +673,7 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) * - detach mbuf * - free attached mbuf segment */ - if (unlikely (md != m)) { + if (unlikely((md != m) && !(m->ol_flags & EXTERNAL_MBUF))) { rte_pktmbuf_detach(m); if (rte_mbuf_refcnt_update(md, -1) == 0) __rte_mbuf_raw_free(md); -- 1.8.4.2