From patchwork Tue Dec 2 16:17:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 1732 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 42A357F55; Tue, 2 Dec 2014 17:18:52 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 452757EB0 for ; Tue, 2 Dec 2014 17:18:49 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 02 Dec 2014 08:18:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,501,1413270000"; d="scan'208";a="646961407" Received: from bricha3-mobl3.ger.corp.intel.com ([10.243.20.11]) by orsmga002.jf.intel.com with SMTP; 02 Dec 2014 08:18:19 -0800 Received: by (sSMTP sendmail emulation); Tue, 02 Dec 2014 16:18:19 +0025 From: Bruce Richardson To: dev@dpdk.org Date: Tue, 2 Dec 2014 16:17:58 +0000 Message-Id: <1417537079-476-2-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1417537079-476-1-git-send-email-bruce.richardson@intel.com> References: <1417537079-476-1-git-send-email-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/2] doc: update mbuf section of programmer's guide for 1.8 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In Release 1.8, the mbuf structure was significantly reworked to add extra information, leading to the structure being split across two cache lines, and the data pointer being replaced by an offset. The description of the library in the programmer's guide document needs to be updated to take account of these changes. Signed-off-by: Bruce Richardson Acked-by: Bernard Iremonger --- doc/guides/prog_guide/mbuf_lib.rst | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/guides/prog_guide/mbuf_lib.rst b/doc/guides/prog_guide/mbuf_lib.rst index 4e1ccf0..d6b6e50 100644 --- a/doc/guides/prog_guide/mbuf_lib.rst +++ b/doc/guides/prog_guide/mbuf_lib.rst @@ -37,10 +37,12 @@ The mbuf library provides the ability to allocate and free buffers (mbufs) that may be used by the IntelĀ® DPDK application to store message buffers. The message buffers are stored in a mempool, using the :ref:`Mempool Library `. -A rte_mbuf struct can carry network packet buffers (type is RTE_MBUF_PKT) -or generic control buffers (type is RTE_MBUF_CTRL). +A rte_mbuf struct can carry network packet buffers +or generic control buffers (indicated by the CTRL_MBUF_FLAG). This can be extended to other types. -The rte_mbuf is kept as small as possible (one cache line if possible). +The rte_mbuf header structure is kept as small as possible and currently uses +just two cache lines, with the most frequently used fields being on the first +of the two cache lines. Design of Packet Buffers ------------------------ @@ -57,17 +59,17 @@ the complete separation of the allocation of metadata structures from the alloca The first method was chosen for the IntelĀ® DPDK. The metadata contains control information such as message type, length, -pointer to the start of the data and a pointer for additional mbuf structures allowing buffer chaining. +offset to the start of the data and a pointer for additional mbuf structures allowing buffer chaining. Message buffers that are used to carry network packets can handle buffer chaining where multiple buffers are required to hold the complete packet. -This is the case for jumbo frames that are composed of many mbufs linked together through their pkt.next field. +This is the case for jumbo frames that are composed of many mbufs linked together through their next field. For a newly allocated mbuf, the area at which the data begins in the message buffer is RTE_PKTMBUF_HEADROOM bytes after the beginning of the buffer, which is cache aligned. Message buffers may be used to carry control information, packets, events, and so on between different entities in the system. -Message buffers may also use their data pointers to point to other message buffer data sections or other structures. +Message buffers may also use their buffer pointers to point to other message buffer data sections or other structures. Figure 8 and Figure 9 show some of these scenarios. @@ -109,9 +111,8 @@ Allocating and Freeing mbufs ---------------------------- Allocating a new mbuf requires the user to specify the mempool from which the mbuf should be taken. -For a packet mbuf, it contains one segment, with a length of 0. -The pointer to data is initialized to have some bytes of headroom in the buffer (RTE_PKTMBUF_HEADROOM). -For a control mbuf, it is initialized with data pointing to the beginning of the buffer and a length of zero. +For any newly-allocated mbuf, it contains one segment, with a length of 0. +The offset to data is initialized to have some bytes of headroom in the buffer (RTE_PKTMBUF_HEADROOM). Freeing a mbuf means returning it into its original mempool. The content of an mbuf is not modified when it is stored in a pool (as a free mbuf). @@ -151,7 +152,8 @@ Direct and Indirect Buffers --------------------------- A direct buffer is a buffer that is completely separate and self-contained. -An indirect buffer behaves like a direct buffer but for the fact that the data pointer it contains points to data in another direct buffer. +An indirect buffer behaves like a direct buffer but for the fact that the buffer pointer and +data offset in it refer to data in another direct buffer. This is useful in situations where packets need to be duplicated or fragmented, since indirect buffers provide the means to reuse the same packet data across multiple buffers.