| 2305 | } |
| 2306 | |
| 2307 | static int |
| 2308 | initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports, |
| 2309 | uint8_t *enabled_cdevs) |
| 2310 | { |
| 2311 | uint8_t cdev_id, cdev_count, enabled_cdev_count = 0; |
| 2312 | const struct rte_cryptodev_capabilities *cap; |
| 2313 | unsigned int sess_sz, max_sess_sz = 0; |
| 2314 | uint32_t sessions_needed = 0; |
| 2315 | int retval; |
| 2316 | |
| 2317 | cdev_count = rte_cryptodev_count(); |
| 2318 | if (cdev_count == 0) { |
| 2319 | printf("No crypto devices available\n"); |
| 2320 | return -1; |
| 2321 | } |
| 2322 | |
| 2323 | for (cdev_id = 0; cdev_id < cdev_count && enabled_cdev_count < nb_ports; |
| 2324 | cdev_id++) { |
| 2325 | if (check_cryptodev_mask(options, cdev_id) < 0) |
| 2326 | continue; |
| 2327 | |
| 2328 | if (check_capabilities(options, cdev_id) < 0) |
| 2329 | continue; |
| 2330 | |
| 2331 | sess_sz = rte_cryptodev_sym_get_private_session_size(cdev_id); |
| 2332 | if (sess_sz > max_sess_sz) |
| 2333 | max_sess_sz = sess_sz; |
| 2334 | |
| 2335 | l2fwd_enabled_crypto_mask |= (((uint64_t)1) << cdev_id); |
| 2336 | |
| 2337 | enabled_cdevs[cdev_id] = 1; |
| 2338 | enabled_cdev_count++; |
| 2339 | } |
| 2340 | |
| 2341 | for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) { |
| 2342 | struct rte_cryptodev_qp_conf qp_conf; |
| 2343 | struct rte_cryptodev_info dev_info; |
| 2344 | |
| 2345 | if (enabled_cdevs[cdev_id] == 0) |
| 2346 | continue; |
| 2347 | |
| 2348 | if (check_cryptodev_mask(options, cdev_id) < 0) |
| 2349 | continue; |
| 2350 | |
| 2351 | if (check_capabilities(options, cdev_id) < 0) |
| 2352 | continue; |
| 2353 | |
| 2354 | retval = rte_cryptodev_socket_id(cdev_id); |
| 2355 | |
| 2356 | if (retval < 0) { |
| 2357 | printf("Invalid crypto device id used\n"); |
| 2358 | return -1; |
| 2359 | } |
| 2360 | |
| 2361 | uint8_t socket_id = (uint8_t) retval; |
| 2362 | |
| 2363 | struct rte_cryptodev_config conf = { |
| 2364 | .nb_queue_pairs = 1, |
no test coverage detected