nmclan_cs.c 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707
  1. /* ----------------------------------------------------------------------------
  2. Linux PCMCIA ethernet adapter driver for the New Media Ethernet LAN.
  3. nmclan_cs.c,v 0.16 1995/07/01 06:42:17 rpao Exp rpao
  4. The Ethernet LAN uses the Advanced Micro Devices (AMD) Am79C940 Media
  5. Access Controller for Ethernet (MACE). It is essentially the Am2150
  6. PCMCIA Ethernet card contained in the Am2150 Demo Kit.
  7. Written by Roger C. Pao <rpao@paonet.org>
  8. Copyright 1995 Roger C. Pao
  9. Linux 2.5 cleanups Copyright Red Hat 2003
  10. This software may be used and distributed according to the terms of
  11. the GNU General Public License.
  12. Ported to Linux 1.3.* network driver environment by
  13. Matti Aarnio <mea@utu.fi>
  14. References
  15. Am2150 Technical Reference Manual, Revision 1.0, August 17, 1993
  16. Am79C940 (MACE) Data Sheet, 1994
  17. Am79C90 (C-LANCE) Data Sheet, 1994
  18. Linux PCMCIA Programmer's Guide v1.17
  19. /usr/src/linux/net/inet/dev.c, Linux kernel 1.2.8
  20. Eric Mears, New Media Corporation
  21. Tom Pollard, New Media Corporation
  22. Dean Siasoyco, New Media Corporation
  23. Ken Lesniak, Silicon Graphics, Inc. <lesniak@boston.sgi.com>
  24. Donald Becker <becker@scyld.com>
  25. David Hinds <dahinds@users.sourceforge.net>
  26. The Linux client driver is based on the 3c589_cs.c client driver by
  27. David Hinds.
  28. The Linux network driver outline is based on the 3c589_cs.c driver,
  29. the 8390.c driver, and the example skeleton.c kernel code, which are
  30. by Donald Becker.
  31. The Am2150 network driver hardware interface code is based on the
  32. OS/9000 driver for the New Media Ethernet LAN by Eric Mears.
  33. Special thanks for testing and help in debugging this driver goes
  34. to Ken Lesniak.
  35. -------------------------------------------------------------------------------
  36. Driver Notes and Issues
  37. -------------------------------------------------------------------------------
  38. 1. Developed on a Dell 320SLi
  39. PCMCIA Card Services 2.6.2
  40. Linux dell 1.2.10 #1 Thu Jun 29 20:23:41 PDT 1995 i386
  41. 2. rc.pcmcia may require loading pcmcia_core with io_speed=300:
  42. 'insmod pcmcia_core.o io_speed=300'.
  43. This will avoid problems with fast systems which causes rx_framecnt
  44. to return random values.
  45. 3. If hot extraction does not work for you, use 'ifconfig eth0 down'
  46. before extraction.
  47. 4. There is a bad slow-down problem in this driver.
  48. 5. Future: Multicast processing. In the meantime, do _not_ compile your
  49. kernel with multicast ip enabled.
  50. -------------------------------------------------------------------------------
  51. History
  52. -------------------------------------------------------------------------------
  53. Log: nmclan_cs.c,v
  54. * 2.5.75-ac1 2003/07/11 Alan Cox <alan@redhat.com>
  55. * Fixed hang on card eject as we probe it
  56. * Cleaned up to use new style locking.
  57. *
  58. * Revision 0.16 1995/07/01 06:42:17 rpao
  59. * Bug fix: nmclan_reset() called CardServices incorrectly.
  60. *
  61. * Revision 0.15 1995/05/24 08:09:47 rpao
  62. * Re-implement MULTI_TX dev->tbusy handling.
  63. *
  64. * Revision 0.14 1995/05/23 03:19:30 rpao
  65. * Added, in nmclan_config(), "tuple.Attributes = 0;".
  66. * Modified MACE ID check to ignore chip revision level.
  67. * Avoid tx_free_frames race condition between _start_xmit and _interrupt.
  68. *
  69. * Revision 0.13 1995/05/18 05:56:34 rpao
  70. * Statistics changes.
  71. * Bug fix: nmclan_reset did not enable TX and RX: call restore_multicast_list.
  72. * Bug fix: mace_interrupt checks ~MACE_IMR_DEFAULT. Fixes driver lockup.
  73. *
  74. * Revision 0.12 1995/05/14 00:12:23 rpao
  75. * Statistics overhaul.
  76. *
  77. 95/05/13 rpao V0.10a
  78. Bug fix: MACE statistics counters used wrong I/O ports.
  79. Bug fix: mace_interrupt() needed to allow statistics to be
  80. processed without RX or TX interrupts pending.
  81. 95/05/11 rpao V0.10
  82. Multiple transmit request processing.
  83. Modified statistics to use MACE counters where possible.
  84. 95/05/10 rpao V0.09 Bug fix: Must use IO_DATA_PATH_WIDTH_AUTO.
  85. *Released
  86. 95/05/10 rpao V0.08
  87. Bug fix: Make all non-exported functions private by using
  88. static keyword.
  89. Bug fix: Test IntrCnt _before_ reading MACE_IR.
  90. 95/05/10 rpao V0.07 Statistics.
  91. 95/05/09 rpao V0.06 Fix rx_framecnt problem by addition of PCIC wait states.
  92. ---------------------------------------------------------------------------- */
  93. #define DRV_NAME "nmclan_cs"
  94. #define DRV_VERSION "0.16"
  95. /* ----------------------------------------------------------------------------
  96. Conditional Compilation Options
  97. ---------------------------------------------------------------------------- */
  98. #define MULTI_TX 0
  99. #define RESET_ON_TIMEOUT 1
  100. #define TX_INTERRUPTABLE 1
  101. #define RESET_XILINX 0
  102. /* ----------------------------------------------------------------------------
  103. Include Files
  104. ---------------------------------------------------------------------------- */
  105. #include <linux/module.h>
  106. #include <linux/kernel.h>
  107. #include <linux/init.h>
  108. #include <linux/ptrace.h>
  109. #include <linux/slab.h>
  110. #include <linux/string.h>
  111. #include <linux/timer.h>
  112. #include <linux/interrupt.h>
  113. #include <linux/in.h>
  114. #include <linux/delay.h>
  115. #include <linux/ethtool.h>
  116. #include <linux/netdevice.h>
  117. #include <linux/etherdevice.h>
  118. #include <linux/skbuff.h>
  119. #include <linux/if_arp.h>
  120. #include <linux/ioport.h>
  121. #include <linux/bitops.h>
  122. #include <pcmcia/version.h>
  123. #include <pcmcia/cs_types.h>
  124. #include <pcmcia/cs.h>
  125. #include <pcmcia/cisreg.h>
  126. #include <pcmcia/cistpl.h>
  127. #include <pcmcia/ds.h>
  128. #include <asm/uaccess.h>
  129. #include <asm/io.h>
  130. #include <asm/system.h>
  131. /* ----------------------------------------------------------------------------
  132. Defines
  133. ---------------------------------------------------------------------------- */
  134. #define ETHER_ADDR_LEN ETH_ALEN
  135. /* 6 bytes in an Ethernet Address */
  136. #define MACE_LADRF_LEN 8
  137. /* 8 bytes in Logical Address Filter */
  138. /* Loop Control Defines */
  139. #define MACE_MAX_IR_ITERATIONS 10
  140. #define MACE_MAX_RX_ITERATIONS 12
  141. /*
  142. TBD: Dean brought this up, and I assumed the hardware would
  143. handle it:
  144. If MACE_MAX_RX_ITERATIONS is > 1, rx_framecnt may still be
  145. non-zero when the isr exits. We may not get another interrupt
  146. to process the remaining packets for some time.
  147. */
  148. /*
  149. The Am2150 has a Xilinx XC3042 field programmable gate array (FPGA)
  150. which manages the interface between the MACE and the PCMCIA bus. It
  151. also includes buffer management for the 32K x 8 SRAM to control up to
  152. four transmit and 12 receive frames at a time.
  153. */
  154. #define AM2150_MAX_TX_FRAMES 4
  155. #define AM2150_MAX_RX_FRAMES 12
  156. /* Am2150 Ethernet Card I/O Mapping */
  157. #define AM2150_RCV 0x00
  158. #define AM2150_XMT 0x04
  159. #define AM2150_XMT_SKIP 0x09
  160. #define AM2150_RCV_NEXT 0x0A
  161. #define AM2150_RCV_FRAME_COUNT 0x0B
  162. #define AM2150_MACE_BANK 0x0C
  163. #define AM2150_MACE_BASE 0x10
  164. /* MACE Registers */
  165. #define MACE_RCVFIFO 0
  166. #define MACE_XMTFIFO 1
  167. #define MACE_XMTFC 2
  168. #define MACE_XMTFS 3
  169. #define MACE_XMTRC 4
  170. #define MACE_RCVFC 5
  171. #define MACE_RCVFS 6
  172. #define MACE_FIFOFC 7
  173. #define MACE_IR 8
  174. #define MACE_IMR 9
  175. #define MACE_PR 10
  176. #define MACE_BIUCC 11
  177. #define MACE_FIFOCC 12
  178. #define MACE_MACCC 13
  179. #define MACE_PLSCC 14
  180. #define MACE_PHYCC 15
  181. #define MACE_CHIPIDL 16
  182. #define MACE_CHIPIDH 17
  183. #define MACE_IAC 18
  184. /* Reserved */
  185. #define MACE_LADRF 20
  186. #define MACE_PADR 21
  187. /* Reserved */
  188. /* Reserved */
  189. #define MACE_MPC 24
  190. /* Reserved */
  191. #define MACE_RNTPC 26
  192. #define MACE_RCVCC 27
  193. /* Reserved */
  194. #define MACE_UTR 29
  195. #define MACE_RTR1 30
  196. #define MACE_RTR2 31
  197. /* MACE Bit Masks */
  198. #define MACE_XMTRC_EXDEF 0x80
  199. #define MACE_XMTRC_XMTRC 0x0F
  200. #define MACE_XMTFS_XMTSV 0x80
  201. #define MACE_XMTFS_UFLO 0x40
  202. #define MACE_XMTFS_LCOL 0x20
  203. #define MACE_XMTFS_MORE 0x10
  204. #define MACE_XMTFS_ONE 0x08
  205. #define MACE_XMTFS_DEFER 0x04
  206. #define MACE_XMTFS_LCAR 0x02
  207. #define MACE_XMTFS_RTRY 0x01
  208. #define MACE_RCVFS_RCVSTS 0xF000
  209. #define MACE_RCVFS_OFLO 0x8000
  210. #define MACE_RCVFS_CLSN 0x4000
  211. #define MACE_RCVFS_FRAM 0x2000
  212. #define MACE_RCVFS_FCS 0x1000
  213. #define MACE_FIFOFC_RCVFC 0xF0
  214. #define MACE_FIFOFC_XMTFC 0x0F
  215. #define MACE_IR_JAB 0x80
  216. #define MACE_IR_BABL 0x40
  217. #define MACE_IR_CERR 0x20
  218. #define MACE_IR_RCVCCO 0x10
  219. #define MACE_IR_RNTPCO 0x08
  220. #define MACE_IR_MPCO 0x04
  221. #define MACE_IR_RCVINT 0x02
  222. #define MACE_IR_XMTINT 0x01
  223. #define MACE_MACCC_PROM 0x80
  224. #define MACE_MACCC_DXMT2PD 0x40
  225. #define MACE_MACCC_EMBA 0x20
  226. #define MACE_MACCC_RESERVED 0x10
  227. #define MACE_MACCC_DRCVPA 0x08
  228. #define MACE_MACCC_DRCVBC 0x04
  229. #define MACE_MACCC_ENXMT 0x02
  230. #define MACE_MACCC_ENRCV 0x01
  231. #define MACE_PHYCC_LNKFL 0x80
  232. #define MACE_PHYCC_DLNKTST 0x40
  233. #define MACE_PHYCC_REVPOL 0x20
  234. #define MACE_PHYCC_DAPC 0x10
  235. #define MACE_PHYCC_LRT 0x08
  236. #define MACE_PHYCC_ASEL 0x04
  237. #define MACE_PHYCC_RWAKE 0x02
  238. #define MACE_PHYCC_AWAKE 0x01
  239. #define MACE_IAC_ADDRCHG 0x80
  240. #define MACE_IAC_PHYADDR 0x04
  241. #define MACE_IAC_LOGADDR 0x02
  242. #define MACE_UTR_RTRE 0x80
  243. #define MACE_UTR_RTRD 0x40
  244. #define MACE_UTR_RPA 0x20
  245. #define MACE_UTR_FCOLL 0x10
  246. #define MACE_UTR_RCVFCSE 0x08
  247. #define MACE_UTR_LOOP_INCL_MENDEC 0x06
  248. #define MACE_UTR_LOOP_NO_MENDEC 0x04
  249. #define MACE_UTR_LOOP_EXTERNAL 0x02
  250. #define MACE_UTR_LOOP_NONE 0x00
  251. #define MACE_UTR_RESERVED 0x01
  252. /* Switch MACE register bank (only 0 and 1 are valid) */
  253. #define MACEBANK(win_num) outb((win_num), ioaddr + AM2150_MACE_BANK)
  254. #define MACE_IMR_DEFAULT \
  255. (0xFF - \
  256. ( \
  257. MACE_IR_CERR | \
  258. MACE_IR_RCVCCO | \
  259. MACE_IR_RNTPCO | \
  260. MACE_IR_MPCO | \
  261. MACE_IR_RCVINT | \
  262. MACE_IR_XMTINT \
  263. ) \
  264. )
  265. #undef MACE_IMR_DEFAULT
  266. #define MACE_IMR_DEFAULT 0x00 /* New statistics handling: grab everything */
  267. #define TX_TIMEOUT ((400*HZ)/1000)
  268. /* ----------------------------------------------------------------------------
  269. Type Definitions
  270. ---------------------------------------------------------------------------- */
  271. typedef struct _mace_statistics {
  272. /* MACE_XMTFS */
  273. int xmtsv;
  274. int uflo;
  275. int lcol;
  276. int more;
  277. int one;
  278. int defer;
  279. int lcar;
  280. int rtry;
  281. /* MACE_XMTRC */
  282. int exdef;
  283. int xmtrc;
  284. /* RFS1--Receive Status (RCVSTS) */
  285. int oflo;
  286. int clsn;
  287. int fram;
  288. int fcs;
  289. /* RFS2--Runt Packet Count (RNTPC) */
  290. int rfs_rntpc;
  291. /* RFS3--Receive Collision Count (RCVCC) */
  292. int rfs_rcvcc;
  293. /* MACE_IR */
  294. int jab;
  295. int babl;
  296. int cerr;
  297. int rcvcco;
  298. int rntpco;
  299. int mpco;
  300. /* MACE_MPC */
  301. int mpc;
  302. /* MACE_RNTPC */
  303. int rntpc;
  304. /* MACE_RCVCC */
  305. int rcvcc;
  306. } mace_statistics;
  307. typedef struct _mace_private {
  308. dev_link_t link;
  309. dev_node_t node;
  310. struct net_device_stats linux_stats; /* Linux statistics counters */
  311. mace_statistics mace_stats; /* MACE chip statistics counters */
  312. /* restore_multicast_list() state variables */
  313. int multicast_ladrf[MACE_LADRF_LEN]; /* Logical address filter */
  314. int multicast_num_addrs;
  315. char tx_free_frames; /* Number of free transmit frame buffers */
  316. char tx_irq_disabled; /* MACE TX interrupt disabled */
  317. spinlock_t bank_lock; /* Must be held if you step off bank 0 */
  318. } mace_private;
  319. /* ----------------------------------------------------------------------------
  320. Private Global Variables
  321. ---------------------------------------------------------------------------- */
  322. #ifdef PCMCIA_DEBUG
  323. static char rcsid[] =
  324. "nmclan_cs.c,v 0.16 1995/07/01 06:42:17 rpao Exp rpao";
  325. static char *version =
  326. DRV_NAME " " DRV_VERSION " (Roger C. Pao)";
  327. #endif
  328. static dev_info_t dev_info="nmclan_cs";
  329. static dev_link_t *dev_list;
  330. static char *if_names[]={
  331. "Auto", "10baseT", "BNC",
  332. };
  333. /* ----------------------------------------------------------------------------
  334. Parameters
  335. These are the parameters that can be set during loading with
  336. 'insmod'.
  337. ---------------------------------------------------------------------------- */
  338. MODULE_DESCRIPTION("New Media PCMCIA ethernet driver");
  339. MODULE_LICENSE("GPL");
  340. #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0)
  341. /* 0=auto, 1=10baseT, 2 = 10base2, default=auto */
  342. INT_MODULE_PARM(if_port, 0);
  343. #ifdef PCMCIA_DEBUG
  344. INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
  345. #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
  346. #else
  347. #define DEBUG(n, args...)
  348. #endif
  349. /* ----------------------------------------------------------------------------
  350. Function Prototypes
  351. ---------------------------------------------------------------------------- */
  352. static void nmclan_config(dev_link_t *link);
  353. static void nmclan_release(dev_link_t *link);
  354. static int nmclan_event(event_t event, int priority,
  355. event_callback_args_t *args);
  356. static void nmclan_reset(struct net_device *dev);
  357. static int mace_config(struct net_device *dev, struct ifmap *map);
  358. static int mace_open(struct net_device *dev);
  359. static int mace_close(struct net_device *dev);
  360. static int mace_start_xmit(struct sk_buff *skb, struct net_device *dev);
  361. static void mace_tx_timeout(struct net_device *dev);
  362. static irqreturn_t mace_interrupt(int irq, void *dev_id, struct pt_regs *regs);
  363. static struct net_device_stats *mace_get_stats(struct net_device *dev);
  364. static int mace_rx(struct net_device *dev, unsigned char RxCnt);
  365. static void restore_multicast_list(struct net_device *dev);
  366. static void set_multicast_list(struct net_device *dev);
  367. static struct ethtool_ops netdev_ethtool_ops;
  368. static dev_link_t *nmclan_attach(void);
  369. static void nmclan_detach(dev_link_t *);
  370. /* ----------------------------------------------------------------------------
  371. nmclan_attach
  372. Creates an "instance" of the driver, allocating local data
  373. structures for one device. The device is registered with Card
  374. Services.
  375. ---------------------------------------------------------------------------- */
  376. static dev_link_t *nmclan_attach(void)
  377. {
  378. mace_private *lp;
  379. dev_link_t *link;
  380. struct net_device *dev;
  381. client_reg_t client_reg;
  382. int ret;
  383. DEBUG(0, "nmclan_attach()\n");
  384. DEBUG(1, "%s\n", rcsid);
  385. /* Create new ethernet device */
  386. dev = alloc_etherdev(sizeof(mace_private));
  387. if (!dev)
  388. return NULL;
  389. lp = netdev_priv(dev);
  390. link = &lp->link;
  391. link->priv = dev;
  392. spin_lock_init(&lp->bank_lock);
  393. link->io.NumPorts1 = 32;
  394. link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
  395. link->io.IOAddrLines = 5;
  396. link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
  397. link->irq.IRQInfo1 = IRQ_LEVEL_ID;
  398. link->irq.Handler = &mace_interrupt;
  399. link->irq.Instance = dev;
  400. link->conf.Attributes = CONF_ENABLE_IRQ;
  401. link->conf.Vcc = 50;
  402. link->conf.IntType = INT_MEMORY_AND_IO;
  403. link->conf.ConfigIndex = 1;
  404. link->conf.Present = PRESENT_OPTION;
  405. lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
  406. SET_MODULE_OWNER(dev);
  407. dev->hard_start_xmit = &mace_start_xmit;
  408. dev->set_config = &mace_config;
  409. dev->get_stats = &mace_get_stats;
  410. dev->set_multicast_list = &set_multicast_list;
  411. SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
  412. dev->open = &mace_open;
  413. dev->stop = &mace_close;
  414. #ifdef HAVE_TX_TIMEOUT
  415. dev->tx_timeout = mace_tx_timeout;
  416. dev->watchdog_timeo = TX_TIMEOUT;
  417. #endif
  418. /* Register with Card Services */
  419. link->next = dev_list;
  420. dev_list = link;
  421. client_reg.dev_info = &dev_info;
  422. client_reg.EventMask =
  423. CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
  424. CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
  425. CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
  426. client_reg.event_handler = &nmclan_event;
  427. client_reg.Version = 0x0210;
  428. client_reg.event_callback_args.client_data = link;
  429. ret = pcmcia_register_client(&link->handle, &client_reg);
  430. if (ret != 0) {
  431. cs_error(link->handle, RegisterClient, ret);
  432. nmclan_detach(link);
  433. return NULL;
  434. }
  435. return link;
  436. } /* nmclan_attach */
  437. /* ----------------------------------------------------------------------------
  438. nmclan_detach
  439. This deletes a driver "instance". The device is de-registered
  440. with Card Services. If it has been released, all local data
  441. structures are freed. Otherwise, the structures will be freed
  442. when the device is released.
  443. ---------------------------------------------------------------------------- */
  444. static void nmclan_detach(dev_link_t *link)
  445. {
  446. struct net_device *dev = link->priv;
  447. dev_link_t **linkp;
  448. DEBUG(0, "nmclan_detach(0x%p)\n", link);
  449. /* Locate device structure */
  450. for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
  451. if (*linkp == link) break;
  452. if (*linkp == NULL)
  453. return;
  454. if (link->dev)
  455. unregister_netdev(dev);
  456. if (link->state & DEV_CONFIG)
  457. nmclan_release(link);
  458. if (link->handle)
  459. pcmcia_deregister_client(link->handle);
  460. /* Unlink device structure, free bits */
  461. *linkp = link->next;
  462. free_netdev(dev);
  463. } /* nmclan_detach */
  464. /* ----------------------------------------------------------------------------
  465. mace_read
  466. Reads a MACE register. This is bank independent; however, the
  467. caller must ensure that this call is not interruptable. We are
  468. assuming that during normal operation, the MACE is always in
  469. bank 0.
  470. ---------------------------------------------------------------------------- */
  471. static int mace_read(mace_private *lp, kio_addr_t ioaddr, int reg)
  472. {
  473. int data = 0xFF;
  474. unsigned long flags;
  475. switch (reg >> 4) {
  476. case 0: /* register 0-15 */
  477. data = inb(ioaddr + AM2150_MACE_BASE + reg);
  478. break;
  479. case 1: /* register 16-31 */
  480. spin_lock_irqsave(&lp->bank_lock, flags);
  481. MACEBANK(1);
  482. data = inb(ioaddr + AM2150_MACE_BASE + (reg & 0x0F));
  483. MACEBANK(0);
  484. spin_unlock_irqrestore(&lp->bank_lock, flags);
  485. break;
  486. }
  487. return (data & 0xFF);
  488. } /* mace_read */
  489. /* ----------------------------------------------------------------------------
  490. mace_write
  491. Writes to a MACE register. This is bank independent; however,
  492. the caller must ensure that this call is not interruptable. We
  493. are assuming that during normal operation, the MACE is always in
  494. bank 0.
  495. ---------------------------------------------------------------------------- */
  496. static void mace_write(mace_private *lp, kio_addr_t ioaddr, int reg, int data)
  497. {
  498. unsigned long flags;
  499. switch (reg >> 4) {
  500. case 0: /* register 0-15 */
  501. outb(data & 0xFF, ioaddr + AM2150_MACE_BASE + reg);
  502. break;
  503. case 1: /* register 16-31 */
  504. spin_lock_irqsave(&lp->bank_lock, flags);
  505. MACEBANK(1);
  506. outb(data & 0xFF, ioaddr + AM2150_MACE_BASE + (reg & 0x0F));
  507. MACEBANK(0);
  508. spin_unlock_irqrestore(&lp->bank_lock, flags);
  509. break;
  510. }
  511. } /* mace_write */
  512. /* ----------------------------------------------------------------------------
  513. mace_init
  514. Resets the MACE chip.
  515. ---------------------------------------------------------------------------- */
  516. static int mace_init(mace_private *lp, kio_addr_t ioaddr, char *enet_addr)
  517. {
  518. int i;
  519. int ct = 0;
  520. /* MACE Software reset */
  521. mace_write(lp, ioaddr, MACE_BIUCC, 1);
  522. while (mace_read(lp, ioaddr, MACE_BIUCC) & 0x01) {
  523. /* Wait for reset bit to be cleared automatically after <= 200ns */;
  524. if(++ct > 500)
  525. {
  526. printk(KERN_ERR "mace: reset failed, card removed ?\n");
  527. return -1;
  528. }
  529. udelay(1);
  530. }
  531. mace_write(lp, ioaddr, MACE_BIUCC, 0);
  532. /* The Am2150 requires that the MACE FIFOs operate in burst mode. */
  533. mace_write(lp, ioaddr, MACE_FIFOCC, 0x0F);
  534. mace_write(lp,ioaddr, MACE_RCVFC, 0); /* Disable Auto Strip Receive */
  535. mace_write(lp, ioaddr, MACE_IMR, 0xFF); /* Disable all interrupts until _open */
  536. /*
  537. * Bit 2-1 PORTSEL[1-0] Port Select.
  538. * 00 AUI/10Base-2
  539. * 01 10Base-T
  540. * 10 DAI Port (reserved in Am2150)
  541. * 11 GPSI
  542. * For this card, only the first two are valid.
  543. * So, PLSCC should be set to
  544. * 0x00 for 10Base-2
  545. * 0x02 for 10Base-T
  546. * Or just set ASEL in PHYCC below!
  547. */
  548. switch (if_port) {
  549. case 1:
  550. mace_write(lp, ioaddr, MACE_PLSCC, 0x02);
  551. break;
  552. case 2:
  553. mace_write(lp, ioaddr, MACE_PLSCC, 0x00);
  554. break;
  555. default:
  556. mace_write(lp, ioaddr, MACE_PHYCC, /* ASEL */ 4);
  557. /* ASEL Auto Select. When set, the PORTSEL[1-0] bits are overridden,
  558. and the MACE device will automatically select the operating media
  559. interface port. */
  560. break;
  561. }
  562. mace_write(lp, ioaddr, MACE_IAC, MACE_IAC_ADDRCHG | MACE_IAC_PHYADDR);
  563. /* Poll ADDRCHG bit */
  564. ct = 0;
  565. while (mace_read(lp, ioaddr, MACE_IAC) & MACE_IAC_ADDRCHG)
  566. {
  567. if(++ ct > 500)
  568. {
  569. printk(KERN_ERR "mace: ADDRCHG timeout, card removed ?\n");
  570. return -1;
  571. }
  572. }
  573. /* Set PADR register */
  574. for (i = 0; i < ETHER_ADDR_LEN; i++)
  575. mace_write(lp, ioaddr, MACE_PADR, enet_addr[i]);
  576. /* MAC Configuration Control Register should be written last */
  577. /* Let set_multicast_list set this. */
  578. /* mace_write(lp, ioaddr, MACE_MACCC, MACE_MACCC_ENXMT | MACE_MACCC_ENRCV); */
  579. mace_write(lp, ioaddr, MACE_MACCC, 0x00);
  580. return 0;
  581. } /* mace_init */
  582. /* ----------------------------------------------------------------------------
  583. nmclan_config
  584. This routine is scheduled to run after a CARD_INSERTION event
  585. is received, to configure the PCMCIA socket, and to make the
  586. ethernet device available to the system.
  587. ---------------------------------------------------------------------------- */
  588. #define CS_CHECK(fn, ret) \
  589. do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
  590. static void nmclan_config(dev_link_t *link)
  591. {
  592. client_handle_t handle = link->handle;
  593. struct net_device *dev = link->priv;
  594. mace_private *lp = netdev_priv(dev);
  595. tuple_t tuple;
  596. cisparse_t parse;
  597. u_char buf[64];
  598. int i, last_ret, last_fn;
  599. kio_addr_t ioaddr;
  600. DEBUG(0, "nmclan_config(0x%p)\n", link);
  601. tuple.Attributes = 0;
  602. tuple.TupleData = buf;
  603. tuple.TupleDataMax = 64;
  604. tuple.TupleOffset = 0;
  605. tuple.DesiredTuple = CISTPL_CONFIG;
  606. CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
  607. CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
  608. CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
  609. link->conf.ConfigBase = parse.config.base;
  610. /* Configure card */
  611. link->state |= DEV_CONFIG;
  612. CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
  613. CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
  614. CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
  615. dev->irq = link->irq.AssignedIRQ;
  616. dev->base_addr = link->io.BasePort1;
  617. ioaddr = dev->base_addr;
  618. /* Read the ethernet address from the CIS. */
  619. tuple.DesiredTuple = 0x80 /* CISTPL_CFTABLE_ENTRY_MISC */;
  620. tuple.TupleData = buf;
  621. tuple.TupleDataMax = 64;
  622. tuple.TupleOffset = 0;
  623. CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
  624. CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
  625. memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN);
  626. /* Verify configuration by reading the MACE ID. */
  627. {
  628. char sig[2];
  629. sig[0] = mace_read(lp, ioaddr, MACE_CHIPIDL);
  630. sig[1] = mace_read(lp, ioaddr, MACE_CHIPIDH);
  631. if ((sig[0] == 0x40) && ((sig[1] & 0x0F) == 0x09)) {
  632. DEBUG(0, "nmclan_cs configured: mace id=%x %x\n",
  633. sig[0], sig[1]);
  634. } else {
  635. printk(KERN_NOTICE "nmclan_cs: mace id not found: %x %x should"
  636. " be 0x40 0x?9\n", sig[0], sig[1]);
  637. link->state &= ~DEV_CONFIG_PENDING;
  638. return;
  639. }
  640. }
  641. if(mace_init(lp, ioaddr, dev->dev_addr) == -1)
  642. goto failed;
  643. /* The if_port symbol can be set when the module is loaded */
  644. if (if_port <= 2)
  645. dev->if_port = if_port;
  646. else
  647. printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n");
  648. link->dev = &lp->node;
  649. link->state &= ~DEV_CONFIG_PENDING;
  650. SET_NETDEV_DEV(dev, &handle_to_dev(handle));
  651. i = register_netdev(dev);
  652. if (i != 0) {
  653. printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n");
  654. link->dev = NULL;
  655. goto failed;
  656. }
  657. strcpy(lp->node.dev_name, dev->name);
  658. printk(KERN_INFO "%s: nmclan: port %#3lx, irq %d, %s port, hw_addr ",
  659. dev->name, dev->base_addr, dev->irq, if_names[dev->if_port]);
  660. for (i = 0; i < 6; i++)
  661. printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n"));
  662. return;
  663. cs_failed:
  664. cs_error(link->handle, last_fn, last_ret);
  665. failed:
  666. nmclan_release(link);
  667. return;
  668. } /* nmclan_config */
  669. /* ----------------------------------------------------------------------------
  670. nmclan_release
  671. After a card is removed, nmclan_release() will unregister the
  672. net device, and release the PCMCIA configuration. If the device
  673. is still open, this will be postponed until it is closed.
  674. ---------------------------------------------------------------------------- */
  675. static void nmclan_release(dev_link_t *link)
  676. {
  677. DEBUG(0, "nmclan_release(0x%p)\n", link);
  678. pcmcia_release_configuration(link->handle);
  679. pcmcia_release_io(link->handle, &link->io);
  680. pcmcia_release_irq(link->handle, &link->irq);
  681. link->state &= ~DEV_CONFIG;
  682. }
  683. /* ----------------------------------------------------------------------------
  684. nmclan_event
  685. The card status event handler. Mostly, this schedules other
  686. stuff to run after an event is received. A CARD_REMOVAL event
  687. also sets some flags to discourage the net drivers from trying
  688. to talk to the card any more.
  689. ---------------------------------------------------------------------------- */
  690. static int nmclan_event(event_t event, int priority,
  691. event_callback_args_t *args)
  692. {
  693. dev_link_t *link = args->client_data;
  694. struct net_device *dev = link->priv;
  695. DEBUG(1, "nmclan_event(0x%06x)\n", event);
  696. switch (event) {
  697. case CS_EVENT_CARD_REMOVAL:
  698. link->state &= ~DEV_PRESENT;
  699. if (link->state & DEV_CONFIG)
  700. netif_device_detach(dev);
  701. break;
  702. case CS_EVENT_CARD_INSERTION:
  703. link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
  704. nmclan_config(link);
  705. break;
  706. case CS_EVENT_PM_SUSPEND:
  707. link->state |= DEV_SUSPEND;
  708. /* Fall through... */
  709. case CS_EVENT_RESET_PHYSICAL:
  710. if (link->state & DEV_CONFIG) {
  711. if (link->open)
  712. netif_device_detach(dev);
  713. pcmcia_release_configuration(link->handle);
  714. }
  715. break;
  716. case CS_EVENT_PM_RESUME:
  717. link->state &= ~DEV_SUSPEND;
  718. /* Fall through... */
  719. case CS_EVENT_CARD_RESET:
  720. if (link->state & DEV_CONFIG) {
  721. pcmcia_request_configuration(link->handle, &link->conf);
  722. if (link->open) {
  723. nmclan_reset(dev);
  724. netif_device_attach(dev);
  725. }
  726. }
  727. break;
  728. case CS_EVENT_RESET_REQUEST:
  729. return 1;
  730. break;
  731. }
  732. return 0;
  733. } /* nmclan_event */
  734. /* ----------------------------------------------------------------------------
  735. nmclan_reset
  736. Reset and restore all of the Xilinx and MACE registers.
  737. ---------------------------------------------------------------------------- */
  738. static void nmclan_reset(struct net_device *dev)
  739. {
  740. mace_private *lp = netdev_priv(dev);
  741. #if RESET_XILINX
  742. dev_link_t *link = &lp->link;
  743. conf_reg_t reg;
  744. u_long OrigCorValue;
  745. /* Save original COR value */
  746. reg.Function = 0;
  747. reg.Action = CS_READ;
  748. reg.Offset = CISREG_COR;
  749. reg.Value = 0;
  750. pcmcia_access_configuration_register(link->handle, &reg);
  751. OrigCorValue = reg.Value;
  752. /* Reset Xilinx */
  753. reg.Action = CS_WRITE;
  754. reg.Offset = CISREG_COR;
  755. DEBUG(1, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n",
  756. OrigCorValue);
  757. reg.Value = COR_SOFT_RESET;
  758. pcmcia_access_configuration_register(link->handle, &reg);
  759. /* Need to wait for 20 ms for PCMCIA to finish reset. */
  760. /* Restore original COR configuration index */
  761. reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK);
  762. pcmcia_access_configuration_register(link->handle, &reg);
  763. /* Xilinx is now completely reset along with the MACE chip. */
  764. lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
  765. #endif /* #if RESET_XILINX */
  766. /* Xilinx is now completely reset along with the MACE chip. */
  767. lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
  768. /* Reinitialize the MACE chip for operation. */
  769. mace_init(lp, dev->base_addr, dev->dev_addr);
  770. mace_write(lp, dev->base_addr, MACE_IMR, MACE_IMR_DEFAULT);
  771. /* Restore the multicast list and enable TX and RX. */
  772. restore_multicast_list(dev);
  773. } /* nmclan_reset */
  774. /* ----------------------------------------------------------------------------
  775. mace_config
  776. [Someone tell me what this is supposed to do? Is if_port a defined
  777. standard? If so, there should be defines to indicate 1=10Base-T,
  778. 2=10Base-2, etc. including limited automatic detection.]
  779. ---------------------------------------------------------------------------- */
  780. static int mace_config(struct net_device *dev, struct ifmap *map)
  781. {
  782. if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
  783. if (map->port <= 2) {
  784. dev->if_port = map->port;
  785. printk(KERN_INFO "%s: switched to %s port\n", dev->name,
  786. if_names[dev->if_port]);
  787. } else
  788. return -EINVAL;
  789. }
  790. return 0;
  791. } /* mace_config */
  792. /* ----------------------------------------------------------------------------
  793. mace_open
  794. Open device driver.
  795. ---------------------------------------------------------------------------- */
  796. static int mace_open(struct net_device *dev)
  797. {
  798. kio_addr_t ioaddr = dev->base_addr;
  799. mace_private *lp = netdev_priv(dev);
  800. dev_link_t *link = &lp->link;
  801. if (!DEV_OK(link))
  802. return -ENODEV;
  803. link->open++;
  804. MACEBANK(0);
  805. netif_start_queue(dev);
  806. nmclan_reset(dev);
  807. return 0; /* Always succeed */
  808. } /* mace_open */
  809. /* ----------------------------------------------------------------------------
  810. mace_close
  811. Closes device driver.
  812. ---------------------------------------------------------------------------- */
  813. static int mace_close(struct net_device *dev)
  814. {
  815. kio_addr_t ioaddr = dev->base_addr;
  816. mace_private *lp = netdev_priv(dev);
  817. dev_link_t *link = &lp->link;
  818. DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
  819. /* Mask off all interrupts from the MACE chip. */
  820. outb(0xFF, ioaddr + AM2150_MACE_BASE + MACE_IMR);
  821. link->open--;
  822. netif_stop_queue(dev);
  823. return 0;
  824. } /* mace_close */
  825. static void netdev_get_drvinfo(struct net_device *dev,
  826. struct ethtool_drvinfo *info)
  827. {
  828. strcpy(info->driver, DRV_NAME);
  829. strcpy(info->version, DRV_VERSION);
  830. sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
  831. }
  832. #ifdef PCMCIA_DEBUG
  833. static u32 netdev_get_msglevel(struct net_device *dev)
  834. {
  835. return pc_debug;
  836. }
  837. static void netdev_set_msglevel(struct net_device *dev, u32 level)
  838. {
  839. pc_debug = level;
  840. }
  841. #endif /* PCMCIA_DEBUG */
  842. static struct ethtool_ops netdev_ethtool_ops = {
  843. .get_drvinfo = netdev_get_drvinfo,
  844. #ifdef PCMCIA_DEBUG
  845. .get_msglevel = netdev_get_msglevel,
  846. .set_msglevel = netdev_set_msglevel,
  847. #endif /* PCMCIA_DEBUG */
  848. };
  849. /* ----------------------------------------------------------------------------
  850. mace_start_xmit
  851. This routine begins the packet transmit function. When completed,
  852. it will generate a transmit interrupt.
  853. According to /usr/src/linux/net/inet/dev.c, if _start_xmit
  854. returns 0, the "packet is now solely the responsibility of the
  855. driver." If _start_xmit returns non-zero, the "transmission
  856. failed, put skb back into a list."
  857. ---------------------------------------------------------------------------- */
  858. static void mace_tx_timeout(struct net_device *dev)
  859. {
  860. mace_private *lp = netdev_priv(dev);
  861. dev_link_t *link = &lp->link;
  862. printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name);
  863. #if RESET_ON_TIMEOUT
  864. printk("resetting card\n");
  865. pcmcia_reset_card(link->handle, NULL);
  866. #else /* #if RESET_ON_TIMEOUT */
  867. printk("NOT resetting card\n");
  868. #endif /* #if RESET_ON_TIMEOUT */
  869. dev->trans_start = jiffies;
  870. netif_wake_queue(dev);
  871. }
  872. static int mace_start_xmit(struct sk_buff *skb, struct net_device *dev)
  873. {
  874. mace_private *lp = netdev_priv(dev);
  875. kio_addr_t ioaddr = dev->base_addr;
  876. netif_stop_queue(dev);
  877. DEBUG(3, "%s: mace_start_xmit(length = %ld) called.\n",
  878. dev->name, (long)skb->len);
  879. #if (!TX_INTERRUPTABLE)
  880. /* Disable MACE TX interrupts. */
  881. outb(MACE_IMR_DEFAULT | MACE_IR_XMTINT,
  882. ioaddr + AM2150_MACE_BASE + MACE_IMR);
  883. lp->tx_irq_disabled=1;
  884. #endif /* #if (!TX_INTERRUPTABLE) */
  885. {
  886. /* This block must not be interrupted by another transmit request!
  887. mace_tx_timeout will take care of timer-based retransmissions from
  888. the upper layers. The interrupt handler is guaranteed never to
  889. service a transmit interrupt while we are in here.
  890. */
  891. lp->linux_stats.tx_bytes += skb->len;
  892. lp->tx_free_frames--;
  893. /* WARNING: Write the _exact_ number of bytes written in the header! */
  894. /* Put out the word header [must be an outw()] . . . */
  895. outw(skb->len, ioaddr + AM2150_XMT);
  896. /* . . . and the packet [may be any combination of outw() and outb()] */
  897. outsw(ioaddr + AM2150_XMT, skb->data, skb->len >> 1);
  898. if (skb->len & 1) {
  899. /* Odd byte transfer */
  900. outb(skb->data[skb->len-1], ioaddr + AM2150_XMT);
  901. }
  902. dev->trans_start = jiffies;
  903. #if MULTI_TX
  904. if (lp->tx_free_frames > 0)
  905. netif_start_queue(dev);
  906. #endif /* #if MULTI_TX */
  907. }
  908. #if (!TX_INTERRUPTABLE)
  909. /* Re-enable MACE TX interrupts. */
  910. lp->tx_irq_disabled=0;
  911. outb(MACE_IMR_DEFAULT, ioaddr + AM2150_MACE_BASE + MACE_IMR);
  912. #endif /* #if (!TX_INTERRUPTABLE) */
  913. dev_kfree_skb(skb);
  914. return 0;
  915. } /* mace_start_xmit */
  916. /* ----------------------------------------------------------------------------
  917. mace_interrupt
  918. The interrupt handler.
  919. ---------------------------------------------------------------------------- */
  920. static irqreturn_t mace_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  921. {
  922. struct net_device *dev = (struct net_device *) dev_id;
  923. mace_private *lp = netdev_priv(dev);
  924. kio_addr_t ioaddr = dev->base_addr;
  925. int status;
  926. int IntrCnt = MACE_MAX_IR_ITERATIONS;
  927. if (dev == NULL) {
  928. DEBUG(2, "mace_interrupt(): irq 0x%X for unknown device.\n",
  929. irq);
  930. return IRQ_NONE;
  931. }
  932. if (lp->tx_irq_disabled) {
  933. printk(
  934. (lp->tx_irq_disabled?
  935. KERN_NOTICE "%s: Interrupt with tx_irq_disabled "
  936. "[isr=%02X, imr=%02X]\n":
  937. KERN_NOTICE "%s: Re-entering the interrupt handler "
  938. "[isr=%02X, imr=%02X]\n"),
  939. dev->name,
  940. inb(ioaddr + AM2150_MACE_BASE + MACE_IR),
  941. inb(ioaddr + AM2150_MACE_BASE + MACE_IMR)
  942. );
  943. /* WARNING: MACE_IR has been read! */
  944. return IRQ_NONE;
  945. }
  946. if (!netif_device_present(dev)) {
  947. DEBUG(2, "%s: interrupt from dead card\n", dev->name);
  948. return IRQ_NONE;
  949. }
  950. do {
  951. /* WARNING: MACE_IR is a READ/CLEAR port! */
  952. status = inb(ioaddr + AM2150_MACE_BASE + MACE_IR);
  953. DEBUG(3, "mace_interrupt: irq 0x%X status 0x%X.\n", irq, status);
  954. if (status & MACE_IR_RCVINT) {
  955. mace_rx(dev, MACE_MAX_RX_ITERATIONS);
  956. }
  957. if (status & MACE_IR_XMTINT) {
  958. unsigned char fifofc;
  959. unsigned char xmtrc;
  960. unsigned char xmtfs;
  961. fifofc = inb(ioaddr + AM2150_MACE_BASE + MACE_FIFOFC);
  962. if ((fifofc & MACE_FIFOFC_XMTFC)==0) {
  963. lp->linux_stats.tx_errors++;
  964. outb(0xFF, ioaddr + AM2150_XMT_SKIP);
  965. }
  966. /* Transmit Retry Count (XMTRC, reg 4) */
  967. xmtrc = inb(ioaddr + AM2150_MACE_BASE + MACE_XMTRC);
  968. if (xmtrc & MACE_XMTRC_EXDEF) lp->mace_stats.exdef++;
  969. lp->mace_stats.xmtrc += (xmtrc & MACE_XMTRC_XMTRC);
  970. if (
  971. (xmtfs = inb(ioaddr + AM2150_MACE_BASE + MACE_XMTFS)) &
  972. MACE_XMTFS_XMTSV /* Transmit Status Valid */
  973. ) {
  974. lp->mace_stats.xmtsv++;
  975. if (xmtfs & ~MACE_XMTFS_XMTSV) {
  976. if (xmtfs & MACE_XMTFS_UFLO) {
  977. /* Underflow. Indicates that the Transmit FIFO emptied before
  978. the end of frame was reached. */
  979. lp->mace_stats.uflo++;
  980. }
  981. if (xmtfs & MACE_XMTFS_LCOL) {
  982. /* Late Collision */
  983. lp->mace_stats.lcol++;
  984. }
  985. if (xmtfs & MACE_XMTFS_MORE) {
  986. /* MORE than one retry was needed */
  987. lp->mace_stats.more++;
  988. }
  989. if (xmtfs & MACE_XMTFS_ONE) {
  990. /* Exactly ONE retry occurred */
  991. lp->mace_stats.one++;
  992. }
  993. if (xmtfs & MACE_XMTFS_DEFER) {
  994. /* Transmission was defered */
  995. lp->mace_stats.defer++;
  996. }
  997. if (xmtfs & MACE_XMTFS_LCAR) {
  998. /* Loss of carrier */
  999. lp->mace_stats.lcar++;
  1000. }
  1001. if (xmtfs & MACE_XMTFS_RTRY) {
  1002. /* Retry error: transmit aborted after 16 attempts */
  1003. lp->mace_stats.rtry++;
  1004. }
  1005. } /* if (xmtfs & ~MACE_XMTFS_XMTSV) */
  1006. } /* if (xmtfs & MACE_XMTFS_XMTSV) */
  1007. lp->linux_stats.tx_packets++;
  1008. lp->tx_free_frames++;
  1009. netif_wake_queue(dev);
  1010. } /* if (status & MACE_IR_XMTINT) */
  1011. if (status & ~MACE_IMR_DEFAULT & ~MACE_IR_RCVINT & ~MACE_IR_XMTINT) {
  1012. if (status & MACE_IR_JAB) {
  1013. /* Jabber Error. Excessive transmit duration (20-150ms). */
  1014. lp->mace_stats.jab++;
  1015. }
  1016. if (status & MACE_IR_BABL) {
  1017. /* Babble Error. >1518 bytes transmitted. */
  1018. lp->mace_stats.babl++;
  1019. }
  1020. if (status & MACE_IR_CERR) {
  1021. /* Collision Error. CERR indicates the absence of the
  1022. Signal Quality Error Test message after a packet
  1023. transmission. */
  1024. lp->mace_stats.cerr++;
  1025. }
  1026. if (status & MACE_IR_RCVCCO) {
  1027. /* Receive Collision Count Overflow; */
  1028. lp->mace_stats.rcvcco++;
  1029. }
  1030. if (status & MACE_IR_RNTPCO) {
  1031. /* Runt Packet Count Overflow */
  1032. lp->mace_stats.rntpco++;
  1033. }
  1034. if (status & MACE_IR_MPCO) {
  1035. /* Missed Packet Count Overflow */
  1036. lp->mace_stats.mpco++;
  1037. }
  1038. } /* if (status & ~MACE_IMR_DEFAULT & ~MACE_IR_RCVINT & ~MACE_IR_XMTINT) */
  1039. } while ((status & ~MACE_IMR_DEFAULT) && (--IntrCnt));
  1040. return IRQ_HANDLED;
  1041. } /* mace_interrupt */
  1042. /* ----------------------------------------------------------------------------
  1043. mace_rx
  1044. Receives packets.
  1045. ---------------------------------------------------------------------------- */
  1046. static int mace_rx(struct net_device *dev, unsigned char RxCnt)
  1047. {
  1048. mace_private *lp = netdev_priv(dev);
  1049. kio_addr_t ioaddr = dev->base_addr;
  1050. unsigned char rx_framecnt;
  1051. unsigned short rx_status;
  1052. while (
  1053. ((rx_framecnt = inb(ioaddr + AM2150_RCV_FRAME_COUNT)) > 0) &&
  1054. (rx_framecnt <= 12) && /* rx_framecnt==0xFF if card is extracted. */
  1055. (RxCnt--)
  1056. ) {
  1057. rx_status = inw(ioaddr + AM2150_RCV);
  1058. DEBUG(3, "%s: in mace_rx(), framecnt 0x%X, rx_status"
  1059. " 0x%X.\n", dev->name, rx_framecnt, rx_status);
  1060. if (rx_status & MACE_RCVFS_RCVSTS) { /* Error, update stats. */
  1061. lp->linux_stats.rx_errors++;
  1062. if (rx_status & MACE_RCVFS_OFLO) {
  1063. lp->mace_stats.oflo++;
  1064. }
  1065. if (rx_status & MACE_RCVFS_CLSN) {
  1066. lp->mace_stats.clsn++;
  1067. }
  1068. if (rx_status & MACE_RCVFS_FRAM) {
  1069. lp->mace_stats.fram++;
  1070. }
  1071. if (rx_status & MACE_RCVFS_FCS) {
  1072. lp->mace_stats.fcs++;
  1073. }
  1074. } else {
  1075. short pkt_len = (rx_status & ~MACE_RCVFS_RCVSTS) - 4;
  1076. /* Auto Strip is off, always subtract 4 */
  1077. struct sk_buff *skb;
  1078. lp->mace_stats.rfs_rntpc += inb(ioaddr + AM2150_RCV);
  1079. /* runt packet count */
  1080. lp->mace_stats.rfs_rcvcc += inb(ioaddr + AM2150_RCV);
  1081. /* rcv collision count */
  1082. DEBUG(3, " receiving packet size 0x%X rx_status"
  1083. " 0x%X.\n", pkt_len, rx_status);
  1084. skb = dev_alloc_skb(pkt_len+2);
  1085. if (skb != NULL) {
  1086. skb->dev = dev;
  1087. skb_reserve(skb, 2);
  1088. insw(ioaddr + AM2150_RCV, skb_put(skb, pkt_len), pkt_len>>1);
  1089. if (pkt_len & 1)
  1090. *(skb->tail-1) = inb(ioaddr + AM2150_RCV);
  1091. skb->protocol = eth_type_trans(skb, dev);
  1092. netif_rx(skb); /* Send the packet to the upper (protocol) layers. */
  1093. dev->last_rx = jiffies;
  1094. lp->linux_stats.rx_packets++;
  1095. lp->linux_stats.rx_bytes += skb->len;
  1096. outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
  1097. continue;
  1098. } else {
  1099. DEBUG(1, "%s: couldn't allocate a sk_buff of size"
  1100. " %d.\n", dev->name, pkt_len);
  1101. lp->linux_stats.rx_dropped++;
  1102. }
  1103. }
  1104. outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
  1105. } /* while */
  1106. return 0;
  1107. } /* mace_rx */
  1108. /* ----------------------------------------------------------------------------
  1109. pr_linux_stats
  1110. ---------------------------------------------------------------------------- */
  1111. static void pr_linux_stats(struct net_device_stats *pstats)
  1112. {
  1113. DEBUG(2, "pr_linux_stats\n");
  1114. DEBUG(2, " rx_packets=%-7ld tx_packets=%ld\n",
  1115. (long)pstats->rx_packets, (long)pstats->tx_packets);
  1116. DEBUG(2, " rx_errors=%-7ld tx_errors=%ld\n",
  1117. (long)pstats->rx_errors, (long)pstats->tx_errors);
  1118. DEBUG(2, " rx_dropped=%-7ld tx_dropped=%ld\n",
  1119. (long)pstats->rx_dropped, (long)pstats->tx_dropped);
  1120. DEBUG(2, " multicast=%-7ld collisions=%ld\n",
  1121. (long)pstats->multicast, (long)pstats->collisions);
  1122. DEBUG(2, " rx_length_errors=%-7ld rx_over_errors=%ld\n",
  1123. (long)pstats->rx_length_errors, (long)pstats->rx_over_errors);
  1124. DEBUG(2, " rx_crc_errors=%-7ld rx_frame_errors=%ld\n",
  1125. (long)pstats->rx_crc_errors, (long)pstats->rx_frame_errors);
  1126. DEBUG(2, " rx_fifo_errors=%-7ld rx_missed_errors=%ld\n",
  1127. (long)pstats->rx_fifo_errors, (long)pstats->rx_missed_errors);
  1128. DEBUG(2, " tx_aborted_errors=%-7ld tx_carrier_errors=%ld\n",
  1129. (long)pstats->tx_aborted_errors, (long)pstats->tx_carrier_errors);
  1130. DEBUG(2, " tx_fifo_errors=%-7ld tx_heartbeat_errors=%ld\n",
  1131. (long)pstats->tx_fifo_errors, (long)pstats->tx_heartbeat_errors);
  1132. DEBUG(2, " tx_window_errors=%ld\n",
  1133. (long)pstats->tx_window_errors);
  1134. } /* pr_linux_stats */
  1135. /* ----------------------------------------------------------------------------
  1136. pr_mace_stats
  1137. ---------------------------------------------------------------------------- */
  1138. static void pr_mace_stats(mace_statistics *pstats)
  1139. {
  1140. DEBUG(2, "pr_mace_stats\n");
  1141. DEBUG(2, " xmtsv=%-7d uflo=%d\n",
  1142. pstats->xmtsv, pstats->uflo);
  1143. DEBUG(2, " lcol=%-7d more=%d\n",
  1144. pstats->lcol, pstats->more);
  1145. DEBUG(2, " one=%-7d defer=%d\n",
  1146. pstats->one, pstats->defer);
  1147. DEBUG(2, " lcar=%-7d rtry=%d\n",
  1148. pstats->lcar, pstats->rtry);
  1149. /* MACE_XMTRC */
  1150. DEBUG(2, " exdef=%-7d xmtrc=%d\n",
  1151. pstats->exdef, pstats->xmtrc);
  1152. /* RFS1--Receive Status (RCVSTS) */
  1153. DEBUG(2, " oflo=%-7d clsn=%d\n",
  1154. pstats->oflo, pstats->clsn);
  1155. DEBUG(2, " fram=%-7d fcs=%d\n",
  1156. pstats->fram, pstats->fcs);
  1157. /* RFS2--Runt Packet Count (RNTPC) */
  1158. /* RFS3--Receive Collision Count (RCVCC) */
  1159. DEBUG(2, " rfs_rntpc=%-7d rfs_rcvcc=%d\n",
  1160. pstats->rfs_rntpc, pstats->rfs_rcvcc);
  1161. /* MACE_IR */
  1162. DEBUG(2, " jab=%-7d babl=%d\n",
  1163. pstats->jab, pstats->babl);
  1164. DEBUG(2, " cerr=%-7d rcvcco=%d\n",
  1165. pstats->cerr, pstats->rcvcco);
  1166. DEBUG(2, " rntpco=%-7d mpco=%d\n",
  1167. pstats->rntpco, pstats->mpco);
  1168. /* MACE_MPC */
  1169. DEBUG(2, " mpc=%d\n", pstats->mpc);
  1170. /* MACE_RNTPC */
  1171. DEBUG(2, " rntpc=%d\n", pstats->rntpc);
  1172. /* MACE_RCVCC */
  1173. DEBUG(2, " rcvcc=%d\n", pstats->rcvcc);
  1174. } /* pr_mace_stats */
  1175. /* ----------------------------------------------------------------------------
  1176. update_stats
  1177. Update statistics. We change to register window 1, so this
  1178. should be run single-threaded if the device is active. This is
  1179. expected to be a rare operation, and it's simpler for the rest
  1180. of the driver to assume that window 0 is always valid rather
  1181. than use a special window-state variable.
  1182. oflo & uflo should _never_ occur since it would mean the Xilinx
  1183. was not able to transfer data between the MACE FIFO and the
  1184. card's SRAM fast enough. If this happens, something is
  1185. seriously wrong with the hardware.
  1186. ---------------------------------------------------------------------------- */
  1187. static void update_stats(kio_addr_t ioaddr, struct net_device *dev)
  1188. {
  1189. mace_private *lp = netdev_priv(dev);
  1190. lp->mace_stats.rcvcc += mace_read(lp, ioaddr, MACE_RCVCC);
  1191. lp->mace_stats.rntpc += mace_read(lp, ioaddr, MACE_RNTPC);
  1192. lp->mace_stats.mpc += mace_read(lp, ioaddr, MACE_MPC);
  1193. /* At this point, mace_stats is fully updated for this call.
  1194. We may now update the linux_stats. */
  1195. /* The MACE has no equivalent for linux_stats field which are commented
  1196. out. */
  1197. /* lp->linux_stats.multicast; */
  1198. lp->linux_stats.collisions =
  1199. lp->mace_stats.rcvcco * 256 + lp->mace_stats.rcvcc;
  1200. /* Collision: The MACE may retry sending a packet 15 times
  1201. before giving up. The retry count is in XMTRC.
  1202. Does each retry constitute a collision?
  1203. If so, why doesn't the RCVCC record these collisions? */
  1204. /* detailed rx_errors: */
  1205. lp->linux_stats.rx_length_errors =
  1206. lp->mace_stats.rntpco * 256 + lp->mace_stats.rntpc;
  1207. /* lp->linux_stats.rx_over_errors */
  1208. lp->linux_stats.rx_crc_errors = lp->mace_stats.fcs;
  1209. lp->linux_stats.rx_frame_errors = lp->mace_stats.fram;
  1210. lp->linux_stats.rx_fifo_errors = lp->mace_stats.oflo;
  1211. lp->linux_stats.rx_missed_errors =
  1212. lp->mace_stats.mpco * 256 + lp->mace_stats.mpc;
  1213. /* detailed tx_errors */
  1214. lp->linux_stats.tx_aborted_errors = lp->mace_stats.rtry;
  1215. lp->linux_stats.tx_carrier_errors = lp->mace_stats.lcar;
  1216. /* LCAR usually results from bad cabling. */
  1217. lp->linux_stats.tx_fifo_errors = lp->mace_stats.uflo;
  1218. lp->linux_stats.tx_heartbeat_errors = lp->mace_stats.cerr;
  1219. /* lp->linux_stats.tx_window_errors; */
  1220. return;
  1221. } /* update_stats */
  1222. /* ----------------------------------------------------------------------------
  1223. mace_get_stats
  1224. Gathers ethernet statistics from the MACE chip.
  1225. ---------------------------------------------------------------------------- */
  1226. static struct net_device_stats *mace_get_stats(struct net_device *dev)
  1227. {
  1228. mace_private *lp = netdev_priv(dev);
  1229. update_stats(dev->base_addr, dev);
  1230. DEBUG(1, "%s: updating the statistics.\n", dev->name);
  1231. pr_linux_stats(&lp->linux_stats);
  1232. pr_mace_stats(&lp->mace_stats);
  1233. return &lp->linux_stats;
  1234. } /* net_device_stats */
  1235. /* ----------------------------------------------------------------------------
  1236. updateCRC
  1237. Modified from Am79C90 data sheet.
  1238. ---------------------------------------------------------------------------- */
  1239. #ifdef BROKEN_MULTICAST
  1240. static void updateCRC(int *CRC, int bit)
  1241. {
  1242. int poly[]={
  1243. 1,1,1,0, 1,1,0,1,
  1244. 1,0,1,1, 1,0,0,0,
  1245. 1,0,0,0, 0,0,1,1,
  1246. 0,0,1,0, 0,0,0,0
  1247. }; /* CRC polynomial. poly[n] = coefficient of the x**n term of the
  1248. CRC generator polynomial. */
  1249. int j;
  1250. /* shift CRC and control bit (CRC[32]) */
  1251. for (j = 32; j > 0; j--)
  1252. CRC[j] = CRC[j-1];
  1253. CRC[0] = 0;
  1254. /* If bit XOR(control bit) = 1, set CRC = CRC XOR polynomial. */
  1255. if (bit ^ CRC[32])
  1256. for (j = 0; j < 32; j++)
  1257. CRC[j] ^= poly[j];
  1258. } /* updateCRC */
  1259. /* ----------------------------------------------------------------------------
  1260. BuildLAF
  1261. Build logical address filter.
  1262. Modified from Am79C90 data sheet.
  1263. Input
  1264. ladrf: logical address filter (contents initialized to 0)
  1265. adr: ethernet address
  1266. ---------------------------------------------------------------------------- */
  1267. static void BuildLAF(int *ladrf, int *adr)
  1268. {
  1269. int CRC[33]={1}; /* CRC register, 1 word/bit + extra control bit */
  1270. int i, byte; /* temporary array indices */
  1271. int hashcode; /* the output object */
  1272. CRC[32]=0;
  1273. for (byte = 0; byte < 6; byte++)
  1274. for (i = 0; i < 8; i++)
  1275. updateCRC(CRC, (adr[byte] >> i) & 1);
  1276. hashcode = 0;
  1277. for (i = 0; i < 6; i++)
  1278. hashcode = (hashcode << 1) + CRC[i];
  1279. byte = hashcode >> 3;
  1280. ladrf[byte] |= (1 << (hashcode & 7));
  1281. #ifdef PCMCIA_DEBUG
  1282. if (pc_debug > 2) {
  1283. printk(KERN_DEBUG " adr =");
  1284. for (i = 0; i < 6; i++)
  1285. printk(" %02X", adr[i]);
  1286. printk("\n" KERN_DEBUG " hashcode = %d(decimal), ladrf[0:63]"
  1287. " =", hashcode);
  1288. for (i = 0; i < 8; i++)
  1289. printk(" %02X", ladrf[i]);
  1290. printk("\n");
  1291. }
  1292. #endif
  1293. } /* BuildLAF */
  1294. /* ----------------------------------------------------------------------------
  1295. restore_multicast_list
  1296. Restores the multicast filter for MACE chip to the last
  1297. set_multicast_list() call.
  1298. Input
  1299. multicast_num_addrs
  1300. multicast_ladrf[]
  1301. ---------------------------------------------------------------------------- */
  1302. static void restore_multicast_list(struct net_device *dev)
  1303. {
  1304. mace_private *lp = netdev_priv(dev);
  1305. int num_addrs = lp->multicast_num_addrs;
  1306. int *ladrf = lp->multicast_ladrf;
  1307. kio_addr_t ioaddr = dev->base_addr;
  1308. int i;
  1309. DEBUG(2, "%s: restoring Rx mode to %d addresses.\n",
  1310. dev->name, num_addrs);
  1311. if (num_addrs > 0) {
  1312. DEBUG(1, "Attempt to restore multicast list detected.\n");
  1313. mace_write(lp, ioaddr, MACE_IAC, MACE_IAC_ADDRCHG | MACE_IAC_LOGADDR);
  1314. /* Poll ADDRCHG bit */
  1315. while (mace_read(lp, ioaddr, MACE_IAC) & MACE_IAC_ADDRCHG)
  1316. ;
  1317. /* Set LADRF register */
  1318. for (i = 0; i < MACE_LADRF_LEN; i++)
  1319. mace_write(lp, ioaddr, MACE_LADRF, ladrf[i]);
  1320. mace_write(lp, ioaddr, MACE_UTR, MACE_UTR_RCVFCSE | MACE_UTR_LOOP_EXTERNAL);
  1321. mace_write(lp, ioaddr, MACE_MACCC, MACE_MACCC_ENXMT | MACE_MACCC_ENRCV);
  1322. } else if (num_addrs < 0) {
  1323. /* Promiscuous mode: receive all packets */
  1324. mace_write(lp, ioaddr, MACE_UTR, MACE_UTR_LOOP_EXTERNAL);
  1325. mace_write(lp, ioaddr, MACE_MACCC,
  1326. MACE_MACCC_PROM | MACE_MACCC_ENXMT | MACE_MACCC_ENRCV
  1327. );
  1328. } else {
  1329. /* Normal mode */
  1330. mace_write(lp, ioaddr, MACE_UTR, MACE_UTR_LOOP_EXTERNAL);
  1331. mace_write(lp, ioaddr, MACE_MACCC, MACE_MACCC_ENXMT | MACE_MACCC_ENRCV);
  1332. }
  1333. } /* restore_multicast_list */
  1334. /* ----------------------------------------------------------------------------
  1335. set_multicast_list
  1336. Set or clear the multicast filter for this adaptor.
  1337. Input
  1338. num_addrs == -1 Promiscuous mode, receive all packets
  1339. num_addrs == 0 Normal mode, clear multicast list
  1340. num_addrs > 0 Multicast mode, receive normal and MC packets, and do
  1341. best-effort filtering.
  1342. Output
  1343. multicast_num_addrs
  1344. multicast_ladrf[]
  1345. ---------------------------------------------------------------------------- */
  1346. static void set_multicast_list(struct net_device *dev)
  1347. {
  1348. mace_private *lp = netdev_priv(dev);
  1349. int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */
  1350. int i;
  1351. struct dev_mc_list *dmi = dev->mc_list;
  1352. #ifdef PCMCIA_DEBUG
  1353. if (pc_debug > 1) {
  1354. static int old;
  1355. if (dev->mc_count != old) {
  1356. old = dev->mc_count;
  1357. DEBUG(0, "%s: setting Rx mode to %d addresses.\n",
  1358. dev->name, old);
  1359. }
  1360. }
  1361. #endif
  1362. /* Set multicast_num_addrs. */
  1363. lp->multicast_num_addrs = dev->mc_count;
  1364. /* Set multicast_ladrf. */
  1365. if (num_addrs > 0) {
  1366. /* Calculate multicast logical address filter */
  1367. memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN);
  1368. for (i = 0; i < dev->mc_count; i++) {
  1369. memcpy(adr, dmi->dmi_addr, ETHER_ADDR_LEN);
  1370. dmi = dmi->next;
  1371. BuildLAF(lp->multicast_ladrf, adr);
  1372. }
  1373. }
  1374. restore_multicast_list(dev);
  1375. } /* set_multicast_list */
  1376. #endif /* BROKEN_MULTICAST */
  1377. static void restore_multicast_list(struct net_device *dev)
  1378. {
  1379. kio_addr_t ioaddr = dev->base_addr;
  1380. mace_private *lp = netdev_priv(dev);
  1381. DEBUG(2, "%s: restoring Rx mode to %d addresses.\n", dev->name,
  1382. lp->multicast_num_addrs);
  1383. if (dev->flags & IFF_PROMISC) {
  1384. /* Promiscuous mode: receive all packets */
  1385. mace_write(lp,ioaddr, MACE_UTR, MACE_UTR_LOOP_EXTERNAL);
  1386. mace_write(lp, ioaddr, MACE_MACCC,
  1387. MACE_MACCC_PROM | MACE_MACCC_ENXMT | MACE_MACCC_ENRCV
  1388. );
  1389. } else {
  1390. /* Normal mode */
  1391. mace_write(lp, ioaddr, MACE_UTR, MACE_UTR_LOOP_EXTERNAL);
  1392. mace_write(lp, ioaddr, MACE_MACCC, MACE_MACCC_ENXMT | MACE_MACCC_ENRCV);
  1393. }
  1394. } /* restore_multicast_list */
  1395. static void set_multicast_list(struct net_device *dev)
  1396. {
  1397. mace_private *lp = netdev_priv(dev);
  1398. #ifdef PCMCIA_DEBUG
  1399. if (pc_debug > 1) {
  1400. static int old;
  1401. if (dev->mc_count != old) {
  1402. old = dev->mc_count;
  1403. DEBUG(0, "%s: setting Rx mode to %d addresses.\n",
  1404. dev->name, old);
  1405. }
  1406. }
  1407. #endif
  1408. lp->multicast_num_addrs = dev->mc_count;
  1409. restore_multicast_list(dev);
  1410. } /* set_multicast_list */
  1411. static struct pcmcia_device_id nmclan_ids[] = {
  1412. PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "Ethernet", 0x085a850b, 0x00b2e941),
  1413. PCMCIA_DEVICE_PROD_ID12("Portable Add-ons", "Ethernet", 0x0ebf1d60, 0x00b2e941),
  1414. PCMCIA_DEVICE_NULL,
  1415. };
  1416. MODULE_DEVICE_TABLE(pcmcia, nmclan_ids);
  1417. static struct pcmcia_driver nmclan_cs_driver = {
  1418. .owner = THIS_MODULE,
  1419. .drv = {
  1420. .name = "nmclan_cs",
  1421. },
  1422. .attach = nmclan_attach,
  1423. .detach = nmclan_detach,
  1424. .id_table = nmclan_ids,
  1425. };
  1426. static int __init init_nmclan_cs(void)
  1427. {
  1428. return pcmcia_register_driver(&nmclan_cs_driver);
  1429. }
  1430. static void __exit exit_nmclan_cs(void)
  1431. {
  1432. pcmcia_unregister_driver(&nmclan_cs_driver);
  1433. BUG_ON(dev_list != NULL);
  1434. }
  1435. module_init(init_nmclan_cs);
  1436. module_exit(exit_nmclan_cs);