sun3_82586.c 32 KB

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