X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fvhost%2Frte_vhost_async.h;h=a87ea6ba37592f4013a8778f01c85ce88bd352eb;hb=6e858b4d9244cf53505589673755ab18ac2a4a83;hp=7c55825de258d92ffa4ad66831575c260c62031a;hpb=0c0935c5f794c66e587d8e0fa5bb2dc75c9c010d;p=dpdk.git diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h index 7c55825de2..a87ea6ba37 100644 --- a/lib/vhost/rte_vhost_async.h +++ b/lib/vhost/rte_vhost_async.h @@ -7,30 +7,25 @@ #include "rte_vhost.h" +/** + * iovec + */ +struct rte_vhost_iovec { + void *src_addr; + void *dst_addr; + size_t len; +}; + /** * iovec iterator */ struct rte_vhost_iov_iter { - /** offset to the first byte of interesting data */ - size_t offset; - /** total bytes of data in this iterator */ - size_t count; /** pointer to the iovec array */ - struct iovec *iov; + struct rte_vhost_iovec *iov; /** number of iovec in this iterator */ unsigned long nr_segs; }; -/** - * dma transfer descriptor pair - */ -struct rte_vhost_async_desc { - /** source memory iov_iter */ - struct rte_vhost_iov_iter *src; - /** destination memory iov_iter */ - struct rte_vhost_iov_iter *dst; -}; - /** * dma transfer status */ @@ -52,17 +47,17 @@ struct rte_vhost_async_channel_ops { * id of vhost device to perform data copies * @param queue_id * queue id to perform data copies - * @param descs - * an array of DMA transfer memory descriptors + * @param iov_iter + * an array of IOV iterators * @param opaque_data * opaque data pair sending to DMA engine * @param count * number of elements in the "descs" array * @return - * number of descs processed + * number of IOV iterators processed, negative value means error */ - uint32_t (*transfer_data)(int vid, uint16_t queue_id, - struct rte_vhost_async_desc *descs, + int32_t (*transfer_data)(int vid, uint16_t queue_id, + struct rte_vhost_iov_iter *iov_iter, struct rte_vhost_async_status *opaque_data, uint16_t count); /** @@ -76,66 +71,54 @@ struct rte_vhost_async_channel_ops { * @param max_packets * max number of packets could be completed * @return - * number of async descs completed + * number of async descs completed, negative value means error */ - uint32_t (*check_completed_copies)(int vid, uint16_t queue_id, + int32_t (*check_completed_copies)(int vid, uint16_t queue_id, struct rte_vhost_async_status *opaque_data, uint16_t max_packets); }; /** - * inflight async packet information + * async channel features */ -struct async_inflight_info { - struct rte_mbuf *mbuf; - uint16_t descs; /* num of descs inflight */ - uint16_t nr_buffers; /* num of buffers inflight for packed ring */ +enum { + RTE_VHOST_ASYNC_INORDER = 1U << 0, }; /** - * dma channel feature bit definition + * async channel configuration */ -struct rte_vhost_async_features { - union { - uint32_t intval; - struct { - uint32_t async_inorder:1; - uint32_t resvd_0:15; - uint32_t async_threshold:12; - uint32_t resvd_1:4; - }; - }; +struct rte_vhost_async_config { + uint32_t features; + uint32_t rsvd[2]; }; /** - * register an async channel for vhost + * Register an async channel for a vhost queue * * @param vid * vhost device id async channel to be attached to * @param queue_id * vhost queue id async channel to be attached to - * @param features - * DMA channel feature bit - * b0 : DMA supports inorder data transfer - * b1 - b15: reserved - * b16 - b27: Packet length threshold for DMA transfer - * b28 - b31: reserved + * @param config + * Async channel configuration structure * @param ops - * DMA operation callbacks + * Async channel operation callbacks * @return * 0 on success, -1 on failures */ __rte_experimental int rte_vhost_async_channel_register(int vid, uint16_t queue_id, - uint32_t features, struct rte_vhost_async_channel_ops *ops); + struct rte_vhost_async_config config, + struct rte_vhost_async_channel_ops *ops); /** - * unregister a dma channel for vhost + * Unregister an async channel for a vhost queue * * @param vid - * vhost device id DMA channel to be detached + * vhost device id async channel to be detached from * @param queue_id - * vhost queue id DMA channel to be detached + * vhost queue id async channel to be detached from * @return * 0 on success, -1 on failures */ @@ -143,13 +126,50 @@ __rte_experimental int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id); /** - * This function submits enqueue data to async engine. Successfully - * enqueued packets can be transfer completed or being occupied by DMA - * engines, when this API returns. Transfer completed packets are returned - * in comp_pkts, so users need to guarantee its size is greater than or - * equal to the size of pkts; for packets that are successfully enqueued - * but not transfer completed, users should poll transfer status by - * rte_vhost_poll_enqueue_completed(). + * Register an async channel for a vhost queue without performing any + * locking + * + * @note This function does not perform any locking, and is only safe to + * call in vhost callback functions. + * + * @param vid + * vhost device id async channel to be attached to + * @param queue_id + * vhost queue id async channel to be attached to + * @param config + * Async channel configuration + * @param ops + * Async channel operation callbacks + * @return + * 0 on success, -1 on failures + */ +__rte_experimental +int rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id, + struct rte_vhost_async_config config, + struct rte_vhost_async_channel_ops *ops); + +/** + * Unregister an async channel for a vhost queue without performing any + * locking + * + * @note This function does not perform any locking, and is only safe to + * call in vhost callback functions. + * + * @param vid + * vhost device id async channel to be detached from + * @param queue_id + * vhost queue id async channel to be detached from + * @return + * 0 on success, -1 on failures + */ +__rte_experimental +int rte_vhost_async_channel_unregister_thread_unsafe(int vid, + uint16_t queue_id); + +/** + * This function submits enqueue packets to async copy engine. Users + * need to poll transfer status by rte_vhost_poll_enqueue_completed() + * for successfully enqueued packets. * * @param vid * id of vhost device to enqueue data @@ -159,19 +179,12 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id); * array of packets to be enqueued * @param count * packets num to be enqueued - * @param comp_pkts - * empty array to get transfer completed packets. Users need to - * guarantee its size is greater than or equal to that of pkts - * @param comp_count - * num of packets that are transfer completed, when this API returns. - * If no packets are transfer completed, its value is set to 0. * @return - * num of packets enqueued, including in-flight and transfer completed + * num of packets enqueued */ __rte_experimental uint16_t rte_vhost_submit_enqueue_burst(int vid, uint16_t queue_id, - struct rte_mbuf **pkts, uint16_t count, - struct rte_mbuf **comp_pkts, uint32_t *comp_count); + struct rte_mbuf **pkts, uint16_t count); /** * This function checks async completion status for a specific vhost @@ -207,4 +220,26 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id, __rte_experimental int rte_vhost_async_get_inflight(int vid, uint16_t queue_id); +/** + * This function checks async completion status and clear packets for + * a specific vhost device queue. Packets which are inflight will be + * returned in an array. + * + * @note This function does not perform any locking + * + * @param vid + * ID of vhost device to clear data + * @param queue_id + * Queue id to clear data + * @param pkts + * Blank array to get return packet pointer + * @param count + * Size of the packet array + * @return + * Number of packets returned + */ +__rte_experimental +uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id, + struct rte_mbuf **pkts, uint16_t count); + #endif /* _RTE_VHOST_ASYNC_H_ */