From patchwork Mon Aug 11 20:44:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 142 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 8E2F7B391 for ; Mon, 11 Aug 2014 22:44:06 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 11 Aug 2014 13:41:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,844,1400050800"; d="scan'208";a="586659689" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 11 Aug 2014 13:44:52 -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 s7BKiqmE020951; Mon, 11 Aug 2014 21:44:52 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s7BKiq4X017681; Mon, 11 Aug 2014 21:44:52 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s7BKiqnB017677; Mon, 11 Aug 2014 21:44:52 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Mon, 11 Aug 2014 21:44:42 +0100 Message-Id: <1407789890-17355-7-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1407789890-17355-1-git-send-email-bruce.richardson@intel.com> References: <1407789890-17355-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [RFC PATCH 06/14] mbuf: reorder fields by time-of-use 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: Mon, 11 Aug 2014 20:44:07 -0000 * Reorder the fields in the mbuf so that we have fields that are used together side-by-side in the structure. This means that we have a contiguous block of 8-bytes in the mbuf which are used to reset an mbuf of descriptor rearm. * Where needed add in a dummy fields to overwrite values 8 or 16 bytes at a time, when doing RX or RX descriptor rearm. This avoids compiler warnings when using uint64_t values to overwrite a set of smaller values. * At the end, place fields that are only used for TX or for the slower RX path, and mark them as down to be moved to a second cache line. Signed-off-by: Bruce Richardson --- lib/librte_mbuf/rte_mbuf.c | 2 +- lib/librte_mbuf/rte_mbuf.h | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 64f1587..594b910 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -161,7 +161,7 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len) fprintf(f, "dump mbuf at 0x%p, phys=%"PRIx64", buf_len=%u\n", m, (uint64_t)m->buf_physaddr, (unsigned)m->buf_len); - fprintf(f, " pkt_len=%"PRIu32", ol_flags=%"PRIx16", nb_segs=%u, " + fprintf(f, " pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, " "in_port=%u\n", m->pkt_len, m->ol_flags, (unsigned)m->nb_segs, (unsigned)m->port); nb_segs = m->nb_segs; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index e0981c9..566bb7e 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -132,22 +132,20 @@ union rte_vlan_macip { /**< MAC+IP length. */ #define TX_MACIP_LEN_CMP_MASK (TX_MAC_LEN_CMP_MASK | TX_IP_LEN_CMP_MASK) + /** * The generic rte_mbuf, containing a packet mbuf. */ struct rte_mbuf { - struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ void *buf_addr; /**< Virtual address of segment buffer. */ phys_addr_t buf_physaddr; /**< Physical address of segment buffer. */ - uint16_t buf_len; /**< Length of segment buffer. */ - /* valid for any segment */ - struct rte_mbuf *next; /**< Next segment of scattered packet. */ + /* next 8 bytes are initialised on RX descriptor rearm */ + uint64_t rearm_data[0]; /**< dummy element so we can get uin64_t ptrs + * to this part of the mbuf without alias error + */ + uint16_t buf_len; /**< Length of segment buffer. */ uint16_t data_off; - uint16_t data_len; /**< Amount of data in segment buffer. */ - uint32_t pkt_len; /**< Total pkt len: sum of all segments. */ - -#ifdef RTE_MBUF_REFCNT /** * 16-bit Reference counter. * It should only be accessed using the following functions: @@ -157,20 +155,23 @@ struct rte_mbuf { * config option. */ union { +#ifdef RTE_MBUF_REFCNT rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */ uint16_t refcnt; /**< Non-atomically accessed refcnt */ - }; -#else - uint16_t refcnt_reserved; /**< Do not use this field */ #endif - - /* these fields are valid for first segment only */ + uint16_t refcnt_reserved; /**< Do not use this field */ + }; uint8_t nb_segs; /**< Number of segments. */ uint8_t port; /**< Input port. */ - uint16_t ol_flags; /**< Offload features. */ - uint16_t reserved; /**< Unused field. Required for padding. */ - /* offload features, valid for first segment only */ + /* remaining bytes are set on RX when pulling packet from descriptor */ + uint64_t ol_flags; /**< Offload features. */ + + __m128i rx_descriptor_fields1[0]; /**< dummy field used as marker for + * writes in a vector driver */ + uint16_t packet_type; /**< Type of packet, e.g. protocols used */ + uint16_t data_len; /**< Amount of data in segment buffer. */ + uint32_t pkt_len; /**< Total pkt len: sum of all segments. */ union rte_vlan_macip vlan_macip; union { uint32_t rss; /**< RSS hash result if RSS enabled */ @@ -181,6 +182,10 @@ struct rte_mbuf { uint32_t sched; /**< Hierarchical scheduler */ } hash; /**< hash information */ + /* second cache line, fields only used in slow path or on TX */ + struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ + struct rte_mbuf *next; /**< Next segment of scattered packet. */ + union { uint8_t metadata[0]; uint16_t metadata16[0];