1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright 2014-2016 Freescale Semiconductor Inc.
4 * Copyright 2017-2018 NXP
8 #ifndef __FSL_DPSW_CMD_H
9 #define __FSL_DPSW_CMD_H
12 #define DPSW_VER_MAJOR 8
13 #define DPSW_VER_MINOR 1
15 #define DPSW_CMD_BASE_VERSION 1
16 #define DPSW_CMD_ID_OFFSET 4
18 #define DPSW_CMD_ID(id) (((id) << DPSW_CMD_ID_OFFSET) | DPSW_CMD_BASE_VERSION)
21 #define DPSW_CMDID_CLOSE DPSW_CMD_ID(0x800)
22 #define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
24 #define DPSW_CMDID_GET_API_VERSION DPSW_CMD_ID(0xa02)
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)
31 #define DPSW_CMDID_SET_IRQ_ENABLE DPSW_CMD_ID(0x012)
33 #define DPSW_CMDID_SET_IRQ_MASK DPSW_CMD_ID(0x014)
35 #define DPSW_CMDID_GET_IRQ_STATUS DPSW_CMD_ID(0x016)
36 #define DPSW_CMDID_CLEAR_IRQ_STATUS DPSW_CMD_ID(0x017)
38 #define DPSW_CMDID_IF_SET_TCI DPSW_CMD_ID(0x030)
39 #define DPSW_CMDID_IF_SET_STP DPSW_CMD_ID(0x031)
41 #define DPSW_CMDID_IF_GET_COUNTER DPSW_CMD_ID(0x034)
43 #define DPSW_CMDID_IF_ENABLE DPSW_CMD_ID(0x03D)
44 #define DPSW_CMDID_IF_DISABLE DPSW_CMD_ID(0x03E)
46 #define DPSW_CMDID_IF_SET_MAX_FRAME_LENGTH DPSW_CMD_ID(0x044)
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)
52 #define DPSW_CMDID_IF_GET_TCI DPSW_CMD_ID(0x04A)
54 #define DPSW_CMDID_IF_SET_LINK_CFG DPSW_CMD_ID(0x04C)
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)
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)
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)
72 /* Macros for accessing command fields smaller than 1byte */
73 #define DPSW_MASK(field) \
74 GENMASK(DPSW_##field##_SHIFT + DPSW_##field##_SIZE - 1, \
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))
83 struct dpsw_cmd_open {
87 #define DPSW_COMPONENT_TYPE_SHIFT 0
88 #define DPSW_COMPONENT_TYPE_SIZE 4
90 struct dpsw_cmd_create {
95 /* from LSB: only the first 4 bits */
100 __le16 max_fdb_entries;
101 __le16 fdb_aging_time;
102 __le16 max_fdb_mc_groups;
107 struct dpsw_cmd_destroy {
111 #define DPSW_ENABLE_SHIFT 0
112 #define DPSW_ENABLE_SIZE 1
114 struct dpsw_rsp_is_enabled {
115 /* from LSB: enable:1 */
119 struct dpsw_cmd_set_irq_enable {
125 struct dpsw_cmd_get_irq_enable {
130 struct dpsw_rsp_get_irq_enable {
134 struct dpsw_cmd_set_irq_mask {
139 struct dpsw_cmd_get_irq_mask {
144 struct dpsw_rsp_get_irq_mask {
148 struct dpsw_cmd_get_irq_status {
153 struct dpsw_rsp_get_irq_status {
157 struct dpsw_cmd_clear_irq_status {
162 #define DPSW_COMPONENT_TYPE_SHIFT 0
163 #define DPSW_COMPONENT_TYPE_SIZE 4
165 struct dpsw_rsp_get_attr {
173 __le16 max_fdb_entries;
174 __le16 fdb_aging_time;
178 __le16 max_fdb_mc_groups;
179 u8 max_meters_per_if;
180 /* from LSB only the first 4 bits */
187 struct dpsw_cmd_if_set_flooding {
189 /* from LSB: enable:1 */
193 struct dpsw_cmd_if_set_broadcast {
195 /* from LSB: enable:1 */
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
206 struct dpsw_cmd_if_set_tci {
208 /* from LSB: VLAN_ID:12 DEI:1 PCP:3 */
212 struct dpsw_cmd_if_get_tci {
216 struct dpsw_rsp_if_get_tci {
223 #define DPSW_STATE_SHIFT 0
224 #define DPSW_STATE_SIZE 4
226 struct dpsw_cmd_if_set_stp {
229 /* only the first LSB 4 bits */
233 #define DPSW_COUNTER_TYPE_SHIFT 0
234 #define DPSW_COUNTER_TYPE_SIZE 5
236 struct dpsw_cmd_if_get_counter {
238 /* from LSB: type:5 */
242 struct dpsw_rsp_if_get_counter {
251 struct dpsw_cmd_if_set_max_frame_length {
256 struct dpsw_cmd_if_set_link_cfg {
267 struct dpsw_cmd_if_get_link_state {
271 #define DPSW_UP_SHIFT 0
272 #define DPSW_UP_SIZE 1
274 struct dpsw_rsp_if_get_link_state {
286 struct dpsw_vlan_add {
291 struct dpsw_cmd_vlan_manage_if {
300 struct dpsw_cmd_vlan_remove {
305 struct dpsw_cmd_fdb_add {
307 __le16 fdb_aging_time;
308 __le16 num_fdb_entries;
311 struct dpsw_rsp_fdb_add {
315 struct dpsw_cmd_fdb_remove {
319 #define DPSW_ENTRY_TYPE_SHIFT 0
320 #define DPSW_ENTRY_TYPE_SIZE 4
322 struct dpsw_cmd_fdb_unicast_op {
328 /* only the first 4 bits from LSB */
332 struct dpsw_cmd_fdb_multicast_op {
336 /* only the first 4 bits from LSB */
346 #define DPSW_LEARNING_MODE_SHIFT 0
347 #define DPSW_LEARNING_MODE_SIZE 4
349 struct dpsw_cmd_fdb_set_learning_mode {
351 /* only the first 4 bits from LSB */
355 struct dpsw_cmd_fdb_dump {
363 struct dpsw_rsp_fdb_dump {
367 struct dpsw_rsp_get_api_version {
368 __le16 version_major;
369 __le16 version_minor;
372 #endif /* __FSL_DPSW_CMD_H */