net/mlx5: fix meter creation default state
[dpdk.git] / drivers / bus / fslmc / mc / fsl_dpdmai.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018-2021 NXP
3  */
4
5 #ifndef __FSL_DPDMAI_H
6 #define __FSL_DPDMAI_H
7
8 #include <rte_compat.h>
9
10 struct fsl_mc_io;
11
12 /* Data Path DMA Interface API
13  * Contains initialization APIs and runtime control APIs for DPDMAI
14  */
15
16 /* General DPDMAI macros */
17
18 /**
19  * Maximum number of Tx/Rx priorities per DPDMAI object
20  */
21 #define DPDMAI_PRIO_NUM         2
22
23 /**
24  * All queues considered; see dpdmai_set_rx_queue()
25  */
26 #define DPDMAI_ALL_QUEUES       (uint8_t)(-1)
27
28 __rte_internal
29 int dpdmai_open(struct fsl_mc_io *mc_io,
30                 uint32_t cmd_flags,
31                 int dpdmai_id,
32                 uint16_t *token);
33
34 __rte_internal
35 int dpdmai_close(struct fsl_mc_io *mc_io,
36                  uint32_t cmd_flags,
37                  uint16_t token);
38
39 /* DPDMAI options */
40
41 /**
42  * Enable individual Congestion Groups usage per each priority queue
43  * If this option is not enabled then only one CG is used for all priority
44  * queues
45  * If this option is enabled then a separate specific CG is used for each
46  * individual priority queue.
47  * In this case the priority queue must be specified via congestion notification
48  * API
49  */
50 #define DPDMAI_OPT_CG_PER_PRIORITY              0x00000001
51
52 /**
53  * struct dpdmai_cfg - Structure representing DPDMAI configuration
54  * @priorities: Priorities for the DMA hardware processing; valid priorities are
55  *      configured with values 1-8; the entry following last valid entry
56  *      should be configured with 0
57  *      @options: dpdmai options
58  */
59 struct dpdmai_cfg {
60         uint8_t num_queues;
61         uint8_t priorities[DPDMAI_PRIO_NUM];
62         struct {
63                 uint32_t options;
64         } adv;
65 };
66
67 int dpdmai_create(struct fsl_mc_io *mc_io,
68                   uint16_t dprc_token,
69                   uint32_t cmd_flags,
70                   const struct dpdmai_cfg *cfg,
71                   uint32_t *obj_id);
72
73 int dpdmai_destroy(struct fsl_mc_io *mc_io,
74                    uint16_t dprc_token,
75                    uint32_t cmd_flags,
76                    uint32_t object_id);
77
78 __rte_internal
79 int dpdmai_enable(struct fsl_mc_io *mc_io,
80                   uint32_t cmd_flags,
81                   uint16_t token);
82
83 __rte_internal
84 int dpdmai_disable(struct fsl_mc_io *mc_io,
85                    uint32_t cmd_flags,
86                    uint16_t token);
87
88 int dpdmai_is_enabled(struct fsl_mc_io *mc_io,
89                       uint32_t cmd_flags,
90                       uint16_t token,
91                       int *en);
92
93 int dpdmai_reset(struct fsl_mc_io *mc_io,
94                  uint32_t cmd_flags,
95                  uint16_t token);
96
97 /**
98  * struct dpdmai_attr - Structure representing DPDMAI attributes
99  * @id: DPDMAI object ID
100  * @num_of_priorities: number of priorities
101  * @options: dpdmai options
102  */
103 struct dpdmai_attr {
104         int id;
105         uint8_t num_of_priorities;
106         uint8_t num_of_queues;
107         uint32_t options;
108 };
109
110 __rte_internal
111 int dpdmai_get_attributes(struct fsl_mc_io *mc_io,
112                           uint32_t cmd_flags,
113                           uint16_t token,
114                           struct dpdmai_attr *attr);
115
116 /**
117  * enum dpdmai_dest - DPDMAI destination types
118  * @DPDMAI_DEST_NONE: Unassigned destination; The queue is set in parked mode
119  *      and does not generate FQDAN notifications; user is expected to dequeue
120  *      from the queue based on polling or other user-defined method
121  * @DPDMAI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
122  *      notifications to the specified DPIO; user is expected to dequeue
123  *      from the queue only after notification is received
124  * @DPDMAI_DEST_DPCON: The queue is set in schedule mode and does not generate
125  *      FQDAN notifications, but is connected to the specified DPCON object;
126  *      user is expected to dequeue from the DPCON channel
127  */
128 enum dpdmai_dest {
129         DPDMAI_DEST_NONE = 0,
130         DPDMAI_DEST_DPIO = 1,
131         DPDMAI_DEST_DPCON = 2
132 };
133
134 /**
135  * struct dpdmai_dest_cfg - Structure representing DPDMAI destination parameters
136  * @dest_type: Destination type
137  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
138  * @priority: Priority selection within the DPIO or DPCON channel; valid values
139  *      are 0-1 or 0-7, depending on the number of priorities in that
140  *      channel; not relevant for 'DPDMAI_DEST_NONE' option
141  */
142 struct dpdmai_dest_cfg {
143         enum dpdmai_dest dest_type;
144         int dest_id;
145         uint8_t priority;
146 };
147
148 /* DPDMAI queue modification options */
149
150 /**
151  * Select to modify the user's context associated with the queue
152  */
153 #define DPDMAI_QUEUE_OPT_USER_CTX       0x00000001
154
155 /**
156  * Select to modify the queue's destination
157  */
158 #define DPDMAI_QUEUE_OPT_DEST           0x00000002
159
160 /**
161  * struct dpdmai_rx_queue_cfg - DPDMAI RX queue configuration
162  * @options: Flags representing the suggested modifications to the queue;
163  *      Use any combination of 'DPDMAI_QUEUE_OPT_<X>' flags
164  * @user_ctx: User context value provided in the frame descriptor of each
165  *      dequeued frame;
166  *      valid only if 'DPDMAI_QUEUE_OPT_USER_CTX' is contained in 'options'
167  * @dest_cfg: Queue destination parameters;
168  *      valid only if 'DPDMAI_QUEUE_OPT_DEST' is contained in 'options'
169  */
170 struct dpdmai_rx_queue_cfg {
171         uint32_t options;
172         uint64_t user_ctx;
173         struct dpdmai_dest_cfg dest_cfg;
174
175 };
176
177 __rte_internal
178 int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io,
179                         uint32_t cmd_flags,
180                         uint16_t token,
181                         uint8_t queue_idx,
182                         uint8_t priority,
183                         const struct dpdmai_rx_queue_cfg *cfg);
184
185 /**
186  * struct dpdmai_rx_queue_attr - Structure representing attributes of Rx queues
187  * @user_ctx:  User context value provided in the frame descriptor of each
188  *       dequeued frame
189  * @dest_cfg: Queue destination configuration
190  * @fqid: Virtual FQID value to be used for dequeue operations
191  */
192 struct dpdmai_rx_queue_attr {
193         uint64_t user_ctx;
194         struct dpdmai_dest_cfg dest_cfg;
195         uint32_t fqid;
196 };
197
198 __rte_internal
199 int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io,
200                         uint32_t cmd_flags,
201                         uint16_t token,
202                         uint8_t queue_idx,
203                         uint8_t priority,
204                         struct dpdmai_rx_queue_attr *attr);
205
206 /**
207  * struct dpdmai_tx_queue_attr - Structure representing attributes of Tx queues
208  * @fqid: Virtual FQID to be used for sending frames to DMA hardware
209  */
210
211 struct dpdmai_tx_queue_attr {
212         uint32_t fqid;
213 };
214
215 __rte_internal
216 int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io,
217                         uint32_t cmd_flags,
218                         uint16_t token,
219                         uint8_t queue_idx,
220                         uint8_t priority,
221                         struct dpdmai_tx_queue_attr *attr);
222
223 #endif /* __FSL_DPDMAI_H */