From: Akhil Goyal <akhil.goyal@nxp.com>
To: dev@dpdk.org
Cc: hemant.agrawal@nxp.com, Akhil Goyal <akhil.goyal@nxp.com>
Subject: [dpdk-dev] [PATCH v2 2/2] crypto/dpaa_sec: improve error handling
Date: Tue, 5 May 2020 03:09:21 +0530 [thread overview]
Message-ID: <20200504213921.15449-2-akhil.goyal@nxp.com> (raw)
In-Reply-To: <20200504213921.15449-1-akhil.goyal@nxp.com>
The return values in cases of errors were not
specified properly. With this patch appropriate
error numbers are returned.
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
drivers/crypto/dpaa_sec/dpaa_sec.c | 40 ++++++++++++++++--------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index a11b17bda..0ee21319a 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2041,7 +2041,7 @@ dpaa_sec_cipher_init(struct rte_cryptodev *dev __rte_unused,
DPAA_SEC_ERR("Crypto: Undefined Cipher specified %u",
xform->cipher.algo);
rte_free(session->cipher_key.data);
- return -1;
+ return -ENOTSUP;
}
session->dir = (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
DIR_ENC : DIR_DEC;
@@ -2109,7 +2109,7 @@ dpaa_sec_auth_init(struct rte_cryptodev *dev __rte_unused,
DPAA_SEC_ERR("Crypto: Unsupported Auth specified %u",
xform->auth.algo);
rte_free(session->auth_key.data);
- return -1;
+ return -ENOTSUP;
}
session->dir = (xform->auth.op == RTE_CRYPTO_AUTH_OP_GENERATE) ?
@@ -2126,6 +2126,7 @@ dpaa_sec_chain_init(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_cipher_xform *cipher_xform;
struct rte_crypto_auth_xform *auth_xform;
+ int ret = 0;
session->ctxt = DPAA_SEC_CIPHER_HASH;
if (session->auth_cipher_text) {
@@ -2144,7 +2145,7 @@ dpaa_sec_chain_init(struct rte_cryptodev *dev __rte_unused,
RTE_CACHE_LINE_SIZE);
if (session->cipher_key.data == NULL && cipher_xform->key.length > 0) {
DPAA_SEC_ERR("No Memory for cipher key");
- return -1;
+ return -ENOMEM;
}
session->cipher_key.length = cipher_xform->key.length;
session->auth_key.data = rte_zmalloc(NULL, auth_xform->key.length,
@@ -2191,6 +2192,7 @@ dpaa_sec_chain_init(struct rte_cryptodev *dev __rte_unused,
default:
DPAA_SEC_ERR("Crypto: Unsupported Auth specified %u",
auth_xform->algo);
+ ret = -ENOTSUP;
goto error_out;
}
@@ -2212,16 +2214,17 @@ dpaa_sec_chain_init(struct rte_cryptodev *dev __rte_unused,
default:
DPAA_SEC_ERR("Crypto: Undefined Cipher specified %u",
cipher_xform->algo);
+ ret = -ENOTSUP;
goto error_out;
}
session->dir = (cipher_xform->op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
DIR_ENC : DIR_DEC;
- return 0;
+ return ret;
error_out:
rte_free(session->cipher_key.data);
rte_free(session->auth_key.data);
- return -1;
+ return ret;
}
static int
@@ -2254,7 +2257,7 @@ dpaa_sec_aead_init(struct rte_cryptodev *dev __rte_unused,
default:
DPAA_SEC_ERR("unsupported AEAD alg %d", session->aead_alg);
rte_free(session->aead_key.data);
- return -ENOMEM;
+ return -ENOTSUP;
}
session->dir = (xform->aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ?
@@ -2368,7 +2371,7 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev,
ret = dpaa_sec_chain_init(dev, xform, session);
} else {
DPAA_SEC_ERR("Not supported: Auth then Cipher");
- return -EINVAL;
+ return -ENOTSUP;
}
/* Authenticate then Cipher */
} else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH &&
@@ -2384,7 +2387,7 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev,
ret = dpaa_sec_chain_init(dev, xform, session);
} else {
DPAA_SEC_ERR("Not supported: Auth then Cipher");
- return -EINVAL;
+ return -ENOTSUP;
}
/* AEAD operation for AES-GCM kind of Algorithms */
@@ -2407,6 +2410,7 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev,
if (session->inq[i] == NULL) {
DPAA_SEC_ERR("unable to attach sec queue");
rte_spinlock_unlock(&internals->lock);
+ ret = -EBUSY;
goto err1;
}
}
@@ -2419,7 +2423,7 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev,
rte_free(session->auth_key.data);
memset(session, 0, sizeof(dpaa_sec_session));
- return -EINVAL;
+ return ret;
}
static int
@@ -2501,7 +2505,7 @@ dpaa_sec_ipsec_aead_init(struct rte_crypto_aead_xform *aead_xform,
RTE_CACHE_LINE_SIZE);
if (session->aead_key.data == NULL && aead_xform->key.length > 0) {
DPAA_SEC_ERR("No Memory for aead key");
- return -1;
+ return -ENOMEM;
}
memcpy(session->aead_key.data, aead_xform->key.data,
aead_xform->key.length);
@@ -2524,7 +2528,7 @@ dpaa_sec_ipsec_aead_init(struct rte_crypto_aead_xform *aead_xform,
default:
DPAA_SEC_ERR("Crypto: Undefined GCM digest %d",
session->digest_length);
- return -1;
+ return -EINVAL;
}
if (session->dir == DIR_ENC) {
memcpy(session->encap_pdb.gcm.salt,
@@ -2539,7 +2543,7 @@ dpaa_sec_ipsec_aead_init(struct rte_crypto_aead_xform *aead_xform,
default:
DPAA_SEC_ERR("Crypto: Undefined AEAD specified %u",
aead_xform->algo);
- return -1;
+ return -ENOTSUP;
}
return 0;
}
@@ -2636,11 +2640,11 @@ dpaa_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform,
case RTE_CRYPTO_AUTH_ZUC_EIA3:
DPAA_SEC_ERR("Crypto: Unsupported auth alg %u",
session->auth_alg);
- return -1;
+ return -ENOTSUP;
default:
DPAA_SEC_ERR("Crypto: Undefined Auth specified %u",
session->auth_alg);
- return -1;
+ return -ENOTSUP;
}
switch (session->cipher_alg) {
@@ -2673,11 +2677,11 @@ dpaa_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform,
case RTE_CRYPTO_CIPHER_KASUMI_F8:
DPAA_SEC_ERR("Crypto: Unsupported Cipher alg %u",
session->cipher_alg);
- return -1;
+ return -ENOTSUP;
default:
DPAA_SEC_ERR("Crypto: Undefined Cipher specified %u",
session->cipher_alg);
- return -1;
+ return -ENOTSUP;
}
return 0;
@@ -2893,7 +2897,7 @@ dpaa_sec_set_pdcp_session(struct rte_cryptodev *dev,
default:
DPAA_SEC_ERR("Crypto: Undefined Cipher specified %u",
session->cipher_alg);
- return -1;
+ return -EINVAL;
}
session->cipher_key.data = rte_zmalloc(NULL,
@@ -2944,7 +2948,7 @@ dpaa_sec_set_pdcp_session(struct rte_cryptodev *dev,
DPAA_SEC_ERR("Crypto: Unsupported auth alg %u",
session->auth_alg);
rte_free(session->cipher_key.data);
- return -1;
+ return -EINVAL;
}
session->auth_key.data = rte_zmalloc(NULL,
auth_xform->key.length,
--
2.17.1
next prev parent reply other threads:[~2020-05-04 22:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-04 20:39 [dpdk-dev] [PATCH 1/2] crypto/dpaa2_sec: " Akhil Goyal
2020-05-04 20:39 ` [dpdk-dev] [PATCH 2/2] crypto/dpaa_sec: " Akhil Goyal
2020-05-04 21:39 ` [dpdk-dev] [PATCH v2 1/2] crypto/dpaa2_sec: " Akhil Goyal
2020-05-04 21:39 ` Akhil Goyal [this message]
2020-05-05 1:17 ` Lukasz Wojciechowski
2020-05-05 13:47 ` Akhil Goyal
2020-05-09 22:22 ` [dpdk-dev] [PATCH v3 " Akhil Goyal
2020-05-09 22:22 ` [dpdk-dev] [PATCH v3 2/2] crypto/dpaa_sec: " Akhil Goyal
2020-05-11 6:14 ` Hemant Agrawal (OSS)
2020-05-11 6:13 ` [dpdk-dev] [PATCH v3 1/2] crypto/dpaa2_sec: " Hemant Agrawal (OSS)
2020-05-11 7:59 ` 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=20200504213921.15449-2-akhil.goyal@nxp.com \
--to=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.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).