11#ifndef __INCLUDE_DAO_DMA_H__
12#define __INCLUDE_DAO_DMA_H__
16#include <rte_dmadev.h>
20#include <dao_config.h>
25#define DAO_DMA_MAX_POINTER 15u
28#define DAO_DMA_MAX_META_POINTER 48
31#define DAO_DMA_MAX_VCHAN_PER_LCORE 64
34#define DAO_DMA_MAX_INFLIGHT_MDATA 4096
249static __rte_always_inline
int
270static __rte_always_inline
bool
273 uint16_t head = vchan->
head;
274 uint16_t tail = vchan->
tail;
276 if (vchan->
src_i && (tail == op_idx))
279 return head <= tail ? (op_idx < head || op_idx >= tail) : (op_idx < head && op_idx >= tail);
292static __rte_always_inline
bool
297 uint64_t flags = (uint64_t)vchan->
auto_free << 3;
300 if (likely((src_avail >= (
int)avail || !vchan->
src_i) &&
301 (dst_avail >= (
int)avail || !vchan->
dst_i)))
305 vchan->
dst_i, flags);
306 if (unlikely(rc < 0)) {
331static __rte_always_inline uint16_t
347static __rte_always_inline uint16_t
363static __rte_always_inline
struct rte_dma_sge *
377static __rte_always_inline
struct rte_dma_sge *
400static __rte_always_inline
void
404 uint16_t src_i = vchan->
src_i;
405 uint16_t dst_i = vchan->
dst_i;
407 vchan->
dst[dst_i].addr = dst;
408 vchan->
dst[dst_i].length = dst_len;
409 vchan->
src[src_i].addr = src;
410 vchan->
src[src_i].length = src_len;
412 vchan->
src_i = src_i + 1;
413 vchan->
dst_i = dst_i + 1;
429static __rte_always_inline
void
432 uint16_t dst_i = vchan->
dst_i;
434 vchan->
dst[dst_i].addr = dst;
435 vchan->
dst[dst_i].length = dst_len;
437 vchan->
dst_i = dst_i + 1;
453static __rte_always_inline
void
456 uint16_t src_i = vchan->
src_i;
458 vchan->
src[src_i].addr = src;
459 vchan->
src[src_i].length = src_len;
461 vchan->
src_i = src_i + 1;
476static __rte_always_inline uint16_t
479 struct rte_dma_sge *src, *dst;
480 uint16_t src_i = vchan->
src_i;
481 uint16_t dst_i = vchan->
dst_i;
482 int src_avail = vchan->
flush_thr - src_i;
485 src = vchan->
src + src_i;
486 dst = vchan->
dst + dst_i;
487 if (src_avail >= 4) {
488 vst1q_u64((uint64_t *)&src[0], vsrc[0]);
489 vst1q_u64((uint64_t *)&src[1], vsrc[1]);
490 vst1q_u64((uint64_t *)&src[2], vsrc[2]);
491 vst1q_u64((uint64_t *)&src[3], vsrc[3]);
493 vst1q_u64((uint64_t *)&dst[0], vdst[0]);
494 vst1q_u64((uint64_t *)&dst[1], vdst[1]);
495 vst1q_u64((uint64_t *)&dst[2], vdst[2]);
496 vst1q_u64((uint64_t *)&dst[3], vdst[3]);
498 vchan->
src_i = src_i + 4;
499 vchan->
dst_i = dst_i + 4;
504 while (i < 4 && src_avail > 0) {
505 vst1q_u64((uint64_t *)src, vsrc[i]);
506 vst1q_u64((uint64_t *)dst, vdst[i]);
512 vchan->
src_i = src_i + i;
513 vchan->
dst_i = dst_i + i;
518 src_i = vchan->
src_i;
519 dst_i = vchan->
dst_i;
520 src = vchan->
src + src_i;
521 dst = vchan->
dst + dst_i;
524 while (i < 4 && src_avail > 0) {
525 vst1q_u64((uint64_t *)src, vsrc[i]);
526 vst1q_u64((uint64_t *)dst, vdst[i]);
543static __rte_always_inline
void
550 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
551 if (unlikely(has_err)) {
567static __rte_always_inline
void
570 uint32_t cmpl, i, j, idx = 0;
574 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
575 if (unlikely(has_err)) {
579 for (i = vchan->
head; i < vchan->
head + cmpl; i++) {
581 for (j = 0; j < vchan->
mdata[idx].
cnt; j++) {
610static __rte_always_inline
void
612 uint16_t *pend_ptr, uint16_t pend_val, uint16_t tail)
633static __rte_always_inline
void
636 uint32_t cmpl, i, j, idx = 0;
640 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
641 if (unlikely(has_err)) {
645 for (i = vchan->
head; i < vchan->
head + cmpl; i++) {
647 for (j = 0; j < vchan->
mdata[idx].
cnt; j++) {
671static __rte_always_inline
void
static __rte_always_inline void dao_dma_enq_src_x1(struct dao_dma_vchan_state *vchan, rte_iova_t src, uint32_t src_len)
static __rte_always_inline int dao_dma_has_stats_feature(void)
static __rte_always_inline struct rte_dma_sge * dao_dma_sge_dst(struct dao_dma_vchan_state *vchan)
static __rte_always_inline void dao_dma_check_meta_compl(struct dao_dma_vchan_state *vchan, const int mem_order)
void dao_dma_compl_wait_v2(uint16_t vchan)
void dao_dma_compl_wait(uint16_t vchan)
int dao_dma_lcore_mem2dev_autofree_set(int16_t dma_devid, uint16_t vchan, bool enable)
#define DAO_DMA_MAX_INFLIGHT_MDATA
int16_t dao_dma_ctrl_mem2dev(void)
static __rte_always_inline void dao_dma_check_compl(struct dao_dma_vchan_state *vchan)
int dao_dma_lcore_mem2dev_set(int16_t dma_devid, uint16_t nb_vchans, uint16_t flush_thr)
static __rte_always_inline void dao_dma_enq_x1(struct dao_dma_vchan_state *vchan, rte_iova_t src, uint32_t src_len, rte_iova_t dst, uint32_t dst_len)
int dao_dma_stats_get(uint16_t lcore_id, struct dao_dma_stats *stats)
#define DAO_DMA_MAX_VCHAN_PER_LCORE
#define DAO_DMA_MAX_META_POINTER
static __rte_always_inline uint16_t dao_dma_src_avail(struct dao_dma_vchan_state *vchan)
int dao_dma_flush_submit(void)
RTE_DECLARE_PER_LCORE(struct dao_dma_vchan_info *, dao_dma_vchan_info)
static __rte_always_inline void dao_dma_enq_dst_x1(struct dao_dma_vchan_state *vchan, rte_iova_t dst, uint32_t dst_len)
static __rte_always_inline void dao_dma_check_meta_compl_v2(struct dao_dma_vchan_state *vchan, const int mem_order)
static __rte_always_inline uint16_t dao_dma_dst_avail(struct dao_dma_vchan_state *vchan)
static __rte_always_inline bool dao_dma_flush(struct dao_dma_vchan_state *vchan, const uint8_t avail)
static __rte_always_inline struct rte_dma_sge * dao_dma_sge_src(struct dao_dma_vchan_state *vchan)
static __rte_always_inline void dao_dma_update_cmpl_meta(struct dao_dma_vchan_state *vchan, uint16_t *ptr, uint16_t val, uint16_t *pend_ptr, uint16_t pend_val, uint16_t tail)
int dao_dma_flush_submit_v2(void)
static __rte_always_inline void dao_dma_update_cmpl_meta_v2(struct dao_dma_vchan_state *vchan, uint16_t *ptr, uint16_t val, uint16_t tail)
static __rte_always_inline bool dao_dma_op_status(struct dao_dma_vchan_state *vchan, uint16_t op_idx)
int16_t dao_dma_ctrl_dev2mem(void)
static __rte_always_inline uint16_t dao_dma_enq_x4(struct dao_dma_vchan_state *vchan, uint64x2_t *vsrc, uint64x2_t *vdst)
int dao_dma_ctrl_dev_set(int16_t dev2mem_id, int16_t mem2dev_id)
int dao_dma_lcore_dev2mem_set(int16_t dma_devid, uint16_t nb_vchans, uint16_t flush_thr)
#define DAO_DMA_MAX_POINTER
uint16_t val[DAO_DMA_MAX_META_POINTER]
uint16_t * pend_ptr[DAO_DMA_MAX_META_POINTER]
uint16_t * ptr[DAO_DMA_MAX_META_POINTER]
uint16_t pend_val[DAO_DMA_MAX_META_POINTER]
struct dao_dma_vchan_stats dev2mem[DAO_DMA_MAX_VCHAN_PER_LCORE]
struct dao_dma_vchan_stats mem2dev[DAO_DMA_MAX_VCHAN_PER_LCORE]
struct dao_dma_vchan_state mem2dev[DAO_DMA_MAX_VCHAN_PER_LCORE]
struct dao_dma_vchan_state dev2mem[DAO_DMA_MAX_VCHAN_PER_LCORE]
struct rte_dma_sge dst[DAO_DMA_MAX_POINTER]
struct rte_dma_sge src[DAO_DMA_MAX_POINTER]
struct dao_dma_cmpl_mdata mdata[DAO_DMA_MAX_INFLIGHT_MDATA]