From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3799AA04AE; Mon, 4 May 2020 23:00:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C8B251D567; Mon, 4 May 2020 23:00:13 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 5A6291D551 for ; Mon, 4 May 2020 23:00:12 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D41D01A0519; Mon, 4 May 2020 23:00:11 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 117331A0501; Mon, 4 May 2020 23:00:10 +0200 (CEST) Received: from GDB1.ap.freescale.net (gdb1.ap.freescale.net [10.232.132.179]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id E638B4030B; Tue, 5 May 2020 05:00:07 +0800 (SGT) From: Akhil Goyal To: dev@dpdk.org Cc: hemant.agrawal@nxp.com, Akhil Goyal Date: Tue, 5 May 2020 02:09:15 +0530 Message-Id: <20200504203915.9602-2-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200504203915.9602-1-akhil.goyal@nxp.com> References: <20200504203915.9602-1-akhil.goyal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 2/2] crypto/dpaa_sec: improve error handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The return values in cases of errors were not specified properly. With this patch appropriate error numbers are returned. Signed-off-by: Akhil Goyal --- drivers/crypto/dpaa_sec/dpaa_sec.c | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index a11b17bda..c8110aa50 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) ? @@ -2501,7 +2504,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 +2527,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 +2542,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 +2639,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 +2676,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 +2896,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 +2947,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