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 71FEC5927 for ; Tue, 7 Mar 2017 12:33:20 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2017 03:33:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,258,1484035200"; d="scan'208";a="831864200" Received: from sivswdev01.ir.intel.com ([10.237.217.45]) by FMSMGA003.fm.intel.com with ESMTP; 07 Mar 2017 03:33:02 -0800 From: Bruce Richardson To: olivier.matz@6wind.com Cc: jerin.jacob@caviumnetworks.com, dev@dpdk.org, Bruce Richardson Date: Tue, 7 Mar 2017 11:32:05 +0000 Message-Id: <20170307113217.11077-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20170307113217.11077-1-bruce.richardson@intel.com> References: <20170223172407.27664-1-bruce.richardson@intel.com> <20170307113217.11077-1-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH v2 02/14] ring: create common structure for prod and cons metadata 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: Tue, 07 Mar 2017 11:33:20 -0000 create a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask. Signed-off-by: Bruce Richardson --- V2: renamed the shared structure based on maintainer feedback. --- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index 399ae3b..659c6d0 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,6 +147,19 @@ struct rte_memzone; /* forward declaration, so as not to require memzone.h */ #define CONS_ALIGN RTE_CACHE_LINE_SIZE #endif +/* structure to hold a pair of head/tail values and other metadata */ +struct rte_ring_headtail { + volatile uint32_t head; /**< Prod/consumer head. */ + volatile uint32_t tail; /**< Prod/consumer tail. */ + uint32_t size; /**< Size of ring. */ + uint32_t mask; /**< Mask (size-1) of ring. */ + union { + uint32_t sp_enqueue; /**< True, if single producer. */ + uint32_t sc_dequeue; /**< True, if single consumer. */ + }; + uint32_t watermark; /**< Max items before EDQUOT in producer. */ +}; + /** * An RTE ring structure. * @@ -169,23 +182,10 @@ struct rte_ring { /**< Memzone, if any, containing the rte_ring */ /** Ring producer status. */ - struct prod { - uint32_t watermark; /**< Maximum items before EDQUOT. */ - uint32_t sp_enqueue; /**< True, if single producer. */ - uint32_t size; /**< Size of ring. */ - uint32_t mask; /**< Mask (size-1) of ring. */ - volatile uint32_t head; /**< Producer head. */ - volatile uint32_t tail; /**< Producer tail. */ - } prod __rte_aligned(PROD_ALIGN); + struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN); /** Ring consumer status. */ - struct cons { - uint32_t sc_dequeue; /**< True, if single consumer. */ - uint32_t size; /**< Size of the ring. */ - uint32_t mask; /**< Mask (size-1) of ring. */ - volatile uint32_t head; /**< Consumer head. */ - volatile uint32_t tail; /**< Consumer tail. */ - } cons __rte_aligned(CONS_ALIGN); + struct rte_ring_headtail cons __rte_aligned(CONS_ALIGN); #ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE]; -- 2.9.3