xref: /openbmc/qemu/hw/net/tulip.h (revision 8fa3b702)
1 #ifndef HW_TULIP_H
2 #define HW_TULIP_H
3 
4 #include "qemu/units.h"
5 #include "net/net.h"
6 #include "qom/object.h"
7 
8 #define TYPE_TULIP "tulip"
9 typedef struct TULIPState TULIPState;
10 DECLARE_INSTANCE_CHECKER(TULIPState, TULIP,
11                          TYPE_TULIP)
12 
13 #define CSR(_x) ((_x) << 3)
14 
15 #define CSR0_SWR        BIT(0)
16 #define CSR0_BAR        BIT(1)
17 #define CSR0_DSL_SHIFT  2
18 #define CSR0_DSL_MASK   0x1f
19 #define CSR0_BLE        BIT(7)
20 #define CSR0_PBL_SHIFT  8
21 #define CSR0_PBL_MASK   0x3f
22 #define CSR0_CAC_SHIFT  14
23 #define CSR0_CAC_MASK   0x3
24 #define CSR0_DAS        0x10000
25 #define CSR0_TAP_SHIFT  17
26 #define CSR0_TAP_MASK   0x7
27 #define CSR0_DBO        0x100000
28 #define CSR1_TPD        0x01
29 #define CSR0_RLE        BIT(23)
30 #define CSR0_WIE        BIT(24)
31 
32 #define CSR2_RPD        0x01
33 
34 #define CSR5_TI         BIT(0)
35 #define CSR5_TPS        BIT(1)
36 #define CSR5_TU         BIT(2)
37 #define CSR5_TJT        BIT(3)
38 #define CSR5_LNP_ANC    BIT(4)
39 #define CSR5_UNF        BIT(5)
40 #define CSR5_RI         BIT(6)
41 #define CSR5_RU         BIT(7)
42 #define CSR5_RPS        BIT(8)
43 #define CSR5_RWT        BIT(9)
44 #define CSR5_ETI        BIT(10)
45 #define CSR5_GTE        BIT(11)
46 #define CSR5_LNF        BIT(12)
47 #define CSR5_FBE        BIT(13)
48 #define CSR5_ERI        BIT(14)
49 #define CSR5_AIS        BIT(15)
50 #define CSR5_NIS        BIT(16)
51 #define CSR5_RS_SHIFT   17
52 #define CSR5_RS_MASK    7
53 #define CSR5_TS_SHIFT   20
54 #define CSR5_TS_MASK    7
55 
56 #define CSR5_TS_STOPPED                 0
57 #define CSR5_TS_RUNNING_FETCH           1
58 #define CSR5_TS_RUNNING_WAIT_EOT        2
59 #define CSR5_TS_RUNNING_READ_BUF        3
60 #define CSR5_TS_RUNNING_SETUP           5
61 #define CSR5_TS_SUSPENDED               6
62 #define CSR5_TS_RUNNING_CLOSE           7
63 
64 #define CSR5_RS_STOPPED                 0
65 #define CSR5_RS_RUNNING_FETCH           1
66 #define CSR5_RS_RUNNING_CHECK_EOR       2
67 #define CSR5_RS_RUNNING_WAIT_RECEIVE    3
68 #define CSR5_RS_SUSPENDED               4
69 #define CSR5_RS_RUNNING_CLOSE           5
70 #define CSR5_RS_RUNNING_FLUSH           6
71 #define CSR5_RS_RUNNING_QUEUE           7
72 
73 #define CSR5_EB_SHIFT   23
74 #define CSR5_EB_MASK    7
75 
76 #define CSR5_GPI        BIT(26)
77 #define CSR5_LC         BIT(27)
78 
79 #define CSR6_HP         BIT(0)
80 #define CSR6_SR         BIT(1)
81 #define CSR6_HO         BIT(2)
82 #define CSR6_PB         BIT(3)
83 #define CSR6_IF         BIT(4)
84 #define CSR6_SB         BIT(5)
85 #define CSR6_PR         BIT(6)
86 #define CSR6_PM         BIT(7)
87 #define CSR6_FKD        BIT(8)
88 #define CSR6_FD         BIT(9)
89 
90 #define CSR6_OM_SHIFT   10
91 #define CSR6_OM_MASK    3
92 #define CSR6_OM_NORMAL          0
93 #define CSR6_OM_INT_LOOPBACK    1
94 #define CSR6_OM_EXT_LOOPBACK    2
95 
96 #define CSR6_FC         BIT(12)
97 #define CSR6_ST         BIT(13)
98 
99 
100 #define CSR6_TR_SHIFT   14
101 #define CSR6_TR_MASK    3
102 #define CSR6_TR_72      0
103 #define CSR6_TR_96      1
104 #define CSR6_TR_128     2
105 #define CSR6_TR_160     3
106 
107 #define CSR6_CA         BIT(17)
108 #define CSR6_RA         BIT(30)
109 #define CSR6_SC         BIT(31)
110 
111 #define CSR7_TIM        BIT(0)
112 #define CSR7_TSM        BIT(1)
113 #define CSR7_TUM        BIT(2)
114 #define CSR7_TJM        BIT(3)
115 #define CSR7_LPM        BIT(4)
116 #define CSR7_UNM        BIT(5)
117 #define CSR7_RIM        BIT(6)
118 #define CSR7_RUM        BIT(7)
119 #define CSR7_RSM        BIT(8)
120 #define CSR7_RWM        BIT(9)
121 #define CSR7_TMM        BIT(11)
122 #define CSR7_LFM        BIT(12)
123 #define CSR7_SEM        BIT(13)
124 #define CSR7_ERM        BIT(14)
125 #define CSR7_AIM        BIT(15)
126 #define CSR7_NIM        BIT(16)
127 
128 #define CSR8_MISSED_FRAME_OVL           BIT(16)
129 #define CSR8_MISSED_FRAME_CNT_MASK      0xffff
130 
131 #define CSR9_DATA_MASK  0xff
132 #define CSR9_SR_CS      BIT(0)
133 #define CSR9_SR_SK      BIT(1)
134 #define CSR9_SR_DI      BIT(2)
135 #define CSR9_SR_DO      BIT(3)
136 #define CSR9_REG        BIT(10)
137 #define CSR9_SR         BIT(11)
138 #define CSR9_BR         BIT(12)
139 #define CSR9_WR         BIT(13)
140 #define CSR9_RD         BIT(14)
141 #define CSR9_MOD        BIT(15)
142 #define CSR9_MDC        BIT(16)
143 #define CSR9_MDO        BIT(17)
144 #define CSR9_MII        BIT(18)
145 #define CSR9_MDI        BIT(19)
146 
147 #define CSR11_CON       BIT(16)
148 #define CSR11_TIMER_MASK 0xffff
149 
150 #define CSR12_MRA       BIT(0)
151 #define CSR12_LS100     BIT(1)
152 #define CSR12_LS10      BIT(2)
153 #define CSR12_APS       BIT(3)
154 #define CSR12_ARA       BIT(8)
155 #define CSR12_TRA       BIT(9)
156 #define CSR12_NSN       BIT(10)
157 #define CSR12_TRF       BIT(11)
158 #define CSR12_ANS_SHIFT 12
159 #define CSR12_ANS_MASK  7
160 #define CSR12_LPN       BIT(15)
161 #define CSR12_LPC_SHIFT 16
162 #define CSR12_LPC_MASK  0xffff
163 
164 #define CSR13_SRL       BIT(0)
165 #define CSR13_CAC       BIT(2)
166 #define CSR13_AUI       BIT(3)
167 #define CSR13_SDM_SHIFT 4
168 #define CSR13_SDM_MASK  0xfff
169 
170 #define CSR14_ECEN      BIT(0)
171 #define CSR14_LBK       BIT(1)
172 #define CSR14_DREN      BIT(2)
173 #define CSR14_LSE       BIT(3)
174 #define CSR14_CPEN_SHIFT 4
175 #define CSR14_CPEN_MASK 3
176 #define CSR14_MBO       BIT(6)
177 #define CSR14_ANE       BIT(7)
178 #define CSR14_RSQ       BIT(8)
179 #define CSR14_CSQ       BIT(9)
180 #define CSR14_CLD       BIT(10)
181 #define CSR14_SQE       BIT(11)
182 #define CSR14_LTE       BIT(12)
183 #define CSR14_APE       BIT(13)
184 #define CSR14_SPP       BIT(14)
185 #define CSR14_TAS       BIT(15)
186 
187 #define CSR15_JBD       BIT(0)
188 #define CSR15_HUJ       BIT(1)
189 #define CSR15_JCK       BIT(2)
190 #define CSR15_ABM       BIT(3)
191 #define CSR15_RWD       BIT(4)
192 #define CSR15_RWR       BIT(5)
193 #define CSR15_LE1       BIT(6)
194 #define CSR15_LV1       BIT(7)
195 #define CSR15_TSCK      BIT(8)
196 #define CSR15_FUSQ      BIT(9)
197 #define CSR15_FLF       BIT(10)
198 #define CSR15_LSD       BIT(11)
199 #define CSR15_DPST      BIT(12)
200 #define CSR15_FRL       BIT(13)
201 #define CSR15_LE2       BIT(14)
202 #define CSR15_LV2       BIT(15)
203 
204 #define RDES0_OF         BIT(0)
205 #define RDES0_CE         BIT(1)
206 #define RDES0_DB         BIT(2)
207 #define RDES0_RJ         BIT(4)
208 #define RDES0_FT         BIT(5)
209 #define RDES0_CS         BIT(6)
210 #define RDES0_TL         BIT(7)
211 #define RDES0_LS         BIT(8)
212 #define RDES0_FS         BIT(9)
213 #define RDES0_MF         BIT(10)
214 #define RDES0_RF         BIT(11)
215 #define RDES0_DT_SHIFT   12
216 #define RDES0_DT_MASK    3
217 #define RDES0_DE         BIT(14)
218 #define RDES0_ES         BIT(15)
219 #define RDES0_FL_SHIFT   16
220 #define RDES0_FL_MASK    0x3fff
221 #define RDES0_FF         BIT(30)
222 #define RDES0_OWN        BIT(31)
223 
224 #define RDES1_BUF1_SIZE_SHIFT 0
225 #define RDES1_BUF1_SIZE_MASK 0x7ff
226 
227 #define RDES1_BUF2_SIZE_SHIFT 11
228 #define RDES1_BUF2_SIZE_MASK 0x7ff
229 #define RDES1_RCH       BIT(24)
230 #define RDES1_RER       BIT(25)
231 
232 #define TDES0_DE        BIT(0)
233 #define TDES0_UF        BIT(1)
234 #define TDES0_LF        BIT(2)
235 #define TDES0_CC_SHIFT  3
236 #define TDES0_CC_MASK   0xf
237 #define TDES0_HF        BIT(7)
238 #define TDES0_EC        BIT(8)
239 #define TDES0_LC        BIT(9)
240 #define TDES0_NC        BIT(10)
241 #define TDES0_LO        BIT(11)
242 #define TDES0_TO        BIT(14)
243 #define TDES0_ES        BIT(15)
244 #define TDES0_OWN       BIT(31)
245 
246 #define TDES1_BUF1_SIZE_SHIFT 0
247 #define TDES1_BUF1_SIZE_MASK 0x7ff
248 
249 #define TDES1_BUF2_SIZE_SHIFT 11
250 #define TDES1_BUF2_SIZE_MASK 0x7ff
251 
252 #define TDES1_FT0       BIT(22)
253 #define TDES1_DPD       BIT(23)
254 #define TDES1_TCH       BIT(24)
255 #define TDES1_TER       BIT(25)
256 #define TDES1_AC        BIT(26)
257 #define TDES1_SET       BIT(27)
258 #define TDES1_FT1       BIT(28)
259 #define TDES1_FS        BIT(29)
260 #define TDES1_LS        BIT(30)
261 #define TDES1_IC        BIT(31)
262 
263 struct tulip_descriptor {
264     uint32_t status;
265     uint32_t control;
266     uint32_t buf_addr1;
267     uint32_t buf_addr2;
268 };
269 
270 #endif
271