| 1334 | } |
| 1335 | |
| 1336 | int |
| 1337 | rte_cryptodev_close(uint8_t dev_id) |
| 1338 | { |
| 1339 | struct rte_cryptodev *dev; |
| 1340 | int retval; |
| 1341 | |
| 1342 | if (!rte_cryptodev_is_valid_dev(dev_id)) { |
| 1343 | CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); |
| 1344 | return -1; |
| 1345 | } |
| 1346 | |
| 1347 | dev = &rte_crypto_devices[dev_id]; |
| 1348 | |
| 1349 | /* Device must be stopped before it can be closed */ |
| 1350 | if (dev->data->dev_started == 1) { |
| 1351 | CDEV_LOG_ERR("Device %u must be stopped before closing", |
| 1352 | dev_id); |
| 1353 | return -EBUSY; |
| 1354 | } |
| 1355 | |
| 1356 | /* We can't close the device if there are outstanding sessions in use */ |
| 1357 | if (dev->data->session_pool != NULL) { |
| 1358 | if (!rte_mempool_full(dev->data->session_pool)) { |
| 1359 | CDEV_LOG_ERR("dev_id=%u close failed, session mempool " |
| 1360 | "has sessions still in use, free " |
| 1361 | "all sessions before calling close", |
| 1362 | (unsigned)dev_id); |
| 1363 | return -EBUSY; |
| 1364 | } |
| 1365 | } |
| 1366 | |
| 1367 | if (*dev->dev_ops->dev_close == NULL) |
| 1368 | return -ENOTSUP; |
| 1369 | retval = (*dev->dev_ops->dev_close)(dev); |
| 1370 | rte_cryptodev_trace_close(dev_id, retval); |
| 1371 | |
| 1372 | if (retval < 0) |
| 1373 | return retval; |
| 1374 | |
| 1375 | return 0; |
| 1376 | } |
| 1377 | |
| 1378 | int |
| 1379 | rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id) |