xref: /f-stack/dpdk/drivers/crypto/virtio/virtqueue.c (revision d30ea906)
1*d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2*d30ea906Sjfb8856606  * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
3*d30ea906Sjfb8856606  */
4*d30ea906Sjfb8856606 
5*d30ea906Sjfb8856606 #include <stdint.h>
6*d30ea906Sjfb8856606 
7*d30ea906Sjfb8856606 #include <rte_mbuf.h>
8*d30ea906Sjfb8856606 #include <rte_crypto.h>
9*d30ea906Sjfb8856606 #include <rte_malloc.h>
10*d30ea906Sjfb8856606 
11*d30ea906Sjfb8856606 #include "virtqueue.h"
12*d30ea906Sjfb8856606 
13*d30ea906Sjfb8856606 void
virtqueue_disable_intr(struct virtqueue * vq)14*d30ea906Sjfb8856606 virtqueue_disable_intr(struct virtqueue *vq)
15*d30ea906Sjfb8856606 {
16*d30ea906Sjfb8856606 	/*
17*d30ea906Sjfb8856606 	 * Set VRING_AVAIL_F_NO_INTERRUPT to hint host
18*d30ea906Sjfb8856606 	 * not to interrupt when it consumes packets
19*d30ea906Sjfb8856606 	 * Note: this is only considered a hint to the host
20*d30ea906Sjfb8856606 	 */
21*d30ea906Sjfb8856606 	vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
22*d30ea906Sjfb8856606 }
23*d30ea906Sjfb8856606 
24*d30ea906Sjfb8856606 void
virtqueue_detatch_unused(struct virtqueue * vq)25*d30ea906Sjfb8856606 virtqueue_detatch_unused(struct virtqueue *vq)
26*d30ea906Sjfb8856606 {
27*d30ea906Sjfb8856606 	struct rte_crypto_op *cop = NULL;
28*d30ea906Sjfb8856606 
29*d30ea906Sjfb8856606 	int idx;
30*d30ea906Sjfb8856606 
31*d30ea906Sjfb8856606 	if (vq != NULL)
32*d30ea906Sjfb8856606 		for (idx = 0; idx < vq->vq_nentries; idx++) {
33*d30ea906Sjfb8856606 			cop = vq->vq_descx[idx].crypto_op;
34*d30ea906Sjfb8856606 			if (cop) {
35*d30ea906Sjfb8856606 				if (cop->sym->m_src)
36*d30ea906Sjfb8856606 					rte_pktmbuf_free(cop->sym->m_src);
37*d30ea906Sjfb8856606 				if (cop->sym->m_dst)
38*d30ea906Sjfb8856606 					rte_pktmbuf_free(cop->sym->m_dst);
39*d30ea906Sjfb8856606 				rte_crypto_op_free(cop);
40*d30ea906Sjfb8856606 				vq->vq_descx[idx].crypto_op = NULL;
41*d30ea906Sjfb8856606 			}
42*d30ea906Sjfb8856606 		}
43*d30ea906Sjfb8856606 }
44