2 * Copyright (C) 2013-2015 Freescale Semiconductor
4 * SPDX-License-Identifier: GPL-2.0+
10 #define DPNI_VER_MAJOR 4
11 #define DPNI_VER_MINOR 0
14 #define DPNI_CMDID_OPEN 0x801
15 #define DPNI_CMDID_CLOSE 0x800
17 #define DPNI_CMDID_ENABLE 0x002
18 #define DPNI_CMDID_DISABLE 0x003
19 #define DPNI_CMDID_GET_ATTR 0x004
20 #define DPNI_CMDID_RESET 0x005
22 #define DPNI_CMDID_SET_POOLS 0x200
23 #define DPNI_CMDID_GET_RX_BUFFER_LAYOUT 0x201
24 #define DPNI_CMDID_SET_RX_BUFFER_LAYOUT 0x202
25 #define DPNI_CMDID_GET_TX_BUFFER_LAYOUT 0x203
26 #define DPNI_CMDID_SET_TX_BUFFER_LAYOUT 0x204
27 #define DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT 0x205
28 #define DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT 0x206
30 #define DPNI_CMDID_GET_QDID 0x210
31 #define DPNI_CMDID_GET_TX_DATA_OFFSET 0x212
32 #define DPNI_CMDID_GET_COUNTER 0x213
33 #define DPNI_CMDID_SET_COUNTER 0x214
34 #define DPNI_CMDID_GET_LINK_STATE 0x215
35 #define DPNI_CMDID_SET_LINK_CFG 0x21A
37 #define DPNI_CMDID_SET_PRIM_MAC 0x224
38 #define DPNI_CMDID_GET_PRIM_MAC 0x225
39 #define DPNI_CMDID_ADD_MAC_ADDR 0x226
40 #define DPNI_CMDID_REMOVE_MAC_ADDR 0x227
42 #define DPNI_CMDID_SET_TX_FLOW 0x236
43 #define DPNI_CMDID_GET_TX_FLOW 0x237
44 #define DPNI_CMDID_SET_RX_FLOW 0x238
45 #define DPNI_CMDID_GET_RX_FLOW 0x239
47 /* cmd, param, offset, width, type, arg_name */
48 #define DPNI_CMD_OPEN(cmd, dpni_id) \
49 MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
52 /* cmd, param, offset, width, type, arg_name */
53 #define DPNI_CMD_SET_POOLS(cmd, cfg) \
55 MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
56 MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
57 MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
58 MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
59 MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
60 MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
61 MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
62 MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
63 MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
64 MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
65 MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
66 MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
67 MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
68 MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
69 MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
70 MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
71 MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
74 /* cmd, param, offset, width, type, arg_name */
75 #define DPNI_RSP_GET_ATTR(cmd, attr) \
77 MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
78 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_tcs); \
79 MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_senders); \
80 MC_RSP_OP(cmd, 0, 48, 8, enum net_prot, attr->start_hdr); \
81 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->options); \
82 MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_unicast_filters); \
83 MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_multicast_filters);\
84 MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->max_vlan_filters); \
85 MC_RSP_OP(cmd, 2, 24, 8, uint8_t, attr->max_qos_entries); \
86 MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->max_qos_key_size); \
87 MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->max_dist_key_size); \
88 MC_RSP_OP(cmd, 3, 0, 8, uint8_t, attr->max_dist_per_tc[0]); \
89 MC_RSP_OP(cmd, 3, 8, 8, uint8_t, attr->max_dist_per_tc[1]); \
90 MC_RSP_OP(cmd, 3, 16, 8, uint8_t, attr->max_dist_per_tc[2]); \
91 MC_RSP_OP(cmd, 3, 24, 8, uint8_t, attr->max_dist_per_tc[3]); \
92 MC_RSP_OP(cmd, 3, 32, 8, uint8_t, attr->max_dist_per_tc[4]); \
93 MC_RSP_OP(cmd, 3, 40, 8, uint8_t, attr->max_dist_per_tc[5]); \
94 MC_RSP_OP(cmd, 3, 48, 8, uint8_t, attr->max_dist_per_tc[6]); \
95 MC_RSP_OP(cmd, 3, 56, 8, uint8_t, attr->max_dist_per_tc[7]); \
96 MC_RSP_OP(cmd, 4, 0, 16, uint16_t, \
97 attr->ipr_cfg.max_reass_frm_size); \
98 MC_RSP_OP(cmd, 4, 16, 16, uint16_t, \
99 attr->ipr_cfg.min_frag_size_ipv4); \
100 MC_RSP_OP(cmd, 4, 32, 16, uint16_t, \
101 attr->ipr_cfg.min_frag_size_ipv6); \
102 MC_RSP_OP(cmd, 5, 0, 16, uint16_t, \
103 attr->ipr_cfg.max_open_frames_ipv4); \
104 MC_RSP_OP(cmd, 5, 16, 16, uint16_t, \
105 attr->ipr_cfg.max_open_frames_ipv6); \
106 MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\
107 MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\
110 /* cmd, param, offset, width, type, arg_name */
111 #define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \
113 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
114 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
115 MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
116 MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
117 MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
118 MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
119 MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
122 /* cmd, param, offset, width, type, arg_name */
123 #define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \
125 MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
126 MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
127 MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
128 MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
129 MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
130 MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
131 MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
132 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
135 /* cmd, param, offset, width, type, arg_name */
136 #define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \
138 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
139 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
140 MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
141 MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
142 MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
143 MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
144 MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
147 /* cmd, param, offset, width, type, arg_name */
148 #define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \
150 MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
151 MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
152 MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
153 MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
154 MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
155 MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
156 MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
157 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
160 /* cmd, param, offset, width, type, arg_name */
161 #define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
163 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
164 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
165 MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
166 MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
167 MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
168 MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
169 MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
172 /* cmd, param, offset, width, type, arg_name */
173 #define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
175 MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
176 MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
177 MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
178 MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
179 MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
180 MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
181 MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
182 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
185 /* cmd, param, offset, width, type, arg_name */
186 #define DPNI_RSP_GET_QDID(cmd, qdid) \
187 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid)
189 /* cmd, param, offset, width, type, arg_name */
190 #define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
191 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset)
193 /* cmd, param, offset, width, type, arg_name */
194 #define DPNI_CMD_GET_COUNTER(cmd, counter) \
195 MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter)
197 /* cmd, param, offset, width, type, arg_name */
198 #define DPNI_RSP_GET_COUNTER(cmd, value) \
199 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, value)
201 /* cmd, param, offset, width, type, arg_name */
202 #define DPNI_CMD_SET_COUNTER(cmd, counter, value) \
204 MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter); \
205 MC_CMD_OP(cmd, 1, 0, 64, uint64_t, value); \
208 /* cmd, param, offset, width, type, arg_name */
209 #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
211 MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->rate);\
212 MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
215 /* cmd, param, offset, width, type, arg_name */
216 #define DPNI_RSP_GET_LINK_STATE(cmd, state) \
218 MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
219 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, state->rate);\
220 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
225 /* cmd, param, offset, width, type, arg_name */
226 #define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
228 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
229 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
230 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
231 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
232 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
233 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
236 /* cmd, param, offset, width, type, arg_name */
237 #define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
239 MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
240 MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
241 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
242 MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
243 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
244 MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
247 /* cmd, param, offset, width, type, arg_name */
248 #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
250 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
251 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
252 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
253 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
254 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
255 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
258 /* cmd, param, offset, width, type, arg_name */
259 #define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
261 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
262 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
263 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
264 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
265 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
266 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
269 /* cmd, param, offset, width, type, arg_name */
270 #define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \
272 MC_CMD_OP(cmd, 0, 0, 32, int, \
273 cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_id);\
274 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, \
275 cfg->conf_err_cfg.queue_cfg.dest_cfg.priority);\
276 MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, \
277 cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_type);\
278 MC_CMD_OP(cmd, 0, 42, 1, int, cfg->conf_err_cfg.errors_only);\
279 MC_CMD_OP(cmd, 0, 43, 1, int, cfg->l3_chksum_gen);\
280 MC_CMD_OP(cmd, 0, 44, 1, int, cfg->l4_chksum_gen);\
281 MC_CMD_OP(cmd, 0, 45, 1, int, \
282 cfg->conf_err_cfg.use_default_queue);\
283 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\
284 MC_CMD_OP(cmd, 1, 0, 64, uint64_t, \
285 cfg->conf_err_cfg.queue_cfg.user_ctx);\
286 MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
287 MC_CMD_OP(cmd, 2, 32, 32, uint32_t, \
288 cfg->conf_err_cfg.queue_cfg.options);\
291 /* cmd, param, offset, width, type, arg_name */
292 #define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \
293 MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id)
295 /* cmd, param, offset, width, type, arg_name */
296 #define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \
297 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
299 /* cmd, param, offset, width, type, arg_name */
300 #define DPNI_RSP_GET_TX_FLOW(cmd, attr) \
302 MC_RSP_OP(cmd, 0, 0, 32, int, \
303 attr->conf_err_attr.queue_attr.dest_cfg.dest_id);\
304 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, \
305 attr->conf_err_attr.queue_attr.dest_cfg.priority);\
306 MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, \
307 attr->conf_err_attr.queue_attr.dest_cfg.dest_type);\
308 MC_RSP_OP(cmd, 0, 42, 1, int, attr->conf_err_attr.errors_only);\
309 MC_RSP_OP(cmd, 0, 43, 1, int, attr->l3_chksum_gen);\
310 MC_RSP_OP(cmd, 0, 44, 1, int, attr->l4_chksum_gen);\
311 MC_RSP_OP(cmd, 0, 45, 1, int, \
312 attr->conf_err_attr.use_default_queue);\
313 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, \
314 attr->conf_err_attr.queue_attr.user_ctx);\
315 MC_RSP_OP(cmd, 2, 32, 32, uint32_t, \
316 attr->conf_err_attr.queue_attr.fqid);\
319 /* cmd, param, offset, width, type, arg_name */
320 #define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \
322 MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
323 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\
324 MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, cfg->dest_cfg.dest_type);\
325 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
326 MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
327 MC_CMD_OP(cmd, 2, 16, 8, uint8_t, tc_id); \
328 MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->options); \
331 /* cmd, param, offset, width, type, arg_name */
332 #define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
334 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
335 MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
338 /* cmd, param, offset, width, type, arg_name */
339 #define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
341 MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id); \
342 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
343 MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, attr->dest_cfg.dest_type); \
344 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx); \
345 MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
361 NET_PROT_SCTP_CHUNK_DATA,
365 NET_PROT_PPPMUX_SUBFRM,
367 NET_PROT_L2TPV3_CTRL,
368 NET_PROT_L2TPV3_SESS,
376 NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
384 NET_PROT_CAPWAP_DATA,
385 NET_PROT_CAPWAP_CTRL,
392 NET_PROT_USER_DEFINED_L2,
393 NET_PROT_USER_DEFINED_L3,
394 NET_PROT_USER_DEFINED_L4,
395 NET_PROT_USER_DEFINED_L5,
396 NET_PROT_USER_DEFINED_SHIM1,
397 NET_PROT_USER_DEFINED_SHIM2,
402 /* Data Path Network Interface API
403 * Contains initialization APIs and runtime control APIs for DPNI
408 /* General DPNI macros */
410 /* Maximum number of traffic classes */
411 #define DPNI_MAX_TC 8
412 /* Maximum number of buffer pools per DPNI */
413 #define DPNI_MAX_DPBP 8
415 /* All traffic classes considered; see dpni_set_rx_flow() */
416 #define DPNI_ALL_TCS (uint8_t)(-1)
417 /* All flows within traffic class considered; see dpni_set_rx_flow() */
418 #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
419 /* Generate new flow ID; see dpni_set_tx_flow() */
420 #define DPNI_NEW_FLOW_ID (uint16_t)(-1)
423 * dpni_open() - Open a control session for the specified object
424 * @mc_io: Pointer to MC portal's I/O object
425 * @dpni_id: DPNI unique ID
426 * @token: Returned token; use in subsequent API calls
428 * This function can be used to open a control session for an
429 * already created object; an object may have been declared in
430 * the DPL or by calling the dpni_create() function.
431 * This function returns a unique authentication token,
432 * associated with the specific object ID and the specific MC
433 * portal; this token must be used in all subsequent commands for
434 * this specific object.
436 * Return: '0' on Success; Error code otherwise.
438 int dpni_open(struct fsl_mc_io *mc_io, int dpni_id, uint16_t *token);
441 * dpni_close() - Close the control session of the object
442 * @mc_io: Pointer to MC portal's I/O object
443 * @token: Token of DPNI object
445 * After this function is called, no further operations are
446 * allowed on the object without opening a new control session.
448 * Return: '0' on Success; Error code otherwise.
450 int dpni_close(struct fsl_mc_io *mc_io, uint16_t token);
453 * struct dpni_ipr_cfg - Structure representing IP reassembly configuration
454 * @max_reass_frm_size: Maximum size of the reassembled frame
455 * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
456 * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
457 * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly process
458 * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly process
460 struct dpni_ipr_cfg {
461 uint16_t max_reass_frm_size;
462 uint16_t min_frag_size_ipv4;
463 uint16_t min_frag_size_ipv6;
464 uint16_t max_open_frames_ipv4;
465 uint16_t max_open_frames_ipv6;
469 * struct dpni_pools_cfg - Structure representing buffer pools configuration
470 * @num_dpbp: Number of DPBPs
471 * @pools: Array of buffer pools parameters; The number of valid entries
472 * must match 'num_dpbp' value
474 struct dpni_pools_cfg {
477 * struct pools - Buffer pools parameters
478 * @dpbp_id: DPBP object ID
479 * @buffer_size: Buffer size
483 uint16_t buffer_size;
484 } pools[DPNI_MAX_DPBP];
488 * dpni_set_pools() - Set buffer pools configuration
489 * @mc_io: Pointer to MC portal's I/O object
490 * @token: Token of DPNI object
491 * @cfg: Buffer pools configuration
493 * mandatory for DPNI operation
494 * warning:Allowed only when DPNI is disabled
496 * Return: '0' on Success; Error code otherwise.
498 int dpni_set_pools(struct fsl_mc_io *mc_io,
500 const struct dpni_pools_cfg *cfg);
503 * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
504 * @mc_io: Pointer to MC portal's I/O object
505 * @token: Token of DPNI object
507 * Return: '0' on Success; Error code otherwise.
509 int dpni_enable(struct fsl_mc_io *mc_io, uint16_t token);
512 * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
513 * @mc_io: Pointer to MC portal's I/O object
514 * @token: Token of DPNI object
516 * Return: '0' on Success; Error code otherwise.
518 int dpni_disable(struct fsl_mc_io *mc_io, uint16_t token);
522 * @dpni_reset() - Reset the DPNI, returns the object to initial state.
523 * @mc_io: Pointer to MC portal's I/O object
524 * @token: Token of DPNI object
526 * Return: '0' on Success; Error code otherwise.
528 int dpni_reset(struct fsl_mc_io *mc_io, uint16_t token);
531 * struct dpni_attr - Structure representing DPNI attributes
532 * @id: DPNI object ID
533 * @version: DPNI version
534 * @start_hdr: Indicates the packet starting header for parsing
535 * @options: Mask of available options; reflects the value as was given in
537 * @max_senders: Maximum number of different senders; used as the number
538 * of dedicated Tx flows;
539 * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
540 * @max_dist_per_tc: Maximum distribution size per Rx traffic class;
541 * Set to the required value minus 1
542 * @max_unicast_filters: Maximum number of unicast filters
543 * @max_multicast_filters: Maximum number of multicast filters
544 * @max_vlan_filters: Maximum number of VLAN filters
545 * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
546 * @max_qos_key_size: Maximum key size for the QoS look-up
547 * @max_dist_key_size: Maximum key size for the distribution look-up
548 * @ipr_cfg: IP reassembly configuration
553 * struct version - DPNI version
554 * @major: DPNI major version
555 * @minor: DPNI minor version
561 enum net_prot start_hdr;
565 uint8_t max_dist_per_tc[DPNI_MAX_TC];
566 uint8_t max_unicast_filters;
567 uint8_t max_multicast_filters;
568 uint8_t max_vlan_filters;
569 uint8_t max_qos_entries;
570 uint8_t max_qos_key_size;
571 uint8_t max_dist_key_size;
572 struct dpni_ipr_cfg ipr_cfg;
575 * dpni_get_attributes() - Retrieve DPNI attributes.
576 * @mc_io: Pointer to MC portal's I/O objec
577 * @token: Token of DPNI object
578 * @attr: Returned object's attributes
580 * Return: '0' on Success; Error code otherwise.
582 int dpni_get_attributes(struct fsl_mc_io *mc_io,
584 struct dpni_attr *attr);
586 /* DPNI buffer layout modification options */
588 /* Select to modify the time-stamp setting */
589 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
590 /* Select to modify the parser-result setting; not applicable for Tx */
591 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
592 /* Select to modify the frame-status setting */
593 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
594 /* Select to modify the private-data-size setting */
595 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
596 /* Select to modify the data-alignment setting */
597 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
598 /* Select to modify the data-head-room setting */
599 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
600 /*!< Select to modify the data-tail-room setting */
601 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
604 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
605 * @options: Flags representing the suggested modifications to the buffer
606 * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
607 * @pass_timestamp: Pass timestamp value
608 * @pass_parser_result: Pass parser results
609 * @pass_frame_status: Pass frame status
610 * @private_data_size: Size kept for private data (in bytes)
611 * @data_align: Data alignment
612 * @data_head_room: Data head room
613 * @data_tail_room: Data tail room
615 struct dpni_buffer_layout {
618 int pass_parser_result;
619 int pass_frame_status;
620 uint16_t private_data_size;
622 uint16_t data_head_room;
623 uint16_t data_tail_room;
627 * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
628 * @mc_io: Pointer to MC portal's I/O object
629 * @token: Token of DPNI object
630 * @layout: Returns buffer layout attributes
632 * Return: '0' on Success; Error code otherwise.
634 int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
636 struct dpni_buffer_layout *layout);
638 * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration.
639 * @mc_io: Pointer to MC portal's I/O object
640 * @token: Token of DPNI object
641 * @layout: Buffer layout configuration
643 * Return: '0' on Success; Error code otherwise.
645 * @warning Allowed only when DPNI is disabled
647 int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
649 const struct dpni_buffer_layout *layout);
652 * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
653 * @mc_io: Pointer to MC portal's I/O object
654 * @token: Token of DPNI object
655 * @layout: Returns buffer layout attributes
657 * Return: '0' on Success; Error code otherwise.
659 int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
661 struct dpni_buffer_layout *layout);
664 * @brief Set Tx buffer layout configuration.
666 * @param[in] mc_io Pointer to MC portal's I/O object
667 * @param[in] token Token of DPNI object
668 * @param[in] layout Buffer layout configuration
670 * @returns '0' on Success; Error code otherwise.
672 * @warning Allowed only when DPNI is disabled
674 int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
676 const struct dpni_buffer_layout *layout);
678 * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
680 * @mc_io: Pointer to MC portal's I/O object
681 * @token: Token of DPNI object
682 * @layout: Returns buffer layout attributes
684 * Return: '0' on Success; Error code otherwise.
686 int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
688 struct dpni_buffer_layout *layout);
690 * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
692 * @mc_io: Pointer to MC portal's I/O object
693 * @token: Token of DPNI object
694 * @layout: Buffer layout configuration
696 * Return: '0' on Success; Error code otherwise.
698 * @warning Allowed only when DPNI is disabled
700 int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
702 const struct dpni_buffer_layout *layout);
704 * dpni_get_spid() - Get the AIOP storage profile ID associated with the DPNI
705 * @mc_io: Pointer to MC portal's I/O object
706 * @token: Token of DPNI object
707 * @spid: Returned aiop storage-profile ID
709 * Return: '0' on Success; Error code otherwise.
711 * @warning Only relevant for DPNI that belongs to AIOP container.
713 int dpni_get_qdid(struct fsl_mc_io *mc_io, uint16_t token, uint16_t *qdid);
716 * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
717 * @mc_io: Pointer to MC portal's I/O object
718 * @token: Token of DPNI object
719 * @data_offset: Tx data offset (from start of buffer)
721 * Return: '0' on Success; Error code otherwise.
723 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
725 uint16_t *data_offset);
728 * enum dpni_counter - DPNI counter types
729 * @DPNI_CNT_ING_FRAME: Counts ingress frames
730 * @DPNI_CNT_ING_BYTE: Counts ingress bytes
731 * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
733 * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
734 * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
735 * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
736 * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
737 * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
738 * @DPNI_CNT_EGR_FRAME: Counts egress frames
739 * @DPNI_CNT_EGR_BYTE: Counts egress bytes
740 * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
743 DPNI_CNT_ING_FRAME = 0x0,
744 DPNI_CNT_ING_BYTE = 0x1,
745 DPNI_CNT_ING_FRAME_DROP = 0x2,
746 DPNI_CNT_ING_FRAME_DISCARD = 0x3,
747 DPNI_CNT_ING_MCAST_FRAME = 0x4,
748 DPNI_CNT_ING_MCAST_BYTE = 0x5,
749 DPNI_CNT_ING_BCAST_FRAME = 0x6,
750 DPNI_CNT_ING_BCAST_BYTES = 0x7,
751 DPNI_CNT_EGR_FRAME = 0x8,
752 DPNI_CNT_EGR_BYTE = 0x9,
753 DPNI_CNT_EGR_FRAME_DISCARD = 0xa
757 * dpni_get_counter() - Read a specific DPNI counter
758 * @mc_io: Pointer to MC portal's I/O object
759 * @token: Token of DPNI object
760 * @counter: The requested counter
761 * @value: Returned counter's current value
763 * Return: '0' on Success; Error code otherwise.
765 int dpni_get_counter(struct fsl_mc_io *mc_io,
767 enum dpni_counter counter,
771 * dpni_set_counter() - Set (or clear) a specific DPNI counter
772 * @mc_io: Pointer to MC portal's I/O object
773 * @token: Token of DPNI object
774 * @counter: The requested counter
775 * @value: New counter value; typically pass '0' for resetting
778 * Return: '0' on Success; Error code otherwise.
780 int dpni_set_counter(struct fsl_mc_io *mc_io,
782 enum dpni_counter counter,
785 * struct - Structure representing DPNI link configuration
787 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
789 struct dpni_link_cfg {
795 * dpni_set_link_cfg() - set the link configuration.
796 * @mc_io: Pointer to MC portal's I/O object
797 * @token: Token of DPNI object
798 * @cfg: Link configuration
800 * Return: '0' on Success; Error code otherwise.
802 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
804 struct dpni_link_cfg *cfg);
807 * struct dpni_link_state - Structure representing DPNI link state
809 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
810 * @up: Link state; '0' for down, '1' for up
812 struct dpni_link_state {
819 * dpni_get_link_state() - Return the link state (either up or down)
820 * @mc_io: Pointer to MC portal's I/O object
821 * @token: Token of DPNI object
822 * @state: Returned link state;
824 * Return: '0' on Success; Error code otherwise.
826 int dpni_get_link_state(struct fsl_mc_io *mc_io,
828 struct dpni_link_state *state);
831 * dpni_set_primary_mac_addr() - Set the primary MAC address
832 * @mc_io: Pointer to MC portal's I/O object
833 * @token: Token of DPNI object
834 * @mac_addr: MAC address to set as primary address
836 * Return: '0' on Success; Error code otherwise.
838 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
840 const uint8_t mac_addr[6]);
842 * dpni_get_primary_mac_addr() - Get the primary MAC address
843 * @mc_io: Pointer to MC portal's I/O object
844 * @token: Token of DPNI object
845 * @mac_addr: Returned MAC address
847 * Return: '0' on Success; Error code otherwise.
849 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
851 uint8_t mac_addr[6]);
853 * dpni_add_mac_addr() - Add MAC address filter
854 * @mc_io: Pointer to MC portal's I/O object
855 * @token: Token of DPNI object
856 * @mac_addr: MAC address to add
858 * Return: '0' on Success; Error code otherwise.
860 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
862 const uint8_t mac_addr[6]);
865 * dpni_remove_mac_addr() - Remove MAC address filter
866 * @mc_io: Pointer to MC portal's I/O object
867 * @token: Token of DPNI object
868 * @mac_addr: MAC address to remove
870 * Return: '0' on Success; Error code otherwise.
872 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
874 const uint8_t mac_addr[6]);
877 * enum dpni_dest - DPNI destination types
878 * DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
879 * does not generate FQDAN notifications; user is expected to
880 * dequeue from the queue based on polling or other user-defined
882 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
883 * notifications to the specified DPIO; user is expected to dequeue
884 * from the queue only after notification is received
885 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
886 * FQDAN notifications, but is connected to the specified DPCON
887 * object; user is expected to dequeue from the DPCON channel
896 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
897 * @dest_type: Destination type
898 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
899 * @priority: Priority selection within the DPIO or DPCON channel; valid values
900 * are 0-1 or 0-7, depending on the number of priorities in that
901 * channel; not relevant for 'DPNI_DEST_NONE' option
903 struct dpni_dest_cfg {
904 enum dpni_dest dest_type;
909 /* DPNI queue modification options */
911 /* Select to modify the user's context associated with the queue */
912 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
913 /* Select to modify the queue's destination */
914 #define DPNI_QUEUE_OPT_DEST 0x00000002
917 * struct dpni_queue_cfg - Structure representing queue configuration
918 * @options: Flags representing the suggested modifications to the queue;
919 * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
920 * @user_ctx: User context value provided in the frame descriptor of each
921 * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
922 * is contained in 'options'
923 * @dest_cfg: Queue destination parameters;
924 * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
926 struct dpni_queue_cfg {
929 struct dpni_dest_cfg dest_cfg;
933 * struct dpni_queue_attr - Structure representing queue attributes
934 * @user_ctx: User context value provided in the frame descriptor of each
936 * @dest_cfg: Queue destination configuration
937 * @fqid: Virtual fqid value to be used for dequeue operations
939 struct dpni_queue_attr {
941 struct dpni_dest_cfg dest_cfg;
945 /* DPNI Tx flow modification options */
947 /* Select to modify the settings for dedicate Tx confirmation/error */
948 #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR 0x00000001
949 /*!< Select to modify the Tx confirmation and/or error setting */
950 #define DPNI_TX_FLOW_OPT_ONLY_TX_ERROR 0x00000002
951 /*!< Select to modify the queue configuration */
952 #define DPNI_TX_FLOW_OPT_QUEUE 0x00000004
953 /*!< Select to modify the L3 checksum generation setting */
954 #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN 0x00000010
955 /*!< Select to modify the L4 checksum generation setting */
956 #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
959 * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
960 * @options: Flags representing the suggested modifications to the Tx flow;
961 * Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
962 * @conf_err_cfg: Tx confirmation and error configuration; these settings are
963 * ignored if 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' was set at
965 * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
966 * valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in
968 * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
969 * valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in
972 struct dpni_tx_flow_cfg {
975 * struct cnf_err_cfg - Tx confirmation and error configuration
976 * @use_default_queue: Set to '1' to use the common (default) Tx
977 * confirmation and error queue; Set to '0' to use the
978 * private Tx confirmation and error queue; valid only if
979 * 'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in
981 * @errors_only: Set to '1' to report back only error frames;
982 * Set to '0' to confirm transmission/error for all
983 * transmitted frames;
984 * valid only if 'DPNI_TX_FLOW_OPT_ONLY_TX_ERROR' is
985 * contained in 'options' and 'use_default_queue = 0';
986 * @queue_cfg: Queue configuration; valid only if
987 * 'DPNI_TX_FLOW_OPT_QUEUE' is contained in 'options'
990 int use_default_queue;
992 struct dpni_queue_cfg queue_cfg;
999 * dpni_set_tx_flow() - Set Tx flow configuration
1000 * @mc_io: Pointer to MC portal's I/O object
1001 * @token: Token of DPNI object
1002 * @flow_id: Provides (or returns) the sender's flow ID;
1003 * for each new sender set (*flow_id) to
1004 * 'DPNI_NEW_FLOW_ID' to generate a new flow_id;
1005 * this ID should be used as the QDBIN argument
1006 * in enqueue operations
1007 * @cfg: Tx flow configuration
1009 * Return: '0' on Success; Error code otherwise.
1011 int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
1014 const struct dpni_tx_flow_cfg *cfg);
1017 * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
1018 * @conf_err_attr: Tx confirmation and error attributes
1019 * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
1020 * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
1022 struct dpni_tx_flow_attr {
1024 * struct conf_err_attr - Tx confirmation and error attributes
1025 * @use_default_queue: '1' if using common (default) Tx confirmation and
1027 * '0' if using private Tx confirmation and error
1029 * @errors_only: '1' if only error frames are reported back; '0' if all
1030 * transmitted frames are confirmed
1031 * @queue_attr: Queue attributes
1034 int use_default_queue;
1036 struct dpni_queue_attr queue_attr;
1043 * dpni_get_tx_flow() - Get Tx flow attributes
1044 * @mc_io: Pointer to MC portal's I/O object
1045 * @token: Token of DPNI object
1046 * @flow_id: The sender's flow ID, as returned by the
1047 * dpni_set_tx_flow() function
1048 * @attr: Returned Tx flow attributes
1050 * Return: '0' on Success; Error code otherwise.
1052 int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
1055 struct dpni_tx_flow_attr *attr);
1058 * dpni_set_rx_flow() - Set Rx flow configuration
1059 * @mc_io: Pointer to MC portal's I/O object
1060 * @token: Token of DPNI object
1061 * @tc_id: Traffic class selection (0-7);
1062 * use 'DPNI_ALL_TCS' to set all TCs and all flows
1063 * @flow_id Rx flow id within the traffic class; use
1064 * 'DPNI_ALL_TC_FLOWS' to set all flows within
1065 * this tc_id; ignored if tc_id is set to
1067 * @cfg: Rx flow configuration
1069 * Return: '0' on Success; Error code otherwise.
1071 int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
1075 const struct dpni_queue_cfg *cfg);
1078 * dpni_get_rx_flow() - Get Rx flow attributes
1079 * @mc_io: Pointer to MC portal's I/O object
1080 * @token: Token of DPNI object
1081 * @tc_id: Traffic class selection (0-7)
1082 * @flow_id: Rx flow id within the traffic class
1083 * @attr: Returned Rx flow attributes
1085 * Return: '0' on Success; Error code otherwise.
1087 int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
1091 struct dpni_queue_attr *attr);
1093 #endif /* _FSL_DPNI_H */