[dpdk-dev,12/16] crypto/cpt: adds some more callback functions for CPT
diff mbox series

Message ID 1528476325-15585-13-git-send-email-anoob.joseph@caviumnetworks.com
State Superseded, archived
Delegated to: akhil goyal
Headers show
Series
  • Adding Cavium's crypto device(CPT) driver
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Anoob Joseph June 8, 2018, 4:45 p.m. UTC
From: Srisivasubramanian Srinivasan <Srisivasubramanian.Srinivasan@cavium.com>

This patch does the following:
1. Adds the stats callback functions for the cpt vf.
2. Adds the queue pair setup and queue pair release callback
functions for cpt vf.

Signed-off-by: Ankur Dwivedi <ankur.dwivedi@cavium.com>
Signed-off-by: Murthy NSSR <Nidadavolu.Murthy@cavium.com>
Signed-off-by: Nithin Dabilpuram <nithin.dabilpuram@cavium.com>
Signed-off-by: Ragothaman Jayaraman <Ragothaman.Jayaraman@cavium.com>
Signed-off-by: Srisivasubramanian Srinivasan <Srisivasubramanian.Srinivasan@cavium.com>
---
 drivers/crypto/cpt/cpt_pmd_cryptodev.c |  8 ++---
 drivers/crypto/cpt/cpt_pmd_ops.c       | 63 ++++++++++++++++++++++++++++++++++
 drivers/crypto/cpt/cpt_pmd_ops.h       | 11 ++++++
 3 files changed, 78 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/drivers/crypto/cpt/cpt_pmd_cryptodev.c b/drivers/crypto/cpt/cpt_pmd_cryptodev.c
index 3939b5e..3961ec8 100644
--- a/drivers/crypto/cpt/cpt_pmd_cryptodev.c
+++ b/drivers/crypto/cpt/cpt_pmd_cryptodev.c
@@ -53,10 +53,10 @@ 
 	.dev_close = cpt_pmd_dev_close,
 	.dev_infos_get = cptvf_dev_info_get,
 
-	.stats_get = NULL,
-	.stats_reset = NULL,
-	.queue_pair_setup = NULL,
-	.queue_pair_release = NULL,
+	.stats_get = cpt_pmd_stats_get,
+	.stats_reset = cpt_pmd_stats_reset,
+	.queue_pair_setup = cpt_pmd_que_pair_setup,
+	.queue_pair_release = cpt_pmd_que_pair_release,
 	.queue_pair_start = NULL,
 	.queue_pair_stop = NULL,
 	.queue_pair_count = NULL,
diff --git a/drivers/crypto/cpt/cpt_pmd_ops.c b/drivers/crypto/cpt/cpt_pmd_ops.c
index 2f066cb..1c60191 100644
--- a/drivers/crypto/cpt/cpt_pmd_ops.c
+++ b/drivers/crypto/cpt/cpt_pmd_ops.c
@@ -523,6 +523,69 @@  int cpt_pmd_dev_close(struct rte_cryptodev *c_dev)
 	}
 }
 
+void
+cpt_pmd_stats_get(struct rte_cryptodev *dev __rte_unused,
+		  struct rte_cryptodev_stats *stats __rte_unused)
+{
+	PMD_INIT_FUNC_TRACE();
+}
+
+void cpt_pmd_stats_reset(struct rte_cryptodev *dev __rte_unused)
+{
+	PMD_INIT_FUNC_TRACE();
+}
+
+int
+cpt_pmd_que_pair_setup(struct rte_cryptodev *dev,
+		       uint16_t que_pair_id,
+		       const struct rte_cryptodev_qp_conf *qp_conf,
+		       int socket_id __rte_unused,
+		       struct rte_mempool *session_pool __rte_unused)
+{
+	struct cpt_vf *cptvf = dev->data->dev_private;
+	cpt_instance_t *instance = NULL;
+	struct rte_pci_device *pci_dev;
+	int ret = -1;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (dev->data->queue_pairs[que_pair_id] != NULL) {
+		ret = cpt_pmd_que_pair_release(dev, que_pair_id);
+		if (ret)
+			return ret;
+	}
+
+	if (qp_conf->nb_descriptors > DEFAULT_CMD_QLEN) {
+		PMD_DRV_LOG(INFO, "Number of descriptors too big %d,"
+			    " using default queue length of %d\n",
+			    qp_conf->nb_descriptors, DEFAULT_CMD_QLEN);
+	}
+
+	pci_dev = RTE_DEV_TO_PCI(dev->device);
+
+	if (pci_dev->mem_resource[0].addr == NULL) {
+		PMD_DRV_LOG(ERR, "PCI mem address null");
+		return -EIO;
+	}
+
+	/*
+	 * FIXME: We always setup a queue with DEFAULT_CMD_QLEN size
+	 * in get_hw_resource.
+	 */
+	ret = cptvf_get_resource(cptvf, 0, &instance);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error getting instance handle"
+				" from device %s : ret = %d\n",
+				dev->data->name, ret);
+		return ret;
+	}
+
+	instance->queue_id = que_pair_id;
+	dev->data->queue_pairs[que_pair_id] = instance;
+
+	return 0;
+}
+
 int
 cpt_pmd_que_pair_release(struct rte_cryptodev *dev, uint16_t que_pair_id)
 {
diff --git a/drivers/crypto/cpt/cpt_pmd_ops.h b/drivers/crypto/cpt/cpt_pmd_ops.h
index 015b4a2..db2024b 100644
--- a/drivers/crypto/cpt/cpt_pmd_ops.h
+++ b/drivers/crypto/cpt/cpt_pmd_ops.h
@@ -58,7 +58,18 @@  int cpt_pmd_dev_config(struct rte_cryptodev *dev __rte_unused,
 
 void cptvf_dev_info_get(struct rte_cryptodev *dev,
 			  struct rte_cryptodev_info *inf);
+int
+cpt_pmd_que_pair_setup(struct rte_cryptodev *dev,
+		   uint16_t que_pair_id,
+		   const struct rte_cryptodev_qp_conf *qp_conf,
+		   int socket_id,
+		   struct rte_mempool *session_pool);
 
 int cpt_pmd_que_pair_release(struct rte_cryptodev *dev, uint16_t que_pair_id);
 
+void cpt_pmd_stats_get(struct rte_cryptodev *dev,
+		   struct rte_cryptodev_stats *stats);
+
+void cpt_pmd_stats_reset(struct rte_cryptodev *dev);
+
 #endif