xref: /linux/drivers/net/ethernet/ti/icssg/icssg_config.h (revision aba74e639f8d76d29b94991615e33319d7371b63)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Texas Instruments ICSSG Ethernet driver
3  *
4  * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
5  *
6  */
7 
8 #ifndef __NET_TI_ICSSG_CONFIG_H
9 #define __NET_TI_ICSSG_CONFIG_H
10 
11 struct icssg_buffer_pool_cfg {
12 	__le32	addr;
13 	__le32	len;
14 } __packed;
15 
16 struct icssg_flow_cfg {
17 	__le16 rx_base_flow;
18 	__le16 mgm_base_flow;
19 } __packed;
20 
21 #define PRUETH_PKT_TYPE_CMD	0x10
22 #define PRUETH_NAV_PS_DATA_SIZE	16	/* Protocol specific data size */
23 #define PRUETH_NAV_SW_DATA_SIZE	16	/* SW related data size */
24 #define PRUETH_MAX_TX_DESC	512
25 #define PRUETH_MAX_RX_DESC	512
26 #define PRUETH_MAX_RX_FLOWS	1	/* excluding default flow */
27 #define PRUETH_RX_FLOW_DATA	0
28 
29 #define PRUETH_EMAC_BUF_POOL_SIZE	SZ_8K
30 #define PRUETH_EMAC_POOLS_PER_SLICE	24
31 #define PRUETH_EMAC_BUF_POOL_START	8
32 #define PRUETH_NUM_BUF_POOLS	8
33 #define PRUETH_EMAC_RX_CTX_BUF_SIZE	SZ_16K	/* per slice */
34 #define MSMC_RAM_SIZE	\
35 	(2 * (PRUETH_EMAC_BUF_POOL_SIZE * PRUETH_NUM_BUF_POOLS + \
36 	 PRUETH_EMAC_RX_CTX_BUF_SIZE * 2))
37 
38 #define PRUETH_SW_BUF_POOL_SIZE_HOST	SZ_4K
39 #define PRUETH_SW_NUM_BUF_POOLS_HOST	8
40 #define PRUETH_SW_NUM_BUF_POOLS_PER_PRU 4
41 #define MSMC_RAM_SIZE_SWITCH_MODE \
42 	(MSMC_RAM_SIZE + \
43 	(2 * PRUETH_SW_BUF_POOL_SIZE_HOST * PRUETH_SW_NUM_BUF_POOLS_HOST))
44 
45 #define PRUETH_SWITCH_FDB_MASK ((SIZE_OF_FDB / NUMBER_OF_FDB_BUCKET_ENTRIES) - 1)
46 
47 struct icssg_rxq_ctx {
48 	__le32 start[3];
49 	__le32 end;
50 } __packed;
51 
52 /* Load time Fiwmware Configuration */
53 
54 #define ICSSG_FW_MGMT_CMD_HEADER	0x81
55 #define ICSSG_FW_MGMT_FDB_CMD_TYPE	0x03
56 #define ICSSG_FW_MGMT_CMD_TYPE		0x04
57 #define ICSSG_FW_MGMT_PKT		0x80000000
58 #define ICSSG_FW_MGMT_FDB_CMD_TYPE_RX_FLOW	0x05
59 
60 struct icssg_r30_cmd {
61 	u32 cmd[4];
62 } __packed;
63 
64 enum icssg_port_state_cmd {
65 	ICSSG_EMAC_PORT_DISABLE = 0,
66 	ICSSG_EMAC_PORT_BLOCK,
67 	ICSSG_EMAC_PORT_FORWARD,
68 	ICSSG_EMAC_PORT_FORWARD_WO_LEARNING,
69 	ICSSG_EMAC_PORT_ACCEPT_ALL,
70 	ICSSG_EMAC_PORT_ACCEPT_TAGGED,
71 	ICSSG_EMAC_PORT_ACCEPT_UNTAGGED_N_PRIO,
72 	ICSSG_EMAC_PORT_TAS_TRIGGER,
73 	ICSSG_EMAC_PORT_TAS_ENABLE,
74 	ICSSG_EMAC_PORT_TAS_RESET,
75 	ICSSG_EMAC_PORT_TAS_DISABLE,
76 	ICSSG_EMAC_PORT_UC_FLOODING_ENABLE,
77 	ICSSG_EMAC_PORT_UC_FLOODING_DISABLE,
78 	ICSSG_EMAC_PORT_MC_FLOODING_ENABLE,
79 	ICSSG_EMAC_PORT_MC_FLOODING_DISABLE,
80 	ICSSG_EMAC_PORT_PREMPT_TX_ENABLE,
81 	ICSSG_EMAC_PORT_PREMPT_TX_DISABLE,
82 	ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE,
83 	ICSSG_EMAC_PORT_VLAN_AWARE_DISABLE,
84 	ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE,
85 	ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE,
86 	ICSSG_EMAC_PORT_MAX_COMMANDS
87 };
88 
89 #define EMAC_NONE           0xffff0000
90 #define EMAC_PRU0_P_DI      0xffff0004
91 #define EMAC_PRU1_P_DI      0xffff0040
92 #define EMAC_TX_P_DI        0xffff0100
93 
94 #define EMAC_PRU0_P_EN      0xfffb0000
95 #define EMAC_PRU1_P_EN      0xffbf0000
96 #define EMAC_TX_P_EN        0xfeff0000
97 
98 #define EMAC_P_BLOCK        0xffff0040
99 #define EMAC_TX_P_BLOCK     0xffff0200
100 #define EMAC_P_UNBLOCK      0xffbf0000
101 #define EMAC_TX_P_UNBLOCK   0xfdff0000
102 #define EMAC_LEAN_EN        0xfff70000
103 #define EMAC_LEAN_DI        0xffff0008
104 
105 #define EMAC_ACCEPT_ALL     0xffff0001
106 #define EMAC_ACCEPT_TAG     0xfffe0002
107 #define EMAC_ACCEPT_PRIOR   0xfffc0000
108 
109 /* Config area lies in DRAM */
110 #define ICSSG_CONFIG_OFFSET	0x0
111 
112 /* Config area lies in shared RAM */
113 #define ICSSG_CONFIG_OFFSET_SLICE0   0
114 #define ICSSG_CONFIG_OFFSET_SLICE1   0x8000
115 
116 #define ICSSG_NUM_NORMAL_PDS	64
117 #define ICSSG_NUM_SPECIAL_PDS	16
118 
119 #define ICSSG_NORMAL_PD_SIZE	8
120 #define ICSSG_SPECIAL_PD_SIZE	20
121 
122 #define ICSSG_FLAG_MASK		0xff00ffff
123 
124 /* SR1.0-specific bits */
125 #define PRUETH_MAX_RX_FLOWS_SR1			4	/* excluding default flow */
126 #define PRUETH_RX_FLOW_DATA_SR1			3       /* highest priority flow */
127 #define PRUETH_MAX_RX_MGM_DESC_SR1		8
128 #define PRUETH_MAX_RX_MGM_FLOWS_SR1		2	/* excluding default flow */
129 #define PRUETH_RX_MGM_FLOW_RESPONSE_SR1		0
130 #define PRUETH_RX_MGM_FLOW_TIMESTAMP_SR1	1
131 
132 #define PRUETH_NUM_BUF_POOLS_SR1		16
133 #define PRUETH_EMAC_BUF_POOL_START_SR1		8
134 #define PRUETH_EMAC_BUF_POOL_MIN_SIZE_SR1	128
135 #define PRUETH_EMAC_BUF_SIZE_SR1		1536
136 #define PRUETH_EMAC_NUM_BUF_SR1			4
137 #define PRUETH_EMAC_BUF_POOL_SIZE_SR1	(PRUETH_EMAC_NUM_BUF_SR1 * \
138 					 PRUETH_EMAC_BUF_SIZE_SR1)
139 #define MSMC_RAM_SIZE_SR1	(SZ_64K + SZ_32K + SZ_2K) /* 0x1880 x 8 x 2 */
140 
141 struct icssg_sr1_config {
142 	__le32 status;		/* Firmware status */
143 	__le32 addr_lo;		/* MSMC Buffer pool base address low. */
144 	__le32 addr_hi;		/* MSMC Buffer pool base address high. Must be 0 */
145 	__le32 tx_buf_sz[16];	/* Array of buffer pool sizes */
146 	__le32 num_tx_threads;	/* Number of active egress threads, 1 to 4 */
147 	__le32 tx_rate_lim_en;	/* Bitmask: Egress rate limit en per thread */
148 	__le32 rx_flow_id;	/* RX flow id for first rx ring */
149 	__le32 rx_mgr_flow_id;	/* RX flow id for the first management ring */
150 	__le32 flags;		/* TBD */
151 	__le32 n_burst;		/* for debug */
152 	__le32 rtu_status;	/* RTU status */
153 	__le32 info;		/* reserved */
154 	__le32 reserve;
155 	__le32 rand_seed;	/* Used for the random number generation at fw */
156 } __packed;
157 
158 /* SR1.0 shutdown command to stop processing at firmware.
159  * Command format: 0x8101ss00, where
160  *	- ss: sequence number. Currently not used by driver.
161  */
162 #define ICSSG_SHUTDOWN_CMD_SR1		0x81010000
163 
164 /* SR1.0 pstate speed/duplex command to set speed and duplex settings
165  * in firmware.
166  * Command format: 0x8102ssPN, where
167  *	- ss: sequence number. Currently not used by driver.
168  *	- P: port number (for switch mode).
169  *	- N: Speed/Duplex state:
170  *		0x0 - 10Mbps/Half duplex;
171  *		0x8 - 10Mbps/Full duplex;
172  *		0x2 - 100Mbps/Half duplex;
173  *		0xa - 100Mbps/Full duplex;
174  *		0xc - 1Gbps/Full duplex;
175  *		NOTE: The above are the same value as bits [3..1](slice 0)
176  *		      or bits [7..5](slice 1) of RGMII CFG register.
177  */
178 #define ICSSG_PSTATE_SPEED_DUPLEX_CMD_SR1	0x81020000
179 
180 struct icssg_setclock_desc {
181 	u8 request;
182 	u8 restore;
183 	u8 acknowledgment;
184 	u8 cmp_status;
185 	u32 margin;
186 	u32 cyclecounter0_set;
187 	u32 cyclecounter1_set;
188 	u32 iepcount_set;
189 	u32 rsvd1;
190 	u32 rsvd2;
191 	u32 CMP0_current;
192 	u32 iepcount_current;
193 	u32 difference;
194 	u32 cyclecounter0_new;
195 	u32 cyclecounter1_new;
196 	u32 CMP0_new;
197 } __packed;
198 
199 #define ICSSG_CMD_POP_SLICE0	56
200 #define ICSSG_CMD_POP_SLICE1	60
201 
202 #define ICSSG_CMD_PUSH_SLICE0	57
203 #define ICSSG_CMD_PUSH_SLICE1	61
204 
205 #define ICSSG_RSP_POP_SLICE0	58
206 #define ICSSG_RSP_POP_SLICE1	62
207 
208 #define ICSSG_RSP_PUSH_SLICE0	56
209 #define ICSSG_RSP_PUSH_SLICE1	60
210 
211 #define ICSSG_TS_POP_SLICE0	59
212 #define ICSSG_TS_POP_SLICE1	63
213 
214 #define ICSSG_TS_PUSH_SLICE0	40
215 #define ICSSG_TS_PUSH_SLICE1	41
216 
217 struct mgmt_cmd {
218 	u8 param;
219 	u8 seqnum;
220 	u8 type;
221 	u8 header;
222 	u32 cmd_args[3];
223 };
224 
225 struct mgmt_cmd_rsp {
226 	u32 reserved;
227 	u8 status;
228 	u8 seqnum;
229 	u8 type;
230 	u8 header;
231 	u32 cmd_args[3];
232 };
233 
234 /* FDB FID_C2 flag definitions */
235 /* Indicates host port membership.*/
236 #define ICSSG_FDB_ENTRY_P0_MEMBERSHIP         BIT(0)
237 /* Indicates that MAC ID is connected to physical port 1 */
238 #define ICSSG_FDB_ENTRY_P1_MEMBERSHIP         BIT(1)
239 /* Indicates that MAC ID is connected to physical port 2 */
240 #define ICSSG_FDB_ENTRY_P2_MEMBERSHIP         BIT(2)
241 /* Ageable bit is set for learned entries and cleared for static entries */
242 #define ICSSG_FDB_ENTRY_AGEABLE               BIT(3)
243 /* If set for DA then packet is determined to be a special packet */
244 #define ICSSG_FDB_ENTRY_BLOCK                 BIT(4)
245 /* If set for DA then the SA from the packet is not learned */
246 #define ICSSG_FDB_ENTRY_SECURE                BIT(5)
247 /* If set, it means packet has been seen recently with source address + FID
248  * matching MAC address/FID of entry
249  */
250 #define ICSSG_FDB_ENTRY_TOUCHED               BIT(6)
251 /* Set if entry is valid */
252 #define ICSSG_FDB_ENTRY_VALID                 BIT(7)
253 
254 /**
255  * struct prueth_vlan_tbl - VLAN table entries struct in ICSSG SMEM
256  * @fid_c1: membership and forwarding rules flag to this table. See
257  *          above to defines for bit definitions
258  * @fid: FDB index for this VID (there is 1-1 mapping b/w VID and FID)
259  */
260 struct prueth_vlan_tbl {
261 	u8 fid_c1;
262 	u8 fid;
263 } __packed;
264 
265 /**
266  * struct prueth_fdb_slot - Result of FDB slot lookup
267  * @mac: MAC address
268  * @fid: fid to be associated with MAC
269  * @fid_c2: FID_C2 entry for this MAC
270  */
271 struct prueth_fdb_slot {
272 	u8 mac[ETH_ALEN];
273 	u8 fid;
274 	u8 fid_c2;
275 } __packed;
276 
277 enum icssg_ietfpe_verify_states {
278 	ICSSG_IETFPE_STATE_UNKNOWN = 0,
279 	ICSSG_IETFPE_STATE_INITIAL,
280 	ICSSG_IETFPE_STATE_VERIFYING,
281 	ICSSG_IETFPE_STATE_SUCCEEDED,
282 	ICSSG_IETFPE_STATE_FAILED,
283 	ICSSG_IETFPE_STATE_DISABLED
284 };
285 #endif /* __NET_TI_ICSSG_CONFIG_H */
286