* cryptodev */
| 196 | * cryptodev |
| 197 | */ |
| 198 | int |
| 199 | cryptodev_config(const char *name, struct cryptodev_params *params) |
| 200 | { |
| 201 | struct rte_cryptodev_info dev_info; |
| 202 | struct rte_cryptodev_config dev_conf; |
| 203 | struct rte_cryptodev_qp_conf queue_conf; |
| 204 | uint8_t dev_id; |
| 205 | uint32_t socket_id, i; |
| 206 | int status; |
| 207 | |
| 208 | /* Check input parameters. */ |
| 209 | if (!name || |
| 210 | !params->n_queue_pairs || |
| 211 | !params->queue_size) |
| 212 | return -EINVAL; |
| 213 | |
| 214 | /* Find the crypto device. */ |
| 215 | status = rte_cryptodev_get_dev_id(name); |
| 216 | if (status < 0) |
| 217 | return -EINVAL; |
| 218 | |
| 219 | dev_id = (uint8_t)status; |
| 220 | |
| 221 | rte_cryptodev_info_get(dev_id, &dev_info); |
| 222 | if (params->n_queue_pairs > dev_info.max_nb_queue_pairs) |
| 223 | return -EINVAL; |
| 224 | |
| 225 | socket_id = rte_cryptodev_socket_id(dev_id); |
| 226 | |
| 227 | /* Configure the crypto device. */ |
| 228 | memset(&dev_conf, 0, sizeof(dev_conf)); |
| 229 | dev_conf.socket_id = socket_id; |
| 230 | dev_conf.nb_queue_pairs = params->n_queue_pairs; |
| 231 | dev_conf.ff_disable = 0; |
| 232 | |
| 233 | status = rte_cryptodev_configure(dev_id, &dev_conf); |
| 234 | if (status) |
| 235 | return status; |
| 236 | |
| 237 | /* Configure the crypto device queue pairs. */ |
| 238 | memset(&queue_conf, 0, sizeof(queue_conf)); |
| 239 | queue_conf.nb_descriptors = params->queue_size; |
| 240 | queue_conf.mp_session = NULL; |
| 241 | |
| 242 | for (i = 0; i < params->n_queue_pairs; i++) { |
| 243 | status = rte_cryptodev_queue_pair_setup(dev_id, i, &queue_conf, socket_id); |
| 244 | if (status) |
| 245 | return status; |
| 246 | } |
| 247 | |
| 248 | /* Start the crypto device. */ |
| 249 | status = rte_cryptodev_start(dev_id); |
| 250 | if (status) |
| 251 | return status; |
| 252 | |
| 253 | return 0; |
| 254 | } |
no test coverage detected