[API-NEXT,v5,1/1] api: crypto: add odp_crypto_session_create2 returning odp_crypto_session_t

Message ID 1496156414-29557-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • api: crypto: make odp_crypto_session_create return odp_crypto_session_t
Related show

Commit Message

Github ODP bot May 30, 2017, 3 p.m.
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Currently odp_crypto_session_create() (unlike other creation functions)
returns int result with session being returned through pointer argument.
Replace it with odp_crypto_session_create2 directly returning a session
(or ODP_CRYPTO_SESSION_INVALID in case of an error).

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 37 (lumag:crypto-create-ret)
 ** https://github.com/Linaro/odp/pull/37
 ** Patch: https://github.com/Linaro/odp/pull/37.patch
 ** Base sha: 552817483e9d4b6a84d49960920f1de50029f111
 ** Merge commit sha: 6f929f89f7e0ffd3726e5f2f799496b8112fa574
 **/
 example/ipsec/odp_ipsec_cache.c                    |  4 +-
 include/odp/api/spec/crypto.h                      | 27 +++++++--
 platform/linux-generic/odp_crypto.c                | 18 +++---
 test/common_plat/performance/odp_crypto.c          | 68 +++++++++++-----------
 .../validation/api/crypto/odp_crypto_test_inp.c    |  6 +-
 5 files changed, 69 insertions(+), 54 deletions(-)

Comments

Bala Manoharan May 30, 2017, 3:06 p.m. | #1
On 30 May 2017 at 20:30, Github ODP bot <odpbot@yandex.ru> wrote:
> From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>

> Currently odp_crypto_session_create() (unlike other creation functions)

> returns int result with session being returned through pointer argument.

> Replace it with odp_crypto_session_create2 directly returning a session

> (or ODP_CRYPTO_SESSION_INVALID in case of an error).

>

> Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

> ---

> /** Email created from pull request 37 (lumag:crypto-create-ret)

>  ** https://github.com/Linaro/odp/pull/37

>  ** Patch: https://github.com/Linaro/odp/pull/37.patch

>  ** Base sha: 552817483e9d4b6a84d49960920f1de50029f111

>  ** Merge commit sha: 6f929f89f7e0ffd3726e5f2f799496b8112fa574

>  **/

>  example/ipsec/odp_ipsec_cache.c                    |  4 +-

>  include/odp/api/spec/crypto.h                      | 27 +++++++--

>  platform/linux-generic/odp_crypto.c                | 18 +++---

>  test/common_plat/performance/odp_crypto.c          | 68 +++++++++++-----------

>  .../validation/api/crypto/odp_crypto_test_inp.c    |  6 +-

>  5 files changed, 69 insertions(+), 54 deletions(-)

>

> diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c

> index b2a91c24..8bb36076 100644

> --- a/example/ipsec/odp_ipsec_cache.c

> +++ b/example/ipsec/odp_ipsec_cache.c

> @@ -114,8 +114,8 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,

>                         return -1;

>         }

>

> -       /* Synchronous session create for now */

> -       if (odp_crypto_session_create(&params, &session, &ses_create_rc))

> +       session = odp_crypto_session_create2(&params, &ses_create_rc);


IMO, I would prefer not having these types of numbered extensions to
an API this will be confusing on the long run.

Regards,
Bala

> +       if (ODP_CRYPTO_SESSION_INVALID == session)

>                 return -1;

>         if (ODP_CRYPTO_SES_CREATE_ERR_NONE != ses_create_rc)

>                 return -1;

> diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h

> index c47d3149..d4ea17ff 100644

> --- a/include/odp/api/spec/crypto.h

> +++ b/include/odp/api/spec/crypto.h

> @@ -585,15 +585,34 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth,

>   * default values.

>   *

>   * @param param             Session parameters

> - * @param session           Created session else ODP_CRYPTO_SESSION_INVALID

>   * @param status            Failure code if unsuccessful

>   *

> - * @retval 0 on success

> - * @retval <0 on failure

> + * @retval created session on success

> + * @retval ODP_CRYPTO_SESSION_INVALID on failure

>   */

> +odp_crypto_session_t odp_crypto_session_create2(odp_crypto_session_param_t

> +                                               *param,

> +                                               odp_crypto_ses_create_err_t

> +                                               *status);

> +

> +#if ODP_DEPRECATED_API

> +static inline

>  int odp_crypto_session_create(odp_crypto_session_param_t *param,

>                               odp_crypto_session_t *session,

> -                             odp_crypto_ses_create_err_t *status);

