cryptodev: remove queue start/stop functions
[dpdk.git] / drivers / crypto / dpaa2_sec / dpaa2_sec_dpseci.c
index 3700d70..1b1c30d 100644 (file)
@@ -122,7 +122,7 @@ build_authenc_gcm_sg_fd(dpaa2_sec_session *sess,
                return -1;
        }
        memset(fle, 0, FLE_SG_MEM_SIZE);
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (size_t)priv);
 
        op_fle = fle + 1;
@@ -273,7 +273,7 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
                return -1;
        }
        memset(fle, 0, FLE_POOL_BUF_SIZE);
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv);
        fle = fle + 1;
        sge = fle + 2;
@@ -418,7 +418,7 @@ build_authenc_sg_fd(dpaa2_sec_session *sess,
                return -1;
        }
        memset(fle, 0, FLE_SG_MEM_SIZE);
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv);
 
        op_fle = fle + 1;
@@ -567,7 +567,7 @@ build_authenc_fd(dpaa2_sec_session *sess,
                return -1;
        }
        memset(fle, 0, FLE_POOL_BUF_SIZE);
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv);
        fle = fle + 1;
        sge = fle + 2;
@@ -697,7 +697,7 @@ static inline int build_auth_sg_fd(
        }
        memset(fle, 0, FLE_SG_MEM_SIZE);
        /* first FLE entry used to store mbuf and session ctxt */
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv);
        op_fle = fle + 1;
        ip_fle = fle + 2;
@@ -778,7 +778,7 @@ build_auth_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
         * to get the MBUF Addr from the previous FLE.
         * We can have a better approach to use the inline Mbuf
         */
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv);
        fle = fle + 1;
 
@@ -870,7 +870,7 @@ build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
        }
        memset(fle, 0, FLE_SG_MEM_SIZE);
        /* first FLE entry used to store mbuf and session ctxt */
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv);
 
        op_fle = fle + 1;
@@ -994,7 +994,7 @@ build_cipher_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
         * to get the MBUF Addr from the previous FLE.
         * We can have a better approach to use the inline Mbuf
         */
-       DPAA2_SET_FLE_ADDR(fle, DPAA2_OP_VADDR_TO_IOVA(op));
+       DPAA2_SET_FLE_ADDR(fle, (size_t)op);
        DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv);
        fle = fle + 1;
        sge = fle + 2;
@@ -1261,8 +1261,7 @@ sec_fd_to_mbuf(const struct qbman_fd *fd, uint8_t driver_id)
                DPAA2_SEC_ERR("error: non inline buffer");
                return NULL;
        }
-       op = (struct rte_crypto_op *)DPAA2_IOVA_TO_VADDR(
-                       DPAA2_GET_FLE_ADDR((fle - 1)));
+       op = (struct rte_crypto_op *)DPAA2_GET_FLE_ADDR((fle - 1));
 
        /* Prefeth op */
        src = op->sym->m_src;
@@ -1471,26 +1470,6 @@ dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
        return retcode;
 }
 
-/** Start queue pair */
-static int
-dpaa2_sec_queue_pair_start(__rte_unused struct rte_cryptodev *dev,
-                          __rte_unused uint16_t queue_pair_id)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       return 0;
-}
-
-/** Stop queue pair */
-static int
-dpaa2_sec_queue_pair_stop(__rte_unused struct rte_cryptodev *dev,
-                         __rte_unused uint16_t queue_pair_id)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       return 0;
-}
-
 /** Return the number of allocated queue pairs */
 static uint32_t
 dpaa2_sec_queue_pair_count(struct rte_cryptodev *dev)
