crypto/octeontx: add basic device operations
Adding the following dev ops, - dev_configure - dev_start - dev_stop - dev_close - dev_infos_get - stats_get - stats_reset Signed-off-by: Ankur Dwivedi <ankur.dwivedi@caviumnetworks.com> Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com> Signed-off-by: Murthy NSSR <nidadavolu.murthy@caviumnetworks.com> Signed-off-by: Nithin Dabilpuram <nithin.dabilpuram@caviumnetworks.com> Signed-off-by: Ragothaman Jayaraman <rjayaraman@caviumnetworks.com> Signed-off-by: Srisivasubramanian S <ssrinivasan@caviumnetworks.com> Signed-off-by: Tejasree Kondoj <kondoj.tejasree@caviumnetworks.com>
This commit is contained in:
parent
ae50054152
commit
0906b99f34
@ -2,6 +2,7 @@
|
|||||||
* Copyright(c) 2018 Cavium, Inc
|
* Copyright(c) 2018 Cavium, Inc
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <rte_branch_prediction.h>
|
#include <rte_branch_prediction.h>
|
||||||
#include <rte_common.h>
|
#include <rte_common.h>
|
||||||
@ -260,3 +261,58 @@ otx_cpt_deinit_device(void *dev)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
otx_cpt_start_device(void *dev)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
struct cpt_vf *cptvf = (struct cpt_vf *)dev;
|
||||||
|
|
||||||
|
rc = otx_cpt_send_vf_up(cptvf);
|
||||||
|
if (rc) {
|
||||||
|
CPT_LOG_ERR("Failed to mark CPT VF device %s UP, rc = %d",
|
||||||
|
cptvf->dev_name, rc);
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((cptvf->vftype != SE_TYPE) && (cptvf->vftype != AE_TYPE)) {
|
||||||
|
CPT_LOG_ERR("Fatal error, unexpected vf type %u, for CPT VF "
|
||||||
|
"device %s", cptvf->vftype, cptvf->dev_name);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
otx_cpt_stop_device(void *dev)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
uint32_t pending, retries = 5;
|
||||||
|
struct cpt_vf *cptvf = (struct cpt_vf *)dev;
|
||||||
|
|
||||||
|
/* Wait for pending entries to complete */
|
||||||
|
pending = otx_cpt_read_vq_doorbell(cptvf);
|
||||||
|
while (pending) {
|
||||||
|
CPT_LOG_DP_DEBUG("%s: Waiting for pending %u cmds to complete",
|
||||||
|
cptvf->dev_name, pending);
|
||||||
|
sleep(1);
|
||||||
|
pending = otx_cpt_read_vq_doorbell(cptvf);
|
||||||
|
retries--;
|
||||||
|
if (!retries)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!retries && pending) {
|
||||||
|
CPT_LOG_ERR("%s: Timeout waiting for commands(%u)",
|
||||||
|
cptvf->dev_name, pending);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = otx_cpt_send_vf_down(cptvf);
|
||||||
|
if (rc) {
|
||||||
|
CPT_LOG_ERR("Failed to bring down vf %s, rc %d",
|
||||||
|
cptvf->dev_name, rc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <rte_memory.h>
|
#include <rte_memory.h>
|
||||||
|
|
||||||
#include "cpt_common.h"
|
#include "cpt_common.h"
|
||||||
|
#include "cpt_hw_types.h"
|
||||||
|
|
||||||
#define CPT_INTR_POLL_INTERVAL_MS (50)
|
#define CPT_INTR_POLL_INTERVAL_MS (50)
|
||||||
|
|
||||||
@ -145,4 +146,33 @@ otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void *reg_base, char *name);
|
|||||||
int
|
int
|
||||||
otx_cpt_deinit_device(void *dev);
|
otx_cpt_deinit_device(void *dev);
|
||||||
|
|
||||||
|
int
|
||||||
|
otx_cpt_start_device(void *cptvf);
|
||||||
|
|
||||||
|
void
|
||||||
|
otx_cpt_stop_device(void *cptvf);
|
||||||
|
|
||||||
|
/* Write to VQX_DOORBELL register
|
||||||
|
*/
|
||||||
|
static __rte_always_inline void
|
||||||
|
otx_cpt_write_vq_doorbell(struct cpt_vf *cptvf, uint32_t val)
|
||||||
|
{
|
||||||
|
cptx_vqx_doorbell_t vqx_dbell;
|
||||||
|
|
||||||
|
vqx_dbell.u = 0;
|
||||||
|
vqx_dbell.s.dbell_cnt = val * 8; /* Num of Instructions * 8 words */
|
||||||
|
CPT_WRITE_CSR(CPT_CSR_REG_BASE(cptvf),
|
||||||
|
CPTX_VQX_DOORBELL(0, 0), vqx_dbell.u);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __rte_always_inline uint32_t
|
||||||
|
otx_cpt_read_vq_doorbell(struct cpt_vf *cptvf)
|
||||||
|
{
|
||||||
|
cptx_vqx_doorbell_t vqx_dbell;
|
||||||
|
|
||||||
|
vqx_dbell.u = CPT_READ_CSR(CPT_CSR_REG_BASE(cptvf),
|
||||||
|
CPTX_VQX_DOORBELL(0, 0));
|
||||||
|
return vqx_dbell.s.dbell_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _OTX_CRYPTODEV_HW_ACCESS_H_ */
|
#endif /* _OTX_CRYPTODEV_HW_ACCESS_H_ */
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
#include <rte_alarm.h>
|
#include <rte_alarm.h>
|
||||||
#include <rte_bus_pci.h>
|
#include <rte_bus_pci.h>
|
||||||
#include <rte_cryptodev.h>
|
#include <rte_cryptodev.h>
|
||||||
|
#include <rte_cryptodev_pmd.h>
|
||||||
#include <rte_malloc.h>
|
#include <rte_malloc.h>
|
||||||
|
|
||||||
#include "cpt_pmd_logs.h"
|
#include "cpt_pmd_logs.h"
|
||||||
#include "cpt_pmd_ops_helper.h"
|
#include "cpt_pmd_ops_helper.h"
|
||||||
|
|
||||||
#include "otx_cryptodev.h"
|
#include "otx_cryptodev.h"
|
||||||
|
#include "otx_cryptodev_capabilities.h"
|
||||||
#include "otx_cryptodev_hw_access.h"
|
#include "otx_cryptodev_hw_access.h"
|
||||||
#include "otx_cryptodev_ops.h"
|
#include "otx_cryptodev_ops.h"
|
||||||
|
|
||||||
@ -95,6 +97,97 @@ otx_cpt_periodic_alarm_stop(void *arg)
|
|||||||
return rte_eal_alarm_cancel(otx_cpt_alarm_cb, arg);
|
return rte_eal_alarm_cancel(otx_cpt_alarm_cb, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PMD ops */
|
||||||
|
|
||||||
|
static int
|
||||||
|
otx_cpt_dev_config(struct rte_cryptodev *dev __rte_unused,
|
||||||
|
struct rte_cryptodev_config *config __rte_unused)
|
||||||
|
{
|
||||||
|
CPT_PMD_INIT_FUNC_TRACE();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
otx_cpt_dev_start(struct rte_cryptodev *c_dev)
|
||||||
|
{
|
||||||
|
void *cptvf = c_dev->data->dev_private;
|
||||||
|
|
||||||
|
CPT_PMD_INIT_FUNC_TRACE();
|
||||||
|
|
||||||
|
return otx_cpt_start_device(cptvf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
otx_cpt_dev_stop(struct rte_cryptodev *c_dev)
|
||||||
|
{
|
||||||
|
void *cptvf = c_dev->data->dev_private;
|
||||||
|
|
||||||
|
CPT_PMD_INIT_FUNC_TRACE();
|
||||||
|
|
||||||
|
otx_cpt_stop_device(cptvf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
otx_cpt_dev_close(struct rte_cryptodev *c_dev)
|
||||||
|
{
|
||||||
|
void *cptvf = c_dev->data->dev_private;
|
||||||
|
|
||||||
|
CPT_PMD_INIT_FUNC_TRACE();
|
||||||
|
|
||||||
|
otx_cpt_periodic_alarm_stop(cptvf);
|
||||||
|
otx_cpt_deinit_device(cptvf);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
otx_cpt_dev_info_get(struct rte_cryptodev *dev, struct rte_cryptodev_info *info)
|
||||||
|
{
|
||||||
|
CPT_PMD_INIT_FUNC_TRACE();
|
||||||
|
if (info != NULL) {
|
||||||
|
info->max_nb_queue_pairs = CPT_NUM_QS_PER_VF;
|
||||||
|
info->feature_flags = dev->feature_flags;
|
||||||
|
info->capabilities = otx_get_capabilities();
|
||||||
|
info->sym.max_nb_sessions = 0;
|
||||||
|
info->driver_id = otx_cryptodev_driver_id;
|
||||||
|
info->min_mbuf_headroom_req = OTX_CPT_MIN_HEADROOM_REQ;
|
||||||
|
info->min_mbuf_tailroom_req = OTX_CPT_MIN_TAILROOM_REQ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
otx_cpt_stats_get(struct rte_cryptodev *dev __rte_unused,
|
||||||
|
struct rte_cryptodev_stats *stats __rte_unused)
|
||||||
|
{
|
||||||
|
CPT_PMD_INIT_FUNC_TRACE();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
otx_cpt_stats_reset(struct rte_cryptodev *dev __rte_unused)
|
||||||
|
{
|
||||||
|
CPT_PMD_INIT_FUNC_TRACE();
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct rte_cryptodev_ops cptvf_ops = {
|
||||||
|
/* Device related operations */
|
||||||
|
.dev_configure = otx_cpt_dev_config,
|
||||||
|
.dev_start = otx_cpt_dev_start,
|
||||||
|
.dev_stop = otx_cpt_dev_stop,
|
||||||
|
.dev_close = otx_cpt_dev_close,
|
||||||
|
.dev_infos_get = otx_cpt_dev_info_get,
|
||||||
|
|
||||||
|
.stats_get = otx_cpt_stats_get,
|
||||||
|
.stats_reset = otx_cpt_stats_reset,
|
||||||
|
.queue_pair_setup = NULL,
|
||||||
|
.queue_pair_release = NULL,
|
||||||
|
.queue_pair_count = NULL,
|
||||||
|
|
||||||
|
/* Crypto related operations */
|
||||||
|
.sym_session_get_size = NULL,
|
||||||
|
.sym_session_configure = NULL,
|
||||||
|
.sym_session_clear = NULL
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
otx_cpt_common_vars_init(struct cpt_vf *cptvf)
|
otx_cpt_common_vars_init(struct cpt_vf *cptvf)
|
||||||
{
|
{
|
||||||
@ -164,7 +257,7 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
|
|||||||
/* Initialize data path variables used by common code */
|
/* Initialize data path variables used by common code */
|
||||||
otx_cpt_common_vars_init(cptvf);
|
otx_cpt_common_vars_init(cptvf);
|
||||||
|
|
||||||
c_dev->dev_ops = NULL;
|
c_dev->dev_ops = &cptvf_ops;
|
||||||
|
|
||||||
c_dev->enqueue_burst = NULL;
|
c_dev->enqueue_burst = NULL;
|
||||||
c_dev->dequeue_burst = NULL;
|
c_dev->dequeue_burst = NULL;
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
#ifndef _OTX_CRYPTODEV_OPS_H_
|
#ifndef _OTX_CRYPTODEV_OPS_H_
|
||||||
#define _OTX_CRYPTODEV_OPS_H_
|
#define _OTX_CRYPTODEV_OPS_H_
|
||||||
|
|
||||||
|
#define OTX_CPT_MIN_HEADROOM_REQ (24)
|
||||||
|
#define OTX_CPT_MIN_TAILROOM_REQ (8)
|
||||||
|
#define CPT_NUM_QS_PER_VF (1)
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanup_global_resources(void);
|
cleanup_global_resources(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user