| 1221 | } |
| 1222 | |
| 1223 | int |
| 1224 | rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config) |
| 1225 | { |
| 1226 | struct rte_cryptodev *dev; |
| 1227 | int diag; |
| 1228 | |
| 1229 | if (!rte_cryptodev_is_valid_dev(dev_id)) { |
| 1230 | CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); |
| 1231 | return -EINVAL; |
| 1232 | } |
| 1233 | |
| 1234 | dev = &rte_crypto_devices[dev_id]; |
| 1235 | |
| 1236 | if (dev->data->dev_started) { |
| 1237 | CDEV_LOG_ERR( |
| 1238 | "device %d must be stopped to allow configuration", dev_id); |
| 1239 | return -EBUSY; |
| 1240 | } |
| 1241 | |
| 1242 | if (*dev->dev_ops->dev_configure == NULL) |
| 1243 | return -ENOTSUP; |
| 1244 | |
| 1245 | rte_spinlock_lock(&rte_cryptodev_callback_lock); |
| 1246 | cryptodev_cb_cleanup(dev); |
| 1247 | rte_spinlock_unlock(&rte_cryptodev_callback_lock); |
| 1248 | |
| 1249 | /* Setup new number of queue pairs and reconfigure device. */ |
| 1250 | diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs, |
| 1251 | config->socket_id); |
| 1252 | if (diag != 0) { |
| 1253 | CDEV_LOG_ERR("dev%d rte_crypto_dev_queue_pairs_config = %d", |
| 1254 | dev_id, diag); |
| 1255 | return diag; |
| 1256 | } |
| 1257 | |
| 1258 | rte_spinlock_lock(&rte_cryptodev_callback_lock); |
| 1259 | diag = cryptodev_cb_init(dev); |
| 1260 | rte_spinlock_unlock(&rte_cryptodev_callback_lock); |
| 1261 | if (diag) { |
| 1262 | CDEV_LOG_ERR("Callback init failed for dev_id=%d", dev_id); |
| 1263 | return diag; |
| 1264 | } |
| 1265 | |
| 1266 | rte_cryptodev_trace_configure(dev_id, config); |
| 1267 | return (*dev->dev_ops->dev_configure)(dev, config); |
| 1268 | } |
| 1269 | |
| 1270 | int |
| 1271 | rte_cryptodev_start(uint8_t dev_id) |