From: Fan Zhang Date: Fri, 28 Sep 2018 12:26:11 +0000 (+0100) Subject: examples/ip_pipeline: configure crypto port X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e1884698f688eddee352c1bbe0ecb007bd2ed205;p=dpdk.git examples/ip_pipeline: configure crypto port This patch adds symmetric crypto port configuration to ip_pipeline sample application. Signed-off-by: Fan Zhang Acked-by: Cristian Dumitrescu --- diff --git a/examples/ip_pipeline/pipeline.c b/examples/ip_pipeline/pipeline.c index b2fd215b1b..b23d6c09af 100644 --- a/examples/ip_pipeline/pipeline.c +++ b/examples/ip_pipeline/pipeline.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -36,6 +37,7 @@ #include "tap.h" #include "tmgr.h" #include "swq.h" +#include "cryptodev.h" #ifndef PIPELINE_MSGQ_SIZE #define PIPELINE_MSGQ_SIZE 64 @@ -162,6 +164,7 @@ pipeline_port_in_create(const char *pipeline_name, struct rte_port_kni_reader_params kni; #endif struct rte_port_source_params source; + struct rte_port_sym_crypto_reader_params sym_crypto; } pp; struct pipeline *pipeline; @@ -295,6 +298,27 @@ pipeline_port_in_create(const char *pipeline_name, break; } + case PORT_IN_CRYPTODEV: + { + struct cryptodev *cryptodev; + + cryptodev = cryptodev_find(params->dev_name); + if (cryptodev == NULL) + return -1; + + if (params->rxq.queue_id > cryptodev->n_queues - 1) + return -1; + + pp.sym_crypto.cryptodev_id = cryptodev->dev_id; + pp.sym_crypto.queue_id = params->cryptodev.queue_id; + pp.sym_crypto.f_callback = params->cryptodev.f_callback; + pp.sym_crypto.arg_callback = params->cryptodev.arg_callback; + p.ops = &rte_port_sym_crypto_reader_ops; + p.arg_create = &pp.sym_crypto; + + break; + } + default: return -1; } @@ -384,6 +408,7 @@ pipeline_port_out_create(const char *pipeline_name, struct rte_port_kni_writer_params kni; #endif struct rte_port_sink_params sink; + struct rte_port_sym_crypto_writer_params sym_crypto; } pp; union { @@ -393,6 +418,7 @@ pipeline_port_out_create(const char *pipeline_name, #ifdef RTE_LIBRTE_KNI struct rte_port_kni_writer_nodrop_params kni; #endif + struct rte_port_sym_crypto_writer_nodrop_params sym_crypto; } pp_nodrop; struct pipeline *pipeline; @@ -548,6 +574,40 @@ pipeline_port_out_create(const char *pipeline_name, break; } + case PORT_OUT_CRYPTODEV: + { + struct cryptodev *cryptodev; + + cryptodev = cryptodev_find(params->dev_name); + if (cryptodev == NULL) + return -1; + + if (params->cryptodev.queue_id >= cryptodev->n_queues) + return -1; + + pp.sym_crypto.cryptodev_id = cryptodev->dev_id; + pp.sym_crypto.queue_id = params->cryptodev.queue_id; + pp.sym_crypto.tx_burst_sz = params->burst_size; + pp.sym_crypto.crypto_op_offset = params->cryptodev.op_offset; + + pp_nodrop.sym_crypto.cryptodev_id = cryptodev->dev_id; + pp_nodrop.sym_crypto.queue_id = params->cryptodev.queue_id; + pp_nodrop.sym_crypto.tx_burst_sz = params->burst_size; + pp_nodrop.sym_crypto.n_retries = params->retry; + pp_nodrop.sym_crypto.crypto_op_offset = + params->cryptodev.op_offset; + + if (params->retry == 0) { + p.ops = &rte_port_sym_crypto_writer_ops; + p.arg_create = &pp.sym_crypto; + } else { + p.ops = &rte_port_sym_crypto_writer_nodrop_ops; + p.arg_create = &pp_nodrop.sym_crypto; + } + + break; + } + default: return -1; } diff --git a/examples/ip_pipeline/pipeline.h b/examples/ip_pipeline/pipeline.h index a953a29fa8..fb283e558e 100644 --- a/examples/ip_pipeline/pipeline.h +++ b/examples/ip_pipeline/pipeline.h @@ -27,6 +27,7 @@ enum port_in_type { PORT_IN_TAP, PORT_IN_KNI, PORT_IN_SOURCE, + PORT_IN_CRYPTODEV, }; struct port_in_params { @@ -48,6 +49,12 @@ struct port_in_params { const char *file_name; uint32_t n_bytes_per_pkt; } source; + + struct { + uint16_t queue_id; + void *f_callback; + void *arg_callback; + } cryptodev; }; uint32_t burst_size; @@ -62,6 +69,7 @@ enum port_out_type { PORT_OUT_TAP, PORT_OUT_KNI, PORT_OUT_SINK, + PORT_OUT_CRYPTODEV, }; struct port_out_params { @@ -76,6 +84,11 @@ struct port_out_params { const char *file_name; uint32_t max_n_pkts; } sink; + + struct { + uint16_t queue_id; + uint32_t op_offset; + } cryptodev; }; uint32_t burst_size; int retry;