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