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_POINTER_THR_DFLT 8u
31#define DAO_DMA_MAX_VCHAN_PER_LCORE 128
34#define DAO_DMA_MAX_INFLIGHT_MDATA 4096
233static __rte_always_inline
int
254static __rte_always_inline
bool
257 uint16_t head = vchan->
head;
258 uint16_t tail = vchan->
tail;
260 if (vchan->
src_i && (tail == op_idx))
263 return head <= tail ? (op_idx < head || op_idx >= tail) : (op_idx < head && op_idx >= tail);
276static __rte_always_inline
bool
281 uint64_t flags = (uint64_t)vchan->
auto_free << 3;
284 if (likely((src_avail >= (
int)avail || !vchan->
src_i) &&
285 (dst_avail >= (
int)avail || !vchan->
dst_i)))
289 vchan->
dst_i, flags);
290 if (unlikely(rc < 0)) {
315static __rte_always_inline uint16_t
331static __rte_always_inline
struct rte_dma_sge *
345static __rte_always_inline
struct rte_dma_sge *
368static __rte_always_inline
void
372 uint16_t src_i = vchan->
src_i;
373 uint16_t dst_i = vchan->
dst_i;
375 vchan->
dst[dst_i].addr = dst;
376 vchan->
dst[dst_i].length = dst_len;
377 vchan->
src[src_i].addr = src;
378 vchan->
src[src_i].length = src_len;
380 vchan->
src_i = src_i + 1;
381 vchan->
dst_i = dst_i + 1;
397static __rte_always_inline
void
400 uint16_t dst_i = vchan->
dst_i;
402 vchan->
dst[dst_i].addr = dst;
403 vchan->
dst[dst_i].length = dst_len;
405 vchan->
dst_i = dst_i + 1;
421static __rte_always_inline
void
424 uint16_t src_i = vchan->
src_i;
426 vchan->
src[src_i].addr = src;
427 vchan->
src[src_i].length = src_len;
429 vchan->
src_i = src_i + 1;
444static __rte_always_inline uint16_t
447 struct rte_dma_sge *src, *dst;
448 uint16_t src_i = vchan->
src_i;
449 uint16_t dst_i = vchan->
dst_i;
450 int src_avail = vchan->
flush_thr - src_i;
453 src = vchan->
src + src_i;
454 dst = vchan->
dst + dst_i;
455 if (src_avail >= 4) {
456 vst1q_u64((uint64_t *)&src[0], vsrc[0]);
457 vst1q_u64((uint64_t *)&src[1], vsrc[1]);
458 vst1q_u64((uint64_t *)&src[2], vsrc[2]);
459 vst1q_u64((uint64_t *)&src[3], vsrc[3]);
461 vst1q_u64((uint64_t *)&dst[0], vdst[0]);
462 vst1q_u64((uint64_t *)&dst[1], vdst[1]);
463 vst1q_u64((uint64_t *)&dst[2], vdst[2]);
464 vst1q_u64((uint64_t *)&dst[3], vdst[3]);
466 vchan->
src_i = src_i + 4;
467 vchan->
dst_i = dst_i + 4;
472 while (i < 4 && src_avail > 0) {
473 vst1q_u64((uint64_t *)src, vsrc[i]);
474 vst1q_u64((uint64_t *)dst, vdst[i]);
480 vchan->
src_i = src_i + i;
481 vchan->
dst_i = dst_i + i;
486 src_i = vchan->
src_i;
487 dst_i = vchan->
dst_i;
488 src = vchan->
src + src_i;
489 dst = vchan->
dst + dst_i;
492 while (i < 4 && src_avail > 0) {
493 vst1q_u64((uint64_t *)src, vsrc[i]);
494 vst1q_u64((uint64_t *)dst, vdst[i]);
511static __rte_always_inline
void
518 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
519 if (unlikely(has_err)) {
535static __rte_always_inline
void
538 uint32_t cmpl, i, j, idx = 0;
542 cmpl = rte_dma_completed(vchan->
devid, vchan->
vchan, 128, NULL, &has_err);
543 if (unlikely(has_err)) {
547 for (i = vchan->
head; i < vchan->
head + cmpl; i++) {
549 for (j = 0; j < vchan->
mdata[idx].
cnt; j++) {
578static __rte_always_inline
void
580 uint16_t *pend_ptr, uint16_t pend_val, uint16_t tail)
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
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 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)
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
static __rte_always_inline uint16_t dao_dma_avail(struct dao_dma_vchan_state *vchan)
uint16_t * ptr[DAO_DMA_MAX_POINTER]
uint16_t * pend_ptr[DAO_DMA_MAX_POINTER]
uint16_t val[DAO_DMA_MAX_POINTER]
uint16_t pend_val[DAO_DMA_MAX_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]