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

Function pdcp_crypto_sess_create

dpdk/lib/pdcp/pdcp_crypto.c:166–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166int
167pdcp_crypto_sess_create(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_conf *conf)
168{
169 struct rte_crypto_sym_xform *c_xfrm, *a_xfrm;
170 struct entity_priv *en_priv;
171 bool is_auth_then_cipher;
172 int ret;
173
174 if (entity == NULL || conf == NULL || conf->crypto_xfrm == NULL)
175 return -EINVAL;
176
177 en_priv = entity_priv_get(entity);
178
179 en_priv->dev_id = conf->dev_id;
180
181 if (conf->crypto_xfrm->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {
182 c_xfrm = conf->crypto_xfrm;
183 a_xfrm = conf->crypto_xfrm->next;
184 is_auth_then_cipher = false;
185 } else if (conf->crypto_xfrm->type == RTE_CRYPTO_SYM_XFORM_AUTH) {
186 a_xfrm = conf->crypto_xfrm;
187 c_xfrm = conf->crypto_xfrm->next;
188 is_auth_then_cipher = true;
189 } else {
190 return -EINVAL;
191 }
192
193 ret = pdcp_crypto_xfrm_validate(conf, c_xfrm, a_xfrm, is_auth_then_cipher);
194 if (ret)
195 return ret;
196
197 if (c_xfrm->cipher.algo == RTE_CRYPTO_CIPHER_NULL)
198 c_xfrm->cipher.iv.offset = 0;
199 else
200 c_xfrm->cipher.iv.offset = PDCP_IV_OFFSET;
201
202 if (a_xfrm != NULL) {
203 if (a_xfrm->auth.algo == RTE_CRYPTO_AUTH_NULL)
204 a_xfrm->auth.iv.offset = 0;
205 else
206 if (c_xfrm->cipher.iv.offset)
207 a_xfrm->auth.iv.offset = PDCP_IV_OFFSET + PDCP_IV_LEN;
208 else
209 a_xfrm->auth.iv.offset = PDCP_IV_OFFSET;
210 }
211
212 if (conf->sess_mpool == NULL)
213 return -EINVAL;
214
215 en_priv->crypto_sess = rte_cryptodev_sym_session_create(conf->dev_id, conf->crypto_xfrm,
216 conf->sess_mpool);
217 if (en_priv->crypto_sess == NULL) {
218 /* rte_errno is set as positive values of error codes */
219 return -rte_errno;
220 }
221
222 rte_cryptodev_sym_session_opaque_data_set(en_priv->crypto_sess, (uint64_t)entity);
223

Callers 1

Tested by

no test coverage detected