* [dpdk-dev] [PATCH v2] app/test-crypto-perf: support PDCP
@ 2019-11-07 12:59 Akhil Goyal
2019-11-07 14:10 ` Hemant Agrawal
0 siblings, 1 reply; 2+ messages in thread
From: Akhil Goyal @ 2019-11-07 12:59 UTC (permalink / raw)
To: dev; +Cc: declan.doherty, anoobj, konstantin.ananyev, Akhil Goyal, Manish Tomar
test-crypto-perf app is updated to calculate PDCP
throughput numbers.
2 new params are added for PDCP
--pdcp-sn-sz <5/7/12/15/18>
--pdcp-domain <control/user>
./dpdk-test-crypto-perf --master-lcore 0 -l 0,1 --log-level=8 --
--devtype crypto_dpaa2_sec --optype pdcp --cipher-algo aes-ctr
--cipher-op encrypt --auth-algo null --auth-op generate --auth-key-sz
16 --ptest throughput --total-ops 100000 --burst-sz 64 --buffer-sz
64,390,1512 --pool-sz 4096 --silent --pdcp-sn-sz 12 --pdcp-domain
control
Signed-off-by: Manish Tomar <manish.tomar@nxp.com>
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
changes in v2:
fixed checkpatch warning.
app/test-crypto-perf/cperf_ops.c | 112 +++++++++++++++++++
app/test-crypto-perf/cperf_options.h | 9 +-
app/test-crypto-perf/cperf_options_parsing.c | 66 +++++++++++
app/test-crypto-perf/cperf_test_common.c | 1 +
app/test-crypto-perf/cperf_test_throughput.c | 22 ++--
app/test-crypto-perf/cperf_test_vectors.c | 55 +++++++++
app/test-crypto-perf/main.c | 3 +-
app/test-crypto-perf/meson.build | 2 +
doc/guides/rel_notes/release_19_11.rst | 2 +-
doc/guides/tools/cryptoperf.rst | 10 ++
10 files changed, 272 insertions(+), 10 deletions(-)
diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index f59568b80..3a381552e 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -3,10 +3,47 @@
*/
#include <rte_cryptodev.h>
+#include <rte_security.h>
#include "cperf_ops.h"
#include "cperf_test_vectors.h"
+static int
+cperf_set_ops_security(struct rte_crypto_op **ops,
+ uint32_t src_buf_offset __rte_unused,
+ uint32_t dst_buf_offset __rte_unused,
+ uint16_t nb_ops, struct rte_cryptodev_sym_session *sess,
+ const struct cperf_options *options __rte_unused,
+ const struct cperf_test_vector *test_vector __rte_unused,
+ uint16_t iv_offset __rte_unused,
+ uint32_t *imix_idx __rte_unused)
+{
+ uint16_t i;
+
+ for (i = 0; i < nb_ops; i++) {
+ struct rte_crypto_sym_op *sym_op = ops[i]->sym;
+ struct rte_security_session *sec_sess =
+ (struct rte_security_session *)sess;
+
+ ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+ rte_security_attach_session(ops[i], sec_sess);
+ sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
+ src_buf_offset);
+ sym_op->m_src->buf_len = options->segment_sz;
+ sym_op->m_src->data_len = options->test_buffer_size;
+ sym_op->m_src->pkt_len = sym_op->m_src->data_len;
+
+ /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
+ if (dst_buf_offset == 0)
+ sym_op->m_dst = NULL;
+ else
+ sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
+ dst_buf_offset);
+ }
+
+ return 0;
+}
+
static int
cperf_set_ops_null_cipher(struct rte_crypto_op **ops,
uint32_t src_buf_offset, uint32_t dst_buf_offset,
@@ -480,6 +517,77 @@ cperf_create_session(struct rte_mempool *sess_mp,
struct rte_crypto_sym_xform aead_xform;
struct rte_cryptodev_sym_session *sess = NULL;
+ /*
+ * security only
+ */
+ if (options->op_type == CPERF_PDCP) {
+ /* Setup Cipher Parameters */
+ cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+ cipher_xform.next = NULL;
+ cipher_xform.cipher.algo = options->cipher_algo;
+ cipher_xform.cipher.op = options->cipher_op;
+ cipher_xform.cipher.iv.offset = iv_offset;
+
+ /* cipher different than null */
+ if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
+ cipher_xform.cipher.key.data = test_vector->cipher_key.data;
+ cipher_xform.cipher.key.length = test_vector->cipher_key.length;
+ cipher_xform.cipher.iv.length = test_vector->cipher_iv.length;
+ } else {
+ cipher_xform.cipher.key.data = NULL;
+ cipher_xform.cipher.key.length = 0;
+ cipher_xform.cipher.iv.length = 0;
+ }
+
+ /* Setup Auth Parameters */
+ if (options->auth_algo != 0) {
+ auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
+ auth_xform.next = NULL;
+ auth_xform.auth.algo = options->auth_algo;
+ auth_xform.auth.op = options->auth_op;
+ auth_xform.auth.iv.offset = iv_offset +
+ cipher_xform.cipher.iv.length;
+
+ /* auth different than null */
+ if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
+ auth_xform.auth.digest_length = options->digest_sz;
+ auth_xform.auth.key.length = test_vector->auth_key.length;
+ auth_xform.auth.key.data = test_vector->auth_key.data;
+ auth_xform.auth.iv.length = test_vector->auth_iv.length;
+ } else {
+ auth_xform.auth.digest_length = 0;
+ auth_xform.auth.key.length = 0;
+ auth_xform.auth.key.data = NULL;
+ auth_xform.auth.iv.length = 0;
+ }
+
+ cipher_xform.next = &auth_xform;
+ } else {
+ cipher_xform.next = NULL;
+ }
+
+ struct rte_security_session_conf sess_conf = {
+ .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
+ .protocol = RTE_SECURITY_PROTOCOL_PDCP,
+ {.pdcp = {
+ .bearer = 0x16,
+ .domain = options->pdcp_domain,
+ .pkt_dir = 0,
+ .sn_size = options->pdcp_sn_sz,
+ .hfn = 0x1,
+ .hfn_threshold = 0x70C0A,
+ } },
+ .crypto_xform = &cipher_xform
+ };
+
+ struct rte_security_ctx *ctx = (struct rte_security_ctx *)
+ rte_cryptodev_get_sec_ctx(dev_id);
+
+ /* Create security session */
+ return (void *)rte_security_session_create(ctx,
+ &sess_conf, sess_mp);
+ }
+
sess = rte_cryptodev_sym_session_create(sess_mp);
/*
* cipher only
@@ -657,6 +765,10 @@ cperf_get_op_functions(const struct cperf_options *options,
op_fns->populate_ops = cperf_set_ops_cipher;
return 0;
}
+ if (options->op_type == CPERF_PDCP) {
+ op_fns->populate_ops = cperf_set_ops_security;
+ return 0;
+ }
return -1;
}
diff --git a/app/test-crypto-perf/cperf_options.h b/app/test-crypto-perf/cperf_options.h
index f5bf03c81..48d0f8180 100644
--- a/app/test-crypto-perf/cperf_options.h
+++ b/app/test-crypto-perf/cperf_options.h
@@ -7,6 +7,7 @@
#include <rte_crypto.h>
#include <rte_cryptodev.h>
+#include <rte_security.h>
#define CPERF_PTEST_TYPE ("ptest")
#define CPERF_SILENT ("silent")
@@ -43,6 +44,8 @@
#define CPERF_AEAD_AAD_SZ ("aead-aad-sz")
#define CPERF_DIGEST_SZ ("digest-sz")
+#define CPERF_PDCP_SN_SZ ("pdcp-sn-sz")
+#define CPERF_PDCP_DOMAIN ("pdcp-domain")
#define CPERF_CSV ("csv-friendly")
@@ -66,7 +69,8 @@ enum cperf_op_type {
CPERF_AUTH_ONLY,
CPERF_CIPHER_THEN_AUTH,
CPERF_AUTH_THEN_CIPHER,
- CPERF_AEAD
+ CPERF_AEAD,
+ CPERF_PDCP
};
extern const char *cperf_op_type_strs[];
@@ -110,6 +114,9 @@ struct cperf_options {
uint16_t digest_sz;
+ uint16_t pdcp_sn_sz;
+ enum rte_security_pdcp_domain pdcp_domain;
+
char device_type[RTE_CRYPTODEV_NAME_MAX_LEN];
enum cperf_op_type op_type;
diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index eba4cf7a6..36cf593fc 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <rte_cryptodev.h>
+#include <rte_security.h>
#include <rte_malloc.h>
#include "cperf_options.h"
@@ -442,6 +443,10 @@ parse_op_type(struct cperf_options *opts, const char *arg)
{
cperf_op_type_strs[CPERF_AEAD],
CPERF_AEAD
+ },
+ {
+ cperf_op_type_strs[CPERF_PDCP],
+ CPERF_PDCP
}
};
@@ -616,6 +621,61 @@ parse_digest_sz(struct cperf_options *opts, const char *arg)
return parse_uint16_t(&opts->digest_sz, arg);
}
+static int
+parse_pdcp_sn_sz(struct cperf_options *opts, const char *arg)
+{
+ uint32_t val = 0;
+ int ret = parse_uint32_t(&val, arg);
+
+ if (ret < 0)
+ return ret;
+
+ if (val != RTE_SECURITY_PDCP_SN_SIZE_5 &&
+ val != RTE_SECURITY_PDCP_SN_SIZE_7 &&
+ val != RTE_SECURITY_PDCP_SN_SIZE_12 &&
+ val != RTE_SECURITY_PDCP_SN_SIZE_15 &&
+ val != RTE_SECURITY_PDCP_SN_SIZE_18) {
+ printf("\nInvalid pdcp SN size: %u\n", val);
+ return -ERANGE;
+ }
+ opts->pdcp_sn_sz = val;
+
+ return 0;
+}
+
+const char *cperf_pdcp_domain_strs[] = {
+ [RTE_SECURITY_PDCP_MODE_CONTROL] = "control",
+ [RTE_SECURITY_PDCP_MODE_DATA] = "data"
+};
+
+static int
+parse_pdcp_domain(struct cperf_options *opts, const char *arg)
+{
+ struct name_id_map pdcp_domain_namemap[] = {
+ {
+ cperf_pdcp_domain_strs
+ [RTE_SECURITY_PDCP_MODE_CONTROL],
+ RTE_SECURITY_PDCP_MODE_CONTROL },
+ {
+ cperf_pdcp_domain_strs
+ [RTE_SECURITY_PDCP_MODE_DATA],
+ RTE_SECURITY_PDCP_MODE_DATA
+ }
+ };
+
+ int id = get_str_key_id_mapping(pdcp_domain_namemap,
+ RTE_DIM(pdcp_domain_namemap), arg);
+ if (id < 0) {
+ RTE_LOG(ERR, USER1, "invalid pdcp domain specified"
+ "\n");
+ return -1;
+ }
+
+ opts->pdcp_domain = (enum rte_security_pdcp_domain)id;
+
+ return 0;
+}
+
static int
parse_auth_iv_sz(struct cperf_options *opts, const char *arg)
{
@@ -755,6 +815,8 @@ static struct option lgopts[] = {
{ CPERF_AEAD_IV_SZ, required_argument, 0, 0 },
{ CPERF_DIGEST_SZ, required_argument, 0, 0 },
+ { CPERF_PDCP_SN_SZ, required_argument, 0, 0 },
+ { CPERF_PDCP_DOMAIN, required_argument, 0, 0 },
{ CPERF_CSV, no_argument, 0, 0},
@@ -822,6 +884,8 @@ cperf_options_default(struct cperf_options *opts)
opts->digest_sz = 12;
opts->pmdcc_delay = 0;
+ opts->pdcp_sn_sz = 12;
+ opts->pdcp_domain = RTE_SECURITY_PDCP_MODE_CONTROL;
}
static int
@@ -857,6 +921,8 @@ cperf_opts_parse_long(int opt_idx, struct cperf_options *opts)
{ CPERF_AEAD_IV_SZ, parse_aead_iv_sz },
{ CPERF_AEAD_AAD_SZ, parse_aead_aad_sz },
{ CPERF_DIGEST_SZ, parse_digest_sz },
+ { CPERF_PDCP_SN_SZ, parse_pdcp_sn_sz },
+ { CPERF_PDCP_DOMAIN, parse_pdcp_domain },
{ CPERF_CSV, parse_csv_friendly},
{ CPERF_PMDCC_DELAY_MS, parse_pmd_cyclecount_delay_ms},
};
diff --git a/app/test-crypto-perf/cperf_test_common.c b/app/test-crypto-perf/cperf_test_common.c
index e803dc10c..85603eed5 100644
--- a/app/test-crypto-perf/cperf_test_common.c
+++ b/app/test-crypto-perf/cperf_test_common.c
@@ -30,6 +30,7 @@ fill_single_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp,
mbuf_offset + mbuf_hdr_size;
m->buf_len = segment_sz;
m->data_len = data_len;
+ m->pkt_len = data_len;
/* Use headroom specified for the buffer */
m->data_off = headroom;
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 9a5d0d95b..a72f88cbb 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -5,6 +5,7 @@
#include <rte_malloc.h>
#include <rte_cycles.h>
#include <rte_crypto.h>
+#include <rte_security.h>
#include <rte_cryptodev.h>
#include "cperf_test_throughput.h"
@@ -32,17 +33,24 @@ struct cperf_throughput_ctx {
static void
cperf_throughput_test_free(struct cperf_throughput_ctx *ctx)
{
- if (ctx) {
- if (ctx->sess) {
+ if (!ctx)
+ return;
+ if (ctx->sess) {
+ if (ctx->options->op_type == CPERF_PDCP) {
+ struct rte_security_ctx *sec_ctx =
+ (struct rte_security_ctx *)
+ rte_cryptodev_get_sec_ctx(ctx->dev_id);
+ rte_security_session_destroy(sec_ctx,
+ (struct rte_security_session *)ctx->sess);
+ } else {
rte_cryptodev_sym_session_clear(ctx->dev_id, ctx->sess);
rte_cryptodev_sym_session_free(ctx->sess);
}
-
- if (ctx->pool)
- rte_mempool_free(ctx->pool);
-
- rte_free(ctx);
}
+ if (ctx->pool)
+ rte_mempool_free(ctx->pool);
+
+ rte_free(ctx);
}
void *
diff --git a/app/test-crypto-perf/cperf_test_vectors.c b/app/test-crypto-perf/cperf_test_vectors.c
index 1af952499..41641650c 100644
--- a/app/test-crypto-perf/cperf_test_vectors.c
+++ b/app/test-crypto-perf/cperf_test_vectors.c
@@ -412,6 +412,61 @@ cperf_test_vector_get_dummy(struct cperf_options *options)
t_vec->plaintext.data = plaintext;
t_vec->plaintext.length = options->max_buffer_size;
+ if (options->op_type == CPERF_PDCP) {
+ if (options->cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
+ t_vec->cipher_key.length = 0;
+ t_vec->ciphertext.data = plaintext;
+ t_vec->cipher_key.data = NULL;
+ } else {
+ t_vec->cipher_key.length = options->cipher_key_sz;
+ t_vec->ciphertext.data = ciphertext;
+ t_vec->cipher_key.data = cipher_key;
+ }
+
+ /* Init IV data ptr */
+ t_vec->cipher_iv.data = NULL;
+
+ if (options->cipher_iv_sz != 0) {
+ /* Set IV parameters */
+ t_vec->cipher_iv.data = rte_malloc(NULL,
+ options->cipher_iv_sz, 16);
+ if (t_vec->cipher_iv.data == NULL) {
+ rte_free(t_vec);
+ return NULL;
+ }
+ memcpy(t_vec->cipher_iv.data, iv, options->cipher_iv_sz);
+ }
+ t_vec->ciphertext.length = options->max_buffer_size;
+ t_vec->cipher_iv.length = options->cipher_iv_sz;
+ t_vec->data.cipher_offset = 0;
+ t_vec->data.cipher_length = options->max_buffer_size;
+ if (options->auth_algo == RTE_CRYPTO_AUTH_NULL) {
+ t_vec->auth_key.length = 0;
+ t_vec->auth_key.data = NULL;
+ t_vec->digest.data = NULL;
+ t_vec->digest.length = 0;
+ } else {
+ t_vec->auth_key.length = options->auth_key_sz;
+ t_vec->auth_key.data = auth_key;
+
+ t_vec->digest.data = rte_malloc(NULL,
+ options->digest_sz,
+ 16);
+ if (t_vec->digest.data == NULL) {
+ rte_free(t_vec->cipher_iv.data);
+ rte_free(t_vec);
+ return NULL;
+ }
+ t_vec->digest.phys_addr =
+ rte_malloc_virt2iova(t_vec->digest.data);
+ t_vec->digest.length = options->digest_sz;
+ memcpy(t_vec->digest.data, digest,
+ options->digest_sz);
+ }
+ t_vec->data.auth_offset = 0;
+ t_vec->data.auth_length = options->max_buffer_size;
+ }
+
if (options->op_type == CPERF_CIPHER_ONLY ||
options->op_type == CPERF_CIPHER_THEN_AUTH ||
options->op_type == CPERF_AUTH_THEN_CIPHER) {
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 2109e7007..52a1860fb 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -38,7 +38,8 @@ const char *cperf_op_type_strs[] = {
[CPERF_AUTH_ONLY] = "auth-only",
[CPERF_CIPHER_THEN_AUTH] = "cipher-then-auth",
[CPERF_AUTH_THEN_CIPHER] = "auth-then-cipher",
- [CPERF_AEAD] = "aead"
+ [CPERF_AEAD] = "aead",
+ [CPERF_PDCP] = "pdcp"
};
const struct cperf_test cperf_testmap[] = {
diff --git a/app/test-crypto-perf/meson.build b/app/test-crypto-perf/meson.build
index d735b186f..1783b2a26 100644
--- a/app/test-crypto-perf/meson.build
+++ b/app/test-crypto-perf/meson.build
@@ -2,6 +2,8 @@
# Copyright(c) 2018 Intel Corporation
allow_experimental_apis = true
+
+deps += ['security']
sources = files('cperf_ops.c',
'cperf_options_parsing.c',
'cperf_test_common.c',
diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst
index a4aa99a93..877595cad 100644
--- a/doc/guides/rel_notes/release_19_11.rst
+++ b/doc/guides/rel_notes/release_19_11.rst
@@ -189,7 +189,7 @@ New Features
PDCP support is added to DPAA_SEC and DPAA2_SEC PMDs using rte_security APIs.
Support is added for all sequence number sizes for control and user plane.
- Test application is updated for unit testing.
+ Test and test-crypto-perf application is updated for unit testing.
* **Enabled Single Pass GCM acceleration on QAT GEN3.**
diff --git a/doc/guides/tools/cryptoperf.rst b/doc/guides/tools/cryptoperf.rst
index 2fc65441d..a19ccb262 100644
--- a/doc/guides/tools/cryptoperf.rst
+++ b/doc/guides/tools/cryptoperf.rst
@@ -192,6 +192,7 @@ The following are the application command-line options:
cipher-then-auth
auth-then-cipher
aead
+ pdcp
For GCM/CCM algorithms you should use aead flag.
@@ -332,6 +333,15 @@ The following are the application command-line options:
Enable test result output CSV friendly rather than human friendly.
+* ``--pdcp-sn-sz <n>``
+
+ Set PDCP sequence number size(n) in bits. Valid values of n will
+ be 5/7/12/15/18.
+
+* ``--pdcp-domain <control/user>``
+
+ Set PDCP domain to specify Control/user plane.
+
Test Vector File
~~~~~~~~~~~~~~~~
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH v2] app/test-crypto-perf: support PDCP
2019-11-07 12:59 [dpdk-dev] [PATCH v2] app/test-crypto-perf: support PDCP Akhil Goyal
@ 2019-11-07 14:10 ` Hemant Agrawal
0 siblings, 0 replies; 2+ messages in thread
From: Hemant Agrawal @ 2019-11-07 14:10 UTC (permalink / raw)
To: Akhil Goyal, dev
Cc: declan.doherty, anoobj, konstantin.ananyev, Akhil Goyal, Manish Tomar
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-07 14:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07 12:59 [dpdk-dev] [PATCH v2] app/test-crypto-perf: support PDCP Akhil Goyal
2019-11-07 14:10 ` Hemant Agrawal
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).