1
2
3
4
5
6
7
8 #ifndef __FSL_DPSW_CMD_H
9 #define __FSL_DPSW_CMD_H
10
11
12 #define DPSW_VER_MAJOR 8
13 #define DPSW_VER_MINOR 1
14
15 #define DPSW_CMD_BASE_VERSION 1
16 #define DPSW_CMD_ID_OFFSET 4
17
18 #define DPSW_CMD_ID(id) (((id) << DPSW_CMD_ID_OFFSET) | DPSW_CMD_BASE_VERSION)
19
20
21 #define DPSW_CMDID_CLOSE DPSW_CMD_ID(0x800)
22 #define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
23
24 #define DPSW_CMDID_GET_API_VERSION DPSW_CMD_ID(0xa02)
25
26 #define DPSW_CMDID_ENABLE DPSW_CMD_ID(0x002)
27 #define DPSW_CMDID_DISABLE DPSW_CMD_ID(0x003)
28 #define DPSW_CMDID_GET_ATTR DPSW_CMD_ID(0x004)
29 #define DPSW_CMDID_RESET DPSW_CMD_ID(0x005)
30
31 #define DPSW_CMDID_SET_IRQ_ENABLE DPSW_CMD_ID(0x012)
32
33 #define DPSW_CMDID_SET_IRQ_MASK DPSW_CMD_ID(0x014)
34
35 #define DPSW_CMDID_GET_IRQ_STATUS DPSW_CMD_ID(0x016)
36 #define DPSW_CMDID_CLEAR_IRQ_STATUS DPSW_CMD_ID(0x017)
37
38 #define DPSW_CMDID_IF_SET_TCI DPSW_CMD_ID(0x030)
39 #define DPSW_CMDID_IF_SET_STP DPSW_CMD_ID(0x031)
40
41 #define DPSW_CMDID_IF_GET_COUNTER DPSW_CMD_ID(0x034)
42
43 #define DPSW_CMDID_IF_ENABLE DPSW_CMD_ID(0x03D)
44 #define DPSW_CMDID_IF_DISABLE DPSW_CMD_ID(0x03E)
45
46 #define DPSW_CMDID_IF_SET_MAX_FRAME_LENGTH DPSW_CMD_ID(0x044)
47
48 #define DPSW_CMDID_IF_GET_LINK_STATE DPSW_CMD_ID(0x046)
49 #define DPSW_CMDID_IF_SET_FLOODING DPSW_CMD_ID(0x047)
50 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
51
52 #define DPSW_CMDID_IF_GET_TCI DPSW_CMD_ID(0x04A)
53
54 #define DPSW_CMDID_IF_SET_LINK_CFG DPSW_CMD_ID(0x04C)
55
56 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
57 #define DPSW_CMDID_VLAN_ADD_IF DPSW_CMD_ID(0x061)
58 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
59
60 #define DPSW_CMDID_VLAN_REMOVE_IF DPSW_CMD_ID(0x064)
61 #define DPSW_CMDID_VLAN_REMOVE_IF_UNTAGGED DPSW_CMD_ID(0x065)
62 #define DPSW_CMDID_VLAN_REMOVE_IF_FLOODING DPSW_CMD_ID(0x066)
63 #define DPSW_CMDID_VLAN_REMOVE DPSW_CMD_ID(0x067)
64
65 #define DPSW_CMDID_FDB_ADD_UNICAST DPSW_CMD_ID(0x084)
66 #define DPSW_CMDID_FDB_REMOVE_UNICAST DPSW_CMD_ID(0x085)
67 #define DPSW_CMDID_FDB_ADD_MULTICAST DPSW_CMD_ID(0x086)
68 #define DPSW_CMDID_FDB_REMOVE_MULTICAST DPSW_CMD_ID(0x087)
69 #define DPSW_CMDID_FDB_SET_LEARNING_MODE DPSW_CMD_ID(0x088)
70 #define DPSW_CMDID_FDB_DUMP DPSW_CMD_ID(0x08A)
71
72
73 #define DPSW_MASK(field) \
74 GENMASK(DPSW_##field##_SHIFT + DPSW_##field##_SIZE - 1, \
75 DPSW_##field##_SHIFT)
76 #define dpsw_set_field(var, field, val) \
77 ((var) |= (((val) << DPSW_##field##_SHIFT) & DPSW_MASK(field)))
78 #define dpsw_get_field(var, field) \
79 (((var) & DPSW_MASK(field)) >> DPSW_##field##_SHIFT)
80 #define dpsw_get_bit(var, bit) \
81 (((var) >> (bit)) & GENMASK(0, 0))
82
83 struct dpsw_cmd_open {
84 __le32 dpsw_id;
85 };
86
87 #define DPSW_COMPONENT_TYPE_SHIFT 0
88 #define DPSW_COMPONENT_TYPE_SIZE 4
89
90 struct dpsw_cmd_create {
91
92 __le16 num_ifs;
93 u8 max_fdbs;
94 u8 max_meters_per_if;
95
96 u8 component_type;
97 u8 pad[3];
98
99 __le16 max_vlans;
100 __le16 max_fdb_entries;
101 __le16 fdb_aging_time;
102 __le16 max_fdb_mc_groups;
103
104 __le64 options;
105 };
106
107 struct dpsw_cmd_destroy {
108 __le32 dpsw_id;
109 };
110
111 #define DPSW_ENABLE_SHIFT 0
112 #define DPSW_ENABLE_SIZE 1
113
114 struct dpsw_rsp_is_enabled {
115
116 u8 enabled;
117 };
118
119 struct dpsw_cmd_set_irq_enable {
120 u8 enable_state;
121 u8 pad[3];
122 u8 irq_index;
123 };
124
125 struct dpsw_cmd_get_irq_enable {
126 __le32 pad;
127 u8 irq_index;
128 };
129
130 struct dpsw_rsp_get_irq_enable {
131 u8 enable_state;
132 };
133
134 struct dpsw_cmd_set_irq_mask {
135 __le32 mask;
136 u8 irq_index;
137 };
138
139 struct dpsw_cmd_get_irq_mask {
140 __le32 pad;
141 u8 irq_index;
142 };
143
144 struct dpsw_rsp_get_irq_mask {
145 __le32 mask;
146 };
147
148 struct dpsw_cmd_get_irq_status {
149 __le32 status;
150 u8 irq_index;
151 };
152
153 struct dpsw_rsp_get_irq_status {
154 __le32 status;
155 };
156
157 struct dpsw_cmd_clear_irq_status {
158 __le32 status;
159 u8 irq_index;
160 };
161
162 #define DPSW_COMPONENT_TYPE_SHIFT 0
163 #define DPSW_COMPONENT_TYPE_SIZE 4
164
165 struct dpsw_rsp_get_attr {
166
167 __le16 num_ifs;
168 u8 max_fdbs;
169 u8 num_fdbs;
170 __le16 max_vlans;
171 __le16 num_vlans;
172
173 __le16 max_fdb_entries;
174 __le16 fdb_aging_time;
175 __le32 dpsw_id;
176
177 __le16 mem_size;
178 __le16 max_fdb_mc_groups;
179 u8 max_meters_per_if;
180
181 u8 component_type;
182 __le16 pad;
183
184 __le64 options;
185 };
186
187 struct dpsw_cmd_if_set_flooding {
188 __le16 if_id;
189
190 u8 enable;
191 };
192
193 struct dpsw_cmd_if_set_broadcast {
194 __le16 if_id;
195
196 u8 enable;
197 };
198
199 #define DPSW_VLAN_ID_SHIFT 0
200 #define DPSW_VLAN_ID_SIZE 12
201 #define DPSW_DEI_SHIFT 12
202 #define DPSW_DEI_SIZE 1
203 #define DPSW_PCP_SHIFT 13
204 #define DPSW_PCP_SIZE 3
205
206 struct dpsw_cmd_if_set_tci {
207 __le16 if_id;
208
209 __le16 conf;
210 };
211
212 struct dpsw_cmd_if_get_tci {
213 __le16 if_id;
214 };
215
216 struct dpsw_rsp_if_get_tci {
217 __le16 pad;
218 __le16 vlan_id;
219 u8 dei;
220 u8 pcp;
221 };
222
223 #define DPSW_STATE_SHIFT 0
224 #define DPSW_STATE_SIZE 4
225
226 struct dpsw_cmd_if_set_stp {
227 __le16 if_id;
228 __le16 vlan_id;
229
230 u8 state;
231 };
232
233 #define DPSW_COUNTER_TYPE_SHIFT 0
234 #define DPSW_COUNTER_TYPE_SIZE 5
235
236 struct dpsw_cmd_if_get_counter {
237 __le16 if_id;
238
239 u8 type;
240 };
241
242 struct dpsw_rsp_if_get_counter {
243 __le64 pad;
244 __le64 counter;
245 };
246
247 struct dpsw_cmd_if {
248 __le16 if_id;
249 };
250
251 struct dpsw_cmd_if_set_max_frame_length {
252 __le16 if_id;
253 __le16 frame_length;
254 };
255
256 struct dpsw_cmd_if_set_link_cfg {
257
258 __le16 if_id;
259 u8 pad[6];
260
261 __le32 rate;
262 __le32 pad1;
263
264 __le64 options;
265 };
266
267 struct dpsw_cmd_if_get_link_state {
268 __le16 if_id;
269 };
270
271 #define DPSW_UP_SHIFT 0
272 #define DPSW_UP_SIZE 1
273
274 struct dpsw_rsp_if_get_link_state {
275
276 __le32 pad0;
277 u8 up;
278 u8 pad1[3];
279
280 __le32 rate;
281 __le32 pad2;
282
283 __le64 options;
284 };
285
286 struct dpsw_vlan_add {
287 __le16 fdb_id;
288 __le16 vlan_id;
289 };
290
291 struct dpsw_cmd_vlan_manage_if {
292
293 __le16 pad0;
294 __le16 vlan_id;
295 __le32 pad1;
296
297 __le64 if_id[4];
298 };
299
300 struct dpsw_cmd_vlan_remove {
301 __le16 pad;
302 __le16 vlan_id;
303 };
304
305 struct dpsw_cmd_fdb_add {
306 __le32 pad;
307 __le16 fdb_aging_time;
308 __le16 num_fdb_entries;
309 };
310
311 struct dpsw_rsp_fdb_add {
312 __le16 fdb_id;
313 };
314
315 struct dpsw_cmd_fdb_remove {
316 __le16 fdb_id;
317 };
318
319 #define DPSW_ENTRY_TYPE_SHIFT 0
320 #define DPSW_ENTRY_TYPE_SIZE 4
321
322 struct dpsw_cmd_fdb_unicast_op {
323
324 __le16 fdb_id;
325 u8 mac_addr[6];
326
327 __le16 if_egress;
328
329 u8 type;
330 };
331
332 struct dpsw_cmd_fdb_multicast_op {
333
334 __le16 fdb_id;
335 __le16 num_ifs;
336
337 u8 type;
338 u8 pad[3];
339
340 u8 mac_addr[6];
341 __le16 pad2;
342
343 __le64 if_id[4];
344 };
345
346 #define DPSW_LEARNING_MODE_SHIFT 0
347 #define DPSW_LEARNING_MODE_SIZE 4
348
349 struct dpsw_cmd_fdb_set_learning_mode {
350 __le16 fdb_id;
351
352 u8 mode;
353 };
354
355 struct dpsw_cmd_fdb_dump {
356 __le16 fdb_id;
357 __le16 pad0;
358 __le32 pad1;
359 __le64 iova_addr;
360 __le32 iova_size;
361 };
362
363 struct dpsw_rsp_fdb_dump {
364 __le16 num_entries;
365 };
366
367 struct dpsw_rsp_get_api_version {
368 __le16 version_major;
369 __le16 version_minor;
370 };
371
372 #endif