[PATCH v2] crypto/virtio: cookies are allocated from mempool

Ji, Kai kai.ji at intel.com
Wed Jul 15 12:29:28 CEST 2026


Acked-by: Kai Ji <kai.ji at intel.com>
________________________________
From: Radu Nicolau <radu.nicolau at intel.com>
Sent: 06 July 2026 17:57
To: dev at dpdk.org <dev at dpdk.org>
Cc: maxime.coquelin at redhat.com <maxime.coquelin at redhat.com>; david.marchand at redhat.com <david.marchand at redhat.com>; Nicolau, Radu <radu.nicolau at intel.com>; jianjay.zhou at huawei.com <jianjay.zhou at huawei.com>; Jiang, YuX <yux.jiang at intel.com>; Fan Zhang <fanzhang.oss at gmail.com>
Subject: [PATCH v2] crypto/virtio: cookies are allocated from mempool

The Rx/Tx functions allocate cookies as needed, no need to
allocate and free from heap.

Fixes: 6f0175ff53e0 ("crypto/virtio: support basic PMD ops")
Cc: jianjay.zhou at huawei.com

Signed-off-by: Radu Nicolau <radu.nicolau at intel.com>
Tested-by: Yu Jiang <yux.jiang at intel.com>
---
v2: removed redundant mempool free

 drivers/crypto/virtio/virtio_cryptodev.c | 23 -----------------------
 1 file changed, 23 deletions(-)

diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index 6f079f15f6..d70651646e 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -68,7 +68,6 @@ void
 virtio_crypto_queue_release(struct virtqueue *vq)
 {
         struct virtio_crypto_hw *hw;
-       uint16_t i;

         PMD_INIT_FUNC_TRACE();

@@ -80,9 +79,6 @@ virtio_crypto_queue_release(struct virtqueue *vq)
                 hw->vqs[vq->vq_queue_index] = NULL;
                 rte_memzone_free(vq->mz);
                 rte_mempool_free(vq->mpool);
-               for (i = 0; i < vq->vq_nentries; i++)
-                       rte_free(vq->vq_descx[i].cookie);
-
                 rte_free(vq);
         }
 }
@@ -102,8 +98,6 @@ virtio_crypto_queue_setup(struct rte_cryptodev *dev,
         unsigned int vq_size;
         struct virtio_crypto_hw *hw = dev->data->dev_private;
         struct virtqueue *vq = NULL;
-       uint32_t i = 0;
-       uint32_t j;

         PMD_INIT_FUNC_TRACE();

@@ -175,29 +169,12 @@ virtio_crypto_queue_setup(struct rte_cryptodev *dev,
                                         "Cannot create mempool");
                         goto mpool_create_err;
                 }
-               for (i = 0; i < nb_desc; i++) {
-                       vq->vq_descx[i].cookie =
-                               rte_zmalloc("crypto PMD op cookie pointer",
-                                       sizeof(struct virtio_crypto_op_cookie),
-                                       RTE_CACHE_LINE_SIZE);
-                       if (vq->vq_descx[i].cookie == NULL) {
-                               VIRTIO_CRYPTO_DRV_LOG_ERR("Failed to "
-                                               "alloc mem for cookie");
-                               goto cookie_alloc_err;
-                       }
-               }
         }

         *pvq = vq;

         return 0;

-cookie_alloc_err:
-       rte_mempool_free(vq->mpool);
-       if (i != 0) {
-               for (j = 0; j < i; j++)
-                       rte_free(vq->vq_descx[j].cookie);
-       }
 mpool_create_err:
         rte_free(vq);
         return -ENOMEM;
--
2.52.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mails.dpdk.org/archives/dev/attachments/20260715/7ed47aad/attachment.htm>


More information about the dev mailing list