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

Function rte_cryptodev_asym_session_create

dpdk/lib/cryptodev/rte_cryptodev.c:2138–2212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2136}
2137
2138int
2139rte_cryptodev_asym_session_create(uint8_t dev_id,
2140 struct rte_crypto_asym_xform *xforms, struct rte_mempool *mp,
2141 void **session)
2142{
2143 struct rte_cryptodev_asym_session *sess;
2144 uint32_t session_priv_data_sz;
2145 struct rte_cryptodev_asym_session_pool_private_data *pool_priv;
2146 unsigned int session_header_size =
2147 rte_cryptodev_asym_get_header_session_size();
2148 struct rte_cryptodev *dev;
2149 int ret;
2150
2151 if (!rte_cryptodev_is_valid_dev(dev_id)) {
2152 CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
2153 return -EINVAL;
2154 }
2155
2156 dev = rte_cryptodev_pmd_get_dev(dev_id);
2157
2158 if (dev == NULL)
2159 return -EINVAL;
2160
2161 if (!mp) {
2162 CDEV_LOG_ERR("invalid mempool");
2163 return -EINVAL;
2164 }
2165
2166 session_priv_data_sz = rte_cryptodev_asym_get_private_session_size(
2167 dev_id);
2168 pool_priv = rte_mempool_get_priv(mp);
2169
2170 if (pool_priv->max_priv_session_sz < session_priv_data_sz) {
2171 CDEV_LOG_DEBUG(
2172 "The private session data size used when creating the mempool is smaller than this device's private session data.");
2173 return -EINVAL;
2174 }
2175
2176 /* Verify if provided mempool can hold elements big enough. */
2177 if (mp->elt_size < session_header_size + session_priv_data_sz) {
2178 CDEV_LOG_ERR(
2179 "mempool elements too small to hold session objects");
2180 return -EINVAL;
2181 }
2182
2183 /* Allocate a session structure from the session pool */
2184 if (rte_mempool_get(mp, session)) {
2185 CDEV_LOG_ERR("couldn't get object from session mempool");
2186 return -ENOMEM;
2187 }
2188
2189 sess = *session;
2190 sess->driver_id = dev->driver_id;
2191 sess->user_data_sz = pool_priv->user_data_sz;
2192 sess->max_priv_data_sz = pool_priv->max_priv_session_sz;
2193
2194 /* Clear device session pointer.*/
2195 memset(sess->sess_private_data, 0, session_priv_data_sz + sess->user_data_sz);

Callers 15

cperf_create_sessionFunction · 0.85
test_rsa_sign_verifyFunction · 0.85
test_rsa_enc_decFunction · 0.85
test_rsa_sign_verify_crtFunction · 0.85
test_rsa_enc_dec_crtFunction · 0.85
test_dh_gen_shared_secFunction · 0.85
test_dh_gen_priv_keyFunction · 0.85
test_dh_gen_pub_keyFunction · 0.85
test_dh_gen_kpFunction · 0.85
test_mod_invFunction · 0.85
test_mod_expFunction · 0.85
test_dsa_signFunction · 0.85

Calls 7

rte_mempool_get_privFunction · 0.85
rte_mempool_getFunction · 0.85
memsetFunction · 0.85

Tested by 15

test_rsa_sign_verifyFunction · 0.68
test_rsa_enc_decFunction · 0.68
test_rsa_sign_verify_crtFunction · 0.68
test_rsa_enc_dec_crtFunction · 0.68
test_dh_gen_shared_secFunction · 0.68
test_dh_gen_priv_keyFunction · 0.68
test_dh_gen_pub_keyFunction · 0.68
test_dh_gen_kpFunction · 0.68
test_mod_invFunction · 0.68
test_mod_expFunction · 0.68
test_dsa_signFunction · 0.68
test_dsa_verifyFunction · 0.68