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

Function rte_vhost_crypto_create

dpdk/lib/vhost/vhost_crypto.c:1384–1464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382}
1383
1384int
1385rte_vhost_crypto_create(int vid, uint8_t cryptodev_id,
1386 struct rte_mempool *sess_pool,
1387 int socket_id)
1388{
1389 struct virtio_net *dev = get_device(vid);
1390 struct rte_hash_parameters params = {0};
1391 struct vhost_crypto *vcrypto;
1392 char name[128];
1393 int ret;
1394
1395 if (!dev) {
1396 VC_LOG_ERR("Invalid vid %i", vid);
1397 return -EINVAL;
1398 }
1399
1400 vcrypto = rte_zmalloc_socket(NULL, sizeof(*vcrypto),
1401 RTE_CACHE_LINE_SIZE, socket_id);
1402 if (!vcrypto) {
1403 VC_LOG_ERR("Insufficient memory");
1404 return -ENOMEM;
1405 }
1406
1407 vcrypto->sess_pool = sess_pool;
1408 vcrypto->cid = cryptodev_id;
1409 vcrypto->cache_session_id = UINT64_MAX;
1410 vcrypto->last_session_id = 1;
1411 vcrypto->dev = dev;
1412 vcrypto->option = RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE;
1413
1414 snprintf(name, 127, "HASH_VHOST_CRYPT_%u", (uint32_t)vid);
1415 params.name = name;
1416 params.entries = VHOST_CRYPTO_SESSION_MAP_ENTRIES;
1417 params.hash_func = rte_jhash;
1418 params.key_len = sizeof(uint64_t);
1419 params.socket_id = socket_id;
1420 vcrypto->session_map = rte_hash_create(&params);
1421 if (!vcrypto->session_map) {
1422 VC_LOG_ERR("Failed to creath session map");
1423 ret = -ENOMEM;
1424 goto error_exit;
1425 }
1426
1427 snprintf(name, 127, "MBUF_POOL_VM_%u", (uint32_t)vid);
1428 vcrypto->mbuf_pool = rte_pktmbuf_pool_create(name,
1429 VHOST_CRYPTO_MBUF_POOL_SIZE, 512,
1430 sizeof(struct vhost_crypto_data_req),
1431 VHOST_CRYPTO_MAX_DATA_SIZE + RTE_PKTMBUF_HEADROOM,
1432 rte_socket_id());
1433 if (!vcrypto->mbuf_pool) {
1434 VC_LOG_ERR("Failed to creath mbuf pool");
1435 ret = -ENOMEM;
1436 goto error_exit;
1437 }
1438
1439 snprintf(name, 127, "WB_POOL_VM_%u", (uint32_t)vid);
1440 vcrypto->wb_pool = rte_mempool_create(name,
1441 VHOST_CRYPTO_MBUF_POOL_SIZE,

Callers 1

new_deviceFunction · 0.85

Calls 10

get_deviceFunction · 0.85
rte_zmalloc_socketFunction · 0.85
snprintfFunction · 0.85
rte_hash_createFunction · 0.85
rte_pktmbuf_pool_createFunction · 0.85
rte_socket_idFunction · 0.85
rte_mempool_createFunction · 0.85
rte_hash_freeFunction · 0.85
rte_mempool_freeFunction · 0.85
rte_freeFunction · 0.85

Tested by

no test coverage detected