> +                             odp_crypto_ses_create_err_t *status)

> +{

> +       odp_crypto_session_t sess;

> +

> +       sess = odp_crypto_session_create2(param, status);

> +

> +       if (ODP_CRYPTO_SESSION_INVALID == sess)

> +               return -1;

> +

> +       *session = sess;

> +

> +       return 0;

> +}

> +#endif

>

>  /**

>   * Crypto session destroy

> diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c

> index a993542f..b5f75000 100644

> --- a/platform/linux-generic/odp_crypto.c

> +++ b/platform/linux-generic/odp_crypto.c

> @@ -656,10 +656,9 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth,

>         return num;

>  }

>

> -int

> -odp_crypto_session_create(odp_crypto_session_param_t *param,

> -                         odp_crypto_session_t *session_out,

> -                         odp_crypto_ses_create_err_t *status)

> +odp_crypto_session_t

> +odp_crypto_session_create2(odp_crypto_session_param_t *param,

> +                          odp_crypto_ses_create_err_t *status)

>  {

>         int rc;

>         odp_crypto_generic_session_t *session;

> @@ -672,7 +671,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param,

>         session = alloc_session();

>         if (NULL == session) {

>                 *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;

> -               return -1;

> +               return ODP_CRYPTO_SESSION_INVALID;

>         }

>

>         /* Copy parameters */

> @@ -683,7 +682,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param,

>                 if (session->p.iv.length > MAX_IV_LEN) {

>                         ODP_DBG("Maximum IV length exceeded\n");

>                         free_session(session);

> -                       return -1;

> +                       return ODP_CRYPTO_SESSION_INVALID;

>                 }

>

