2 * Copyright (c) 2010 Andrei Faur <da3drus@gmail.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 FILE_LICENCE ( GPL2_OR_LATER
);
25 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
28 * Set the number of Tx and Rx buffers, using Log_2(# buffers).
29 * Set default values to 16 Tx buffers and 32 Rx buffers.
31 #define PCNET32_LOG_TX_BUFFERS 4
32 #define PCNET32_LOG_RX_BUFFERS 5
34 /* Maximum number of descriptor rings is 512 */
35 #define PCNET32_LOG_MAX_TX_BUFFERS 9
36 #define PCNET32_LOG_MAX_RX_BUFFERS 9
38 #define TX_RING_SIZE ( 1 << ( PCNET32_LOG_TX_BUFFERS ) )
39 #define TX_MAX_RING_SIZE ( 1 << ( PCNET32_LOG_MAX_TX_BUFFERS ) )
41 #define RX_RING_SIZE ( 1 << ( PCNET32_LOG_RX_BUFFERS ) )
42 #define RX_MAX_RING_SIZE ( 1 << ( PCNET32_LOG_MAX_RX_BUFFERS ) )
44 #define RX_RING_BYTES ( RX_RING_SIZE * sizeof(struct pcnet32_rx_desc ) )
45 #define TX_RING_BYTES ( TX_RING_SIZE * sizeof(struct pcnet32_tx_desc ) )
47 #define PKT_BUF_SIZE 1536
49 #define RX_RING_ALIGN 16
50 #define TX_RING_ALIGN 16
52 #define INIT_BLOCK_ALIGN 32
54 #define PCNET32_WIO_RDP 0x10
55 #define PCNET32_WIO_RAP 0x12
56 #define PCNET32_WIO_RESET 0x14
57 #define PCNET32_WIO_BDP 0x16
59 #define PCNET32_DWIO_RDP 0x10
60 #define PCNET32_DWIO_RAP 0x14
61 #define PCNET32_DWIO_RESET 0x18
62 #define PCNET32_DWIO_BDP 0x1C
64 #define PCNET32_PORT_AUI 0x00
65 #define PCNET32_PORT_10BT 0x01
66 #define PCNET32_PORT_GPSI 0x02
67 #define PCNET32_PORT_MII 0x03
69 #define PCNET32_PORT_PORTSEL 0x03
70 #define PCNET32_PORT_ASEL 0x04
71 #define PCNET32_PORT_100 0x40
72 #define PCNET32_PORT_FD 0x80
74 #define PCNET32_SWSTYLE_LANCE 0x00
75 #define PCNET32_SWSTYLE_ILACC 0x01
76 #define PCNET32_SWSTYLE_PCNET32 0x02
78 #define PCNET32_MAX_PHYS 32
80 #ifndef PCI_VENDOR_ID_AT
81 #define PCI_VENDOR_ID_AT 0x1259
84 #ifndef PCI_SUBDEVICE_ID_AT_2700FX
85 #define PCI_SUBDEVICE_ID_AT_2700FX 0x2701
88 #ifndef PCI_SUBDEVICE_ID_AT_2701FX
89 #define PCI_SUBDEVICE_ID_AT_2701FX 0x2703
92 struct pcnet32_rx_desc
{
100 struct pcnet32_tx_desc
{
108 struct pcnet32_init_block
{
118 struct pcnet32_access
{
119 u16 ( *read_csr
) ( unsigned long, int );
120 void ( *write_csr
) ( unsigned long, int, u16
);
121 u16 ( *read_bcr
) ( unsigned long, int );
122 void ( *write_bcr
) ( unsigned long, int, u16
);
123 u16 ( *read_rap
) ( unsigned long );
124 void ( *write_rap
) ( unsigned long, u16
);
125 void ( *reset
) ( unsigned long );
128 struct pcnet32_private
{
129 struct pcnet32_init_block init_block
__attribute__((aligned(32)));
130 struct pci_device
*pci_dev
;
131 struct net_device
*netdev
;
133 struct io_buffer
*rx_iobuf
[RX_RING_SIZE
];
134 struct io_buffer
*tx_iobuf
[TX_RING_SIZE
];
136 struct pcnet32_rx_desc
*rx_base
;
137 struct pcnet32_tx_desc
*tx_base
;
141 uint32_t tx_fill_ctr
;
143 struct pcnet32_access
*a
;
148 unsigned short chip_version
;
153 enum pcnet32_desc_status_bit
{
155 StartOfPacket
= (1 << 9),
156 EndOfPacket
= (1 << 8)
159 enum pcnet32_register_content
{
160 /* CSR0 bits - Controller status register */
165 IntEnable
= (1 << 6),
171 /* CSR3 bits - Controller status register */
172 BablMask
= (1 << 14),
173 MissFrameMask
= (1 << 12),
174 MemErrMask
= (1 << 11),
175 RxIntMask
= (1 << 10),
176 TxIntMask
= (1 << 9),
177 InitDoneMask
= (1 << 8)
181 #endif /* _PCNET32_H_ */