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_POINTER_THR_DFLT 8u
34#define DAO_DMA_MAX_VCHAN_PER_LCORE 64
37#define DAO_DMA_MAX_INFLIGHT_MDATA 4096
244static __rte_always_inline
int
265static __rte_always_inline
bool
268 uint16_t head = vchan->
head;
269 uint16_t tail = vchan->
tail;
271 if (vchan->
src_i && (tail == op_idx))
274 return head <= tail ? (op_idx < head || op_idx >= tail) : (op_idx < head && op_idx >= tail);
287static __rte_always_inline
bool
292 uint64_t flags = (uint64_t)vchan->
auto_free << 3;
295 if (likely((src_avail >= (
int)avail || !vchan->
src_i) &&
296 (dst_avail >= (
int)avail || !vchan->
dst_i)))
300 vchan->
dst_i, flags);
301 if (unlikely(rc < 0)) {
326static __rte_always_inline uint16_t
342static __rte_always_inline uint16_t
358static __rte_always_inline
struct rte_dma_sge *
372static __rte_always_inline
struct rte_dma_sge *
395static __rte_always_inline
void
399 uint16_t src_i = vchan->
src_i;
400 uint16_t dst_i = vchan->
dst_i;
402 vchan->
dst[dst_i].addr = dst;
403 vchan->
dst[dst_i].length = dst_len;
404 vchan->
src[src_i].addr = src;
405 vchan->
src[src_i].length = src_len;
407 vchan->
src_i = src_i + 1;
408 vchan->
dst_i = dst_i + 1;
424static __rte_always_inline
void
427 uint16_t dst_i = vchan->
dst_i;
429 vchan->
dst[dst_i].addr = dst;
430 vchan->
dst[dst_i].length = dst_len;
432 vchan->
dst_i = dst_i + 1;
448static __rte_always_inline
void
451 uint16_t src_i = vchan->
src_i;
453 vchan->
src[src_i].addr = src;
454 vchan->
src[src_i].length = src_len;
456 vchan->
src_i = src_i + 1;
471static __rte_always_inline uint16_t
474 struct rte_dma_sge *src, *dst;
475 uint16_t src_i = vchan->
src_i;
476 uint16_t dst_i = vchan->
dst_i;
477 int src_avail = vchan->
flush_thr - src_i;
480 src = vchan->
src + src_i;
481 dst = vchan->
dst + dst_i;
482 if (src_avail >= 4) {
483 vst1q_u64((uint64_t *)&src[0], vsrc[0]);
484 vst1q_u64((uint64_t *)&src[1], vsrc[1]);
485 vst1q_u64((uint64_t *)&src[2], vsrc[2]);
486 vst1q_u64((uint64_t *)&src[3], vsrc[3]);
488 vst1q_u64((uint64_t *)&dst[0], vdst[0]);
489 vst1q_u64((uint64_t *)&dst[1], vdst[1]);
490 vst1q_u64((uint64_t *)&dst[2], vdst[2]);
491 vst1q_u64((uint64_t *)&dst[3], vdst[3]);
493 vchan->
src_i = src_i + 4;
494 vchan->
dst_i = dst_i + 4;
499 while (i < 4 && src_avail > 0) {
500 vst1q_u64((uint64_t *)src, vsrc[i]);
501 vst1q_u64((uint64_t *)dst, vdst[i]);
507 vchan->
src_i = src_i + i;
508 vchan->
dst_i = dst_i + i;
513 src_i = vchan->
src_i;
514 dst_i = vchan->
dst_i;
515 src = vchan->
src + src_i;
516 dst = vchan->
dst + dst_i;
519 while (i < 4 && src_avail > 0) {
520 vst1q_u64((uint64_t *)src, vsrc[i]);
521 vst1q_u64((uint64_t *)dst, vdst[i]);
538static __rte_always_inline
void
545 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
546 if (unlikely(has_err)) {
562static __rte_always_inline
void
565 uint32_t cmpl, i, j, idx = 0;
569 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
570 if (unlikely(has_err)) {
574 for (i = vchan->
head; i < vchan->
head + cmpl; i++) {
576 for (j = 0; j < vchan->
mdata[idx].
cnt; j++) {
605static __rte_always_inline
void
607 uint16_t *pend_ptr, uint16_t pend_val, uint16_t tail)
628static __rte_always_inline
void
631 uint32_t cmpl, i, j, idx = 0;
635 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
636 if (unlikely(has_err)) {
640 for (i = vchan->
head; i < vchan->
head + cmpl; i++) {
642 for (j = 0; j < vchan->
mdata[idx].
cnt; j++) {
666static __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(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]