From: Akhil Goyal <gakhil@marvell.com>
To: Ciara Power <ciara.power@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"thomas@monjalon.net" <thomas@monjalon.net>
Cc: "roy.fan.zhang@intel.com" <roy.fan.zhang@intel.com>,
Anoob Joseph <anoobj@marvell.com>,
"mdr@ashroe.eu" <mdr@ashroe.eu>,
Declan Doherty <declan.doherty@intel.com>
Subject: RE: [EXT] [PATCH v3 4/4] crypto: modify return value for asym session create
Date: Mon, 7 Feb 2022 09:04:30 +0000 [thread overview]
Message-ID: <CO6PR18MB4484D0AB3663D14DF7F19A0ED82C9@CO6PR18MB4484.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20220203160449.1638311-5-ciara.power@intel.com>
> diff --git a/doc/guides/prog_guide/cryptodev_lib.rst
> b/doc/guides/prog_guide/cryptodev_lib.rst
> index 62bd3577f5..8e16461dc6 100644
> --- a/doc/guides/prog_guide/cryptodev_lib.rst
> +++ b/doc/guides/prog_guide/cryptodev_lib.rst
> @@ -1236,10 +1236,10 @@ crypto operations is similar except change to
> respective op and xform setup).
> * Create asym crypto session and initialize it for the crypto device.
> * The session structure is hidden from the app, so void * is used.
> */
> - void *asym_session;
> - asym_session =
> rte_cryptodev_asym_session_create(asym_session_pool,
> + void *asym_session = NULL;
> + ret = rte_cryptodev_asym_session_create(&asym_session,
> asym_session_pool,
> cdev_id, &modex_xform);
> - if (asym_session == NULL)
> + if (ret < 0)
> rte_exit(EXIT_FAILURE, "Session could not be created\n");
Sample Code in the rst files is no more added. @Thomas: Could you please confirm?
Probably a separate patch is required to clean this up.
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
> index 0d816ed4a9..005f0e7952 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -1912,9 +1912,9 @@ rte_cryptodev_sym_session_create(struct
> rte_mempool *mp)
> return sess;
> }
>
> -void *
> -rte_cryptodev_asym_session_create(struct rte_mempool *mp, uint8_t
> dev_id,
> - struct rte_crypto_asym_xform *xforms)
> +int
> +rte_cryptodev_asym_session_create(void **session, struct rte_mempool
> *mp,
> + uint8_t dev_id, struct rte_crypto_asym_xform *xforms)
Do you really need a double pointer for the session handle?
> {
> struct rte_cryptodev_asym_session *sess;
> uint32_t session_priv_data_sz;
> @@ -1926,18 +1926,18 @@ rte_cryptodev_asym_session_create(struct
> rte_mempool *mp, uint8_t dev_id,
>
> if (!rte_cryptodev_is_valid_dev(dev_id)) {
> CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
> - return NULL;
> + return -EINVAL;
> }
> session_priv_data_sz =
> rte_cryptodev_asym_get_private_session_size(
> dev_id);
> dev = rte_cryptodev_pmd_get_dev(dev_id);
>
> if (dev == NULL)
> - return NULL;
> + return -EINVAL;
>
> if (!mp) {
> CDEV_LOG_ERR("invalid mempool\n");
> - return NULL;
> + return -EINVAL;
> }
>
> pool_priv = rte_mempool_get_priv(mp);
> @@ -1945,22 +1945,23 @@ rte_cryptodev_asym_session_create(struct
> rte_mempool *mp, uint8_t dev_id,
> if (pool_priv->max_priv_session_sz < session_priv_data_sz) {
> CDEV_LOG_DEBUG(
> "The private session data size used when creating the
> mempool is smaller than this device's private session data.");
> - return NULL;
> + return -EINVAL;
> }
>
> /* Verify if provided mempool can hold elements big enough. */
> if (mp->elt_size < session_header_size + session_priv_data_sz) {
> CDEV_LOG_ERR(
> "mempool elements too small to hold session
> objects");
> - return NULL;
> + return -EINVAL;
> }
>
> /* Allocate a session structure from the session pool */
> - if (rte_mempool_get(mp, (void **)&sess)) {
> + if (rte_mempool_get(mp, session)) {
> CDEV_LOG_ERR("couldn't get object from session
> mempool");
> - return NULL;
> + return -ENOMEM;
> }
>
> + sess = *session;
> sess->driver_id = dev->driver_id;
> sess->user_data_sz = pool_priv->user_data_sz;
> sess->max_priv_session_sz = pool_priv->max_priv_session_sz;
> @@ -1970,7 +1971,7 @@ rte_cryptodev_asym_session_create(struct
> rte_mempool *mp, uint8_t dev_id,
> */
> memset(sess->sess_private_data, 0, session_priv_data_sz + sess-
> >user_data_sz);
>
> - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-
> >asym_session_configure, NULL);
> + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-
> >asym_session_configure, -ENOTSUP);
>
> if (sess->sess_private_data[0] == 0) {
> ret = dev->dev_ops->asym_session_configure(dev,
> @@ -1980,12 +1981,12 @@ rte_cryptodev_asym_session_create(struct
> rte_mempool *mp, uint8_t dev_id,
> CDEV_LOG_ERR(
> "dev_id %d failed to configure session
> details",
> dev_id);
> - return NULL;
> + return ret;
> }
> }
>
> rte_cryptodev_trace_asym_session_create(mp, sess);
> - return sess;
> + return 0;
> }
>
> int
> diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
> index 6a4d6d9934..9a75936963 100644
> --- a/lib/cryptodev/rte_cryptodev.h
> +++ b/lib/cryptodev/rte_cryptodev.h
> @@ -990,18 +990,21 @@ rte_cryptodev_sym_session_create(struct
> rte_mempool *mempool);
> /**
> * Create asymmetric crypto session header (generic with no private data)
> *
> + * @param session void ** for session to be used
> * @param mempool mempool to allocate asymmetric session
> * objects from
> * @param dev_id ID of device that we want the session to be used on
> * @param xforms Asymmetric crypto transform operations to apply on
> flow
> * processed with this session
> * @return
> - * - On success return pointer to asym-session
> - * - On failure returns NULL
> + * - 0 on success.
> + * - -EINVAL on invalid arguments.
> + * - -ENOMEM on memory error for session allocation.
> + * - -ENOTSUP if device doesn't support session configuration.
> */
> __rte_experimental
> -void *
> -rte_cryptodev_asym_session_create(struct rte_mempool *mempool,
> +int
> +rte_cryptodev_asym_session_create(void **session, struct rte_mempool
> *mempool,
> uint8_t dev_id, struct rte_crypto_asym_xform *xforms);
>
Session should be the last parameter.
First all in params and then out params.
next prev parent reply other threads:[~2022-02-07 9:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 16:04 [PATCH v3 0/4] crypto: improve asym session usage Ciara Power
2022-02-03 16:04 ` [PATCH v3 1/4] crypto: use single buffer for asymmetric session Ciara Power
2022-02-07 8:19 ` [EXT] " Akhil Goyal
2022-02-07 14:22 ` Power, Ciara
2022-02-03 16:04 ` [PATCH v3 2/4] crypto: hide asym session structure Ciara Power
2022-02-03 16:04 ` [PATCH v3 3/4] crypto: add asym session user data API Ciara Power
2022-02-07 8:41 ` [EXT] " Akhil Goyal
2022-02-03 16:04 ` [PATCH v3 4/4] crypto: modify return value for asym session create Ciara Power
2022-02-07 9:04 ` Akhil Goyal [this message]
2022-02-07 13:02 ` [EXT] " Thomas Monjalon
2022-02-07 14:50 ` Power, Ciara
2022-02-08 20:21 ` Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CO6PR18MB4484D0AB3663D14DF7F19A0ED82C9@CO6PR18MB4484.namprd18.prod.outlook.com \
--to=gakhil@marvell.com \
--cc=anoobj@marvell.com \
--cc=ciara.power@intel.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=mdr@ashroe.eu \
--cc=roy.fan.zhang@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).