2 * Copyright (C) 2013-2015 Freescale Semiconductor
4 * SPDX-License-Identifier: GPL-2.0+
10 #define DPNI_VER_MAJOR 5
11 #define DPNI_VER_MINOR 1
14 #define DPNI_CMDID_OPEN 0x801
15 #define DPNI_CMDID_CLOSE 0x800
16 #define DPNI_CMDID_CREATE 0x901
17 #define DPNI_CMDID_DESTROY 0x900
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
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
32 #define DPNI_CMDID_GET_QDID 0x210
33 #define DPNI_CMDID_GET_TX_DATA_OFFSET 0x212
34 #define DPNI_CMDID_GET_COUNTER 0x213
35 #define DPNI_CMDID_SET_COUNTER 0x214
36 #define DPNI_CMDID_GET_LINK_STATE 0x215
37 #define DPNI_CMDID_SET_LINK_CFG 0x21A
39 #define DPNI_CMDID_SET_PRIM_MAC 0x224
40 #define DPNI_CMDID_GET_PRIM_MAC 0x225
41 #define DPNI_CMDID_ADD_MAC_ADDR 0x226
42 #define DPNI_CMDID_REMOVE_MAC_ADDR 0x227
44 #define DPNI_CMDID_SET_TX_FLOW 0x236
45 #define DPNI_CMDID_GET_TX_FLOW 0x237
46 #define DPNI_CMDID_SET_RX_FLOW 0x238
47 #define DPNI_CMDID_GET_RX_FLOW 0x239
49 /* cmd, param, offset, width, type, arg_name */
50 #define DPNI_CMD_OPEN(cmd, dpni_id) \
51 MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
53 /* cmd, param, offset, width, type, arg_name */
54 #define DPNI_CMD_CREATE(cmd, cfg) \
56 MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->adv.max_tcs); \
57 MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->adv.max_senders); \
58 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]); \
59 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]); \
60 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]); \
61 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]); \
62 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]); \
63 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]); \
64 MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->adv.options); \
65 MC_CMD_OP(cmd, 2, 0, 8, uint8_t, cfg->adv.max_unicast_filters); \
66 MC_CMD_OP(cmd, 2, 8, 8, uint8_t, cfg->adv.max_multicast_filters); \
67 MC_CMD_OP(cmd, 2, 16, 8, uint8_t, cfg->adv.max_vlan_filters); \
68 MC_CMD_OP(cmd, 2, 24, 8, uint8_t, cfg->adv.max_qos_entries); \
69 MC_CMD_OP(cmd, 2, 32, 8, uint8_t, cfg->adv.max_qos_key_size); \
70 MC_CMD_OP(cmd, 2, 48, 8, uint8_t, cfg->adv.max_dist_key_size); \
71 MC_CMD_OP(cmd, 2, 56, 8, enum net_prot, cfg->adv.start_hdr); \
72 MC_CMD_OP(cmd, 3, 0, 8, uint8_t, cfg->adv.max_dist_per_tc[0]); \
73 MC_CMD_OP(cmd, 3, 8, 8, uint8_t, cfg->adv.max_dist_per_tc[1]); \
74 MC_CMD_OP(cmd, 3, 16, 8, uint8_t, cfg->adv.max_dist_per_tc[2]); \
75 MC_CMD_OP(cmd, 3, 24, 8, uint8_t, cfg->adv.max_dist_per_tc[3]); \
76 MC_CMD_OP(cmd, 3, 32, 8, uint8_t, cfg->adv.max_dist_per_tc[4]); \
77 MC_CMD_OP(cmd, 3, 40, 8, uint8_t, cfg->adv.max_dist_per_tc[5]); \
78 MC_CMD_OP(cmd, 3, 48, 8, uint8_t, cfg->adv.max_dist_per_tc[6]); \
79 MC_CMD_OP(cmd, 3, 56, 8, uint8_t, cfg->adv.max_dist_per_tc[7]); \
80 MC_CMD_OP(cmd, 4, 0, 16, uint16_t, \
81 cfg->adv.ipr_cfg.max_reass_frm_size); \
82 MC_CMD_OP(cmd, 4, 16, 16, uint16_t, \
83 cfg->adv.ipr_cfg.min_frag_size_ipv4); \
84 MC_CMD_OP(cmd, 4, 32, 16, uint16_t, \
85 cfg->adv.ipr_cfg.min_frag_size_ipv6); \
86 MC_CMD_OP(cmd, 4, 48, 8, uint8_t, cfg->adv.max_policers); \
87 MC_CMD_OP(cmd, 4, 56, 8, uint8_t, cfg->adv.max_congestion_ctrl); \
88 MC_CMD_OP(cmd, 5, 0, 16, uint16_t, \
89 cfg->adv.ipr_cfg.max_open_frames_ipv4); \
90 MC_CMD_OP(cmd, 5, 16, 16, uint16_t, \
91 cfg->adv.ipr_cfg.max_open_frames_ipv6); \
94 /* cmd, param, offset, width, type, arg_name */
95 #define DPNI_CMD_SET_POOLS(cmd, cfg) \
97 MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
98 MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
99 MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
100 MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
101 MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
102 MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
103 MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
104 MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
105 MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
106 MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
107 MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
108 MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
109 MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
110 MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
111 MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
112 MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
113 MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
116 /* cmd, param, offset, width, type, arg_name */
117 #define DPNI_RSP_GET_ATTR(cmd, attr) \
119 MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
120 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_tcs); \
121 MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_senders); \
122 MC_RSP_OP(cmd, 0, 48, 8, enum net_prot, attr->start_hdr); \
123 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options); \
124 MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_unicast_filters); \
125 MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_multicast_filters);\
126 MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->max_vlan_filters); \
127 MC_RSP_OP(cmd, 2, 24, 8, uint8_t, attr->max_qos_entries); \
128 MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->max_qos_key_size); \
129 MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->max_dist_key_size); \
130 MC_RSP_OP(cmd, 3, 0, 8, uint8_t, attr->max_dist_per_tc[0]); \
131 MC_RSP_OP(cmd, 3, 8, 8, uint8_t, attr->max_dist_per_tc[1]); \
132 MC_RSP_OP(cmd, 3, 16, 8, uint8_t, attr->max_dist_per_tc[2]); \
133 MC_RSP_OP(cmd, 3, 24, 8, uint8_t, attr->max_dist_per_tc[3]); \
134 MC_RSP_OP(cmd, 3, 32, 8, uint8_t, attr->max_dist_per_tc[4]); \
135 MC_RSP_OP(cmd, 3, 40, 8, uint8_t, attr->max_dist_per_tc[5]); \
136 MC_RSP_OP(cmd, 3, 48, 8, uint8_t, attr->max_dist_per_tc[6]); \
137 MC_RSP_OP(cmd, 3, 56, 8, uint8_t, attr->max_dist_per_tc[7]); \
138 MC_RSP_OP(cmd, 4, 0, 16, uint16_t, \
139 attr->ipr_cfg.max_reass_frm_size); \
140 MC_RSP_OP(cmd, 4, 16, 16, uint16_t, \
141 attr->ipr_cfg.min_frag_size_ipv4); \
142 MC_RSP_OP(cmd, 4, 32, 16, uint16_t, \
143 attr->ipr_cfg.min_frag_size_ipv6);\
144 MC_RSP_OP(cmd, 4, 48, 8, uint8_t, attr->max_policers); \
145 MC_RSP_OP(cmd, 4, 56, 8, uint8_t, attr->max_congestion_ctrl); \
146 MC_RSP_OP(cmd, 5, 0, 16, uint16_t, \
147 attr->ipr_cfg.max_open_frames_ipv4); \
148 MC_RSP_OP(cmd, 5, 16, 16, uint16_t, \
149 attr->ipr_cfg.max_open_frames_ipv6); \
150 MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\
151 MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\
154 /* cmd, param, offset, width, type, arg_name */
155 #define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \
157 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
158 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
159 MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
160 MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
161 MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
162 MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
163 MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
166 /* cmd, param, offset, width, type, arg_name */
167 #define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \
169 MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
170 MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
171 MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
172 MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
173 MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
174 MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
175 MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
176 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
179 /* cmd, param, offset, width, type, arg_name */
180 #define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \
182 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
183 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
184 MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
185 MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
186 MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
187 MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
188 MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
191 /* cmd, param, offset, width, type, arg_name */
192 #define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \
194 MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
195 MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
196 MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
197 MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
198 MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
199 MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
200 MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
201 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
204 /* cmd, param, offset, width, type, arg_name */
205 #define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
207 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
208 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
209 MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
210 MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
211 MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
212 MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
213 MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
216 /* cmd, param, offset, width, type, arg_name */
217 #define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
219 MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
220 MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
221 MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
222 MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
223 MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
224 MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
225 MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
226 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
229 /* cmd, param, offset, width, type, arg_name */
230 #define DPNI_RSP_GET_QDID(cmd, qdid) \
231 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid)
233 /* cmd, param, offset, width, type, arg_name */
234 #define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
235 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset)
237 /* cmd, param, offset, width, type, arg_name */
238 #define DPNI_CMD_GET_COUNTER(cmd, counter) \
239 MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter)
241 /* cmd, param, offset, width, type, arg_name */
242 #define DPNI_RSP_GET_COUNTER(cmd, value) \
243 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, value)
245 /* cmd, param, offset, width, type, arg_name */
246 #define DPNI_CMD_SET_COUNTER(cmd, counter, value) \
248 MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter); \
249 MC_CMD_OP(cmd, 1, 0, 64, uint64_t, value); \
252 /* cmd, param, offset, width, type, arg_name */
253 #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
255 MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
256 MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
259 /* cmd, param, offset, width, type, arg_name */
260 #define DPNI_RSP_GET_LINK_STATE(cmd, state) \
262 MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
263 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
264 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
269 /* cmd, param, offset, width, type, arg_name */
270 #define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
272 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
273 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
274 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
275 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
276 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
277 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
280 /* cmd, param, offset, width, type, arg_name */
281 #define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
283 MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
284 MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
285 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
286 MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
287 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
288 MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
291 /* cmd, param, offset, width, type, arg_name */
292 #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
294 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
295 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
296 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
297 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
298 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
299 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
302 /* cmd, param, offset, width, type, arg_name */
303 #define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
305 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
306 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
307 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
308 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
309 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
310 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
313 /* cmd, param, offset, width, type, arg_name */
314 #define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \
316 MC_CMD_OP(cmd, 0, 0, 32, int, \
317 cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_id);\
318 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, \
319 cfg->conf_err_cfg.queue_cfg.dest_cfg.priority);\
320 MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, \
321 cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_type);\
322 MC_CMD_OP(cmd, 0, 42, 1, int, cfg->conf_err_cfg.errors_only);\
323 MC_CMD_OP(cmd, 0, 43, 1, int, cfg->l3_chksum_gen);\
324 MC_CMD_OP(cmd, 0, 44, 1, int, cfg->l4_chksum_gen);\
325 MC_CMD_OP(cmd, 0, 45, 1, int, \
326 cfg->conf_err_cfg.use_default_queue);\
327 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\
328 MC_CMD_OP(cmd, 1, 0, 64, uint64_t, \
329 cfg->conf_err_cfg.queue_cfg.user_ctx);\
330 MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
331 MC_CMD_OP(cmd, 2, 32, 32, uint32_t, \
332 cfg->conf_err_cfg.queue_cfg.options);\
335 /* cmd, param, offset, width, type, arg_name */
336 #define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \
337 MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id)
339 /* cmd, param, offset, width, type, arg_name */
340 #define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \
341 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
343 /* cmd, param, offset, width, type, arg_name */
344 #define DPNI_RSP_GET_TX_FLOW(cmd, attr) \
346 MC_RSP_OP(cmd, 0, 0, 32, int, \
347 attr->conf_err_attr.queue_attr.dest_cfg.dest_id);\
348 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, \
349 attr->conf_err_attr.queue_attr.dest_cfg.priority);\
350 MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, \
351 attr->conf_err_attr.queue_attr.dest_cfg.dest_type);\
352 MC_RSP_OP(cmd, 0, 42, 1, int, attr->conf_err_attr.errors_only);\
353 MC_RSP_OP(cmd, 0, 43, 1, int, attr->l3_chksum_gen);\
354 MC_RSP_OP(cmd, 0, 44, 1, int, attr->l4_chksum_gen);\
355 MC_RSP_OP(cmd, 0, 45, 1, int, \
356 attr->conf_err_attr.use_default_queue);\
357 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, \
358 attr->conf_err_attr.queue_attr.user_ctx);\
359 MC_RSP_OP(cmd, 2, 32, 32, uint32_t, \
360 attr->conf_err_attr.queue_attr.fqid);\
363 /* cmd, param, offset, width, type, arg_name */
364 #define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \
366 MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
367 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\
368 MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, cfg->dest_cfg.dest_type);\
369 MC_CMD_OP(cmd, 0, 42, 1, int, cfg->order_preservation_en);\
370 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
371 MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
372 MC_CMD_OP(cmd, 2, 16, 8, uint8_t, tc_id); \
373 MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->options); \
374 MC_CMD_OP(cmd, 3, 0, 4, enum dpni_flc_type, cfg->flc_cfg.flc_type); \
375 MC_CMD_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
376 cfg->flc_cfg.frame_data_size);\
377 MC_CMD_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
378 cfg->flc_cfg.flow_context_size);\
379 MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
380 MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->flc_cfg.flow_context);\
383 /* cmd, param, offset, width, type, arg_name */
384 #define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
386 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
387 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
390 /* cmd, param, offset, width, type, arg_name */
391 #define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
393 MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id); \
394 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
395 MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, attr->dest_cfg.dest_type); \
396 MC_CMD_OP(cmd, 0, 42, 1, int, attr->order_preservation_en);\
397 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx); \
398 MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
399 MC_RSP_OP(cmd, 3, 0, 4, enum dpni_flc_type, attr->flc_cfg.flc_type); \
400 MC_RSP_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
401 attr->flc_cfg.frame_data_size);\
402 MC_RSP_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
403 attr->flc_cfg.flow_context_size);\
404 MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
405 MC_RSP_OP(cmd, 4, 0, 64, uint64_t, attr->flc_cfg.flow_context);\
421 NET_PROT_SCTP_CHUNK_DATA,
425 NET_PROT_PPPMUX_SUBFRM,
427 NET_PROT_L2TPV3_CTRL,
428 NET_PROT_L2TPV3_SESS,
436 NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
444 NET_PROT_CAPWAP_DATA,
445 NET_PROT_CAPWAP_CTRL,
452 NET_PROT_USER_DEFINED_L2,
453 NET_PROT_USER_DEFINED_L3,
454 NET_PROT_USER_DEFINED_L4,
455 NET_PROT_USER_DEFINED_L5,
456 NET_PROT_USER_DEFINED_SHIM1,
457 NET_PROT_USER_DEFINED_SHIM2,
463 * Data Path Network Interface API
464 * Contains initialization APIs and runtime control APIs for DPNI
469 /* General DPNI macros */
471 /* Maximum number of traffic classes */
472 #define DPNI_MAX_TC 8
473 /* Maximum number of buffer pools per DPNI */
474 #define DPNI_MAX_DPBP 8
476 /* All traffic classes considered; see dpni_set_rx_flow() */
477 #define DPNI_ALL_TCS (uint8_t)(-1)
478 /* All flows within traffic class considered; see dpni_set_rx_flow() */
479 #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
480 /* Generate new flow ID; see dpni_set_tx_flow() */
481 #define DPNI_NEW_FLOW_ID (uint16_t)(-1)
484 * dpni_open() - Open a control session for the specified object
485 * @mc_io: Pointer to MC portal's I/O object
486 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
487 * @dpni_id: DPNI unique ID
488 * @token: Returned token; use in subsequent API calls
490 * This function can be used to open a control session for an
491 * already created object; an object may have been declared in
492 * the DPL or by calling the dpni_create() function.
493 * This function returns a unique authentication token,
494 * associated with the specific object ID and the specific MC
495 * portal; this token must be used in all subsequent commands for
496 * this specific object.
498 * Return: '0' on Success; Error code otherwise.
500 int dpni_open(struct fsl_mc_io *mc_io,
506 * dpni_close() - Close the control session of the object
507 * @mc_io: Pointer to MC portal's I/O object
508 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
509 * @token: Token of DPNI object
511 * After this function is called, no further operations are
512 * allowed on the object without opening a new control session.
514 * Return: '0' on Success; Error code otherwise.
516 int dpni_close(struct fsl_mc_io *mc_io,
520 /* DPNI configuration options */
523 * Allow different distribution key profiles for different traffic classes;
524 * if not set, a single key profile is assumed
526 #define DPNI_OPT_ALLOW_DIST_KEY_PER_TC 0x00000001
529 * Disable all non-error transmit confirmation; error frames are reported
530 * back to a common Tx error queue
532 #define DPNI_OPT_TX_CONF_DISABLED 0x00000002
534 /* Disable per-sender private Tx confirmation/error queue */
535 #define DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED 0x00000004
538 * Support distribution based on hashed key;
539 * allows statistical distribution over receive queues in a traffic class
541 #define DPNI_OPT_DIST_HASH 0x00000010
544 * Support distribution based on flow steering;
545 * allows explicit control of distribution over receive queues in a traffic
548 #define DPNI_OPT_DIST_FS 0x00000020
550 /* Unicast filtering support */
551 #define DPNI_OPT_UNICAST_FILTER 0x00000080
552 /* Multicast filtering support */
553 #define DPNI_OPT_MULTICAST_FILTER 0x00000100
554 /* VLAN filtering support */
555 #define DPNI_OPT_VLAN_FILTER 0x00000200
556 /* Support IP reassembly on received packets */
557 #define DPNI_OPT_IPR 0x00000800
558 /* Support IP fragmentation on transmitted packets */
559 #define DPNI_OPT_IPF 0x00001000
560 /* VLAN manipulation support */
561 #define DPNI_OPT_VLAN_MANIPULATION 0x00010000
562 /* Support masking of QoS lookup keys */
563 #define DPNI_OPT_QOS_MASK_SUPPORT 0x00020000
564 /* Support masking of Flow Steering lookup keys */
565 #define DPNI_OPT_FS_MASK_SUPPORT 0x00040000
568 * struct dpni_ipr_cfg - Structure representing IP reassembly configuration
569 * @max_reass_frm_size: Maximum size of the reassembled frame
570 * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
571 * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
572 * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly process
573 * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly process
575 struct dpni_ipr_cfg {
576 uint16_t max_reass_frm_size;
577 uint16_t min_frag_size_ipv4;
578 uint16_t min_frag_size_ipv6;
579 uint16_t max_open_frames_ipv4;
580 uint16_t max_open_frames_ipv6;
584 * struct dpni_cfg - Structure representing DPNI configuration
585 * @mac_addr: Primary MAC address
586 * @adv: Advanced parameters; default is all zeros;
587 * use this structure to change default settings
592 * struct adv - Advanced parameters
593 * @options: Mask of available options; use 'DPNI_OPT_<X>' values
594 * @start_hdr: Selects the packet starting header for parsing;
595 * 'NET_PROT_NONE' is treated as default: 'NET_PROT_ETH'
596 * @max_senders: Maximum number of different senders; used as the number
597 * of dedicated Tx flows; Non-power-of-2 values are rounded
598 * up to the next power-of-2 value as hardware demands it;
599 * '0' will be treated as '1'
600 * @max_tcs: Maximum number of traffic classes (for both Tx and Rx);
601 * '0' will e treated as '1'
602 * @max_dist_per_tc: Maximum distribution size per Rx traffic class;
603 * Must be set to the required value minus 1;
604 * i.e. 0->1, 1->2, ... ,255->256;
605 * Non-power-of-2 values are rounded up to the next
606 * power-of-2 value as hardware demands it
607 * @max_unicast_filters: Maximum number of unicast filters;
608 * '0' is treated as '16'
609 * @max_multicast_filters: Maximum number of multicast filters;
610 * '0' is treated as '64'
611 * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in
612 * the QoS table; '0' is treated as '64'
613 * @max_qos_key_size: Maximum key size for the QoS look-up;
614 * '0' is treated as '24' which is enough for IPv4
616 * @max_dist_key_size: Maximum key size for the distribution;
617 * '0' is treated as '24' which is enough for IPv4 5-tuple
618 * @max_policers: Maximum number of policers;
619 * should be between '0' and max_tcs
620 * @max_congestion_ctrl: Maximum number of congestion control groups
621 * (CGs); covers early drop and congestion notification
622 * requirements for traffic classes;
623 * should be between '0' and max_tcs
624 * @ipr_cfg: IP reassembly configuration
628 enum net_prot start_hdr;
631 uint8_t max_dist_per_tc[DPNI_MAX_TC];
632 uint8_t max_unicast_filters;
633 uint8_t max_multicast_filters;
634 uint8_t max_vlan_filters;
635 uint8_t max_qos_entries;
636 uint8_t max_qos_key_size;
637 uint8_t max_dist_key_size;
638 uint8_t max_policers;
639 uint8_t max_congestion_ctrl;
640 struct dpni_ipr_cfg ipr_cfg;
645 * dpni_create() - Create the DPNI object
646 * @mc_io: Pointer to MC portal's I/O object
647 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
648 * @cfg: Configuration structure
649 * @token: Returned token; use in subsequent API calls
651 * Create the DPNI object, allocate required resources and
652 * perform required initialization.
654 * The object can be created either by declaring it in the
655 * DPL file, or by calling this function.
657 * This function returns a unique authentication token,
658 * associated with the specific object ID and the specific MC
659 * portal; this token must be used in all subsequent calls to
660 * this specific object. For objects that are created using the
661 * DPL file, call dpni_open() function to get an authentication
664 * Return: '0' on Success; Error code otherwise.
666 int dpni_create(struct fsl_mc_io *mc_io,
668 const struct dpni_cfg *cfg,
672 * dpni_destroy() - Destroy the DPNI object and release all its resources.
673 * @mc_io: Pointer to MC portal's I/O object
674 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
675 * @token: Token of DPNI object
677 * Return: '0' on Success; error code otherwise.
679 int dpni_destroy(struct fsl_mc_io *mc_io,
684 * struct dpni_pools_cfg - Structure representing buffer pools configuration
685 * @num_dpbp: Number of DPBPs
686 * @pools: Array of buffer pools parameters; The number of valid entries
687 * must match 'num_dpbp' value
689 struct dpni_pools_cfg {
692 * struct pools - Buffer pools parameters
693 * @dpbp_id: DPBP object ID
694 * @buffer_size: Buffer size
695 * @backup_pool: Backup pool
699 uint16_t buffer_size;
701 } pools[DPNI_MAX_DPBP];
705 * dpni_set_pools() - Set buffer pools configuration
706 * @mc_io: Pointer to MC portal's I/O object
707 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
708 * @token: Token of DPNI object
709 * @cfg: Buffer pools configuration
711 * mandatory for DPNI operation
712 * warning:Allowed only when DPNI is disabled
714 * Return: '0' on Success; Error code otherwise.
716 int dpni_set_pools(struct fsl_mc_io *mc_io,
719 const struct dpni_pools_cfg *cfg);
722 * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
723 * @mc_io: Pointer to MC portal's I/O object
724 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
725 * @token: Token of DPNI object
727 * Return: '0' on Success; Error code otherwise.
729 int dpni_enable(struct fsl_mc_io *mc_io,
734 * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
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
739 * Return: '0' on Success; Error code otherwise.
741 int dpni_disable(struct fsl_mc_io *mc_io,
747 * dpni_reset() - Reset the DPNI, returns the object to initial state.
748 * @mc_io: Pointer to MC portal's I/O object
749 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
750 * @token: Token of DPNI object
752 * Return: '0' on Success; Error code otherwise.
754 int dpni_reset(struct fsl_mc_io *mc_io,
759 * struct dpni_attr - Structure representing DPNI attributes
760 * @id: DPNI object ID
761 * @version: DPNI version
762 * @start_hdr: Indicates the packet starting header for parsing
763 * @options: Mask of available options; reflects the value as was given in
765 * @max_senders: Maximum number of different senders; used as the number
766 * of dedicated Tx flows;
767 * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
768 * @max_dist_per_tc: Maximum distribution size per Rx traffic class;
769 * Set to the required value minus 1
770 * @max_unicast_filters: Maximum number of unicast filters
771 * @max_multicast_filters: Maximum number of multicast filters
772 * @max_vlan_filters: Maximum number of VLAN filters
773 * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
774 * @max_qos_key_size: Maximum key size for the QoS look-up
775 * @max_dist_key_size: Maximum key size for the distribution look-up
776 * @max_policers: Maximum number of policers;
777 * @max_congestion_ctrl: Maximum number of congestion control groups (CGs);
778 * @ipr_cfg: IP reassembly configuration
783 * struct version - DPNI version
784 * @major: DPNI major version
785 * @minor: DPNI minor version
791 enum net_prot start_hdr;
795 uint8_t max_dist_per_tc[DPNI_MAX_TC];
796 uint8_t max_unicast_filters;
797 uint8_t max_multicast_filters;
798 uint8_t max_vlan_filters;
799 uint8_t max_qos_entries;
800 uint8_t max_qos_key_size;
801 uint8_t max_dist_key_size;
802 uint8_t max_policers;
803 uint8_t max_congestion_ctrl;
804 struct dpni_ipr_cfg ipr_cfg;
808 * dpni_get_attributes() - Retrieve DPNI attributes.
809 * @mc_io: Pointer to MC portal's I/O object
810 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
811 * @token: Token of DPNI object
812 * @attr: Returned object's attributes
814 * Return: '0' on Success; Error code otherwise.
816 int dpni_get_attributes(struct fsl_mc_io *mc_io,
819 struct dpni_attr *attr);
821 /* DPNI buffer layout modification options */
823 /* Select to modify the time-stamp setting */
824 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
825 /* Select to modify the parser-result setting; not applicable for Tx */
826 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
827 /* Select to modify the frame-status setting */
828 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
829 /* Select to modify the private-data-size setting */
830 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
831 /* Select to modify the data-alignment setting */
832 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
833 /* Select to modify the data-head-room setting */
834 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
835 /*!< Select to modify the data-tail-room setting */
836 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
839 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
840 * @options: Flags representing the suggested modifications to the buffer
841 * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
842 * @pass_timestamp: Pass timestamp value
843 * @pass_parser_result: Pass parser results
844 * @pass_frame_status: Pass frame status
845 * @private_data_size: Size kept for private data (in bytes)
846 * @data_align: Data alignment
847 * @data_head_room: Data head room
848 * @data_tail_room: Data tail room
850 struct dpni_buffer_layout {
853 int pass_parser_result;
854 int pass_frame_status;
855 uint16_t private_data_size;
857 uint16_t data_head_room;
858 uint16_t data_tail_room;
862 * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
863 * @mc_io: Pointer to MC portal's I/O object
864 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
865 * @token: Token of DPNI object
866 * @layout: Returns buffer layout attributes
868 * Return: '0' on Success; Error code otherwise.
870 int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
873 struct dpni_buffer_layout *layout);
876 * dpni_set_rx_buffer_layout() - Set Rx buffer layout 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 * @layout: Buffer layout configuration
882 * Return: '0' on Success; Error code otherwise.
884 * @warning Allowed only when DPNI is disabled
886 int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
889 const struct dpni_buffer_layout *layout);
892 * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
893 * @mc_io: Pointer to MC portal's I/O object
894 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
895 * @token: Token of DPNI object
896 * @layout: Returns buffer layout attributes
898 * Return: '0' on Success; Error code otherwise.
900 int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
903 struct dpni_buffer_layout *layout);
906 * dpni_set_tx_buffer_layout() - Set Tx buffer layout configuration.
907 * @mc_io: Pointer to MC portal's I/O object
908 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
909 * @token: Token of DPNI object
910 * @layout: Buffer layout configuration
912 * Return: '0' on Success; Error code otherwise.
914 * @warning Allowed only when DPNI is disabled
916 int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
919 const struct dpni_buffer_layout *layout);
922 * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
924 * @mc_io: Pointer to MC portal's I/O object
925 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
926 * @token: Token of DPNI object
927 * @layout: Returns buffer layout attributes
929 * Return: '0' on Success; Error code otherwise.
931 int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
934 struct dpni_buffer_layout *layout);
937 * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
939 * @mc_io: Pointer to MC portal's I/O object
940 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
941 * @token: Token of DPNI object
942 * @layout: Buffer layout configuration
944 * Return: '0' on Success; Error code otherwise.
946 * @warning Allowed only when DPNI is disabled
948 int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
951 const struct dpni_buffer_layout *layout);
954 * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
955 * for enqueue operations
956 * @mc_io: Pointer to MC portal's I/O object
957 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
958 * @token: Token of DPNI object
959 * @qdid: Returned virtual QDID value that should be used as an argument
960 * in all enqueue operations
962 * Return: '0' on Success; Error code otherwise.
964 int dpni_get_qdid(struct fsl_mc_io *mc_io,
970 * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
971 * @mc_io: Pointer to MC portal's I/O object
972 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
973 * @token: Token of DPNI object
974 * @data_offset: Tx data offset (from start of buffer)
976 * Return: '0' on Success; Error code otherwise.
978 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
981 uint16_t *data_offset);
984 * enum dpni_counter - DPNI counter types
985 * @DPNI_CNT_ING_FRAME: Counts ingress frames
986 * @DPNI_CNT_ING_BYTE: Counts ingress bytes
987 * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
989 * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
990 * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
991 * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
992 * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
993 * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
994 * @DPNI_CNT_EGR_FRAME: Counts egress frames
995 * @DPNI_CNT_EGR_BYTE: Counts egress bytes
996 * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
999 DPNI_CNT_ING_FRAME = 0x0,
1000 DPNI_CNT_ING_BYTE = 0x1,
1001 DPNI_CNT_ING_FRAME_DROP = 0x2,
1002 DPNI_CNT_ING_FRAME_DISCARD = 0x3,
1003 DPNI_CNT_ING_MCAST_FRAME = 0x4,
1004 DPNI_CNT_ING_MCAST_BYTE = 0x5,
1005 DPNI_CNT_ING_BCAST_FRAME = 0x6,
1006 DPNI_CNT_ING_BCAST_BYTES = 0x7,
1007 DPNI_CNT_EGR_FRAME = 0x8,
1008 DPNI_CNT_EGR_BYTE = 0x9,
1009 DPNI_CNT_EGR_FRAME_DISCARD = 0xa
1013 * dpni_get_counter() - Read a specific DPNI counter
1014 * @mc_io: Pointer to MC portal's I/O object
1015 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1016 * @token: Token of DPNI object
1017 * @counter: The requested counter
1018 * @value: Returned counter's current value
1020 * Return: '0' on Success; Error code otherwise.
1022 int dpni_get_counter(struct fsl_mc_io *mc_io,
1025 enum dpni_counter counter,
1029 * dpni_set_counter() - Set (or clear) a specific DPNI counter
1030 * @mc_io: Pointer to MC portal's I/O object
1031 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1032 * @token: Token of DPNI object
1033 * @counter: The requested counter
1034 * @value: New counter value; typically pass '0' for resetting
1037 * Return: '0' on Success; Error code otherwise.
1039 int dpni_set_counter(struct fsl_mc_io *mc_io,
1042 enum dpni_counter counter,
1045 /* Enable auto-negotiation */
1046 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
1047 /* Enable half-duplex mode */
1048 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
1049 /* Enable pause frames */
1050 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
1051 /* Enable a-symmetric pause frames */
1052 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
1055 * struct - Structure representing DPNI link configuration
1057 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
1059 struct dpni_link_cfg {
1065 * dpni_set_link_cfg() - set the link 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 * @cfg: Link configuration
1071 * Return: '0' on Success; Error code otherwise.
1073 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
1076 const struct dpni_link_cfg *cfg);
1079 * struct dpni_link_state - Structure representing DPNI link state
1081 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
1082 * @up: Link state; '0' for down, '1' for up
1084 struct dpni_link_state {
1091 * dpni_get_link_state() - Return the link state (either up or down)
1092 * @mc_io: Pointer to MC portal's I/O object
1093 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1094 * @token: Token of DPNI object
1095 * @state: Returned link state;
1097 * Return: '0' on Success; Error code otherwise.
1099 int dpni_get_link_state(struct fsl_mc_io *mc_io,
1102 struct dpni_link_state *state);
1105 * dpni_set_primary_mac_addr() - Set the primary MAC address
1106 * @mc_io: Pointer to MC portal's I/O object
1107 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1108 * @token: Token of DPNI object
1109 * @mac_addr: MAC address to set as primary address
1111 * Return: '0' on Success; Error code otherwise.
1113 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
1116 const uint8_t mac_addr[6]);
1119 * dpni_get_primary_mac_addr() - Get the primary MAC address
1120 * @mc_io: Pointer to MC portal's I/O object
1121 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1122 * @token: Token of DPNI object
1123 * @mac_addr: Returned MAC address
1125 * Return: '0' on Success; Error code otherwise.
1127 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
1130 uint8_t mac_addr[6]);
1133 * dpni_add_mac_addr() - Add MAC address filter
1134 * @mc_io: Pointer to MC portal's I/O object
1135 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1136 * @token: Token of DPNI object
1137 * @mac_addr: MAC address to add
1139 * Return: '0' on Success; Error code otherwise.
1141 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
1144 const uint8_t mac_addr[6]);
1147 * dpni_remove_mac_addr() - Remove MAC address filter
1148 * @mc_io: Pointer to MC portal's I/O object
1149 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1150 * @token: Token of DPNI object
1151 * @mac_addr: MAC address to remove
1153 * Return: '0' on Success; Error code otherwise.
1155 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
1158 const uint8_t mac_addr[6]);
1161 * enum dpni_dest - DPNI destination types
1162 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
1163 * does not generate FQDAN notifications; user is expected to
1164 * dequeue from the queue based on polling or other user-defined
1166 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
1167 * notifications to the specified DPIO; user is expected to dequeue
1168 * from the queue only after notification is received
1169 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
1170 * FQDAN notifications, but is connected to the specified DPCON
1171 * object; user is expected to dequeue from the DPCON channel
1180 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
1181 * @dest_type: Destination type
1182 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
1183 * @priority: Priority selection within the DPIO or DPCON channel; valid values
1184 * are 0-1 or 0-7, depending on the number of priorities in that
1185 * channel; not relevant for 'DPNI_DEST_NONE' option
1187 struct dpni_dest_cfg {
1188 enum dpni_dest dest_type;
1194 * enum dpni_flc_type - DPNI FLC types
1195 * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
1196 * @DPNI_FLC_STASH: select the FLC to be used for stash control
1198 enum dpni_flc_type {
1199 DPNI_FLC_USER_DEFINED = 0,
1204 * enum dpni_stash_size - DPNI FLC stashing size
1205 * @DPNI_STASH_SIZE_0B: no stash
1206 * @DPNI_STASH_SIZE_64B: stashes 64 bytes
1207 * @DPNI_STASH_SIZE_128B: stashes 128 bytes
1208 * @DPNI_STASH_SIZE_192B: stashes 192 bytes
1210 enum dpni_stash_size {
1211 DPNI_STASH_SIZE_0B = 0,
1212 DPNI_STASH_SIZE_64B = 1,
1213 DPNI_STASH_SIZE_128B = 2,
1214 DPNI_STASH_SIZE_192B = 3,
1217 /* DPNI FLC stash options */
1219 /* stashes the whole annotation area (up to 192 bytes) */
1220 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
1223 * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
1224 * @flc_type: FLC type
1225 * @options: Mask of available options;
1226 * use 'DPNI_FLC_STASH_<X>' values
1227 * @frame_data_size: Size of frame data to be stashed
1228 * @flow_context_size: Size of flow context to be stashed
1229 * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
1230 * this value will be provided in the frame descriptor
1232 * 2. In case flc_type is 'DPNI_FLC_STASH':
1233 * this value will be I/O virtual address of the
1235 * Must be cacheline-aligned and DMA-able memory
1237 struct dpni_flc_cfg {
1238 enum dpni_flc_type flc_type;
1240 enum dpni_stash_size frame_data_size;
1241 enum dpni_stash_size flow_context_size;
1242 uint64_t flow_context;
1245 /* DPNI queue modification options */
1247 /* Select to modify the user's context associated with the queue */
1248 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1249 /* Select to modify the queue's destination */
1250 #define DPNI_QUEUE_OPT_DEST 0x00000002
1251 /** Select to modify the flow-context parameters;
1252 * not applicable for Tx-conf/Err queues as the FD comes from the user
1254 #define DPNI_QUEUE_OPT_FLC 0x00000004
1255 /* Select to modify the queue's order preservation */
1256 #define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008
1259 * struct dpni_queue_cfg - Structure representing queue configuration
1260 * @options: Flags representing the suggested modifications to the queue;
1261 * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
1262 * @user_ctx: User context value provided in the frame descriptor of each
1263 * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
1264 * is contained in 'options'
1265 * @dest_cfg: Queue destination parameters;
1266 * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
1267 * @flc_cfg: Flow context configuration; in case the TC's distribution
1268 * is either NONE or HASH the FLC's settings of flow#0 are used.
1269 * in the case of FS (flow-steering) the flow's FLC settings
1271 * valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
1272 * @order_preservation_en: enable/disable order preservation;
1273 * valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained
1276 struct dpni_queue_cfg {
1279 struct dpni_dest_cfg dest_cfg;
1280 struct dpni_flc_cfg flc_cfg;
1281 int order_preservation_en;
1285 * struct dpni_queue_attr - Structure representing queue attributes
1286 * @user_ctx: User context value provided in the frame descriptor of each
1288 * @dest_cfg: Queue destination configuration
1289 * @flc_cfg: Flow context configuration
1290 * @order_preservation_en: enable/disable order preservation
1291 * @fqid: Virtual fqid value to be used for dequeue operations
1293 struct dpni_queue_attr {
1295 struct dpni_dest_cfg dest_cfg;
1296 struct dpni_flc_cfg flc_cfg;
1297 int order_preservation_en;
1301 /* DPNI Tx flow modification options */
1303 /* Select to modify the settings for dedicate Tx confirmation/error */
1304 #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR 0x00000001
1305 /*!< Select to modify the Tx confirmation and/or error setting */
1306 #define DPNI_TX_FLOW_OPT_ONLY_TX_ERROR 0x00000002
1307 /*!< Select to modify the queue configuration */
1308 #define DPNI_TX_FLOW_OPT_QUEUE 0x00000004
1309 /*!< Select to modify the L3 checksum generation setting */
1310 #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN 0x00000010
1311 /*!< Select to modify the L4 checksum generation setting */
1312 #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
1315 * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
1316 * @options: Flags representing the suggested modifications to the Tx flow;
1317 * Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
1318 * @conf_err_cfg: Tx confirmation and error configuration; these settings are
1319 * ignored if 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' was set at
1321 * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
1322 * valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in
1324 * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
1325 * valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in
1328 struct dpni_tx_flow_cfg {
1331 * struct cnf_err_cfg - Tx confirmation and error configuration
1332 * @use_default_queue: Set to '1' to use the common (default) Tx
1333 * confirmation and error queue; Set to '0' to use the
1334 * private Tx confirmation and error queue; valid only if
1335 * 'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in
1337 * @errors_only: Set to '1' to report back only error frames;
1338 * Set to '0' to confirm transmission/error for all
1339 * transmitted frames;
1340 * valid only if 'DPNI_TX_FLOW_OPT_ONLY_TX_ERROR' is
1341 * contained in 'options' and 'use_default_queue = 0';
1342 * @queue_cfg: Queue configuration; valid only if
1343 * 'DPNI_TX_FLOW_OPT_QUEUE' is contained in 'options'
1346 int use_default_queue;
1348 struct dpni_queue_cfg queue_cfg;
1355 * dpni_set_tx_flow() - Set Tx flow configuration
1356 * @mc_io: Pointer to MC portal's I/O object
1357 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1358 * @token: Token of DPNI object
1359 * @flow_id: Provides (or returns) the sender's flow ID;
1360 * for each new sender set (*flow_id) to
1361 * 'DPNI_NEW_FLOW_ID' to generate a new flow_id;
1362 * this ID should be used as the QDBIN argument
1363 * in enqueue operations
1364 * @cfg: Tx flow configuration
1366 * Return: '0' on Success; Error code otherwise.
1368 int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
1372 const struct dpni_tx_flow_cfg *cfg);
1375 * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
1376 * @conf_err_attr: Tx confirmation and error attributes
1377 * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
1378 * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
1380 struct dpni_tx_flow_attr {
1382 * struct conf_err_attr - Tx confirmation and error attributes
1383 * @use_default_queue: '1' if using common (default) Tx confirmation and
1385 * '0' if using private Tx confirmation and error
1387 * @errors_only: '1' if only error frames are reported back; '0' if all
1388 * transmitted frames are confirmed
1389 * @queue_attr: Queue attributes
1392 int use_default_queue;
1394 struct dpni_queue_attr queue_attr;
1401 * dpni_get_tx_flow() - Get Tx flow attributes
1402 * @mc_io: Pointer to MC portal's I/O object
1403 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1404 * @token: Token of DPNI object
1405 * @flow_id: The sender's flow ID, as returned by the
1406 * dpni_set_tx_flow() function
1407 * @attr: Returned Tx flow attributes
1409 * Return: '0' on Success; Error code otherwise.
1411 int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
1415 struct dpni_tx_flow_attr *attr);
1418 * dpni_set_rx_flow() - Set Rx flow configuration
1419 * @mc_io: Pointer to MC portal's I/O object
1420 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1421 * @token: Token of DPNI object
1422 * @tc_id: Traffic class selection (0-7);
1423 * use 'DPNI_ALL_TCS' to set all TCs and all flows
1424 * @flow_id: Rx flow id within the traffic class; use
1425 * 'DPNI_ALL_TC_FLOWS' to set all flows within
1426 * this tc_id; ignored if tc_id is set to
1428 * @cfg: Rx flow configuration
1430 * Return: '0' on Success; Error code otherwise.
1432 int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
1437 const struct dpni_queue_cfg *cfg);
1440 * dpni_get_rx_flow() - Get Rx flow attributes
1441 * @mc_io: Pointer to MC portal's I/O object
1442 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1443 * @token: Token of DPNI object
1444 * @tc_id: Traffic class selection (0-7)
1445 * @flow_id: Rx flow id within the traffic class
1446 * @attr: Returned Rx flow attributes
1448 * Return: '0' on Success; Error code otherwise.
1450 int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
1455 struct dpni_queue_attr *attr);
1457 #endif /* _FSL_DPNI_H */