xref: /openbmc/linux/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h (revision 8dd06ef34b6e2f41b29fbf5fc1663780f2524285)
175a6faf6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2753a7109SAlexandre TORGUE /*
3753a7109SAlexandre TORGUE  * Header File to describe the DMA descriptors and related definitions specific
4753a7109SAlexandre TORGUE  * for DesignWare databook 4.xx.
5753a7109SAlexandre TORGUE  *
6753a7109SAlexandre TORGUE  * Copyright (C) 2015  STMicroelectronics Ltd
7753a7109SAlexandre TORGUE  *
8753a7109SAlexandre TORGUE  * Author: Alexandre Torgue <alexandre.torgue@st.com>
9753a7109SAlexandre TORGUE  */
10753a7109SAlexandre TORGUE 
11753a7109SAlexandre TORGUE #ifndef __DWMAC4_DESCS_H__
12753a7109SAlexandre TORGUE #define __DWMAC4_DESCS_H__
13753a7109SAlexandre TORGUE 
14753a7109SAlexandre TORGUE #include <linux/bitops.h>
15753a7109SAlexandre TORGUE 
16753a7109SAlexandre TORGUE /* Normal transmit descriptor defines (without split feature) */
17753a7109SAlexandre TORGUE 
18753a7109SAlexandre TORGUE /* TDES2 (read format) */
19753a7109SAlexandre TORGUE #define TDES2_BUFFER1_SIZE_MASK		GENMASK(13, 0)
20753a7109SAlexandre TORGUE #define TDES2_VLAN_TAG_MASK		GENMASK(15, 14)
21e94e3f3bSJose Abreu #define TDES2_VLAN_TAG_SHIFT		14
22753a7109SAlexandre TORGUE #define TDES2_BUFFER2_SIZE_MASK		GENMASK(29, 16)
23753a7109SAlexandre TORGUE #define TDES2_BUFFER2_SIZE_MASK_SHIFT	16
24e94e3f3bSJose Abreu #define TDES3_IVTIR_MASK		GENMASK(19, 18)
25e94e3f3bSJose Abreu #define TDES3_IVTIR_SHIFT		18
26e94e3f3bSJose Abreu #define TDES3_IVLTV			BIT(17)
27753a7109SAlexandre TORGUE #define TDES2_TIMESTAMP_ENABLE		BIT(30)
28e94e3f3bSJose Abreu #define TDES2_IVT_MASK			GENMASK(31, 16)
29e94e3f3bSJose Abreu #define TDES2_IVT_SHIFT			16
30753a7109SAlexandre TORGUE #define TDES2_INTERRUPT_ON_COMPLETION	BIT(31)
31753a7109SAlexandre TORGUE 
32753a7109SAlexandre TORGUE /* TDES3 (read format) */
33753a7109SAlexandre TORGUE #define TDES3_PACKET_SIZE_MASK		GENMASK(14, 0)
34e94e3f3bSJose Abreu #define TDES3_VLAN_TAG			GENMASK(15, 0)
35e94e3f3bSJose Abreu #define TDES3_VLTV			BIT(16)
36753a7109SAlexandre TORGUE #define TDES3_CHECKSUM_INSERTION_MASK	GENMASK(17, 16)
37753a7109SAlexandre TORGUE #define TDES3_CHECKSUM_INSERTION_SHIFT	16
38753a7109SAlexandre TORGUE #define TDES3_TCP_PKT_PAYLOAD_MASK	GENMASK(17, 0)
39753a7109SAlexandre TORGUE #define TDES3_TCP_SEGMENTATION_ENABLE	BIT(18)
40753a7109SAlexandre TORGUE #define TDES3_HDR_LEN_SHIFT		19
41753a7109SAlexandre TORGUE #define TDES3_SLOT_NUMBER_MASK		GENMASK(22, 19)
42753a7109SAlexandre TORGUE #define TDES3_SA_INSERT_CTRL_MASK	GENMASK(25, 23)
431d982e93SJose Abreu #define TDES3_SA_INSERT_CTRL_SHIFT	23
44753a7109SAlexandre TORGUE #define TDES3_CRC_PAD_CTRL_MASK		GENMASK(27, 26)
45753a7109SAlexandre TORGUE 
46753a7109SAlexandre TORGUE /* TDES3 (write back format) */
47753a7109SAlexandre TORGUE #define TDES3_IP_HDR_ERROR		BIT(0)
48753a7109SAlexandre TORGUE #define TDES3_DEFERRED			BIT(1)
49753a7109SAlexandre TORGUE #define TDES3_UNDERFLOW_ERROR		BIT(2)
50753a7109SAlexandre TORGUE #define TDES3_EXCESSIVE_DEFERRAL	BIT(3)
51753a7109SAlexandre TORGUE #define TDES3_COLLISION_COUNT_MASK	GENMASK(7, 4)
52753a7109SAlexandre TORGUE #define TDES3_COLLISION_COUNT_SHIFT	4
53753a7109SAlexandre TORGUE #define TDES3_EXCESSIVE_COLLISION	BIT(8)
54753a7109SAlexandre TORGUE #define TDES3_LATE_COLLISION		BIT(9)
55753a7109SAlexandre TORGUE #define TDES3_NO_CARRIER		BIT(10)
56753a7109SAlexandre TORGUE #define TDES3_LOSS_CARRIER		BIT(11)
57753a7109SAlexandre TORGUE #define TDES3_PAYLOAD_ERROR		BIT(12)
58753a7109SAlexandre TORGUE #define TDES3_PACKET_FLUSHED		BIT(13)
59753a7109SAlexandre TORGUE #define TDES3_JABBER_TIMEOUT		BIT(14)
60753a7109SAlexandre TORGUE #define TDES3_ERROR_SUMMARY		BIT(15)
61753a7109SAlexandre TORGUE #define TDES3_TIMESTAMP_STATUS		BIT(17)
62753a7109SAlexandre TORGUE #define TDES3_TIMESTAMP_STATUS_SHIFT	17
63753a7109SAlexandre TORGUE 
64753a7109SAlexandre TORGUE /* TDES3 context */
65753a7109SAlexandre TORGUE #define TDES3_CTXT_TCMSSV		BIT(26)
66753a7109SAlexandre TORGUE 
67753a7109SAlexandre TORGUE /* TDES3 Common */
68ba1ffd74SGiuseppe CAVALLARO #define	TDES3_RS1V			BIT(26)
69ba1ffd74SGiuseppe CAVALLARO #define	TDES3_RS1V_SHIFT		26
70753a7109SAlexandre TORGUE #define TDES3_LAST_DESCRIPTOR		BIT(28)
71753a7109SAlexandre TORGUE #define TDES3_LAST_DESCRIPTOR_SHIFT	28
72753a7109SAlexandre TORGUE #define TDES3_FIRST_DESCRIPTOR		BIT(29)
73753a7109SAlexandre TORGUE #define TDES3_CONTEXT_TYPE		BIT(30)
74ba1ffd74SGiuseppe CAVALLARO #define	TDES3_CONTEXT_TYPE_SHIFT	30
75753a7109SAlexandre TORGUE 
76*58ae9281SJose Abreu /* TDES4 */
77*58ae9281SJose Abreu #define TDES4_LTV			BIT(31)
78*58ae9281SJose Abreu #define TDES4_LT			GENMASK(7, 0)
79*58ae9281SJose Abreu 
80*58ae9281SJose Abreu /* TDES5 */
81*58ae9281SJose Abreu #define TDES5_LT			GENMASK(31, 8)
82*58ae9281SJose Abreu 
83753a7109SAlexandre TORGUE /* TDS3 use for both format (read and write back) */
84753a7109SAlexandre TORGUE #define TDES3_OWN			BIT(31)
85753a7109SAlexandre TORGUE #define TDES3_OWN_SHIFT			31
86753a7109SAlexandre TORGUE 
87753a7109SAlexandre TORGUE /* Normal receive descriptor defines (without split feature) */
88753a7109SAlexandre TORGUE 
89753a7109SAlexandre TORGUE /* RDES0 (write back format) */
90753a7109SAlexandre TORGUE #define RDES0_VLAN_TAG_MASK		GENMASK(15, 0)
91753a7109SAlexandre TORGUE 
92753a7109SAlexandre TORGUE /* RDES1 (write back format) */
93753a7109SAlexandre TORGUE #define RDES1_IP_PAYLOAD_TYPE_MASK	GENMASK(2, 0)
94753a7109SAlexandre TORGUE #define RDES1_IP_HDR_ERROR		BIT(3)
95753a7109SAlexandre TORGUE #define RDES1_IPV4_HEADER		BIT(4)
96753a7109SAlexandre TORGUE #define RDES1_IPV6_HEADER		BIT(5)
97753a7109SAlexandre TORGUE #define RDES1_IP_CSUM_BYPASSED		BIT(6)
98753a7109SAlexandre TORGUE #define RDES1_IP_CSUM_ERROR		BIT(7)
99753a7109SAlexandre TORGUE #define RDES1_PTP_MSG_TYPE_MASK		GENMASK(11, 8)
100753a7109SAlexandre TORGUE #define RDES1_PTP_PACKET_TYPE		BIT(12)
101753a7109SAlexandre TORGUE #define RDES1_PTP_VER			BIT(13)
102753a7109SAlexandre TORGUE #define RDES1_TIMESTAMP_AVAILABLE	BIT(14)
103753a7109SAlexandre TORGUE #define RDES1_TIMESTAMP_AVAILABLE_SHIFT	14
104753a7109SAlexandre TORGUE #define RDES1_TIMESTAMP_DROPPED		BIT(15)
105753a7109SAlexandre TORGUE #define RDES1_IP_TYPE1_CSUM_MASK	GENMASK(31, 16)
106753a7109SAlexandre TORGUE 
107753a7109SAlexandre TORGUE /* RDES2 (write back format) */
108753a7109SAlexandre TORGUE #define RDES2_L3_L4_HEADER_SIZE_MASK	GENMASK(9, 0)
109753a7109SAlexandre TORGUE #define RDES2_VLAN_FILTER_STATUS	BIT(15)
110753a7109SAlexandre TORGUE #define RDES2_SA_FILTER_FAIL		BIT(16)
111753a7109SAlexandre TORGUE #define RDES2_DA_FILTER_FAIL		BIT(17)
112753a7109SAlexandre TORGUE #define RDES2_HASH_FILTER_STATUS	BIT(18)
113753a7109SAlexandre TORGUE #define RDES2_MAC_ADDR_MATCH_MASK	GENMASK(26, 19)
114753a7109SAlexandre TORGUE #define RDES2_HASH_VALUE_MATCH_MASK	GENMASK(26, 19)
115753a7109SAlexandre TORGUE #define RDES2_L3_FILTER_MATCH		BIT(27)
116753a7109SAlexandre TORGUE #define RDES2_L4_FILTER_MATCH		BIT(28)
117753a7109SAlexandre TORGUE #define RDES2_L3_L4_FILT_NB_MATCH_MASK	GENMASK(27, 26)
118753a7109SAlexandre TORGUE #define RDES2_L3_L4_FILT_NB_MATCH_SHIFT	26
1198c6fc097SJose Abreu #define RDES2_HL			GENMASK(9, 0)
120753a7109SAlexandre TORGUE 
121753a7109SAlexandre TORGUE /* RDES3 (write back format) */
122753a7109SAlexandre TORGUE #define RDES3_PACKET_SIZE_MASK		GENMASK(14, 0)
123753a7109SAlexandre TORGUE #define RDES3_ERROR_SUMMARY		BIT(15)
124753a7109SAlexandre TORGUE #define RDES3_PACKET_LEN_TYPE_MASK	GENMASK(18, 16)
125753a7109SAlexandre TORGUE #define RDES3_DRIBBLE_ERROR		BIT(19)
126753a7109SAlexandre TORGUE #define RDES3_RECEIVE_ERROR		BIT(20)
127753a7109SAlexandre TORGUE #define RDES3_OVERFLOW_ERROR		BIT(21)
128753a7109SAlexandre TORGUE #define RDES3_RECEIVE_WATCHDOG		BIT(22)
129753a7109SAlexandre TORGUE #define RDES3_GIANT_PACKET		BIT(23)
130753a7109SAlexandre TORGUE #define RDES3_CRC_ERROR			BIT(24)
131753a7109SAlexandre TORGUE #define RDES3_RDES0_VALID		BIT(25)
132753a7109SAlexandre TORGUE #define RDES3_RDES1_VALID		BIT(26)
133753a7109SAlexandre TORGUE #define RDES3_RDES2_VALID		BIT(27)
134753a7109SAlexandre TORGUE #define RDES3_LAST_DESCRIPTOR		BIT(28)
135753a7109SAlexandre TORGUE #define RDES3_FIRST_DESCRIPTOR		BIT(29)
136753a7109SAlexandre TORGUE #define RDES3_CONTEXT_DESCRIPTOR	BIT(30)
137ba1ffd74SGiuseppe CAVALLARO #define RDES3_CONTEXT_DESCRIPTOR_SHIFT	30
138753a7109SAlexandre TORGUE 
139753a7109SAlexandre TORGUE /* RDES3 (read format) */
140753a7109SAlexandre TORGUE #define RDES3_BUFFER1_VALID_ADDR	BIT(24)
141753a7109SAlexandre TORGUE #define RDES3_BUFFER2_VALID_ADDR	BIT(25)
142753a7109SAlexandre TORGUE #define RDES3_INT_ON_COMPLETION_EN	BIT(30)
143753a7109SAlexandre TORGUE 
144753a7109SAlexandre TORGUE /* TDS3 use for both format (read and write back) */
145753a7109SAlexandre TORGUE #define RDES3_OWN			BIT(31)
146753a7109SAlexandre TORGUE 
147753a7109SAlexandre TORGUE #endif /* __DWMAC4_DESCS_H__ */
148