#include "cperf_ops.h"
-struct cperf_latency_results {
-
- uint64_t ops_failed;
-
- uint64_t enqd_tot;
- uint64_t enqd_max;
- uint64_t enqd_min;
-
- uint64_t deqd_tot;
- uint64_t deqd_max;
- uint64_t deqd_min;
-
- uint64_t cycles_tot;
- uint64_t cycles_max;
- uint64_t cycles_min;
-
- uint64_t burst_num;
- uint64_t num;
-};
-
struct cperf_op_result {
uint64_t tsc_start;
uint64_t tsc_end;
const struct cperf_options *options;
const struct cperf_test_vector *test_vector;
struct cperf_op_result *res;
- struct cperf_latency_results results;
};
#define max(a, b) (a > b ? (uint64_t)a : (uint64_t)b)
goto err;
/* Generate mbufs_in with plaintext populated for test */
- if (ctx->options->pool_sz % ctx->options->burst_sz)
- goto err;
-
ctx->mbufs_in = rte_malloc(NULL,
(sizeof(struct rte_mbuf *) *
ctx->options->pool_sz), 0);
struct cperf_latency_ctx *ctx = arg;
struct cperf_op_result *pres;
+ static int only_once;
+
if (ctx == NULL)
return 0;
struct rte_crypto_op *ops[ctx->options->burst_sz];
struct rte_crypto_op *ops_processed[ctx->options->burst_sz];
- uint64_t ops_enqd = 0, ops_deqd = 0;
- uint64_t m_idx = 0, b_idx = 0, i;
-
- uint64_t tsc_val, tsc_end, tsc_start;
- uint64_t tsc_max = 0, tsc_min = ~0UL, tsc_tot = 0, tsc_idx = 0;
- uint64_t enqd_max = 0, enqd_min = ~0UL, enqd_tot = 0;
- uint64_t deqd_max = 0, deqd_min = ~0UL, deqd_tot = 0;
+ uint64_t i;
uint32_t lcore = rte_lcore_id();
for (i = 0; i < ctx->options->total_ops; i++)
rte_cryptodev_enqueue_burst(ctx->dev_id, ctx->qp_id, NULL, 0);
- while (enqd_tot < ctx->options->total_ops) {
+ uint64_t ops_enqd = 0, ops_deqd = 0;
+ uint64_t m_idx = 0, b_idx = 0;
+
+ uint64_t tsc_val, tsc_end, tsc_start;
+ uint64_t tsc_max = 0, tsc_min = ~0UL, tsc_tot = 0, tsc_idx = 0;
+ uint64_t enqd_max = 0, enqd_min = ~0UL, enqd_tot = 0;
+ uint64_t deqd_max = 0, deqd_min = ~0UL, deqd_tot = 0;
+ while (enqd_tot < ctx->options->total_ops) {
uint16_t burst_size = ((enqd_tot + ctx->options->burst_sz)
<= ctx->options->total_ops) ?
ctx->options->burst_sz :
tsc_tot += tsc_val;
}
- ctx->results.enqd_tot = enqd_tot;
- ctx->results.enqd_max = enqd_max;
- ctx->results.enqd_min = enqd_min;
-
- ctx->results.deqd_tot = deqd_tot;
- ctx->results.deqd_max = deqd_max;
- ctx->results.deqd_min = deqd_min;
-
- ctx->results.cycles_tot = tsc_tot;
- ctx->results.cycles_max = tsc_max;
- ctx->results.cycles_min = tsc_min;
-
- ctx->results.burst_num = b_idx;
- ctx->results.num = tsc_idx;
-
- return 0;
-}
-
-void
-cperf_latency_test_destructor(void *arg)
-{
- struct cperf_latency_ctx *ctx = arg;
- uint64_t i;
- if (ctx == NULL)
- return;
- static int only_once;
- uint64_t etot, eavg, emax, emin;
- uint64_t dtot, davg, dmax, dmin;
- uint64_t ctot, cavg, cmax, cmin;
- double ttot, tavg, tmax, tmin;
+ double time_tot, time_avg, time_max, time_min;
const uint64_t tunit = 1000000; /* us */
const uint64_t tsc_hz = rte_get_tsc_hz();
- etot = ctx->results.enqd_tot;
- eavg = ctx->results.enqd_tot / ctx->results.burst_num;
- emax = ctx->results.enqd_max;
- emin = ctx->results.enqd_min;
-
- dtot = ctx->results.deqd_tot;
- davg = ctx->results.deqd_tot / ctx->results.burst_num;
- dmax = ctx->results.deqd_max;
- dmin = ctx->results.deqd_min;
+ uint64_t enqd_avg = enqd_tot / b_idx;
+ uint64_t deqd_avg = deqd_tot / b_idx;
+ uint64_t tsc_avg = tsc_tot / tsc_idx;
- ctot = ctx->results.cycles_tot;
- cavg = ctx->results.cycles_tot / ctx->results.num;
- cmax = ctx->results.cycles_max;
- cmin = ctx->results.cycles_min;
-
- ttot = tunit*(double)(ctot) / tsc_hz;
- tavg = tunit*(double)(cavg) / tsc_hz;
- tmax = tunit*(double)(cmax) / tsc_hz;
- tmin = tunit*(double)(cmin) / tsc_hz;
+ time_tot = tunit*(double)(tsc_tot) / tsc_hz;
+ time_avg = tunit*(double)(tsc_avg) / tsc_hz;
+ time_max = tunit*(double)(tsc_max) / tsc_hz;
+ time_min = tunit*(double)(tsc_min) / tsc_hz;
if (ctx->options->csv) {
if (!only_once)
- printf("\n# lcore, Pakt Seq #, Packet Size, cycles,"
- " time (us)");
+ printf("\n# lcore, Buffer Size, Burst Size, Pakt Seq #, "
+ "Packet Size, cycles, time (us)");
for (i = 0; i < ctx->options->total_ops; i++) {
- printf("\n%u;%"PRIu64";%"PRIu64";%.3f",
- ctx->lcore_id, i + 1,
+ printf("\n%u;%u;%u;%"PRIu64";%"PRIu64";%.3f",
+ ctx->lcore_id, ctx->options->buffer_sz,
+ ctx->options->burst_sz, i + 1,
ctx->res[i].tsc_end - ctx->res[i].tsc_start,
tunit * (double) (ctx->res[i].tsc_end
- ctx->res[i].tsc_start)
printf("\n# Device %d on lcore %u\n", ctx->dev_id,
ctx->lcore_id);
printf("\n# total operations: %u", ctx->options->total_ops);
- printf("\n# burst number: %"PRIu64,
- ctx->results.burst_num);
+ printf("\n# Buffer size: %u", ctx->options->buffer_sz);
+ printf("\n# Burst size: %u", ctx->options->burst_sz);
+ printf("\n# Number of bursts: %"PRIu64,
+ b_idx);
+
printf("\n#");
- printf("\n# \t Total\t Average\t Maximum\t "
- " Minimum");
- printf("\n# enqueued\t%12"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t"
- "%10"PRIu64, etot, eavg, emax, emin);
- printf("\n# dequeued\t%12"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t"
- "%10"PRIu64, dtot, davg, dmax, dmin);
- printf("\n# cycles\t%12"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t"
- "%10"PRIu64, ctot, cavg, cmax, cmin);
- printf("\n# time [us]\t%12.0f\t%10.3f\t%10.3f\t%10.3f", ttot,
- tavg, tmax, tmin);
+ printf("\n# \t Total\t Average\t "
+ "Maximum\t Minimum");
+ printf("\n# enqueued\t%12"PRIu64"\t%10"PRIu64"\t"
+ "%10"PRIu64"\t%10"PRIu64, enqd_tot,
+ enqd_avg, enqd_max, enqd_min);
+ printf("\n# dequeued\t%12"PRIu64"\t%10"PRIu64"\t"
+ "%10"PRIu64"\t%10"PRIu64, deqd_tot,
+ deqd_avg, deqd_max, deqd_min);
+ printf("\n# cycles\t%12"PRIu64"\t%10"PRIu64"\t"
+ "%10"PRIu64"\t%10"PRIu64, tsc_tot,
+ tsc_avg, tsc_max, tsc_min);
+ printf("\n# time [us]\t%12.0f\t%10.3f\t%10.3f\t%10.3f",
+ time_tot, time_avg, time_max, time_min);
printf("\n\n");
}
+
+ return 0;
+}
+
+void
+cperf_latency_test_destructor(void *arg)
+{
+ struct cperf_latency_ctx *ctx = arg;
+
+ if (ctx == NULL)
+ return;
+
cperf_latency_test_free(ctx, ctx->options->pool_sz);
}
#include "cperf_test_throughput.h"
#include "cperf_ops.h"
-struct cperf_throughput_results {
- uint64_t ops_enqueued;
- uint64_t ops_dequeued;
-
- uint64_t ops_enqueued_failed;
- uint64_t ops_dequeued_failed;
-
- double ops_per_second;
- double throughput_gbps;
- double cycles_per_byte;
-};
-
struct cperf_throughput_ctx {
uint8_t dev_id;
uint16_t qp_id;
const struct cperf_options *options;
const struct cperf_test_vector *test_vector;
- struct cperf_throughput_results results;
-
};
static void
goto err;
/* Generate mbufs_in with plaintext populated for test */
- if (ctx->options->pool_sz % ctx->options->burst_sz)
- goto err;
-
ctx->mbufs_in = rte_malloc(NULL,
(sizeof(struct rte_mbuf *) * ctx->options->pool_sz), 0);
{
struct cperf_throughput_ctx *ctx = test_ctx;
- uint64_t ops_enqd = 0, ops_enqd_total = 0, ops_enqd_failed = 0;
- uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0;
-
- uint64_t i, m_idx = 0, tsc_start, tsc_end, tsc_duration;
-
- uint16_t ops_unused = 0;
+ static int only_once;
struct rte_crypto_op *ops[ctx->options->burst_sz];
struct rte_crypto_op *ops_processed[ctx->options->burst_sz];
+ uint64_t i;
uint32_t lcore = rte_lcore_id();
ctx->lcore_id = lcore;
- if (!ctx->options->csv)
- printf("\n# Running throughput test on device: %u, lcore: %u\n",
- ctx->dev_id, lcore);
-
/* Warm up the host CPU before starting the test */
for (i = 0; i < ctx->options->total_ops; i++)
rte_cryptodev_enqueue_burst(ctx->dev_id, ctx->qp_id, NULL, 0);
- tsc_start = rte_rdtsc_precise();
+ uint64_t ops_enqd = 0, ops_enqd_total = 0, ops_enqd_failed = 0;
+ uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0;
+ uint64_t m_idx = 0, tsc_start, tsc_end, tsc_duration;
+ tsc_start = rte_rdtsc_precise();
while (ops_enqd_total < ctx->options->total_ops) {
+ uint16_t ops_unused = 0;
+
uint16_t burst_size = ((ops_enqd_total + ctx->options->burst_sz)
<= ctx->options->total_ops) ?
ctx->options->burst_sz :
tsc_duration = (tsc_end - tsc_start);
/* Calculate average operations processed per second */
- ctx->results.ops_per_second = ((double)ctx->options->total_ops /
+ double ops_per_second = ((double)ctx->options->total_ops /
tsc_duration) * rte_get_tsc_hz();
/* Calculate average throughput (Gbps) in bits per second */
- ctx->results.throughput_gbps = ((ctx->results.ops_per_second *
+ double throughput_gbps = ((ops_per_second *
ctx->options->buffer_sz * 8) / 1000000000);
- /* Calculate average cycles per byte */
- ctx->results.cycles_per_byte = ((double)tsc_duration /
- ctx->options->total_ops) / ctx->options->buffer_sz;
+ /* Calculate average cycles per packet */
+ double cycles_per_packet = ((double)tsc_duration /
+ ctx->options->total_ops);
- ctx->results.ops_enqueued = ops_enqd_total;
- ctx->results.ops_dequeued = ops_deqd_total;
+ if (!ctx->options->csv) {
+ if (!only_once)
+ printf("%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s\n\n",
+ "lcore id", "Buf Size", "Burst Size",
+ "Enqueued", "Dequeued", "Failed Enq",
+ "Failed Deq", "MOps", "Gbps",
+ "Cycles/Buf");
+ only_once = 1;
+
+ printf("%12u%12u%12u%12"PRIu64"%12"PRIu64"%12"PRIu64
+ "%12"PRIu64"%12.4f%12.4f%12.2f\n",
+ ctx->lcore_id,
+ ctx->options->buffer_sz,
+ ctx->options->burst_sz,
+ ops_enqd_total,
+ ops_deqd_total,
+ ops_enqd_failed,
+ ops_deqd_failed,
+ ops_per_second/1000000,
+ throughput_gbps,
+ cycles_per_packet);
+ } else {
+ if (!only_once)
+ printf("# lcore id, Buffer Size(B),"
+ "Burst Size,Enqueued,Dequeued,Failed Enq,"
+ "Failed Deq,Ops(Millions),Throughput(Gbps),"
+ "Cycles/Buf\n\n");
+ only_once = 1;
- ctx->results.ops_enqueued_failed = ops_enqd_failed;
- ctx->results.ops_dequeued_failed = ops_deqd_failed;
+ printf("%10u;%10u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";"
+ "%.f3;%.f3;%.f3\n",
+ ctx->lcore_id,
+ ctx->options->buffer_sz,
+ ctx->options->burst_sz,
+ ops_enqd_total,
+ ops_deqd_total,
+ ops_enqd_failed,
+ ops_deqd_failed,
+ ops_per_second/1000000,
+ throughput_gbps,
+ cycles_per_packet);
+ }
return 0;
}
cperf_throughput_test_destructor(void *arg)
{
struct cperf_throughput_ctx *ctx = arg;
- struct cperf_throughput_results *results = &ctx->results;
- static int only_once;
if (ctx == NULL)
return;
- if (!ctx->options->csv) {
- printf("\n# Device %d on lcore %u\n",
- ctx->dev_id, ctx->lcore_id);
- printf("# Buffer Size(B)\t Enqueued\t Dequeued\tFailed Enq"
- "\tFailed Deq\tOps(Millions)\tThroughput(Gbps)"
- "\tCycles Per Byte\n");
-
- printf("\n%16u\t%10"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t"
- "%10"PRIu64"\t%16.4f\t%16.4f\t%15.2f\n",
- ctx->options->buffer_sz,
- results->ops_enqueued,
- results->ops_dequeued,
- results->ops_enqueued_failed,
- results->ops_dequeued_failed,
- results->ops_per_second/1000000,
- results->throughput_gbps,
- results->cycles_per_byte);
- } else {
- if (!only_once)
- printf("\n# CPU lcore id, Burst Size(B), "
- "Buffer Size(B),Enqueued,Dequeued,Failed Enq,"
- "Failed Deq,Ops(Millions),Throughput(Gbps),"
- "Cycles Per Byte\n");
- only_once = 1;
-
- printf("%u;%u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";"
- "%.f3;%.f3;%.f3\n",
- ctx->lcore_id,
- ctx->options->burst_sz,
- ctx->options->buffer_sz,
- results->ops_enqueued,
- results->ops_dequeued,
- results->ops_enqueued_failed,
- results->ops_dequeued_failed,
- results->ops_per_second/1000000,
- results->throughput_gbps,
- results->cycles_per_byte);
- }
-
cperf_throughput_test_free(ctx, ctx->options->pool_sz);
}
#include "cperf_test_verify.h"
#include "cperf_ops.h"
-struct cperf_verify_results {
- uint64_t ops_enqueued;
- uint64_t ops_dequeued;
-
- uint64_t ops_enqueued_failed;
- uint64_t ops_dequeued_failed;
-
- uint64_t ops_failed;
-};
-
struct cperf_verify_ctx {
uint8_t dev_id;
uint16_t qp_id;
const struct cperf_options *options;
const struct cperf_test_vector *test_vector;
- struct cperf_verify_results results;
-
};
struct cperf_op_result {
goto err;
/* Generate mbufs_in with plaintext populated for test */
- if (ctx->options->pool_sz % ctx->options->burst_sz)
- goto err;
-
ctx->mbufs_in = rte_malloc(NULL,
(sizeof(struct rte_mbuf *) * ctx->options->pool_sz), 0);
if (options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
res += memcmp(data + auth_offset,
vector->digest.data,
- vector->digest.length);
+ options->auth_digest_sz);
}
return !!res;
uint64_t ops_enqd = 0, ops_enqd_total = 0, ops_enqd_failed = 0;
uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0;
+ uint64_t ops_failed = 0;
+
+ static int only_once;
uint64_t i, m_idx = 0;
uint16_t ops_unused = 0;
for (i = 0; i < ops_deqd; i++) {
if (cperf_verify_op(ops_processed[i], ctx->options,
ctx->test_vector))
- ctx->results.ops_failed++;
+ ops_failed++;
/* free crypto ops so they can be reused. We don't free
* the mbufs here as we don't want to reuse them as
* the crypto operation will change the data and cause
* failures.
*/
rte_crypto_op_free(ops_processed[i]);
- ops_deqd_total += ops_deqd;
}
+ ops_deqd_total += ops_deqd;
}
/* Dequeue any operations still in the crypto device */
for (i = 0; i < ops_deqd; i++) {
if (cperf_verify_op(ops_processed[i], ctx->options,
ctx->test_vector))
- ctx->results.ops_failed++;
+ ops_failed++;
/* free crypto ops so they can be reused. We don't free
* the mbufs here as we don't want to reuse them as
* the crypto operation will change the data and cause
* failures.
*/
rte_crypto_op_free(ops_processed[i]);
- ops_deqd_total += ops_deqd;
}
+ ops_deqd_total += ops_deqd;
}
- ctx->results.ops_enqueued = ops_enqd_total;
- ctx->results.ops_dequeued = ops_deqd_total;
+ if (!ctx->options->csv) {
+ if (!only_once)
+ printf("%12s%12s%12s%12s%12s%12s%12s%12s\n\n",
+ "lcore id", "Buf Size", "Burst size",
+ "Enqueued", "Dequeued", "Failed Enq",
+ "Failed Deq", "Failed Ops");
+ only_once = 1;
+
+ printf("%12u%12u%12u%12"PRIu64"%12"PRIu64"%12"PRIu64
+ "%12"PRIu64"%12"PRIu64"\n",
+ ctx->lcore_id,
+ ctx->options->buffer_sz,
+ ctx->options->burst_sz,
+ ops_enqd_total,
+ ops_deqd_total,
+ ops_enqd_failed,
+ ops_deqd_failed,
+ ops_failed);
+ } else {
+ if (!only_once)
+ printf("\n# lcore id, Buffer Size(B), "
+ "Burst Size,Enqueued,Dequeued,Failed Enq,"
+ "Failed Deq,Failed Ops\n");
+ only_once = 1;
- ctx->results.ops_enqueued_failed = ops_enqd_failed;
- ctx->results.ops_dequeued_failed = ops_deqd_failed;
+ printf("%10u;%10u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";"
+ "%"PRIu64"\n",
+ ctx->lcore_id,
+ ctx->options->buffer_sz,
+ ctx->options->burst_sz,
+ ops_enqd_total,
+ ops_deqd_total,
+ ops_enqd_failed,
+ ops_deqd_failed,
+ ops_failed);
+ }
return 0;
}
cperf_verify_test_destructor(void *arg)
{
struct cperf_verify_ctx *ctx = arg;
- struct cperf_verify_results *results = &ctx->results;
- static int only_once;
if (ctx == NULL)
return;
- if (!ctx->options->csv) {
- printf("\n# Device %d on lcore %u\n",
- ctx->dev_id, ctx->lcore_id);
- printf("# Buffer Size(B)\t Enqueued\t Dequeued\tFailed Enq"
- "\tFailed Deq\tEmpty Polls\n");
-
- printf("\n%16u\t%10"PRIu64"\t%10"PRIu64"\t%10"PRIu64"\t"
- "%10"PRIu64"\t%10"PRIu64"\n",
- ctx->options->buffer_sz,
- results->ops_enqueued,
- results->ops_dequeued,
- results->ops_enqueued_failed,
- results->ops_dequeued_failed,
- results->ops_failed);
- } else {
- if (!only_once)
- printf("\n# CPU lcore id, Burst Size(B), "
- "Buffer Size(B),Enqueued,Dequeued,Failed Enq,"
- "Failed Deq,Empty Polls\n");
- only_once = 1;
-
- printf("%u;%u;%u;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";"
- "%"PRIu64"\n",
- ctx->lcore_id,
- ctx->options->burst_sz,
- ctx->options->buffer_sz,
- results->ops_enqueued,
- results->ops_dequeued,
- results->ops_enqueued_failed,
- results->ops_dequeued_failed,
- results->ops_failed);
- }
-
cperf_verify_test_free(ctx, ctx->options->pool_sz);
}