1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
5 #ifndef _RTE_VHOST_ASYNC_H_
6 #define _RTE_VHOST_ASYNC_H_
10 #include <rte_compat.h>
14 * Register an async channel for a vhost queue
17 * vhost device id async channel to be attached to
19 * vhost queue id async channel to be attached to
21 * 0 on success, -1 on failures
24 int rte_vhost_async_channel_register(int vid, uint16_t queue_id);
27 * Unregister an async channel for a vhost queue
30 * vhost device id async channel to be detached from
32 * vhost queue id async channel to be detached from
34 * 0 on success, -1 on failures
37 int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id);
40 * Register an async channel for a vhost queue without performing any
43 * @note This function does not perform any locking, and is only safe to
44 * call in vhost callback functions.
47 * vhost device id async channel to be attached to
49 * vhost queue id async channel to be attached to
51 * 0 on success, -1 on failures
54 int rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id);
57 * Unregister an async channel for a vhost queue without performing any
60 * @note This function does not perform any locking, and is only safe to
61 * call in vhost callback functions.
64 * vhost device id async channel to be detached from
66 * vhost queue id async channel to be detached from
68 * 0 on success, -1 on failures
71 int rte_vhost_async_channel_unregister_thread_unsafe(int vid,
75 * This function submits enqueue packets to async copy engine. Users
76 * need to poll transfer status by rte_vhost_poll_enqueue_completed()
77 * for successfully enqueued packets.
80 * id of vhost device to enqueue data
82 * queue id to enqueue data
84 * array of packets to be enqueued
86 * packets num to be enqueued
88 * the identifier of DMA device
90 * the identifier of virtual DMA channel
92 * num of packets enqueued
95 uint16_t rte_vhost_submit_enqueue_burst(int vid, uint16_t queue_id,
96 struct rte_mbuf **pkts, uint16_t count, int16_t dma_id,
100 * This function checks async completion status for a specific vhost
101 * device queue. Packets which finish copying (enqueue) operation
102 * will be returned in an array.
105 * id of vhost device to enqueue data
107 * queue id to enqueue data
109 * blank array to get return packet pointer
111 * size of the packet array
113 * the identifier of DMA device
115 * the identifier of virtual DMA channel
117 * num of packets returned
120 uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
121 struct rte_mbuf **pkts, uint16_t count, int16_t dma_id,
125 * This function returns the amount of in-flight packets for the vhost
126 * queue which uses async channel acceleration.
129 * id of vhost device to enqueue data
131 * queue id to enqueue data
133 * the amount of in-flight packets on success; -1 on failure
136 int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);
139 * This function checks async completion status and clear packets for
140 * a specific vhost device queue. Packets which are inflight will be
141 * returned in an array.
143 * @note This function does not perform any locking
146 * ID of vhost device to clear data
148 * Queue id to clear data
150 * Blank array to get return packet pointer
152 * Size of the packet array
154 * the identifier of DMA device
156 * the identifier of virtual DMA channel
158 * Number of packets returned
161 uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,
162 struct rte_mbuf **pkts, uint16_t count, int16_t dma_id,
166 * The DMA vChannels used in asynchronous data path must be configured
167 * first. So this function needs to be called before enabling DMA
168 * acceleration for vring. If this function fails, the given DMA vChannel
169 * cannot be used in asynchronous data path.
171 * DMA devices used in data-path must belong to DMA devices given in this
172 * function. Application is free to use DMA devices passed to this function
173 * for non-vhost scenarios, but will have to ensure the Vhost library is not
174 * using the channel at the same time.
177 * the identifier of DMA device
179 * the identifier of virtual DMA channel
181 * 0 on success, and -1 on failure
184 int rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id);
186 #endif /* _RTE_VHOST_ASYNC_H_ */