| 272 | } |
| 273 | |
| 274 | static int |
| 275 | new_device(int vid) |
| 276 | { |
| 277 | struct vhost_crypto_info *info = NULL; |
| 278 | char path[PATH_MAX]; |
| 279 | uint32_t i, j; |
| 280 | int ret; |
| 281 | |
| 282 | ret = rte_vhost_get_ifname(vid, path, PATH_MAX); |
| 283 | if (ret) { |
| 284 | RTE_LOG(ERR, USER1, "Cannot find matched socket\n"); |
| 285 | return ret; |
| 286 | } |
| 287 | |
| 288 | for (i = 0; i < options.nb_los; i++) { |
| 289 | for (j = 0; j < options.los[i].nb_sockets; j++) { |
| 290 | if (strcmp(path, options.los[i].socket_files[j]) == 0) { |
| 291 | info = options.infos[i]; |
| 292 | break; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | if (info) |
| 297 | break; |
| 298 | } |
| 299 | |
| 300 | if (!info) { |
| 301 | RTE_LOG(ERR, USER1, "Cannot find recorded socket\n"); |
| 302 | return -ENOENT; |
| 303 | } |
| 304 | |
| 305 | ret = rte_vhost_crypto_create(vid, info->cid, info->sess_pool, |
| 306 | rte_lcore_to_socket_id(options.los[i].lcore_id)); |
| 307 | if (ret) { |
| 308 | RTE_LOG(ERR, USER1, "Cannot create vhost crypto\n"); |
| 309 | return ret; |
| 310 | } |
| 311 | |
| 312 | ret = rte_vhost_crypto_set_zero_copy(vid, options.zero_copy); |
| 313 | if (ret) { |
| 314 | RTE_LOG(ERR, USER1, "Cannot %s zero copy feature\n", |
| 315 | options.zero_copy == 1 ? "enable" : "disable"); |
| 316 | return ret; |
| 317 | } |
| 318 | |
| 319 | info->vids[j] = vid; |
| 320 | info->initialized[j] = 1; |
| 321 | |
| 322 | rte_wmb(); |
| 323 | |
| 324 | RTE_LOG(INFO, USER1, "New Vhost-crypto Device %s, Device ID %d\n", path, |
| 325 | vid); |
| 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | static void |
| 330 | destroy_device(int vid) |
nothing calls this directly
no test coverage detected