@@ -1630,7 +1609,7 @@ dpaa2_sec_auth_init(struct rte_cryptodev *dev,
 {
        struct dpaa2_sec_dev_private *dev_priv = dev->data->dev_private;
        struct alginfo authdata;
-       unsigned int bufsize, i;
+       int bufsize, i;
        struct ctxt_priv *priv;
        struct sec_flow_context *flc;
 
@@ -1726,6 +1705,10 @@ dpaa2_sec_auth_init(struct rte_cryptodev *dev,
        bufsize = cnstr_shdsc_hmac(priv->flc_desc[DESC_INITFINAL].desc,
                                   1, 0, &authdata, !session->dir,
                                   session->digest_length);
+       if (bufsize < 0) {
+               DPAA2_SEC_ERR("Crypto: Invalid buffer length");
+               goto error_out;
+       }
 
        flc->word1_sdl = (uint8_t)bufsize;
        flc->word2_rflc_31_0 = lower_32_bits(
@@ -1756,7 +1739,7 @@ dpaa2_sec_aead_init(struct rte_cryptodev *dev,
        struct dpaa2_sec_aead_ctxt *ctxt = &session->ext_params.aead_ctxt;
        struct dpaa2_sec_dev_private *dev_priv = dev->data->dev_private;
        struct alginfo aeaddata;
-       unsigned int bufsize, i;
+       int bufsize, i;
        struct ctxt_priv *priv;
        struct sec_flow_context *flc;
        struct rte_crypto_aead_xform *aead_xform = &xform->aead;
@@ -1847,6 +1830,11 @@ dpaa2_sec_aead_init(struct rte_cryptodev *dev,
                                priv->flc_desc[0].desc, 1, 0,
                                &aeaddata, session->iv.length,
                                session->digest_length);
+       if (bufsize < 0) {
+               DPAA2_SEC_ERR("Crypto: Invalid buffer length");
+               goto error_out;
+       }
+
        flc->word1_sdl = (uint8_t)bufsize;
        flc->word2_rflc_31_0 = lower_32_bits(
                        (size_t)&(((struct dpaa2_sec_qp *)
@@ -1876,7 +1864,7 @@ dpaa2_sec_aead_chain_init(struct rte_cryptodev *dev,
        struct dpaa2_sec_aead_ctxt *ctxt = &session->ext_params.aead_ctxt;
        struct dpaa2_sec_dev_private *dev_priv = dev->data->dev_private;
        struct alginfo authdata, cipherdata;
-       unsigned int bufsize, i;
+       int bufsize, i;
        struct ctxt_priv *priv;
        struct sec_flow_context *flc;
        struct rte_crypto_cipher_xform *cipher_xform;
@@ -2068,6 +2056,10 @@ dpaa2_sec_aead_chain_init(struct rte_cryptodev *dev,
                                              ctxt->auth_only_len,
                                              session->digest_length,
                                              session->dir);
+               if (bufsize < 0) {
+                       DPAA2_SEC_ERR("Crypto: Invalid buffer length");
+                       goto error_out;
+               }
        } else {
                DPAA2_SEC_ERR("Hash before cipher not supported");
                goto error_out;
@@ -2159,7 +2151,7 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
        struct ipsec_encap_pdb encap_pdb;
        struct ipsec_decap_pdb decap_pdb;
        struct alginfo authdata, cipherdata;
-       unsigned int bufsize;
+       int bufsize;
        struct sec_flow_context *flc;
 
        PMD_INIT_FUNC_TRACE();
@@ -2349,6 +2341,12 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
                                1, 0, &decap_pdb, &cipherdata, &authdata);
        } else
                goto out;
+
+       if (bufsize < 0) {
+               DPAA2_SEC_ERR("Crypto: Invalid buffer length");
+               goto out;
+       }
+
        flc->word1_sdl = (uint8_t)bufsize;
 
        /* Enable the stashing control bit */
@@ -2608,7 +2606,8 @@ dpaa2_sec_dev_infos_get(struct rte_cryptodev *dev,
                info->max_nb_queue_pairs = internals->max_nb_queue_pairs;
                info->feature_flags = dev->feature_flags;
                info->capabilities = dpaa2_sec_capabilities;
-               info->sym.max_nb_sessions = internals->max_nb_sessions;
+               /* No limit of number of sessions */
+               info->sym.max_nb_sessions = 0;
                info->driver_id = cryptodev_driver_id;
        }
 }
@@ -2697,8 +2696,6 @@ static struct rte_cryptodev_ops crypto_ops = {
        .stats_reset          = dpaa2_sec_stats_reset,
        .queue_pair_setup     = dpaa2_sec_queue_pair_setup,
        .queue_pair_release   = dpaa2_sec_queue_pair_release,
-       .queue_pair_start     = dpaa2_sec_queue_pair_start,
-       .queue_pair_stop      = dpaa2_sec_queue_pair_stop,
        .queue_pair_count     = dpaa2_sec_queue_pair_count,
        .session_get_size     = dpaa2_sec_session_get_size,
        .session_configure    = dpaa2_sec_session_configure,
@@ -2768,7 +2765,6 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
                        RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
 
        internals = cryptodev->data->dev_private;
-       internals->max_nb_sessions = RTE_DPAA2_SEC_PMD_MAX_NB_SESSIONS;
 
        /*
         * For secondary processes, we don't initialise any further as primary
@@ -2919,8 +2915,8 @@ static struct rte_dpaa2_driver rte_dpaa2_sec_driver = {
 static struct cryptodev_driver dpaa2_sec_crypto_drv;
 
 RTE_PMD_REGISTER_DPAA2(CRYPTODEV_NAME_DPAA2_SEC_PMD, rte_dpaa2_sec_driver);
-RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa2_sec_crypto_drv, rte_dpaa2_sec_driver,
-               cryptodev_driver_id);
+RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa2_sec_crypto_drv,
+               rte_dpaa2_sec_driver.driver, cryptodev_driver_id);
 
 RTE_INIT(dpaa2_sec_init_log);
 static void