>                 memcpy(session->cipher.iv_data, session->p.iv.data,

> @@ -734,7 +733,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param,

>         if (rc) {

>                 *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;

>                 free_session(session);

> -               return -1;

> +               return ODP_CRYPTO_SESSION_INVALID;

>         }

>

>         aes_gcm = 0;

> @@ -781,12 +780,11 @@ odp_crypto_session_create(odp_crypto_session_param_t *param,

>         if (rc) {

>                 *status = ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH;

>                 free_session(session);

> -               return -1;

> +               return ODP_CRYPTO_SESSION_INVALID;

>         }

>

>         /* We're happy */

> -       *session_out = (intptr_t)session;

> -       return 0;

> +       return (odp_crypto_session_t)(intptr_t)session;

>  }

>

>  int odp_crypto_session_destroy(odp_crypto_session_t session)

> diff --git a/test/common_plat/performance/odp_crypto.c b/test/common_plat/performance/odp_crypto.c

> index b3857973..f976523c 100644

> --- a/test/common_plat/performance/odp_crypto.c

> +++ b/test/common_plat/performance/odp_crypto.c

> @@ -415,13 +415,13 @@ print_mem(const char *msg,

>  /**

>   * Create ODP crypto session for given config.

>   */

> -static int

> -create_session_from_config(odp_crypto_session_t *session,

> -                          crypto_alg_config_t *config,

> +static odp_crypto_session_t

> +create_session_from_config(crypto_alg_config_t *config,

>                            crypto_args_t *cargs)

>  {

>         odp_crypto_session_param_t params;

>         odp_crypto_ses_create_err_t ses_create_rc;

> +       odp_crypto_session_t session;

>         odp_pool_t pkt_pool;

>         odp_queue_t out_queue;

>

> @@ -434,7 +434,7 @@ create_session_from_config(odp_crypto_session_t *session,

>         pkt_pool = odp_pool_lookup("packet_pool");

>         if (pkt_pool == ODP_POOL_INVALID) {

>                 app_err("packet_pool pool not found\n");

> -               return -1;

> +               return ODP_CRYPTO_SESSION_INVALID;

>         }

>         params.output_pool = pkt_pool;

>

> @@ -442,20 +442,21 @@ create_session_from_config(odp_crypto_session_t *session,

>                 out_queue = odp_queue_lookup("crypto-out");

>                 if (out_queue == ODP_QUEUE_INVALID) {

>                         app_err("crypto-out queue not found\n");

> -                       return -1;

> +                       return ODP_CRYPTO_SESSION_INVALID;

>                 }

>                 params.compl_queue = out_queue;

>

>         } else {

>                 params.compl_queue = ODP_QUEUE_INVALID;

>         }

> -       if (odp_crypto_session_create(&params, session,

> -                                     &ses_create_rc)) {

> +

> +       session = odp_crypto_session_create2(&params,

> +                                            &ses_create_rc);

> +

> +       if (session == ODP_CRYPTO_SESSION_INVALID)

>                 app_err("crypto session create failed.\n");

> -               return -1;

> -       }

>

> -       return 0;

> +       return session;

>  }

>

>  /**

> @@ -664,35 +665,34 @@ run_measure_one_config(crypto_args_t *cargs,

>         odp_crypto_session_t session;

>         int rc = 0;

>

> -       if (create_session_from_config(&session, config, cargs))

> -               rc = -1;

> -

> -       if (!rc) {

> -               if (cargs->payload_length) {

> -                       rc = run_measure_one(cargs, config, &session,

> -                                            cargs->payload_length, &result);

> -                       if (!rc) {

> -                               print_result_header();

> -                               print_result(cargs, cargs->payload_length,

> -                                            config, &result);

> -                       }

> -               } else {

> -                       unsigned i;

> +       session = create_session_from_config(config, cargs);

> +       if (session == ODP_CRYPTO_SESSION_INVALID)

> +               return -1;

>

> +       if (cargs->payload_length) {

> +               rc = run_measure_one(cargs, config, &session,

> +                                    cargs->payload_length, &result);

> +               if (!rc) {

>                         print_result_header();

> -                       for (i = 0; i < num_payloads; i++) {

> -                               rc = run_measure_one(cargs, config, &session,

> -                                                    payloads[i], &result);

> -                               if (rc)

> -                                       break;

> -                               print_result(cargs, payloads[i],

> -                                            config, &result);

> -                       }

> +                       print_result(cargs, cargs->payload_length,

> +                                    config, &result);

> +               }

> +       } else {

> +               unsigned i;

> +

> +               print_result_header();

> +               for (i = 0; i < num_payloads; i++) {

> +                       rc = run_measure_one(cargs, config, &session,

> +                                            payloads[i], &result);

> +                       if (rc)

> +                               break;

> +                       print_result(cargs, payloads[i],

> +                                    config, &result);

>                 }

>         }

>

> -       if (session != ODP_CRYPTO_SESSION_INVALID)

> -               odp_crypto_session_destroy(session);

> +       odp_crypto_session_destroy(session);

> +

>         return rc;

>  }

>

> diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c

> index bfc9da3c..be819a5b 100644

> --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c

> +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c

> @@ -202,11 +202,9 @@ static void alg_test(odp_crypto_op_t op,

>         ses_params.iv = ses_iv;

>         ses_params.auth_key = auth_key;

>

> -       rc = odp_crypto_session_create(&ses_params, &session, &status);

> -       CU_ASSERT_FATAL(!rc);

> +       session = odp_crypto_session_create2(&ses_params, &status);

> +       CU_ASSERT_FATAL(session != ODP_CRYPTO_SESSION_INVALID);

>         CU_ASSERT(status == ODP_CRYPTO_SES_CREATE_ERR_NONE);

> -       CU_ASSERT(odp_crypto_session_to_u64(session) !=

> -                 odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));

>

>         /* Prepare input data */

>         odp_packet_t pkt = odp_packet_alloc(suite_context.pool,

>
Dmitry Eremin-Solenikov May 30, 2017, 3:16 p.m. | #2
On 30 May 2017 at 18:06, Bala Manoharan <bala.manoharan@linaro.org> wrote:
> On 30 May 2017 at 20:30, Github ODP bot <odpbot@yandex.ru> wrote:

>> From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>>

>> Currently odp_crypto_session_create() (unlike other creation functions)

>> returns int result with session being returned through pointer argument.

>> Replace it with odp_crypto_session_create2 directly returning a session

>> (or ODP_CRYPTO_SESSION_INVALID in case of an error).

>>

>> Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


[skipped]

>> @@ -114,8 +114,8 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,

>>                         return -1;

>>         }

>>

>> -       /* Synchronous session create for now */

>> -       if (odp_crypto_session_create(&params, &session, &ses_create_rc))

>> +       session = odp_crypto_session_create2(&params, &ses_create_rc);

>

> IMO, I would prefer not having these types of numbered extensions to

> an API this will be confusing on the long run.


Well, your proposal for the name?

-- 
With best wishes
Dmitry
Bala Manoharan May 30, 2017, 3:30 p.m. | #3
On 30 May 2017 at 20:46, Dmitry Eremin-Solenikov
<dmitry.ereminsolenikov@linaro.org> wrote:
> On 30 May 2017 at 18:06, Bala Manoharan <bala.manoharan@linaro.org> wrote:

>> On 30 May 2017 at 20:30, Github ODP bot <odpbot@yandex.ru> wrote:

>>> From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>>>

>>> Currently odp_crypto_session_create() (unlike other creation functions)

>>> returns int result with session being returned through pointer argument.

>>> Replace it with odp_crypto_session_create2 directly returning a session

>>> (or ODP_CRYPTO_SESSION_INVALID in case of an error).

>>>

>>> Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>

> [skipped]

>

>>> @@ -114,8 +114,8 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,

>>>                         return -1;

>>>         }

>>>

>>> -       /* Synchronous session create for now */

>>> -       if (odp_crypto_session_create(&params, &session, &ses_create_rc))

>>> +       session = odp_crypto_session_create2(&params, &ses_create_rc);

>>

>> IMO, I would prefer not having these types of numbered extensions to

>> an API this will be confusing on the long run.

>

> Well, your proposal for the name?


Do we really need this change to the API? This is not such a big
change to propose a new API.

Regards,
Bala

>

> --

> With best wishes

> Dmitry
Dmitry Eremin-Solenikov May 30, 2017, 3:54 p.m. | #4
On 30 May 2017 at 18:30, Bala Manoharan <bala.manoharan@linaro.org> wrote:
> On 30 May 2017 at 20:46, Dmitry Eremin-Solenikov

> <dmitry.ereminsolenikov@linaro.org> wrote:

>> On 30 May 2017 at 18:06, Bala Manoharan <bala.manoharan@linaro.org> wrote:

>>> On 30 May 2017 at 20:30, Github ODP bot <odpbot@yandex.ru> wrote:

>>>> From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>>>>

>>>> Currently odp_crypto_session_create() (unlike other creation functions)

>>>> returns int result with session being returned through pointer argument.

>>>> Replace it with odp_crypto_session_create2 directly returning a session

>>>> (or ODP_CRYPTO_SESSION_INVALID in case of an error).

>>>>

>>>> Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>>

>> [skipped]

>>

>>>> @@ -114,8 +114,8 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,

>>>>                         return -1;

>>>>         }

>>>>

>>>> -       /* Synchronous session create for now */

>>>> -       if (odp_crypto_session_create(&params, &session, &ses_create_rc))

>>>> +       session = odp_crypto_session_create2(&params, &ses_create_rc);

>>>

>>> IMO, I would prefer not having these types of numbered extensions to

>>> an API this will be confusing on the long run.

>>

>> Well, your proposal for the name?

>

> Do we really need this change to the API? This is not such a big

> change to propose a new API.


I think we need.

First, we need consistency in the API usage.

Second, right now it is not clear even from the example/test point of view,
whether odp_crypto_session_create will set *session param in case
of error. See run_measure_one_config in
test/common_plat/performance/odp_crypto.c file.
Bala Manoharan May 30, 2017, 4:05 p.m. | #5
On 30 May 2017 at 21:24, Dmitry Eremin-Solenikov
<dmitry.ereminsolenikov@linaro.org> wrote:
> On 30 May 2017 at 18:30, Bala Manoharan <bala.manoharan@linaro.org> wrote:

>> On 30 May 2017 at 20:46, Dmitry Eremin-Solenikov

>> <dmitry.ereminsolenikov@linaro.org> wrote:

>>> On 30 May 2017 at 18:06, Bala Manoharan <bala.manoharan@linaro.org> wrote:

>>>> On 30 May 2017 at 20:30, Github ODP bot <odpbot@yandex.ru> wrote:

>>>>> From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>>>>>

>>>>> Currently odp_crypto_session_create() (unlike other creation functions)

>>>>> returns int result with session being returned through pointer argument.

>>>>> Replace it with odp_crypto_session_create2 directly returning a session

>>>>> (or ODP_CRYPTO_SESSION_INVALID in case of an error).

>>>>>

>>>>> Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

>>>

>>> [skipped]

>>>

>>>>> @@ -114,8 +114,8 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,

>>>>>                         return -1;

>>>>>         }

>>>>>

>>>>> -       /* Synchronous session create for now */

>>>>> -       if (odp_crypto_session_create(&params, &session, &ses_create_rc))

>>>>> +       session = odp_crypto_session_create2(&params, &ses_create_rc);

>>>>

>>>> IMO, I would prefer not having these types of numbered extensions to

>>>> an API this will be confusing on the long run.

>>>

>>> Well, your proposal for the name?

>>

>> Do we really need this change to the API? This is not such a big

>> change to propose a new API.

>

> I think we need.

>

> First, we need consistency in the API usage.


 Not sure about this. We have to maintain backward compatibility and
having multiple APIs will create confusion for application user.

>

> Second, right now it is not clear even from the example/test point of view,

> whether odp_crypto_session_create will set *session param in case

> of error. See run_measure_one_config in

> test/common_plat/performance/odp_crypto.c file.


This seems valid. Why don't you update the documentation to clarify this.

Regards,
Bala

Patch hide | download patch | download mbox

diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index b2a91c24..8bb36076 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -114,8 +114,8 @@  int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
 			return -1;
 	}
 
