sun3_82586.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. /*
  2. * Sun3 i82586 Ethernet driver
  3. *
  4. * Cloned from ni52.c for the Sun3 by Sam Creasey (sammy@sammy.net)
  5. *
  6. * Original copyright follows:
  7. * --------------------------
  8. *
  9. * net-3-driver for the NI5210 card (i82586 Ethernet chip)
  10. *
  11. * This is an extension to the Linux operating system, and is covered by the
  12. * same Gnu Public License that covers that work.
  13. *
  14. * Alphacode 0.82 (96/09/29) for Linux 2.0.0 (or later)
  15. * Copyrights (c) 1994,1995,1996 by M.Hipp (hippm@informatik.uni-tuebingen.de)
  16. * --------------------------
  17. *
  18. * Consult ni52.c for further notes from the original driver.
  19. *
  20. * This incarnation currently supports the OBIO version of the i82586 chip
  21. * used in certain sun3 models. It should be fairly doable to expand this
  22. * to support VME if I should every acquire such a board.
  23. *
  24. */
  25. static int debuglevel = 0; /* debug-printk 0: off 1: a few 2: more */
  26. static int automatic_resume = 0; /* experimental .. better should be zero */
  27. static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */
  28. static int fifo=0x8; /* don't change */
  29. #include <linux/module.h>
  30. #include <linux/kernel.h>
  31. #include <linux/string.h>
  32. #include <linux/errno.h>
  33. #include <linux/ioport.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/delay.h>
  36. #include <linux/init.h>
  37. #include <linux/bitops.h>
  38. #include <asm/io.h>
  39. #include <asm/idprom.h>
  40. #include <asm/machines.h>
  41. #include <asm/sun3mmu.h>
  42. #include <asm/dvma.h>
  43. #include <asm/byteorder.h>
  44. #include <linux/netdevice.h>
  45. #include <linux/etherdevice.h>
  46. #include <linux/skbuff.h>
  47. #include "sun3_82586.h"
  48. #define DRV_NAME "sun3_82586"
  49. #define DEBUG /* debug on */
  50. #define SYSBUSVAL 0 /* 16 Bit */
  51. #define SUN3_82586_TOTAL_SIZE PAGE_SIZE
  52. #define sun3_attn586() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_ATTEN; *(volatile unsigned char *)(dev->base_addr) &= ~IEOB_ATTEN;}
  53. #define sun3_reset586() {*(volatile unsigned char *)(dev->base_addr) = 0; udelay(100); *(volatile unsigned char *)(dev->base_addr) = IEOB_NORSET;}
  54. #define sun3_disint() {*(volatile unsigned char *)(dev->base_addr) &= ~IEOB_IENAB;}
  55. #define sun3_enaint() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_IENAB;}
  56. #define sun3_active() {*(volatile unsigned char *)(dev->base_addr) |= (IEOB_IENAB|IEOB_ONAIR|IEOB_NORSET);}
  57. #define make32(ptr16) (p->memtop + (swab16((unsigned short) (ptr16))) )
  58. #define make24(ptr32) (char *)swab32(( ((unsigned long) (ptr32)) - p->base))
  59. #define make16(ptr32) (swab16((unsigned short) ((unsigned long)(ptr32) - (unsigned long) p->memtop )))
  60. /******************* how to calculate the buffers *****************************
  61. * IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works
  62. * --------------- in a different (more stable?) mode. Only in this mode it's
  63. * possible to configure the driver with 'NO_NOPCOMMANDS'
  64. sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8;
  65. sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT
  66. sizeof(rfd) = 24; sizeof(rbd) = 12;
  67. sizeof(tbd) = 8; sizeof(transmit_cmd) = 16;
  68. sizeof(nop_cmd) = 8;
  69. * if you don't know the driver, better do not change these values: */
  70. #define RECV_BUFF_SIZE 1536 /* slightly oversized */
  71. #define XMIT_BUFF_SIZE 1536 /* slightly oversized */
  72. #define NUM_XMIT_BUFFS 1 /* config for 32K shmem */
  73. #define NUM_RECV_BUFFS_8 4 /* config for 32K shared mem */
  74. #define NUM_RECV_BUFFS_16 9 /* config for 32K shared mem */
  75. #define NUM_RECV_BUFFS_32 16 /* config for 32K shared mem */
  76. #define NO_NOPCOMMANDS /* only possible with NUM_XMIT_BUFFS=1 */
  77. /**************************************************************************/
  78. /* different DELAYs */
  79. #define DELAY(x) mdelay(32 * x);
  80. #define DELAY_16(); { udelay(16); }
  81. #define DELAY_18(); { udelay(4); }
  82. /* wait for command with timeout: */
  83. #define WAIT_4_SCB_CMD() \
  84. { int i; \
  85. for(i=0;i<16384;i++) { \
  86. if(!p->scb->cmd_cuc) break; \
  87. DELAY_18(); \
  88. if(i == 16383) { \
  89. printk("%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_cuc,p->scb->cus); \
  90. if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
  91. #define WAIT_4_SCB_CMD_RUC() { int i; \
  92. for(i=0;i<16384;i++) { \
  93. if(!p->scb->cmd_ruc) break; \
  94. DELAY_18(); \
  95. if(i == 16383) { \
  96. printk("%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_ruc,p->scb->rus); \
  97. if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
  98. #define WAIT_4_STAT_COMPL(addr) { int i; \
  99. for(i=0;i<32767;i++) { \
  100. if(swab16((addr)->cmd_status) & STAT_COMPL) break; \
  101. DELAY_16(); DELAY_16(); } }
  102. static int sun3_82586_probe1(struct net_device *dev,int ioaddr);
  103. static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id);
  104. static int sun3_82586_open(struct net_device *dev);
  105. static int sun3_82586_close(struct net_device *dev);
  106. static int sun3_82586_send_packet(struct sk_buff *,struct net_device *);
  107. static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev);
  108. static void set_multicast_list(struct net_device *dev);
  109. static void sun3_82586_timeout(struct net_device *dev);
  110. #if 0
  111. static void sun3_82586_dump(struct net_device *,void *);
  112. #endif
  113. /* helper-functions */
  114. static int init586(struct net_device *dev);
  115. static int check586(struct net_device *dev,char *where,unsigned size);
  116. static void alloc586(struct net_device *dev);
  117. static void startrecv586(struct net_device *dev);
  118. static void *alloc_rfa(struct net_device *dev,void *ptr);
  119. static void sun3_82586_rcv_int(struct net_device *dev);
  120. static void sun3_82586_xmt_int(struct net_device *dev);
  121. static void sun3_82586_rnr_int(struct net_device *dev);
  122. struct priv
  123. {
  124. unsigned long base;
  125. char *memtop;
  126. long int lock;
  127. int reseted;
  128. volatile struct rfd_struct *rfd_last,*rfd_top,*rfd_first;
  129. volatile struct scp_struct *scp; /* volatile is important */
  130. volatile struct iscp_struct *iscp; /* volatile is important */
  131. volatile struct scb_struct *scb; /* volatile is important */
  132. volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS];
  133. volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
  134. #if (NUM_XMIT_BUFFS == 1)
  135. volatile struct nop_cmd_struct *nop_cmds[2];
  136. #else
  137. volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS];
  138. #endif
  139. volatile int nop_point,num_recv_buffs;
  140. volatile char *xmit_cbuffs[NUM_XMIT_BUFFS];
  141. volatile int xmit_count,xmit_last;
  142. };
  143. /**********************************************
  144. * close device
  145. */
  146. static int sun3_82586_close(struct net_device *dev)
  147. {
  148. free_irq(dev->irq, dev);
  149. sun3_reset586(); /* the hard way to stop the receiver */
  150. netif_stop_queue(dev);
  151. return 0;
  152. }
  153. /**********************************************
  154. * open device
  155. */
  156. static int sun3_82586_open(struct net_device *dev)
  157. {
  158. int ret;
  159. sun3_disint();
  160. alloc586(dev);
  161. init586(dev);
  162. startrecv586(dev);
  163. sun3_enaint();
  164. ret = request_irq(dev->irq, sun3_82586_interrupt,0,dev->name,dev);
  165. if (ret)
  166. {
  167. sun3_reset586();
  168. return ret;
  169. }
  170. netif_start_queue(dev);
  171. return 0; /* most done by init */
  172. }
  173. /**********************************************
  174. * Check to see if there's an 82586 out there.
  175. */
  176. static int check586(struct net_device *dev,char *where,unsigned size)
  177. {
  178. struct priv pb;
  179. struct priv *p = &pb;
  180. char *iscp_addr;
  181. int i;
  182. p->base = (unsigned long) dvma_btov(0);
  183. p->memtop = (char *)dvma_btov((unsigned long)where);
  184. p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
  185. memset((char *)p->scp,0, sizeof(struct scp_struct));
  186. for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */
  187. if(((char *)p->scp)[i])
  188. return 0;
  189. p->scp->sysbus = SYSBUSVAL; /* 1 = 8Bit-Bus, 0 = 16 Bit */
  190. if(p->scp->sysbus != SYSBUSVAL)
  191. return 0;
  192. iscp_addr = (char *)dvma_btov((unsigned long)where);
  193. p->iscp = (struct iscp_struct *) iscp_addr;
  194. memset((char *)p->iscp,0, sizeof(struct iscp_struct));
  195. p->scp->iscp = make24(p->iscp);
  196. p->iscp->busy = 1;
  197. sun3_reset586();
  198. sun3_attn586();
  199. DELAY(1); /* wait a while... */
  200. if(p->iscp->busy) /* i82586 clears 'busy' after successful init */
  201. return 0;
  202. return 1;
  203. }
  204. /******************************************************************
  205. * set iscp at the right place, called by sun3_82586_probe1 and open586.
  206. */
  207. static void alloc586(struct net_device *dev)
  208. {
  209. struct priv *p = netdev_priv(dev);
  210. sun3_reset586();
  211. DELAY(1);
  212. p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS);
  213. p->iscp = (struct iscp_struct *) dvma_btov(dev->mem_start);
  214. p->scb = (struct scb_struct *) ((char *)p->iscp + sizeof(struct iscp_struct));
  215. memset((char *) p->iscp,0,sizeof(struct iscp_struct));
  216. memset((char *) p->scp ,0,sizeof(struct scp_struct));
  217. p->scp->iscp = make24(p->iscp);
  218. p->scp->sysbus = SYSBUSVAL;
  219. p->iscp->scb_offset = make16(p->scb);
  220. p->iscp->scb_base = make24(dvma_btov(dev->mem_start));
  221. p->iscp->busy = 1;
  222. sun3_reset586();
  223. sun3_attn586();
  224. DELAY(1);
  225. if(p->iscp->busy)
  226. printk("%s: Init-Problems (alloc).\n",dev->name);
  227. p->reseted = 0;
  228. memset((char *)p->scb,0,sizeof(struct scb_struct));
  229. }
  230. struct net_device * __init sun3_82586_probe(int unit)
  231. {
  232. struct net_device *dev;
  233. unsigned long ioaddr;
  234. static int found = 0;
  235. int err = -ENOMEM;
  236. /* check that this machine has an onboard 82586 */
  237. switch(idprom->id_machtype) {
  238. case SM_SUN3|SM_3_160:
  239. case SM_SUN3|SM_3_260:
  240. /* these machines have 82586 */
  241. break;
  242. default:
  243. return ERR_PTR(-ENODEV);
  244. }
  245. if (found)
  246. return ERR_PTR(-ENODEV);
  247. ioaddr = (unsigned long)ioremap(IE_OBIO, SUN3_82586_TOTAL_SIZE);
  248. if (!ioaddr)
  249. return ERR_PTR(-ENOMEM);
  250. found = 1;
  251. dev = alloc_etherdev(sizeof(struct priv));
  252. if (!dev)
  253. goto out;
  254. if (unit >= 0) {
  255. sprintf(dev->name, "eth%d", unit);
  256. netdev_boot_setup_check(dev);
  257. }
  258. dev->irq = IE_IRQ;
  259. dev->base_addr = ioaddr;
  260. err = sun3_82586_probe1(dev, ioaddr);
  261. if (err)
  262. goto out1;
  263. err = register_netdev(dev);
  264. if (err)
  265. goto out2;
  266. return dev;
  267. out2:
  268. release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
  269. out1:
  270. free_netdev(dev);
  271. out:
  272. iounmap((void __iomem *)ioaddr);
  273. return ERR_PTR(err);
  274. }
  275. static const struct net_device_ops sun3_82586_netdev_ops = {
  276. .ndo_open = sun3_82586_open,
  277. .ndo_stop = sun3_82586_close,
  278. .ndo_start_xmit = sun3_82586_send_packet,
  279. .ndo_set_multicast_list = set_multicast_list,
  280. .ndo_tx_timeout = sun3_82586_timeout,
  281. .ndo_get_stats = sun3_82586_get_stats,
  282. .ndo_validate_addr = eth_validate_addr,
  283. .ndo_set_mac_address = eth_mac_addr,
  284. .ndo_change_mtu = eth_change_mtu,
  285. };
  286. static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
  287. {
  288. int i, size, retval;
  289. if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME))
  290. return -EBUSY;
  291. /* copy in the ethernet address from the prom */
  292. for(i = 0; i < 6 ; i++)
  293. dev->dev_addr[i] = idprom->id_ethaddr[i];
  294. printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);
  295. /*
  296. * check (or search) IO-Memory, 32K
  297. */
  298. size = 0x8000;
  299. dev->mem_start = (unsigned long)dvma_malloc_align(0x8000, 0x1000);
  300. dev->mem_end = dev->mem_start + size;
  301. if(size != 0x2000 && size != 0x4000 && size != 0x8000) {
  302. printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 or 0x8000 bytes.\n",dev->name,size);
  303. retval = -ENODEV;
  304. goto out;
  305. }
  306. if(!check586(dev,(char *) dev->mem_start,size)) {
  307. printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
  308. retval = -ENODEV;
  309. goto out;
  310. }
  311. ((struct priv *)netdev_priv(dev))->memtop =
  312. (char *)dvma_btov(dev->mem_start);
  313. ((struct priv *)netdev_priv(dev))->base = (unsigned long) dvma_btov(0);
  314. alloc586(dev);
  315. /* set number of receive-buffs according to memsize */
  316. if(size == 0x2000)
  317. ((struct priv *)netdev_priv(dev))->num_recv_buffs =
  318. NUM_RECV_BUFFS_8;
  319. else if(size == 0x4000)
  320. ((struct priv *)netdev_priv(dev))->num_recv_buffs =
  321. NUM_RECV_BUFFS_16;
  322. else
  323. ((struct priv *)netdev_priv(dev))->num_recv_buffs =
  324. NUM_RECV_BUFFS_32;
  325. printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq);
  326. dev->netdev_ops = &sun3_82586_netdev_ops;
  327. dev->watchdog_timeo = HZ/20;
  328. dev->if_port = 0;
  329. return 0;
  330. out:
  331. release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
  332. return retval;
  333. }
  334. static int init586(struct net_device *dev)
  335. {
  336. void *ptr;
  337. int i,result=0;
  338. struct priv *p = netdev_priv(dev);
  339. volatile struct configure_cmd_struct *cfg_cmd;
  340. volatile struct iasetup_cmd_struct *ias_cmd;
  341. volatile struct tdr_cmd_struct *tdr_cmd;
  342. volatile struct mcsetup_cmd_struct *mc_cmd;
  343. struct netdev_hw_addr *ha;
  344. int num_addrs=netdev_mc_count(dev);
  345. ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
  346. cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
  347. cfg_cmd->cmd_status = 0;
  348. cfg_cmd->cmd_cmd = swab16(CMD_CONFIGURE | CMD_LAST);
  349. cfg_cmd->cmd_link = 0xffff;
  350. cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */
  351. cfg_cmd->fifo = fifo; /* fifo-limit (8=tx:32/rx:64) */
  352. cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */
  353. cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
  354. cfg_cmd->priority = 0x00;
  355. cfg_cmd->ifs = 0x60;
  356. cfg_cmd->time_low = 0x00;
  357. cfg_cmd->time_high = 0xf2;
  358. cfg_cmd->promisc = 0;
  359. if(dev->flags & IFF_ALLMULTI) {
  360. int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
  361. if(num_addrs > len) {
  362. printk("%s: switching to promisc. mode\n",dev->name);
  363. cfg_cmd->promisc = 1;
  364. }
  365. }
  366. if(dev->flags&IFF_PROMISC)
  367. cfg_cmd->promisc = 1;
  368. cfg_cmd->carr_coll = 0x00;
  369. p->scb->cbl_offset = make16(cfg_cmd);
  370. p->scb->cmd_ruc = 0;
  371. p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
  372. sun3_attn586();
  373. WAIT_4_STAT_COMPL(cfg_cmd);
  374. if((swab16(cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK))
  375. {
  376. printk("%s: configure command failed: %x\n",dev->name,swab16(cfg_cmd->cmd_status));
  377. return 1;
  378. }
  379. /*
  380. * individual address setup
  381. */
  382. ias_cmd = (struct iasetup_cmd_struct *)ptr;
  383. ias_cmd->cmd_status = 0;
  384. ias_cmd->cmd_cmd = swab16(CMD_IASETUP | CMD_LAST);
  385. ias_cmd->cmd_link = 0xffff;
  386. memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN);
  387. p->scb->cbl_offset = make16(ias_cmd);
  388. p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
  389. sun3_attn586();
  390. WAIT_4_STAT_COMPL(ias_cmd);
  391. if((swab16(ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) {
  392. printk("%s (82586): individual address setup command failed: %04x\n",dev->name,swab16(ias_cmd->cmd_status));
  393. return 1;
  394. }
  395. /*
  396. * TDR, wire check .. e.g. no resistor e.t.c
  397. */
  398. tdr_cmd = (struct tdr_cmd_struct *)ptr;
  399. tdr_cmd->cmd_status = 0;
  400. tdr_cmd->cmd_cmd = swab16(CMD_TDR | CMD_LAST);
  401. tdr_cmd->cmd_link = 0xffff;
  402. tdr_cmd->status = 0;
  403. p->scb->cbl_offset = make16(tdr_cmd);
  404. p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
  405. sun3_attn586();
  406. WAIT_4_STAT_COMPL(tdr_cmd);
  407. if(!(swab16(tdr_cmd->cmd_status) & STAT_COMPL))
  408. {
  409. printk("%s: Problems while running the TDR.\n",dev->name);
  410. }
  411. else
  412. {
  413. DELAY_16(); /* wait for result */
  414. result = swab16(tdr_cmd->status);
  415. p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
  416. sun3_attn586(); /* ack the interrupts */
  417. if(result & TDR_LNK_OK)
  418. ;
  419. else if(result & TDR_XCVR_PRB)
  420. printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name);
  421. else if(result & TDR_ET_OPN)
  422. printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
  423. else if(result & TDR_ET_SRT)
  424. {
  425. if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
  426. printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
  427. }
  428. else
  429. printk("%s: TDR: Unknown status %04x\n",dev->name,result);
  430. }
  431. /*
  432. * Multicast setup
  433. */
  434. if(num_addrs && !(dev->flags & IFF_PROMISC) )
  435. {
  436. mc_cmd = (struct mcsetup_cmd_struct *) ptr;
  437. mc_cmd->cmd_status = 0;
  438. mc_cmd->cmd_cmd = swab16(CMD_MCSETUP | CMD_LAST);
  439. mc_cmd->cmd_link = 0xffff;
  440. mc_cmd->mc_cnt = swab16(num_addrs * 6);
  441. i = 0;
  442. netdev_for_each_mc_addr(ha, dev)
  443. memcpy((char *) mc_cmd->mc_list[i++],
  444. ha->addr, ETH_ALEN);
  445. p->scb->cbl_offset = make16(mc_cmd);
  446. p->scb->cmd_cuc = CUC_START;
  447. sun3_attn586();
  448. WAIT_4_STAT_COMPL(mc_cmd);
  449. if( (swab16(mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
  450. printk("%s: Can't apply multicast-address-list.\n",dev->name);
  451. }
  452. /*
  453. * alloc nop/xmit-cmds
  454. */
  455. #if (NUM_XMIT_BUFFS == 1)
  456. for(i=0;i<2;i++)
  457. {
  458. p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
  459. p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP);
  460. p->nop_cmds[i]->cmd_status = 0;
  461. p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
  462. ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
  463. }
  464. #else
  465. for(i=0;i<NUM_XMIT_BUFFS;i++)
  466. {
  467. p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
  468. p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP);
  469. p->nop_cmds[i]->cmd_status = 0;
  470. p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
  471. ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
  472. }
  473. #endif
  474. ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */
  475. /*
  476. * alloc xmit-buffs / init xmit_cmds
  477. */
  478. for(i=0;i<NUM_XMIT_BUFFS;i++)
  479. {
  480. p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/
  481. ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
  482. p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
  483. ptr = (char *) ptr + XMIT_BUFF_SIZE;
  484. p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
  485. ptr = (char *) ptr + sizeof(struct tbd_struct);
  486. if((void *)ptr > (void *)dev->mem_end)
  487. {
  488. printk("%s: not enough shared-mem for your configuration!\n",dev->name);
  489. return 1;
  490. }
  491. memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
  492. memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
  493. p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
  494. p->xmit_cmds[i]->cmd_status = swab16(STAT_COMPL);
  495. p->xmit_cmds[i]->cmd_cmd = swab16(CMD_XMIT | CMD_INT);
  496. p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
  497. p->xmit_buffs[i]->next = 0xffff;
  498. p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
  499. }
  500. p->xmit_count = 0;
  501. p->xmit_last = 0;
  502. #ifndef NO_NOPCOMMANDS
  503. p->nop_point = 0;
  504. #endif
  505. /*
  506. * 'start transmitter'
  507. */
  508. #ifndef NO_NOPCOMMANDS
  509. p->scb->cbl_offset = make16(p->nop_cmds[0]);
  510. p->scb->cmd_cuc = CUC_START;
  511. sun3_attn586();
  512. WAIT_4_SCB_CMD();
  513. #else
  514. p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]);
  515. p->xmit_cmds[0]->cmd_cmd = swab16(CMD_XMIT | CMD_SUSPEND | CMD_INT);
  516. #endif
  517. /*
  518. * ack. interrupts
  519. */
  520. p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
  521. sun3_attn586();
  522. DELAY_16();
  523. sun3_enaint();
  524. sun3_active();
  525. return 0;
  526. }
  527. /******************************************************
  528. * This is a helper routine for sun3_82586_rnr_int() and init586().
  529. * It sets up the Receive Frame Area (RFA).
  530. */
  531. static void *alloc_rfa(struct net_device *dev,void *ptr)
  532. {
  533. volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
  534. volatile struct rbd_struct *rbd;
  535. int i;
  536. struct priv *p = netdev_priv(dev);
  537. memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
  538. p->rfd_first = rfd;
  539. for(i = 0; i < (p->num_recv_buffs+rfdadd); i++) {
  540. rfd[i].next = make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd) );
  541. rfd[i].rbd_offset = 0xffff;
  542. }
  543. rfd[p->num_recv_buffs-1+rfdadd].last = RFD_SUSP; /* RU suspend */
  544. ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd) );
  545. rbd = (struct rbd_struct *) ptr;
  546. ptr = (void *) (rbd + p->num_recv_buffs);
  547. /* clr descriptors */
  548. memset((char *) rbd,0,sizeof(struct rbd_struct)*(p->num_recv_buffs));
  549. for(i=0;i<p->num_recv_buffs;i++)
  550. {
  551. rbd[i].next = make16((rbd + (i+1) % p->num_recv_buffs));
  552. rbd[i].size = swab16(RECV_BUFF_SIZE);
  553. rbd[i].buffer = make24(ptr);
  554. ptr = (char *) ptr + RECV_BUFF_SIZE;
  555. }
  556. p->rfd_top = p->rfd_first;
  557. p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd);
  558. p->scb->rfa_offset = make16(p->rfd_first);
  559. p->rfd_first->rbd_offset = make16(rbd);
  560. return ptr;
  561. }
  562. /**************************************************
  563. * Interrupt Handler ...
  564. */
  565. static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id)
  566. {
  567. struct net_device *dev = dev_id;
  568. unsigned short stat;
  569. int cnt=0;
  570. struct priv *p;
  571. if (!dev) {
  572. printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
  573. return IRQ_NONE;
  574. }
  575. p = netdev_priv(dev);
  576. if(debuglevel > 1)
  577. printk("I");
  578. WAIT_4_SCB_CMD(); /* wait for last command */
  579. while((stat=p->scb->cus & STAT_MASK))
  580. {
  581. p->scb->cmd_cuc = stat;
  582. sun3_attn586();
  583. if(stat & STAT_FR) /* received a frame */
  584. sun3_82586_rcv_int(dev);
  585. if(stat & STAT_RNR) /* RU went 'not ready' */
  586. {
  587. printk("(R)");
  588. if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */
  589. {
  590. WAIT_4_SCB_CMD();
  591. p->scb->cmd_ruc = RUC_RESUME;
  592. sun3_attn586();
  593. WAIT_4_SCB_CMD_RUC();
  594. }
  595. else
  596. {
  597. printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
  598. sun3_82586_rnr_int(dev);
  599. }
  600. }
  601. if(stat & STAT_CX) /* command with I-bit set complete */
  602. sun3_82586_xmt_int(dev);
  603. #ifndef NO_NOPCOMMANDS
  604. if(stat & STAT_CNA) /* CU went 'not ready' */
  605. {
  606. if(netif_running(dev))
  607. printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus);
  608. }
  609. #endif
  610. if(debuglevel > 1)
  611. printk("%d",cnt++);
  612. WAIT_4_SCB_CMD(); /* wait for ack. (sun3_82586_xmt_int can be faster than ack!!) */
  613. if(p->scb->cmd_cuc) /* timed out? */
  614. {
  615. printk("%s: Acknowledge timed out.\n",dev->name);
  616. sun3_disint();
  617. break;
  618. }
  619. }
  620. if(debuglevel > 1)
  621. printk("i");
  622. return IRQ_HANDLED;
  623. }
  624. /*******************************************************
  625. * receive-interrupt
  626. */
  627. static void sun3_82586_rcv_int(struct net_device *dev)
  628. {
  629. int status,cnt=0;
  630. unsigned short totlen;
  631. struct sk_buff *skb;
  632. struct rbd_struct *rbd;
  633. struct priv *p = netdev_priv(dev);
  634. if(debuglevel > 0)
  635. printk("R");
  636. for(;(status = p->rfd_top->stat_high) & RFD_COMPL;)
  637. {
  638. rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
  639. if(status & RFD_OK) /* frame received without error? */
  640. {
  641. if( (totlen = swab16(rbd->status)) & RBD_LAST) /* the first and the last buffer? */
  642. {
  643. totlen &= RBD_MASK; /* length of this frame */
  644. rbd->status = 0;
  645. skb = (struct sk_buff *) dev_alloc_skb(totlen+2);
  646. if(skb != NULL)
  647. {
  648. skb_reserve(skb,2);
  649. skb_put(skb,totlen);
  650. skb_copy_to_linear_data(skb,(char *) p->base+swab32((unsigned long) rbd->buffer),totlen);
  651. skb->protocol=eth_type_trans(skb,dev);
  652. netif_rx(skb);
  653. dev->stats.rx_packets++;
  654. }
  655. else
  656. dev->stats.rx_dropped++;
  657. }
  658. else
  659. {
  660. int rstat;
  661. /* free all RBD's until RBD_LAST is set */
  662. totlen = 0;
  663. while(!((rstat=swab16(rbd->status)) & RBD_LAST))
  664. {
  665. totlen += rstat & RBD_MASK;
  666. if(!rstat)
  667. {
  668. printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
  669. break;
  670. }
  671. rbd->status = 0;
  672. rbd = (struct rbd_struct *) make32(rbd->next);
  673. }
  674. totlen += rstat & RBD_MASK;
  675. rbd->status = 0;
  676. printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
  677. dev->stats.rx_dropped++;
  678. }
  679. }
  680. else /* frame !(ok), only with 'save-bad-frames' */
  681. {
  682. printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
  683. dev->stats.rx_errors++;
  684. }
  685. p->rfd_top->stat_high = 0;
  686. p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */
  687. p->rfd_top->rbd_offset = 0xffff;
  688. p->rfd_last->last = 0; /* delete RFD_SUSP */
  689. p->rfd_last = p->rfd_top;
  690. p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
  691. p->scb->rfa_offset = make16(p->rfd_top);
  692. if(debuglevel > 0)
  693. printk("%d",cnt++);
  694. }
  695. if(automatic_resume)
  696. {
  697. WAIT_4_SCB_CMD();
  698. p->scb->cmd_ruc = RUC_RESUME;
  699. sun3_attn586();
  700. WAIT_4_SCB_CMD_RUC();
  701. }
  702. #ifdef WAIT_4_BUSY
  703. {
  704. int i;
  705. for(i=0;i<1024;i++)
  706. {
  707. if(p->rfd_top->status)
  708. break;
  709. DELAY_16();
  710. if(i == 1023)
  711. printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name);
  712. }
  713. }
  714. #endif
  715. #if 0
  716. if(!at_least_one)
  717. {
  718. int i;
  719. volatile struct rfd_struct *rfds=p->rfd_top;
  720. volatile struct rbd_struct *rbds;
  721. printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
  722. for(i=0;i< (p->num_recv_buffs+4);i++)
  723. {
  724. rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
  725. printk("%04x:%04x ",rfds->status,rbds->status);
  726. rfds = (struct rfd_struct *) make32(rfds->next);
  727. }
  728. printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
  729. printk("\nerrs: %04x %04x rus: %02x, cus: %02x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->rus,(int)p->scb->cus);
  730. }
  731. old_at_least = at_least_one;
  732. #endif
  733. if(debuglevel > 0)
  734. printk("r");
  735. }
  736. /**********************************************************
  737. * handle 'Receiver went not ready'.
  738. */
  739. static void sun3_82586_rnr_int(struct net_device *dev)
  740. {
  741. struct priv *p = netdev_priv(dev);
  742. dev->stats.rx_errors++;
  743. WAIT_4_SCB_CMD(); /* wait for the last cmd, WAIT_4_FULLSTAT?? */
  744. p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
  745. sun3_attn586();
  746. WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. */
  747. alloc_rfa(dev,(char *)p->rfd_first);
  748. /* maybe add a check here, before restarting the RU */
  749. startrecv586(dev); /* restart RU */
  750. printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus);
  751. }
  752. /**********************************************************
  753. * handle xmit - interrupt
  754. */
  755. static void sun3_82586_xmt_int(struct net_device *dev)
  756. {
  757. int status;
  758. struct priv *p = netdev_priv(dev);
  759. if(debuglevel > 0)
  760. printk("X");
  761. status = swab16(p->xmit_cmds[p->xmit_last]->cmd_status);
  762. if(!(status & STAT_COMPL))
  763. printk("%s: strange .. xmit-int without a 'COMPLETE'\n",dev->name);
  764. if(status & STAT_OK)
  765. {
  766. dev->stats.tx_packets++;
  767. dev->stats.collisions += (status & TCMD_MAXCOLLMASK);
  768. }
  769. else
  770. {
  771. dev->stats.tx_errors++;
  772. if(status & TCMD_LATECOLL) {
  773. printk("%s: late collision detected.\n",dev->name);
  774. dev->stats.collisions++;
  775. }
  776. else if(status & TCMD_NOCARRIER) {
  777. dev->stats.tx_carrier_errors++;
  778. printk("%s: no carrier detected.\n",dev->name);
  779. }
  780. else if(status & TCMD_LOSTCTS)
  781. printk("%s: loss of CTS detected.\n",dev->name);
  782. else if(status & TCMD_UNDERRUN) {
  783. dev->stats.tx_fifo_errors++;
  784. printk("%s: DMA underrun detected.\n",dev->name);
  785. }
  786. else if(status & TCMD_MAXCOLL) {
  787. printk("%s: Max. collisions exceeded.\n",dev->name);
  788. dev->stats.collisions += 16;
  789. }
  790. }
  791. #if (NUM_XMIT_BUFFS > 1)
  792. if( (++p->xmit_last) == NUM_XMIT_BUFFS)
  793. p->xmit_last = 0;
  794. #endif
  795. netif_wake_queue(dev);
  796. }
  797. /***********************************************************
  798. * (re)start the receiver
  799. */
  800. static void startrecv586(struct net_device *dev)
  801. {
  802. struct priv *p = netdev_priv(dev);
  803. WAIT_4_SCB_CMD();
  804. WAIT_4_SCB_CMD_RUC();
  805. p->scb->rfa_offset = make16(p->rfd_first);
  806. p->scb->cmd_ruc = RUC_START;
  807. sun3_attn586(); /* start cmd. */
  808. WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. (no timeout!!) */
  809. }
  810. static void sun3_82586_timeout(struct net_device *dev)
  811. {
  812. struct priv *p = netdev_priv(dev);
  813. #ifndef NO_NOPCOMMANDS
  814. if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
  815. {
  816. netif_wake_queue(dev);
  817. #ifdef DEBUG
  818. printk("%s: strange ... timeout with CU active?!?\n",dev->name);
  819. printk("%s: X0: %04x N0: %04x N1: %04x %d\n",dev->name,(int)swab16(p->xmit_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[1]->cmd_status),(int)p->nop_point);
  820. #endif
  821. p->scb->cmd_cuc = CUC_ABORT;
  822. sun3_attn586();
  823. WAIT_4_SCB_CMD();
  824. p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
  825. p->scb->cmd_cuc = CUC_START;
  826. sun3_attn586();
  827. WAIT_4_SCB_CMD();
  828. dev->trans_start = jiffies; /* prevent tx timeout */
  829. return 0;
  830. }
  831. #endif
  832. {
  833. #ifdef DEBUG
  834. printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
  835. printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
  836. printk("%s: check, whether you set the right interrupt number!\n",dev->name);
  837. #endif
  838. sun3_82586_close(dev);
  839. sun3_82586_open(dev);
  840. }
  841. dev->trans_start = jiffies; /* prevent tx timeout */
  842. }
  843. /******************************************************
  844. * send frame
  845. */
  846. static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
  847. {
  848. int len,i;
  849. #ifndef NO_NOPCOMMANDS
  850. int next_nop;
  851. #endif
  852. struct priv *p = netdev_priv(dev);
  853. if(skb->len > XMIT_BUFF_SIZE)
  854. {
  855. printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
  856. return NETDEV_TX_OK;
  857. }
  858. netif_stop_queue(dev);
  859. #if(NUM_XMIT_BUFFS > 1)
  860. if(test_and_set_bit(0,(void *) &p->lock)) {
  861. printk("%s: Queue was locked\n",dev->name);
  862. return NETDEV_TX_BUSY;
  863. }
  864. else
  865. #endif
  866. {
  867. len = skb->len;
  868. if (len < ETH_ZLEN) {
  869. memset((void *)p->xmit_cbuffs[p->xmit_count], 0,
  870. ETH_ZLEN);
  871. len = ETH_ZLEN;
  872. }
  873. skb_copy_from_linear_data(skb, (void *)p->xmit_cbuffs[p->xmit_count], skb->len);
  874. #if (NUM_XMIT_BUFFS == 1)
  875. # ifdef NO_NOPCOMMANDS
  876. #ifdef DEBUG
  877. if(p->scb->cus & CU_ACTIVE)
  878. {
  879. printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name);
  880. printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,swab16(p->xmit_cmds[0]->cmd_status));
  881. }
  882. #endif
  883. p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
  884. for(i=0;i<16;i++)
  885. {
  886. p->xmit_cmds[0]->cmd_status = 0;
  887. WAIT_4_SCB_CMD();
  888. if( (p->scb->cus & CU_STATUS) == CU_SUSPEND)
  889. p->scb->cmd_cuc = CUC_RESUME;
  890. else
  891. {
  892. p->scb->cbl_offset = make16(p->xmit_cmds[0]);
  893. p->scb->cmd_cuc = CUC_START;
  894. }
  895. sun3_attn586();
  896. if(!i)
  897. dev_kfree_skb(skb);
  898. WAIT_4_SCB_CMD();
  899. if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
  900. break;
  901. if(p->xmit_cmds[0]->cmd_status)
  902. break;
  903. if(i==15)
  904. printk("%s: Can't start transmit-command.\n",dev->name);
  905. }
  906. # else
  907. next_nop = (p->nop_point + 1) & 0x1;
  908. p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
  909. p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link
  910. = make16((p->nop_cmds[next_nop]));
  911. p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
  912. p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
  913. p->nop_point = next_nop;
  914. dev_kfree_skb(skb);
  915. # endif
  916. #else
  917. p->xmit_buffs[p->xmit_count]->size = swab16(TBD_LAST | len);
  918. if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
  919. next_nop = 0;
  920. p->xmit_cmds[p->xmit_count]->cmd_status = 0;
  921. /* linkpointer of xmit-command already points to next nop cmd */
  922. p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop]));
  923. p->nop_cmds[next_nop]->cmd_status = 0;
  924. p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
  925. p->xmit_count = next_nop;
  926. {
  927. unsigned long flags;
  928. local_irq_save(flags);
  929. if(p->xmit_count != p->xmit_last)
  930. netif_wake_queue(dev);
  931. p->lock = 0;
  932. local_irq_restore(flags);
  933. }
  934. dev_kfree_skb(skb);
  935. #endif
  936. }
  937. return NETDEV_TX_OK;
  938. }
  939. /*******************************************
  940. * Someone wanna have the statistics
  941. */
  942. static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev)
  943. {
  944. struct priv *p = netdev_priv(dev);
  945. unsigned short crc,aln,rsc,ovrn;
  946. crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */
  947. p->scb->crc_errs = 0;
  948. aln = swab16(p->scb->aln_errs);
  949. p->scb->aln_errs = 0;
  950. rsc = swab16(p->scb->rsc_errs);
  951. p->scb->rsc_errs = 0;
  952. ovrn = swab16(p->scb->ovrn_errs);
  953. p->scb->ovrn_errs = 0;
  954. dev->stats.rx_crc_errors += crc;
  955. dev->stats.rx_fifo_errors += ovrn;
  956. dev->stats.rx_frame_errors += aln;
  957. dev->stats.rx_dropped += rsc;
  958. return &dev->stats;
  959. }
  960. /********************************************************
  961. * Set MC list ..
  962. */
  963. static void set_multicast_list(struct net_device *dev)
  964. {
  965. netif_stop_queue(dev);
  966. sun3_disint();
  967. alloc586(dev);
  968. init586(dev);
  969. startrecv586(dev);
  970. sun3_enaint();
  971. netif_wake_queue(dev);
  972. }
  973. #ifdef MODULE
  974. #error This code is not currently supported as a module
  975. static struct net_device *dev_sun3_82586;
  976. int init_module(void)
  977. {
  978. dev_sun3_82586 = sun3_82586_probe(-1);
  979. if (IS_ERR(dev_sun3_82586))
  980. return PTR_ERR(dev_sun3_82586);
  981. return 0;
  982. }
  983. void cleanup_module(void)
  984. {
  985. unsigned long ioaddr = dev_sun3_82586->base_addr;
  986. unregister_netdev(dev_sun3_82586);
  987. release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
  988. iounmap((void *)ioaddr);
  989. free_netdev(dev_sun3_82586);
  990. }
  991. #endif /* MODULE */
  992. #if 0
  993. /*
  994. * DUMP .. we expect a not running CMD unit and enough space
  995. */
  996. void sun3_82586_dump(struct net_device *dev,void *ptr)
  997. {
  998. struct priv *p = netdev_priv(dev);
  999. struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
  1000. int i;
  1001. p->scb->cmd_cuc = CUC_ABORT;
  1002. sun3_attn586();
  1003. WAIT_4_SCB_CMD();
  1004. WAIT_4_SCB_CMD_RUC();
  1005. dump_cmd->cmd_status = 0;
  1006. dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
  1007. dump_cmd->dump_offset = make16((dump_cmd + 1));
  1008. dump_cmd->cmd_link = 0xffff;
  1009. p->scb->cbl_offset = make16(dump_cmd);
  1010. p->scb->cmd_cuc = CUC_START;
  1011. sun3_attn586();
  1012. WAIT_4_STAT_COMPL(dump_cmd);
  1013. if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
  1014. printk("%s: Can't get dump information.\n",dev->name);
  1015. for(i=0;i<170;i++) {
  1016. printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
  1017. if(i % 24 == 23)
  1018. printk("\n");
  1019. }
  1020. printk("\n");
  1021. }
  1022. #endif
  1023. MODULE_LICENSE("GPL");