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