* Create a new crypto device. * * @param name Driver name. * @param vdev Pointer to device structure. * @param init_params Pointer to initialization parameters. * @returns 0 in case of success, negative value otherwise. */
| 1049 | * @returns 0 in case of success, negative value otherwise. |
| 1050 | */ |
| 1051 | static int |
| 1052 | cryptodev_mrvl_crypto_create(const char *name, |
| 1053 | struct rte_vdev_device *vdev, |
| 1054 | struct mrvl_pmd_init_params *init_params) |
| 1055 | { |
| 1056 | struct rte_cryptodev *dev; |
| 1057 | struct mrvl_crypto_private *internals; |
| 1058 | struct sam_init_params sam_params; |
| 1059 | struct rte_security_ctx *security_instance; |
| 1060 | int ret = -EINVAL; |
| 1061 | |
| 1062 | dev = rte_cryptodev_pmd_create(name, &vdev->device, |
| 1063 | &init_params->common); |
| 1064 | if (dev == NULL) { |
| 1065 | MRVL_LOG(ERR, "Failed to create cryptodev vdev!"); |
| 1066 | goto init_error; |
| 1067 | } |
| 1068 | |
| 1069 | dev->driver_id = cryptodev_driver_id; |
| 1070 | dev->dev_ops = rte_mrvl_crypto_pmd_ops; |
| 1071 | |
| 1072 | /* Register rx/tx burst functions for data path. */ |
| 1073 | dev->enqueue_burst = mrvl_crypto_pmd_enqueue_burst; |
| 1074 | dev->dequeue_burst = mrvl_crypto_pmd_dequeue_burst; |
| 1075 | |
| 1076 | dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | |
| 1077 | RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING | |
| 1078 | RTE_CRYPTODEV_FF_HW_ACCELERATED | |
| 1079 | RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT | |
| 1080 | RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT | |
| 1081 | RTE_CRYPTODEV_FF_SECURITY; |
| 1082 | |
| 1083 | internals = dev->data->dev_private; |
| 1084 | |
| 1085 | internals->max_nb_qpairs = init_params->common.max_nb_queue_pairs; |
| 1086 | internals->max_nb_sessions = init_params->max_nb_sessions; |
| 1087 | |
| 1088 | ret = rte_mvep_init(MVEP_MOD_T_SAM, NULL); |
| 1089 | if (ret) |
| 1090 | goto init_error; |
| 1091 | |
| 1092 | sam_params.max_num_sessions = internals->max_nb_sessions; |
| 1093 | |
| 1094 | /* Initialize security_ctx only for primary process*/ |
| 1095 | security_instance = rte_malloc("rte_security_instances_ops", |
| 1096 | sizeof(struct rte_security_ctx), 0); |
| 1097 | if (security_instance == NULL) |
| 1098 | return -ENOMEM; |
| 1099 | security_instance->device = (void *)dev; |
| 1100 | security_instance->ops = rte_mrvl_security_pmd_ops; |
| 1101 | security_instance->sess_cnt = 0; |
| 1102 | dev->security_ctx = security_instance; |
| 1103 | |
| 1104 | /*sam_set_debug_flags(3);*/ |
| 1105 | |
| 1106 | ret = sam_init(&sam_params); |
| 1107 | if (ret) |
| 1108 | goto init_error; |
no test coverage detected