Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/68764/?format=api
http://patches.dpdk.org/api/patches/68764/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200417133639.14019-3-konstantin.ananyev@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20200417133639.14019-3-konstantin.ananyev@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200417133639.14019-3-konstantin.ananyev@intel.com", "date": "2020-04-17T13:36:32", "name": "[v4,2/9] ring: prepare ring to allow new sync schemes", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "ef85ee16b0f436807e668fc0810a434d6528fde2", "submitter": { "id": 33, "url": "http://patches.dpdk.org/api/people/33/?format=api", "name": "Ananyev, Konstantin", "email": "konstantin.ananyev@intel.com" }, "delegate": { "id": 24651, "url": "http://patches.dpdk.org/api/users/24651/?format=api", "username": "dmarchand", "first_name": "David", "last_name": "Marchand", "email": "david.marchand@redhat.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200417133639.14019-3-konstantin.ananyev@intel.com/mbox/", "series": [ { "id": 9464, "url": "http://patches.dpdk.org/api/series/9464/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=9464", "date": "2020-04-17T13:36:30", "name": "New sync modes for ring", "version": 4, "mbox": "http://patches.dpdk.org/series/9464/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/68764/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/68764/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C907AA058A;\n\tFri, 17 Apr 2020 15:37:17 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 7E6641E8C3;\n\tFri, 17 Apr 2020 15:37:08 +0200 (CEST)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id 7774C1E8BF\n for <dev@dpdk.org>; Fri, 17 Apr 2020 15:37:06 +0200 (CEST)", "from orsmga003.jf.intel.com ([10.7.209.27])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 17 Apr 2020 06:37:05 -0700", "from sivswdev08.ir.intel.com ([10.237.217.47])\n by orsmga003.jf.intel.com with ESMTP; 17 Apr 2020 06:37:03 -0700" ], "IronPort-SDR": [ "\n 24dWuEaxfyRHlDq5a3t1l2MjYI2ySucwaXwjZNAriWYEXFV/a4UUIxzR3DpPXMi5cTJxlBquuj\n 1KDaAJ1Ru4PQ==", "\n L5iK5etrc85OaNICMIB98d0wGVCw0emTTuhlpS5p+trZ6bWCxbXGM4U4Pm/LSakVM+nIfAag/8\n 3iSjkms8ALug==" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.72,395,1580803200\"; d=\"scan'208\";a=\"254209909\"", "From": "Konstantin Ananyev <konstantin.ananyev@intel.com>", "To": "dev@dpdk.org", "Cc": "honnappa.nagarahalli@arm.com, david.marchand@redhat.com,\n jielong.zjl@antfin.com, Konstantin Ananyev <konstantin.ananyev@intel.com>", "Date": "Fri, 17 Apr 2020 14:36:32 +0100", "Message-Id": "<20200417133639.14019-3-konstantin.ananyev@intel.com>", "X-Mailer": "git-send-email 2.18.0", "In-Reply-To": "<20200417133639.14019-1-konstantin.ananyev@intel.com>", "References": "<20200403174235.23308-1-konstantin.ananyev@intel.com>\n <20200417133639.14019-1-konstantin.ananyev@intel.com>", "Subject": "[dpdk-dev] [PATCH v4 2/9] ring: prepare ring to allow new sync\n\tschemes", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "To make these preparations two main things are done:\n- Change from *single* to *sync_type* to allow different\n synchronisation schemes to be applied.\n Mark *single* as deprecated in comments.\n Add new functions to allow user to query ring sync types.\n Replace direct access to *single* with appropriate function call.\n- Move actual rte_ring and related structures definitions into a\n separate file: <rte_ring_core.h>. It allows to refer contents\n of <rte_ring_elem.h> from <rte_ring.h> without introducing a\n circular dependency.\n\nSigned-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\n---\n app/test/test_pdump.c | 6 +-\n lib/librte_pdump/rte_pdump.c | 2 +-\n lib/librte_port/rte_port_ring.c | 12 +--\n lib/librte_ring/Makefile | 1 +\n lib/librte_ring/meson.build | 1 +\n lib/librte_ring/rte_ring.c | 6 +-\n lib/librte_ring/rte_ring.h | 170 ++++++++++++++------------------\n lib/librte_ring/rte_ring_core.h | 131 ++++++++++++++++++++++++\n lib/librte_ring/rte_ring_elem.h | 42 +++-----\n 9 files changed, 233 insertions(+), 138 deletions(-)\n create mode 100644 lib/librte_ring/rte_ring_core.h", "diff": "diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c\nindex ad183184c..6a1180bcb 100644\n--- a/app/test/test_pdump.c\n+++ b/app/test/test_pdump.c\n@@ -57,8 +57,7 @@ run_pdump_client_tests(void)\n \tif (ret < 0)\n \t\treturn -1;\n \tmp->flags = 0x0000;\n-\tring_client = rte_ring_create(\"SR0\", RING_SIZE, rte_socket_id(),\n-\t\t\t\t RING_F_SP_ENQ | RING_F_SC_DEQ);\n+\tring_client = rte_ring_create(\"SR0\", RING_SIZE, rte_socket_id(), 0);\n \tif (ring_client == NULL) {\n \t\tprintf(\"rte_ring_create SR0 failed\");\n \t\treturn -1;\n@@ -71,9 +70,6 @@ run_pdump_client_tests(void)\n \t}\n \trte_eth_dev_probing_finish(eth_dev);\n \n-\tring_client->prod.single = 0;\n-\tring_client->cons.single = 0;\n-\n \tprintf(\"\\n***** flags = RTE_PDUMP_FLAG_TX *****\\n\");\n \n \tfor (itr = 0; itr < NUM_ITR; itr++) {\ndiff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c\nindex 8a01ac510..f96709f95 100644\n--- a/lib/librte_pdump/rte_pdump.c\n+++ b/lib/librte_pdump/rte_pdump.c\n@@ -380,7 +380,7 @@ pdump_validate_ring_mp(struct rte_ring *ring, struct rte_mempool *mp)\n \t\trte_errno = EINVAL;\n \t\treturn -1;\n \t}\n-\tif (ring->prod.single || ring->cons.single) {\n+\tif (rte_ring_is_prod_single(ring) || rte_ring_is_cons_single(ring)) {\n \t\tPDUMP_LOG(ERR, \"ring with either SP or SC settings\"\n \t\t\" is not valid for pdump, should have MP and MC settings\\n\");\n \t\trte_errno = EINVAL;\ndiff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c\nindex 47fcdd06a..52b2d8e55 100644\n--- a/lib/librte_port/rte_port_ring.c\n+++ b/lib/librte_port/rte_port_ring.c\n@@ -44,8 +44,8 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,\n \t/* Check input parameters */\n \tif ((conf == NULL) ||\n \t\t(conf->ring == NULL) ||\n-\t\t(conf->ring->cons.single && is_multi) ||\n-\t\t(!(conf->ring->cons.single) && !is_multi)) {\n+\t\t(rte_ring_is_cons_single(conf->ring) && is_multi) ||\n+\t\t(!rte_ring_is_cons_single(conf->ring) && !is_multi)) {\n \t\tRTE_LOG(ERR, PORT, \"%s: Invalid Parameters\\n\", __func__);\n \t\treturn NULL;\n \t}\n@@ -171,8 +171,8 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,\n \t/* Check input parameters */\n \tif ((conf == NULL) ||\n \t\t(conf->ring == NULL) ||\n-\t\t(conf->ring->prod.single && is_multi) ||\n-\t\t(!(conf->ring->prod.single) && !is_multi) ||\n+\t\t(rte_ring_is_prod_single(conf->ring) && is_multi) ||\n+\t\t(!rte_ring_is_prod_single(conf->ring) && !is_multi) ||\n \t\t(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {\n \t\tRTE_LOG(ERR, PORT, \"%s: Invalid Parameters\\n\", __func__);\n \t\treturn NULL;\n@@ -440,8 +440,8 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,\n \t/* Check input parameters */\n \tif ((conf == NULL) ||\n \t\t(conf->ring == NULL) ||\n-\t\t(conf->ring->prod.single && is_multi) ||\n-\t\t(!(conf->ring->prod.single) && !is_multi) ||\n+\t\t(rte_ring_is_prod_single(conf->ring) && is_multi) ||\n+\t\t(!rte_ring_is_prod_single(conf->ring) && !is_multi) ||\n \t\t(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {\n \t\tRTE_LOG(ERR, PORT, \"%s: Invalid Parameters\\n\", __func__);\n \t\treturn NULL;\ndiff --git a/lib/librte_ring/Makefile b/lib/librte_ring/Makefile\nindex 28368e6d1..6572768c9 100644\n--- a/lib/librte_ring/Makefile\n+++ b/lib/librte_ring/Makefile\n@@ -16,6 +16,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c\n \n # install includes\n SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \\\n+\t\t\t\t\trte_ring_core.h \\\n \t\t\t\t\trte_ring_elem.h \\\n \t\t\t\t\trte_ring_generic.h \\\n \t\t\t\t\trte_ring_c11_mem.h\ndiff --git a/lib/librte_ring/meson.build b/lib/librte_ring/meson.build\nindex 05402e4f0..c656781da 100644\n--- a/lib/librte_ring/meson.build\n+++ b/lib/librte_ring/meson.build\n@@ -3,6 +3,7 @@\n \n sources = files('rte_ring.c')\n headers = files('rte_ring.h',\n+\t\t'rte_ring_core.h',\n \t\t'rte_ring_elem.h',\n \t\t'rte_ring_c11_mem.h',\n \t\t'rte_ring_generic.h')\ndiff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c\nindex 77e5de099..fa5733907 100644\n--- a/lib/librte_ring/rte_ring.c\n+++ b/lib/librte_ring/rte_ring.c\n@@ -106,8 +106,10 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,\n \tif (ret < 0 || ret >= (int)sizeof(r->name))\n \t\treturn -ENAMETOOLONG;\n \tr->flags = flags;\n-\tr->prod.single = (flags & RING_F_SP_ENQ) ? __IS_SP : __IS_MP;\n-\tr->cons.single = (flags & RING_F_SC_DEQ) ? __IS_SC : __IS_MC;\n+\tr->prod.sync_type = (flags & RING_F_SP_ENQ) ?\n+\t\tRTE_RING_SYNC_ST : RTE_RING_SYNC_MT;\n+\tr->cons.sync_type = (flags & RING_F_SC_DEQ) ?\n+\t\tRTE_RING_SYNC_ST : RTE_RING_SYNC_MT;\n \n \tif (flags & RING_F_EXACT_SZ) {\n \t\tr->size = rte_align32pow2(count + 1);\ndiff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h\nindex 18fc5d845..35ee4491c 100644\n--- a/lib/librte_ring/rte_ring.h\n+++ b/lib/librte_ring/rte_ring.h\n@@ -36,91 +36,7 @@\n extern \"C\" {\n #endif\n \n-#include <stdio.h>\n-#include <stdint.h>\n-#include <sys/queue.h>\n-#include <errno.h>\n-#include <rte_common.h>\n-#include <rte_config.h>\n-#include <rte_memory.h>\n-#include <rte_lcore.h>\n-#include <rte_atomic.h>\n-#include <rte_branch_prediction.h>\n-#include <rte_memzone.h>\n-#include <rte_pause.h>\n-\n-#define RTE_TAILQ_RING_NAME \"RTE_RING\"\n-\n-enum rte_ring_queue_behavior {\n-\tRTE_RING_QUEUE_FIXED = 0, /* Enq/Deq a fixed number of items from a ring */\n-\tRTE_RING_QUEUE_VARIABLE /* Enq/Deq as many items as possible from ring */\n-};\n-\n-#define RTE_RING_MZ_PREFIX \"RG_\"\n-/** The maximum length of a ring name. */\n-#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \\\n-\t\t\t sizeof(RTE_RING_MZ_PREFIX) + 1)\n-\n-/* structure to hold a pair of head/tail values and other metadata */\n-struct rte_ring_headtail {\n-\tvolatile uint32_t head; /**< Prod/consumer head. */\n-\tvolatile uint32_t tail; /**< Prod/consumer tail. */\n-\tuint32_t single; /**< True if single prod/cons */\n-};\n-\n-/**\n- * An RTE ring structure.\n- *\n- * The producer and the consumer have a head and a tail index. The particularity\n- * of these index is that they are not between 0 and size(ring). These indexes\n- * are between 0 and 2^32, and we mask their value when we access the ring[]\n- * field. Thanks to this assumption, we can do subtractions between 2 index\n- * values in a modulo-32bit base: that's why the overflow of the indexes is not\n- * a problem.\n- */\n-struct rte_ring {\n-\t/*\n-\t * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI\n-\t * compatibility requirements, it could be changed to RTE_RING_NAMESIZE\n-\t * next time the ABI changes\n-\t */\n-\tchar name[RTE_MEMZONE_NAMESIZE] __rte_cache_aligned; /**< Name of the ring. */\n-\tint flags; /**< Flags supplied at creation. */\n-\tconst struct rte_memzone *memzone;\n-\t\t\t/**< Memzone, if any, containing the rte_ring */\n-\tuint32_t size; /**< Size of ring. */\n-\tuint32_t mask; /**< Mask (size-1) of ring. */\n-\tuint32_t capacity; /**< Usable size of ring */\n-\n-\tchar pad0 __rte_cache_aligned; /**< empty cache line */\n-\n-\t/** Ring producer status. */\n-\tstruct rte_ring_headtail prod __rte_cache_aligned;\n-\tchar pad1 __rte_cache_aligned; /**< empty cache line */\n-\n-\t/** Ring consumer status. */\n-\tstruct rte_ring_headtail cons __rte_cache_aligned;\n-\tchar pad2 __rte_cache_aligned; /**< empty cache line */\n-};\n-\n-#define RING_F_SP_ENQ 0x0001 /**< The default enqueue is \"single-producer\". */\n-#define RING_F_SC_DEQ 0x0002 /**< The default dequeue is \"single-consumer\". */\n-/**\n- * Ring is to hold exactly requested number of entries.\n- * Without this flag set, the ring size requested must be a power of 2, and the\n- * usable space will be that size - 1. With the flag, the requested size will\n- * be rounded up to the next power of two, but the usable space will be exactly\n- * that requested. Worst case, if a power-of-2 size is requested, half the\n- * ring space will be wasted.\n- */\n-#define RING_F_EXACT_SZ 0x0004\n-#define RTE_RING_SZ_MASK (0x7fffffffU) /**< Ring size mask */\n-\n-/* @internal defines for passing to the enqueue dequeue worker functions */\n-#define __IS_SP 1\n-#define __IS_MP 0\n-#define __IS_SC 1\n-#define __IS_MC 0\n+#include <rte_ring_core.h>\n \n /**\n * Calculate the memory size needed for a ring\n@@ -420,7 +336,7 @@ rte_ring_mp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,\n \t\t\t unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,\n-\t\t\t__IS_MP, free_space);\n+\t\t\tRTE_RING_SYNC_MT, free_space);\n }\n \n /**\n@@ -443,9 +359,13 @@ rte_ring_sp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,\n \t\t\t unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,\n-\t\t\t__IS_SP, free_space);\n+\t\t\tRTE_RING_SYNC_ST, free_space);\n }\n \n+#ifdef ALLOW_EXPERIMENTAL_API\n+#include <rte_ring_elem.h>\n+#endif\n+\n /**\n * Enqueue several objects on a ring.\n *\n@@ -470,7 +390,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,\n \t\t unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,\n-\t\t\tr->prod.single, free_space);\n+\t\t\tr->prod.sync_type, free_space);\n }\n \n /**\n@@ -554,7 +474,7 @@ rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table,\n \t\tunsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,\n-\t\t\t__IS_MC, available);\n+\t\t\tRTE_RING_SYNC_MT, available);\n }\n \n /**\n@@ -578,7 +498,7 @@ rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table,\n \t\tunsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,\n-\t\t\t__IS_SC, available);\n+\t\t\tRTE_RING_SYNC_ST, available);\n }\n \n /**\n@@ -605,7 +525,7 @@ rte_ring_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n,\n \t\tunsigned int *available)\n {\n \treturn __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,\n-\t\t\t\tr->cons.single, available);\n+\t\t\t\tr->cons.sync_type, available);\n }\n \n /**\n@@ -777,6 +697,62 @@ rte_ring_get_capacity(const struct rte_ring *r)\n \treturn r->capacity;\n }\n \n+/**\n+ * Return sync type used by producer in the ring.\n+ *\n+ * @param r\n+ * A pointer to the ring structure.\n+ * @return\n+ * Producer sync type value.\n+ */\n+static inline enum rte_ring_sync_type\n+rte_ring_get_prod_sync_type(const struct rte_ring *r)\n+{\n+\treturn r->prod.sync_type;\n+}\n+\n+/**\n+ * Check is the ring for single producer.\n+ *\n+ * @param r\n+ * A pointer to the ring structure.\n+ * @return\n+ * true if ring is SP, zero otherwise.\n+ */\n+static inline int\n+rte_ring_is_prod_single(const struct rte_ring *r)\n+{\n+\treturn (rte_ring_get_prod_sync_type(r) == RTE_RING_SYNC_ST);\n+}\n+\n+/**\n+ * Return sync type used by consumer in the ring.\n+ *\n+ * @param r\n+ * A pointer to the ring structure.\n+ * @return\n+ * Consumer sync type value.\n+ */\n+static inline enum rte_ring_sync_type\n+rte_ring_get_cons_sync_type(const struct rte_ring *r)\n+{\n+\treturn r->cons.sync_type;\n+}\n+\n+/**\n+ * Check is the ring for single consumer.\n+ *\n+ * @param r\n+ * A pointer to the ring structure.\n+ * @return\n+ * true if ring is SC, zero otherwise.\n+ */\n+static inline int\n+rte_ring_is_cons_single(const struct rte_ring *r)\n+{\n+\treturn (rte_ring_get_cons_sync_type(r) == RTE_RING_SYNC_ST);\n+}\n+\n /**\n * Dump the status of all rings on the console\n *\n@@ -820,7 +796,7 @@ rte_ring_mp_enqueue_burst(struct rte_ring *r, void * const *obj_table,\n \t\t\t unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue(r, obj_table, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_MP, free_space);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, free_space);\n }\n \n /**\n@@ -843,7 +819,7 @@ rte_ring_sp_enqueue_burst(struct rte_ring *r, void * const *obj_table,\n \t\t\t unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue(r, obj_table, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_SP, free_space);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, free_space);\n }\n \n /**\n@@ -870,7 +846,7 @@ rte_ring_enqueue_burst(struct rte_ring *r, void * const *obj_table,\n \t\t unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_VARIABLE,\n-\t\t\tr->prod.single, free_space);\n+\t\t\tr->prod.sync_type, free_space);\n }\n \n /**\n@@ -898,7 +874,7 @@ rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table,\n \t\tunsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue(r, obj_table, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_MC, available);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, available);\n }\n \n /**\n@@ -923,7 +899,7 @@ rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table,\n \t\tunsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue(r, obj_table, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_SC, available);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, available);\n }\n \n /**\n@@ -951,7 +927,7 @@ rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table,\n {\n \treturn __rte_ring_do_dequeue(r, obj_table, n,\n \t\t\t\tRTE_RING_QUEUE_VARIABLE,\n-\t\t\t\tr->cons.single, available);\n+\t\t\t\tr->cons.sync_type, available);\n }\n \n #ifdef __cplusplus\ndiff --git a/lib/librte_ring/rte_ring_core.h b/lib/librte_ring/rte_ring_core.h\nnew file mode 100644\nindex 000000000..459a0ffa1\n--- /dev/null\n+++ b/lib/librte_ring/rte_ring_core.h\n@@ -0,0 +1,131 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ *\n+ * Copyright (c) 2010-2020 Intel Corporation\n+ * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org\n+ * All rights reserved.\n+ * Derived from FreeBSD's bufring.h\n+ * Used as BSD-3 Licensed with permission from Kip Macy.\n+ */\n+\n+#ifndef _RTE_RING_CORE_H_\n+#define _RTE_RING_CORE_H_\n+\n+/**\n+ * @file\n+ * This file contains definion of RTE ring structure itself,\n+ * init flags and some related macros.\n+ * For majority of DPDK entities, it is not recommended to include\n+ * this file directly, use include <rte_ring.h> or <rte_ring_elem.h>\n+ * instead.\n+ */\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+#include <stdio.h>\n+#include <stdint.h>\n+#include <string.h>\n+#include <sys/queue.h>\n+#include <errno.h>\n+#include <rte_common.h>\n+#include <rte_config.h>\n+#include <rte_memory.h>\n+#include <rte_lcore.h>\n+#include <rte_atomic.h>\n+#include <rte_branch_prediction.h>\n+#include <rte_memzone.h>\n+#include <rte_pause.h>\n+#include <rte_debug.h>\n+\n+#define RTE_TAILQ_RING_NAME \"RTE_RING\"\n+\n+enum rte_ring_queue_behavior {\n+\t/** Enq/Deq a fixed number of items from a ring */\n+\tRTE_RING_QUEUE_FIXED = 0,\n+\t/** Enq/Deq as many items as possible from ring */\n+\tRTE_RING_QUEUE_VARIABLE\n+};\n+\n+#define RTE_RING_MZ_PREFIX \"RG_\"\n+/** The maximum length of a ring name. */\n+#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \\\n+\t\t\t sizeof(RTE_RING_MZ_PREFIX) + 1)\n+\n+/** prod/cons sync types */\n+enum rte_ring_sync_type {\n+\tRTE_RING_SYNC_MT, /**< multi-thread safe (default mode) */\n+\tRTE_RING_SYNC_ST, /**< single thread only */\n+};\n+\n+/**\n+ * structures to hold a pair of head/tail values and other metadata.\n+ * Depending on sync_type format of that structure might be different,\n+ * but offset for *sync_type* and *tail* values should remain the same.\n+ */\n+struct rte_ring_headtail {\n+\tvolatile uint32_t head; /**< prod/consumer head. */\n+\tvolatile uint32_t tail; /**< prod/consumer tail. */\n+\tRTE_STD_C11\n+\tunion {\n+\t\t/** sync type of prod/cons */\n+\t\tenum rte_ring_sync_type sync_type;\n+\t\t/** deprecated - True if single prod/cons */\n+\t\tuint32_t single;\n+\t};\n+};\n+\n+/**\n+ * An RTE ring structure.\n+ *\n+ * The producer and the consumer have a head and a tail index. The particularity\n+ * of these index is that they are not between 0 and size(ring). These indexes\n+ * are between 0 and 2^32, and we mask their value when we access the ring[]\n+ * field. Thanks to this assumption, we can do subtractions between 2 index\n+ * values in a modulo-32bit base: that's why the overflow of the indexes is not\n+ * a problem.\n+ */\n+struct rte_ring {\n+\t/*\n+\t * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI\n+\t * compatibility requirements, it could be changed to RTE_RING_NAMESIZE\n+\t * next time the ABI changes\n+\t */\n+\tchar name[RTE_MEMZONE_NAMESIZE] __rte_cache_aligned;\n+\t/**< Name of the ring. */\n+\tint flags; /**< Flags supplied at creation. */\n+\tconst struct rte_memzone *memzone;\n+\t\t\t/**< Memzone, if any, containing the rte_ring */\n+\tuint32_t size; /**< Size of ring. */\n+\tuint32_t mask; /**< Mask (size-1) of ring. */\n+\tuint32_t capacity; /**< Usable size of ring */\n+\n+\tchar pad0 __rte_cache_aligned; /**< empty cache line */\n+\n+\t/** Ring producer status. */\n+\tstruct rte_ring_headtail prod __rte_cache_aligned;\n+\tchar pad1 __rte_cache_aligned; /**< empty cache line */\n+\n+\t/** Ring consumer status. */\n+\tstruct rte_ring_headtail cons __rte_cache_aligned;\n+\tchar pad2 __rte_cache_aligned; /**< empty cache line */\n+};\n+\n+#define RING_F_SP_ENQ 0x0001 /**< The default enqueue is \"single-producer\". */\n+#define RING_F_SC_DEQ 0x0002 /**< The default dequeue is \"single-consumer\". */\n+/**\n+ * Ring is to hold exactly requested number of entries.\n+ * Without this flag set, the ring size requested must be a power of 2, and the\n+ * usable space will be that size - 1. With the flag, the requested size will\n+ * be rounded up to the next power of two, but the usable space will be exactly\n+ * that requested. Worst case, if a power-of-2 size is requested, half the\n+ * ring space will be wasted.\n+ */\n+#define RING_F_EXACT_SZ 0x0004\n+#define RTE_RING_SZ_MASK (0x7fffffffU) /**< Ring size mask */\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* _RTE_RING_CORE_H_ */\ndiff --git a/lib/librte_ring/rte_ring_elem.h b/lib/librte_ring/rte_ring_elem.h\nindex 663addc73..7406c0b0f 100644\n--- a/lib/librte_ring/rte_ring_elem.h\n+++ b/lib/librte_ring/rte_ring_elem.h\n@@ -20,21 +20,7 @@\n extern \"C\" {\n #endif\n \n-#include <stdio.h>\n-#include <stdint.h>\n-#include <string.h>\n-#include <sys/queue.h>\n-#include <errno.h>\n-#include <rte_common.h>\n-#include <rte_config.h>\n-#include <rte_memory.h>\n-#include <rte_lcore.h>\n-#include <rte_atomic.h>\n-#include <rte_branch_prediction.h>\n-#include <rte_memzone.h>\n-#include <rte_pause.h>\n-\n-#include \"rte_ring.h\"\n+#include <rte_ring_core.h>\n \n /**\n * @warning\n@@ -510,7 +496,7 @@ rte_ring_mp_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_FIXED, __IS_MP, free_space);\n+\t\t\tRTE_RING_QUEUE_FIXED, RTE_RING_SYNC_MT, free_space);\n }\n \n /**\n@@ -539,7 +525,7 @@ rte_ring_sp_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_FIXED, __IS_SP, free_space);\n+\t\t\tRTE_RING_QUEUE_FIXED, RTE_RING_SYNC_ST, free_space);\n }\n \n /**\n@@ -570,7 +556,7 @@ rte_ring_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_FIXED, r->prod.single, free_space);\n+\t\t\tRTE_RING_QUEUE_FIXED, r->prod.sync_type, free_space);\n }\n \n /**\n@@ -675,7 +661,7 @@ rte_ring_mc_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue_elem(r, obj_table, esize, n,\n-\t\t\t\tRTE_RING_QUEUE_FIXED, __IS_MC, available);\n+\t\t\t\tRTE_RING_QUEUE_FIXED, RTE_RING_SYNC_MT, available);\n }\n \n /**\n@@ -703,7 +689,7 @@ rte_ring_sc_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_FIXED, __IS_SC, available);\n+\t\t\tRTE_RING_QUEUE_FIXED, RTE_RING_SYNC_ST, available);\n }\n \n /**\n@@ -734,7 +720,7 @@ rte_ring_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_FIXED, r->cons.single, available);\n+\t\t\tRTE_RING_QUEUE_FIXED, r->cons.sync_type, available);\n }\n \n /**\n@@ -842,7 +828,7 @@ rte_ring_mp_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_MP, free_space);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, free_space);\n }\n \n /**\n@@ -871,7 +857,7 @@ rte_ring_sp_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_SP, free_space);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, free_space);\n }\n \n /**\n@@ -902,7 +888,7 @@ rte_ring_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *free_space)\n {\n \treturn __rte_ring_do_enqueue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, r->prod.single, free_space);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, r->prod.sync_type, free_space);\n }\n \n /**\n@@ -934,7 +920,7 @@ rte_ring_mc_dequeue_burst_elem(struct rte_ring *r, void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_MC, available);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, available);\n }\n \n /**\n@@ -963,7 +949,7 @@ rte_ring_sc_dequeue_burst_elem(struct rte_ring *r, void *obj_table,\n \t\tunsigned int esize, unsigned int n, unsigned int *available)\n {\n \treturn __rte_ring_do_dequeue_elem(r, obj_table, esize, n,\n-\t\t\tRTE_RING_QUEUE_VARIABLE, __IS_SC, available);\n+\t\t\tRTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, available);\n }\n \n /**\n@@ -995,9 +981,11 @@ rte_ring_dequeue_burst_elem(struct rte_ring *r, void *obj_table,\n {\n \treturn __rte_ring_do_dequeue_elem(r, obj_table, esize, n,\n \t\t\t\tRTE_RING_QUEUE_VARIABLE,\n-\t\t\t\tr->cons.single, available);\n+\t\t\t\tr->cons.sync_type, available);\n }\n \n+#include <rte_ring.h>\n+\n #ifdef __cplusplus\n }\n #endif\n", "prefixes": [ "v4", "2/9" ] }{ "id": 68764, "url": "