From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: dev@dpdk.org
Cc: fiona.trahe@intel.com, shally.verma@cavium.com,
ahmed.mansour@nxp.com, Ashish.Gupta@cavium.com,
Pablo de Lara <pablo.de.lara.guarch@intel.com>,
Shally Verma <shally.verma@caviumnetworks.com>,
Ashish Gupta <ashish.gupta@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH v6 05/14] compressdev: add operation management
Date: Fri, 27 Apr 2018 14:23:58 +0100 [thread overview]
Message-ID: <20180427132407.13385-6-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <20180427132407.13385-1-pablo.de.lara.guarch@intel.com>
From: Fiona Trahe <fiona.trahe@intel.com>
Added functions to allocate and free compression operations.
Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
---
lib/librte_compressdev/Makefile | 2 +-
lib/librte_compressdev/meson.build | 3 +-
lib/librte_compressdev/rte_comp.c | 176 +++++++++++++++++++++
lib/librte_compressdev/rte_comp.h | 64 ++++++++
lib/librte_compressdev/rte_compressdev_internal.h | 1 -
lib/librte_compressdev/rte_compressdev_version.map | 4 +
6 files changed, 247 insertions(+), 3 deletions(-)
create mode 100644 lib/librte_compressdev/rte_comp.c
diff --git a/lib/librte_compressdev/Makefile b/lib/librte_compressdev/Makefile
index 4dae6ca42..7ef89e613 100644
--- a/lib/librte_compressdev/Makefile
+++ b/lib/librte_compressdev/Makefile
@@ -16,7 +16,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
LDLIBS += -lrte_eal -lrte_mempool -lrte_kvargs
# library source files
-SRCS-y += rte_compressdev.c rte_compressdev_pmd.c
+SRCS-y += rte_compressdev.c rte_compressdev_pmd.c rte_comp.c
# export include files
SYMLINK-y-include += rte_comp.h
diff --git a/lib/librte_compressdev/meson.build b/lib/librte_compressdev/meson.build
index 2115961c2..5416571c9 100644
--- a/lib/librte_compressdev/meson.build
+++ b/lib/librte_compressdev/meson.build
@@ -3,7 +3,8 @@
allow_experimental_apis = true
sources = files('rte_compressdev.c',
- 'rte_compressdev_pmd.c')
+ 'rte_compressdev_pmd.c',
+ 'rte_comp.c')
headers = files('rte_compressdev.h',
'rte_compressdev_pmd.h',
'rte_compressdev_internal.h',
diff --git a/lib/librte_compressdev/rte_comp.c b/lib/librte_compressdev/rte_comp.c
new file mode 100644
index 000000000..eb99e99d2
--- /dev/null
+++ b/lib/librte_compressdev/rte_comp.c
@@ -0,0 +1,176 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Intel Corporation
+ */
+
+#include "rte_comp.h"
+#include "rte_compressdev.h"
+#include "rte_compressdev_internal.h"
+
+/**
+ * Reset the fields of an operation to their default values.
+ *
+ * @note The private data associated with the operation is not zeroed.
+ *
+ * @param op
+ * The operation to be reset
+ */
+static inline void
+rte_comp_op_reset(struct rte_comp_op *op)
+{
+ struct rte_mempool *tmp_mp = op->mempool;
+ rte_iova_t tmp_iova_addr = op->iova_addr;
+
+ memset(op, 0, sizeof(struct rte_comp_op));
+ op->status = RTE_COMP_OP_STATUS_NOT_PROCESSED;
+ op->iova_addr = tmp_iova_addr;
+ op->mempool = tmp_mp;
+}
+
+/**
+ * Private data structure belonging to an operation pool.
+ */
+struct rte_comp_op_pool_private {
+ uint16_t user_size;
+ /**< Size of private user data with each operation. */
+};
+
+/**
+ * Bulk allocate raw element from mempool and return as comp operations
+ *
+ * @param mempool
+ * Compress operation mempool
+ * @param ops
+ * Array to place allocated operations
+ * @param nb_ops
+ * Number of operations to allocate
+ * @return
+ * - 0: Success
+ * - -ENOENT: Not enough entries in the mempool; no ops are retrieved.
+ */
+static inline int
+rte_comp_op_raw_bulk_alloc(struct rte_mempool *mempool,
+ struct rte_comp_op **ops, uint16_t nb_ops)
+{
+ if (rte_mempool_get_bulk(mempool, (void **)ops, nb_ops) == 0)
+ return nb_ops;
+
+ return 0;
+}
+
+/** Initialise rte_comp_op mempool element */
+static void
+rte_comp_op_init(struct rte_mempool *mempool,
+ __rte_unused void *opaque_arg,
+ void *_op_data,
+ __rte_unused unsigned int i)
+{
+ struct rte_comp_op *op = _op_data;
+
+ memset(_op_data, 0, mempool->elt_size);
+
+ op->status = RTE_COMP_OP_STATUS_NOT_PROCESSED;
+ op->iova_addr = rte_mem_virt2iova(_op_data);
+ op->mempool = mempool;
+}
+
+struct rte_mempool * __rte_experimental
+rte_comp_op_pool_create(const char *name,
+ unsigned int nb_elts, unsigned int cache_size,
+ uint16_t user_size, int socket_id)
+{
+ struct rte_comp_op_pool_private *priv;
+
+ unsigned int elt_size = sizeof(struct rte_comp_op) + user_size;
+
+ /* lookup mempool in case already allocated */
+ struct rte_mempool *mp = rte_mempool_lookup(name);
+
+ if (mp != NULL) {
+ priv = (struct rte_comp_op_pool_private *)
+ rte_mempool_get_priv(mp);
+
+ if (mp->elt_size != elt_size ||
+ mp->cache_size < cache_size ||
+ mp->size < nb_elts ||
+ priv->user_size < user_size) {
+ mp = NULL;
+ COMPRESSDEV_LOG(ERR,
+ "Mempool %s already exists but with incompatible parameters",
+ name);
+ return NULL;
+ }
+ return mp;
+ }
+
+ mp = rte_mempool_create(
+ name,
+ nb_elts,
+ elt_size,
+ cache_size,
+ sizeof(struct rte_comp_op_pool_private),
+ NULL,
+ NULL,
+ rte_comp_op_init,
+ NULL,
+ socket_id,
+ 0);
+
+ if (mp == NULL) {
+ COMPRESSDEV_LOG(ERR, "Failed to create mempool %s", name);
+ return NULL;
+ }
+
+ priv = (struct rte_comp_op_pool_private *)
+ rte_mempool_get_priv(mp);
+
+ priv->user_size = user_size;
+
+ return mp;
+}
+
+struct rte_comp_op * __rte_experimental
+rte_comp_op_alloc(struct rte_mempool *mempool)
+{
+ struct rte_comp_op *op = NULL;
+ int retval;
+
+ retval = rte_comp_op_raw_bulk_alloc(mempool, &op, 1);
+ if (unlikely(retval < 0))
+ return NULL;
+
+ rte_comp_op_reset(op);
+
+ return op;
+}
+
+int __rte_experimental
+rte_comp_op_bulk_alloc(struct rte_mempool *mempool,
+ struct rte_comp_op **ops, uint16_t nb_ops)
+{
+ int ret;
+ uint16_t i;
+
+ ret = rte_comp_op_raw_bulk_alloc(mempool, ops, nb_ops);
+ if (unlikely(ret < nb_ops))
+ return ret;
+
+ for (i = 0; i < nb_ops; i++)
+ rte_comp_op_reset(ops[i]);
+
+ return nb_ops;
+}
+
+/**
+ * free operation structure
+ * If operation has been allocate from a rte_mempool, then the operation will
+ * be returned to the mempool.
+ *
+ * @param op
+ * Compress operation
+ */
+void __rte_experimental
+rte_comp_op_free(struct rte_comp_op *op)
+{
+ if (op != NULL && op->mempool != NULL)
+ rte_mempool_put(op->mempool, op);
+}
diff --git a/lib/librte_compressdev/rte_comp.h b/lib/librte_compressdev/rte_comp.h
index 9f35c37c5..996b17871 100644
--- a/lib/librte_compressdev/rte_comp.h
+++ b/lib/librte_compressdev/rte_comp.h
@@ -309,6 +309,70 @@ struct rte_comp_op {
*/
} __rte_cache_aligned;
+/**
+ * Creates an operation pool
+ *
+ * @param name
+ * Compress pool name
+ * @param nb_elts
+ * Number of elements in pool
+ * @param cache_size
+ * Number of elements to cache on lcore, see
+ * *rte_mempool_create* for further details about cache size
+ * @param user_size
+ * Size of private data to allocate for user with each operation
+ * @param socket_id
+ * Socket to identifier allocate memory on
+ * @return
+ * - On success pointer to mempool
+ * - On failure NULL
+ */
+struct rte_mempool * __rte_experimental
+rte_comp_op_pool_create(const char *name,
+ unsigned int nb_elts, unsigned int cache_size,
+ uint16_t user_size, int socket_id);
+
+/**
+ * Allocate an operation from a mempool with default parameters set
+ *
+ * @param mempool
+ * Compress operation mempool
+ *
+ * @return
+ * - On success returns a valid rte_comp_op structure
+ * - On failure returns NULL
+ */
+struct rte_comp_op * __rte_experimental
+rte_comp_op_alloc(struct rte_mempool *mempool);
+
+/**
+ * Bulk allocate operations from a mempool with default parameters set
+ *
+ * @param mempool
+ * Compress operation mempool
+ * @param ops
+ * Array to place allocated operations
+ * @param nb_ops
+ * Number of operations to allocate
+ * @return
+ * - 0: Success
+ * - -ENOENT: Not enough entries in the mempool; no ops are retrieved.
+ */
+int __rte_experimental
+rte_comp_op_bulk_alloc(struct rte_mempool *mempool,
+ struct rte_comp_op **ops, uint16_t nb_ops);
+
+/**
+ * Free operation structure
+ * If operation has been allocate from a rte_mempool, then the operation will
+ * be returned to the mempool.
+ *
+ * @param op
+ * Compress operation
+ */
+void __rte_experimental
+rte_comp_op_free(struct rte_comp_op *op);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_compressdev/rte_compressdev_internal.h b/lib/librte_compressdev/rte_compressdev_internal.h
index e33e75eb2..9ec44f2c1 100644
--- a/lib/librte_compressdev/rte_compressdev_internal.h
+++ b/lib/librte_compressdev/rte_compressdev_internal.h
@@ -63,7 +63,6 @@ typedef uint16_t (*compressdev_dequeue_pkt_burst_t)(void *qp,
typedef uint16_t (*compressdev_enqueue_pkt_burst_t)(void *qp,
struct rte_comp_op **ops, uint16_t nb_ops);
-
/** The data structure associated with each comp device. */
struct rte_compressdev {
compressdev_dequeue_pkt_burst_t dequeue_burst;
diff --git a/lib/librte_compressdev/rte_compressdev_version.map b/lib/librte_compressdev/rte_compressdev_version.map
index 882395885..292417fde 100644
--- a/lib/librte_compressdev/rte_compressdev_version.map
+++ b/lib/librte_compressdev/rte_compressdev_version.map
@@ -23,6 +23,10 @@ EXPERIMENTAL {
rte_compressdev_socket_id;
rte_compressdev_start;
rte_compressdev_stop;
+ rte_comp_op_alloc;
+ rte_comp_op_bulk_alloc;
+ rte_comp_op_free;
+ rte_comp_op_pool_create;
local: *;
};
--
2.14.3
next prev parent reply other threads:[~2018-04-27 13:24 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 18:25 [dpdk-dev] [PATCH] compressdev: implement API Fiona Trahe
2018-02-04 14:18 ` Thomas Monjalon
2018-02-21 19:11 ` Trahe, Fiona
2018-02-24 1:17 ` Ahmed Mansour
2018-02-26 11:24 ` Trahe, Fiona
2018-02-26 19:15 ` Ahmed Mansour
2018-02-27 5:48 ` Verma, Shally
2018-02-26 11:25 ` Verma, Shally
2018-02-26 21:35 ` Ahmed Mansour
2018-02-27 5:53 ` Verma, Shally
2018-02-28 18:39 ` Trahe, Fiona
2018-03-01 6:58 ` Verma, Shally
2018-03-01 14:41 ` Trahe, Fiona
2018-03-02 0:55 ` Ahmed Mansour
2018-03-02 9:53 ` Trahe, Fiona
2018-03-02 19:48 ` Ahmed Mansour
2018-03-05 14:32 ` Verma, Shally
2018-03-06 23:33 ` Ahmed Mansour
2018-03-03 0:52 ` Ahmed Mansour
2018-02-04 14:24 ` Thomas Monjalon
2018-03-23 18:08 ` Trahe, Fiona
2018-03-24 1:02 ` Thomas Monjalon
2018-03-26 11:44 ` Trahe, Fiona
2018-03-27 16:04 ` [dpdk-dev] [PATCH v2 0/3] implement compression API Fiona Trahe
2018-04-06 18:04 ` [dpdk-dev] [PATCH v3 00/13] Implement " Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 01/13] compressdev: add basic device management Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 02/13] compressdev: add queue pair management Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 03/13] compressdev: add compression specific data Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 04/13] compressdev: add enqueue/dequeue functions Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 05/13] compressdev: add operation management Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 06/13] compressdev: support stateless operations Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 07/13] compressdev: support stateful operations Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 08/13] compressdev: support hash operations Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 09/13] compressdev: add device feature flags Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 10/13] compressdev: add compression service " Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 11/13] compressdev: add device stats Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 12/13] compressdev: add device capabilities Pablo de Lara
2018-04-06 18:05 ` [dpdk-dev] [PATCH v3 13/13] compressdev: get device id from name Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 00/13] Implement compression API Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 01/13] compressdev: add basic device management Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 02/13] compressdev: add queue pair management Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 03/13] compressdev: add compression specific data Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 04/13] compressdev: add enqueue/dequeue functions Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 05/13] compressdev: add operation management Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 06/13] compressdev: support stateless operations Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 07/13] compressdev: support stateful operations Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 08/13] compressdev: support hash operations Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 09/13] compressdev: add device feature flags Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 10/13] compressdev: add compression service " Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 11/13] compressdev: add device stats Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 12/13] compressdev: add device capabilities Pablo de Lara
2018-04-08 12:58 ` [dpdk-dev] [PATCH v4 13/13] compressdev: get device id from name Pablo de Lara
2018-03-27 16:04 ` [dpdk-dev] [PATCH v2 1/3] compressdev: add structs and enum for compression service Fiona Trahe
2018-03-27 16:04 ` [dpdk-dev] [PATCH v2 2/3] compressdev: implement API Fiona Trahe
2018-03-27 16:04 ` [dpdk-dev] [PATCH v2 3/3] doc: update doxy and release note for compressdev Fiona Trahe
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 00/13] Implement compression API Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 01/13] compressdev: add basic device management Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 02/13] compressdev: add queue pair management Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 03/13] compressdev: add compression specific data Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 04/13] compressdev: add enqueue/dequeue functions Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 05/13] compressdev: add operation management Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 06/13] compressdev: support stateless operations Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 07/13] compressdev: support stateful operations Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 08/13] compressdev: support hash operations Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 09/13] compressdev: add device feature flags Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 10/13] compressdev: add compression service " Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 11/13] compressdev: add device stats Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 12/13] compressdev: add device capabilities Pablo de Lara
2018-04-13 18:18 ` [dpdk-dev] [PATCH v5 13/13] compressdev: get device id from name Pablo de Lara
2018-04-27 13:23 ` [dpdk-dev] [PATCH v6 00/14] Implement compression API Pablo de Lara
2018-04-27 13:23 ` [dpdk-dev] [PATCH v6 01/14] compressdev: add basic device management Pablo de Lara
2018-04-27 13:23 ` [dpdk-dev] [PATCH v6 02/14] compressdev: add queue pair management Pablo de Lara
2018-05-04 2:48 ` Verma, Shally
2018-05-04 8:43 ` Trahe, Fiona
2018-05-14 7:53 ` Verma, Shally
2018-05-14 8:04 ` De Lara Guarch, Pablo
2018-05-14 8:16 ` Verma, Shally
2018-05-14 8:30 ` De Lara Guarch, Pablo
2018-04-27 13:23 ` [dpdk-dev] [PATCH v6 03/14] compressdev: add compression specific data Pablo de Lara
2018-04-27 13:23 ` [dpdk-dev] [PATCH v6 04/14] compressdev: add enqueue/dequeue functions Pablo de Lara
2018-04-27 13:23 ` Pablo de Lara [this message]
2018-04-27 13:23 ` [dpdk-dev] [PATCH v6 06/14] compressdev: support stateless operations Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 07/14] compressdev: support stateful operations Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 08/14] compressdev: support hash operations Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 09/14] compressdev: add device feature flags Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 10/14] compressdev: add compression service " Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 11/14] compressdev: add device stats Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 12/14] compressdev: add device capabilities Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 13/14] compressdev: get device id from name Pablo de Lara
2018-04-27 13:24 ` [dpdk-dev] [PATCH v6 14/14] doc: add compressdev library guide Pablo de Lara
2018-05-08 21:25 ` [dpdk-dev] [PATCH v6 00/14] Implement compression API De Lara Guarch, Pablo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180427132407.13385-6-pablo.de.lara.guarch@intel.com \
--to=pablo.de.lara.guarch@intel.com \
--cc=Ashish.Gupta@cavium.com \
--cc=ahmed.mansour@nxp.com \
--cc=ashish.gupta@caviumnetworks.com \
--cc=dev@dpdk.org \
--cc=fiona.trahe@intel.com \
--cc=shally.verma@cavium.com \
--cc=shally.verma@caviumnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).