xref: /openbmc/u-boot/include/fsl-mc/fsl_dpni.h (revision 9ee16897)
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				1
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, 42, 1,  int,      cfg->order_preservation_en);\
328 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
329 	MC_CMD_OP(cmd, 1, 0,  64, uint64_t, cfg->user_ctx); \
330 	MC_CMD_OP(cmd, 2, 16, 8,  uint8_t,  tc_id); \
331 	MC_CMD_OP(cmd, 2, 32,  32, uint32_t, cfg->options); \
332 	MC_CMD_OP(cmd, 3, 0,  4,  enum dpni_flc_type, cfg->flc_cfg.flc_type); \
333 	MC_CMD_OP(cmd, 3, 4,  4,  enum dpni_stash_size, \
334 		cfg->flc_cfg.frame_data_size);\
335 	MC_CMD_OP(cmd, 3, 8,  4,  enum dpni_stash_size, \
336 		cfg->flc_cfg.flow_context_size);\
337 	MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
338 	MC_CMD_OP(cmd, 4, 0,  64, uint64_t, cfg->flc_cfg.flow_context);\
339 } while (0)
340 
341 /*                cmd, param, offset, width, type, arg_name */
342 #define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
343 do { \
344 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  tc_id); \
345 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
346 } while (0)
347 
348 /*                cmd, param, offset, width, type, arg_name */
349 #define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
350 do { \
351 	MC_RSP_OP(cmd, 0, 0,  32, int,      attr->dest_cfg.dest_id); \
352 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  attr->dest_cfg.priority);\
353 	MC_RSP_OP(cmd, 0, 40, 2,  enum dpni_dest, attr->dest_cfg.dest_type); \
354 	MC_CMD_OP(cmd, 0, 42, 1,  int,      attr->order_preservation_en);\
355 	MC_RSP_OP(cmd, 1, 0,  64, uint64_t, attr->user_ctx); \
356 	MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
357 	MC_RSP_OP(cmd, 3, 0,  4,  enum dpni_flc_type, attr->flc_cfg.flc_type); \
358 	MC_RSP_OP(cmd, 3, 4,  4,  enum dpni_stash_size, \
359 		attr->flc_cfg.frame_data_size);\
360 	MC_RSP_OP(cmd, 3, 8,  4,  enum dpni_stash_size, \
361 		attr->flc_cfg.flow_context_size);\
362 	MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
363 	MC_RSP_OP(cmd, 4, 0,  64, uint64_t, attr->flc_cfg.flow_context);\
364 } while (0)
365 
366 enum net_prot {
367 	NET_PROT_NONE = 0,
368 	NET_PROT_PAYLOAD,
369 	NET_PROT_ETH,
370 	NET_PROT_VLAN,
371 	NET_PROT_IPV4,
372 	NET_PROT_IPV6,
373 	NET_PROT_IP,
374 	NET_PROT_TCP,
375 	NET_PROT_UDP,
376 	NET_PROT_UDP_LITE,
377 	NET_PROT_IPHC,
378 	NET_PROT_SCTP,
379 	NET_PROT_SCTP_CHUNK_DATA,
380 	NET_PROT_PPPOE,
381 	NET_PROT_PPP,
382 	NET_PROT_PPPMUX,
383 	NET_PROT_PPPMUX_SUBFRM,
384 	NET_PROT_L2TPV2,
385 	NET_PROT_L2TPV3_CTRL,
386 	NET_PROT_L2TPV3_SESS,
387 	NET_PROT_LLC,
388 	NET_PROT_LLC_SNAP,
389 	NET_PROT_NLPID,
390 	NET_PROT_SNAP,
391 	NET_PROT_MPLS,
392 	NET_PROT_IPSEC_AH,
393 	NET_PROT_IPSEC_ESP,
394 	NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
395 	NET_PROT_MACSEC,
396 	NET_PROT_GRE,
397 	NET_PROT_MINENCAP,
398 	NET_PROT_DCCP,
399 	NET_PROT_ICMP,
400 	NET_PROT_IGMP,
401 	NET_PROT_ARP,
402 	NET_PROT_CAPWAP_DATA,
403 	NET_PROT_CAPWAP_CTRL,
404 	NET_PROT_RFC2684,
405 	NET_PROT_ICMPV6,
406 	NET_PROT_FCOE,
407 	NET_PROT_FIP,
408 	NET_PROT_ISCSI,
409 	NET_PROT_GTP,
410 	NET_PROT_USER_DEFINED_L2,
411 	NET_PROT_USER_DEFINED_L3,
412 	NET_PROT_USER_DEFINED_L4,
413 	NET_PROT_USER_DEFINED_L5,
414 	NET_PROT_USER_DEFINED_SHIM1,
415 	NET_PROT_USER_DEFINED_SHIM2,
416 
417 	NET_PROT_DUMMY_LAST
418 };
419 
420 /**
421  * Data Path Network Interface API
422  * Contains initialization APIs and runtime control APIs for DPNI
423  */
424 
425 struct fsl_mc_io;
426 
427 /* General DPNI macros */
428 
429 /* Maximum number of traffic classes */
430 #define DPNI_MAX_TC				8
431 /* Maximum number of buffer pools per DPNI */
432 #define DPNI_MAX_DPBP				8
433 
434 /* All traffic classes considered; see dpni_set_rx_flow() */
435 #define DPNI_ALL_TCS				(uint8_t)(-1)
436 /* All flows within traffic class considered; see dpni_set_rx_flow() */
437 #define DPNI_ALL_TC_FLOWS			(uint16_t)(-1)
438 /* Generate new flow ID; see dpni_set_tx_flow() */
439 #define DPNI_NEW_FLOW_ID			(uint16_t)(-1)
440 
441 /**
442  * dpni_open() - Open a control session for the specified object
443  * @mc_io:	Pointer to MC portal's I/O object
444  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
445  * @dpni_id:	DPNI unique ID
446  * @token:	Returned token; use in subsequent API calls
447  *
448  * This function can be used to open a control session for an
449  * already created object; an object may have been declared in
450  * the DPL or by calling the dpni_create() function.
451  * This function returns a unique authentication token,
452  * associated with the specific object ID and the specific MC
453  * portal; this token must be used in all subsequent commands for
454  * this specific object.
455  *
456  * Return:	'0' on Success; Error code otherwise.
457  */
458 int dpni_open(struct fsl_mc_io	*mc_io,
459 	      uint32_t		cmd_flags,
460 	      int		dpni_id,
461 	      uint16_t		*token);
462 
463 /**
464  * dpni_close() - Close the control session of the object
465  * @mc_io:	Pointer to MC portal's I/O object
466  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
467  * @token:	Token of DPNI object
468  *
469  * After this function is called, no further operations are
470  * allowed on the object without opening a new control session.
471  *
472  * Return:	'0' on Success; Error code otherwise.
473  */
474 int dpni_close(struct fsl_mc_io	*mc_io,
475 	       uint32_t		cmd_flags,
476 	       uint16_t		token);
477 
478 /**
479  * struct dpni_ipr_cfg - Structure representing IP reassembly configuration
480  * @max_reass_frm_size: Maximum size of the reassembled frame
481  * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
482  * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
483  * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly process
484  * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly process
485  */
486 struct dpni_ipr_cfg {
487 	uint16_t max_reass_frm_size;
488 	uint16_t min_frag_size_ipv4;
489 	uint16_t min_frag_size_ipv6;
490 	uint16_t max_open_frames_ipv4;
491 	uint16_t max_open_frames_ipv6;
492 };
493 
494 /**
495  * struct dpni_pools_cfg - Structure representing buffer pools configuration
496  * @num_dpbp: Number of DPBPs
497  * @pools: Array of buffer pools parameters; The number of valid entries
498  *	must match 'num_dpbp' value
499  */
500 struct dpni_pools_cfg {
501 	uint8_t num_dpbp;
502 	/**
503 	 * struct pools - Buffer pools parameters
504 	 * @dpbp_id: DPBP object ID
505 	 * @buffer_size: Buffer size
506 	 * @backup_pool: Backup pool
507 	 */
508 	struct {
509 		int		dpbp_id;
510 		uint16_t	buffer_size;
511 		int		backup_pool;
512 	} pools[DPNI_MAX_DPBP];
513 };
514 
515 /**
516  * dpni_set_pools() - Set buffer pools configuration
517  * @mc_io:	Pointer to MC portal's I/O object
518  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
519  * @token:	Token of DPNI object
520  * @cfg:	Buffer pools configuration
521  *
522  * mandatory for DPNI operation
523  * warning:Allowed only when DPNI is disabled
524  *
525  * Return:	'0' on Success; Error code otherwise.
526  */
527 int dpni_set_pools(struct fsl_mc_io		*mc_io,
528 		   uint32_t			cmd_flags,
529 		   uint16_t			token,
530 		   const struct dpni_pools_cfg	*cfg);
531 
532 /**
533  * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
534  * @mc_io:	Pointer to MC portal's I/O object
535  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
536  * @token:		Token of DPNI object
537  *
538  * Return:	'0' on Success; Error code otherwise.
539  */
540 int dpni_enable(struct fsl_mc_io	*mc_io,
541 		uint32_t		cmd_flags,
542 		uint16_t		token);
543 
544 /**
545  * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
546  * @mc_io:	Pointer to MC portal's I/O object
547  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
548  * @token:	Token of DPNI object
549  *
550  * Return:	'0' on Success; Error code otherwise.
551  */
552 int dpni_disable(struct fsl_mc_io	*mc_io,
553 		 uint32_t		cmd_flags,
554 		 uint16_t		token);
555 
556 
557 /**
558  * dpni_reset() - Reset the DPNI, returns the object to initial state.
559  * @mc_io:	Pointer to MC portal's I/O object
560  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
561  * @token:	Token of DPNI object
562  *
563  * Return:	'0' on Success; Error code otherwise.
564  */
565 int dpni_reset(struct fsl_mc_io	*mc_io,
566 	       uint32_t		cmd_flags,
567 	       uint16_t		token);
568 
569 /**
570  * struct dpni_attr - Structure representing DPNI attributes
571  * @id: DPNI object ID
572  * @version: DPNI version
573  * @start_hdr: Indicates the packet starting header for parsing
574  * @options: Mask of available options; reflects the value as was given in
575  *		object's creation
576  * @max_senders: Maximum number of different senders; used as the number
577  *		of dedicated Tx flows;
578  * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
579  * @max_dist_per_tc: Maximum distribution size per Rx traffic class;
580  *			Set to the required value minus 1
581  * @max_unicast_filters: Maximum number of unicast filters
582  * @max_multicast_filters: Maximum number of multicast filters
583  * @max_vlan_filters: Maximum number of VLAN filters
584  * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
585  * @max_qos_key_size: Maximum key size for the QoS look-up
586  * @max_dist_key_size: Maximum key size for the distribution look-up
587  * @max_policers: Maximum number of policers;
588  * @max_congestion_ctrl: Maximum number of congestion control groups (CGs);
589  * @ipr_cfg: IP reassembly configuration
590  */
591 struct dpni_attr {
592 	int id;
593 	/**
594 	 * struct version - DPNI version
595 	 * @major: DPNI major version
596 	 * @minor: DPNI minor version
597 	 */
598 	struct {
599 		uint16_t major;
600 		uint16_t minor;
601 	} version;
602 	enum net_prot start_hdr;
603 	uint32_t options;
604 	uint8_t max_senders;
605 	uint8_t max_tcs;
606 	uint8_t max_dist_per_tc[DPNI_MAX_TC];
607 	uint8_t max_unicast_filters;
608 	uint8_t max_multicast_filters;
609 	uint8_t max_vlan_filters;
610 	uint8_t max_qos_entries;
611 	uint8_t max_qos_key_size;
612 	uint8_t max_dist_key_size;
613 	uint8_t max_policers;
614 	uint8_t max_congestion_ctrl;
615 	struct dpni_ipr_cfg ipr_cfg;
616 };
617 
618 /**
619  * dpni_get_attributes() - Retrieve DPNI attributes.
620  * @mc_io:	Pointer to MC portal's I/O object
621  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
622  * @token:	Token of DPNI object
623  * @attr:	Returned object's attributes
624  *
625  * Return:	'0' on Success; Error code otherwise.
626  */
627 int dpni_get_attributes(struct fsl_mc_io	*mc_io,
628 			uint32_t		cmd_flags,
629 			uint16_t		token,
630 			struct dpni_attr	*attr);
631 
632 /* DPNI buffer layout modification options */
633 
634 /* Select to modify the time-stamp setting */
635 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
636 /* Select to modify the parser-result setting; not applicable for Tx */
637 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
638 /* Select to modify the frame-status setting */
639 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
640 /* Select to modify the private-data-size setting */
641 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
642 /* Select to modify the data-alignment setting */
643 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
644 /* Select to modify the data-head-room setting */
645 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
646 /*!< Select to modify the data-tail-room setting */
647 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
648 
649 /**
650  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
651  * @options: Flags representing the suggested modifications to the buffer
652  *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
653  * @pass_timestamp: Pass timestamp value
654  * @pass_parser_result: Pass parser results
655  * @pass_frame_status: Pass frame status
656  * @private_data_size: Size kept for private data (in bytes)
657  * @data_align: Data alignment
658  * @data_head_room: Data head room
659  * @data_tail_room: Data tail room
660  */
661 struct dpni_buffer_layout {
662 	uint32_t options;
663 	int pass_timestamp;
664 	int pass_parser_result;
665 	int pass_frame_status;
666 	uint16_t private_data_size;
667 	uint16_t data_align;
668 	uint16_t data_head_room;
669 	uint16_t data_tail_room;
670 };
671 
672 /**
673  * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
674  * @mc_io:	Pointer to MC portal's I/O object
675  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
676  * @token:	Token of DPNI object
677  * @layout:	Returns buffer layout attributes
678  *
679  * Return:	'0' on Success; Error code otherwise.
680  */
681 int dpni_get_rx_buffer_layout(struct fsl_mc_io		*mc_io,
682 			      uint32_t			cmd_flags,
683 			      uint16_t			token,
684 			      struct dpni_buffer_layout	*layout);
685 
686 /**
687  * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration.
688  * @mc_io:	Pointer to MC portal's I/O object
689  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
690  * @token:	Token of DPNI object
691  * @layout:	Buffer layout configuration
692  *
693  * Return:	'0' on Success; Error code otherwise.
694  *
695  * @warning	Allowed only when DPNI is disabled
696  */
697 int dpni_set_rx_buffer_layout(struct fsl_mc_io			*mc_io,
698 			      uint32_t				cmd_flags,
699 			      uint16_t				token,
700 			      const struct dpni_buffer_layout	*layout);
701 
702 /**
703  * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
704  * @mc_io:	Pointer to MC portal's I/O object
705  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
706  * @token:	Token of DPNI object
707  * @layout:	Returns buffer layout attributes
708  *
709  * Return:	'0' on Success; Error code otherwise.
710  */
711 int dpni_get_tx_buffer_layout(struct fsl_mc_io		*mc_io,
712 			      uint32_t			cmd_flags,
713 			      uint16_t			token,
714 			      struct dpni_buffer_layout	*layout);
715 
716 /**
717  * dpni_set_tx_buffer_layout() - Set Tx buffer layout configuration.
718  * @mc_io:	Pointer to MC portal's I/O object
719  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
720  * @token:	Token of DPNI object
721  * @layout:	Buffer layout configuration
722  *
723  * Return:	'0' on Success; Error code otherwise.
724  *
725  * @warning	Allowed only when DPNI is disabled
726  */
727 int dpni_set_tx_buffer_layout(struct fsl_mc_io			*mc_io,
728 			      uint32_t				cmd_flags,
729 			      uint16_t				token,
730 			      const struct dpni_buffer_layout	*layout);
731 
732 /**
733  * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
734  *				attributes.
735  * @mc_io:	Pointer to MC portal's I/O object
736  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
737  * @token:	Token of DPNI object
738  * @layout:	Returns buffer layout attributes
739  *
740  * Return:	'0' on Success; Error code otherwise.
741  */
742 int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io		*mc_io,
743 				   uint32_t			cmd_flags,
744 				   uint16_t			token,
745 				   struct dpni_buffer_layout	*layout);
746 
747 /**
748  * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
749  *					configuration.
750  * @mc_io:	Pointer to MC portal's I/O object
751  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
752  * @token:	Token of DPNI object
753  * @layout:	Buffer layout configuration
754  *
755  * Return:	'0' on Success; Error code otherwise.
756  *
757  * @warning	Allowed only when DPNI is disabled
758  */
759 int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io		   *mc_io,
760 				   uint32_t			   cmd_flags,
761 				   uint16_t			   token,
762 				   const struct dpni_buffer_layout *layout);
763 
764 /**
765  * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
766  *			for enqueue operations
767  * @mc_io:	Pointer to MC portal's I/O object
768  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
769  * @token:	Token of DPNI object
770  * @qdid:	Returned virtual QDID value that should be used as an argument
771  *			in all enqueue operations
772  *
773  * Return:	'0' on Success; Error code otherwise.
774  */
775 int dpni_get_qdid(struct fsl_mc_io	*mc_io,
776 		  uint32_t		cmd_flags,
777 		  uint16_t		token,
778 		  uint16_t		*qdid);
779 
780 /**
781  * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
782  * @mc_io:	Pointer to MC portal's I/O object
783  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
784  * @token:	Token of DPNI object
785  * @data_offset: Tx data offset (from start of buffer)
786  *
787  * Return:	'0' on Success; Error code otherwise.
788  */
789 int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
790 			    uint32_t		cmd_flags,
791 			    uint16_t		token,
792 			    uint16_t		*data_offset);
793 
794 /**
795  * enum dpni_counter - DPNI counter types
796  * @DPNI_CNT_ING_FRAME: Counts ingress frames
797  * @DPNI_CNT_ING_BYTE: Counts ingress bytes
798  * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
799  *		'drop' setting
800  * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
801  * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
802  * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
803  * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
804  * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
805  * @DPNI_CNT_EGR_FRAME: Counts egress frames
806  * @DPNI_CNT_EGR_BYTE: Counts egress bytes
807  * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
808  */
809 enum dpni_counter {
810 	DPNI_CNT_ING_FRAME = 0x0,
811 	DPNI_CNT_ING_BYTE = 0x1,
812 	DPNI_CNT_ING_FRAME_DROP = 0x2,
813 	DPNI_CNT_ING_FRAME_DISCARD = 0x3,
814 	DPNI_CNT_ING_MCAST_FRAME = 0x4,
815 	DPNI_CNT_ING_MCAST_BYTE = 0x5,
816 	DPNI_CNT_ING_BCAST_FRAME = 0x6,
817 	DPNI_CNT_ING_BCAST_BYTES = 0x7,
818 	DPNI_CNT_EGR_FRAME = 0x8,
819 	DPNI_CNT_EGR_BYTE = 0x9,
820 	DPNI_CNT_EGR_FRAME_DISCARD = 0xa
821 };
822 
823 /**
824  * dpni_get_counter() - Read a specific DPNI counter
825  * @mc_io:	Pointer to MC portal's I/O object
826  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
827  * @token:	Token of DPNI object
828  * @counter:	The requested counter
829  * @value:	Returned counter's current value
830  *
831  * Return:	'0' on Success; Error code otherwise.
832  */
833 int dpni_get_counter(struct fsl_mc_io	*mc_io,
834 		     uint32_t		cmd_flags,
835 		     uint16_t		token,
836 		     enum dpni_counter	counter,
837 		     uint64_t		*value);
838 
839 /**
840  * dpni_set_counter() - Set (or clear) a specific DPNI counter
841  * @mc_io:	Pointer to MC portal's I/O object
842  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
843  * @token:	Token of DPNI object
844  * @counter:	The requested counter
845  * @value:	New counter value; typically pass '0' for resetting
846  *			the counter.
847  *
848  * Return:	'0' on Success; Error code otherwise.
849  */
850 int dpni_set_counter(struct fsl_mc_io	*mc_io,
851 		     uint32_t		cmd_flags,
852 		     uint16_t		token,
853 		     enum dpni_counter	counter,
854 		     uint64_t		value);
855 
856 /* Enable auto-negotiation */
857 #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
858 /* Enable half-duplex mode */
859 #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
860 /* Enable pause frames */
861 #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
862 /* Enable a-symmetric pause frames */
863 #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
864 
865 /**
866  * struct - Structure representing DPNI link configuration
867  * @rate: Rate
868  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
869  */
870 struct dpni_link_cfg {
871 	uint32_t rate;
872 	uint64_t options;
873 };
874 
875 /**
876  * dpni_set_link_cfg() - set the link configuration.
877  * @mc_io:	Pointer to MC portal's I/O object
878  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
879  * @token:	Token of DPNI object
880  * @cfg:	Link configuration
881  *
882  * Return:	'0' on Success; Error code otherwise.
883  */
884 int dpni_set_link_cfg(struct fsl_mc_io			*mc_io,
885 		      uint32_t				cmd_flags,
886 		      uint16_t				token,
887 		      const struct dpni_link_cfg	*cfg);
888 
889 /**
890  * struct dpni_link_state - Structure representing DPNI link state
891  * @rate: Rate
892  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
893  * @up: Link state; '0' for down, '1' for up
894  */
895 struct dpni_link_state {
896 	uint32_t rate;
897 	uint64_t options;
898 	int up;
899 };
900 
901 /**
902  * dpni_get_link_state() - Return the link state (either up or down)
903  * @mc_io:	Pointer to MC portal's I/O object
904  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
905  * @token:	Token of DPNI object
906  * @state:	Returned link state;
907  *
908  * Return:	'0' on Success; Error code otherwise.
909  */
910 int dpni_get_link_state(struct fsl_mc_io	*mc_io,
911 			uint32_t		cmd_flags,
912 			uint16_t		token,
913 			struct dpni_link_state	*state);
914 
915 /**
916  * dpni_set_primary_mac_addr() - Set the primary MAC address
917  * @mc_io:	Pointer to MC portal's I/O object
918  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
919  * @token:	Token of DPNI object
920  * @mac_addr:	MAC address to set as primary address
921  *
922  * Return:	'0' on Success; Error code otherwise.
923  */
924 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
925 			      uint32_t		cmd_flags,
926 			      uint16_t		token,
927 			      const uint8_t	mac_addr[6]);
928 
929 /**
930  * dpni_get_primary_mac_addr() - Get the primary MAC address
931  * @mc_io:	Pointer to MC portal's I/O object
932  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
933  * @token:	Token of DPNI object
934  * @mac_addr:	Returned MAC address
935  *
936  * Return:	'0' on Success; Error code otherwise.
937  */
938 int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
939 			      uint32_t		cmd_flags,
940 			      uint16_t		token,
941 			      uint8_t		mac_addr[6]);
942 
943 /**
944  * dpni_add_mac_addr() - Add MAC address filter
945  * @mc_io:	Pointer to MC portal's I/O object
946  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
947  * @token:	Token of DPNI object
948  * @mac_addr:	MAC address to add
949  *
950  * Return:	'0' on Success; Error code otherwise.
951  */
952 int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
953 		      uint32_t		cmd_flags,
954 		      uint16_t		token,
955 		      const uint8_t	mac_addr[6]);
956 
957 /**
958  * dpni_remove_mac_addr() - Remove MAC address filter
959  * @mc_io:	Pointer to MC portal's I/O object
960  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
961  * @token:	Token of DPNI object
962  * @mac_addr:	MAC address to remove
963  *
964  * Return:	'0' on Success; Error code otherwise.
965  */
966 int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
967 			 uint32_t		cmd_flags,
968 			 uint16_t		token,
969 			 const uint8_t		mac_addr[6]);
970 
971 /**
972  * enum dpni_dest - DPNI destination types
973  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
974  *		does not generate FQDAN notifications; user is expected to
975  *		dequeue from the queue based on polling or other user-defined
976  *		method
977  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
978  *		notifications to the specified DPIO; user is expected to dequeue
979  *		from the queue only after notification is received
980  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
981  *		FQDAN notifications, but is connected to the specified DPCON
982  *		object; user is expected to dequeue from the DPCON channel
983  */
984 enum dpni_dest {
985 	DPNI_DEST_NONE = 0,
986 	DPNI_DEST_DPIO = 1,
987 	DPNI_DEST_DPCON = 2
988 };
989 
990 /**
991  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
992  * @dest_type: Destination type
993  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
994  * @priority: Priority selection within the DPIO or DPCON channel; valid values
995  *		are 0-1 or 0-7, depending on the number of priorities in that
996  *		channel; not relevant for 'DPNI_DEST_NONE' option
997  */
998 struct dpni_dest_cfg {
999 	enum dpni_dest dest_type;
1000 	int dest_id;
1001 	uint8_t priority;
1002 };
1003 
1004 /**
1005  * enum dpni_flc_type - DPNI FLC types
1006  * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
1007  * @DPNI_FLC_STASH: select the FLC to be used for stash control
1008  */
1009 enum dpni_flc_type {
1010 	DPNI_FLC_USER_DEFINED = 0,
1011 	DPNI_FLC_STASH = 1,
1012 };
1013 
1014 /**
1015  * enum dpni_stash_size - DPNI FLC stashing size
1016  * @DPNI_STASH_SIZE_0B: no stash
1017  * @DPNI_STASH_SIZE_64B: stashes 64 bytes
1018  * @DPNI_STASH_SIZE_128B: stashes 128 bytes
1019  * @DPNI_STASH_SIZE_192B: stashes 192 bytes
1020  */
1021 enum dpni_stash_size {
1022 	DPNI_STASH_SIZE_0B = 0,
1023 	DPNI_STASH_SIZE_64B = 1,
1024 	DPNI_STASH_SIZE_128B = 2,
1025 	DPNI_STASH_SIZE_192B = 3,
1026 };
1027 
1028 /* DPNI FLC stash options */
1029 
1030 /* stashes the whole annotation area (up to 192 bytes) */
1031 #define DPNI_FLC_STASH_FRAME_ANNOTATION	0x00000001
1032 
1033 /**
1034  * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
1035  * @flc_type: FLC type
1036  * @options: Mask of available options;
1037  *	use 'DPNI_FLC_STASH_<X>' values
1038  * @frame_data_size: Size of frame data to be stashed
1039  * @flow_context_size: Size of flow context to be stashed
1040  * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
1041  *			this value will be provided in the frame descriptor
1042  *			(FD[FLC])
1043  *		  2. In case flc_type is 'DPNI_FLC_STASH':
1044  *			this value will be I/O virtual address of the
1045  *			flow-context;
1046  *			Must be cacheline-aligned and DMA-able memory
1047  */
1048 struct dpni_flc_cfg {
1049 	enum dpni_flc_type flc_type;
1050 	uint32_t options;
1051 	enum dpni_stash_size frame_data_size;
1052 	enum dpni_stash_size flow_context_size;
1053 	uint64_t flow_context;
1054 };
1055 
1056 /* DPNI queue modification options */
1057 
1058 /* Select to modify the user's context associated with the queue */
1059 #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
1060 /* Select to modify the queue's destination */
1061 #define DPNI_QUEUE_OPT_DEST		0x00000002
1062 /** Select to modify the flow-context parameters;
1063  * not applicable for Tx-conf/Err queues as the FD comes from the user
1064  */
1065 #define DPNI_QUEUE_OPT_FLC		0x00000004
1066 /* Select to modify the queue's order preservation */
1067 #define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008
1068 
1069 /**
1070  * struct dpni_queue_cfg - Structure representing queue configuration
1071  * @options: Flags representing the suggested modifications to the queue;
1072  *		Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
1073  * @user_ctx: User context value provided in the frame descriptor of each
1074  *		dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
1075  *		is contained in 'options'
1076  * @dest_cfg: Queue destination parameters;
1077  *		valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
1078  * @flc_cfg: Flow context configuration; in case the TC's distribution
1079  *		is either NONE or HASH the FLC's settings of flow#0 are used.
1080  *		in the case of FS (flow-steering) the flow's FLC settings
1081  *		are used.
1082  *		valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
1083  * @order_preservation_en: enable/disable order preservation;
1084  *		valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained
1085  *		in 'options'
1086  */
1087 struct dpni_queue_cfg {
1088 	uint32_t options;
1089 	uint64_t user_ctx;
1090 	struct dpni_dest_cfg dest_cfg;
1091 	struct dpni_flc_cfg flc_cfg;
1092 	int order_preservation_en;
1093 };
1094 
1095 /**
1096  * struct dpni_queue_attr - Structure representing queue attributes
1097  * @user_ctx: User context value provided in the frame descriptor of each
1098  *	dequeued frame
1099  * @dest_cfg: Queue destination configuration
1100  * @flc_cfg: Flow context configuration
1101  * @order_preservation_en: enable/disable order preservation
1102  * @fqid: Virtual fqid value to be used for dequeue operations
1103  */
1104 struct dpni_queue_attr {
1105 	uint64_t user_ctx;
1106 	struct dpni_dest_cfg dest_cfg;
1107 	struct dpni_flc_cfg flc_cfg;
1108 	int order_preservation_en;
1109 	uint32_t fqid;
1110 };
1111 
1112 /* DPNI Tx flow modification options */
1113 
1114 /* Select to modify the settings for dedicate Tx confirmation/error */
1115 #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR	0x00000001
1116 /*!< Select to modify the Tx confirmation and/or error setting */
1117 #define DPNI_TX_FLOW_OPT_ONLY_TX_ERROR	0x00000002
1118 /*!< Select to modify the queue configuration */
1119 #define DPNI_TX_FLOW_OPT_QUEUE		0x00000004
1120 /*!< Select to modify the L3 checksum generation setting */
1121 #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN	0x00000010
1122 /*!< Select to modify the L4 checksum generation setting */
1123 #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN	0x00000020
1124 
1125 /**
1126  * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
1127  * @options: Flags representing the suggested modifications to the Tx flow;
1128  *		Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
1129  * @conf_err_cfg: Tx confirmation and error configuration; these settings are
1130  *		ignored if 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' was set at
1131  *		DPNI creation
1132  * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
1133  *		valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in
1134  *		'options'
1135  * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
1136  *		valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in
1137  *		'options'
1138  */
1139 struct dpni_tx_flow_cfg {
1140 	uint32_t options;
1141 	/**
1142 	 * struct cnf_err_cfg - Tx confirmation and error configuration
1143 	 * @use_default_queue: Set to '1' to use the common (default) Tx
1144 	 *		confirmation and error queue; Set to '0' to use the
1145 	 *		private Tx confirmation and error queue; valid only if
1146 	 *		'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in
1147 	 *		'options'
1148 	 * @errors_only: Set to '1' to report back only error frames;
1149 	 *		Set to '0' to confirm transmission/error for all
1150 	 *		transmitted frames;
1151 	 *		valid only if 'DPNI_TX_FLOW_OPT_ONLY_TX_ERROR' is
1152 	 *		contained in 'options' and 'use_default_queue = 0';
1153 	 * @queue_cfg: Queue configuration; valid only if
1154 	 *		'DPNI_TX_FLOW_OPT_QUEUE' is contained in 'options'
1155 	 */
1156 	struct {
1157 		int use_default_queue;
1158 		int errors_only;
1159 		struct dpni_queue_cfg queue_cfg;
1160 	} conf_err_cfg;
1161 	int l3_chksum_gen;
1162 	int l4_chksum_gen;
1163 };
1164 
1165 /**
1166  * dpni_set_tx_flow() - Set Tx flow configuration
1167  * @mc_io:	Pointer to MC portal's I/O object
1168  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1169  * @token:	Token of DPNI object
1170  * @flow_id:	Provides (or returns) the sender's flow ID;
1171  *				for each new sender set (*flow_id) to
1172  *				'DPNI_NEW_FLOW_ID' to generate a new flow_id;
1173  *				this ID should be used as the QDBIN argument
1174  *				in enqueue operations
1175  * @cfg:	Tx flow configuration
1176  *
1177  * Return:	'0' on Success; Error code otherwise.
1178  */
1179 int dpni_set_tx_flow(struct fsl_mc_io			*mc_io,
1180 		     uint32_t				cmd_flags,
1181 		     uint16_t				token,
1182 		     uint16_t				*flow_id,
1183 		     const struct dpni_tx_flow_cfg	*cfg);
1184 
1185 /**
1186  * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
1187  * @conf_err_attr: Tx confirmation and error attributes
1188  * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
1189  * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
1190  */
1191 struct dpni_tx_flow_attr {
1192 	/**
1193 	 * struct conf_err_attr - Tx confirmation and error attributes
1194 	 * @use_default_queue: '1' if using common (default) Tx confirmation and
1195 	 *			error queue;
1196 	 *			'0' if using private Tx confirmation and error
1197 	 *			queue
1198 	 * @errors_only: '1' if only error frames are reported back; '0' if all
1199 	 *		transmitted frames are confirmed
1200 	 * @queue_attr: Queue attributes
1201 	 */
1202 	struct {
1203 		int use_default_queue;
1204 		int errors_only;
1205 		struct dpni_queue_attr queue_attr;
1206 	} conf_err_attr;
1207 	int l3_chksum_gen;
1208 	int l4_chksum_gen;
1209 };
1210 
1211 /**
1212  * dpni_get_tx_flow() - Get Tx flow attributes
1213  * @mc_io:	Pointer to MC portal's I/O object
1214  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1215  * @token:	Token of DPNI object
1216  * @flow_id:	The sender's flow ID, as returned by the
1217  *			dpni_set_tx_flow() function
1218  * @attr:	Returned Tx flow attributes
1219  *
1220  * Return:	'0' on Success; Error code otherwise.
1221  */
1222 int dpni_get_tx_flow(struct fsl_mc_io		*mc_io,
1223 		     uint32_t			cmd_flags,
1224 		     uint16_t			token,
1225 		     uint16_t			flow_id,
1226 		     struct dpni_tx_flow_attr	*attr);
1227 
1228 /**
1229  * dpni_set_rx_flow() - Set Rx flow configuration
1230  * @mc_io:	Pointer to MC portal's I/O object
1231  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1232  * @token:	Token of DPNI object
1233  * @tc_id:	Traffic class selection (0-7);
1234  *			use 'DPNI_ALL_TCS' to set all TCs and all flows
1235  * @flow_id:	Rx flow id within the traffic class; use
1236  *			'DPNI_ALL_TC_FLOWS' to set all flows within
1237  *			this tc_id; ignored if tc_id is set to
1238  *			'DPNI_ALL_TCS';
1239  * @cfg:	Rx flow configuration
1240  *
1241  * Return:	'0' on Success; Error code otherwise.
1242  */
1243 int dpni_set_rx_flow(struct fsl_mc_io			*mc_io,
1244 		     uint32_t				cmd_flags,
1245 		     uint16_t				token,
1246 		     uint8_t				tc_id,
1247 		     uint16_t				flow_id,
1248 		     const struct dpni_queue_cfg	*cfg);
1249 
1250 /**
1251  * dpni_get_rx_flow() -	Get Rx flow attributes
1252  * @mc_io:	Pointer to MC portal's I/O object
1253  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1254  * @token:	Token of DPNI object
1255  * @tc_id:	Traffic class selection (0-7)
1256  * @flow_id:	Rx flow id within the traffic class
1257  * @attr:	Returned Rx flow attributes
1258  *
1259  * Return:	'0' on Success; Error code otherwise.
1260  */
1261 int dpni_get_rx_flow(struct fsl_mc_io		*mc_io,
1262 		     uint32_t			cmd_flags,
1263 		     uint16_t			token,
1264 		     uint8_t			tc_id,
1265 		     uint16_t			flow_id,
1266 		     struct dpni_queue_attr	*attr);
1267 
1268 #endif /* _FSL_DPNI_H */
1269