2 * originally drivers/net/tulip/tulip.h
3 * Copyright 2000,2001 The Linux Kernel Team
4 * Written/copyright 1994-2001 by Donald Becker.
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
11 #ifndef __NET_TULIP_H__
12 #define __NET_TULIP_H__
14 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/init.h>
17 #include <linux/mii.h>
18 #include <linux/crc32.h>
19 #include <linux/kernel.h>
20 #include <linux/types.h>
21 #include <linux/spinlock.h>
22 #include <linux/netdevice.h>
23 #include <linux/ethtool.h>
24 #include <linux/timer.h>
25 #include <linux/delay.h>
26 #include <linux/etherdevice.h>
27 #include <linux/platform_device.h>
28 #include <asm/unaligned.h>
29 #include <asm/uaccess.h>
33 /* undefine, or define to various debugging levels (>4 == obscene levels) */
35 #define VALID_INTR 0x0001a451
36 #define ADM8668_WAN_IRQ 8
37 #define ADM8668_LAN_IRQ 7
38 #define ADM8668_WAN_MACADDR 0xb00205ac
39 #define ADM8668_LAN_MACADDR 0xb0020404
41 /* Offsets to the Command and Status Registers, "CSRs". All accesses
42 must be longword instructions and quadword aligned. */
67 #define RxPollInt (RxIntr|RxNoBuf|RxDied|RxJabber)
69 /* The bits in the CSR5 status registers, mostly interrupt sources. */
76 AbnormalIntr
= 0x8000,
81 TxFIFOUnderflow
= 0x20,
89 /* bit mask for CSR5 TX/RX process state */
90 #define CSR5_TS 0x00700000
91 #define CSR5_RS 0x000e0000
93 enum tulip_mode_bits
{
94 TxThreshold
= (1 << 22),
95 FullDuplex
= (1 << 9),
97 AcceptBroadcast
= 0x0100,
98 AcceptAllMulticast
= 0x0080,
99 AcceptAllPhys
= 0x0040,
102 RxTx
= (TxOn
| RxOn
),
105 /* The Tulip Rx and Tx buffer descriptors. */
106 struct tulip_rx_desc
{
113 struct tulip_tx_desc
{
117 __le32 buffer2
; /* We use only buffer 1. */
120 enum desc_status_bits
{
121 DescOwned
= 0x80000000,
122 DescWholePkt
= 0x60000000,
123 DescEndPkt
= 0x40000000,
124 DescStartPkt
= 0x20000000,
125 DescEndRing
= 0x02000000,
126 DescUseLink
= 0x01000000,
129 * Error summary flag is logical or of 'CRC Error', 'Collision Seen',
130 * 'Frame Too Long', 'Runt' and 'Descriptor Error' flags generated
133 RxDescErrorSummary
= 0x8000,
134 RxDescCRCError
= 0x0002,
135 RxDescCollisionSeen
= 0x0040,
138 * 'Frame Too Long' flag is set if packet length including CRC exceeds
139 * 1518. However, a full sized VLAN tagged frame is 1522 bytes
142 * The tulip chip does not block oversized frames, and if this flag is
143 * set on a receive descriptor it does not indicate the frame has been
144 * truncated. The receive descriptor also includes the actual length.
145 * Therefore we can safety ignore this flag and check the length
148 RxDescFrameTooLong
= 0x0080,
150 RxDescDescErr
= 0x4000,
151 RxWholePkt
= 0x00000300,
153 * Top three bits of 14 bit frame length (status bits 27-29) should
154 * never be set as that would make frame over 2047 bytes. The Receive
155 * Watchdog flag (bit 4) may indicate the length is over 2048 and the
156 * length field is invalid.
158 RxLengthOver2047
= 0x38000010
161 /* Keep the ring sizes a power of two for efficiency.
162 Making the Tx ring too large decreases the effectiveness of channel
163 bonding and packet priority.
164 There are no ill effects from too-large receive rings. */
166 #define TX_RING_SIZE 32
167 #define RX_RING_SIZE 128
169 /* The receiver on the DC21143 rev 65 can fail to close the last
170 * receive descriptor in certain circumstances (see errata) when
171 * using MWI. This can only occur if the receive buffer ends on
172 * a cache line boundary, so the "+ 4" below ensures it doesn't.
174 #define PKT_BUF_SZ (1536 + 4) /* Size of each temporary Rx buffer. */
176 /* Ring-wrap flag in length field, use for last ring entry.
177 0x01000000 means chain on buffer2 address,
178 0x02000000 means use the ring start address in CSR2/3.
179 Note: Some work-alike chips do not function correctly in chained mode.
180 The ASIX chip works only in chained mode.
181 Thus we indicates ring mode, but always write the 'next' field for
182 chained mode as well.
184 #define DESC_RING_WRAP 0x02000000
191 struct tulip_private
{
192 struct tulip_rx_desc
*rx_ring
;
193 struct tulip_tx_desc
*tx_ring
;
194 dma_addr_t rx_ring_dma
;
195 dma_addr_t tx_ring_dma
;
196 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
197 struct ring_info tx_buffers
[TX_RING_SIZE
];
198 /* The addresses of receive-in-place skbuffs. */
199 struct ring_info rx_buffers
[RX_RING_SIZE
];
200 struct napi_struct napi
;
201 struct net_device_stats stats
;
202 struct timer_list oom_timer
; /* Out of memory timer. */
205 unsigned int cur_rx
, cur_tx
; /* The next free ring entry */
206 unsigned int dirty_rx
, dirty_tx
; /* The ring entries to be free()ed. */
207 unsigned int csr0
; /* CSR0 setting. */
208 unsigned int csr6
; /* Current CSR6 control settings. */
209 void (*link_change
) (struct net_device
* dev
, int csr5
);
210 struct platform_device
*pdev
;
212 void __iomem
*base_addr
;
213 int pad0
; /* Used for 8-byte alignment */
214 struct net_device
*dev
;
219 irqreturn_t
tulip_interrupt(int irq
, void *dev_instance
);
220 int tulip_refill_rx(struct net_device
*dev
);
221 int tulip_poll(struct napi_struct
*napi
, int budget
);
224 extern int tulip_debug
;
225 void oom_timer(unsigned long data
);
227 static inline void tulip_start_rxtx(struct tulip_private
*tp
)
229 void __iomem
*ioaddr
= tp
->base_addr
;
230 iowrite32(tp
->csr6
| RxTx
, ioaddr
+ CSR6
);
232 (void) ioread32(ioaddr
+ CSR6
); /* mmio sync */
235 static inline void tulip_stop_rxtx(struct tulip_private
*tp
)
237 void __iomem
*ioaddr
= tp
->base_addr
;
238 u32 csr6
= ioread32(ioaddr
+ CSR6
);
242 iowrite32(csr6
& ~RxTx
, ioaddr
+ CSR6
);
244 /* wait until in-flight frame completes.
245 * Max time @ 10BT: 1500*8b/10Mbps == 1200us (+ 100us margin)
246 * Typically expect this loop to end in < 50 us on 100BT.
248 while (--i
&& (ioread32(ioaddr
+ CSR5
) & (CSR5_TS
|CSR5_RS
)))
252 printk(KERN_DEBUG
"fixme: tulip_stop_rxtx() failed"
253 " (CSR5 0x%x CSR6 0x%x)\n",
254 ioread32(ioaddr
+ CSR5
),
255 ioread32(ioaddr
+ CSR6
));
259 static inline void tulip_restart_rxtx(struct tulip_private
*tp
)
263 tulip_start_rxtx(tp
);
266 static inline void tulip_tx_timeout_complete(struct tulip_private
*tp
, void __iomem
*ioaddr
)
268 /* Stop and restart the chip's Tx processes. */
269 tulip_restart_rxtx(tp
);
270 /* Trigger an immediate transmit demand. */
271 iowrite32(0, ioaddr
+ CSR1
);
273 tp
->stats
.tx_errors
++;
276 #endif /* __NET_TULIP_H__ */
This page took 0.064145 seconds and 5 git commands to generate.