Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
net-3-driver for the 3c523 Etherlink/MC card (i82586 Ethernet chip)
This is an extension to the Linux operating system, and is covered by the
same GNU General Public License that covers that work.
Copyright 1995, 1996 by Chris Beauregard (cpbeaure@undergrad.math.uwaterloo.ca)
This is basically Michael Hipp's ni52 driver, with a new probing
algorithm and some minor changes to the 82586 CA and reset routines.
Thanks a lot Michael for a really clean i82586 implementation! Unless
otherwise documented in ni52.c, any bugs are mine.
Contrary to the Ethernet-HOWTO, this isn't based on the 3c507 driver in
any way. The ni52 is a lot easier to modify.
sources:
ni52.c
Crynwr packet driver collection was a great reference for my first
attempt at this sucker. The 3c507 driver also helped, until I noticed
that ni52.c was a lot nicer.
EtherLink/MC: Micro Channel Ethernet Adapter Technical Reference
Manual, courtesy of 3Com CardFacts, documents the 3c523-specific
stuff. Information on CardFacts is found in the Ethernet HOWTO.
Also see <a href="http://www.3com.com/">
Microprocessor Communications Support Chips, T.J. Byers, ISBN
0-444-01224-9, has a section on the i82586. It tells you just enough
to know that you really don't want to learn how to program the chip.
The original device probe code was stolen from ps2esdi.c
Known Problems:
Since most of the code was stolen from ni52.c, you'll run across the
same bugs in the 0.62 version of ni52.c, plus maybe a few because of
the 3c523 idiosynchacies. The 3c523 has 16K of RAM though, so there
shouldn't be the overrun problem that the 8K ni52 has.
This driver is for a 16K adapter. It should work fine on the 64K
adapters, but it will only use one of the 4 banks of RAM. Modifying
this for the 64K version would require a lot of heinous bank
switching, which I'm sure not interested in doing. If you try to
implement a bank switching version, you'll basically have to remember
what bank is enabled and do a switch every time you access a memory
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
location that's not current. You'll also have to remap pointers on
the driver side, because it only knows about 16K of the memory.
Anyone desperate or masochistic enough to try?
It seems to be stable now when multiple transmit buffers are used. I
can't see any performance difference, but then I'm working on a 386SX.
Multicast doesn't work. It doesn't even pretend to work. Don't use
it. Don't compile your kernel with multicast support. I don't know
why.
Features:
This driver is useable as a loadable module. If you try to specify an
IRQ or a IO address (via insmod 3c523.o irq=xx io=0xyyy), it will
search the MCA slots until it finds a 3c523 with the specified
parameters.
This driver does support multiple ethernet cards when used as a module
(up to MAX_3C523_CARDS, the default being 4)
This has been tested with both BNC and TP versions, internal and
external transceivers. Haven't tested with the 64K version (that I
know of).
History:
Jan 1st, 1996
first public release
Feb 4th, 1996
update to 1.3.59, incorporated multicast diffs from ni52.c
Feb 15th, 1996
added shared irq support
Apr 1999
added support for multiple cards when used as a module
added option to disable multicast as is causes problems
Ganesh Sittampalam <ganesh.sittampalam@magdalen.oxford.ac.uk>
Stuart Adamson <stuart.adamson@compsoc.net>
Nov 2001
added support for ethtool (jgarzik)
$Header: /fsys2/home/chrisb/linux-1.3.59-MCA/drivers/net/RCS/3c523.c,v 1.1 1996/02/05 01:53:46 chrisb Exp chrisb $
*/
#define DRV_NAME "3c523"
#define DRV_VERSION "17-Nov-2001"
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/skbuff.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/mca-legacy.h>
#include <linux/ethtool.h>
#include <linux/bitops.h>
#include <linux/jiffies.h>
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <asm/uaccess.h>
#include <asm/processor.h>
#include <asm/io.h>
#include "3c523.h"
/*************************************************************************/
#define DEBUG /* debug on */
#define SYSBUSVAL 0 /* 1 = 8 Bit, 0 = 16 bit - 3c523 only does 16 bit */
#undef ELMC_MULTICAST /* Disable multicast support as it is somewhat seriously broken at the moment */
#define make32(ptr16) (p->memtop + (short) (ptr16) )
#define make24(ptr32) ((char *) (ptr32) - p->base)
#define make16(ptr32) ((unsigned short) ((unsigned long) (ptr32) - (unsigned long) p->memtop ))
/*************************************************************************/
/*
Tables to which we can map values in the configuration registers.
*/
static int irq_table[] __initdata = {
12, 7, 3, 9
};
static int csr_table[] __initdata = {
0x300, 0x1300, 0x2300, 0x3300
};
static int shm_table[] __initdata = {
0x0c0000, 0x0c8000, 0x0d0000, 0x0d8000
};
/******************* how to calculate the buffers *****************************
* IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works
* --------------- in a different (more stable?) mode. Only in this mode it's
* possible to configure the driver with 'NO_NOPCOMMANDS'
sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8;
sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT
sizeof(rfd) = 24; sizeof(rbd) = 12;
sizeof(tbd) = 8; sizeof(transmit_cmd) = 16;
sizeof(nop_cmd) = 8;
* if you don't know the driver, better do not change this values: */
#define RECV_BUFF_SIZE 1524 /* slightly oversized */
#define XMIT_BUFF_SIZE 1524 /* slightly oversized */
#define NUM_XMIT_BUFFS 1 /* config for both, 8K and 16K shmem */
#define NUM_RECV_BUFFS_8 4 /* config for 8K shared mem */
#define NUM_RECV_BUFFS_16 9 /* config for 16K shared mem */
#if (NUM_XMIT_BUFFS == 1)
#define NO_NOPCOMMANDS /* only possible with NUM_XMIT_BUFFS=1 */
#endif
/**************************************************************************/
#define DELAY(x) { mdelay(32 * x); }
/* a much shorter delay: */
#define DELAY_16(); { udelay(16) ; }
/* wait for command with timeout: */
#define WAIT_4_SCB_CMD() { int i; \
for(i=0;i<1024;i++) { \
if(!p->scb->cmd) break; \
DELAY_16(); \
if(i == 1023) { \
pr_warning("%s:%d: scb_cmd timed out .. resetting i82586\n",\
dev->name,__LINE__); \
elmc_id_reset586(); } } }
static irqreturn_t elmc_interrupt(int irq, void *dev_id);
static int elmc_open(struct net_device *dev);
static int elmc_close(struct net_device *dev);
static netdev_tx_t elmc_send_packet(struct sk_buff *, struct net_device *);
static struct net_device_stats *elmc_get_stats(struct net_device *dev);
static void elmc_timeout(struct net_device *dev);
#ifdef ELMC_MULTICAST
static void set_multicast_list(struct net_device *dev);
#endif
static const struct ethtool_ops netdev_ethtool_ops;
/* helper-functions */
static int init586(struct net_device *dev);
static int check586(struct net_device *dev, unsigned long where, unsigned size);
static void alloc586(struct net_device *dev);
static void startrecv586(struct net_device *dev);
static void *alloc_rfa(struct net_device *dev, void *ptr);
static void elmc_rcv_int(struct net_device *dev);
static void elmc_xmt_int(struct net_device *dev);
Loading
Loading full blame...