-	/* Synchronous session create for now */
-	if (odp_crypto_session_create(&params, &session, &ses_create_rc))
+	session = odp_crypto_session_create2(&params, &ses_create_rc);
+	if (ODP_CRYPTO_SESSION_INVALID == session)
 		return -1;
 	if (ODP_CRYPTO_SES_CREATE_ERR_NONE != ses_create_rc)
 		return -1;
diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index c47d3149..d4ea17ff 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -585,15 +585,34 @@  int odp_crypto_auth_capability(odp_auth_alg_t auth,
  * default values.
  *
  * @param param             Session parameters
- * @param session           Created session else ODP_CRYPTO_SESSION_INVALID
  * @param status            Failure code if unsuccessful
  *
- * @retval 0 on success
- * @retval <0 on failure
+ * @retval created session on success
+ * @retval ODP_CRYPTO_SESSION_INVALID on failure
  */
+odp_crypto_session_t odp_crypto_session_create2(odp_crypto_session_param_t
+						*param,
+						odp_crypto_ses_create_err_t
+						*status);
+
+#if ODP_DEPRECATED_API
+static inline
 int odp_crypto_session_create(odp_crypto_session_param_t *param,
 			      odp_crypto_session_t *session,
-			      odp_crypto_ses_create_err_t *status);
+			      odp_crypto_ses_create_err_t *status)
+{
+	odp_crypto_session_t sess;
+
+	sess = odp_crypto_session_create2(param, status);
+
+	if (ODP_CRYPTO_SESSION_INVALID == sess)
+		return -1;
+
+	*session = sess;
+
+	return 0;
+}
+#endif
 
 /**
  * Crypto session destroy
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index a993542f..b5f75000 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -656,10 +656,9 @@  int odp_crypto_auth_capability(odp_auth_alg_t auth,
 	return num;
 }
 
-int
-odp_crypto_session_create(odp_crypto_session_param_t *param,
-			  odp_crypto_session_t *session_out,
-			  odp_crypto_ses_create_err_t *status)
+odp_crypto_session_t
+odp_crypto_session_create2(odp_crypto_session_param_t *param,
+			   odp_crypto_ses_create_err_t *status)
 {
 	int rc;
 	odp_crypto_generic_session_t *session;
@@ -672,7 +671,7 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 	session = alloc_session();
 	if (NULL == session) {
 		*status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
-		return -1;
+		return ODP_CRYPTO_SESSION_INVALID;
 	}
 
 	/* Copy parameters */
