From: "Trahe, Fiona" <fiona.trahe@intel.com>
To: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>,
"zbigniew.bodek@caviumnetworks.com"
<zbigniew.bodek@caviumnetworks.com>,
"jerin.jacob@caviumnetworks.com" <jerin.jacob@caviumnetworks.com>,
"akhil.goyal@nxp.com" <akhil.goyal@nxp.com>,
"hemant.agrawal@nxp.com" <hemant.agrawal@nxp.com>,
"Jain, Deepak K" <deepak.k.jain@intel.com>,
"Griffin, John" <john.griffin@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "Trahe, Fiona" <fiona.trahe@intel.com>
Subject: Re: [dpdk-dev] [PATCH] cryptodev: fix session init return value
Date: Tue, 25 Jul 2017 11:55:20 +0000 [thread overview]
Message-ID: <348A99DA5F5B7549AA880327E580B4358923BC4B@IRSMSX101.ger.corp.intel.com> (raw)
In-Reply-To: <20170724085428.51995-1-pablo.de.lara.guarch@intel.com>
Hi Pablo,
> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Monday, July 24, 2017 9:54 AM
> To: zbigniew.bodek@caviumnetworks.com; jerin.jacob@caviumnetworks.com; akhil.goyal@nxp.com;
> hemant.agrawal@nxp.com; Trahe, Fiona <fiona.trahe@intel.com>; Jain, Deepak K
> <deepak.k.jain@intel.com>; Griffin, John <john.griffin@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH] cryptodev: fix session init return value
>
> When calling rte_cryptodev_sym_session_init(),
> if there was an error, it returned -1, regardless
> the error.
> Instead, it should return the specific error code, which can
> be valuable for the application for error handling.
>
> Fixes: b3bbd9e5f265 ("cryptodev: support device independent sessions")
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
Trimmed to just the relevant QAT sections
> diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
> index d92de35..e115540 100644
> --- a/drivers/crypto/qat/qat_crypto.c
> +++ b/drivers/crypto/qat/qat_crypto.c
> @@ -171,16 +171,19 @@ bpi_cipher_decrypt(uint8_t *src, uint8_t *dst,
> /** Creates a context in either AES or DES in ECB mode
> * Depends on openssl libcrypto
> */
> -static void *
> +static int
> bpi_cipher_ctx_init(enum rte_crypto_cipher_algorithm cryptodev_algo,
> enum rte_crypto_cipher_operation direction __rte_unused,
> - uint8_t *key)
> + uint8_t *key, EVP_CIPHER_CTX **ctx)
My preference is to use a void ** ctx here. So all EVP refs are encapsulated within these fns
and if we ever wanted to use a lib other than openssl the changes would be confined to the
internals of these functions.
> @@ -499,44 +525,52 @@ qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
> qat_cmd_id = qat_get_cmd_id(xform);
> if (qat_cmd_id < 0 || qat_cmd_id >= ICP_QAT_FW_LA_CMD_DELIMITER) {
> PMD_DRV_LOG(ERR, "Unsupported xform chain requested");
> - return -1;
> + return -ENOTSUP;
> }
> session->qat_cmd = (enum icp_qat_fw_la_cmd_id)qat_cmd_id;
> switch (session->qat_cmd) {
> case ICP_QAT_FW_LA_CMD_CIPHER:
> - if (qat_crypto_sym_configure_session_cipher(dev, xform, session) < 0)
> - return -1;
> + ret = qat_crypto_sym_configure_session_cipher(dev, xform, session);
> + if (ret < 0)
> + return ret;
> break;
> case ICP_QAT_FW_LA_CMD_AUTH:
> - if (qat_crypto_sym_configure_session_auth(dev, xform, session) < 0)
> - return -1;
> + ret = qat_crypto_sym_configure_session_auth(dev, xform, session);
> + if (ret < 0)
> + return ret;
> break;
> case ICP_QAT_FW_LA_CMD_CIPHER_HASH:
> if (xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
> - if (qat_crypto_sym_configure_session_aead(xform,
> - session) < 0)
> - return -1;
> + ret = qat_crypto_sym_configure_session_aead(xform,
> + session);
> + if (ret < 0)
> + return ret;
> } else {
> - if (qat_crypto_sym_configure_session_cipher(dev,
> - xform, session) < 0)
> - return -1;
> - if (qat_crypto_sym_configure_session_auth(dev,
> - xform, session) < 0)
> - return -1;
> + ret = qat_crypto_sym_configure_session_cipher(dev,
> + xform, session);
> + if (ret < 0)
> + return ret;
> + ret = qat_crypto_sym_configure_session_auth(dev,
> + xform, session);
> + if (ret < 0)
> + return ret;
In this case it is also necessary to undo what was done during the previous fn
qat_crypto_sym_configure_session_cipher(), i.e. add
if (session->bpi_ctx) {
bpi_cipher_ctx_free(session->bpi_ctx);
session->bpi_ctx = NULL;
}
OR encapsulate this in a new fn:
qat_crypto_sym_clear_session_cipher()
Note, this is a pre-existing bug, just highlighted by this change.
prev parent reply other threads:[~2017-07-25 11:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 8:54 Pablo de Lara
2017-07-25 6:16 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
2017-07-27 10:12 ` Trahe, Fiona
2017-07-27 15:26 ` De Lara Guarch, Pablo
2017-07-25 8:33 ` [dpdk-dev] [PATCH] " Akhil Goyal
2017-07-25 11:55 ` Trahe, Fiona [this message]
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=348A99DA5F5B7549AA880327E580B4358923BC4B@IRSMSX101.ger.corp.intel.com \
--to=fiona.trahe@intel.com \
--cc=akhil.goyal@nxp.com \
--cc=deepak.k.jain@intel.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=jerin.jacob@caviumnetworks.com \
--cc=john.griffin@intel.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=zbigniew.bodek@caviumnetworks.com \
/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).