xref: /openbmc/u-boot/include/fsl-mc/fsl_dpni.h (revision ee7bb5be)
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				6
11 #define DPNI_VER_MINOR				0
12 
13 /* Command IDs */
14 #define DPNI_CMDID_OPEN				0x801
15 #define DPNI_CMDID_CLOSE			0x800
16 #define DPNI_CMDID_CREATE			0x901
17 #define DPNI_CMDID_DESTROY			0x900
18 
19 #define DPNI_CMDID_ENABLE			0x002
20 #define DPNI_CMDID_DISABLE			0x003
21 #define DPNI_CMDID_GET_ATTR			0x004
22 #define DPNI_CMDID_RESET			0x005
23 
24 #define DPNI_CMDID_SET_POOLS			0x200
25 #define DPNI_CMDID_GET_RX_BUFFER_LAYOUT		0x201
26 #define DPNI_CMDID_SET_RX_BUFFER_LAYOUT		0x202
27 #define DPNI_CMDID_GET_TX_BUFFER_LAYOUT		0x203
28 #define DPNI_CMDID_SET_TX_BUFFER_LAYOUT		0x204
29 #define DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT	0x205
30 #define DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT	0x206
31 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR		0x20B
32 
33 #define DPNI_CMDID_GET_QDID			0x210
34 #define DPNI_CMDID_GET_TX_DATA_OFFSET		0x212
35 #define DPNI_CMDID_GET_COUNTER			0x213
36 #define DPNI_CMDID_SET_COUNTER			0x214
37 #define DPNI_CMDID_GET_LINK_STATE		0x215
38 #define DPNI_CMDID_SET_LINK_CFG		0x21A
39 
40 #define DPNI_CMDID_SET_PRIM_MAC			0x224
41 #define DPNI_CMDID_GET_PRIM_MAC			0x225
42 #define DPNI_CMDID_ADD_MAC_ADDR			0x226
43 #define DPNI_CMDID_REMOVE_MAC_ADDR		0x227
44 
45 #define DPNI_CMDID_SET_TX_FLOW			0x236
46 #define DPNI_CMDID_GET_TX_FLOW			0x237
47 #define DPNI_CMDID_SET_RX_FLOW			0x238
48 #define DPNI_CMDID_GET_RX_FLOW			0x239
49 #define DPNI_CMDID_SET_TX_CONF						0x257
50 #define DPNI_CMDID_GET_TX_CONF						0x258
51 
52 /*                cmd, param, offset, width, type, arg_name */
53 #define DPNI_CMD_OPEN(cmd, dpni_id) \
54 	MC_CMD_OP(cmd,	 0,	0,	32,	int,	dpni_id)
55 
56 #define DPNI_PREP_EXTENDED_CFG(ext, cfg) \
57 do { \
58 	MC_PREP_OP(ext, 0, 0,   16, uint16_t, cfg->tc_cfg[0].max_dist); \
59 	MC_PREP_OP(ext, 0, 16,  16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
60 	MC_PREP_OP(ext, 0, 32,  16, uint16_t, cfg->tc_cfg[1].max_dist); \
61 	MC_PREP_OP(ext, 0, 48,  16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
62 	MC_PREP_OP(ext, 1, 0,   16, uint16_t, cfg->tc_cfg[2].max_dist); \
63 	MC_PREP_OP(ext, 1, 16,  16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
64 	MC_PREP_OP(ext, 1, 32,  16, uint16_t, cfg->tc_cfg[3].max_dist); \
65 	MC_PREP_OP(ext, 1, 48,  16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
66 	MC_PREP_OP(ext, 2, 0,   16, uint16_t, cfg->tc_cfg[4].max_dist); \
67 	MC_PREP_OP(ext, 2, 16,  16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
68 	MC_PREP_OP(ext, 2, 32,  16, uint16_t, cfg->tc_cfg[5].max_dist); \
69 	MC_PREP_OP(ext, 2, 48,  16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
70 	MC_PREP_OP(ext, 3, 0,   16, uint16_t, cfg->tc_cfg[6].max_dist); \
71 	MC_PREP_OP(ext, 3, 16,  16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
72 	MC_PREP_OP(ext, 3, 32,  16, uint16_t, cfg->tc_cfg[7].max_dist); \
73 	MC_PREP_OP(ext, 3, 48,  16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
74 	MC_PREP_OP(ext, 4, 0,   16, uint16_t, \
75 		   cfg->ipr_cfg.max_open_frames_ipv4); \
76 	MC_PREP_OP(ext, 4, 16,  16, uint16_t, \
77 		   cfg->ipr_cfg.max_open_frames_ipv6); \
78 	MC_PREP_OP(ext, 4, 32,  16, uint16_t, \
79 		   cfg->ipr_cfg.max_reass_frm_size); \
80 	MC_PREP_OP(ext, 5, 0,   16, uint16_t, \
81 		   cfg->ipr_cfg.min_frag_size_ipv4); \
82 	MC_PREP_OP(ext, 5, 16,  16, uint16_t, \
83 		   cfg->ipr_cfg.min_frag_size_ipv6); \
84 } while (0)
85 
86 #define DPNI_EXT_EXTENDED_CFG(ext, cfg) \
87 do { \
88 	MC_EXT_OP(ext, 0, 0,   16, uint16_t, cfg->tc_cfg[0].max_dist); \
89 	MC_EXT_OP(ext, 0, 16,  16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
90 	MC_EXT_OP(ext, 0, 32,  16, uint16_t, cfg->tc_cfg[1].max_dist); \
91 	MC_EXT_OP(ext, 0, 48,  16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
92 	MC_EXT_OP(ext, 1, 0,   16, uint16_t, cfg->tc_cfg[2].max_dist); \
93 	MC_EXT_OP(ext, 1, 16,  16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
94 	MC_EXT_OP(ext, 1, 32,  16, uint16_t, cfg->tc_cfg[3].max_dist); \
95 	MC_EXT_OP(ext, 1, 48,  16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
96 	MC_EXT_OP(ext, 2, 0,   16, uint16_t, cfg->tc_cfg[4].max_dist); \
97 	MC_EXT_OP(ext, 2, 16,  16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
98 	MC_EXT_OP(ext, 2, 32,  16, uint16_t, cfg->tc_cfg[5].max_dist); \
99 	MC_EXT_OP(ext, 2, 48,  16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
100 	MC_EXT_OP(ext, 3, 0,   16, uint16_t, cfg->tc_cfg[6].max_dist); \
101 	MC_EXT_OP(ext, 3, 16,  16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
102 	MC_EXT_OP(ext, 3, 32,  16, uint16_t, cfg->tc_cfg[7].max_dist); \
103 	MC_EXT_OP(ext, 3, 48,  16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
104 	MC_EXT_OP(ext, 4, 0,   16, uint16_t, \
105 		  cfg->ipr_cfg.max_open_frames_ipv4); \
106 	MC_EXT_OP(ext, 4, 16,  16, uint16_t, \
107 		  cfg->ipr_cfg.max_open_frames_ipv6); \
108 	MC_EXT_OP(ext, 4, 32,  16, uint16_t, \
109 		  cfg->ipr_cfg.max_reass_frm_size); \
110 	MC_EXT_OP(ext, 5, 0,   16, uint16_t, \
111 		  cfg->ipr_cfg.min_frag_size_ipv4); \
112 	MC_EXT_OP(ext, 5, 16,  16, uint16_t, \
113 		  cfg->ipr_cfg.min_frag_size_ipv6); \
114 } while (0)
115 
116 /*                cmd, param, offset, width, type, arg_name */
117 #define DPNI_CMD_CREATE(cmd, cfg) \
118 do { \
119 	MC_CMD_OP(cmd, 0, 0,	8,  uint8_t,  cfg->adv.max_tcs); \
120 	MC_CMD_OP(cmd, 0, 8,	8,  uint8_t,  cfg->adv.max_senders); \
121 	MC_CMD_OP(cmd, 0, 16,	8,  uint8_t,  cfg->mac_addr[5]); \
122 	MC_CMD_OP(cmd, 0, 24,	8,  uint8_t,  cfg->mac_addr[4]); \
123 	MC_CMD_OP(cmd, 0, 32,	8,  uint8_t,  cfg->mac_addr[3]); \
124 	MC_CMD_OP(cmd, 0, 40,	8,  uint8_t,  cfg->mac_addr[2]); \
125 	MC_CMD_OP(cmd, 0, 48,	8,  uint8_t,  cfg->mac_addr[1]); \
126 	MC_CMD_OP(cmd, 0, 56,	8,  uint8_t,  cfg->mac_addr[0]); \
127 	MC_CMD_OP(cmd, 1, 0,	32, uint32_t, cfg->adv.options); \
128 	MC_CMD_OP(cmd, 2, 0,	8,  uint8_t,  cfg->adv.max_unicast_filters); \
129 	MC_CMD_OP(cmd, 2, 8,	8,  uint8_t,  cfg->adv.max_multicast_filters); \
130 	MC_CMD_OP(cmd, 2, 16,	8,  uint8_t,  cfg->adv.max_vlan_filters); \
131 	MC_CMD_OP(cmd, 2, 24,	8,  uint8_t,  cfg->adv.max_qos_entries); \
132 	MC_CMD_OP(cmd, 2, 32,	8,  uint8_t,  cfg->adv.max_qos_key_size); \
133 	MC_CMD_OP(cmd, 2, 48,	8,  uint8_t,  cfg->adv.max_dist_key_size); \
134 	MC_CMD_OP(cmd, 2, 56,	8,  enum net_prot, cfg->adv.start_hdr); \
135 	MC_CMD_OP(cmd, 4, 48,	8,  uint8_t, cfg->adv.max_policers); \
136 	MC_CMD_OP(cmd, 4, 56,	8,  uint8_t, cfg->adv.max_congestion_ctrl); \
137 	MC_CMD_OP(cmd, 5, 0,	64, uint64_t, cfg->adv.ext_cfg_iova); \
138 } while (0)
139 
140 /*                cmd, param, offset, width, type, arg_name */
141 #define DPNI_CMD_SET_POOLS(cmd, cfg) \
142 do { \
143 	MC_CMD_OP(cmd, 0, 0,  8,  uint8_t,  cfg->num_dpbp); \
144 	MC_CMD_OP(cmd, 0, 8,  1,  int,      cfg->pools[0].backup_pool); \
145 	MC_CMD_OP(cmd, 0, 9,  1,  int,      cfg->pools[1].backup_pool); \
146 	MC_CMD_OP(cmd, 0, 10, 1,  int,      cfg->pools[2].backup_pool); \
147 	MC_CMD_OP(cmd, 0, 11, 1,  int,      cfg->pools[3].backup_pool); \
148 	MC_CMD_OP(cmd, 0, 12, 1,  int,      cfg->pools[4].backup_pool); \
149 	MC_CMD_OP(cmd, 0, 13, 1,  int,      cfg->pools[5].backup_pool); \
150 	MC_CMD_OP(cmd, 0, 14, 1,  int,      cfg->pools[6].backup_pool); \
151 	MC_CMD_OP(cmd, 0, 15, 1,  int,      cfg->pools[7].backup_pool); \
152 	MC_CMD_OP(cmd, 0, 32, 32, int,      cfg->pools[0].dpbp_id); \
153 	MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
154 	MC_CMD_OP(cmd, 1, 0,  32, int,      cfg->pools[1].dpbp_id); \
155 	MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
156 	MC_CMD_OP(cmd, 1, 32, 32, int,      cfg->pools[2].dpbp_id); \
157 	MC_CMD_OP(cmd, 5, 0,  16, uint16_t, cfg->pools[2].buffer_size);\
158 	MC_CMD_OP(cmd, 2, 0,  32, int,      cfg->pools[3].dpbp_id); \
159 	MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
160 	MC_CMD_OP(cmd, 2, 32, 32, int,      cfg->pools[4].dpbp_id); \
161 	MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
162 	MC_CMD_OP(cmd, 3, 0,  32, int,      cfg->pools[5].dpbp_id); \
163 	MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
164 	MC_CMD_OP(cmd, 3, 32, 32, int,      cfg->pools[6].dpbp_id); \
165 	MC_CMD_OP(cmd, 6, 0,  16, uint16_t, cfg->pools[6].buffer_size);\
166 	MC_CMD_OP(cmd, 4, 0,  32, int,      cfg->pools[7].dpbp_id); \
167 	MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
168 } while (0)
169 
170 /*                cmd, param, offset, width, type, arg_name */
171 #define DPNI_CMD_GET_ATTR(cmd, attr) \
172 	MC_CMD_OP(cmd, 6, 0,  64, uint64_t, attr->ext_cfg_iova)
173 
174 /*                cmd, param, offset, width, type, arg_name */
175 #define DPNI_RSP_GET_ATTR(cmd, attr) \
176 do { \
177 	MC_RSP_OP(cmd, 0, 0,  32, int,	    attr->id);\
178 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  attr->max_tcs); \
179 	MC_RSP_OP(cmd, 0, 40, 8,  uint8_t,  attr->max_senders); \
180 	MC_RSP_OP(cmd, 0, 48, 8,  enum net_prot, attr->start_hdr); \
181 	MC_RSP_OP(cmd, 1, 0,  32, uint32_t, attr->options); \
182 	MC_RSP_OP(cmd, 2, 0,  8,  uint8_t,  attr->max_unicast_filters); \
183 	MC_RSP_OP(cmd, 2, 8,  8,  uint8_t,  attr->max_multicast_filters);\
184 	MC_RSP_OP(cmd, 2, 16, 8,  uint8_t,  attr->max_vlan_filters); \
185 	MC_RSP_OP(cmd, 2, 24, 8,  uint8_t,  attr->max_qos_entries); \
186 	MC_RSP_OP(cmd, 2, 32, 8,  uint8_t,  attr->max_qos_key_size); \
187 	MC_RSP_OP(cmd, 2, 40, 8,  uint8_t,  attr->max_dist_key_size); \
188 	MC_RSP_OP(cmd, 4, 48, 8,  uint8_t, attr->max_policers); \
189 	MC_RSP_OP(cmd, 4, 56, 8,  uint8_t, attr->max_congestion_ctrl); \
190 	MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\
191 	MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\
192 } while (0)
193 
194 /*                cmd, param, offset, width, type, arg_name */
195 #define DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg) \
196 do { \
197 	MC_CMD_OP(cmd, 0, 0,  32, uint32_t, cfg->errors); \
198 	MC_CMD_OP(cmd, 0, 32, 4,  enum dpni_error_action, cfg->error_action); \
199 	MC_CMD_OP(cmd, 0, 36, 1,  int,      cfg->set_frame_annotation); \
200 } while (0)
201 
202 /*                cmd, param, offset, width, type, arg_name */
203 #define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \
204 do { \
205 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
206 	MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
207 	MC_RSP_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
208 	MC_RSP_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
209 	MC_RSP_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
210 	MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
211 	MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
212 } while (0)
213 
214 /*                cmd, param, offset, width, type, arg_name */
215 #define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \
216 do { \
217 	MC_CMD_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
218 	MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
219 	MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
220 	MC_CMD_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
221 	MC_CMD_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
222 	MC_CMD_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
223 	MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
224 	MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
225 } while (0)
226 
227 /*                cmd, param, offset, width, type, arg_name */
228 #define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \
229 do { \
230 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
231 	MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
232 	MC_RSP_OP(cmd, 1, 0,  1,  int,      layout->pass_timestamp); \
233 	MC_RSP_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
234 	MC_RSP_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
235 	MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
236 	MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
237 } while (0)
238 
239 /*                cmd, param, offset, width, type, arg_name */
240 #define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \
241 do { \
242 	MC_CMD_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
243 	MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
244 	MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
245 	MC_CMD_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
246 	MC_CMD_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
247 	MC_CMD_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
248 	MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
249 	MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
250 } while (0)
251 
252 /*                cmd, param, offset, width, type, arg_name */
253 #define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
254 do { \
255 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
256 	MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
257 	MC_RSP_OP(cmd, 1, 0,  1,  int,      layout->pass_timestamp); \
258 	MC_RSP_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
259 	MC_RSP_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
260 	MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
261 	MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
262 } while (0)
263 
264 /*                cmd, param, offset, width, type, arg_name */
265 #define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
266 do { \
267 	MC_CMD_OP(cmd, 0, 0,  16, uint16_t, layout->private_data_size); \
268 	MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
269 	MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
270 	MC_CMD_OP(cmd, 1, 0,  1,  int,	    layout->pass_timestamp); \
271 	MC_CMD_OP(cmd, 1, 1,  1,  int,	    layout->pass_parser_result); \
272 	MC_CMD_OP(cmd, 1, 2,  1,  int,	    layout->pass_frame_status); \
273 	MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
274 	MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
275 } while (0)
276 
277 /*                cmd, param, offset, width, type, arg_name */
278 #define DPNI_RSP_GET_QDID(cmd, qdid) \
279 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, qdid)
280 
281 /*                cmd, param, offset, width, type, arg_name */
282 #define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
283 	MC_RSP_OP(cmd, 0, 0,  16, uint16_t, data_offset)
284 
285 /*                cmd, param, offset, width, type, arg_name */
286 #define DPNI_CMD_GET_COUNTER(cmd, counter) \
287 	MC_CMD_OP(cmd, 0, 0,  16, enum dpni_counter, counter)
288 
289 /*                cmd, param, offset, width, type, arg_name */
290 #define DPNI_RSP_GET_COUNTER(cmd, value) \
291 	MC_RSP_OP(cmd, 1, 0,  64, uint64_t, value)
292 
293 /*                cmd, param, offset, width, type, arg_name */
294 #define DPNI_CMD_SET_COUNTER(cmd, counter, value) \
295 do { \
296 	MC_CMD_OP(cmd, 0, 0,  16, enum dpni_counter, counter); \
297 	MC_CMD_OP(cmd, 1, 0,  64, uint64_t, value); \
298 } while (0)
299 
300 /*                cmd, param, offset, width, type, arg_name */
301 #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
302 do { \
303 	MC_CMD_OP(cmd, 1, 0,  32, uint32_t, cfg->rate);\
304 	MC_CMD_OP(cmd, 2, 0,  64, uint64_t, cfg->options);\
305 } while (0)
306 
307 /*                cmd, param, offset, width, type, arg_name */
308 #define DPNI_RSP_GET_LINK_STATE(cmd, state) \
309 do { \
310 	MC_RSP_OP(cmd, 0, 32,  1, int,      state->up);\
311 	MC_RSP_OP(cmd, 1, 0,  32, uint32_t, state->rate);\
312 	MC_RSP_OP(cmd, 2, 0,  64, uint64_t, state->options);\
313 } while (0)
314 
315 
316 
317 /*                cmd, param, offset, width, type, arg_name */
318 #define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
319 do { \
320 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
321 	MC_CMD_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
322 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
323 	MC_CMD_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
324 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
325 	MC_CMD_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
326 } while (0)
327 
328 /*                cmd, param, offset, width, type, arg_name */
329 #define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
330 do { \
331 	MC_RSP_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
332 	MC_RSP_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
333 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
334 	MC_RSP_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
335 	MC_RSP_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
336 	MC_RSP_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
337 } while (0)
338 
339 /*                cmd, param, offset, width, type, arg_name */
340 #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
341 do { \
342 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
343 	MC_CMD_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
344 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
345 	MC_CMD_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
346 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
347 	MC_CMD_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
348 } while (0)
349 
350 /*                cmd, param, offset, width, type, arg_name */
351 #define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
352 do { \
353 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  mac_addr[5]); \
354 	MC_CMD_OP(cmd, 0, 24, 8,  uint8_t,  mac_addr[4]); \
355 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  mac_addr[3]); \
356 	MC_CMD_OP(cmd, 0, 40, 8,  uint8_t,  mac_addr[2]); \
357 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  mac_addr[1]); \
358 	MC_CMD_OP(cmd, 0, 56, 8,  uint8_t,  mac_addr[0]); \
359 } while (0)
360 
361 /*                cmd, param, offset, width, type, arg_name */
362 #define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \
363 do { \
364 	MC_CMD_OP(cmd, 0, 43, 1,  int,	    cfg->l3_chksum_gen);\
365 	MC_CMD_OP(cmd, 0, 44, 1,  int,	    cfg->l4_chksum_gen);\
366 	MC_CMD_OP(cmd, 0, 45, 1,  int,	    cfg->use_common_tx_conf_queue);\
367 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\
368 	MC_CMD_OP(cmd, 2, 0,  32, uint32_t, cfg->options);\
369 } while (0)
370 
371 /*                cmd, param, offset, width, type, arg_name */
372 #define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \
373 	MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id)
374 
375 /*                cmd, param, offset, width, type, arg_name */
376 #define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \
377 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
378 
379 /*                cmd, param, offset, width, type, arg_name */
380 #define DPNI_RSP_GET_TX_FLOW(cmd, attr) \
381 do { \
382 	MC_RSP_OP(cmd, 0, 43, 1,  int,	    attr->l3_chksum_gen);\
383 	MC_RSP_OP(cmd, 0, 44, 1,  int,	    attr->l4_chksum_gen);\
384 	MC_RSP_OP(cmd, 0, 45, 1,  int,	    attr->use_common_tx_conf_queue);\
385 } while (0)
386 
387 /*                cmd, param, offset, width, type, arg_name */
388 #define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \
389 do { \
390 	MC_CMD_OP(cmd, 0, 0,  32, int,      cfg->dest_cfg.dest_id); \
391 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  cfg->dest_cfg.priority);\
392 	MC_CMD_OP(cmd, 0, 40, 2,  enum dpni_dest, cfg->dest_cfg.dest_type);\
393 	MC_CMD_OP(cmd, 0, 42, 1,  int,      cfg->order_preservation_en);\
394 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
395 	MC_CMD_OP(cmd, 1, 0,  64, uint64_t, cfg->user_ctx); \
396 	MC_CMD_OP(cmd, 2, 16, 8,  uint8_t,  tc_id); \
397 	MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->options); \
398 	MC_CMD_OP(cmd, 3, 0,  4,  enum dpni_flc_type, cfg->flc_cfg.flc_type); \
399 	MC_CMD_OP(cmd, 3, 4,  4,  enum dpni_stash_size, \
400 		cfg->flc_cfg.frame_data_size);\
401 	MC_CMD_OP(cmd, 3, 8,  4,  enum dpni_stash_size, \
402 		cfg->flc_cfg.flow_context_size);\
403 	MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
404 	MC_CMD_OP(cmd, 4, 0,  64, uint64_t, cfg->flc_cfg.flow_context);\
405 	MC_CMD_OP(cmd, 5, 0,  32, uint32_t, cfg->tail_drop_threshold); \
406 } while (0)
407 
408 /*                cmd, param, offset, width, type, arg_name */
409 #define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
410 do { \
411 	MC_CMD_OP(cmd, 0, 16, 8,  uint8_t,  tc_id); \
412 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
413 } while (0)
414 
415 /*                cmd, param, offset, width, type, arg_name */
416 #define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
417 do { \
418 	MC_RSP_OP(cmd, 0, 0,  32, int,      attr->dest_cfg.dest_id); \
419 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t,  attr->dest_cfg.priority);\
420 	MC_RSP_OP(cmd, 0, 40, 2,  enum dpni_dest, attr->dest_cfg.dest_type); \
421 	MC_RSP_OP(cmd, 0, 42, 1,  int,      attr->order_preservation_en);\
422 	MC_RSP_OP(cmd, 1, 0,  64, uint64_t, attr->user_ctx); \
423 	MC_RSP_OP(cmd, 2, 0,  32, uint32_t, attr->tail_drop_threshold); \
424 	MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
425 	MC_RSP_OP(cmd, 3, 0,  4,  enum dpni_flc_type, attr->flc_cfg.flc_type); \
426 	MC_RSP_OP(cmd, 3, 4,  4,  enum dpni_stash_size, \
427 		attr->flc_cfg.frame_data_size);\
428 	MC_RSP_OP(cmd, 3, 8,  4,  enum dpni_stash_size, \
429 		attr->flc_cfg.flow_context_size);\
430 	MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
431 	MC_RSP_OP(cmd, 4, 0,  64, uint64_t, attr->flc_cfg.flow_context);\
432 } while (0)
433 
434 #define DPNI_CMD_SET_TX_CONF(cmd, flow_id, cfg) \
435 do { \
436 	MC_CMD_OP(cmd, 0, 32, 8,  uint8_t, cfg->queue_cfg.dest_cfg.priority); \
437 	MC_CMD_OP(cmd, 0, 40, 2,  enum dpni_dest, \
438 		cfg->queue_cfg.dest_cfg.dest_type); \
439 	MC_CMD_OP(cmd, 0, 42, 1,  int, cfg->errors_only); \
440 	MC_CMD_OP(cmd, 0, 46, 1,  int, cfg->queue_cfg.order_preservation_en); \
441 	MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
442 	MC_CMD_OP(cmd, 1, 0,  64, uint64_t, cfg->queue_cfg.user_ctx); \
443 	MC_CMD_OP(cmd, 2, 0,  32, uint32_t, cfg->queue_cfg.options); \
444 	MC_CMD_OP(cmd, 2, 32, 32, int,	    cfg->queue_cfg.dest_cfg.dest_id); \
445 	MC_CMD_OP(cmd, 3, 0,  32, uint32_t, \
446 		cfg->queue_cfg.tail_drop_threshold); \
447 	MC_CMD_OP(cmd, 4, 0,  4,  enum dpni_flc_type, \
448 		cfg->queue_cfg.flc_cfg.flc_type); \
449 	MC_CMD_OP(cmd, 4, 4,  4,  enum dpni_stash_size, \
450 		cfg->queue_cfg.flc_cfg.frame_data_size); \
451 	MC_CMD_OP(cmd, 4, 8,  4,  enum dpni_stash_size, \
452 		cfg->queue_cfg.flc_cfg.flow_context_size); \
453 	MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->queue_cfg.flc_cfg.options); \
454 	MC_CMD_OP(cmd, 5, 0,  64, uint64_t, \
455 		cfg->queue_cfg.flc_cfg.flow_context); \
456 } while (0)
457 
458 #define DPNI_CMD_GET_TX_CONF(cmd, flow_id) \
459 		MC_CMD_OP(cmd, 0, 48, 16, uint16_t,  flow_id)
460 
461 #define DPNI_RSP_GET_TX_CONF(cmd, attr) \
462 do { \
463 	MC_RSP_OP(cmd, 0, 32, 8,  uint8_t, \
464 		  attr->queue_attr.dest_cfg.priority); \
465 	MC_RSP_OP(cmd, 0, 40, 2,  enum dpni_dest, \
466 		attr->queue_attr.dest_cfg.dest_type); \
467 	MC_RSP_OP(cmd, 0, 42, 1,  int, attr->errors_only); \
468 	MC_RSP_OP(cmd, 0, 46, 1,  int, \
469 		  attr->queue_attr.order_preservation_en); \
470 	MC_RSP_OP(cmd, 1, 0,  64, uint64_t, attr->queue_attr.user_ctx); \
471 	MC_RSP_OP(cmd, 2, 32, 32, int,	attr->queue_attr.dest_cfg.dest_id); \
472 	MC_RSP_OP(cmd, 3, 0,  32, uint32_t, \
473 		attr->queue_attr.tail_drop_threshold); \
474 	MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->queue_attr.fqid); \
475 	MC_RSP_OP(cmd, 4, 0,  4,  enum dpni_flc_type, \
476 		attr->queue_attr.flc_cfg.flc_type); \
477 	MC_RSP_OP(cmd, 4, 4,  4,  enum dpni_stash_size, \
478 		attr->queue_attr.flc_cfg.frame_data_size); \
479 	MC_RSP_OP(cmd, 4, 8,  4,  enum dpni_stash_size, \
480 		attr->queue_attr.flc_cfg.flow_context_size); \
481 	MC_RSP_OP(cmd, 4, 32, 32, uint32_t, attr->queue_attr.flc_cfg.options); \
482 	MC_RSP_OP(cmd, 5, 0,  64, uint64_t, \
483 		attr->queue_attr.flc_cfg.flow_context); \
484 } while (0)
485 
486 enum net_prot {
487 	NET_PROT_NONE = 0,
488 	NET_PROT_PAYLOAD,
489 	NET_PROT_ETH,
490 	NET_PROT_VLAN,
491 	NET_PROT_IPV4,
492 	NET_PROT_IPV6,
493 	NET_PROT_IP,
494 	NET_PROT_TCP,
495 	NET_PROT_UDP,
496 	NET_PROT_UDP_LITE,
497 	NET_PROT_IPHC,
498 	NET_PROT_SCTP,
499 	NET_PROT_SCTP_CHUNK_DATA,
500 	NET_PROT_PPPOE,
501 	NET_PROT_PPP,
502 	NET_PROT_PPPMUX,
503 	NET_PROT_PPPMUX_SUBFRM,
504 	NET_PROT_L2TPV2,
505 	NET_PROT_L2TPV3_CTRL,
506 	NET_PROT_L2TPV3_SESS,
507 	NET_PROT_LLC,
508 	NET_PROT_LLC_SNAP,
509 	NET_PROT_NLPID,
510 	NET_PROT_SNAP,
511 	NET_PROT_MPLS,
512 	NET_PROT_IPSEC_AH,
513 	NET_PROT_IPSEC_ESP,
514 	NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
515 	NET_PROT_MACSEC,
516 	NET_PROT_GRE,
517 	NET_PROT_MINENCAP,
518 	NET_PROT_DCCP,
519 	NET_PROT_ICMP,
520 	NET_PROT_IGMP,
521 	NET_PROT_ARP,
522 	NET_PROT_CAPWAP_DATA,
523 	NET_PROT_CAPWAP_CTRL,
524 	NET_PROT_RFC2684,
525 	NET_PROT_ICMPV6,
526 	NET_PROT_FCOE,
527 	NET_PROT_FIP,
528 	NET_PROT_ISCSI,
529 	NET_PROT_GTP,
530 	NET_PROT_USER_DEFINED_L2,
531 	NET_PROT_USER_DEFINED_L3,
532 	NET_PROT_USER_DEFINED_L4,
533 	NET_PROT_USER_DEFINED_L5,
534 	NET_PROT_USER_DEFINED_SHIM1,
535 	NET_PROT_USER_DEFINED_SHIM2,
536 
537 	NET_PROT_DUMMY_LAST
538 };
539 
540 /**
541  * Data Path Network Interface API
542  * Contains initialization APIs and runtime control APIs for DPNI
543  */
544 
545 struct fsl_mc_io;
546 
547 /* General DPNI macros */
548 
549 /* Maximum number of traffic classes */
550 #define DPNI_MAX_TC				8
551 /* Maximum number of buffer pools per DPNI */
552 #define DPNI_MAX_DPBP				8
553 
554 /* All traffic classes considered; see dpni_set_rx_flow() */
555 #define DPNI_ALL_TCS				(uint8_t)(-1)
556 /* All flows within traffic class considered; see dpni_set_rx_flow() */
557 #define DPNI_ALL_TC_FLOWS			(uint16_t)(-1)
558 /* Generate new flow ID; see dpni_set_tx_flow() */
559 #define DPNI_NEW_FLOW_ID			(uint16_t)(-1)
560 /* use for common tx-conf queue; see dpni_set_tx_conf_<x>() */
561 #define DPNI_COMMON_TX_CONF			(uint16_t)(-1)
562 
563 /**
564  * dpni_open() - Open a control session for the specified object
565  * @mc_io:	Pointer to MC portal's I/O object
566  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
567  * @dpni_id:	DPNI unique ID
568  * @token:	Returned token; use in subsequent API calls
569  *
570  * This function can be used to open a control session for an
571  * already created object; an object may have been declared in
572  * the DPL or by calling the dpni_create() function.
573  * This function returns a unique authentication token,
574  * associated with the specific object ID and the specific MC
575  * portal; this token must be used in all subsequent commands for
576  * this specific object.
577  *
578  * Return:	'0' on Success; Error code otherwise.
579  */
580 int dpni_open(struct fsl_mc_io	*mc_io,
581 	      uint32_t		cmd_flags,
582 	      int		dpni_id,
583 	      uint16_t		*token);
584 
585 /**
586  * dpni_close() - Close the control session of the object
587  * @mc_io:	Pointer to MC portal's I/O object
588  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
589  * @token:	Token of DPNI object
590  *
591  * After this function is called, no further operations are
592  * allowed on the object without opening a new control session.
593  *
594  * Return:	'0' on Success; Error code otherwise.
595  */
596 int dpni_close(struct fsl_mc_io	*mc_io,
597 	       uint32_t		cmd_flags,
598 	       uint16_t		token);
599 
600 /* DPNI configuration options */
601 
602 /**
603  * Allow different distribution key profiles for different traffic classes;
604  * if not set, a single key profile is assumed
605  */
606 #define DPNI_OPT_ALLOW_DIST_KEY_PER_TC		0x00000001
607 
608 /**
609  * Disable all non-error transmit confirmation; error frames are reported
610  * back to a common Tx error queue
611  */
612 #define DPNI_OPT_TX_CONF_DISABLED		0x00000002
613 
614 /* Disable per-sender private Tx confirmation/error queue */
615 #define DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED	0x00000004
616 
617 /**
618  * Support distribution based on hashed key;
619  * allows statistical distribution over receive queues in a traffic class
620  */
621 #define DPNI_OPT_DIST_HASH			0x00000010
622 
623 /**
624  * Support distribution based on flow steering;
625  * allows explicit control of distribution over receive queues in a traffic
626  * class
627  */
628 #define DPNI_OPT_DIST_FS			0x00000020
629 
630 /* Unicast filtering support */
631 #define DPNI_OPT_UNICAST_FILTER			0x00000080
632 /* Multicast filtering support */
633 #define DPNI_OPT_MULTICAST_FILTER		0x00000100
634 /* VLAN filtering support */
635 #define DPNI_OPT_VLAN_FILTER			0x00000200
636 /* Support IP reassembly on received packets */
637 #define DPNI_OPT_IPR				0x00000800
638 /* Support IP fragmentation on transmitted packets */
639 #define DPNI_OPT_IPF				0x00001000
640 /* VLAN manipulation support */
641 #define DPNI_OPT_VLAN_MANIPULATION		0x00010000
642 /* Support masking of QoS lookup keys */
643 #define DPNI_OPT_QOS_MASK_SUPPORT		0x00020000
644 /* Support masking of Flow Steering lookup keys */
645 #define DPNI_OPT_FS_MASK_SUPPORT		0x00040000
646 
647 /**
648  * struct dpni_extended_cfg - Structure representing extended DPNI configuration
649  * @tc_cfg: TCs configuration
650  * @ipr_cfg: IP reassembly configuration
651  */
652 struct dpni_extended_cfg {
653 	/**
654 	 * struct tc_cfg - TC configuration
655 	 * @max_dist: Maximum distribution size for Rx traffic class;
656 	 *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
657 	 *	112,128,192,224,256,384,448,512,768,896,1024;
658 	 *	value '0' will be treated as '1'.
659 	 *	other unsupported values will be round down to the nearest
660 	 *	supported value.
661 	 * @max_fs_entries: Maximum FS entries for Rx traffic class;
662 	 *	'0' means no support for this TC;
663 	 */
664 	struct {
665 		uint16_t	max_dist;
666 		uint16_t	max_fs_entries;
667 	} tc_cfg[DPNI_MAX_TC];
668 	/**
669 	 * struct ipr_cfg - Structure representing IP reassembly configuration
670 	 * @max_reass_frm_size: Maximum size of the reassembled frame
671 	 * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
672 	 * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
673 	 * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly
674 	 *		process
675 	 * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly
676 	 *		process
677 	 */
678 	struct {
679 		uint16_t max_reass_frm_size;
680 		uint16_t min_frag_size_ipv4;
681 		uint16_t min_frag_size_ipv6;
682 		uint16_t max_open_frames_ipv4;
683 		uint16_t max_open_frames_ipv6;
684 	} ipr_cfg;
685 };
686 
687 /**
688  * dpni_prepare_extended_cfg() - function prepare extended parameters
689  * @cfg: extended structure
690  * @ext_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
691  *
692  * This function has to be called before dpni_create()
693  */
694 int dpni_prepare_extended_cfg(const struct dpni_extended_cfg	*cfg,
695 			      uint8_t			*ext_cfg_buf);
696 
697 /**
698  * struct dpni_cfg - Structure representing DPNI configuration
699  * @mac_addr: Primary MAC address
700  * @adv: Advanced parameters; default is all zeros;
701  *		use this structure to change default settings
702  */
703 struct dpni_cfg {
704 	uint8_t mac_addr[6];
705 	/**
706 	 * struct adv - Advanced parameters
707 	 * @options: Mask of available options; use 'DPNI_OPT_<X>' values
708 	 * @start_hdr: Selects the packet starting header for parsing;
709 	 *		'NET_PROT_NONE' is treated as default: 'NET_PROT_ETH'
710 	 * @max_senders: Maximum number of different senders; used as the number
711 	 *		of dedicated Tx flows; Non-power-of-2 values are rounded
712 	 *		up to the next power-of-2 value as hardware demands it;
713 	 *		'0' will be treated as '1'
714 	 * @max_tcs: Maximum number of traffic classes (for both Tx and Rx);
715 	 *		'0' will e treated as '1'
716 	 * @max_unicast_filters: Maximum number of unicast filters;
717 	 *			'0' is treated	as '16'
718 	 * @max_multicast_filters: Maximum number of multicast filters;
719 	 *			'0' is treated as '64'
720 	 * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in
721 	 *			the QoS	table; '0' is treated as '64'
722 	 * @max_qos_key_size: Maximum key size for the QoS look-up;
723 	 *			'0' is treated as '24' which is enough for IPv4
724 	 *			5-tuple
725 	 * @max_dist_key_size: Maximum key size for the distribution;
726 	 *		'0' is treated as '24' which is enough for IPv4 5-tuple
727 	 * @max_policers: Maximum number of policers;
728 	 *		should be between '0' and max_tcs
729 	 * @max_congestion_ctrl: Maximum number of congestion control groups
730 	 *		(CGs); covers early drop and congestion notification
731 	 *		requirements;
732 	 *		should be between '0' and ('max_tcs' + 'max_senders')
733 	 * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory
734 	 *		filled with the extended configuration by calling
735 	 *		dpni_prepare_extended_cfg()
736 	 */
737 	struct {
738 		uint32_t		options;
739 		enum net_prot		start_hdr;
740 		uint8_t		max_senders;
741 		uint8_t		max_tcs;
742 		uint8_t		max_unicast_filters;
743 		uint8_t		max_multicast_filters;
744 		uint8_t			max_vlan_filters;
745 		uint8_t		max_qos_entries;
746 		uint8_t		max_qos_key_size;
747 		uint8_t		max_dist_key_size;
748 		uint8_t		max_policers;
749 		uint8_t		max_congestion_ctrl;
750 		uint64_t	ext_cfg_iova;
751 	} adv;
752 };
753 
754 /**
755  * dpni_create() - Create the DPNI object
756  * @mc_io:	Pointer to MC portal's I/O object
757  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
758  * @cfg:	Configuration structure
759  * @token:	Returned token; use in subsequent API calls
760  *
761  * Create the DPNI object, allocate required resources and
762  * perform required initialization.
763  *
764  * The object can be created either by declaring it in the
765  * DPL file, or by calling this function.
766  *
767  * This function returns a unique authentication token,
768  * associated with the specific object ID and the specific MC
769  * portal; this token must be used in all subsequent calls to
770  * this specific object. For objects that are created using the
771  * DPL file, call dpni_open() function to get an authentication
772  * token first.
773  *
774  * Return:	'0' on Success; Error code otherwise.
775  */
776 int dpni_create(struct fsl_mc_io	*mc_io,
777 		uint32_t		cmd_flags,
778 		const struct dpni_cfg	*cfg,
779 		uint16_t		*token);
780 
781 /**
782  * dpni_destroy() - Destroy the DPNI object and release all its resources.
783  * @mc_io:	Pointer to MC portal's I/O object
784  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
785  * @token:	Token of DPNI object
786  *
787  * Return:	'0' on Success; error code otherwise.
788  */
789 int dpni_destroy(struct fsl_mc_io	*mc_io,
790 		 uint32_t		cmd_flags,
791 		 uint16_t		token);
792 
793 /**
794  * struct dpni_pools_cfg - Structure representing buffer pools configuration
795  * @num_dpbp: Number of DPBPs
796  * @pools: Array of buffer pools parameters; The number of valid entries
797  *	must match 'num_dpbp' value
798  */
799 struct dpni_pools_cfg {
800 	uint8_t num_dpbp;
801 	/**
802 	 * struct pools - Buffer pools parameters
803 	 * @dpbp_id: DPBP object ID
804 	 * @buffer_size: Buffer size
805 	 * @backup_pool: Backup pool
806 	 */
807 	struct {
808 		int		dpbp_id;
809 		uint16_t	buffer_size;
810 		int		backup_pool;
811 	} pools[DPNI_MAX_DPBP];
812 };
813 
814 /**
815  * dpni_set_pools() - Set buffer pools configuration
816  * @mc_io:	Pointer to MC portal's I/O object
817  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
818  * @token:	Token of DPNI object
819  * @cfg:	Buffer pools configuration
820  *
821  * mandatory for DPNI operation
822  * warning:Allowed only when DPNI is disabled
823  *
824  * Return:	'0' on Success; Error code otherwise.
825  */
826 int dpni_set_pools(struct fsl_mc_io		*mc_io,
827 		   uint32_t			cmd_flags,
828 		   uint16_t			token,
829 		   const struct dpni_pools_cfg	*cfg);
830 
831 /**
832  * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
833  * @mc_io:	Pointer to MC portal's I/O object
834  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
835  * @token:		Token of DPNI object
836  *
837  * Return:	'0' on Success; Error code otherwise.
838  */
839 int dpni_enable(struct fsl_mc_io	*mc_io,
840 		uint32_t		cmd_flags,
841 		uint16_t		token);
842 
843 /**
844  * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
845  * @mc_io:	Pointer to MC portal's I/O object
846  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
847  * @token:	Token of DPNI object
848  *
849  * Return:	'0' on Success; Error code otherwise.
850  */
851 int dpni_disable(struct fsl_mc_io	*mc_io,
852 		 uint32_t		cmd_flags,
853 		 uint16_t		token);
854 
855 
856 /**
857  * dpni_reset() - Reset the DPNI, returns the object to initial state.
858  * @mc_io:	Pointer to MC portal's I/O object
859  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
860  * @token:	Token of DPNI object
861  *
862  * Return:	'0' on Success; Error code otherwise.
863  */
864 int dpni_reset(struct fsl_mc_io	*mc_io,
865 	       uint32_t		cmd_flags,
866 	       uint16_t		token);
867 
868 /**
869  * struct dpni_attr - Structure representing DPNI attributes
870  * @id: DPNI object ID
871  * @version: DPNI version
872  * @start_hdr: Indicates the packet starting header for parsing
873  * @options: Mask of available options; reflects the value as was given in
874  *		object's creation
875  * @max_senders: Maximum number of different senders; used as the number
876  *		of dedicated Tx flows;
877  * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
878  * @max_unicast_filters: Maximum number of unicast filters
879  * @max_multicast_filters: Maximum number of multicast filters
880  * @max_vlan_filters: Maximum number of VLAN filters
881  * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
882  * @max_qos_key_size: Maximum key size for the QoS look-up
883  * @max_dist_key_size: Maximum key size for the distribution look-up
884  * @max_policers: Maximum number of policers;
885  * @max_congestion_ctrl: Maximum number of congestion control groups (CGs);
886  * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory;
887  *	call dpni_extract_extended_cfg() to extract the extended configuration
888  */
889 struct dpni_attr {
890 	int id;
891 	/**
892 	 * struct version - DPNI version
893 	 * @major: DPNI major version
894 	 * @minor: DPNI minor version
895 	 */
896 	struct {
897 		uint16_t major;
898 		uint16_t minor;
899 	} version;
900 	enum net_prot start_hdr;
901 	uint32_t options;
902 	uint8_t max_senders;
903 	uint8_t max_tcs;
904 	uint8_t max_unicast_filters;
905 	uint8_t max_multicast_filters;
906 	uint8_t max_vlan_filters;
907 	uint8_t max_qos_entries;
908 	uint8_t max_qos_key_size;
909 	uint8_t max_dist_key_size;
910 	uint8_t max_policers;
911 	uint8_t max_congestion_ctrl;
912 	uint64_t	ext_cfg_iova;
913 };
914 
915 /**
916  * dpni_get_attributes() - Retrieve DPNI attributes.
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  * @attr:	Object's attributes
921  *
922  * Return:	'0' on Success; Error code otherwise.
923  */
924 int dpni_get_attributes(struct fsl_mc_io	*mc_io,
925 			uint32_t		cmd_flags,
926 			uint16_t		token,
927 			struct dpni_attr	*attr);
928 
929 /**
930  * dpni_extract_extended_cfg() - extract the extended parameters
931  * @cfg: extended structure
932  * @ext_cfg_buf: 256 bytes of DMA-able memory
933  *
934  * This function has to be called after dpni_get_attributes()
935  */
936 int dpni_extract_extended_cfg(struct dpni_extended_cfg	*cfg,
937 			      const uint8_t		*ext_cfg_buf);
938 
939 /**
940  * DPNI errors
941  */
942 
943 /**
944  * Extract out of frame header error
945  */
946 #define DPNI_ERROR_EOFHE	0x00020000
947 /**
948  * Frame length error
949  */
950 #define DPNI_ERROR_FLE		0x00002000
951 /**
952  * Frame physical error
953  */
954 #define DPNI_ERROR_FPE		0x00001000
955 /**
956  * Parsing header error
957  */
958 #define DPNI_ERROR_PHE		0x00000020
959 /**
960  * Parser L3 checksum error
961  */
962 #define DPNI_ERROR_L3CE		0x00000004
963 /**
964  * Parser L3 checksum error
965  */
966 #define DPNI_ERROR_L4CE		0x00000001
967 
968 /**
969  * enum dpni_error_action - Defines DPNI behavior for errors
970  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
971  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
972  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
973  */
974 enum dpni_error_action {
975 	DPNI_ERROR_ACTION_DISCARD = 0,
976 	DPNI_ERROR_ACTION_CONTINUE = 1,
977 	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
978 };
979 
980 /**
981  * struct dpni_error_cfg - Structure representing DPNI errors treatment
982  * @errors: Errors mask; use 'DPNI_ERROR__<X>
983  * @error_action: The desired action for the errors mask
984  * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
985  *		status (FAS); relevant only for the non-discard action
986  */
987 struct dpni_error_cfg {
988 	uint32_t		errors;
989 	enum dpni_error_action	error_action;
990 	int			set_frame_annotation;
991 };
992 
993 /**
994  * dpni_set_errors_behavior() - Set errors behavior
995  * @mc_io:	Pointer to MC portal's I/O object
996  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
997  * @token:	Token of DPNI object
998  * @cfg:	Errors configuration
999  *
1000  * this function may be called numerous times with different
1001  * error masks
1002  *
1003  * Return:	'0' on Success; Error code otherwise.
1004  */
1005 int dpni_set_errors_behavior(struct fsl_mc_io		*mc_io,
1006 			     uint32_t			cmd_flags,
1007 			     uint16_t			token,
1008 			     struct dpni_error_cfg	*cfg);
1009 
1010 /* DPNI buffer layout modification options */
1011 
1012 /* Select to modify the time-stamp setting */
1013 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
1014 /* Select to modify the parser-result setting; not applicable for Tx */
1015 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
1016 /* Select to modify the frame-status setting */
1017 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
1018 /* Select to modify the private-data-size setting */
1019 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
1020 /* Select to modify the data-alignment setting */
1021 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
1022 /* Select to modify the data-head-room setting */
1023 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
1024 /*!< Select to modify the data-tail-room setting */
1025 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
1026 
1027 /**
1028  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
1029  * @options: Flags representing the suggested modifications to the buffer
1030  *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
1031  * @pass_timestamp: Pass timestamp value
1032  * @pass_parser_result: Pass parser results
1033  * @pass_frame_status: Pass frame status
1034  * @private_data_size: Size kept for private data (in bytes)
1035  * @data_align: Data alignment
1036  * @data_head_room: Data head room
1037  * @data_tail_room: Data tail room
1038  */
1039 struct dpni_buffer_layout {
1040 	uint32_t options;
1041 	int pass_timestamp;
1042 	int pass_parser_result;
1043 	int pass_frame_status;
1044 	uint16_t private_data_size;
1045 	uint16_t data_align;
1046 	uint16_t data_head_room;
1047 	uint16_t data_tail_room;
1048 };
1049 
1050 /**
1051  * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
1052  * @mc_io:	Pointer to MC portal's I/O object
1053  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1054  * @token:	Token of DPNI object
1055  * @layout:	Returns buffer layout attributes
1056  *
1057  * Return:	'0' on Success; Error code otherwise.
1058  */
1059 int dpni_get_rx_buffer_layout(struct fsl_mc_io		*mc_io,
1060 			      uint32_t			cmd_flags,
1061 			      uint16_t			token,
1062 			      struct dpni_buffer_layout	*layout);
1063 
1064 /**
1065  * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration.
1066  * @mc_io:	Pointer to MC portal's I/O object
1067  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1068  * @token:	Token of DPNI object
1069  * @layout:	Buffer layout configuration
1070  *
1071  * Return:	'0' on Success; Error code otherwise.
1072  *
1073  * @warning	Allowed only when DPNI is disabled
1074  */
1075 int dpni_set_rx_buffer_layout(struct fsl_mc_io			*mc_io,
1076 			      uint32_t				cmd_flags,
1077 			      uint16_t				token,
1078 			      const struct dpni_buffer_layout	*layout);
1079 
1080 /**
1081  * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
1082  * @mc_io:	Pointer to MC portal's I/O object
1083  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1084  * @token:	Token of DPNI object
1085  * @layout:	Returns buffer layout attributes
1086  *
1087  * Return:	'0' on Success; Error code otherwise.
1088  */
1089 int dpni_get_tx_buffer_layout(struct fsl_mc_io		*mc_io,
1090 			      uint32_t			cmd_flags,
1091 			      uint16_t			token,
1092 			      struct dpni_buffer_layout	*layout);
1093 
1094 /**
1095  * dpni_set_tx_buffer_layout() - Set Tx buffer layout configuration.
1096  * @mc_io:	Pointer to MC portal's I/O object
1097  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1098  * @token:	Token of DPNI object
1099  * @layout:	Buffer layout configuration
1100  *
1101  * Return:	'0' on Success; Error code otherwise.
1102  *
1103  * @warning	Allowed only when DPNI is disabled
1104  */
1105 int dpni_set_tx_buffer_layout(struct fsl_mc_io			*mc_io,
1106 			      uint32_t				cmd_flags,
1107 			      uint16_t				token,
1108 			      const struct dpni_buffer_layout	*layout);
1109 
1110 /**
1111  * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
1112  *				attributes.
1113  * @mc_io:	Pointer to MC portal's I/O object
1114  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1115  * @token:	Token of DPNI object
1116  * @layout:	Returns buffer layout attributes
1117  *
1118  * Return:	'0' on Success; Error code otherwise.
1119  */
1120 int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io		*mc_io,
1121 				   uint32_t			cmd_flags,
1122 				   uint16_t			token,
1123 				   struct dpni_buffer_layout	*layout);
1124 
1125 /**
1126  * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
1127  *					configuration.
1128  * @mc_io:	Pointer to MC portal's I/O object
1129  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1130  * @token:	Token of DPNI object
1131  * @layout:	Buffer layout configuration
1132  *
1133  * Return:	'0' on Success; Error code otherwise.
1134  *
1135  * @warning	Allowed only when DPNI is disabled
1136  */
1137 int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io		   *mc_io,
1138 				   uint32_t			   cmd_flags,
1139 				   uint16_t			   token,
1140 				   const struct dpni_buffer_layout *layout);
1141 
1142 /**
1143  * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
1144  *			for enqueue operations
1145  * @mc_io:	Pointer to MC portal's I/O object
1146  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1147  * @token:	Token of DPNI object
1148  * @qdid:	Returned virtual QDID value that should be used as an argument
1149  *			in all enqueue operations
1150  *
1151  * Return:	'0' on Success; Error code otherwise.
1152  */
1153 int dpni_get_qdid(struct fsl_mc_io	*mc_io,
1154 		  uint32_t		cmd_flags,
1155 		  uint16_t		token,
1156 		  uint16_t		*qdid);
1157 
1158 /**
1159  * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
1160  * @mc_io:	Pointer to MC portal's I/O object
1161  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1162  * @token:	Token of DPNI object
1163  * @data_offset: Tx data offset (from start of buffer)
1164  *
1165  * Return:	'0' on Success; Error code otherwise.
1166  */
1167 int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
1168 			    uint32_t		cmd_flags,
1169 			    uint16_t		token,
1170 			    uint16_t		*data_offset);
1171 
1172 /**
1173  * enum dpni_counter - DPNI counter types
1174  * @DPNI_CNT_ING_FRAME: Counts ingress frames
1175  * @DPNI_CNT_ING_BYTE: Counts ingress bytes
1176  * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
1177  *		'drop' setting
1178  * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
1179  * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
1180  * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
1181  * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
1182  * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
1183  * @DPNI_CNT_EGR_FRAME: Counts egress frames
1184  * @DPNI_CNT_EGR_BYTE: Counts egress bytes
1185  * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
1186  */
1187 enum dpni_counter {
1188 	DPNI_CNT_ING_FRAME = 0x0,
1189 	DPNI_CNT_ING_BYTE = 0x1,
1190 	DPNI_CNT_ING_FRAME_DROP = 0x2,
1191 	DPNI_CNT_ING_FRAME_DISCARD = 0x3,
1192 	DPNI_CNT_ING_MCAST_FRAME = 0x4,
1193 	DPNI_CNT_ING_MCAST_BYTE = 0x5,
1194 	DPNI_CNT_ING_BCAST_FRAME = 0x6,
1195 	DPNI_CNT_ING_BCAST_BYTES = 0x7,
1196 	DPNI_CNT_EGR_FRAME = 0x8,
1197 	DPNI_CNT_EGR_BYTE = 0x9,
1198 	DPNI_CNT_EGR_FRAME_DISCARD = 0xa
1199 };
1200 
1201 /**
1202  * dpni_get_counter() - Read a specific DPNI counter
1203  * @mc_io:	Pointer to MC portal's I/O object
1204  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1205  * @token:	Token of DPNI object
1206  * @counter:	The requested counter
1207  * @value:	Returned counter's current value
1208  *
1209  * Return:	'0' on Success; Error code otherwise.
1210  */
1211 int dpni_get_counter(struct fsl_mc_io	*mc_io,
1212 		     uint32_t		cmd_flags,
1213 		     uint16_t		token,
1214 		     enum dpni_counter	counter,
1215 		     uint64_t		*value);
1216 
1217 /**
1218  * dpni_set_counter() - Set (or clear) a specific DPNI counter
1219  * @mc_io:	Pointer to MC portal's I/O object
1220  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1221  * @token:	Token of DPNI object
1222  * @counter:	The requested counter
1223  * @value:	New counter value; typically pass '0' for resetting
1224  *			the counter.
1225  *
1226  * Return:	'0' on Success; Error code otherwise.
1227  */
1228 int dpni_set_counter(struct fsl_mc_io	*mc_io,
1229 		     uint32_t		cmd_flags,
1230 		     uint16_t		token,
1231 		     enum dpni_counter	counter,
1232 		     uint64_t		value);
1233 
1234 /* Enable auto-negotiation */
1235 #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
1236 /* Enable half-duplex mode */
1237 #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
1238 /* Enable pause frames */
1239 #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
1240 /* Enable a-symmetric pause frames */
1241 #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
1242 
1243 /**
1244  * struct - Structure representing DPNI link configuration
1245  * @rate: Rate
1246  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
1247  */
1248 struct dpni_link_cfg {
1249 	uint32_t rate;
1250 	uint64_t options;
1251 };
1252 
1253 /**
1254  * dpni_set_link_cfg() - set the link configuration.
1255  * @mc_io:	Pointer to MC portal's I/O object
1256  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1257  * @token:	Token of DPNI object
1258  * @cfg:	Link configuration
1259  *
1260  * Return:	'0' on Success; Error code otherwise.
1261  */
1262 int dpni_set_link_cfg(struct fsl_mc_io			*mc_io,
1263 		      uint32_t				cmd_flags,
1264 		      uint16_t				token,
1265 		      const struct dpni_link_cfg	*cfg);
1266 
1267 /**
1268  * struct dpni_link_state - Structure representing DPNI link state
1269  * @rate: Rate
1270  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
1271  * @up: Link state; '0' for down, '1' for up
1272  */
1273 struct dpni_link_state {
1274 	uint32_t rate;
1275 	uint64_t options;
1276 	int up;
1277 };
1278 
1279 /**
1280  * dpni_get_link_state() - Return the link state (either up or down)
1281  * @mc_io:	Pointer to MC portal's I/O object
1282  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1283  * @token:	Token of DPNI object
1284  * @state:	Returned link state;
1285  *
1286  * Return:	'0' on Success; Error code otherwise.
1287  */
1288 int dpni_get_link_state(struct fsl_mc_io	*mc_io,
1289 			uint32_t		cmd_flags,
1290 			uint16_t		token,
1291 			struct dpni_link_state	*state);
1292 
1293 /**
1294  * dpni_set_primary_mac_addr() - Set the primary MAC address
1295  * @mc_io:	Pointer to MC portal's I/O object
1296  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1297  * @token:	Token of DPNI object
1298  * @mac_addr:	MAC address to set as primary address
1299  *
1300  * Return:	'0' on Success; Error code otherwise.
1301  */
1302 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
1303 			      uint32_t		cmd_flags,
1304 			      uint16_t		token,
1305 			      const uint8_t	mac_addr[6]);
1306 
1307 /**
1308  * dpni_get_primary_mac_addr() - Get the primary MAC address
1309  * @mc_io:	Pointer to MC portal's I/O object
1310  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1311  * @token:	Token of DPNI object
1312  * @mac_addr:	Returned MAC address
1313  *
1314  * Return:	'0' on Success; Error code otherwise.
1315  */
1316 int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
1317 			      uint32_t		cmd_flags,
1318 			      uint16_t		token,
1319 			      uint8_t		mac_addr[6]);
1320 
1321 /**
1322  * dpni_add_mac_addr() - Add MAC address filter
1323  * @mc_io:	Pointer to MC portal's I/O object
1324  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1325  * @token:	Token of DPNI object
1326  * @mac_addr:	MAC address to add
1327  *
1328  * Return:	'0' on Success; Error code otherwise.
1329  */
1330 int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
1331 		      uint32_t		cmd_flags,
1332 		      uint16_t		token,
1333 		      const uint8_t	mac_addr[6]);
1334 
1335 /**
1336  * dpni_remove_mac_addr() - Remove MAC address filter
1337  * @mc_io:	Pointer to MC portal's I/O object
1338  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1339  * @token:	Token of DPNI object
1340  * @mac_addr:	MAC address to remove
1341  *
1342  * Return:	'0' on Success; Error code otherwise.
1343  */
1344 int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
1345 			 uint32_t		cmd_flags,
1346 			 uint16_t		token,
1347 			 const uint8_t		mac_addr[6]);
1348 
1349 /**
1350  * enum dpni_dest - DPNI destination types
1351  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
1352  *		does not generate FQDAN notifications; user is expected to
1353  *		dequeue from the queue based on polling or other user-defined
1354  *		method
1355  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
1356  *		notifications to the specified DPIO; user is expected to dequeue
1357  *		from the queue only after notification is received
1358  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
1359  *		FQDAN notifications, but is connected to the specified DPCON
1360  *		object; user is expected to dequeue from the DPCON channel
1361  */
1362 enum dpni_dest {
1363 	DPNI_DEST_NONE = 0,
1364 	DPNI_DEST_DPIO = 1,
1365 	DPNI_DEST_DPCON = 2
1366 };
1367 
1368 /**
1369  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
1370  * @dest_type: Destination type
1371  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
1372  * @priority: Priority selection within the DPIO or DPCON channel; valid values
1373  *		are 0-1 or 0-7, depending on the number of priorities in that
1374  *		channel; not relevant for 'DPNI_DEST_NONE' option
1375  */
1376 struct dpni_dest_cfg {
1377 	enum dpni_dest dest_type;
1378 	int dest_id;
1379 	uint8_t priority;
1380 };
1381 
1382 /**
1383  * enum dpni_flc_type - DPNI FLC types
1384  * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
1385  * @DPNI_FLC_STASH: select the FLC to be used for stash control
1386  */
1387 enum dpni_flc_type {
1388 	DPNI_FLC_USER_DEFINED = 0,
1389 	DPNI_FLC_STASH = 1,
1390 };
1391 
1392 /**
1393  * enum dpni_stash_size - DPNI FLC stashing size
1394  * @DPNI_STASH_SIZE_0B: no stash
1395  * @DPNI_STASH_SIZE_64B: stashes 64 bytes
1396  * @DPNI_STASH_SIZE_128B: stashes 128 bytes
1397  * @DPNI_STASH_SIZE_192B: stashes 192 bytes
1398  */
1399 enum dpni_stash_size {
1400 	DPNI_STASH_SIZE_0B = 0,
1401 	DPNI_STASH_SIZE_64B = 1,
1402 	DPNI_STASH_SIZE_128B = 2,
1403 	DPNI_STASH_SIZE_192B = 3,
1404 };
1405 
1406 /* DPNI FLC stash options */
1407 
1408 /* stashes the whole annotation area (up to 192 bytes) */
1409 #define DPNI_FLC_STASH_FRAME_ANNOTATION	0x00000001
1410 
1411 /**
1412  * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
1413  * @flc_type: FLC type
1414  * @options: Mask of available options;
1415  *	use 'DPNI_FLC_STASH_<X>' values
1416  * @frame_data_size: Size of frame data to be stashed
1417  * @flow_context_size: Size of flow context to be stashed
1418  * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
1419  *			this value will be provided in the frame descriptor
1420  *			(FD[FLC])
1421  *		  2. In case flc_type is 'DPNI_FLC_STASH':
1422  *			this value will be I/O virtual address of the
1423  *			flow-context;
1424  *			Must be cacheline-aligned and DMA-able memory
1425  */
1426 struct dpni_flc_cfg {
1427 	enum dpni_flc_type flc_type;
1428 	uint32_t options;
1429 	enum dpni_stash_size frame_data_size;
1430 	enum dpni_stash_size flow_context_size;
1431 	uint64_t flow_context;
1432 };
1433 
1434 /* DPNI queue modification options */
1435 
1436 /* Select to modify the user's context associated with the queue */
1437 #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
1438 /* Select to modify the queue's destination */
1439 #define DPNI_QUEUE_OPT_DEST		0x00000002
1440 /** Select to modify the flow-context parameters;
1441  * not applicable for Tx-conf/Err queues as the FD comes from the user
1442  */
1443 #define DPNI_QUEUE_OPT_FLC		0x00000004
1444 /* Select to modify the queue's order preservation */
1445 #define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008
1446 /* Select to modify the queue's tail-drop threshold */
1447 #define DPNI_QUEUE_OPT_TAILDROP_THRESHOLD 0x00000010
1448 
1449 /**
1450  * struct dpni_queue_cfg - Structure representing queue configuration
1451  * @options: Flags representing the suggested modifications to the queue;
1452  *		Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
1453  * @user_ctx: User context value provided in the frame descriptor of each
1454  *		dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
1455  *		is contained in 'options'
1456  * @dest_cfg: Queue destination parameters;
1457  *		valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
1458  * @flc_cfg: Flow context configuration; in case the TC's distribution
1459  *		is either NONE or HASH the FLC's settings of flow#0 are used.
1460  *		in the case of FS (flow-steering) the flow's FLC settings
1461  *		are used.
1462  *		valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
1463  * @order_preservation_en: enable/disable order preservation;
1464  *		valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained
1465  *		in 'options'
1466  * @tail_drop_threshold: set the queue's tail drop threshold in bytes;
1467  *		'0' value disable the threshold; maximum value is 0xE000000;
1468  *		valid only if 'DPNI_QUEUE_OPT_TAILDROP_THRESHOLD' is contained
1469  *		in 'options'
1470  */
1471 struct dpni_queue_cfg {
1472 	uint32_t options;
1473 	uint64_t user_ctx;
1474 	struct dpni_dest_cfg dest_cfg;
1475 	struct dpni_flc_cfg flc_cfg;
1476 	int order_preservation_en;
1477 	uint32_t tail_drop_threshold;
1478 };
1479 
1480 /**
1481  * struct dpni_queue_attr - Structure representing queue attributes
1482  * @user_ctx: User context value provided in the frame descriptor of each
1483  *	dequeued frame
1484  * @dest_cfg: Queue destination configuration
1485  * @flc_cfg: Flow context configuration
1486  * @order_preservation_en: enable/disable order preservation
1487  * @tail_drop_threshold: queue's tail drop threshold in bytes;
1488  * @fqid: Virtual fqid value to be used for dequeue operations
1489  */
1490 struct dpni_queue_attr {
1491 	uint64_t user_ctx;
1492 	struct dpni_dest_cfg dest_cfg;
1493 	struct dpni_flc_cfg flc_cfg;
1494 	int order_preservation_en;
1495 	uint32_t tail_drop_threshold;
1496 	uint32_t fqid;
1497 };
1498 
1499 /* DPNI Tx flow modification options */
1500 
1501 /* Select to modify the settings for dedicate Tx confirmation/error */
1502 #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR	0x00000001
1503 /*!< Select to modify the L3 checksum generation setting */
1504 #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN	0x00000010
1505 /*!< Select to modify the L4 checksum generation setting */
1506 #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN	0x00000020
1507 
1508 /**
1509  * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
1510  * @options: Flags representing the suggested modifications to the Tx flow;
1511  *	Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
1512  * @use_common_tx_conf_queue: Set to '1' to use the common (default) Tx
1513  *	confirmation and error queue; Set to '0' to use the private
1514  *	Tx confirmation and error queue; valid only if
1515  *	'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' wasn't set at DPNI creation
1516  *	and 'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in 'options'
1517  * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
1518  *	valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in 'options'
1519  * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
1520  *	valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in 'options'
1521  */
1522 struct dpni_tx_flow_cfg {
1523 	uint32_t	options;
1524 	int		use_common_tx_conf_queue;
1525 	int		l3_chksum_gen;
1526 	int		l4_chksum_gen;
1527 };
1528 
1529 /**
1530  * dpni_set_tx_flow() - Set Tx flow configuration
1531  * @mc_io:	Pointer to MC portal's I/O object
1532  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1533  * @token:	Token of DPNI object
1534  * @flow_id:	Provides (or returns) the sender's flow ID;
1535  *	for each new sender set (*flow_id) to 'DPNI_NEW_FLOW_ID' to generate
1536  *	a new flow_id;	this ID should be used as the QDBIN argument
1537  *	in enqueue operations
1538  * @cfg:	Tx flow configuration
1539  *
1540  * Return:	'0' on Success; Error code otherwise.
1541  */
1542 int dpni_set_tx_flow(struct fsl_mc_io			*mc_io,
1543 		     uint32_t				cmd_flags,
1544 		     uint16_t				token,
1545 		     uint16_t				*flow_id,
1546 		     const struct dpni_tx_flow_cfg	*cfg);
1547 
1548 /**
1549  * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
1550  * @use_common_tx_conf_queue: '1' if using common (default) Tx confirmation and
1551  *	error queue; '0' if using private Tx confirmation and error queue
1552  * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
1553  * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
1554  */
1555 struct dpni_tx_flow_attr {
1556 	int	use_common_tx_conf_queue;
1557 	int	l3_chksum_gen;
1558 	int	l4_chksum_gen;
1559 };
1560 
1561 /**
1562  * dpni_get_tx_flow() - Get Tx flow attributes
1563  * @mc_io:	Pointer to MC portal's I/O object
1564  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1565  * @token:	Token of DPNI object
1566  * @flow_id:	The sender's flow ID, as returned by the
1567  *	dpni_set_tx_flow() function
1568  * @attr:	Returned Tx flow attributes
1569  *
1570  * Return:	'0' on Success; Error code otherwise.
1571  */
1572 int dpni_get_tx_flow(struct fsl_mc_io		*mc_io,
1573 		     uint32_t			cmd_flags,
1574 		     uint16_t			token,
1575 		     uint16_t			flow_id,
1576 		     struct dpni_tx_flow_attr	*attr);
1577 
1578 /**
1579  * struct dpni_tx_conf_cfg - Structure representing Tx conf configuration
1580  * @errors_only: Set to '1' to report back only error frames;
1581  *	Set to '0' to confirm transmission/error for all transmitted frames;
1582  * @queue_cfg: Queue configuration
1583  */
1584 struct dpni_tx_conf_cfg {
1585 	int			errors_only;
1586 	struct dpni_queue_cfg	queue_cfg;
1587 };
1588 
1589 /**
1590  * dpni_set_tx_conf() - Set Tx confirmation and error queue configuration
1591  * @mc_io:	Pointer to MC portal's I/O object
1592  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1593  * @token:	Token of DPNI object
1594  * @flow_id:	The sender's flow ID, as returned by the
1595  *	dpni_set_tx_flow() function;
1596  *	use 'DPNI_COMMON_TX_CONF' for common tx-conf
1597  * @cfg:	Queue configuration
1598  *
1599  * If either 'DPNI_OPT_TX_CONF_DISABLED' or
1600  * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
1601  * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
1602  * i.e. only serve the common tx-conf-err queue;
1603  * if 'DPNI_OPT_TX_CONF_DISABLED' was selected, only error frames are reported
1604  * back - successfully transmitted frames are not confirmed. Otherwise, all
1605  * transmitted frames are sent for confirmation.
1606  *
1607  * Return:	'0' on Success; Error code otherwise.
1608  */
1609 int dpni_set_tx_conf(struct fsl_mc_io	*mc_io,
1610 		     uint32_t		cmd_flags,
1611 		     uint16_t		token,
1612 		     uint16_t		flow_id,
1613 		     const struct dpni_tx_conf_cfg	*cfg);
1614 
1615 /**
1616  * struct dpni_tx_conf_attr - Structure representing Tx conf attributes
1617  * @errors_only: '1' if only error frames are reported back; '0' if all
1618  *		transmitted frames are confirmed
1619  * @queue_attr: Queue attributes
1620  */
1621 struct dpni_tx_conf_attr {
1622 	int			errors_only;
1623 	struct dpni_queue_attr	queue_attr;
1624 };
1625 
1626 /**
1627  * dpni_get_tx_conf() - Get Tx confirmation and error queue attributes
1628  * @mc_io:	Pointer to MC portal's I/O object
1629  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1630  * @token:	Token of DPNI object
1631  * @flow_id:	The sender's flow ID, as returned by the
1632  *	dpni_set_tx_flow() function;
1633  *	use 'DPNI_COMMON_TX_CONF' for common tx-conf
1634  * @attr:	Returned tx-conf attributes
1635  *
1636  * If either 'DPNI_OPT_TX_CONF_DISABLED' or
1637  * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
1638  * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
1639  * i.e. only serve the common tx-conf-err queue;
1640  *
1641  * Return:	'0' on Success; Error code otherwise.
1642  */
1643 int dpni_get_tx_conf(struct fsl_mc_io	*mc_io,
1644 		     uint32_t		cmd_flags,
1645 		     uint16_t		token,
1646 		     uint16_t		flow_id,
1647 		     struct dpni_tx_conf_attr	*attr);
1648 /**
1649  * dpni_set_rx_flow() - Set Rx flow configuration
1650  * @mc_io:	Pointer to MC portal's I/O object
1651  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1652  * @token:	Token of DPNI object
1653  * @tc_id:	Traffic class selection (0-7);
1654  *			use 'DPNI_ALL_TCS' to set all TCs and all flows
1655  * @flow_id:	Rx flow id within the traffic class; use
1656  *			'DPNI_ALL_TC_FLOWS' to set all flows within
1657  *			this tc_id; ignored if tc_id is set to
1658  *			'DPNI_ALL_TCS';
1659  * @cfg:	Rx flow configuration
1660  *
1661  * Return:	'0' on Success; Error code otherwise.
1662  */
1663 int dpni_set_rx_flow(struct fsl_mc_io			*mc_io,
1664 		     uint32_t				cmd_flags,
1665 		     uint16_t				token,
1666 		     uint8_t				tc_id,
1667 		     uint16_t				flow_id,
1668 		     const struct dpni_queue_cfg	*cfg);
1669 
1670 /**
1671  * dpni_get_rx_flow() -	Get Rx flow attributes
1672  * @mc_io:	Pointer to MC portal's I/O object
1673  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1674  * @token:	Token of DPNI object
1675  * @tc_id:	Traffic class selection (0-7)
1676  * @flow_id:	Rx flow id within the traffic class
1677  * @attr:	Returned Rx flow attributes
1678  *
1679  * Return:	'0' on Success; Error code otherwise.
1680  */
1681 int dpni_get_rx_flow(struct fsl_mc_io		*mc_io,
1682 		     uint32_t			cmd_flags,
1683 		     uint16_t			token,
1684 		     uint8_t			tc_id,
1685 		     uint16_t			flow_id,
1686 		     struct dpni_queue_attr	*attr);
1687 
1688 #endif /* _FSL_DPNI_H */
1689