-
Notifications
You must be signed in to change notification settings - Fork 3
/
neuron_dma.h
101 lines (90 loc) · 3.44 KB
/
neuron_dma.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2020, Amazon.com, Inc. or its affiliates. All Rights Reserved
*/
#ifndef NEURON_DMA_H
#define NEURON_DMA_H
#include "udma/udma.h"
#include "neuron_mempool.h"
#include "neuron_ring.h"
struct neuron_device;
/**
* ndma_memcpy_mc() - Copy data from a memory to another memory chunk.
*
* @nd: neuron device which should be used for dma
* @src_mc: source memory chunk from which data should be copied
* @dst_mc: destination memory chunk to which data should be copied
* @src_offset: offset in the source from where copy should start
* @dst_offset: offset in the destination
* @size: copy size
*
* Return: 0 if copy succeeds, a negative error code otherwise.
*/
int ndma_memcpy_mc(struct neuron_device *nd, struct mem_chunk *src_mc, struct mem_chunk *dst_mc,
u32 src_offset, u32 dst_offset, u32 size);
/**
* ndma_memcpy_buf_to_mc() - Copyin data from given buffer to a memory chunk.
*
* @nd: neuron device which should be used for dma
* @buffer: source buffer from which data should be copied
* @dst_mc: destination memory chunk to which data should be copied
* @src_offset: offset in the source from where copy should start
* @dst_offset: offset in the destination
* @size: copy size
*
* Return: 0 if copy succeeds, a negative error code otherwise.
*/
int ndma_memcpy_buf_to_mc(struct neuron_device *nd, void *buffer, u32 src_offset,
struct mem_chunk *dst_mc, u32 dst_offset, u32 size);
/**
* ndma_memcpy_buf_from_mc() - Copyout data from given buffer to a memory chunk.
*
* @nd: neuron device which should be used for dma
* @src_mc: source memory chunk from which data should be copied
* @buffer: destination buffer
* @src_offset: offset in the source from where copy should start
* @dst_offset: offset in the destination
* @size: copy size.
*
* Return: 0 if copy succeeds, a negative error code otherwise.
*/
int ndma_memcpy_buf_from_mc(struct neuron_device *nd, void *buffer, u32 dst_offset,
struct mem_chunk *src_mc, u32 src_offset, u32 size);
/**
* ndma_memcpy_dma_copy_descriptors() - Copy dma descriptors to mc which is backing a dma queue.
*
* @nd: neuron device which should be used for dma
* @buffer: source buffer which contains the dma descriptors
* @queue_type: dma queue type(tx or rx)
* @dst_mc: mc which backs the dma queue
* @offset: offset in the queue.
* @size: copy size.
*
* Return: 0 if copy succeeds, a negative error code otherwise.
*/
int ndma_memcpy_dma_copy_descriptors(struct neuron_device *nd, void *buffer, u32 src_offset,
struct mem_chunk *dst_mc, u32 dst_offset, u32 size,
u32 queue_type);
/**
* ndma_memcpy() - Copy data from one physical address to another physical address.
*
* @nd: neuron device which should be used for dma
* @nc_id: neuron core index(determines which dma engine to use for the transfer)
* @src: source address in the neuron core
* @dst: destination address in the neuron core
* @size: copy size.
*
* Return: 0 if copy succeeds, a negative error code otherwise.
*/
int ndma_memcpy(struct neuron_device *nd, u32 nc_id, dma_addr_t src, dma_addr_t dst, u32 size);
/**
* ndma_memcpy_wait_for_completion() - Wait for already initiated DMA transfer to complete.
*
* @eng: dma engine
* @ring: dma ring
* @count: number of descriptors to wait for.
*
* Return: 0 if wait succeeds, a negative error code otherwise.
*/
int ndma_memcpy_wait_for_completion(struct ndma_eng *eng, struct ndma_ring *ring, u32 count);
#endif