@@ -683,7 +682,7 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 		if (session->p.iv.length > MAX_IV_LEN) {
 			ODP_DBG("Maximum IV length exceeded\n");
 			free_session(session);
-			return -1;
+			return ODP_CRYPTO_SESSION_INVALID;
 		}
 
 		memcpy(session->cipher.iv_data, session->p.iv.data,
@@ -734,7 +733,7 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 	if (rc) {
 		*status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
 		free_session(session);
-		return -1;
+		return ODP_CRYPTO_SESSION_INVALID;
 	}
 
 	aes_gcm = 0;
@@ -781,12 +780,11 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 	if (rc) {
 		*status = ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH;
 		free_session(session);
-		return -1;
+		return ODP_CRYPTO_SESSION_INVALID;
 	}
 
 	/* We're happy */
-	*session_out = (intptr_t)session;
-	return 0;
+	return (odp_crypto_session_t)(intptr_t)session;
 }
 
 int odp_crypto_session_destroy(odp_crypto_session_t session)
diff --git a/test/common_plat/performance/odp_crypto.c b/test/common_plat/performance/odp_crypto.c
index b3857973..f976523c 100644
--- a/test/common_plat/performance/odp_crypto.c
+++ b/test/common_plat/performance/odp_crypto.c
@@ -415,13 +415,13 @@  print_mem(const char *msg,
 /**
  * Create ODP crypto session for given config.
  */
-static int
-create_session_from_config(odp_crypto_session_t *session,
-			   crypto_alg_config_t *config,
+static odp_crypto_session_t
+create_session_from_config(crypto_alg_config_t *config,
 			   crypto_args_t *cargs)
 {
 	odp_crypto_session_param_t params;
 	odp_crypto_ses_create_err_t ses_create_rc;
+	odp_crypto_session_t session;
 	odp_pool_t pkt_pool;
 	odp_queue_t out_queue;
 
@@ -434,7 +434,7 @@  create_session_from_config(odp_crypto_session_t *session,
 	pkt_pool = odp_pool_lookup("packet_pool");
 	if (pkt_pool == ODP_POOL_INVALID) {
 		app_err("packet_pool pool not found\n");
-		return -1;
+		return ODP_CRYPTO_SESSION_INVALID;
 	}
 	params.output_pool = pkt_pool;
 
@@ -442,20 +442,21 @@  create_session_from_config(odp_crypto_session_t *session,
 		out_queue = odp_queue_lookup("crypto-out");
 		if (out_queue == ODP_QUEUE_INVALID) {
 			app_err("crypto-out queue not found\n");
-			return -1;
+			return ODP_CRYPTO_SESSION_INVALID;
 		}
 		params.compl_queue = out_queue;
 
 	} else {
 		params.compl_queue = ODP_QUEUE_INVALID;
 	}
-	if (odp_crypto_session_create(&params, session,
-				      &ses_create_rc)) {
+
+	session = odp_crypto_session_create2(&params,
+					     &ses_create_rc);
+
+	if (session == ODP_CRYPTO_SESSION_INVALID)
 		app_err("crypto session create failed.\n");
-		return -1;
-	}
 
-	return 0;
+	return session;
 }
 
 /**
@@ -664,35 +665,34 @@  run_measure_one_config(crypto_args_t *cargs,
 	odp_crypto_session_t session;
 	int rc = 0;
 
-	if (create_session_from_config(&session, config, cargs))
-		rc = -1;
-
-	if (!rc) {
-		if (cargs->payload_length) {
-			rc = run_measure_one(cargs, config, &session,
-					     cargs->payload_length, &result);
-			if (!rc) {
-				print_result_header();
-				print_result(cargs, cargs->payload_length,
-					     config, &result);
-			}
-		} else {
-			unsigned i;
+	session = create_session_from_config(config, cargs);
+	if (session == ODP_CRYPTO_SESSION_INVALID)
+		return -1;
 
+	if (cargs->payload_length) {
+		rc = run_measure_one(cargs, config, &session,
+				     cargs->payload_length, &result);
+		if (!rc) {
 			print_result_header();
-			for (i = 0; i < num_payloads; i++) {
-				rc = run_measure_one(cargs, config, &session,
-						     payloads[i], &result);
-				if (rc)
-					break;
-				print_result(cargs, payloads[i],
-					     config, &result);
-			}
+			print_result(cargs, cargs->payload_length,
+				     config, &result);
+		}
+	} else {
+		unsigned i;
+
+		print_result_header();
+		for (i = 0; i < num_payloads; i++) {
+			rc = run_measure_one(cargs, config, &session,
+					     payloads[i], &result);
+			if (rc)
+				break;
+			print_result(cargs, payloads[i],
+				     config, &result);
 		}
 	}
 
-	if (session != ODP_CRYPTO_SESSION_INVALID)
-		odp_crypto_session_destroy(session);
+	odp_crypto_session_destroy(session);
+
 	return rc;
 }
 
diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index bfc9da3c..be819a5b 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -202,11 +202,9 @@  static void alg_test(odp_crypto_op_t op,
 	ses_params.iv = ses_iv;
 	ses_params.auth_key = auth_key;
 
-	rc = odp_crypto_session_create(&ses_params, &session, &status);
-	CU_ASSERT_FATAL(!rc);
+	session = odp_crypto_session_create2(&ses_params, &status);
+	CU_ASSERT_FATAL(session != ODP_CRYPTO_SESSION_INVALID);
 	CU_ASSERT(status == ODP_CRYPTO_SES_CREATE_ERR_NONE);
-	CU_ASSERT(odp_crypto_session_to_u64(session) !=
-		  odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));
 
 	/* Prepare input data */
 	odp_packet_t pkt = odp_packet_alloc(suite_context.pool,