replace packed attributes
[dpdk.git] / drivers / raw / dpaa2_qdma / dpaa2_qdma.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018-2019 NXP
3  */
4
5 #ifndef __DPAA2_QDMA_H__
6 #define __DPAA2_QDMA_H__
7
8 struct qdma_sdd;
9 struct rte_qdma_job;
10
11 #define DPAA2_QDMA_MAX_FLE 3
12 #define DPAA2_QDMA_MAX_SDD 2
13
14 #define DPAA2_DPDMAI_MAX_QUEUES 8
15
16 /** FLE pool size: 3 Frame list + 2 source/destination descriptor */
17 #define QDMA_FLE_POOL_SIZE (sizeof(struct rte_qdma_job *) + \
18                 sizeof(struct qbman_fle) * DPAA2_QDMA_MAX_FLE + \
19                 sizeof(struct qdma_sdd) * DPAA2_QDMA_MAX_SDD)
20 /** FLE pool cache size */
21 #define QDMA_FLE_CACHE_SIZE(_num) (_num/(RTE_MAX_LCORE * 2))
22
23 /** Notification by FQD_CTX[fqid] */
24 #define QDMA_SER_CTX (1 << 8)
25 #define DPAA2_RBP_MEM_RW            0x0
26 /**
27  * Source descriptor command read transaction type for RBP=0:
28  * coherent copy of cacheable memory
29  */
30 #define DPAA2_COHERENT_NO_ALLOCATE_CACHE        0xb
31 #define DPAA2_LX2_COHERENT_NO_ALLOCATE_CACHE    0x7
32 /**
33  * Destination descriptor command write transaction type for RBP=0:
34  * coherent copy of cacheable memory
35  */
36 #define DPAA2_COHERENT_ALLOCATE_CACHE           0x6
37 #define DPAA2_LX2_COHERENT_ALLOCATE_CACHE       0xb
38
39 /** Maximum possible H/W Queues on each core */
40 #define MAX_HW_QUEUE_PER_CORE           64
41
42 #define QDMA_RBP_UPPER_ADDRESS_MASK (0xfff0000000000)
43 /**
44  * Represents a QDMA device.
45  * A single QDMA device exists which is combination of multiple DPDMAI rawdev's.
46  */
47 struct qdma_device {
48         /** total number of hw queues. */
49         uint16_t num_hw_queues;
50         /**
51          * Maximum number of hw queues to be alocated per core.
52          * This is limited by MAX_HW_QUEUE_PER_CORE
53          */
54         uint16_t max_hw_queues_per_core;
55         /** Maximum number of VQ's */
56         uint16_t max_vqs;
57         /** mode of operation - physical(h/w) or virtual */
58         uint8_t mode;
59         /** Device state - started or stopped */
60         uint8_t state;
61         /** FLE pool for the device */
62         struct rte_mempool *fle_pool;
63         /** FLE pool size */
64         int fle_pool_count;
65         /** A lock to QDMA device whenever required */
66         rte_spinlock_t lock;
67 };
68
69 /** Represents a QDMA H/W queue */
70 struct qdma_hw_queue {
71         /** Pointer to Next instance */
72         TAILQ_ENTRY(qdma_hw_queue) next;
73         /** DPDMAI device to communicate with HW */
74         struct dpaa2_dpdmai_dev *dpdmai_dev;
75         /** queue ID to communicate with HW */
76         uint16_t queue_id;
77         /** Associated lcore id */
78         uint32_t lcore_id;
79         /** Number of users of this hw queue */
80         uint32_t num_users;
81 };
82
83 /** Represents a QDMA virtual queue */
84 struct qdma_virt_queue {
85         /** Status ring of the virtual queue */
86         struct rte_ring *status_ring;
87         /** Associated hw queue */
88         struct qdma_hw_queue *hw_queue;
89         /** Route by port */
90         struct rte_qdma_rbp rbp;
91         /** Associated lcore id */
92         uint32_t lcore_id;
93         /** States if this vq is in use or not */
94         uint8_t in_use;
95         /** States if this vq has exclusively associated hw queue */
96         uint8_t exclusive_hw_queue;
97         /* Total number of enqueues on this VQ */
98         uint64_t num_enqueues;
99         /* Total number of dequeues from this VQ */
100         uint64_t num_dequeues;
101 };
102
103 /** Represents a QDMA per core hw queues allocation in virtual mode */
104 struct qdma_per_core_info {
105         /** list for allocated hw queues */
106         struct qdma_hw_queue *hw_queues[MAX_HW_QUEUE_PER_CORE];
107         /* Number of hw queues allocated for this core */
108         uint16_t num_hw_queues;
109 };
110
111 /** Source/Destination Descriptor */
112 struct qdma_sdd {
113         uint32_t rsv;
114         /** Stride configuration */
115         uint32_t stride;
116         /** Route-by-port command */
117         union {
118                 uint32_t rbpcmd;
119                 struct rbpcmd_st {
120                         uint32_t vfid:6;
121                         uint32_t rsv4:2;
122                         uint32_t pfid:1;
123                         uint32_t rsv3:7;
124                         uint32_t attr:3;
125                         uint32_t rsv2:1;
126                         uint32_t at:2;
127                         uint32_t vfa:1;
128                         uint32_t ca:1;
129                         uint32_t tc:3;
130                         uint32_t rsv1:5;
131                 } rbpcmd_simple;
132         };
133         union {
134                 uint32_t cmd;
135                 struct rcmd_simple {
136                         uint32_t portid:4;
137                         uint32_t rsv1:14;
138                         uint32_t rbp:1;
139                         uint32_t ssen:1;
140                         uint32_t rthrotl:4;
141                         uint32_t sqos:3;
142                         uint32_t ns:1;
143                         uint32_t rdtype:4;
144                 } read_cmd;
145                 struct wcmd_simple {
146                         uint32_t portid:4;
147                         uint32_t rsv3:10;
148                         uint32_t rsv2:2;
149                         uint32_t lwc:2;
150                         uint32_t rbp:1;
151                         uint32_t dsen:1;
152                         uint32_t rsv1:4;
153                         uint32_t dqos:3;
154                         uint32_t ns:1;
155                         uint32_t wrttype:4;
156                 } write_cmd;
157         };
158 } __rte_packed;
159
160 /** Represents a DPDMAI raw device */
161 struct dpaa2_dpdmai_dev {
162         /** Pointer to Next device instance */
163         TAILQ_ENTRY(dpaa2_qdma_device) next;
164         /** handle to DPDMAI object */
165         struct fsl_mc_io dpdmai;
166         /** HW ID for DPDMAI object */
167         uint32_t dpdmai_id;
168         /** Tocken of this device */
169         uint16_t token;
170         /** Number of queue in this DPDMAI device */
171         uint8_t num_queues;
172         /** RX queues */
173         struct dpaa2_queue rx_queue[DPAA2_DPDMAI_MAX_QUEUES];
174         /** TX queues */
175         struct dpaa2_queue tx_queue[DPAA2_DPDMAI_MAX_QUEUES];
176 };
177
178 #endif /* __DPAA2_QDMA_H__ */