xref: /netbsd-src/sys/dev/pci/if_txpreg.h (revision fd153186c855a17c5920c73ef4df43511d8c7806)
1 /* $NetBSD: if_txpreg.h,v 1.11 2020/03/10 00:24:08 thorpej Exp $ */
2 
3 /*
4  * Copyright (c) 2001 Aaron Campbell <aaron@monkey.org>.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  * THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _DEV_PCI_IF_TXPREG_H_
30 #define	_DEV_PCI_IF_TXPREG_H_
31 
32 #define	TXP_PCI_LOMEM			0x14	/* pci conf, memory map BAR */
33 #define	TXP_PCI_LOIO			0x10	/* pci conf, IO map BAR */
34 
35 /*
36  * Typhoon registers.
37  */
38 #define	TXP_SRR				0x00	/* soft reset register */
39 #define	TXP_ISR				0x04	/* interrupt status register */
40 #define	TXP_IER				0x08	/* interrupt enable register */
41 #define	TXP_IMR				0x0c	/* interrupt mask register */
42 #define	TXP_SIR				0x10	/* self interrupt register */
43 #define	TXP_H2A_7			0x14	/* host->arm comm 7 */
44 #define	TXP_H2A_6			0x18	/* host->arm comm 6 */
45 #define	TXP_H2A_5			0x1c	/* host->arm comm 5 */
46 #define	TXP_H2A_4			0x20	/* host->arm comm 4 */
47 #define	TXP_H2A_3			0x24	/* host->arm comm 3 */
48 #define	TXP_H2A_2			0x28	/* host->arm comm 2 */
49 #define	TXP_H2A_1			0x2c	/* host->arm comm 1 */
50 #define	TXP_H2A_0			0x30	/* host->arm comm 0 */
51 #define	TXP_A2H_3			0x34	/* arm->host comm 3 */
52 #define	TXP_A2H_2			0x38	/* arm->host comm 2 */
53 #define	TXP_A2H_1			0x3c	/* arm->host comm 1 */
54 #define	TXP_A2H_0			0x40	/* arm->host comm 0 */
55 
56 /*
57  * interrupt bits (IMR, ISR, IER)
58  */
59 #define	TXP_INT_RESERVED	0xffff0000
60 #define	TXP_INT_A2H_7		0x00008000	/* arm->host comm 7 */
61 #define	TXP_INT_A2H_6		0x00004000	/* arm->host comm 6 */
62 #define	TXP_INT_A2H_5		0x00002000	/* arm->host comm 5 */
63 #define	TXP_INT_A2H_4		0x00001000	/* arm->host comm 4 */
64 #define	TXP_INT_SELF		0x00000800	/* self interrupt */
65 #define	TXP_INT_PCI_TABORT	0x00000400	/* pci target abort */
66 #define	TXP_INT_PCI_MABORT	0x00000200	/* pci master abort */
67 #define	TXP_INT_DMA3		0x00000100	/* dma3 done */
68 #define	TXP_INT_DMA2		0x00000080	/* dma2 done */
69 #define	TXP_INT_DMA1		0x00000040	/* dma1 done */
70 #define	TXP_INT_DMA0		0x00000020	/* dma0 done */
71 #define	TXP_INT_A2H_3		0x00000010	/* arm->host comm 3 */
72 #define	TXP_INT_A2H_2		0x00000008	/* arm->host comm 2 */
73 #define	TXP_INT_A2H_1		0x00000004	/* arm->host comm 1 */
74 #define	TXP_INT_A2H_0		0x00000002	/* arm->host comm 0 */
75 #define	TXP_INT_LATCH		0x00000001	/* interrupt latch */
76 
77 /*
78  * soft reset register (SRR)
79  */
80 #define	TXP_SRR_ALL		0x0000007f	/* full reset */
81 
82 /*
83  * Typhoon boot commands.
84  */
85 #define	TXP_BOOTCMD_NULL			0x00
86 #define	TXP_BOOTCMD_DOWNLOAD_COMPLETE		0xfb
87 #define	TXP_BOOTCMD_SEGMENT_AVAILABLE		0xfc
88 #define	TXP_BOOTCMD_RUNTIME_IMAGE		0xfd
89 #define	TXP_BOOTCMD_REGISTER_BOOT_RECORD	0xff
90 
91 /*
92  * Typhoon runtime commands.
93  */
94 #define	TXP_CMD_GLOBAL_RESET			0x00
95 #define	TXP_CMD_TX_ENABLE			0x01
96 #define	TXP_CMD_TX_DISABLE			0x02
97 #define	TXP_CMD_RX_ENABLE			0x03
98 #define	TXP_CMD_RX_DISABLE			0x04
99 #define	TXP_CMD_RX_FILTER_WRITE			0x05
100 #define	TXP_CMD_RX_FILTER_READ			0x06
101 #define	TXP_CMD_READ_STATISTICS			0x07
102 #define	TXP_CMD_CYCLE_STATISTICS		0x08
103 #define	TXP_CMD_CLEAR_STATISTICS		0x09
104 #define	TXP_CMD_MEMORY_READ			0x0a
105 #define	TXP_CMD_MEMORY_WRITE_SINGLE		0x0b
106 #define	TXP_CMD_VARIABLE_SECTION_READ		0x0c
107 #define	TXP_CMD_VARIABLE_SECTION_WRITE		0x0d
108 #define	TXP_CMD_STATIC_SECTION_READ		0x0e
109 #define	TXP_CMD_STATIC_SECTION_WRITE		0x0f
110 #define	TXP_CMD_IMAGE_SECTION_PROGRAM		0x10
111 #define	TXP_CMD_NVRAM_PAGE_READ			0x11
112 #define	TXP_CMD_NVRAM_PAGE_WRITE		0x12
113 #define	TXP_CMD_XCVR_SELECT			0x13
114 #define	TXP_CMD_TEST_MUX			0x14
115 #define	TXP_CMD_PHYLOOPBACK_ENABLE		0x15
116 #define	TXP_CMD_PHYLOOPBACK_DISABLE		0x16
117 #define	TXP_CMD_MAC_CONTROL_READ		0x17
118 #define	TXP_CMD_MAC_CONTROL_WRITE		0x18
119 #define	TXP_CMD_MAX_PKT_SIZE_READ		0x19
120 #define	TXP_CMD_MAX_PKT_SIZE_WRITE		0x1a
121 #define	TXP_CMD_MEDIA_STATUS_READ		0x1b
122 #define	TXP_CMD_MEDIA_STATUS_WRITE		0x1c
123 #define	TXP_CMD_NETWORK_DIAGS_READ		0x1d
124 #define	TXP_CMD_NETWORK_DIAGS_WRITE		0x1e
125 #define	TXP_CMD_PHY_MGMT_READ			0x1f
126 #define	TXP_CMD_PHY_MGMT_WRITE			0x20
127 #define	TXP_CMD_VARIABLE_PARAMETER_READ		0x21
128 #define	TXP_CMD_VARIABLE_PARAMETER_WRITE	0x22
129 #define	TXP_CMD_GOTO_SLEEP			0x23
130 #define	TXP_CMD_FIREWALL_CONTROL		0x24
131 #define	TXP_CMD_MCAST_HASH_MASK_WRITE		0x25
132 #define	TXP_CMD_STATION_ADDRESS_WRITE		0x26
133 #define	TXP_CMD_STATION_ADDRESS_READ		0x27
134 #define	TXP_CMD_STATION_MASK_WRITE		0x28
135 #define	TXP_CMD_STATION_MASK_READ		0x29
136 #define	TXP_CMD_VLAN_ETHER_TYPE_READ		0x2a
137 #define	TXP_CMD_VLAN_ETHER_TYPE_WRITE		0x2b
138 #define	TXP_CMD_VLAN_MASK_READ			0x2c
139 #define	TXP_CMD_VLAN_MASK_WRITE			0x2d
140 #define	TXP_CMD_BCAST_THROTTLE_WRITE		0x2e
141 #define	TXP_CMD_BCAST_THROTTLE_READ		0x2f
142 #define	TXP_CMD_DHCP_PREVENT_WRITE		0x30
143 #define	TXP_CMD_DHCP_PREVENT_READ		0x31
144 #define	TXP_CMD_RECV_BUFFER_CONTROL		0x32
145 #define	TXP_CMD_SOFTWARE_RESET			0x33
146 #define	TXP_CMD_CREATE_SA			0x34
147 #define	TXP_CMD_DELETE_SA			0x35
148 #define	TXP_CMD_ENABLE_RX_IP_OPTION		0x36
149 #define	TXP_CMD_RANDOM_NUMBER_CONTROL		0x37
150 #define	TXP_CMD_RANDOM_NUMBER_READ		0x38
151 #define	TXP_CMD_MATRIX_TABLE_MODE_WRITE		0x39
152 #define	TXP_CMD_MATRIX_DETAIL_READ		0x3a
153 #define	TXP_CMD_FILTER_ARRAY_READ		0x3b
154 #define	TXP_CMD_FILTER_DETAIL_READ		0x3c
155 #define	TXP_CMD_FILTER_TABLE_MODE_WRITE		0x3d
156 #define	TXP_CMD_FILTER_TCL_WRITE		0x3e
157 #define	TXP_CMD_FILTER_TBL_READ			0x3f
158 #define	TXP_CMD_VERSIONS_READ			0x43
159 #define	TXP_CMD_FILTER_DEFINE			0x45
160 #define	TXP_CMD_ADD_WAKEUP_PKT			0x46
161 #define	TXP_CMD_ADD_SLEEP_PKT			0x47
162 #define	TXP_CMD_ENABLE_SLEEP_EVENTS		0x48
163 #define	TXP_CMD_ENABLE_WAKEUP_EVENTS		0x49
164 #define	TXP_CMD_GET_IP_ADDRESS			0x4a
165 #define	TXP_CMD_READ_PCI_REG			0x4c
166 #define	TXP_CMD_WRITE_PCI_REG			0x4d
167 #define	TXP_CMD_OFFLOAD_READ			0x4e
168 #define	TXP_CMD_OFFLOAD_WRITE			0x4f
169 #define	TXP_CMD_HELLO_RESPONSE			0x57
170 #define	TXP_CMD_ENABLE_RX_FILTER		0x58
171 #define	TXP_CMD_RX_FILTER_CAPABILITY		0x59
172 #define	TXP_CMD_HALT				0x5d
173 #define	TXP_CMD_READ_IPSEC_INFO			0x54
174 #define	TXP_CMD_GET_IPSEC_ENABLE		0x67
175 #define	TXP_CMD_INVALID				0xffff
176 
177 #define	TXP_FRAGMENT		0x0000
178 #define	TXP_TXFRAME		0x0001
179 #define	TXP_COMMAND		0x0002
180 #define	TXP_OPTION		0x0003
181 #define	TXP_RECEIVE		0x0004
182 #define	TXP_RESPONSE		0x0005
183 
184 #define	TXP_TYPE_IPSEC		0x0000
185 #define	TXP_TYPE_TCPSEGMENT	0x0001
186 
187 #define	TXP_PFLAG_NOCRC		0x0000
188 #define	TXP_PFLAG_IPCKSUM	0x0001
189 #define	TXP_PFLAG_TCPCKSUM	0x0002
190 #define	TXP_PFLAG_TCPSEGMENT	0x0004
191 #define	TXP_PFLAG_INSERTVLAN	0x0008
192 #define	TXP_PFLAG_IPSEC		0x0010
193 #define	TXP_PFLAG_PRIORITY	0x0020
194 #define	TXP_PFLAG_UDPCKSUM	0x0040
195 #define	TXP_PFLAG_PADFRAME	0x0080
196 
197 #define	TXP_MISC_FIRSTDESC	0x0000
198 #define	TXP_MISC_LASTDESC	0x0001
199 
200 #define	TXP_ERR_INTERNAL	0x0000
201 #define	TXP_ERR_FIFOUNDERRUN	0x0001
202 #define	TXP_ERR_BADSSD		0x0002
203 #define	TXP_ERR_RUNT		0x0003
204 #define	TXP_ERR_CRC		0x0004
205 #define	TXP_ERR_OVERSIZE	0x0005
206 #define	TXP_ERR_ALIGNMENT	0x0006
207 #define	TXP_ERR_DRIBBLEBIT	0x0007
208 
209 #define	TXP_PROTO_UNKNOWN	0x0000
210 #define	TXP_PROTO_IP		0x0001
211 #define	TXP_PROTO_IPX		0x0002
212 #define	TXP_PROTO_RESERVED	0x0003
213 
214 #define	TXP_STAT_PROTO		0x0001
215 #define	TXP_STAT_VLAN		0x0002
216 #define	TXP_STAT_IPFRAGMENT	0x0004
217 #define	TXP_STAT_IPSEC		0x0008
218 #define	TXP_STAT_IPCKSUMBAD	0x0010
219 #define	TXP_STAT_TCPCKSUMBAD	0x0020
220 #define	TXP_STAT_UDPCKSUMBAD	0x0040
221 #define	TXP_STAT_IPCKSUMGOOD	0x0080
222 #define	TXP_STAT_TCPCKSUMGOOD	0x0100
223 #define	TXP_STAT_UDPCKSUMGOOD	0x0200
224 
225 struct txp_tx_desc {
226 	volatile u_int8_t	tx_flags;	/* type/descriptor flags */
227 	volatile u_int8_t	tx_numdesc;	/* number of descriptors */
228 	volatile u_int16_t	tx_totlen;	/* total packet length */
229 	volatile u_int32_t	tx_addrlo;	/* virt addr low word */
230 	volatile u_int32_t	tx_addrhi;	/* virt addr high word */
231 	volatile u_int32_t	tx_pflags;	/* processing flags */
232 };
233 #define	TX_FLAGS_TYPE_M		0x07		/* type mask */
234 #define	TX_FLAGS_TYPE_FRAG	0x00		/* type: fragment */
235 #define	TX_FLAGS_TYPE_DATA	0x01		/* type: data frame */
236 #define	TX_FLAGS_TYPE_CMD	0x02		/* type: command frame */
237 #define	TX_FLAGS_TYPE_OPT	0x03		/* type: options */
238 #define	TX_FLAGS_TYPE_RX	0x04		/* type: command */
239 #define	TX_FLAGS_TYPE_RESP	0x05		/* type: response */
240 #define	TX_FLAGS_RESP		0x40		/* response requested */
241 #define	TX_FLAGS_VALID		0x80		/* valid descriptor */
242 
243 #define	TX_PFLAGS_DNAC		0x00000001	/* do not add crc */
244 #define	TX_PFLAGS_IPCKSUM	0x00000002	/* ip checksum */
245 #define	TX_PFLAGS_TCPCKSUM	0x00000004	/* tcp checksum */
246 #define	TX_PFLAGS_TCPSEG	0x00000008	/* tcp segmentation */
247 #define	TX_PFLAGS_VLAN		0x00000010	/* insert vlan */
248 #define	TX_PFLAGS_IPSEC		0x00000020	/* perform ipsec */
249 #define	TX_PFLAGS_PRIO		0x00000040	/* priority field valid */
250 #define	TX_PFLAGS_UDPCKSUM	0x00000080	/* udp checksum */
251 #define	TX_PFLAGS_PADFRAME	0x00000100	/* pad frame */
252 #define	TX_PFLAGS_VLANTAG_M	0x0ffff000	/* vlan tag mask */
253 #define	TX_PFLAGS_VLANPRI_M	0x00700000	/* vlan priority mask */
254 #define	TX_PFLAGS_VLANTAG_S	12		/* amount to shift tag */
255 
256 struct txp_rx_desc {
257 	volatile u_int8_t	rx_flags;	/* type/descriptor flags */
258 	volatile u_int8_t	rx_numdesc;	/* number of descriptors */
259 	volatile u_int16_t	rx_len;		/* frame length */
260 	volatile u_int32_t	rx_vaddrlo;	/* virtual address, lo word */
261 	volatile u_int32_t	rx_vaddrhi;	/* virtual address, hi word */
262 	volatile u_int32_t	rx_stat;	/* status */
263 	volatile u_int16_t	rx_filter;	/* filter status */
264 	volatile u_int16_t	rx_hash;	/* hash status */
265 	volatile u_int32_t	rx_vlan;	/* vlan tag/priority */
266 };
267 
268 /* txp_rx_desc.rx_flags */
269 #define	RX_FLAGS_TYPE_M		0x07		/* type mask */
270 #define	RX_FLAGS_TYPE_FRAG	0x00		/* type: fragment */
271 #define	RX_FLAGS_TYPE_DATA	0x01		/* type: data frame */
272 #define	RX_FLAGS_TYPE_CMD	0x02		/* type: command frame */
273 #define	RX_FLAGS_TYPE_OPT	0x03		/* type: options */
274 #define	RX_FLAGS_TYPE_RX	0x04		/* type: command */
275 #define	RX_FLAGS_TYPE_RESP	0x05		/* type: response */
276 #define	RX_FLAGS_RCV_TYPE_M	0x18		/* rcvtype mask */
277 #define	RX_FLAGS_RCV_TYPE_RX	0x00		/* rcvtype: receive */
278 #define	RX_FLAGS_RCV_TYPE_RSP	0x08		/* rcvtype: response */
279 #define	RX_FLAGS_ERROR		0x40		/* error in packet */
280 
281 /* txp_rx_desc.rx_stat (if rx_flags & RX_FLAGS_ERROR bit set) */
282 #define	RX_ERROR_ADAPTER	0x00000000	/* adapter internal error */
283 #define	RX_ERROR_FIFO		0x00000001	/* fifo underrun */
284 #define	RX_ERROR_BADSSD		0x00000002	/* bad ssd */
285 #define	RX_ERROR_RUNT		0x00000003	/* runt packet */
286 #define	RX_ERROR_CRC		0x00000004	/* bad crc */
287 #define	RX_ERROR_OVERSIZE	0x00000005	/* oversized packet */
288 #define	RX_ERROR_ALIGN		0x00000006	/* alignment error */
289 #define	RX_ERROR_DRIBBLE	0x00000007	/* dribble bit */
290 
291 /* txp_rx_desc.rx_stat (if rx_flags & RX_FLAGS_ERROR not bit set) */
292 #define	RX_STAT_PROTO_M		0x00000003	/* protocol mask */
293 #define	RX_STAT_PROTO_UK	0x00000000	/* unknown protocol */
294 #define	RX_STAT_PROTO_IPX	0x00000001	/* IPX */
295 #define	RX_STAT_PROTO_IP	0x00000002	/* IP */
296 #define	RX_STAT_PROTO_RSV	0x00000003	/* reserved */
297 #define	RX_STAT_VLAN		0x00000004	/* vlan tag (in rxd) */
298 #define	RX_STAT_IPFRAG		0x00000008	/* fragment, ipsec not done */
299 #define	RX_STAT_IPSEC		0x00000010	/* ipsec decoded packet */
300 #define	RX_STAT_IPCKSUMBAD	0x00000020	/* ip checksum failed */
301 #define	RX_STAT_UDPCKSUMBAD	0x00000040	/* udp checksum failed */
302 #define	RX_STAT_TCPCKSUMBAD	0x00000080	/* tcp checksum failed */
303 #define	RX_STAT_IPCKSUMGOOD	0x00000100	/* ip checksum succeeded */
304 #define	RX_STAT_UDPCKSUMGOOD	0x00000200	/* udp checksum succeeded */
305 #define	RX_STAT_TCPCKSUMGOOD	0x00000400	/* tcp checksum succeeded */
306 
307 
308 struct txp_rxbuf_desc {
309 	volatile u_int32_t	rb_paddrlo;
310 	volatile u_int32_t	rb_paddrhi;
311 	volatile u_int32_t	rb_vaddrlo;
312 	volatile u_int32_t	rb_vaddrhi;
313 };
314 
315 /* Extension descriptor */
316 struct txp_ext_desc {
317 	volatile u_int32_t	ext_1;
318 	volatile u_int32_t	ext_2;
319 	volatile u_int32_t	ext_3;
320 	volatile u_int32_t	ext_4;
321 };
322 
323 struct txp_cmd_desc {
324 	volatile u_int8_t	cmd_flags;
325 	volatile u_int8_t	cmd_numdesc;
326 	volatile u_int16_t	cmd_id;
327 	volatile u_int16_t	cmd_seq;
328 	volatile u_int16_t	cmd_par1;
329 	volatile u_int32_t	cmd_par2;
330 	volatile u_int32_t	cmd_par3;
331 };
332 #define	CMD_FLAGS_TYPE_M	0x07		/* type mask */
333 #define	CMD_FLAGS_TYPE_FRAG	0x00		/* type: fragment */
334 #define	CMD_FLAGS_TYPE_DATA	0x01		/* type: data frame */
335 #define	CMD_FLAGS_TYPE_CMD	0x02		/* type: command frame */
336 #define	CMD_FLAGS_TYPE_OPT	0x03		/* type: options */
337 #define	CMD_FLAGS_TYPE_RX	0x04		/* type: command */
338 #define	CMD_FLAGS_TYPE_RESP	0x05		/* type: response */
339 #define	CMD_FLAGS_RESP		0x40		/* response requested */
340 #define	CMD_FLAGS_VALID		0x80		/* valid descriptor */
341 
342 struct txp_rsp_desc {
343 	volatile u_int8_t	rsp_flags;
344 	volatile u_int8_t	rsp_numdesc;
345 	volatile u_int16_t	rsp_id;
346 	volatile u_int16_t	rsp_seq;
347 	volatile u_int16_t	rsp_par1;
348 	volatile u_int32_t	rsp_par2;
349 	volatile u_int32_t	rsp_par3;
350 };
351 #define	RSP_FLAGS_TYPE_M	0x07		/* type mask */
352 #define	RSP_FLAGS_TYPE_FRAG	0x00		/* type: fragment */
353 #define	RSP_FLAGS_TYPE_DATA	0x01		/* type: data frame */
354 #define	RSP_FLAGS_TYPE_CMD	0x02		/* type: command frame */
355 #define	RSP_FLAGS_TYPE_OPT	0x03		/* type: options */
356 #define	RSP_FLAGS_TYPE_RX	0x04		/* type: command */
357 #define	RSP_FLAGS_TYPE_RESP	0x05		/* type: response */
358 #define	RSP_FLAGS_ERROR		0x40		/* response error */
359 
360 struct txp_frag_desc {
361 	volatile u_int8_t	frag_flags;	/* type/descriptor flags */
362 	volatile u_int8_t	frag_rsvd1;
363 	volatile u_int16_t	frag_len;	/* bytes in this fragment */
364 	volatile u_int32_t	frag_addrlo;	/* phys addr low word */
365 	volatile u_int32_t	frag_addrhi;	/* phys addr high word */
366 	volatile u_int32_t	frag_rsvd2;
367 };
368 #define	FRAG_FLAGS_TYPE_M	0x07		/* type mask */
369 #define	FRAG_FLAGS_TYPE_FRAG	0x00		/* type: fragment */
370 #define	FRAG_FLAGS_TYPE_DATA	0x01		/* type: data frame */
371 #define	FRAG_FLAGS_TYPE_CMD	0x02		/* type: command frame */
372 #define	FRAG_FLAGS_TYPE_OPT	0x03		/* type: options */
373 #define	FRAG_FLAGS_TYPE_RX	0x04		/* type: command */
374 #define	FRAG_FLAGS_TYPE_RESP	0x05		/* type: response */
375 #define	FRAG_FLAGS_VALID	0x80		/* valid descriptor */
376 
377 struct txp_opt_desc {
378 	u_int8_t		opt_desctype:3,
379 				opt_rsvd:1,
380 				opt_type:4;
381 
382 	u_int8_t		opt_num;
383 	u_int16_t		opt_dep1;
384 	u_int32_t		opt_dep2;
385 	u_int32_t		opt_dep3;
386 	u_int32_t		opt_dep4;
387 };
388 
389 struct txp_ipsec_desc {
390 	u_int8_t		ipsec_desctpe:3,
391 				ipsec_rsvd:1,
392 				ipsec_type:4;
393 
394 	u_int8_t		ipsec_num;
395 	u_int16_t		ipsec_flags;
396 	u_int16_t		ipsec_ah1;
397 	u_int16_t		ipsec_esp1;
398 	u_int16_t		ipsec_ah2;
399 	u_int16_t		ipsec_esp2;
400 	u_int32_t		ipsec_rsvd1;
401 };
402 
403 struct txp_tcpseg_desc {
404 	u_int8_t		tcpseg_desctype:3,
405 				tcpseg_rsvd:1,
406 				tcpseg_type:4;
407 
408 	u_int8_t		tcpseg_num;
409 
410 	u_int16_t		tcpseg_mss:12,
411 				tcpseg_misc:4;
412 
413 	u_int32_t		tcpseg_respaddr;
414 	u_int32_t		tcpseg_txbytes;
415 	u_int32_t		tcpseg_lss;
416 };
417 
418 /*
419  * Transceiver types
420  */
421 #define	TXP_XCVR_10_HDX		0
422 #define	TXP_XCVR_10_FDX		1
423 #define	TXP_XCVR_100_HDX	2
424 #define	TXP_XCVR_100_FDX	3
425 #define	TXP_XCVR_AUTO		4
426 
427 #define TXP_MEDIA_CRC		0x0004	/* crc strip disable */
428 #define	TXP_MEDIA_CD		0x0010	/* collision detection */
429 #define	TXP_MEDIA_CS		0x0020	/* carrier sense */
430 #define	TXP_MEDIA_POL		0x0400	/* polarity reversed */
431 #define	TXP_MEDIA_NOLINK	0x0800	/* 0 = link, 1 = no link */
432 
433 /*
434  * receive filter bits (par1 to TXP_CMD_RX_FILTER_{READ|WRITE}
435  */
436 #define	TXP_RXFILT_DIRECT	0x0001	/* directed packets */
437 #define	TXP_RXFILT_ALLMULTI	0x0002	/* all multicast packets */
438 #define	TXP_RXFILT_BROADCAST	0x0004	/* broadcast packets */
439 #define	TXP_RXFILT_PROMISC	0x0008	/* promiscuous mode */
440 #define	TXP_RXFILT_HASHMULTI	0x0010	/* use multicast filter */
441 
442 /* multicast polynomial */
443 #define	TXP_POLYNOMIAL		0x04c11db7
444 
445 /*
446  * boot record (pointers to rings)
447  */
448 struct txp_boot_record {
449 	volatile u_int32_t	br_hostvar_lo;		/* host ring pointer */
450 	volatile u_int32_t	br_hostvar_hi;
451 	volatile u_int32_t	br_txlopri_lo;		/* tx low pri ring */
452 	volatile u_int32_t	br_txlopri_hi;
453 	volatile u_int32_t	br_txlopri_siz;
454 	volatile u_int32_t	br_txhipri_lo;		/* tx high pri ring */
455 	volatile u_int32_t	br_txhipri_hi;
456 	volatile u_int32_t	br_txhipri_siz;
457 	volatile u_int32_t	br_rxlopri_lo;		/* rx low pri ring */
458 	volatile u_int32_t	br_rxlopri_hi;
459 	volatile u_int32_t	br_rxlopri_siz;
460 	volatile u_int32_t	br_rxbuf_lo;		/* rx buffer ring */
461 	volatile u_int32_t	br_rxbuf_hi;
462 	volatile u_int32_t	br_rxbuf_siz;
463 	volatile u_int32_t	br_cmd_lo;		/* command ring */
464 	volatile u_int32_t	br_cmd_hi;
465 	volatile u_int32_t	br_cmd_siz;
466 	volatile u_int32_t	br_resp_lo;		/* response ring */
467 	volatile u_int32_t	br_resp_hi;
468 	volatile u_int32_t	br_resp_siz;
469 	volatile u_int32_t	br_zero_lo;		/* zero word */
470 	volatile u_int32_t	br_zero_hi;
471 	volatile u_int32_t	br_rxhipri_lo;		/* rx high pri ring */
472 	volatile u_int32_t	br_rxhipri_hi;
473 	volatile u_int32_t	br_rxhipri_siz;
474 };
475 
476 /*
477  * hostvar structure (shared with typhoon)
478  */
479 struct txp_hostvar {
480 	volatile u_int32_t	hv_rx_hi_read_idx;	/* host->arm */
481 	volatile u_int32_t	hv_rx_lo_read_idx;	/* host->arm */
482 	volatile u_int32_t	hv_rx_buf_write_idx;	/* host->arm */
483 	volatile u_int32_t	hv_resp_read_idx;	/* host->arm */
484 	volatile u_int32_t	hv_tx_lo_desc_read_idx;	/* arm->host */
485 	volatile u_int32_t	hv_tx_hi_desc_read_idx;	/* arm->host */
486 	volatile u_int32_t	hv_rx_lo_write_idx;	/* arm->host */
487 	volatile u_int32_t	hv_rx_buf_read_idx;	/* arm->host */
488 	volatile u_int32_t	hv_cmd_read_idx;	/* arm->host */
489 	volatile u_int32_t	hv_resp_write_idx;	/* arm->host */
490 	volatile u_int32_t	hv_rx_hi_write_idx;	/* arm->host */
491 };
492 
493 /*
494  * TYPHOON status register state (in TXP_A2H_0)
495  */
496 #define	STAT_ROM_CODE			0x00000001
497 #define	STAT_ROM_EEPROM_LOAD		0x00000002
498 #define	STAT_WAITING_FOR_BOOT		0x00000007
499 #define	STAT_RUNNING			0x00000009
500 #define	STAT_WAITING_FOR_HOST_REQUEST	0x0000000d
501 #define	STAT_WAITING_FOR_SEGMENT	0x00000010
502 #define	STAT_SLEEPING			0x00000011
503 #define	STAT_HALTED			0x00000014
504 
505 #define	TX_ENTRIES			256
506 #define	RX_ENTRIES			128
507 #define	RXBUF_ENTRIES			256
508 #define	CMD_ENTRIES			32
509 #define	RSP_ENTRIES			32
510 
511 #define	OFFLOAD_TCPCKSUM		0x00000002	/* tcp checksum */
512 #define	OFFLOAD_UDPCKSUM		0x00000004	/* udp checksum */
513 #define	OFFLOAD_IPCKSUM			0x00000008	/* ip checksum */
514 #define	OFFLOAD_IPSEC			0x00000010	/* ipsec enable */
515 #define	OFFLOAD_BCAST			0x00000020	/* broadcast throttle */
516 #define	OFFLOAD_DHCP			0x00000040	/* dhcp prevention */
517 #define	OFFLOAD_VLAN			0x00000080	/* vlan enable */
518 #define	OFFLOAD_FILTER			0x00000100	/* filter enable */
519 #define	OFFLOAD_TCPSEG			0x00000200	/* tcp segmentation */
520 #define	OFFLOAD_MASK			0xfffffffe	/* mask off low bit */
521 
522 /*
523  * Macros for converting array indices to offsets within the descriptor
524  * arrays.  The chip operates on offsets, but it's much easier for us
525  * to operate on indices.  Assumes descriptor entries are 16 bytes.
526  */
527 #define	TXP_IDX2OFFSET(idx)	((idx) << 4)
528 #define	TXP_OFFSET2IDX(off)	((off) >> 4)
529 
530 struct txp_dma_alloc {
531 	void *			dma_vaddr;
532 	bus_dmamap_t		dma_map;
533 #define	dma_paddr		dma_map->dm_segs[0].ds_addr
534 	bus_dma_segment_t	dma_seg;
535 	int			dma_nseg;
536 };
537 
538 struct txp_cmd_ring {
539 	struct txp_cmd_desc	*base;
540 	u_int32_t		lastwrite;
541 	u_int32_t		size;
542 };
543 
544 struct txp_rsp_ring {
545 	struct txp_rsp_desc	*base;
546 	u_int32_t		lastwrite;
547 	u_int32_t		size;
548 };
549 
550 struct txp_tx_ring {
551 	struct txp_tx_desc	*r_desc;	/* base address of descs */
552 	u_int32_t		r_reg;		/* register to activate */
553 	u_int32_t		r_prod;		/* producer */
554 	u_int32_t		r_cons;		/* consumer */
555 	u_int32_t		r_cnt;		/* # descs in use */
556 	volatile u_int32_t	*r_off;		/* hostvar index pointer */
557 };
558 
559 struct txp_swdesc {
560 	struct mbuf *		sd_mbuf;
561 	bus_dmamap_t		sd_map;
562 };
563 
564 struct txp_rx_ring {
565 	struct txp_rx_desc	*r_desc;	/* base address of descs */
566 	volatile u_int32_t	*r_roff;	/* hv read offset ptr */
567 	volatile u_int32_t	*r_woff;	/* hv write offset ptr */
568 };
569 
570 struct txp_softc {
571 	device_t		sc_dev;		/* base device */
572 	struct ethercom		sc_arpcom;	/* ethernet common */
573 	struct txp_hostvar	*sc_hostvar;
574 	struct txp_boot_record	*sc_boot;
575 	bus_space_handle_t	sc_bh;		/* bus handle (regs) */
576 	bus_space_tag_t		sc_bt;		/* bus tag (regs) */
577 	bus_dma_tag_t		sc_dmat;	/* dma tag */
578 	struct txp_cmd_ring	sc_cmdring;
579 	struct txp_rsp_ring	sc_rspring;
580 	struct txp_swdesc	sc_txd[TX_ENTRIES];
581 	void *			sc_ih;
582 	struct callout		sc_tick;
583 	struct ifmedia		sc_ifmedia;
584 	struct txp_tx_ring	sc_txhir, sc_txlor;
585 	struct txp_rxbuf_desc	*sc_rxbufs;
586 	struct txp_rx_ring	sc_rxhir, sc_rxlor;
587 	struct txp_swdesc	sc_rxd[RXBUF_ENTRIES];
588 	struct txp_swdesc	*sc_rxd_pool[RXBUF_ENTRIES];
589 	unsigned int		sc_txd_pool_ptr;
590 	u_int16_t		sc_xcvr;
591 	u_int16_t		sc_seq;
592 	struct txp_dma_alloc	sc_boot_dma, sc_host_dma, sc_zero_dma;
593 	struct txp_dma_alloc	sc_rxhiring_dma, sc_rxloring_dma;
594 	struct txp_dma_alloc	sc_txhiring_dma, sc_txloring_dma;
595 	struct txp_dma_alloc	sc_cmdring_dma, sc_rspring_dma;
596 	struct txp_dma_alloc	sc_rxbufring_dma;
597 	int			sc_cold;
598 	u_int32_t		sc_rx_capability, sc_tx_capability;
599 	int			sc_flags;
600 #define TXP_USESUBSYSTEM	0x1 /* use PCI subsys reg for detail info */
601 #define TXP_SERVERVERSION	0x2
602 #define TXP_FIBER		0x4
603 };
604 
605 #define	TXP_DEVNAME(sc)		((sc)->sc_cold ? "" : device_xname((sc)->sc_dev))
606 
607 struct txp_fw_file_header {
608 	u_int8_t	magicid[8];	/* TYPHOON\0 */
609 	u_int32_t	version;
610 	u_int32_t	nsections;
611 	u_int32_t	addr;
612 	u_int32_t	hmac[5];
613 };
614 
615 struct txp_fw_section_header {
616 	u_int32_t	nbytes;
617 	u_int16_t	cksum;
618 	u_int16_t	reserved;
619 	u_int32_t	addr;
620 };
621 
622 #define	TXP_MAX_SEGLEN	0xffff
623 #define	TXP_MAX_PKTLEN	0x0800
624 
625 #define	TXP_MAXTXSEGS	16
626 
627 #define	WRITE_REG(sc,reg,val) \
628     bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, reg, val)
629 #define	READ_REG(sc,reg) \
630     bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, reg)
631 
632 #endif /* _DEV_PCI_IF_TXPREG_H_ */
633