crypto/dpaa: fix session destroy
[dpdk.git] / drivers / crypto / dpaa2_sec / dpaa2_sec_dpseci.c
index 31b7de6..0d273bb 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <time.h>
 #include <net/if.h>
+#include <unistd.h>
 
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
@@ -1297,7 +1298,7 @@ skip_tx:
 }
 
 static inline struct rte_crypto_op *
-sec_simple_fd_to_mbuf(const struct qbman_fd *fd, __rte_unused uint8_t id)
+sec_simple_fd_to_mbuf(const struct qbman_fd *fd)
 {
        struct rte_crypto_op *op;
        uint16_t len = DPAA2_GET_FD_LEN(fd);
@@ -1326,7 +1327,7 @@ sec_simple_fd_to_mbuf(const struct qbman_fd *fd, __rte_unused uint8_t id)
 }
 
 static inline struct rte_crypto_op *
-sec_fd_to_mbuf(const struct qbman_fd *fd, uint8_t driver_id)
+sec_fd_to_mbuf(const struct qbman_fd *fd)
 {
        struct qbman_fle *fle;
        struct rte_crypto_op *op;
@@ -1334,7 +1335,7 @@ sec_fd_to_mbuf(const struct qbman_fd *fd, uint8_t driver_id)
        struct rte_mbuf *dst, *src;
 
        if (DPAA2_FD_GET_FORMAT(fd) == qbman_fd_single)
-               return sec_simple_fd_to_mbuf(fd, driver_id);
+               return sec_simple_fd_to_mbuf(fd);
 
        fle = (struct qbman_fle *)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd));
 
@@ -1401,8 +1402,6 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops,
 {
        /* Function is responsible to receive frames for a given device and VQ*/
        struct dpaa2_sec_qp *dpaa2_qp = (struct dpaa2_sec_qp *)qp;
-       struct rte_cryptodev *dev =
-                       (struct rte_cryptodev *)(dpaa2_qp->rx_vq.dev);
        struct qbman_result *dq_storage;
        uint32_t fqid = dpaa2_qp->rx_vq.fqid;
        int ret, num_rx = 0;
@@ -1472,7 +1471,7 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops,
                }
 
                fd = qbman_result_DQ_fd(dq_storage);
-               ops[num_rx] = sec_fd_to_mbuf(fd, dev->driver_id);
+               ops[num_rx] = sec_fd_to_mbuf(fd);
 
                if (unlikely(fd->simple.frc)) {
                        /* TODO Parse SEC errors */
@@ -1546,8 +1545,8 @@ dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
                return -1;
        }
 
-       qp->rx_vq.dev = dev;
-       qp->tx_vq.dev = dev;
+       qp->rx_vq.crypto_data = dev->data;
+       qp->tx_vq.crypto_data = dev->data;
        qp->rx_vq.q_storage = rte_malloc("sec dq storage",
                sizeof(struct queue_storage_info_t),
                RTE_CACHE_LINE_SIZE);
@@ -2837,7 +2836,7 @@ dpaa2_sec_security_session_destroy(void *dev __rte_unused,
                rte_free(s->ctxt);
                rte_free(s->cipher_key.data);
                rte_free(s->auth_key.data);
-               memset(sess, 0, sizeof(dpaa2_sec_session));
+               memset(s, 0, sizeof(dpaa2_sec_session));
                set_sec_session_private_data(sess, NULL);
                rte_mempool_put(sess_mp, sess_priv);
        }
@@ -3116,8 +3115,7 @@ dpaa2_sec_process_parallel_event(struct qbman_swp *swp,
        ev->sched_type = rxq->ev.sched_type;
        ev->queue_id = rxq->ev.queue_id;
        ev->priority = rxq->ev.priority;
-       ev->event_ptr = sec_fd_to_mbuf(fd, ((struct rte_cryptodev *)
-                               (rxq->dev))->driver_id);
+       ev->event_ptr = sec_fd_to_mbuf(fd);
 
        qbman_swp_dqrr_consume(swp, dq);
 }
@@ -3145,8 +3143,7 @@ dpaa2_sec_process_atomic_event(struct qbman_swp *swp __attribute__((unused)),
        ev->queue_id = rxq->ev.queue_id;
        ev->priority = rxq->ev.priority;
 
-       ev->event_ptr = sec_fd_to_mbuf(fd, ((struct rte_cryptodev *)
-                               (rxq->dev))->driver_id);
+       ev->event_ptr = sec_fd_to_mbuf(fd);
        dqrr_index = qbman_get_dqrr_idx(dq);
        crypto_op->sym->m_src->seqn = dqrr_index + 1;
        DPAA2_PER_LCORE_DQRR_SIZE++;
@@ -3275,7 +3272,7 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
        uint16_t token;
        struct dpseci_attr attr;
        int retcode, hw_id;
-       char str[20];
+       char str[30];
 
        PMD_INIT_FUNC_TRACE();
        dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device);
@@ -3353,7 +3350,8 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
        internals->hw = dpseci;
        internals->token = token;
 
-       snprintf(str, sizeof(str), "fle_pool_%d", cryptodev->data->dev_id);
+       snprintf(str, sizeof(str), "sec_fle_pool_p%d_%d",
+                       getpid(), cryptodev->data->dev_id);
        internals->fle_pool = rte_mempool_create((const char *)str,
                        FLE_POOL_NUM_BUFS,
                        FLE_POOL_BUF_SIZE,