cryptodev: remove opaque data pointer in crypto op
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Sun, 2 Jul 2017 05:41:04 +0000 (06:41 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 6 Jul 2017 20:26:48 +0000 (22:26 +0200)
Storing a pointer to the user data is unnecessary,
since user can store additional data, after the crypto operation.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Declan Doherty <declan.doherty@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
app/test-crypto-perf/cperf_test_latency.c
doc/guides/prog_guide/cryptodev_lib.rst
doc/guides/rel_notes/release_17_08.rst
lib/librte_cryptodev/rte_crypto.h

index 4fb7a9a..32cf5fd 100644 (file)
@@ -66,6 +66,10 @@ struct cperf_latency_ctx {
        struct cperf_op_result *res;
 };
 
        struct cperf_op_result *res;
 };
 
+struct priv_op_data {
+       struct cperf_op_result *result;
+};
+
 #define max(a, b) (a > b ? (uint64_t)a : (uint64_t)b)
 #define min(a, b) (a < b ? (uint64_t)a : (uint64_t)b)
 
 #define max(a, b) (a > b ? (uint64_t)a : (uint64_t)b)
 #define min(a, b) (a < b ? (uint64_t)a : (uint64_t)b)
 
@@ -276,9 +280,11 @@ cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
        snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d",
                        dev_id);
 
        snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d",
                        dev_id);
 
+       uint16_t priv_size = sizeof(struct priv_op_data);
        ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name,
        ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name,
-                       RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 512, 0,
-                       rte_socket_id());
+                       RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz,
+                       512, priv_size, rte_socket_id());
+
        if (ctx->crypto_op_pool == NULL)
                goto err;
 
        if (ctx->crypto_op_pool == NULL)
                goto err;
 
@@ -295,11 +301,20 @@ err:
        return NULL;
 }
 
        return NULL;
 }
 
