MCPcopy Create free account
hub / github.com/F-Stack/f-stack / new_device

Function new_device

dpdk/examples/vhost_crypto/main.c:274–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274static int
275new_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
329static void
330destroy_device(int vid)

Callers

nothing calls this directly

Calls 5

rte_vhost_get_ifnameFunction · 0.85
strcmpFunction · 0.85
rte_vhost_crypto_createFunction · 0.85
rte_lcore_to_socket_idFunction · 0.85

Tested by

no test coverage detected