drivers/crypto: remove double assignment of driver
[dpdk.git] / drivers / crypto / dpaa2_sec / dpaa2_sec_dpseci.c
index 784b96d..d5342a0 100644 (file)
@@ -30,6 +30,9 @@
 #include "dpaa2_sec_priv.h"
 #include "dpaa2_sec_logs.h"
 
+/* Required types */
+typedef uint64_t       dma_addr_t;
+
 /* RTA header files */
 #include <hw/desc/ipsec.h>
 #include <hw/desc/algo.h>
@@ -119,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;
@@ -270,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;
@@ -415,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;
@@ -564,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;
@@ -694,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;
@@ -775,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;
 
@@ -867,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;
@@ -991,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;
@@ -1077,7 +1080,7 @@ build_sec_fd(struct rte_crypto_op *op,
        PMD_INIT_FUNC_TRACE();
 
        if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-               sess = (dpaa2_sec_session *)get_session_private_data(
+               sess = (dpaa2_sec_session *)get_sym_session_private_data(
                                op->sym->session, cryptodev_driver_id);
        else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION)
                sess = (dpaa2_sec_session *)get_sec_session_private_data(
@@ -1159,14 +1162,14 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
        qbman_eq_desc_set_response(&eqdesc, 0, 0);
        qbman_eq_desc_set_fq(&eqdesc, dpaa2_qp->tx_vq.fqid);
 
-       if (!DPAA2_PER_LCORE_SEC_DPIO) {
-               ret = dpaa2_affine_qbman_swp_sec();
+       if (!DPAA2_PER_LCORE_DPIO) {
+               ret = dpaa2_affine_qbman_swp();
                if (ret) {
                        DPAA2_SEC_ERR("Failure in affining portal");
                        return 0;
                }
        }
-       swp = DPAA2_PER_LCORE_SEC_PORTAL;
+       swp = DPAA2_PER_LCORE_PORTAL;
 
        while (nb_ops) {
                frames_to_send = (nb_ops >> 3) ? MAX_TX_RING_SLOTS : nb_ops;
@@ -1258,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;
@@ -1307,14 +1309,14 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops,
        const struct qbman_fd *fd;
        struct qbman_pull_desc pulldesc;
 
-       if (!DPAA2_PER_LCORE_SEC_DPIO) {
-               ret = dpaa2_affine_qbman_swp_sec();
+       if (!DPAA2_PER_LCORE_DPIO) {
+               ret = dpaa2_affine_qbman_swp();
                if (ret) {
                        DPAA2_SEC_ERR("Failure in affining portal");
                        return 0;
                }
        }
-       swp = DPAA2_PER_LCORE_SEC_PORTAL;
+       swp = DPAA2_PER_LCORE_PORTAL;
        dq_storage = dpaa2_qp->rx_vq.q_storage->dq_storage[0];
 
        qbman_pull_desc_clear(&pulldesc);
@@ -1468,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)
@@ -1499,7 +1481,7 @@ dpaa2_sec_queue_pair_count(struct rte_cryptodev *dev)
 
 /** Returns the size of the aesni gcm session structure */
 static unsigned int
-dpaa2_sec_session_get_size(struct rte_cryptodev *dev __rte_unused)
+dpaa2_sec_sym_session_get_size(struct rte_cryptodev *dev __rte_unused)
 {
        PMD_INIT_FUNC_TRACE();
 
@@ -1627,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;
 
@@ -1723,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(
@@ -1753,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;
@@ -1844,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 *)
@@ -1873,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;
@@ -2065,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;
@@ -2156,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();
@@ -2346,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 */
@@ -2435,7 +2436,7 @@ dpaa2_sec_security_session_destroy(void *dev __rte_unused,
 }
 
 static int
-dpaa2_sec_session_configure(struct rte_cryptodev *dev,
+dpaa2_sec_sym_session_configure(struct rte_cryptodev *dev,
                struct rte_crypto_sym_xform *xform,
                struct rte_cryptodev_sym_session *sess,
                struct rte_mempool *mempool)
@@ -2456,7 +2457,7 @@ dpaa2_sec_session_configure(struct rte_cryptodev *dev,
                return ret;
        }
 
-       set_session_private_data(sess, dev->driver_id,
+       set_sym_session_private_data(sess, dev->driver_id,
                sess_private_data);
 
        return 0;
@@ -2464,12 +2465,12 @@ dpaa2_sec_session_configure(struct rte_cryptodev *dev,
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-dpaa2_sec_session_clear(struct rte_cryptodev *dev,
+dpaa2_sec_sym_session_clear(struct rte_cryptodev *dev,
                struct rte_cryptodev_sym_session *sess)
 {
        PMD_INIT_FUNC_TRACE();
        uint8_t index = dev->driver_id;
-       void *sess_priv = get_session_private_data(sess, index);
+       void *sess_priv = get_sym_session_private_data(sess, index);
        dpaa2_sec_session *s = (dpaa2_sec_session *)sess_priv;
 
        if (sess_priv) {
@@ -2478,7 +2479,7 @@ dpaa2_sec_session_clear(struct rte_cryptodev *dev,
                rte_free(s->auth_key.data);
                memset(sess, 0, sizeof(dpaa2_sec_session));
                struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
-               set_session_private_data(sess, index, NULL);
+               set_sym_session_private_data(sess, index, NULL);
                rte_mempool_put(sess_mp, sess_priv);
        }
 }
@@ -2605,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;
        }
 }
@@ -2694,12 +2696,10 @@ 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,
-       .session_clear        = dpaa2_sec_session_clear,
+       .sym_session_get_size     = dpaa2_sec_sym_session_get_size,
+       .sym_session_configure    = dpaa2_sec_sym_session_configure,
+       .sym_session_clear        = dpaa2_sec_sym_session_clear,
 };
 
 static const struct rte_security_capability *
@@ -2762,10 +2762,13 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
                        RTE_CRYPTODEV_FF_HW_ACCELERATED |
                        RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
                        RTE_CRYPTODEV_FF_SECURITY |
-                       RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+                       RTE_CRYPTODEV_FF_IN_PLACE_SGL |
+                       RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
+                       RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
+                       RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT |
+                       RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT;
 
        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
@@ -2840,7 +2843,7 @@ init_error:
 }
 
 static int
-cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv,
+cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
                          struct rte_dpaa2_device *dpaa2_dev)
 {
        struct rte_cryptodev *cryptodev;
@@ -2868,7 +2871,6 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv,
 
        dpaa2_dev->cryptodev = cryptodev;
        cryptodev->device = &dpaa2_dev->device;
-       cryptodev->device->driver = &dpaa2_drv->driver;
 
        /* init user callbacks */
        TAILQ_INIT(&(cryptodev->link_intr_cbs));
@@ -2916,12 +2918,10 @@ 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
-dpaa2_sec_init_log(void)
+RTE_INIT(dpaa2_sec_init_log)
 {
        /* Bus level logs */
        dpaa2_logtype_sec = rte_log_register("pmd.crypto.dpaa2");