bus/fslmc: mark internal symbols
[dpdk.git] / drivers / bus / fslmc / mc / fsl_dpci.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2017-2019 NXP
5  *
6  */
7 #ifndef __FSL_DPCI_H
8 #define __FSL_DPCI_H
9
10 #include <fsl_dpopr.h>
11
12 /* Data Path Communication Interface API
13  * Contains initialization APIs and runtime control APIs for DPCI
14  */
15
16 struct fsl_mc_io;
17
18 /** General DPCI macros */
19
20 /**
21  * Maximum number of Tx/Rx priorities per DPCI object
22  */
23 #define DPCI_PRIO_NUM           4
24
25 /**
26  * Indicates an invalid frame queue
27  */
28 #define DPCI_FQID_NOT_VALID     (uint32_t)(-1)
29
30 /**
31  * All queues considered; see dpci_set_rx_queue()
32  */
33 #define DPCI_ALL_QUEUES         (uint8_t)(-1)
34
35 int dpci_open(struct fsl_mc_io *mc_io,
36               uint32_t cmd_flags,
37               int dpci_id,
38               uint16_t *token);
39
40 int dpci_close(struct fsl_mc_io *mc_io,
41                uint32_t cmd_flags,
42                uint16_t token);
43
44 /**
45  * Enable the Order Restoration support
46  */
47 #define DPCI_OPT_HAS_OPR                                        0x000040
48
49 /**
50  * Order Point Records are shared for the entire DPCI
51  */
52 #define DPCI_OPT_OPR_SHARED                                     0x000080
53
54 /**
55  * struct dpci_cfg - Structure representing DPCI configuration
56  * @options: Any combination of the following options:
57  *              DPCI_OPT_HAS_OPR
58  *              DPCI_OPT_OPR_SHARED
59  * @num_of_priorities:  Number of receive priorities (queues) for the DPCI;
60  *                      note, that the number of transmit priorities (queues)
61  *                      is determined by the number of receive priorities of
62  *                      the peer DPCI object
63  */
64 struct dpci_cfg {
65         uint32_t options;
66         uint8_t num_of_priorities;
67 };
68
69 int dpci_create(struct fsl_mc_io *mc_io,
70                 uint16_t dprc_token,
71                 uint32_t cmd_flags,
72                 const struct dpci_cfg *cfg,
73                 uint32_t *obj_id);
74
75 int dpci_destroy(struct fsl_mc_io *mc_io,
76                  uint16_t dprc_token,
77                  uint32_t cmd_flags,
78                  uint32_t object_id);
79
80 int dpci_enable(struct fsl_mc_io *mc_io,
81                 uint32_t cmd_flags,
82                 uint16_t token);
83
84 int dpci_disable(struct fsl_mc_io *mc_io,
85                  uint32_t cmd_flags,
86                  uint16_t token);
87
88 int dpci_is_enabled(struct fsl_mc_io *mc_io,
89                     uint32_t cmd_flags,
90                     uint16_t token,
91                     int *en);
92
93 int dpci_reset(struct fsl_mc_io *mc_io,
94                uint32_t cmd_flags,
95                uint16_t token);
96
97 /**
98  * struct dpci_attr - Structure representing DPCI attributes
99  * @id:                 DPCI object ID
100  * @num_of_priorities:  Number of receive priorities
101  */
102 struct dpci_attr {
103         int id;
104         uint8_t num_of_priorities;
105 };
106
107 int dpci_get_attributes(struct fsl_mc_io *mc_io,
108                         uint32_t cmd_flags,
109                         uint16_t token,
110                         struct dpci_attr *attr);
111
112 /**
113  * enum dpci_dest - DPCI destination types
114  * @DPCI_DEST_NONE:     Unassigned destination; The queue is set in parked mode
115  *                      and does not generate FQDAN notifications; user is
116  *                      expected to dequeue from the queue based on polling or
117  *                      other user-defined method
118  * @DPCI_DEST_DPIO:     The queue is set in schedule mode and generates FQDAN
119  *                      notifications to the specified DPIO; user is expected
120  *                      to dequeue from the queue only after notification is
121  *                      received
122  * @DPCI_DEST_DPCON:    The queue is set in schedule mode and does not generate
123  *                      FQDAN notifications, but is connected to the specified
124  *                      DPCON object;
125  *                      user is expected to dequeue from the DPCON channel
126  */
127 enum dpci_dest {
128         DPCI_DEST_NONE = 0,
129         DPCI_DEST_DPIO = 1,
130         DPCI_DEST_DPCON = 2
131 };
132
133 /**
134  * struct dpci_dest_cfg - Structure representing DPCI destination configuration
135  * @dest_type:  Destination type
136  * @dest_id:    Either DPIO ID or DPCON ID, depending on the destination type
137  * @priority:   Priority selection within the DPIO or DPCON channel; valid
138  *              values are 0-1 or 0-7, depending on the number of priorities
139  *              in that channel; not relevant for 'DPCI_DEST_NONE' option
140  */
141 struct dpci_dest_cfg {
142         enum dpci_dest dest_type;
143         int dest_id;
144         uint8_t priority;
145 };
146
147 /** DPCI queue modification options */
148
149 /**
150  * Select to modify the user's context associated with the queue
151  */
152 #define DPCI_QUEUE_OPT_USER_CTX         0x00000001
153
154 /**
155  * Select to modify the queue's destination
156  */
157 #define DPCI_QUEUE_OPT_DEST             0x00000002
158
159 /**
160  * Set the queue to hold active mode.
161  */
162 #define DPCI_QUEUE_OPT_HOLD_ACTIVE      0x00000004
163
164 /**
165  * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
166  * @options:    Flags representing the suggested modifications to the queue;
167  *              Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
168  * @user_ctx:   User context value provided in the frame descriptor of each
169  *              dequeued frame;
170  *              valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
171  *              'options'
172  * @dest_cfg:   Queue destination parameters;
173  *              valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
174  * @order_preservation_en: order preservation configuration for the rx queue
175  * valid only if 'DPCI_QUEUE_OPT_HOLD_ACTIVE' is contained in 'options'
176  */
177 struct dpci_rx_queue_cfg {
178         uint32_t options;
179         uint64_t user_ctx;
180         struct dpci_dest_cfg dest_cfg;
181         int order_preservation_en;
182 };
183
184 __rte_internal
185 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
186                       uint32_t cmd_flags,
187                       uint16_t token,
188                       uint8_t priority,
189                       const struct dpci_rx_queue_cfg *cfg);
190
191 /**
192  * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
193  * @user_ctx:   User context value provided in the frame descriptor of each
194  *              dequeued frame
195  * @dest_cfg:   Queue destination configuration
196  * @fqid:       Virtual FQID value to be used for dequeue operations
197  */
198 struct dpci_rx_queue_attr {
199         uint64_t user_ctx;
200         struct dpci_dest_cfg dest_cfg;
201         uint32_t fqid;
202 };
203
204 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
205                       uint32_t cmd_flags,
206                       uint16_t token,
207                       uint8_t priority,
208                       struct dpci_rx_queue_attr *attr);
209
210 /**
211  * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
212  * @fqid:       Virtual FQID to be used for sending frames to peer DPCI;
213  *              returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
214  *              the selected priority exceeds the number of priorities of the
215  *              peer DPCI object
216  */
217 struct dpci_tx_queue_attr {
218         uint32_t fqid;
219 };
220
221 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
222                       uint32_t cmd_flags,
223                       uint16_t token,
224                       uint8_t priority,
225                       struct dpci_tx_queue_attr *attr);
226
227 int dpci_get_api_version(struct fsl_mc_io *mc_io,
228                          uint32_t cmd_flags,
229                          uint16_t *major_ver,
230                          uint16_t *minor_ver);
231
232 __rte_internal
233 int dpci_set_opr(struct fsl_mc_io *mc_io,
234                  uint32_t cmd_flags,
235                  uint16_t token,
236                  uint8_t index,
237                  uint8_t options,
238                  struct opr_cfg *cfg);
239
240 __rte_internal
241 int dpci_get_opr(struct fsl_mc_io *mc_io,
242                  uint32_t cmd_flags,
243                  uint16_t token,
244                  uint8_t index,
245                  struct opr_cfg *cfg,
246                  struct opr_qry *qry);
247
248 #endif /* __FSL_DPCI_H */