examples/ip_pipeline: configure crypto port
authorFan Zhang <roy.fan.zhang@intel.com>
Fri, 28 Sep 2018 12:26:11 +0000 (13:26 +0100)
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>
Fri, 12 Oct 2018 17:33:11 +0000 (19:33 +0200)
This patch adds symmetric crypto port configuration to ip_pipeline
sample application.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
examples/ip_pipeline/pipeline.c
examples/ip_pipeline/pipeline.h

index b2fd215..b23d6c0 100644 (file)
@@ -18,6 +18,7 @@
 #include <rte_port_source_sink.h>
 #include <rte_port_fd.h>
 #include <rte_port_sched.h>
+#include <rte_port_sym_crypto.h>
 
 #include <rte_table_acl.h>
 #include <rte_table_array.h>
@@ -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;
        }
index a953a29..fb283e5 100644 (file)
@@ -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;