dma/idxd: add datapath structures
[dpdk.git] / drivers / dma / idxd / idxd_internal.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2021 Intel Corporation
3  */
4
5 #ifndef _IDXD_INTERNAL_H_
6 #define _IDXD_INTERNAL_H_
7
8 #include <rte_dmadev_pmd.h>
9 #include <rte_spinlock.h>
10
11 #include "idxd_hw_defs.h"
12
13 /**
14  * @file idxd_internal.h
15  *
16  * Internal data structures for the idxd/DSA driver for dmadev
17  *
18  * @warning
19  * @b EXPERIMENTAL: these structures and APIs may change without prior notice
20  */
21
22 extern int idxd_pmd_logtype;
23
24 #define IDXD_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
25                 idxd_pmd_logtype, "IDXD: %s(): " fmt "\n", __func__, ##args)
26
27 #define IDXD_PMD_DEBUG(fmt, args...)  IDXD_PMD_LOG(DEBUG, fmt, ## args)
28 #define IDXD_PMD_INFO(fmt, args...)   IDXD_PMD_LOG(INFO, fmt, ## args)
29 #define IDXD_PMD_ERR(fmt, args...)    IDXD_PMD_LOG(ERR, fmt, ## args)
30 #define IDXD_PMD_WARN(fmt, args...)   IDXD_PMD_LOG(WARNING, fmt, ## args)
31
32 struct idxd_pci_common {
33         rte_spinlock_t lk;
34
35         uint8_t wq_cfg_sz;
36         volatile struct rte_idxd_bar0 *regs;
37         volatile uint32_t *wq_regs_base;
38         volatile struct rte_idxd_grpcfg *grp_regs;
39         volatile void *portals;
40 };
41
42 struct idxd_dmadev {
43         struct idxd_hw_desc *desc_ring;
44
45         /* counters to track the batches */
46         unsigned short max_batches;
47         unsigned short batch_idx_read;
48         unsigned short batch_idx_write;
49
50         /* track descriptors and handles */
51         unsigned short desc_ring_mask;
52         unsigned short ids_avail; /* handles for ops completed */
53         unsigned short ids_returned; /* the read pointer for hdls/desc rings */
54         unsigned short batch_start; /* start+size == write pointer for hdls/desc */
55         unsigned short batch_size;
56
57         void *portal; /* address to write the batch descriptor */
58
59         struct idxd_completion *batch_comp_ring;
60         unsigned short *batch_idx_ring; /* store where each batch ends */
61
62         rte_iova_t batch_iova; /* base address of the batch comp ring */
63         rte_iova_t desc_iova; /* base address of desc ring, needed for completions */
64
65         unsigned short max_batch_size;
66
67         struct rte_dma_dev *dmadev;
68         struct rte_dma_vchan_conf qcfg;
69         uint8_t sva_support;
70         uint8_t qid;
71
72         union {
73                 struct {
74                         unsigned int dsa_id;
75                 } bus;
76
77                 struct idxd_pci_common *pci;
78         } u;
79 };
80
81 int idxd_dmadev_create(const char *name, struct rte_device *dev,
82                 const struct idxd_dmadev *base_idxd, const struct rte_dma_dev_ops *ops);
83 int idxd_dump(const struct rte_dma_dev *dev, FILE *f);
84
85 #endif /* _IDXD_INTERNAL_H_ */