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 0179C333 for ; Tue, 23 Sep 2014 13:02:14 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by fmsmga101.fm.intel.com with ESMTP; 23 Sep 2014 04:08:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,579,1406617200"; d="scan'208";a="479415914" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 23 Sep 2014 04:08:19 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s8NB8IDr012724; Tue, 23 Sep 2014 12:08:18 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s8NB8Ic4010442; Tue, 23 Sep 2014 12:08:18 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s8NB8ITe010438; Tue, 23 Sep 2014 12:08:18 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Tue, 23 Sep 2014 12:08:16 +0100 Message-Id: <1411470497-10209-5-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1411470497-10209-1-git-send-email-bruce.richardson@intel.com> References: <1410948102-12740-1-git-send-email-bruce.richardson@intel.com> <1411470497-10209-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH v2 4/5] mbuf: add userdata pointer field 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: Tue, 23 Sep 2014 11:02:15 -0000 While some applications may store metadata about packets in the packet mbuf headroom, this is not a workable solution for packet metadata which is either: * larger than the headroom (or headroom is needed for adding pkt headers) * needs to be shared or copied among packets To support these use cases in applications, we reserve a general "userdata" pointer field inside the second cache-line of the mbuf. This is better than having the application store the pointer to the external metadata in the packet headroom, as it saves an additional cache-line from being used. Apart from storing metadata, this field also provides a general 8-byte scratch space inside the mbuf for any other application uses that are applicable. Changes in V2: * made the userdata field always have 8-bytes available, even on 32-bit Signed-off-by: Bruce Richardson --- lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 6 ++++-- lib/librte_mbuf/rte_mbuf.h | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index 25ed672..e548161 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -116,8 +116,10 @@ struct rte_kni_mbuf { char pad2[2]; uint16_t data_len; /**< Amount of data in segment buffer. */ uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ - char pad3[8]; - void *pool __attribute__((__aligned__(64))); + + /* fields on second cache line */ + char pad3[8] __attribute__((__aligned__(64))); + void *pool; void *next; }; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 8e27d2e..9e70d3b 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -172,6 +172,12 @@ struct rte_mbuf { /* second cache line - fields only used in slow path or on TX */ MARKER cacheline1 __rte_cache_aligned; + + union { + void *userdata; /**< Can be used for external metadata */ + uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */ + }; + struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ struct rte_mbuf *next; /**< Next segment of scattered packet. */ -- 1.9.3