+static inline void
+store_timestamp(struct rte_crypto_op *op, uint64_t timestamp)
+{
+       struct priv_op_data *priv_data;
+
+       priv_data = (struct priv_op_data *) (op->sym + 1);
+       priv_data->result->status = op->status;
+       priv_data->result->tsc_end = timestamp;
+}
+
 int
 cperf_latency_test_runner(void *arg)
 {
        struct cperf_latency_ctx *ctx = arg;
 int
 cperf_latency_test_runner(void *arg)
 {
        struct cperf_latency_ctx *ctx = arg;
-       struct cperf_op_result *pres;
        uint16_t test_burst_size;
        uint8_t burst_size_idx = 0;
 
        uint16_t test_burst_size;
        uint8_t burst_size_idx = 0;
 
@@ -311,6 +326,7 @@ cperf_latency_test_runner(void *arg)
        struct rte_crypto_op *ops[ctx->options->max_burst_size];
        struct rte_crypto_op *ops_processed[ctx->options->max_burst_size];
        uint64_t i;
        struct rte_crypto_op *ops[ctx->options->max_burst_size];
        struct rte_crypto_op *ops_processed[ctx->options->max_burst_size];
        uint64_t i;
+       struct priv_op_data *priv_data;
 
        uint32_t lcore = rte_lcore_id();
 
 
        uint32_t lcore = rte_lcore_id();
 
@@ -400,7 +416,12 @@ cperf_latency_test_runner(void *arg)
 
                        for (i = 0; i < ops_enqd; i++) {
                                ctx->res[tsc_idx].tsc_start = tsc_start;
 
                        for (i = 0; i < ops_enqd; i++) {
                                ctx->res[tsc_idx].tsc_start = tsc_start;
-                               ops[i]->opaque_data = (void *)&ctx->res[tsc_idx];
+                               /*
+                                * Private data structure starts after the end of the
+                                * rte_crypto_sym_op structure.
+                                */
+                               priv_data = (struct priv_op_data *) (ops[i]->sym + 1);
+                               priv_data->result = (void *)&ctx->res[tsc_idx];
                                tsc_idx++;
                        }
 
                                tsc_idx++;
                        }
 
@@ -411,12 +432,9 @@ cperf_latency_test_runner(void *arg)
                                 * the crypto operation will change the data and cause
                                 * failures.
                                 */
                                 * the crypto operation will change the data and cause
                                 * failures.
                                 */
-                               for (i = 0; i < ops_deqd; i++) {
-                                       pres = (struct cperf_op_result *)
-                                                       (ops_processed[i]->opaque_data);
-                                       pres->status = ops_processed[i]->status;
-                                       pres->tsc_end = tsc_end;
-                               }
+                               for (i = 0; i < ops_deqd; i++)
+                                       store_timestamp(ops_processed[i], tsc_end);
+
                                rte_mempool_put_bulk(ctx->crypto_op_pool,
                                                (void **)ops_processed, ops_deqd);
 
                                rte_mempool_put_bulk(ctx->crypto_op_pool,
                                                (void **)ops_processed, ops_deqd);
 
@@ -447,12 +465,9 @@ cperf_latency_test_runner(void *arg)
                        tsc_end = rte_rdtsc_precise();
 
                        if (ops_deqd != 0) {
                        tsc_end = rte_rdtsc_precise();
 
                        if (ops_deqd != 0) {
-                               for (i = 0; i < ops_deqd; i++) {
-                                       pres = (struct cperf_op_result *)
-                                                       (ops_processed[i]->opaque_data);
-                                       pres->status = ops_processed[i]->status;
-                                       pres->tsc_end = tsc_end;
-                               }
+                               for (i = 0; i < ops_deqd; i++)
+                                       store_timestamp(ops_processed[i], tsc_end);
+
                                rte_mempool_put_bulk(ctx->crypto_op_pool,
                                                (void **)ops_processed, ops_deqd);
 
                                rte_mempool_put_bulk(ctx->crypto_op_pool,
                                                (void **)ops_processed, ops_deqd);
 
index 229cb7a..c9a29f8 100644 (file)
@@ -363,8 +363,7 @@ The operation structure includes the operation type, the operation status
 and the session type (session-based/less), a reference to the operation
 specific data, which can vary in size and content depending on the operation
 being provisioned. It also contains the source mempool for the operation,
 and the session type (session-based/less), a reference to the operation
 specific data, which can vary in size and content depending on the operation
 being provisioned. It also contains the source mempool for the operation,
-if it allocate from a mempool. Finally an opaque pointer for user specific
-data is provided.
+if it allocated from a mempool.
 
 If Crypto operations are allocated from a Crypto operation mempool, see next
 section, there is also the ability to allocate private memory with the
 
 If Crypto operations are allocated from a Crypto operation mempool, see next
 section, there is also the ability to allocate private memory with the
index bfcc110..c21119d 100644 (file)
@@ -98,6 +98,7 @@ New Features
   * Added field ``rte_crypto_op_sess_type``.
   * Enumerations ``rte_crypto_op_status`` and ``rte_crypto_op_type``
     have been modified to be uint8_t values.
   * Added field ``rte_crypto_op_sess_type``.
   * Enumerations ``rte_crypto_op_status`` and ``rte_crypto_op_type``
     have been modified to be uint8_t values.
+  * Removed the field ``opaque_data``.
 
 
 Resolved Issues
 
 
 Resolved Issues
index dd17020..a5655a0 100644 (file)
@@ -122,9 +122,6 @@ struct rte_crypto_op {
        phys_addr_t phys_addr;
        /**< physical address of crypto operation */
 
        phys_addr_t phys_addr;
        /**< physical address of crypto operation */
 
-       void *opaque_data;
-       /**< Opaque pointer for user data */
-
        RTE_STD_C11
        union {
                struct rte_crypto_sym_op *sym;
        RTE_STD_C11
        union {
                struct rte_crypto_sym_op *sym;
@@ -158,8 +155,6 @@ __rte_crypto_op_reset(struct rte_crypto_op *op, enum rte_crypto_op_type type)
        default:
                break;
        }
        default:
                break;
        }
-
-       op->opaque_data = NULL;
 }
 
 /**
 }
 
 /**