This patch add in multi-process IPC request handler function in rte
cryptodev. This function intend to support a queue-pair configuration
request to allow the secondary process to reconfigure the queue-pair
setup'ed by the primary process.

Signed-off-by: Kai Ji <kai...@intel.com>
---
 lib/cryptodev/rte_cryptodev.c | 45 +++++++++++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev.h | 14 +++++++++++
 2 files changed, 59 insertions(+)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 42f3221052..18fdbf6db6 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -1202,6 +1202,51 @@ rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t 
queue_pair_id)
        return 0;
 }
 
+/* crypto queue pair config */
+#define CRYPTODEV_MP_REQ "cryptodev_mp_request"
+
+static int
+rte_cryptodev_mp_request(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+       struct rte_mp_msg mp_res;
+       struct rte_cryptodev_mp_param *res =
+               (struct rte_cryptodev_mp_param *)mp_res.param;
+       const struct rte_cryptodev_mp_param *param =
+               (const struct rte_cryptodev_mp_param *)mp_msg->param;
+
+       int ret;
+       int dev_id = 0;
+       int port_id = 0, socket_id = 1;
+       struct rte_cryptodev_qp_conf queue_conf;
+       queue_conf.nb_descriptors = 2;
+
+       RTE_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+       switch (param->type) {
+       case RTE_CRYPTODEV_MP_REQ_QP:
+               ret = rte_cryptodev_queue_pair_setup(dev_id, port_id,
+                               &queue_conf, socket_id);
+               res->result = ret;
+
+               ret = rte_mp_reply(&mp_res, peer);
+               break;
+       default:
+               CDEV_LOG_ERR("invalid mp request type\n");
+               return -EINVAL;
+       }
+       return ret;
+
+}
+
+int rte_cryptodev_mp_request_register(void)
+{
+       int ret;
+
+       RTE_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
+       ret = rte_mp_action_register(CRYPTODEV_MP_REQ,
+                               rte_cryptodev_mp_request);
+       return ret;
+}
+
 int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
                const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 56f459c6a0..901465ca65 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -539,6 +539,18 @@ enum rte_cryptodev_event_type {
        RTE_CRYPTODEV_EVENT_MAX         /**< max value of this enum */
 };
 
+/* Request types for IPC. */
+enum rte_cryptodev_mp_req_type {
+       RTE_CRYPTODEV_MP_REQ_NONE,
+       RTE_CRYPTODEV_MP_REQ_QP
+};
+
+/* Parameters for IPC. */
+struct rte_cryptodev_mp_param {
+       enum rte_cryptodev_mp_req_type type;
+       int result;
+};
+
 /** Crypto device queue pair configuration structure. */
 struct rte_cryptodev_qp_conf {
        uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
@@ -744,6 +756,8 @@ rte_cryptodev_stop(uint8_t dev_id);
 extern int
 rte_cryptodev_close(uint8_t dev_id);
 
+extern int rte_cryptodev_mp_request_register(void);
+
 /**
  * Allocate and set up a receive queue pair for a device.
  *
-- 
2.17.1

Reply via email to