]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/fsl-mc/fsl_dpni.h
bootcount: Migrate CONFIG_SYS_BOOTCOUNT_ADDR
[people/ms/u-boot.git] / include / fsl-mc / fsl_dpni.h
CommitLineData
a2a55e51 1/*
2557c5a9
YG
2 * Copyright (C) 2013-2016 Freescale Semiconductor
3 * Copyright 2017 NXP
a2a55e51
PK
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7#ifndef _FSL_DPNI_H
8#define _FSL_DPNI_H
9
10/* DPNI Version */
2557c5a9
YG
11#define DPNI_VER_MAJOR 7
12#define DPNI_VER_MINOR 3
a2a55e51
PK
13
14/* Command IDs */
2557c5a9
YG
15#define DPNI_CMDID_OPEN 0x8011
16#define DPNI_CMDID_CLOSE 0x8001
17#define DPNI_CMDID_CREATE 0x9011
18#define DPNI_CMDID_DESTROY 0x9811
19#define DPNI_CMDID_GET_API_VERSION 0xa011
20
21#define DPNI_CMDID_ENABLE 0x0021
22#define DPNI_CMDID_DISABLE 0x0031
23#define DPNI_CMDID_GET_ATTR 0x0041
24#define DPNI_CMDID_RESET 0x0051
25
26#define DPNI_CMDID_SET_POOLS 0x2002
27#define DPNI_CMDID_SET_BUFFER_LAYOUT 0x2651
28#define DPNI_CMDID_GET_BUFFER_LAYOUT 0x2641
29#define DPNI_CMDID_SET_ERRORS_BEHAVIOR 0x20B1
30
31#define DPNI_CMDID_GET_QDID 0x2101
32#define DPNI_CMDID_GET_TX_DATA_OFFSET 0x2121
33#define DPNI_CMDID_GET_LINK_STATE 0x2151
34#define DPNI_CMDID_SET_LINK_CFG 0x21A1
35
36#define DPNI_CMDID_SET_PRIM_MAC 0x2241
37#define DPNI_CMDID_GET_PRIM_MAC 0x2251
38#define DPNI_CMDID_ADD_MAC_ADDR 0x2261
39#define DPNI_CMDID_REMOVE_MAC_ADDR 0x2271
40
41#define DPNI_CMDID_GET_STATISTICS 0x25D1
42#define DPNI_CMDID_RESET_STATISTICS 0x25E1
43#define DPNI_CMDID_GET_QUEUE 0x25F1
44#define DPNI_CMDID_SET_QUEUE 0x2601
45#define DPNI_CMDID_SET_TX_CONFIRMATION_MODE 0x2661
a2a55e51
PK
46
47/* cmd, param, offset, width, type, arg_name */
48#define DPNI_CMD_OPEN(cmd, dpni_id) \
49 MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
50
2557c5a9
YG
51/* cmd, param, offset, width, type, arg_name */
52#define DPNI_PREP_CFG(param, cfg) \
53e353fc 53do { \
2557c5a9
YG
54 MC_PREP_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \
55 MC_PREP_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \
56 MC_PREP_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \
57 MC_PREP_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \
58 MC_PREP_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \
59 MC_PREP_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \
60 MC_PREP_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \
53e353fc
PK
61} while (0)
62
2557c5a9
YG
63/* cmd, param, offset, width, type, arg_name */
64#define DPNI_EXT_CFG(param, cfg) \
53e353fc 65do { \
2557c5a9
YG
66 MC_EXT_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \
67 MC_EXT_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \
68 MC_EXT_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \
69 MC_EXT_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \
70 MC_EXT_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \
71 MC_EXT_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \
72 MC_EXT_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \
53e353fc
PK
73} while (0)
74
1ebbe4fc
PK
75/* cmd, param, offset, width, type, arg_name */
76#define DPNI_CMD_CREATE(cmd, cfg) \
77do { \
2557c5a9
YG
78 MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->adv.options); \
79 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->adv.num_queues); \
80 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->adv.num_tcs); \
81 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->adv.mac_entries); \
82 MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->adv.vlan_entries); \
83 MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->adv.qos_entries); \
84 MC_CMD_OP(cmd, 1, 32, 16, uint8_t, cfg->adv.fs_entries); \
1ebbe4fc 85} while (0)
a2a55e51
PK
86
87/* cmd, param, offset, width, type, arg_name */
88#define DPNI_CMD_SET_POOLS(cmd, cfg) \
89do { \
90 MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
53e353fc
PK
91 MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \
92 MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \
93 MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \
94 MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \
95 MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \
96 MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \
97 MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \
98 MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \
a2a55e51
PK
99 MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
100 MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
101 MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
102 MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
103 MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
104 MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
105 MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
106 MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
107 MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
108 MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
109 MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
110 MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
111 MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
112 MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
113 MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
114 MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
115} while (0)
116
117/* cmd, param, offset, width, type, arg_name */
118#define DPNI_RSP_GET_ATTR(cmd, attr) \
119do { \
2557c5a9
YG
120 MC_RSP_OP(cmd, 0, 0, 32, int, attr->options);\
121 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_num_queues); \
122 MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_num_tcs); \
123 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->max_mac_entries); \
124 MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->max_vlan_entries); \
125 MC_RSP_OP(cmd, 1, 16, 8, uint8_t, attr->max_qos_entries); \
126 MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->max_fs_entries); \
127 MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_qos_key_size); \
128 MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_fs_key_size); \
129 MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->wriop_version); \
a2a55e51
PK
130} while (0)
131
53e353fc
PK
132/* cmd, param, offset, width, type, arg_name */
133#define DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg) \
134do { \
135 MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->errors); \
136 MC_CMD_OP(cmd, 0, 32, 4, enum dpni_error_action, cfg->error_action); \
137 MC_CMD_OP(cmd, 0, 36, 1, int, cfg->set_frame_annotation); \
138} while (0)
139
a2a55e51 140/* cmd, param, offset, width, type, arg_name */
2557c5a9 141#define DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, queue) \
a2a55e51 142do { \
2557c5a9
YG
143 MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, queue); \
144 MC_CMD_OP(cmd, 1, 0, 16, uint16_t, layout->private_data_size); \
145 MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_align); \
146 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, layout->options); \
147 MC_CMD_OP(cmd, 0, 48, 1, int, layout->pass_timestamp); \
148 MC_CMD_OP(cmd, 0, 49, 1, int, layout->pass_parser_result); \
149 MC_CMD_OP(cmd, 0, 50, 1, int, layout->pass_frame_status); \
150 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_head_room); \
151 MC_CMD_OP(cmd, 1, 48, 16, uint16_t, layout->data_tail_room); \
a2a55e51
PK
152} while (0)
153
154/* cmd, param, offset, width, type, arg_name */
155#define DPNI_RSP_GET_QDID(cmd, qdid) \
156 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid)
157
158/* cmd, param, offset, width, type, arg_name */
159#define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
160 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset)
161
a2a55e51
PK
162/* cmd, param, offset, width, type, arg_name */
163#define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
164do { \
1f1c25c7 165 MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
a2a55e51
PK
166 MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
167} while (0)
168
169/* cmd, param, offset, width, type, arg_name */
170#define DPNI_RSP_GET_LINK_STATE(cmd, state) \
171do { \
172 MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
1f1c25c7 173 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
a2a55e51
PK
174 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
175} while (0)
176
177
178
179/* cmd, param, offset, width, type, arg_name */
180#define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
181do { \
182 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
183 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
184 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
185 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
186 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
187 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
188} while (0)
189
190/* cmd, param, offset, width, type, arg_name */
191#define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
192do { \
193 MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
194 MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
195 MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
196 MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
197 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
198 MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
199} while (0)
200
201/* cmd, param, offset, width, type, arg_name */
202#define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
203do { \
204 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
205 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
206 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
207 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
208 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
209 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
210} while (0)
211
212/* cmd, param, offset, width, type, arg_name */
213#define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
214do { \
215 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
216 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
217 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
218 MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
219 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
220 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
221} while (0)
222
2557c5a9 223#define DPNI_CMD_GET_QUEUE(cmd, type, tc, index) \
a2a55e51 224do { \
2557c5a9
YG
225 MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \
226 MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \
227 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \
a2a55e51
PK
228} while (0)
229
2557c5a9 230#define DPNI_RSP_GET_QUEUE(cmd, queue) \
a2a55e51 231do { \
2557c5a9
YG
232 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
233 MC_RSP_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \
234 MC_RSP_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \
235 MC_RSP_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \
236 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \
237 MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \
238 MC_RSP_OP(cmd, 4, 0, 32, uint32_t, (queue)->fqid); \
239 MC_RSP_OP(cmd, 4, 32, 16, uint16_t, (queue)->qdbin); \
a2a55e51
PK
240} while (0)
241
2557c5a9 242#define DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue) \
a2a55e51 243do { \
2557c5a9
YG
244 MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \
245 MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \
246 MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \
247 MC_CMD_OP(cmd, 0, 24, 8, uint8_t, (queue)->options); \
248 MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
249 MC_CMD_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \
250 MC_CMD_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \
251 MC_CMD_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \
252 MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
253 MC_CMD_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \
254 MC_CMD_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \
a2a55e51
PK
255} while (0)
256
2557c5a9
YG
257/* cmd, param, offset, width, type, arg_name */
258#define DPNI_CMD_GET_STATISTICS(cmd, page) \
259 MC_CMD_OP(cmd, 0, 0, 8, uint8_t, page)
a2a55e51
PK
260
261/* cmd, param, offset, width, type, arg_name */
2557c5a9 262#define DPNI_RSP_GET_STATISTICS(cmd, stat) \
a2a55e51 263do { \
2557c5a9
YG
264 MC_RSP_OP(cmd, 0, 0, 64, uint64_t, (stat)->counter0); \
265 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->counter1); \
266 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->counter2); \
267 MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->counter3); \
268 MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->counter4); \
269 MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->counter5); \
270 MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->counter6); \
53e353fc
PK
271} while (0)
272
a2a55e51
PK
273enum net_prot {
274 NET_PROT_NONE = 0,
275 NET_PROT_PAYLOAD,
276 NET_PROT_ETH,
277 NET_PROT_VLAN,
278 NET_PROT_IPV4,
279 NET_PROT_IPV6,
280 NET_PROT_IP,
281 NET_PROT_TCP,
282 NET_PROT_UDP,
283 NET_PROT_UDP_LITE,
284 NET_PROT_IPHC,
285 NET_PROT_SCTP,
286 NET_PROT_SCTP_CHUNK_DATA,
287 NET_PROT_PPPOE,
288 NET_PROT_PPP,
289 NET_PROT_PPPMUX,
290 NET_PROT_PPPMUX_SUBFRM,
291 NET_PROT_L2TPV2,
292 NET_PROT_L2TPV3_CTRL,
293 NET_PROT_L2TPV3_SESS,
294 NET_PROT_LLC,
295 NET_PROT_LLC_SNAP,
296 NET_PROT_NLPID,
297 NET_PROT_SNAP,
298 NET_PROT_MPLS,
299 NET_PROT_IPSEC_AH,
300 NET_PROT_IPSEC_ESP,
301 NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
302 NET_PROT_MACSEC,
303 NET_PROT_GRE,
304 NET_PROT_MINENCAP,
305 NET_PROT_DCCP,
306 NET_PROT_ICMP,
307 NET_PROT_IGMP,
308 NET_PROT_ARP,
309 NET_PROT_CAPWAP_DATA,
310 NET_PROT_CAPWAP_CTRL,
311 NET_PROT_RFC2684,
312 NET_PROT_ICMPV6,
313 NET_PROT_FCOE,
314 NET_PROT_FIP,
315 NET_PROT_ISCSI,
316 NET_PROT_GTP,
317 NET_PROT_USER_DEFINED_L2,
318 NET_PROT_USER_DEFINED_L3,
319 NET_PROT_USER_DEFINED_L4,
320 NET_PROT_USER_DEFINED_L5,
321 NET_PROT_USER_DEFINED_SHIM1,
322 NET_PROT_USER_DEFINED_SHIM2,
323
324 NET_PROT_DUMMY_LAST
325};
326
1f1c25c7
PK
327/**
328 * Data Path Network Interface API
a2a55e51
PK
329 * Contains initialization APIs and runtime control APIs for DPNI
330 */
331
332struct fsl_mc_io;
333
334/* General DPNI macros */
335
336/* Maximum number of traffic classes */
337#define DPNI_MAX_TC 8
338/* Maximum number of buffer pools per DPNI */
339#define DPNI_MAX_DPBP 8
340
341/* All traffic classes considered; see dpni_set_rx_flow() */
342#define DPNI_ALL_TCS (uint8_t)(-1)
343/* All flows within traffic class considered; see dpni_set_rx_flow() */
344#define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
345/* Generate new flow ID; see dpni_set_tx_flow() */
346#define DPNI_NEW_FLOW_ID (uint16_t)(-1)
53e353fc
PK
347/* use for common tx-conf queue; see dpni_set_tx_conf_<x>() */
348#define DPNI_COMMON_TX_CONF (uint16_t)(-1)
a2a55e51
PK
349
350/**
351 * dpni_open() - Open a control session for the specified object
352 * @mc_io: Pointer to MC portal's I/O object
87457d11 353 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
354 * @dpni_id: DPNI unique ID
355 * @token: Returned token; use in subsequent API calls
356 *
357 * This function can be used to open a control session for an
358 * already created object; an object may have been declared in
359 * the DPL or by calling the dpni_create() function.
360 * This function returns a unique authentication token,
361 * associated with the specific object ID and the specific MC
362 * portal; this token must be used in all subsequent commands for
363 * this specific object.
364 *
365 * Return: '0' on Success; Error code otherwise.
366 */
87457d11
PK
367int dpni_open(struct fsl_mc_io *mc_io,
368 uint32_t cmd_flags,
369 int dpni_id,
370 uint16_t *token);
a2a55e51
PK
371
372/**
373 * dpni_close() - Close the control session of the object
374 * @mc_io: Pointer to MC portal's I/O object
87457d11 375 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
376 * @token: Token of DPNI object
377 *
378 * After this function is called, no further operations are
379 * allowed on the object without opening a new control session.
380 *
381 * Return: '0' on Success; Error code otherwise.
382 */
87457d11
PK
383int dpni_close(struct fsl_mc_io *mc_io,
384 uint32_t cmd_flags,
385 uint16_t token);
a2a55e51 386
1ebbe4fc
PK
387/* DPNI configuration options */
388
389/**
390 * Allow different distribution key profiles for different traffic classes;
391 * if not set, a single key profile is assumed
392 */
393#define DPNI_OPT_ALLOW_DIST_KEY_PER_TC 0x00000001
394
395/**
396 * Disable all non-error transmit confirmation; error frames are reported
397 * back to a common Tx error queue
398 */
399#define DPNI_OPT_TX_CONF_DISABLED 0x00000002
400
401/* Disable per-sender private Tx confirmation/error queue */
402#define DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED 0x00000004
403
404/**
405 * Support distribution based on hashed key;
406 * allows statistical distribution over receive queues in a traffic class
407 */
408#define DPNI_OPT_DIST_HASH 0x00000010
409
410/**
411 * Support distribution based on flow steering;
412 * allows explicit control of distribution over receive queues in a traffic
413 * class
414 */
415#define DPNI_OPT_DIST_FS 0x00000020
416
417/* Unicast filtering support */
418#define DPNI_OPT_UNICAST_FILTER 0x00000080
419/* Multicast filtering support */
420#define DPNI_OPT_MULTICAST_FILTER 0x00000100
421/* VLAN filtering support */
422#define DPNI_OPT_VLAN_FILTER 0x00000200
423/* Support IP reassembly on received packets */
424#define DPNI_OPT_IPR 0x00000800
425/* Support IP fragmentation on transmitted packets */
426#define DPNI_OPT_IPF 0x00001000
427/* VLAN manipulation support */
428#define DPNI_OPT_VLAN_MANIPULATION 0x00010000
429/* Support masking of QoS lookup keys */
430#define DPNI_OPT_QOS_MASK_SUPPORT 0x00020000
431/* Support masking of Flow Steering lookup keys */
432#define DPNI_OPT_FS_MASK_SUPPORT 0x00040000
433
2557c5a9
YG
434/**
435 * enum dpni_queue_type - Identifies a type of queue targeted by the command
436 * @DPNI_QUEUE_RX: Rx queue
437 * @DPNI_QUEUE_TX: Tx queue
438 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
439 * @DPNI_QUEUE_RX_ERR: Rx error queue
440 */
441enum dpni_queue_type {
442 DPNI_QUEUE_RX,
443 DPNI_QUEUE_TX,
444 DPNI_QUEUE_TX_CONFIRM,
445 DPNI_QUEUE_RX_ERR,
446};
447
448struct dpni_cfg {
449 uint8_t mac_addr[6];
450 struct {
451 uint32_t options;
452 uint16_t fs_entries;
453 uint8_t num_queues;
454 uint8_t num_tcs;
455 uint8_t mac_entries;
456 uint8_t vlan_entries;
457 uint8_t qos_entries;
458 } adv;
459};
460
a2a55e51 461/**
53e353fc
PK
462 * struct dpni_extended_cfg - Structure representing extended DPNI configuration
463 * @tc_cfg: TCs configuration
464 * @ipr_cfg: IP reassembly configuration
a2a55e51 465 */
53e353fc
PK
466struct dpni_extended_cfg {
467 /**
468 * struct tc_cfg - TC configuration
469 * @max_dist: Maximum distribution size for Rx traffic class;
470 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
471 * 112,128,192,224,256,384,448,512,768,896,1024;
472 * value '0' will be treated as '1'.
473 * other unsupported values will be round down to the nearest
474 * supported value.
475 * @max_fs_entries: Maximum FS entries for Rx traffic class;
476 * '0' means no support for this TC;
477 */
478 struct {
479 uint16_t max_dist;
480 uint16_t max_fs_entries;
481 } tc_cfg[DPNI_MAX_TC];
482 /**
483 * struct ipr_cfg - Structure representing IP reassembly configuration
484 * @max_reass_frm_size: Maximum size of the reassembled frame
485 * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
486 * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
487 * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly
488 * process
489 * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly
490 * process
491 */
492 struct {
493 uint16_t max_reass_frm_size;
494 uint16_t min_frag_size_ipv4;
495 uint16_t min_frag_size_ipv6;
496 uint16_t max_open_frames_ipv4;
497 uint16_t max_open_frames_ipv6;
498 } ipr_cfg;
a2a55e51
PK
499};
500
53e353fc 501/**
2557c5a9
YG
502 * dpni_prepare_cfg() - function prepare parameters
503 * @cfg: cfg structure
504 * @cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
53e353fc
PK
505 *
506 * This function has to be called before dpni_create()
507 */
2557c5a9
YG
508int dpni_prepare_cfg(const struct dpni_cfg *cfg,
509 uint8_t *cfg_buf);
1ebbe4fc
PK
510/**
511 * dpni_create() - Create the DPNI object
512 * @mc_io: Pointer to MC portal's I/O object
2557c5a9 513 * @token: Authentication token.
1ebbe4fc
PK
514 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
515 * @cfg: Configuration structure
2557c5a9 516 * @obj_id: Returned obj_id; use in subsequent API calls
1ebbe4fc
PK
517 *
518 * Create the DPNI object, allocate required resources and
519 * perform required initialization.
520 *
521 * The object can be created either by declaring it in the
522 * DPL file, or by calling this function.
523 *
524 * This function returns a unique authentication token,
525 * associated with the specific object ID and the specific MC
526 * portal; this token must be used in all subsequent calls to
527 * this specific object. For objects that are created using the
528 * DPL file, call dpni_open() function to get an authentication
529 * token first.
530 *
531 * Return: '0' on Success; Error code otherwise.
532 */
533int dpni_create(struct fsl_mc_io *mc_io,
2557c5a9 534 uint16_t token,
1ebbe4fc
PK
535 uint32_t cmd_flags,
536 const struct dpni_cfg *cfg,
2557c5a9 537 uint32_t *obj_id);
1ebbe4fc
PK
538
539/**
540 * dpni_destroy() - Destroy the DPNI object and release all its resources.
541 * @mc_io: Pointer to MC portal's I/O object
2557c5a9 542 * @token: Authentication token.
1ebbe4fc 543 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
2557c5a9 544 * @obj_id: Returned obj_id; use in subsequent API calls
1ebbe4fc
PK
545 *
546 * Return: '0' on Success; error code otherwise.
547 */
548int dpni_destroy(struct fsl_mc_io *mc_io,
2557c5a9 549 uint16_t token,
1ebbe4fc 550 uint32_t cmd_flags,
2557c5a9 551 uint32_t obj_id);
1ebbe4fc 552
a2a55e51
PK
553/**
554 * struct dpni_pools_cfg - Structure representing buffer pools configuration
555 * @num_dpbp: Number of DPBPs
556 * @pools: Array of buffer pools parameters; The number of valid entries
557 * must match 'num_dpbp' value
558 */
559struct dpni_pools_cfg {
560 uint8_t num_dpbp;
561 /**
562 * struct pools - Buffer pools parameters
563 * @dpbp_id: DPBP object ID
564 * @buffer_size: Buffer size
87457d11 565 * @backup_pool: Backup pool
a2a55e51
PK
566 */
567 struct {
87457d11
PK
568 int dpbp_id;
569 uint16_t buffer_size;
570 int backup_pool;
a2a55e51
PK
571 } pools[DPNI_MAX_DPBP];
572};
573
574/**
575 * dpni_set_pools() - Set buffer pools configuration
576 * @mc_io: Pointer to MC portal's I/O object
87457d11 577 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
578 * @token: Token of DPNI object
579 * @cfg: Buffer pools configuration
580 *
581 * mandatory for DPNI operation
582 * warning:Allowed only when DPNI is disabled
583 *
584 * Return: '0' on Success; Error code otherwise.
585 */
586int dpni_set_pools(struct fsl_mc_io *mc_io,
87457d11 587 uint32_t cmd_flags,
a2a55e51
PK
588 uint16_t token,
589 const struct dpni_pools_cfg *cfg);
590
591/**
592 * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
87457d11
PK
593 * @mc_io: Pointer to MC portal's I/O object
594 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
595 * @token: Token of DPNI object
596 *
597 * Return: '0' on Success; Error code otherwise.
598 */
87457d11
PK
599int dpni_enable(struct fsl_mc_io *mc_io,
600 uint32_t cmd_flags,
601 uint16_t token);
a2a55e51
PK
602
603/**
604 * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
605 * @mc_io: Pointer to MC portal's I/O object
87457d11 606 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
607 * @token: Token of DPNI object
608 *
609 * Return: '0' on Success; Error code otherwise.
610 */
87457d11
PK
611int dpni_disable(struct fsl_mc_io *mc_io,
612 uint32_t cmd_flags,
613 uint16_t token);
a2a55e51
PK
614
615
616/**
87457d11 617 * dpni_reset() - Reset the DPNI, returns the object to initial state.
a2a55e51 618 * @mc_io: Pointer to MC portal's I/O object
87457d11 619 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
620 * @token: Token of DPNI object
621 *
622 * Return: '0' on Success; Error code otherwise.
623 */
87457d11
PK
624int dpni_reset(struct fsl_mc_io *mc_io,
625 uint32_t cmd_flags,
626 uint16_t token);
a2a55e51
PK
627
628/**
629 * struct dpni_attr - Structure representing DPNI attributes
a2a55e51
PK
630 * @options: Mask of available options; reflects the value as was given in
631 * object's creation
2557c5a9
YG
632 * @max_num_queues: Number of queues available (for both Tx and Rx)
633 * @max_num_tcs: Maximum number of traffic classes (for both Tx and Rx)
634 * @max_mac_entries: Maximum number of traffic classes (for both Tx and Rx)
a2a55e51
PK
635 * @max_unicast_filters: Maximum number of unicast filters
636 * @max_multicast_filters: Maximum number of multicast filters
2557c5a9 637 * @max_vlan_entries: Maximum number of VLAN filters
a2a55e51 638 * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
2557c5a9 639 * @max_fs_entries: declares the maximum entries in flow steering table
a2a55e51 640 * @max_qos_key_size: Maximum key size for the QoS look-up
2557c5a9
YG
641 * @max_fs_key_size: Maximum key size for the flow steering
642 * @wriop_version: Indicates revision of WRIOP hardware block
a2a55e51
PK
643 */
644struct dpni_attr {
2557c5a9 645 uint32_t id;
1f1c25c7 646 uint32_t options;
2557c5a9
YG
647 uint8_t max_num_queues;
648 uint8_t max_num_tcs;
649 uint8_t max_mac_entries;
650 uint8_t max_vlan_entries;
a2a55e51 651 uint8_t max_qos_entries;
2557c5a9 652 uint16_t max_fs_entries;
a2a55e51 653 uint8_t max_qos_key_size;
2557c5a9
YG
654 uint8_t max_fs_key_size;
655 uint16_t wriop_version;
a2a55e51 656};
1f1c25c7 657
a2a55e51
PK
658/**
659 * dpni_get_attributes() - Retrieve DPNI attributes.
87457d11
PK
660 * @mc_io: Pointer to MC portal's I/O object
661 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51 662 * @token: Token of DPNI object
53e353fc 663 * @attr: Object's attributes
a2a55e51
PK
664 *
665 * Return: '0' on Success; Error code otherwise.
666 */
667int dpni_get_attributes(struct fsl_mc_io *mc_io,
87457d11 668 uint32_t cmd_flags,
a2a55e51
PK
669 uint16_t token,
670 struct dpni_attr *attr);
671
53e353fc 672/**
2557c5a9
YG
673 * dpni_extract_cfg() - extract the parameters
674 * @cfg: cfg structure
675 * @cfg_buf: 256 bytes of DMA-able memory
53e353fc
PK
676 *
677 * This function has to be called after dpni_get_attributes()
678 */
2557c5a9
YG
679int dpni_extract_cfg(struct dpni_cfg *cfg,
680 const uint8_t *cfg_buf);
53e353fc
PK
681
682/**
683 * DPNI errors
684 */
685
686/**
687 * Extract out of frame header error
688 */
689#define DPNI_ERROR_EOFHE 0x00020000
690/**
691 * Frame length error
692 */
693#define DPNI_ERROR_FLE 0x00002000
694/**
695 * Frame physical error
696 */
697#define DPNI_ERROR_FPE 0x00001000
698/**
699 * Parsing header error
700 */
701#define DPNI_ERROR_PHE 0x00000020
702/**
703 * Parser L3 checksum error
704 */
705#define DPNI_ERROR_L3CE 0x00000004
706/**
707 * Parser L3 checksum error
708 */
709#define DPNI_ERROR_L4CE 0x00000001
710
711/**
712 * enum dpni_error_action - Defines DPNI behavior for errors
713 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
714 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
715 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
716 */
717enum dpni_error_action {
718 DPNI_ERROR_ACTION_DISCARD = 0,
719 DPNI_ERROR_ACTION_CONTINUE = 1,
720 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
721};
722
723/**
724 * struct dpni_error_cfg - Structure representing DPNI errors treatment
725 * @errors: Errors mask; use 'DPNI_ERROR__<X>
726 * @error_action: The desired action for the errors mask
727 * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
728 * status (FAS); relevant only for the non-discard action
729 */
730struct dpni_error_cfg {
731 uint32_t errors;
732 enum dpni_error_action error_action;
733 int set_frame_annotation;
734};
735
736/**
737 * dpni_set_errors_behavior() - Set errors behavior
738 * @mc_io: Pointer to MC portal's I/O object
739 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
740 * @token: Token of DPNI object
741 * @cfg: Errors configuration
742 *
743 * this function may be called numerous times with different
744 * error masks
745 *
746 * Return: '0' on Success; Error code otherwise.
747 */
748int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
749 uint32_t cmd_flags,
750 uint16_t token,
751 struct dpni_error_cfg *cfg);
752
a2a55e51
PK
753/* DPNI buffer layout modification options */
754
755/* Select to modify the time-stamp setting */
756#define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
757/* Select to modify the parser-result setting; not applicable for Tx */
758#define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
759/* Select to modify the frame-status setting */
760#define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
761/* Select to modify the private-data-size setting */
762#define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
763/* Select to modify the data-alignment setting */
764#define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
765/* Select to modify the data-head-room setting */
766#define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
767/*!< Select to modify the data-tail-room setting */
768#define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
769
770/**
771 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
772 * @options: Flags representing the suggested modifications to the buffer
773 * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
774 * @pass_timestamp: Pass timestamp value
775 * @pass_parser_result: Pass parser results
776 * @pass_frame_status: Pass frame status
777 * @private_data_size: Size kept for private data (in bytes)
778 * @data_align: Data alignment
779 * @data_head_room: Data head room
780 * @data_tail_room: Data tail room
781 */
782struct dpni_buffer_layout {
2557c5a9 783 uint16_t options;
a2a55e51
PK
784 int pass_timestamp;
785 int pass_parser_result;
786 int pass_frame_status;
787 uint16_t private_data_size;
788 uint16_t data_align;
789 uint16_t data_head_room;
790 uint16_t data_tail_room;
791};
792
793/**
2557c5a9 794 * dpni_get_buffer_layout() - Retrieve buffer layout attributes.
a2a55e51 795 * @mc_io: Pointer to MC portal's I/O object
87457d11 796 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
797 * @token: Token of DPNI object
798 * @layout: Returns buffer layout attributes
2557c5a9 799 * @type: DPNI queue type
a2a55e51
PK
800 *
801 * Return: '0' on Success; Error code otherwise.
802 */
2557c5a9
YG
803int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
804 uint32_t cmd_flags,
805 uint16_t token,
806 const struct dpni_buffer_layout *layout,
807 enum dpni_queue_type type);
1f1c25c7 808
a2a55e51 809/**
2557c5a9 810 * dpni_set_buffer_layout() - Set buffer layout configuration.
a2a55e51 811 * @mc_io: Pointer to MC portal's I/O object
87457d11 812 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
813 * @token: Token of DPNI object
814 * @layout: Buffer layout configuration
2557c5a9 815 * @type: DPNI queue type
a2a55e51
PK
816 *
817 * Return: '0' on Success; Error code otherwise.
818 *
819 * @warning Allowed only when DPNI is disabled
820 */
2557c5a9
YG
821int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
822 uint32_t cmd_flags,
823 uint16_t token,
824 const struct dpni_buffer_layout *layout,
825 enum dpni_queue_type type);
1f1c25c7 826
a2a55e51 827/**
1f1c25c7
PK
828 * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
829 * for enqueue operations
a2a55e51 830 * @mc_io: Pointer to MC portal's I/O object
87457d11 831 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51 832 * @token: Token of DPNI object
1f1c25c7
PK
833 * @qdid: Returned virtual QDID value that should be used as an argument
834 * in all enqueue operations
a2a55e51
PK
835 *
836 * Return: '0' on Success; Error code otherwise.
a2a55e51 837 */
87457d11
PK
838int dpni_get_qdid(struct fsl_mc_io *mc_io,
839 uint32_t cmd_flags,
840 uint16_t token,
841 uint16_t *qdid);
a2a55e51
PK
842
843/**
844 * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
845 * @mc_io: Pointer to MC portal's I/O object
87457d11 846 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
847 * @token: Token of DPNI object
848 * @data_offset: Tx data offset (from start of buffer)
849 *
850 * Return: '0' on Success; Error code otherwise.
851 */
852int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
87457d11 853 uint32_t cmd_flags,
a2a55e51
PK
854 uint16_t token,
855 uint16_t *data_offset);
856
1f1c25c7
PK
857/* Enable auto-negotiation */
858#define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
859/* Enable half-duplex mode */
860#define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
861/* Enable pause frames */
862#define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
863/* Enable a-symmetric pause frames */
864#define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
865
a2a55e51
PK
866/**
867 * struct - Structure representing DPNI link configuration
868 * @rate: Rate
869 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
870 */
871struct dpni_link_cfg {
1f1c25c7 872 uint32_t rate;
a2a55e51
PK
873 uint64_t options;
874};
875
876/**
877 * dpni_set_link_cfg() - set the link configuration.
878 * @mc_io: Pointer to MC portal's I/O object
87457d11 879 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
880 * @token: Token of DPNI object
881 * @cfg: Link configuration
882 *
883 * Return: '0' on Success; Error code otherwise.
884 */
87457d11
PK
885int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
886 uint32_t cmd_flags,
887 uint16_t token,
888 const struct dpni_link_cfg *cfg);
a2a55e51
PK
889
890/**
891 * struct dpni_link_state - Structure representing DPNI link state
892 * @rate: Rate
893 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
894 * @up: Link state; '0' for down, '1' for up
895 */
896struct dpni_link_state {
1f1c25c7 897 uint32_t rate;
a2a55e51
PK
898 uint64_t options;
899 int up;
900};
901
902/**
903 * dpni_get_link_state() - Return the link state (either up or down)
904 * @mc_io: Pointer to MC portal's I/O object
87457d11 905 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
906 * @token: Token of DPNI object
907 * @state: Returned link state;
908 *
909 * Return: '0' on Success; Error code otherwise.
910 */
87457d11
PK
911int dpni_get_link_state(struct fsl_mc_io *mc_io,
912 uint32_t cmd_flags,
913 uint16_t token,
914 struct dpni_link_state *state);
a2a55e51
PK
915
916/**
917 * dpni_set_primary_mac_addr() - Set the primary MAC address
918 * @mc_io: Pointer to MC portal's I/O object
87457d11 919 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
920 * @token: Token of DPNI object
921 * @mac_addr: MAC address to set as primary address
922 *
923 * Return: '0' on Success; Error code otherwise.
924 */
87457d11
PK
925int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
926 uint32_t cmd_flags,
a2a55e51
PK
927 uint16_t token,
928 const uint8_t mac_addr[6]);
1f1c25c7 929
a2a55e51
PK
930/**
931 * dpni_get_primary_mac_addr() - Get the primary MAC address
932 * @mc_io: Pointer to MC portal's I/O object
87457d11 933 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
934 * @token: Token of DPNI object
935 * @mac_addr: Returned MAC address
936 *
937 * Return: '0' on Success; Error code otherwise.
938 */
939int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
87457d11 940 uint32_t cmd_flags,
a2a55e51
PK
941 uint16_t token,
942 uint8_t mac_addr[6]);
1f1c25c7 943
a2a55e51
PK
944/**
945 * dpni_add_mac_addr() - Add MAC address filter
946 * @mc_io: Pointer to MC portal's I/O object
87457d11 947 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
948 * @token: Token of DPNI object
949 * @mac_addr: MAC address to add
950 *
951 * Return: '0' on Success; Error code otherwise.
952 */
953int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
87457d11 954 uint32_t cmd_flags,
a2a55e51
PK
955 uint16_t token,
956 const uint8_t mac_addr[6]);
957
958/**
959 * dpni_remove_mac_addr() - Remove MAC address filter
960 * @mc_io: Pointer to MC portal's I/O object
87457d11 961 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51
PK
962 * @token: Token of DPNI object
963 * @mac_addr: MAC address to remove
964 *
965 * Return: '0' on Success; Error code otherwise.
966 */
967int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
87457d11 968 uint32_t cmd_flags,
a2a55e51
PK
969 uint16_t token,
970 const uint8_t mac_addr[6]);
971
972/**
973 * enum dpni_dest - DPNI destination types
1f1c25c7 974 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
a2a55e51
PK
975 * does not generate FQDAN notifications; user is expected to
976 * dequeue from the queue based on polling or other user-defined
977 * method
978 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
979 * notifications to the specified DPIO; user is expected to dequeue
980 * from the queue only after notification is received
981 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
982 * FQDAN notifications, but is connected to the specified DPCON
983 * object; user is expected to dequeue from the DPCON channel
984 */
985enum dpni_dest {
986 DPNI_DEST_NONE = 0,
987 DPNI_DEST_DPIO = 1,
988 DPNI_DEST_DPCON = 2
989};
990
991/**
992 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
993 * @dest_type: Destination type
994 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
995 * @priority: Priority selection within the DPIO or DPCON channel; valid values
996 * are 0-1 or 0-7, depending on the number of priorities in that
997 * channel; not relevant for 'DPNI_DEST_NONE' option
998 */
999struct dpni_dest_cfg {
1000 enum dpni_dest dest_type;
1001 int dest_id;
1002 uint8_t priority;
1003};
1004
1f1c25c7
PK
1005/**
1006 * enum dpni_flc_type - DPNI FLC types
1007 * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
1008 * @DPNI_FLC_STASH: select the FLC to be used for stash control
1009 */
1010enum dpni_flc_type {
1011 DPNI_FLC_USER_DEFINED = 0,
1012 DPNI_FLC_STASH = 1,
1013};
1014
1015/**
1016 * enum dpni_stash_size - DPNI FLC stashing size
1017 * @DPNI_STASH_SIZE_0B: no stash
1018 * @DPNI_STASH_SIZE_64B: stashes 64 bytes
1019 * @DPNI_STASH_SIZE_128B: stashes 128 bytes
1020 * @DPNI_STASH_SIZE_192B: stashes 192 bytes
1021 */
1022enum dpni_stash_size {
1023 DPNI_STASH_SIZE_0B = 0,
1024 DPNI_STASH_SIZE_64B = 1,
1025 DPNI_STASH_SIZE_128B = 2,
1026 DPNI_STASH_SIZE_192B = 3,
1027};
1028
1029/* DPNI FLC stash options */
1030
1031/* stashes the whole annotation area (up to 192 bytes) */
1032#define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
1033
1034/**
1035 * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
1036 * @flc_type: FLC type
1037 * @options: Mask of available options;
1038 * use 'DPNI_FLC_STASH_<X>' values
1039 * @frame_data_size: Size of frame data to be stashed
1040 * @flow_context_size: Size of flow context to be stashed
1041 * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
1042 * this value will be provided in the frame descriptor
1043 * (FD[FLC])
1044 * 2. In case flc_type is 'DPNI_FLC_STASH':
1045 * this value will be I/O virtual address of the
1046 * flow-context;
1047 * Must be cacheline-aligned and DMA-able memory
1048 */
1049struct dpni_flc_cfg {
1050 enum dpni_flc_type flc_type;
1051 uint32_t options;
1052 enum dpni_stash_size frame_data_size;
1053 enum dpni_stash_size flow_context_size;
1054 uint64_t flow_context;
1055};
1056
a2a55e51
PK
1057/* DPNI queue modification options */
1058
1059/* Select to modify the user's context associated with the queue */
1060#define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1061/* Select to modify the queue's destination */
1062#define DPNI_QUEUE_OPT_DEST 0x00000002
1f1c25c7
PK
1063/** Select to modify the flow-context parameters;
1064 * not applicable for Tx-conf/Err queues as the FD comes from the user
1065 */
1066#define DPNI_QUEUE_OPT_FLC 0x00000004
87457d11
PK
1067/* Select to modify the queue's order preservation */
1068#define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008
53e353fc
PK
1069/* Select to modify the queue's tail-drop threshold */
1070#define DPNI_QUEUE_OPT_TAILDROP_THRESHOLD 0x00000010
a2a55e51
PK
1071
1072/**
1073 * struct dpni_queue_cfg - Structure representing queue configuration
1074 * @options: Flags representing the suggested modifications to the queue;
1075 * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
1076 * @user_ctx: User context value provided in the frame descriptor of each
1077 * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
1078 * is contained in 'options'
1079 * @dest_cfg: Queue destination parameters;
1080 * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
1f1c25c7
PK
1081 * @flc_cfg: Flow context configuration; in case the TC's distribution
1082 * is either NONE or HASH the FLC's settings of flow#0 are used.
1083 * in the case of FS (flow-steering) the flow's FLC settings
1084 * are used.
1085 * valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
87457d11
PK
1086 * @order_preservation_en: enable/disable order preservation;
1087 * valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained
1088 * in 'options'
53e353fc
PK
1089 * @tail_drop_threshold: set the queue's tail drop threshold in bytes;
1090 * '0' value disable the threshold; maximum value is 0xE000000;
1091 * valid only if 'DPNI_QUEUE_OPT_TAILDROP_THRESHOLD' is contained
1092 * in 'options'
a2a55e51
PK
1093 */
1094struct dpni_queue_cfg {
1095 uint32_t options;
1096 uint64_t user_ctx;
1097 struct dpni_dest_cfg dest_cfg;
1f1c25c7 1098 struct dpni_flc_cfg flc_cfg;
87457d11 1099 int order_preservation_en;
53e353fc 1100 uint32_t tail_drop_threshold;
a2a55e51
PK
1101};
1102
1103/**
1104 * struct dpni_queue_attr - Structure representing queue attributes
1105 * @user_ctx: User context value provided in the frame descriptor of each
1106 * dequeued frame
1107 * @dest_cfg: Queue destination configuration
1f1c25c7 1108 * @flc_cfg: Flow context configuration
87457d11 1109 * @order_preservation_en: enable/disable order preservation
53e353fc 1110 * @tail_drop_threshold: queue's tail drop threshold in bytes;
a2a55e51
PK
1111 * @fqid: Virtual fqid value to be used for dequeue operations
1112 */
1113struct dpni_queue_attr {
1114 uint64_t user_ctx;
1115 struct dpni_dest_cfg dest_cfg;
1f1c25c7 1116 struct dpni_flc_cfg flc_cfg;
87457d11 1117 int order_preservation_en;
53e353fc 1118 uint32_t tail_drop_threshold;
a2a55e51
PK
1119 uint32_t fqid;
1120};
1121
1122/* DPNI Tx flow modification options */
1123
1124/* Select to modify the settings for dedicate Tx confirmation/error */
1125#define DPNI_TX_FLOW_OPT_TX_CONF_ERROR 0x00000001
a2a55e51
PK
1126/*!< Select to modify the L3 checksum generation setting */
1127#define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN 0x00000010
1128/*!< Select to modify the L4 checksum generation setting */
1129#define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
1130
1131/**
2557c5a9
YG
1132 * dpni_get_api_version - Retrieve DPNI Major and Minor version info.
1133 *
a2a55e51 1134 * @mc_io: Pointer to MC portal's I/O object
87457d11 1135 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
2557c5a9
YG
1136 * @major_ver: DPNI major version
1137 * @minor_ver: DPNI minor version
a2a55e51 1138 *
2557c5a9
YG
1139 * Return: '0' on Success; Error code otherwise.
1140 */
1141int dpni_get_api_version(struct fsl_mc_io *mc_io,
1142 u32 cmd_flags,
1143 u16 *major_ver,
1144 u16 *minor_ver);
1145
1146/**
1147 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1148 * confirmation
1149 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1150 * an affine Tx Confirmation queue
1151 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1152 * confirmation queue
1153 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
1154 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1155 * buffers will be leaked.
1156 */
1157enum dpni_confirmation_mode {
1158 DPNI_CONF_AFFINE,
1159 DPNI_CONF_SINGLE,
1160 DPNI_CONF_DISABLE,
a2a55e51
PK
1161};
1162
2557c5a9
YG
1163struct dpni_tx_confirmation_mode {
1164 uint32_t pad;
1165 uint8_t confirmation_mode;
1166};
a2a55e51 1167
53e353fc 1168/**
2557c5a9
YG
1169 * struct dpni_queue - Queue structure
1170 * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
1171 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
1172 * for Tx queues.
1173 * @flc: FLC value for traffic dequeued from this queue.
1174 * @user_context: User data, presented to the user along with any frames
1175 * from this queue. Not relevant for Tx queues.
53e353fc 1176 */
2557c5a9
YG
1177struct dpni_queue {
1178 /**
1179 * struct destination - Destination structure
1180 * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
1181 * Identifies either a DPIO or a DPCON object. Not relevant for Tx
1182 * queues.
1183 * @type: May be one of the following:
1184 * 0 - No destination, queue can be manually queried, but won't
1185 * push traffic or notifications to a DPIO;
1186 * 1 - The destination is DPIO. When traffic becomes available in
1187 * the queue a FQDAN (FQ data available notification) will be
1188 * generated to selected DPIO;
1189 * 2 - The destination is a DPCON. The queue is associated with a
1190 * DPCON object for purpose of scheduling between multiple
1191 * queues. The DPCON may be independently configured to
1192 * generate notifications. Not relevant for Tx queues.
1193 * @hold_active: Hold active
1194 */
1195 struct {
1196 uint32_t id;
1197 enum dpni_dest type;
1198 char hold_active;
1199 char stash_ctrl;
1200 } destination;
1201 uint8_t options;
1202 uint32_t fqid;
1203 uint16_t qdbin;
1204 uint64_t flc;
1205 uint64_t user_context;
53e353fc
PK
1206};
1207
1208/**
2557c5a9
YG
1209 * dpni_set_queue() - Set queue parameters
1210 * @mc_io: Pointer to MC portal's I/O object
1211 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1212 * @token: Token of DPNI object
1213 * @type: Type of queue
1214 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1215 * @index: Selects the specific queue out of the set allocated for the same
1216 * TC. Value must be in range 0 to NUM_QUEUES - 1
1217 * @queue: Queue structure
53e353fc 1218 *
2557c5a9
YG
1219 * Return: '0' on Success; Error code otherwise.
1220 */
1221int dpni_set_queue(struct fsl_mc_io *mc_io,
1222 uint32_t cmd_flags,
1223 uint16_t token,
1224 enum dpni_queue_type type,
1225 uint8_t tc,
1226 uint8_t index,
1227 const struct dpni_queue *queue);
1228
1229/**
1230 * dpni_get_queue() - Get queue parameters
1231 * @mc_io: Pointer to MC portal's I/O object
1232 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1233 * @token: Token of DPNI object
1234 * @type: Type of queue
1235 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1236 * @index: Selects the specific queue out of the set allocated for the same
1237 * TC. Value must be in range 0 to NUM_QUEUES - 1
1238 * @queue: Queue structure
53e353fc 1239 *
2557c5a9 1240 * Return: '0' on Success; Error code otherwise.
53e353fc 1241 */
2557c5a9
YG
1242int dpni_get_queue(struct fsl_mc_io *mc_io,
1243 uint32_t cmd_flags,
1244 uint16_t token,
1245 enum dpni_queue_type type,
1246 uint8_t tc,
1247 uint8_t index,
1248 struct dpni_queue *queue);
53e353fc
PK
1249
1250/**
2557c5a9
YG
1251 * dpni_set_tx_confirmation_mode() - Set TX conf mode
1252 * @mc_io: Pointer to MC portal's I/O object
1253 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1254 * @token: Token of DPNI object
1255 * @mode: DPNI confirmation mode type
1256 *
1257 * Return: '0' on Success; Error code otherwise.
53e353fc 1258 */
2557c5a9
YG
1259int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1260 uint32_t cmd_flags,
1261 uint16_t token,
1262 enum dpni_confirmation_mode mode);
1263struct dpni_statistics {
1264 /**
1265 * Page_0 statistics structure
1266 * @ingress_all_frames: Ingress frame count
1267 * @ingress_all_bytes: Ingress byte count
1268 * @ingress_multicast_frames: Ingress multicast frame count
1269 * @ingress_multicast_bytes: Ingress multicast byte count
1270 * @ingress_broadcast_frames: Ingress broadcast frame count
1271 * @ingress_broadcast_bytes: Ingress broadcast byte count
1272 *
1273 * Page_1 statistics structure
1274 * @egress_all_frames: Egress frame count
1275 * @egress_all_bytes: Egress byte count
1276 * @egress_multicast_frames: Egress multicast frame count
1277 * @egress_multicast_bytes: Egress multicast byte count
1278 * @egress_broadcast_frames: Egress broadcast frame count
1279 * @egress_broadcast_bytes: Egress broadcast byte count
1280 *
1281 * Page_2 statistics structure
1282 * @ingress_filtered_frames: Ingress filtered frame count
1283 * @ingress_discarded_frames: Ingress discarded frame count
1284 * @ingress_nobuffer_discards: Ingress discarded frame count due to
1285 * lack of buffers.
1286 * @egress_discarded_frames: Egress discarded frame count
1287 * @egress_confirmed_frames: Egress confirmed frame count
1288 */
1289
1290 uint64_t counter0;
1291 uint64_t counter1;
1292 uint64_t counter2;
1293 uint64_t counter3;
1294 uint64_t counter4;
1295 uint64_t counter5;
1296 uint64_t counter6;
53e353fc
PK
1297};
1298
1299/**
2557c5a9 1300 * dpni_get_statistics() - Get DPNI statistics
53e353fc
PK
1301 * @mc_io: Pointer to MC portal's I/O object
1302 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1303 * @token: Token of DPNI object
2557c5a9
YG
1304 * @page: Selects the statistics page to retrieve, see DPNI_GET_STATISTICS
1305 * output. Pages are numbered 0 to 2.
1306 * @stat: Structure containing the statistics
53e353fc
PK
1307 *
1308 * Return: '0' on Success; Error code otherwise.
1309 */
2557c5a9
YG
1310int dpni_get_statistics(struct fsl_mc_io *mc_io,
1311 uint32_t cmd_flags,
1312 uint16_t token,
1313 uint8_t page,
1314 struct dpni_statistics *stat);
a2a55e51
PK
1315
1316/**
2557c5a9 1317 * dpni_reset_statistics() - Clears DPNI statistics
a2a55e51 1318 * @mc_io: Pointer to MC portal's I/O object
87457d11 1319 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
a2a55e51 1320 * @token: Token of DPNI object
a2a55e51
PK
1321 *
1322 * Return: '0' on Success; Error code otherwise.
1323 */
2557c5a9
YG
1324int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1325 uint32_t cmd_flags,
1326 uint16_t token);
a2a55e51 1327#endif /* _FSL_DPNI_H */