xref: /openbmc/u-boot/include/fsl-mc/fsl_dpni.h (revision 089fddfd)
1 /*
2  * Copyright (C) 2013-2015 Freescale Semiconductor
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 #ifndef _FSL_DPNI_H
7 #define _FSL_DPNI_H
8 
9 /* DPNI Version */
10 #define DPNI_VER_MAJOR				5
11 #define DPNI_VER_MINOR				0
12 
13 /* Command IDs */
14 #define DPNI_CMDID_OPEN				0x801
15 #define DPNI_CMDID_CLOSE			0x800
16 
17 #define DPNI_CMDID_ENABLE			0x002
18 #define DPNI_CMDID_DISABLE			0x003
19 #define DPNI_CMDID_GET_ATTR			0x004
20 #define DPNI_CMDID_RESET			0x005
21 
22 #define DPNI_CMDID_SET_POOLS			0x200
23 #define DPNI_CMDID_GET_RX_BUFFER_LAYOUT		0x201
24 #define DPNI_CMDID_SET_RX_BUFFER_LAYOUT		0x202
25 #define DPNI_CMDID_GET_TX_BUFFER_LAYOUT		0x203
26 #define DPNI_CMDID_SET_TX_BUFFER_LAYOUT		0x204
27 #define DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT	0x205
28 #define DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT	0x206
29 
30 #define DPNI_CMDID_GET_QDID			0x210
31 #define DPNI_CMDID_GET_TX_DATA_OFFSET		0x212
32 #define DPNI_CMDID_GET_COUNTER			0x213
33 #define DPNI_CMDID_SET_COUNTER			0x214
34 #define DPNI_CMDID_GET_LINK_STATE		0x215
35 #define DPNI_CMDID_SET_LINK_CFG		0x21A
36 
37 #define DPNI_CMDID_SET_PRIM_MAC			0x224
38 #define DPNI_CMDID_GET_PRIM_MAC			0x225
39 #define DPNI_CMDID_ADD_MAC_ADDR			0x226
40 #define DPNI_CMDID_REMOVE_MAC_ADDR		0x227
41 
42 #define DPNI_CMDID_SET_TX_FLOW			0x236
43 #define DPNI_CMDID_GET_TX_FLOW			0x237
44 #define DPNI_CMDID_SET_RX_FLOW			0x238
45 #define DPNI_CMDID_GET_RX_FLOW			0x239
46 
47 /*                cmd, param, offset, width, type, arg_name */
48 #define DPNI_CMD_OPEN(cmd, dpni_id) \
49 	MC_CMD_OP(cmd,	 0,	0,	32,	int,	dpni_id)
50 
51 
52 /*                cmd, param, offset, width, type, arg_name */
53 #define DPNI_CMD_SET_POOLS(cmd, cfg) \
54 do { \
55 	MC_CMD_OP(cmd, 0, 0,  8,  uint8_t,  cfg->num_dpbp); \
56 	MC_CMD_OP(cmd, 0, 32, 32, int,      cfg->pools[0].dpbp_id); \
57 	MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
58 	MC_CMD_OP(cmd, 1, 0,  32, int,      cfg->pools[1].dpbp_id); \
59 	MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
60 	MC_CMD_OP(cmd, 1, 32, 32, int,      cfg->pools[2].dpbp_id); \
61 	MC_CMD_OP(cmd, 5, 0,  16, uint16_t, cfg->pools[2].buffer_size);\
62 	MC_CMD_OP(cmd, 2, 0,  32, int,      cfg->pools[3].dpbp_id); \
63 	MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
64 	MC_CMD_OP(cmd, 2, 32, 32, int,      cfg->pools[4].dpbp_id); \
65 	MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
66 	MC_CMD_OP(cmd, 3, 0,  32, int,      cfg->pools[5].dpbp_id); \
67 	MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
68 	MC_CMD_OP(cmd, 3, 32, 32, int,      cfg->pools[6].dpbp_id); \
69 	MC_CMD_OP(cmd, 6, 0,  16, uint16_t, cfg->pools[6].buffer_size);\
70 	MC_CMD_OP(cmd, 4, 0,  32, int,      cfg->pools[7].dpbp_id); \
71 	MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
72 } while (0)
73 
74 /*                cmd, param, offset, width, type, arg_name */
75 #define DPNI_RSP_GET_ATTR(cmd, attr) \
76 do { \
77 	MC_RSP_OP(cmd, 0, 0,  32, int,	    attr->id);\
78 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  attr->max_tcs); \
79 	MC_RSP_OP(cmd, 0, 40, 8,  uint8_t,  attr->max_senders); \
80 	MC_RSP_OP(cmd, 0, 48, 8,  enum net_prot, attr->start_hdr); \
81 	MC_RSP_OP(cmd, 1, 0,  32, uint32_t, attr->options); \
82 	MC_RSP_OP(cmd, 2, 0,  8,  uint8_t,  attr->max_unicast_filters); \
83 	MC_RSP_OP(cmd, 2, 8,  8,  uint8_t,  attr->max_multicast_filters);\
84 	MC_RSP_OP(cmd, 2, 16, 8,  uint8_t,  attr->max_vlan_filters); \
85 	MC_RSP_OP(cmd, 2, 24, 8,  uint8_t,  attr->max_qos_entries); \
86 	MC_RSP_OP(cmd, 2, 32, 8,  uint8_t,  attr->max_qos_key_size); \
87 	MC_RSP_OP(cmd, 2, 40, 8,  uint8_t,  attr->max_dist_key_size); \
88 	MC_RSP_OP(cmd, 3, 0,  8,  uint8_t,  attr->max_dist_per_tc[0]); \
89 	MC_RSP_OP(cmd, 3, 8,  8,  uint8_t,  attr->max_dist_per_tc[1]); \
90 	MC_RSP_OP(cmd, 3, 16, 8,  uint8_t,  attr->max_dist_per_tc[2]); \
91 	MC_RSP_OP(cmd, 3, 24, 8,  uint8_t,  attr->max_dist_per_tc[3]); \
92 	MC_RSP_OP(cmd, 3, 32, 8,  uint8_t,  attr->max_dist_per_tc[4]); \
93 	MC_RSP_OP(cmd, 3, 40, 8,  uint8_t,  attr->max_dist_per_tc[5]); \
94 	MC_RSP_OP(cmd, 3, 48, 8,  uint8_t,  attr->max_dist_per_tc[6]); \
95 	MC_RSP_OP(cmd, 3, 56, 8,  uint8_t,  attr->max_dist_per_tc[7]); \
96 	MC_RSP_OP(cmd, 4, 0,	16, uint16_t, \
97 				    attr->ipr_cfg.max_reass_frm_size); \
98 	MC_RSP_OP(cmd, 4, 16,	16, uint16_t, \
99 				    attr->ipr_cfg.min_frag_size_ipv4); \
100 	MC_RSP_OP(cmd, 4, 32,	16, uint16_t, \
101 				    attr->ipr_cfg.min_frag_size_ipv6);\
102 	MC_RSP_OP(cmd, 4, 48,	8,  uint8_t, attr->max_policers); \
103 	MC_RSP_OP(cmd, 4, 56,	8,  uint8_t, attr->max_congestion_ctrl); \
104 	MC_RSP_OP(cmd, 5, 0,	16, uint16_t, \
105 				  attr->ipr_cfg.max_open_frames_ipv4); \
106 	MC_RSP_OP(cmd, 5, 16,	16, uint16_t, \
107 				  attr->ipr_cfg.max_open_frames_ipv6); \
108 	MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\
109 	MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\
110 } while (0)
111 
112 /*                cmd, param, offset, width, type, arg_name */
113 #define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \
114 do { \
115 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
116 	MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
117 	MC_RSP_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
118 	MC_RSP_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
119 	MC_RSP_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
120 	MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
121 	MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
122 } while (0)
123 
124 /*                cmd, param, offset, width, type, arg_name */
125 #define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \
126 do { \
127 	MC_CMD_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
128 	MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
129 	MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
130 	MC_CMD_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
131 	MC_CMD_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
132 	MC_CMD_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
133 	MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
134 	MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
135 } while (0)
136 
137 /*                cmd, param, offset, width, type, arg_name */
138 #define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \
139 do { \
140 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
141 	MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
142 	MC_RSP_OP(cmd, 1, 0,  1,  int,      layout->pass_timestamp); \
143 	MC_RSP_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
144 	MC_RSP_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
145 	MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
146 	MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
147 } while (0)
148 
149 /*                cmd, param, offset, width, type, arg_name */
150 #define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \
151 do { \
152 	MC_CMD_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
153 	MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
154 	MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
155 	MC_CMD_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
156 	MC_CMD_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
157 	MC_CMD_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
158 	MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
159 	MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
160 } while (0)
161 
162 /*                cmd, param, offset, width, type, arg_name */
163 #define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
164 do { \
165 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
166 	MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
167 	MC_RSP_OP(cmd, 1, 0,  1,  int,      layout->pass_timestamp); \
168 	MC_RSP_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
169 	MC_RSP_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
170 	MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
171 	MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
172 } while (0)
173 
174 /*                cmd, param, offset, width, type, arg_name */
175 #define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
176 do { \
177 	MC_CMD_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
178 	MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
179 	MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
180 	MC_CMD_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
181 	MC_CMD_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
182 	MC_CMD_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
183 	MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
184 	MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
185 } while (0)
186 
187 /*                cmd, param, offset, width, type, arg_name */
188 #define DPNI_RSP_GET_QDID(cmd, qdid) \
189 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, qdid)
190 
191 /*                cmd, param, offset, width, type, arg_name */
192 #define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
193 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, data_offset)
194 
195 /*                cmd, param, offset, width, type, arg_name */
196 #define DPNI_CMD_GET_COUNTER(cmd, counter) \
197 	MC_CMD_OP(cmd, 0, 0,  16, enum dpni_counter, counter)
198 
199 /*                cmd, param, offset, width, type, arg_name */
200 #define DPNI_RSP_GET_COUNTER(cmd, value) \
201 	MC_RSP_OP(cmd, 1, 0,  64, uint64_t, value)
202 
203 /*                cmd, param, offset, width, type, arg_name */
204 #define DPNI_CMD_SET_COUNTER(cmd, counter, value) \
205 do { \
206 	MC_CMD_OP(cmd, 0, 0,  16, enum dpni_counter, counter); \
207 	MC_CMD_OP(cmd, 1, 0,  64, uint64_t, value); \
208 } while (0)
209 
210 /*                cmd, param, offset, width, type, arg_name */
211 #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
212 do { \
213 	MC_CMD_OP(cmd, 1, 0,  32, uint32_t, cfg->rate);\
214 	MC_CMD_OP(cmd, 2, 0,  64, uint64_t, cfg->options);\
215 } while (0)
216 
217 /*                cmd, param, offset, width, type, arg_name */
218 #define DPNI_RSP_GET_LINK_STATE(cmd, state) \
219 do { \
220 	MC_RSP_OP(cmd, 0, 32,  1, int,      state->up);\
221 	MC_RSP_OP(cmd, 1, 0,  32, uint32_t, state->rate);\
222 	MC_RSP_OP(cmd, 2, 0,  64, uint64_t, state->options);\
223 } while (0)
224 
225 
226 
227 /*                cmd, param, offset, width, type, arg_name */
228 #define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
229 do { \
230 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
231 	MC_CMD_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
232 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
233 	MC_CMD_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
234 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
235 	MC_CMD_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
236 } while (0)
237 
238 /*                cmd, param, offset, width, type, arg_name */
239 #define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
240 do { \
241 	MC_RSP_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
242 	MC_RSP_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
243 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
244 	MC_RSP_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
245 	MC_RSP_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
246 	MC_RSP_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
247 } while (0)
248 
249 /*                cmd, param, offset, width, type, arg_name */
250 #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
251 do { \
252 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
253 	MC_CMD_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
254 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
255 	MC_CMD_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
256 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
257 	MC_CMD_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
258 } while (0)
259 
260 /*                cmd, param, offset, width, type, arg_name */
261 #define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
262 do { \
263 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
264 	MC_CMD_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
265 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
266 	MC_CMD_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
267 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
268 	MC_CMD_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
269 } while (0)
270 
271 /*                cmd, param, offset, width, type, arg_name */
272 #define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \
273 do { \
274 	MC_CMD_OP(cmd, 0, 0,  32, int,     \
275 			   cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_id);\
276 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t, \
277 			   cfg->conf_err_cfg.queue_cfg.dest_cfg.priority);\
278 	MC_CMD_OP(cmd, 0, 40, 2,  enum dpni_dest, \
279 			   cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_type);\
280 	MC_CMD_OP(cmd, 0, 42, 1,  int,	    cfg->conf_err_cfg.errors_only);\
281 	MC_CMD_OP(cmd, 0, 43, 1,  int,	    cfg->l3_chksum_gen);\
282 	MC_CMD_OP(cmd, 0, 44, 1,  int,	    cfg->l4_chksum_gen);\
283 	MC_CMD_OP(cmd, 0, 45, 1,  int,	    \
284 			   cfg->conf_err_cfg.use_default_queue);\
285 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\
286 	MC_CMD_OP(cmd, 1, 0,  64, uint64_t, \
287 			   cfg->conf_err_cfg.queue_cfg.user_ctx);\
288 	MC_CMD_OP(cmd, 2, 0,  32, uint32_t, cfg->options);\
289 	MC_CMD_OP(cmd, 2, 32,  32, uint32_t, \
290 			   cfg->conf_err_cfg.queue_cfg.options);\
291 } while (0)
292 
293 /*                cmd, param, offset, width, type, arg_name */
294 #define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \
295 	MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id)
296 
297 /*                cmd, param, offset, width, type, arg_name */
298 #define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \
299 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
300 
301 /*                cmd, param, offset, width, type, arg_name */
302 #define DPNI_RSP_GET_TX_FLOW(cmd, attr) \
303 do { \
304 	MC_RSP_OP(cmd, 0, 0,  32, int,      \
305 			attr->conf_err_attr.queue_attr.dest_cfg.dest_id);\
306 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  \
307 			attr->conf_err_attr.queue_attr.dest_cfg.priority);\
308 	MC_RSP_OP(cmd, 0, 40, 2,  enum dpni_dest, \
309 			attr->conf_err_attr.queue_attr.dest_cfg.dest_type);\
310 	MC_RSP_OP(cmd, 0, 42, 1,  int,	    attr->conf_err_attr.errors_only);\
311 	MC_RSP_OP(cmd, 0, 43, 1,  int,	    attr->l3_chksum_gen);\
312 	MC_RSP_OP(cmd, 0, 44, 1,  int,	    attr->l4_chksum_gen);\
313 	MC_RSP_OP(cmd, 0, 45, 1,  int,	    \
314 			attr->conf_err_attr.use_default_queue);\
315 	MC_RSP_OP(cmd, 1, 0,  64, uint64_t, \
316 			attr->conf_err_attr.queue_attr.user_ctx);\
317 	MC_RSP_OP(cmd, 2, 32, 32, uint32_t, \
318 			attr->conf_err_attr.queue_attr.fqid);\
319 } while (0)
320 
321 /*                cmd, param, offset, width, type, arg_name */
322 #define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \
323 do { \
324 	MC_CMD_OP(cmd, 0, 0,  32, int,      cfg->dest_cfg.dest_id); \
325 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  cfg->dest_cfg.priority);\
326 	MC_CMD_OP(cmd, 0, 40, 2,  enum dpni_dest, cfg->dest_cfg.dest_type);\
327 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
328 	MC_CMD_OP(cmd, 1, 0,  64, uint64_t, cfg->user_ctx); \
329 	MC_CMD_OP(cmd, 2, 16, 8,  uint8_t,  tc_id); \
330 	MC_CMD_OP(cmd, 2, 32,  32, uint32_t, cfg->options); \
331 	MC_CMD_OP(cmd, 3, 0,  4,  enum dpni_flc_type, cfg->flc_cfg.flc_type); \
332 	MC_CMD_OP(cmd, 3, 4,  4,  enum dpni_stash_size, \
333 		cfg->flc_cfg.frame_data_size);\
334 	MC_CMD_OP(cmd, 3, 8,  4,  enum dpni_stash_size, \
335 		cfg->flc_cfg.flow_context_size);\
336 	MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
337 	MC_CMD_OP(cmd, 4, 0,  64, uint64_t, cfg->flc_cfg.flow_context);\
338 } while (0)
339 
340 /*                cmd, param, offset, width, type, arg_name */
341 #define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
342 do { \
343 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  tc_id); \
344 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
345 } while (0)
346 
347 /*                cmd, param, offset, width, type, arg_name */
348 #define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
349 do { \
350 	MC_RSP_OP(cmd, 0, 0,  32, int,      attr->dest_cfg.dest_id); \
351 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  attr->dest_cfg.priority);\
352 	MC_RSP_OP(cmd, 0, 40, 2,  enum dpni_dest, attr->dest_cfg.dest_type); \
353 	MC_RSP_OP(cmd, 1, 0,  64, uint64_t, attr->user_ctx); \
354 	MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
355 	MC_RSP_OP(cmd, 3, 0,  4,  enum dpni_flc_type, attr->flc_cfg.flc_type); \
356 	MC_RSP_OP(cmd, 3, 4,  4,  enum dpni_stash_size, \
357 		attr->flc_cfg.frame_data_size);\
358 	MC_RSP_OP(cmd, 3, 8,  4,  enum dpni_stash_size, \
359 		attr->flc_cfg.flow_context_size);\
360 	MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
361 	MC_RSP_OP(cmd, 4, 0,  64, uint64_t, attr->flc_cfg.flow_context);\
362 } while (0)
363 
364 enum net_prot {
365 	NET_PROT_NONE = 0,
366 	NET_PROT_PAYLOAD,
367 	NET_PROT_ETH,
368 	NET_PROT_VLAN,
369 	NET_PROT_IPV4,
370 	NET_PROT_IPV6,
371 	NET_PROT_IP,
372 	NET_PROT_TCP,
373 	NET_PROT_UDP,
374 	NET_PROT_UDP_LITE,
375 	NET_PROT_IPHC,
376 	NET_PROT_SCTP,
377 	NET_PROT_SCTP_CHUNK_DATA,
378 	NET_PROT_PPPOE,
379 	NET_PROT_PPP,
380 	NET_PROT_PPPMUX,
381 	NET_PROT_PPPMUX_SUBFRM,
382 	NET_PROT_L2TPV2,
383 	NET_PROT_L2TPV3_CTRL,
384 	NET_PROT_L2TPV3_SESS,
385 	NET_PROT_LLC,
386 	NET_PROT_LLC_SNAP,
387 	NET_PROT_NLPID,
388 	NET_PROT_SNAP,
389 	NET_PROT_MPLS,
390 	NET_PROT_IPSEC_AH,
391 	NET_PROT_IPSEC_ESP,
392 	NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
393 	NET_PROT_MACSEC,
394 	NET_PROT_GRE,
395 	NET_PROT_MINENCAP,
396 	NET_PROT_DCCP,
397 	NET_PROT_ICMP,
398 	NET_PROT_IGMP,
399 	NET_PROT_ARP,
400 	NET_PROT_CAPWAP_DATA,
401 	NET_PROT_CAPWAP_CTRL,
402 	NET_PROT_RFC2684,
403 	NET_PROT_ICMPV6,
404 	NET_PROT_FCOE,
405 	NET_PROT_FIP,
406 	NET_PROT_ISCSI,
407 	NET_PROT_GTP,
408 	NET_PROT_USER_DEFINED_L2,
409 	NET_PROT_USER_DEFINED_L3,
410 	NET_PROT_USER_DEFINED_L4,
411 	NET_PROT_USER_DEFINED_L5,
412 	NET_PROT_USER_DEFINED_SHIM1,
413 	NET_PROT_USER_DEFINED_SHIM2,
414 
415 	NET_PROT_DUMMY_LAST
416 };
417 
418 /**
419  * Data Path Network Interface API
420  * Contains initialization APIs and runtime control APIs for DPNI
421  */
422 
423 struct fsl_mc_io;
424 
425 /* General DPNI macros */
426 
427 /* Maximum number of traffic classes */
428 #define DPNI_MAX_TC				8
429 /* Maximum number of buffer pools per DPNI */
430 #define DPNI_MAX_DPBP				8
431 
432 /* All traffic classes considered; see dpni_set_rx_flow() */
433 #define DPNI_ALL_TCS				(uint8_t)(-1)
434 /* All flows within traffic class considered; see dpni_set_rx_flow() */
435 #define DPNI_ALL_TC_FLOWS			(uint16_t)(-1)
436 /* Generate new flow ID; see dpni_set_tx_flow() */
437 #define DPNI_NEW_FLOW_ID			(uint16_t)(-1)
438 
439 /**
440  * dpni_open() - Open a control session for the specified object
441  * @mc_io:	Pointer to MC portal's I/O object
442  * @dpni_id:	DPNI unique ID
443  * @token:	Returned token; use in subsequent API calls
444  *
445  * This function can be used to open a control session for an
446  * already created object; an object may have been declared in
447  * the DPL or by calling the dpni_create() function.
448  * This function returns a unique authentication token,
449  * associated with the specific object ID and the specific MC
450  * portal; this token must be used in all subsequent commands for
451  * this specific object.
452  *
453  * Return:	'0' on Success; Error code otherwise.
454  */
455 int dpni_open(struct fsl_mc_io *mc_io, int dpni_id, uint16_t *token);
456 
457 /**
458  * dpni_close() - Close the control session of the object
459  * @mc_io:	Pointer to MC portal's I/O object
460  * @token:	Token of DPNI object
461  *
462  * After this function is called, no further operations are
463  * allowed on the object without opening a new control session.
464  *
465  * Return:	'0' on Success; Error code otherwise.
466  */
467 int dpni_close(struct fsl_mc_io *mc_io, uint16_t token);
468 
469 /**
470  * struct dpni_ipr_cfg - Structure representing IP reassembly configuration
471  * @max_reass_frm_size: Maximum size of the reassembled frame
472  * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
473  * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
474  * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly process
475  * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly process
476  */
477 struct dpni_ipr_cfg {
478 	uint16_t max_reass_frm_size;
479 	uint16_t min_frag_size_ipv4;
480 	uint16_t min_frag_size_ipv6;
481 	uint16_t max_open_frames_ipv4;
482 	uint16_t max_open_frames_ipv6;
483 };
484 
485 /**
486  * struct dpni_pools_cfg - Structure representing buffer pools configuration
487  * @num_dpbp: Number of DPBPs
488  * @pools: Array of buffer pools parameters; The number of valid entries
489  *	must match 'num_dpbp' value
490  */
491 struct dpni_pools_cfg {
492 	uint8_t num_dpbp;
493 	/**
494 	 * struct pools - Buffer pools parameters
495 	 * @dpbp_id: DPBP object ID
496 	 * @buffer_size: Buffer size
497 	 */
498 	struct {
499 		int dpbp_id;
500 		uint16_t buffer_size;
501 	} pools[DPNI_MAX_DPBP];
502 };
503 
504 /**
505  * dpni_set_pools() - Set buffer pools configuration
506  * @mc_io:	Pointer to MC portal's I/O object
507  * @token:	Token of DPNI object
508  * @cfg:	Buffer pools configuration
509  *
510  * mandatory for DPNI operation
511  * warning:Allowed only when DPNI is disabled
512  *
513  * Return:	'0' on Success; Error code otherwise.
514  */
515 int dpni_set_pools(struct fsl_mc_io		*mc_io,
516 		   uint16_t			token,
517 		   const struct dpni_pools_cfg	*cfg);
518 
519 /**
520  * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
521  * @mc_io:		Pointer to MC portal's I/O object
522  * @token:		Token of DPNI object
523  *
524  * Return:	'0' on Success; Error code otherwise.
525  */
526 int dpni_enable(struct fsl_mc_io *mc_io, uint16_t token);
527 
528 /**
529  * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
530  * @mc_io:	Pointer to MC portal's I/O object
531  * @token:	Token of DPNI object
532  *
533  * Return:	'0' on Success; Error code otherwise.
534  */
535 int dpni_disable(struct fsl_mc_io *mc_io, uint16_t token);
536 
537 
538 /**
539  * @dpni_reset() - Reset the DPNI, returns the object to initial state.
540  * @mc_io:	Pointer to MC portal's I/O object
541  * @token:	Token of DPNI object
542  *
543  * Return:	'0' on Success; Error code otherwise.
544  */
545 int dpni_reset(struct fsl_mc_io *mc_io, uint16_t token);
546 
547 /**
548  * struct dpni_attr - Structure representing DPNI attributes
549  * @id: DPNI object ID
550  * @version: DPNI version
551  * @start_hdr: Indicates the packet starting header for parsing
552  * @options: Mask of available options; reflects the value as was given in
553  *		object's creation
554  * @max_senders: Maximum number of different senders; used as the number
555  *		of dedicated Tx flows;
556  * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
557  * @max_dist_per_tc: Maximum distribution size per Rx traffic class;
558  *			Set to the required value minus 1
559  * @max_unicast_filters: Maximum number of unicast filters
560  * @max_multicast_filters: Maximum number of multicast filters
561  * @max_vlan_filters: Maximum number of VLAN filters
562  * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
563  * @max_qos_key_size: Maximum key size for the QoS look-up
564  * @max_dist_key_size: Maximum key size for the distribution look-up
565  * @max_policers: Maximum number of policers;
566  * @max_congestion_ctrl: Maximum number of congestion control groups (CGs);
567  * @ipr_cfg: IP reassembly configuration
568  */
569 struct dpni_attr {
570 	int id;
571 	/**
572 	 * struct version - DPNI version
573 	 * @major: DPNI major version
574 	 * @minor: DPNI minor version
575 	 */
576 	struct {
577 		uint16_t major;
578 		uint16_t minor;
579 	} version;
580 	enum net_prot start_hdr;
581 	uint32_t options;
582 	uint8_t max_senders;
583 	uint8_t max_tcs;
584 	uint8_t max_dist_per_tc[DPNI_MAX_TC];
585 	uint8_t max_unicast_filters;
586 	uint8_t max_multicast_filters;
587 	uint8_t max_vlan_filters;
588 	uint8_t max_qos_entries;
589 	uint8_t max_qos_key_size;
590 	uint8_t max_dist_key_size;
591 	uint8_t max_policers;
592 	uint8_t max_congestion_ctrl;
593 	struct dpni_ipr_cfg ipr_cfg;
594 };
595 
596 /**
597  * dpni_get_attributes() - Retrieve DPNI attributes.
598  * @mc_io:	Pointer to MC portal's I/O objec
599  * @token:	Token of DPNI object
600  * @attr:	Returned object's attributes
601  *
602  * Return:	'0' on Success; Error code otherwise.
603  */
604 int dpni_get_attributes(struct fsl_mc_io	*mc_io,
605 			uint16_t		token,
606 			struct dpni_attr	*attr);
607 
608 /* DPNI buffer layout modification options */
609 
610 /* Select to modify the time-stamp setting */
611 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
612 /* Select to modify the parser-result setting; not applicable for Tx */
613 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
614 /* Select to modify the frame-status setting */
615 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
616 /* Select to modify the private-data-size setting */
617 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
618 /* Select to modify the data-alignment setting */
619 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
620 /* Select to modify the data-head-room setting */
621 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
622 /*!< Select to modify the data-tail-room setting */
623 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
624 
625 /**
626  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
627  * @options: Flags representing the suggested modifications to the buffer
628  *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
629  * @pass_timestamp: Pass timestamp value
630  * @pass_parser_result: Pass parser results
631  * @pass_frame_status: Pass frame status
632  * @private_data_size: Size kept for private data (in bytes)
633  * @data_align: Data alignment
634  * @data_head_room: Data head room
635  * @data_tail_room: Data tail room
636  */
637 struct dpni_buffer_layout {
638 	uint32_t options;
639 	int pass_timestamp;
640 	int pass_parser_result;
641 	int pass_frame_status;
642 	uint16_t private_data_size;
643 	uint16_t data_align;
644 	uint16_t data_head_room;
645 	uint16_t data_tail_room;
646 };
647 
648 /**
649  * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
650  * @mc_io:	Pointer to MC portal's I/O object
651  * @token:	Token of DPNI object
652  * @layout:	Returns buffer layout attributes
653  *
654  * Return:	'0' on Success; Error code otherwise.
655  */
656 int dpni_get_rx_buffer_layout(struct fsl_mc_io		*mc_io,
657 			      uint16_t			token,
658 			      struct dpni_buffer_layout	*layout);
659 
660 /**
661  * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration.
662  * @mc_io:	Pointer to MC portal's I/O object
663  * @token:	Token of DPNI object
664  * @layout:	Buffer layout configuration
665  *
666  * Return:	'0' on Success; Error code otherwise.
667  *
668  * @warning	Allowed only when DPNI is disabled
669  */
670 int dpni_set_rx_buffer_layout(struct fsl_mc_io			*mc_io,
671 			      uint16_t				token,
672 			      const struct dpni_buffer_layout	*layout);
673 
674 /**
675  * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
676  * @mc_io:	Pointer to MC portal's I/O object
677  * @token:	Token of DPNI object
678  * @layout:	Returns buffer layout attributes
679  *
680  * Return:	'0' on Success; Error code otherwise.
681  */
682 int dpni_get_tx_buffer_layout(struct fsl_mc_io		*mc_io,
683 			      uint16_t			token,
684 			      struct dpni_buffer_layout	*layout);
685 
686 /**
687  * dpni_set_tx_buffer_layout() - Set Tx buffer layout configuration.
688  * @mc_io:	Pointer to MC portal's I/O object
689  * @token:	Token of DPNI object
690  * @layout:	Buffer layout configuration
691  *
692  * Return:	'0' on Success; Error code otherwise.
693  *
694  * @warning	Allowed only when DPNI is disabled
695  */
696 int dpni_set_tx_buffer_layout(struct fsl_mc_io			*mc_io,
697 			      uint16_t				token,
698 			      const struct dpni_buffer_layout	*layout);
699 
700 /**
701  * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
702  *				attributes.
703  * @mc_io:	Pointer to MC portal's I/O object
704  * @token:	Token of DPNI object
705  * @layout:	Returns buffer layout attributes
706  *
707  * Return:	'0' on Success; Error code otherwise.
708  */
709 int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io		*mc_io,
710 				   uint16_t			token,
711 				   struct dpni_buffer_layout	*layout);
712 
713 /**
714  * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
715  *					configuration.
716  * @mc_io:	Pointer to MC portal's I/O object
717  * @token:	Token of DPNI object
718  * @layout:	Buffer layout configuration
719  *
720  * Return:	'0' on Success; Error code otherwise.
721  *
722  * @warning	Allowed only when DPNI is disabled
723  */
724 int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io		   *mc_io,
725 				   uint16_t			   token,
726 				   const struct dpni_buffer_layout *layout);
727 
728 /**
729  * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
730  *			for enqueue operations
731  * @mc_io:	Pointer to MC portal's I/O object
732  * @token:	Token of DPNI object
733  * @qdid:	Returned virtual QDID value that should be used as an argument
734  *			in all enqueue operations
735  *
736  * Return:	'0' on Success; Error code otherwise.
737  */
738 int dpni_get_qdid(struct fsl_mc_io *mc_io, uint16_t token, uint16_t *qdid);
739 
740 /**
741  * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
742  * @mc_io:	Pointer to MC portal's I/O object
743  * @token:	Token of DPNI object
744  * @data_offset: Tx data offset (from start of buffer)
745  *
746  * Return:	'0' on Success; Error code otherwise.
747  */
748 int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
749 			    uint16_t		token,
750 			    uint16_t		*data_offset);
751 
752 /**
753  * enum dpni_counter - DPNI counter types
754  * @DPNI_CNT_ING_FRAME: Counts ingress frames
755  * @DPNI_CNT_ING_BYTE: Counts ingress bytes
756  * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
757  *		'drop' setting
758  * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
759  * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
760  * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
761  * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
762  * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
763  * @DPNI_CNT_EGR_FRAME: Counts egress frames
764  * @DPNI_CNT_EGR_BYTE: Counts egress bytes
765  * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
766  */
767 enum dpni_counter {
768 	DPNI_CNT_ING_FRAME = 0x0,
769 	DPNI_CNT_ING_BYTE = 0x1,
770 	DPNI_CNT_ING_FRAME_DROP = 0x2,
771 	DPNI_CNT_ING_FRAME_DISCARD = 0x3,
772 	DPNI_CNT_ING_MCAST_FRAME = 0x4,
773 	DPNI_CNT_ING_MCAST_BYTE = 0x5,
774 	DPNI_CNT_ING_BCAST_FRAME = 0x6,
775 	DPNI_CNT_ING_BCAST_BYTES = 0x7,
776 	DPNI_CNT_EGR_FRAME = 0x8,
777 	DPNI_CNT_EGR_BYTE = 0x9,
778 	DPNI_CNT_EGR_FRAME_DISCARD = 0xa
779 };
780 
781 /**
782  * dpni_get_counter() - Read a specific DPNI counter
783  * @mc_io:	Pointer to MC portal's I/O object
784  * @token:	Token of DPNI object
785  * @counter:	The requested counter
786  * @value:	Returned counter's current value
787  *
788  * Return:	'0' on Success; Error code otherwise.
789  */
790 int dpni_get_counter(struct fsl_mc_io	*mc_io,
791 		     uint16_t		token,
792 		     enum dpni_counter	counter,
793 		     uint64_t		*value);
794 
795 /**
796  * dpni_set_counter() - Set (or clear) a specific DPNI counter
797  * @mc_io:	Pointer to MC portal's I/O object
798  * @token:	Token of DPNI object
799  * @counter:	The requested counter
800  * @value:	New counter value; typically pass '0' for resetting
801  *			the counter.
802  *
803  * Return:	'0' on Success; Error code otherwise.
804  */
805 int dpni_set_counter(struct fsl_mc_io	*mc_io,
806 		     uint16_t		token,
807 		     enum dpni_counter	counter,
808 		     uint64_t		value);
809 
810 /* Enable auto-negotiation */
811 #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
812 /* Enable half-duplex mode */
813 #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
814 /* Enable pause frames */
815 #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
816 /* Enable a-symmetric pause frames */
817 #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
818 
819 /**
820  * struct - Structure representing DPNI link configuration
821  * @rate: Rate
822  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
823  */
824 struct dpni_link_cfg {
825 	uint32_t rate;
826 	uint64_t options;
827 };
828 
829 /**
830  * dpni_set_link_cfg() - set the link configuration.
831  * @mc_io:	Pointer to MC portal's I/O object
832  * @token:	Token of DPNI object
833  * @cfg:	Link configuration
834  *
835  * Return:	'0' on Success; Error code otherwise.
836  */
837 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
838 		      uint16_t token,
839 		      const struct dpni_link_cfg *cfg);
840 
841 /**
842  * struct dpni_link_state - Structure representing DPNI link state
843  * @rate: Rate
844  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
845  * @up: Link state; '0' for down, '1' for up
846  */
847 struct dpni_link_state {
848 	uint32_t rate;
849 	uint64_t options;
850 	int up;
851 };
852 
853 /**
854  * dpni_get_link_state() - Return the link state (either up or down)
855  * @mc_io:	Pointer to MC portal's I/O object
856  * @token:	Token of DPNI object
857  * @state:	Returned link state;
858  *
859  * Return:	'0' on Success; Error code otherwise.
860  */
861 int dpni_get_link_state(struct fsl_mc_io *mc_io,
862 			uint16_t token,
863 			struct dpni_link_state *state);
864 
865 /**
866  * dpni_set_primary_mac_addr() - Set the primary MAC address
867  * @mc_io:	Pointer to MC portal's I/O object
868  * @token:	Token of DPNI object
869  * @mac_addr:	MAC address to set as primary address
870  *
871  * Return:	'0' on Success; Error code otherwise.
872  */
873 int dpni_set_primary_mac_addr(struct fsl_mc_io	*mc_io,
874 			      uint16_t		token,
875 			      const uint8_t	mac_addr[6]);
876 
877 /**
878  * dpni_get_primary_mac_addr() - Get the primary MAC address
879  * @mc_io:	Pointer to MC portal's I/O object
880  * @token:	Token of DPNI object
881  * @mac_addr:	Returned MAC address
882  *
883  * Return:	'0' on Success; Error code otherwise.
884  */
885 int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
886 			      uint16_t		token,
887 			      uint8_t		mac_addr[6]);
888 
889 /**
890  * dpni_add_mac_addr() - Add MAC address filter
891  * @mc_io:	Pointer to MC portal's I/O object
892  * @token:	Token of DPNI object
893  * @mac_addr:	MAC address to add
894  *
895  * Return:	'0' on Success; Error code otherwise.
896  */
897 int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
898 		      uint16_t		token,
899 		      const uint8_t	mac_addr[6]);
900 
901 /**
902  * dpni_remove_mac_addr() - Remove MAC address filter
903  * @mc_io:	Pointer to MC portal's I/O object
904  * @token:	Token of DPNI object
905  * @mac_addr:	MAC address to remove
906  *
907  * Return:	'0' on Success; Error code otherwise.
908  */
909 int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
910 			 uint16_t		token,
911 			 const uint8_t		mac_addr[6]);
912 
913 /**
914  * enum dpni_dest - DPNI destination types
915  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
916  *		does not generate FQDAN notifications; user is expected to
917  *		dequeue from the queue based on polling or other user-defined
918  *		method
919  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
920  *		notifications to the specified DPIO; user is expected to dequeue
921  *		from the queue only after notification is received
922  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
923  *		FQDAN notifications, but is connected to the specified DPCON
924  *		object; user is expected to dequeue from the DPCON channel
925  */
926 enum dpni_dest {
927 	DPNI_DEST_NONE = 0,
928 	DPNI_DEST_DPIO = 1,
929 	DPNI_DEST_DPCON = 2
930 };
931 
932 /**
933  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
934  * @dest_type: Destination type
935  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
936  * @priority: Priority selection within the DPIO or DPCON channel; valid values
937  *		are 0-1 or 0-7, depending on the number of priorities in that
938  *		channel; not relevant for 'DPNI_DEST_NONE' option
939  */
940 struct dpni_dest_cfg {
941 	enum dpni_dest dest_type;
942 	int dest_id;
943 	uint8_t priority;
944 };
945 
946 /**
947  * enum dpni_flc_type - DPNI FLC types
948  * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
949  * @DPNI_FLC_STASH: select the FLC to be used for stash control
950  */
951 enum dpni_flc_type {
952 	DPNI_FLC_USER_DEFINED = 0,
953 	DPNI_FLC_STASH = 1,
954 };
955 
956 /**
957  * enum dpni_stash_size - DPNI FLC stashing size
958  * @DPNI_STASH_SIZE_0B: no stash
959  * @DPNI_STASH_SIZE_64B: stashes 64 bytes
960  * @DPNI_STASH_SIZE_128B: stashes 128 bytes
961  * @DPNI_STASH_SIZE_192B: stashes 192 bytes
962  */
963 enum dpni_stash_size {
964 	DPNI_STASH_SIZE_0B = 0,
965 	DPNI_STASH_SIZE_64B = 1,
966 	DPNI_STASH_SIZE_128B = 2,
967 	DPNI_STASH_SIZE_192B = 3,
968 };
969 
970 /* DPNI FLC stash options */
971 
972 /* stashes the whole annotation area (up to 192 bytes) */
973 #define DPNI_FLC_STASH_FRAME_ANNOTATION	0x00000001
974 
975 /**
976  * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
977  * @flc_type: FLC type
978  * @options: Mask of available options;
979  *	use 'DPNI_FLC_STASH_<X>' values
980  * @frame_data_size: Size of frame data to be stashed
981  * @flow_context_size: Size of flow context to be stashed
982  * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
983  *			this value will be provided in the frame descriptor
984  *			(FD[FLC])
985  *		  2. In case flc_type is 'DPNI_FLC_STASH':
986  *			this value will be I/O virtual address of the
987  *			flow-context;
988  *			Must be cacheline-aligned and DMA-able memory
989  */
990 struct dpni_flc_cfg {
991 	enum dpni_flc_type flc_type;
992 	uint32_t options;
993 	enum dpni_stash_size frame_data_size;
994 	enum dpni_stash_size flow_context_size;
995 	uint64_t flow_context;
996 };
997 
998 /* DPNI queue modification options */
999 
1000 /* Select to modify the user's context associated with the queue */
1001 #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
1002 /* Select to modify the queue's destination */
1003 #define DPNI_QUEUE_OPT_DEST		0x00000002
1004 /** Select to modify the flow-context parameters;
1005  * not applicable for Tx-conf/Err queues as the FD comes from the user
1006  */
1007 #define DPNI_QUEUE_OPT_FLC		0x00000004
1008 
1009 
1010 /**
1011  * struct dpni_queue_cfg - Structure representing queue configuration
1012  * @options: Flags representing the suggested modifications to the queue;
1013  *		Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
1014  * @user_ctx: User context value provided in the frame descriptor of each
1015  *		dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
1016  *		is contained in 'options'
1017  * @dest_cfg: Queue destination parameters;
1018  *		valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
1019  * @flc_cfg: Flow context configuration; in case the TC's distribution
1020  *		is either NONE or HASH the FLC's settings of flow#0 are used.
1021  *		in the case of FS (flow-steering) the flow's FLC settings
1022  *		are used.
1023  *		valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
1024  */
1025 struct dpni_queue_cfg {
1026 	uint32_t options;
1027 	uint64_t user_ctx;
1028 	struct dpni_dest_cfg dest_cfg;
1029 	struct dpni_flc_cfg flc_cfg;
1030 };
1031 
1032 /**
1033  * struct dpni_queue_attr - Structure representing queue attributes
1034  * @user_ctx: User context value provided in the frame descriptor of each
1035  *	dequeued frame
1036  * @dest_cfg: Queue destination configuration
1037  * @flc_cfg: Flow context configuration
1038  * @fqid: Virtual fqid value to be used for dequeue operations
1039  */
1040 struct dpni_queue_attr {
1041 	uint64_t user_ctx;
1042 	struct dpni_dest_cfg dest_cfg;
1043 	struct dpni_flc_cfg flc_cfg;
1044 	uint32_t fqid;
1045 };
1046 
1047 /* DPNI Tx flow modification options */
1048 
1049 /* Select to modify the settings for dedicate Tx confirmation/error */
1050 #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR	0x00000001
1051 /*!< Select to modify the Tx confirmation and/or error setting */
1052 #define DPNI_TX_FLOW_OPT_ONLY_TX_ERROR	0x00000002
1053 /*!< Select to modify the queue configuration */
1054 #define DPNI_TX_FLOW_OPT_QUEUE		0x00000004
1055 /*!< Select to modify the L3 checksum generation setting */
1056 #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN	0x00000010
1057 /*!< Select to modify the L4 checksum generation setting */
1058 #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN	0x00000020
1059 
1060 /**
1061  * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
1062  * @options: Flags representing the suggested modifications to the Tx flow;
1063  *		Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
1064  * @conf_err_cfg: Tx confirmation and error configuration; these settings are
1065  *		ignored if 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' was set at
1066  *		DPNI creation
1067  * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
1068  *		valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in
1069  *		'options'
1070  * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
1071  *		valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in
1072  *		'options'
1073  */
1074 struct dpni_tx_flow_cfg {
1075 	uint32_t options;
1076 	/**
1077 	 * struct cnf_err_cfg - Tx confirmation and error configuration
1078 	 * @use_default_queue: Set to '1' to use the common (default) Tx
1079 	 *		confirmation and error queue; Set to '0' to use the
1080 	 *		private Tx confirmation and error queue; valid only if
1081 	 *		'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in
1082 	 *		'options'
1083 	 * @errors_only: Set to '1' to report back only error frames;
1084 	 *		Set to '0' to confirm transmission/error for all
1085 	 *		transmitted frames;
1086 	 *		valid only if 'DPNI_TX_FLOW_OPT_ONLY_TX_ERROR' is
1087 	 *		contained in 'options' and 'use_default_queue = 0';
1088 	 * @queue_cfg: Queue configuration; valid only if
1089 	 *		'DPNI_TX_FLOW_OPT_QUEUE' is contained in 'options'
1090 	 */
1091 	struct {
1092 		int use_default_queue;
1093 		int errors_only;
1094 		struct dpni_queue_cfg queue_cfg;
1095 	} conf_err_cfg;
1096 	int l3_chksum_gen;
1097 	int l4_chksum_gen;
1098 };
1099 
1100 /**
1101  * dpni_set_tx_flow() - Set Tx flow configuration
1102  * @mc_io:	Pointer to MC portal's I/O object
1103  * @token:	Token of DPNI object
1104  * @flow_id:	Provides (or returns) the sender's flow ID;
1105  *				for each new sender set (*flow_id) to
1106  *				'DPNI_NEW_FLOW_ID' to generate a new flow_id;
1107  *				this ID should be used as the QDBIN argument
1108  *				in enqueue operations
1109  * @cfg:	Tx flow configuration
1110  *
1111  * Return:	'0' on Success; Error code otherwise.
1112  */
1113 int dpni_set_tx_flow(struct fsl_mc_io			*mc_io,
1114 		     uint16_t				token,
1115 		     uint16_t				*flow_id,
1116 		     const struct dpni_tx_flow_cfg	*cfg);
1117 
1118 /**
1119  * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
1120  * @conf_err_attr: Tx confirmation and error attributes
1121  * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
1122  * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
1123  */
1124 struct dpni_tx_flow_attr {
1125 	/**
1126 	 * struct conf_err_attr - Tx confirmation and error attributes
1127 	 * @use_default_queue: '1' if using common (default) Tx confirmation and
1128 	 *			error queue;
1129 	 *			'0' if using private Tx confirmation and error
1130 	 *			queue
1131 	 * @errors_only: '1' if only error frames are reported back; '0' if all
1132 	 *		transmitted frames are confirmed
1133 	 * @queue_attr: Queue attributes
1134 	 */
1135 	struct {
1136 		int use_default_queue;
1137 		int errors_only;
1138 		struct dpni_queue_attr queue_attr;
1139 	} conf_err_attr;
1140 	int l3_chksum_gen;
1141 	int l4_chksum_gen;
1142 };
1143 
1144 /**
1145  * dpni_get_tx_flow() - Get Tx flow attributes
1146  * @mc_io:	Pointer to MC portal's I/O object
1147  * @token:	Token of DPNI object
1148  * @flow_id:	The sender's flow ID, as returned by the
1149  *			dpni_set_tx_flow() function
1150  * @attr:	Returned Tx flow attributes
1151  *
1152  * Return:	'0' on Success; Error code otherwise.
1153  */
1154 int dpni_get_tx_flow(struct fsl_mc_io		*mc_io,
1155 		     uint16_t			token,
1156 		     uint16_t			flow_id,
1157 		     struct dpni_tx_flow_attr	*attr);
1158 
1159 /**
1160  * dpni_set_rx_flow() - Set Rx flow configuration
1161  * @mc_io:	Pointer to MC portal's I/O object
1162  * @token:	Token of DPNI object
1163  * @tc_id:	Traffic class selection (0-7);
1164  *			use 'DPNI_ALL_TCS' to set all TCs and all flows
1165  * @flow_id	Rx flow id within the traffic class; use
1166  *			'DPNI_ALL_TC_FLOWS' to set all flows within
1167  *			this tc_id; ignored if tc_id is set to
1168  *			'DPNI_ALL_TCS';
1169  * @cfg:	Rx flow configuration
1170  *
1171  * Return:	'0' on Success; Error code otherwise.
1172  */
1173 int dpni_set_rx_flow(struct fsl_mc_io			*mc_io,
1174 		     uint16_t				token,
1175 		     uint8_t				tc_id,
1176 		     uint16_t				flow_id,
1177 		     const struct dpni_queue_cfg	*cfg);
1178 
1179 /**
1180  * dpni_get_rx_flow() -	Get Rx flow attributes
1181  * @mc_io:	Pointer to MC portal's I/O object
1182  * @token:	Token of DPNI object
1183  * @tc_id:	Traffic class selection (0-7)
1184  * @flow_id:	Rx flow id within the traffic class
1185  * @attr:	Returned Rx flow attributes
1186  *
1187  * Return:	'0' on Success; Error code otherwise.
1188  */
1189 int dpni_get_rx_flow(struct fsl_mc_io		*mc_io,
1190 		     uint16_t			token,
1191 		     uint8_t			tc_id,
1192 		     uint16_t			flow_id,
1193 		     struct dpni_queue_attr	*attr);
1194 
1195 #endif /* _FSL_DPNI_H */
1196