atari_bionet.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /* bionet.c BioNet-100 device driver for linux68k.
  2. *
  3. * Version: @(#)bionet.c 1.0 02/06/96
  4. *
  5. * Author: Hartmut Laue <laue@ifk-mp.uni-kiel.de>
  6. * and Torsten Narjes <narjes@ifk-mp.uni-kiel.de>
  7. *
  8. * Little adaptions for integration into pl7 by Roman Hodek
  9. *
  10. * Some changes in bionet_poll_rx by Karl-Heinz Lohner
  11. *
  12. What is it ?
  13. ------------
  14. This driver controls the BIONET-100 LAN-Adapter which connects
  15. an ATARI ST/TT via the ACSI-port to an Ethernet-based network.
  16. This version can be compiled as a loadable module (See the
  17. compile command at the bottom of this file).
  18. At load time, you can optionally set the debugging level and the
  19. fastest response time on the command line of 'insmod'.
  20. 'bionet_debug'
  21. controls the amount of diagnostic messages:
  22. 0 : no messages
  23. >0 : see code for meaning of printed messages
  24. 'bionet_min_poll_time' (always >=1)
  25. gives the time (in jiffies) between polls. Low values
  26. increase the system load (beware!)
  27. When loaded, a net device with the name 'bio0' becomes available,
  28. which can be controlled with the usual 'ifconfig' command.
  29. It is possible to compile this driver into the kernel like other
  30. (net) drivers. For this purpose, some source files (e.g. config-files
  31. makefiles, Space.c) must be changed accordingly. (You may refer to
  32. other drivers how to do it.) In this case, the device will be detected
  33. at boot time and (probably) appear as 'eth0'.
  34. This code is based on several sources:
  35. - The driver code for a parallel port ethernet adapter by
  36. Donald Becker (see file 'atp.c' from the PC linux distribution)
  37. - The ACSI code by Roman Hodek for the ATARI-ACSI harddisk support
  38. and DMA handling.
  39. - Very limited information about moving packets in and out of the
  40. BIONET-adapter from the TCP package for TOS by BioData GmbH.
  41. Theory of Operation
  42. -------------------
  43. Because the ATARI DMA port is usually shared between several
  44. devices (eg. harddisk, floppy) we cannot block the ACSI bus
  45. while waiting for interrupts. Therefore we use a polling mechanism
  46. to fetch packets from the adapter. For the same reason, we send
  47. packets without checking that the previous packet has been sent to
  48. the LAN. We rely on the higher levels of the networking code to detect
  49. missing packets and resend them.
  50. Before we access the ATARI DMA controller, we check if another
  51. process is using the DMA. If not, we lock the DMA, perform one or
  52. more packet transfers and unlock the DMA before returning.
  53. We do not use 'stdma_lock' unconditionally because it is unclear
  54. if the networking code can be set to sleep, which will happen if
  55. another (possibly slow) device is using the DMA controller.
  56. The polling is done via timer interrupts which periodically
  57. 'simulate' an interrupt from the Ethernet adapter. The time (in jiffies)
  58. between polls varies depending on an estimate of the net activity.
  59. The allowed range is given by the variable 'bionet_min_poll_time'
  60. for the lower (fastest) limit and the constant 'MAX_POLL_TIME'
  61. for the higher (slowest) limit.
  62. Whenever a packet arrives, we switch to fastest response by setting
  63. the polling time to its lowest limit. If the following poll fails,
  64. because no packets have arrived, we increase the time for the next
  65. poll. When the net activity is low, the polling time effectively
  66. stays at its maximum value, resulting in the lowest load for the
  67. machine.
  68. */
  69. #define MAX_POLL_TIME 10
  70. static char version[] =
  71. "bionet.c:v1.0 06-feb-96 (c) Hartmut Laue.\n";
  72. #include <linux/module.h>
  73. #include <linux/errno.h>
  74. #include <linux/kernel.h>
  75. #include <linux/jiffies.h>
  76. #include <linux/types.h>
  77. #include <linux/fcntl.h>
  78. #include <linux/interrupt.h>
  79. #include <linux/ioport.h>
  80. #include <linux/in.h>
  81. #include <linux/slab.h>
  82. #include <linux/string.h>
  83. #include <linux/delay.h>
  84. #include <linux/timer.h>
  85. #include <linux/init.h>
  86. #include <linux/bitops.h>
  87. #include <linux/netdevice.h>
  88. #include <linux/etherdevice.h>
  89. #include <linux/skbuff.h>
  90. #include <asm/setup.h>
  91. #include <asm/pgtable.h>
  92. #include <asm/system.h>
  93. #include <asm/io.h>
  94. #include <asm/dma.h>
  95. #include <asm/atarihw.h>
  96. #include <asm/atariints.h>
  97. #include <asm/atari_acsi.h>
  98. #include <asm/atari_stdma.h>
  99. /* use 0 for production, 1 for verification, >2 for debug
  100. */
  101. #ifndef NET_DEBUG
  102. #define NET_DEBUG 0
  103. #endif
  104. /*
  105. * Global variable 'bionet_debug'. Can be set at load time by 'insmod'
  106. */
  107. unsigned int bionet_debug = NET_DEBUG;
  108. module_param(bionet_debug, int, 0);
  109. MODULE_PARM_DESC(bionet_debug, "bionet debug level (0-2)");
  110. MODULE_LICENSE("GPL");
  111. static unsigned int bionet_min_poll_time = 2;
  112. /* Information that need to be kept for each board.
  113. */
  114. struct net_local {
  115. struct net_device_stats stats;
  116. long open_time; /* for debugging */
  117. int poll_time; /* polling time varies with net load */
  118. };
  119. static struct nic_pkt_s { /* packet format */
  120. unsigned char status;
  121. unsigned char dummy;
  122. unsigned char l_lo, l_hi;
  123. unsigned char buffer[3000];
  124. } *nic_packet;
  125. unsigned char *phys_nic_packet;
  126. /* Index to functions, as function prototypes.
  127. */
  128. static int bionet_open(struct net_device *dev);
  129. static int bionet_send_packet(struct sk_buff *skb, struct net_device *dev);
  130. static void bionet_poll_rx(struct net_device *);
  131. static int bionet_close(struct net_device *dev);
  132. static struct net_device_stats *net_get_stats(struct net_device *dev);
  133. static void bionet_tick(unsigned long);
  134. static DEFINE_TIMER(bionet_timer, bionet_tick, 0, 0);
  135. #define STRAM_ADDR(a) (((a) & 0xff000000) == 0)
  136. /* The following routines access the ethernet board connected to the
  137. * ACSI port via the st_dma chip.
  138. */
  139. #define NODE_ADR 0x60
  140. #define C_READ 8
  141. #define C_WRITE 0x0a
  142. #define C_GETEA 0x0f
  143. #define C_SETCR 0x0e
  144. static int
  145. sendcmd(unsigned int a0, unsigned int mod, unsigned int cmd) {
  146. unsigned int c;
  147. dma_wd.dma_mode_status = (mod | ((a0) ? 2 : 0) | 0x88);
  148. dma_wd.fdc_acces_seccount = cmd;
  149. dma_wd.dma_mode_status = (mod | 0x8a);
  150. if( !acsi_wait_for_IRQ(HZ/2) ) /* wait for cmd ack */
  151. return -1; /* timeout */
  152. c = dma_wd.fdc_acces_seccount;
  153. return (c & 0xff);
  154. }
  155. static void
  156. set_status(int cr) {
  157. sendcmd(0,0x100,NODE_ADR | C_SETCR); /* CMD: SET CR */
  158. sendcmd(1,0x100,cr);
  159. dma_wd.dma_mode_status = 0x80;
  160. }
  161. static int
  162. get_status(unsigned char *adr) {
  163. int i,c;
  164. DISABLE_IRQ();
  165. c = sendcmd(0,0x00,NODE_ADR | C_GETEA); /* CMD: GET ETH ADR*/
  166. if( c < 0 ) goto gsend;
  167. /* now read status bytes */
  168. for (i=0; i<6; i++) {
  169. dma_wd.fdc_acces_seccount = 0; /* request next byte */
  170. if( !acsi_wait_for_IRQ(HZ/2) ) { /* wait for cmd ack */
  171. c = -1;
  172. goto gsend; /* timeout */
  173. }
  174. c = dma_wd.fdc_acces_seccount;
  175. *adr++ = (unsigned char)c;
  176. }
  177. c = 1;
  178. gsend:
  179. dma_wd.dma_mode_status = 0x80;
  180. return c;
  181. }
  182. static irqreturn_t
  183. bionet_intr(int irq, void *data) {
  184. return IRQ_HANDLED;
  185. }
  186. static int
  187. get_frame(unsigned long paddr, int odd) {
  188. int c;
  189. unsigned long flags;
  190. DISABLE_IRQ();
  191. local_irq_save(flags);
  192. dma_wd.dma_mode_status = 0x9a;
  193. dma_wd.dma_mode_status = 0x19a;
  194. dma_wd.dma_mode_status = 0x9a;
  195. dma_wd.fdc_acces_seccount = 0x04; /* sector count (was 5) */
  196. dma_wd.dma_lo = (unsigned char)paddr;
  197. paddr >>= 8;
  198. dma_wd.dma_md = (unsigned char)paddr;
  199. paddr >>= 8;
  200. dma_wd.dma_hi = (unsigned char)paddr;
  201. local_irq_restore(flags);
  202. c = sendcmd(0,0x00,NODE_ADR | C_READ); /* CMD: READ */
  203. if( c < 128 ) goto rend;
  204. /* now read block */
  205. c = sendcmd(1,0x00,odd); /* odd flag for address shift */
  206. dma_wd.dma_mode_status = 0x0a;
  207. if( !acsi_wait_for_IRQ(100) ) { /* wait for DMA to complete */
  208. c = -1;
  209. goto rend;
  210. }
  211. dma_wd.dma_mode_status = 0x8a;
  212. dma_wd.dma_mode_status = 0x18a;
  213. dma_wd.dma_mode_status = 0x8a;
  214. c = dma_wd.fdc_acces_seccount;
  215. dma_wd.dma_mode_status = 0x88;
  216. c = dma_wd.fdc_acces_seccount;
  217. c = 1;
  218. rend:
  219. dma_wd.dma_mode_status = 0x80;
  220. udelay(40);
  221. acsi_wait_for_noIRQ(20);
  222. return c;
  223. }
  224. static int
  225. hardware_send_packet(unsigned long paddr, int cnt) {
  226. unsigned int c;
  227. unsigned long flags;
  228. DISABLE_IRQ();
  229. local_irq_save(flags);
  230. dma_wd.dma_mode_status = 0x19a;
  231. dma_wd.dma_mode_status = 0x9a;
  232. dma_wd.dma_mode_status = 0x19a;
  233. dma_wd.dma_lo = (unsigned char)paddr;
  234. paddr >>= 8;
  235. dma_wd.dma_md = (unsigned char)paddr;
  236. paddr >>= 8;
  237. dma_wd.dma_hi = (unsigned char)paddr;
  238. dma_wd.fdc_acces_seccount = 0x4; /* sector count */
  239. local_irq_restore(flags);
  240. c = sendcmd(0,0x100,NODE_ADR | C_WRITE); /* CMD: WRITE */
  241. c = sendcmd(1,0x100,cnt&0xff);
  242. c = sendcmd(1,0x100,cnt>>8);
  243. /* now write block */
  244. dma_wd.dma_mode_status = 0x10a; /* DMA enable */
  245. if( !acsi_wait_for_IRQ(100) ) /* wait for DMA to complete */
  246. goto end;
  247. dma_wd.dma_mode_status = 0x19a; /* DMA disable ! */
  248. c = dma_wd.fdc_acces_seccount;
  249. end:
  250. c = sendcmd(1,0x100,0);
  251. c = sendcmd(1,0x100,0);
  252. dma_wd.dma_mode_status = 0x180;
  253. udelay(40);
  254. acsi_wait_for_noIRQ(20);
  255. return( c & 0x02);
  256. }
  257. /* Check for a network adaptor of this type, and return '0' if one exists.
  258. */
  259. struct net_device * __init bionet_probe(int unit)
  260. {
  261. struct net_device *dev;
  262. unsigned char station_addr[6];
  263. static unsigned version_printed;
  264. static int no_more_found; /* avoid "Probing for..." printed 4 times */
  265. int i;
  266. int err;
  267. if (!MACH_IS_ATARI || no_more_found)
  268. return ERR_PTR(-ENODEV);
  269. dev = alloc_etherdev(sizeof(struct net_local));
  270. if (!dev)
  271. return ERR_PTR(-ENOMEM);
  272. if (unit >= 0) {
  273. sprintf(dev->name, "eth%d", unit);
  274. netdev_boot_setup_check(dev);
  275. }
  276. SET_MODULE_OWNER(dev);
  277. printk("Probing for BioNet 100 Adapter...\n");
  278. stdma_lock(bionet_intr, NULL);
  279. i = get_status(station_addr); /* Read the station address PROM. */
  280. ENABLE_IRQ();
  281. stdma_release();
  282. /* Check the first three octets of the S.A. for the manufactor's code.
  283. */
  284. if( i < 0
  285. || station_addr[0] != 'B'
  286. || station_addr[1] != 'I'
  287. || station_addr[2] != 'O' ) {
  288. no_more_found = 1;
  289. printk( "No BioNet 100 found.\n" );
  290. free_netdev(dev);
  291. return ERR_PTR(-ENODEV);
  292. }
  293. if (bionet_debug > 0 && version_printed++ == 0)
  294. printk(version);
  295. printk("%s: %s found, eth-addr: %02x-%02x-%02x:%02x-%02x-%02x.\n",
  296. dev->name, "BioNet 100",
  297. station_addr[0], station_addr[1], station_addr[2],
  298. station_addr[3], station_addr[4], station_addr[5]);
  299. /* Initialize the device structure. */
  300. nic_packet = (struct nic_pkt_s *)acsi_buffer;
  301. phys_nic_packet = (unsigned char *)phys_acsi_buffer;
  302. if (bionet_debug > 0) {
  303. printk("nic_packet at 0x%p, phys at 0x%p\n",
  304. nic_packet, phys_nic_packet );
  305. }
  306. dev->open = bionet_open;
  307. dev->stop = bionet_close;
  308. dev->hard_start_xmit = bionet_send_packet;
  309. dev->get_stats = net_get_stats;
  310. /* Fill in the fields of the device structure with ethernet-generic
  311. * values. This should be in a common file instead of per-driver.
  312. */
  313. for (i = 0; i < ETH_ALEN; i++) {
  314. #if 0
  315. dev->broadcast[i] = 0xff;
  316. #endif
  317. dev->dev_addr[i] = station_addr[i];
  318. }
  319. err = register_netdev(dev);
  320. if (!err)
  321. return dev;
  322. free_netdev(dev);
  323. return ERR_PTR(err);
  324. }
  325. /* Open/initialize the board. This is called (in the current kernel)
  326. sometime after booting when the 'ifconfig' program is run.
  327. This routine should set everything up anew at each open, even
  328. registers that "should" only need to be set once at boot, so that
  329. there is non-reboot way to recover if something goes wrong.
  330. */
  331. static int
  332. bionet_open(struct net_device *dev) {
  333. struct net_local *lp = netdev_priv(dev);
  334. if (bionet_debug > 0)
  335. printk("bionet_open\n");
  336. stdma_lock(bionet_intr, NULL);
  337. /* Reset the hardware here.
  338. */
  339. set_status(4);
  340. lp->open_time = 0; /*jiffies*/
  341. lp->poll_time = MAX_POLL_TIME;
  342. dev->tbusy = 0;
  343. dev->interrupt = 0;
  344. dev->start = 1;
  345. stdma_release();
  346. bionet_timer.data = (long)dev;
  347. bionet_timer.expires = jiffies + lp->poll_time;
  348. add_timer(&bionet_timer);
  349. return 0;
  350. }
  351. static int
  352. bionet_send_packet(struct sk_buff *skb, struct net_device *dev) {
  353. struct net_local *lp = netdev_priv(dev);
  354. unsigned long flags;
  355. /* Block a timer-based transmit from overlapping. This could better be
  356. * done with atomic_swap(1, dev->tbusy), but set_bit() works as well.
  357. */
  358. local_irq_save(flags);
  359. if (stdma_islocked()) {
  360. local_irq_restore(flags);
  361. lp->stats.tx_errors++;
  362. }
  363. else {
  364. int length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
  365. unsigned long buf = virt_to_phys(skb->data);
  366. int stat;
  367. stdma_lock(bionet_intr, NULL);
  368. local_irq_restore(flags);
  369. if( !STRAM_ADDR(buf+length-1) ) {
  370. memcpy(nic_packet->buffer, skb->data, length);
  371. buf = (unsigned long)&((struct nic_pkt_s *)phys_nic_packet)->buffer;
  372. }
  373. if (bionet_debug >1) {
  374. u_char *data = nic_packet->buffer, *p;
  375. int i;
  376. printk( "%s: TX pkt type 0x%4x from ", dev->name,
  377. ((u_short *)data)[6]);
  378. for( p = &data[6], i = 0; i < 6; i++ )
  379. printk("%02x%s", *p++,i != 5 ? ":" : "" );
  380. printk(" to ");
  381. for( p = data, i = 0; i < 6; i++ )
  382. printk("%02x%s", *p++,i != 5 ? ":" : "" "\n" );
  383. printk( "%s: ", dev->name );
  384. printk(" data %02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x"
  385. " %02x%02x%02x%02x len %d\n",
  386. data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19],
  387. data[20], data[21], data[22], data[23], data[24], data[25], data[26], data[27],
  388. data[28], data[29], data[30], data[31], data[32], data[33],
  389. length );
  390. }
  391. dma_cache_maintenance(buf, length, 1);
  392. stat = hardware_send_packet(buf, length);
  393. ENABLE_IRQ();
  394. stdma_release();
  395. dev->trans_start = jiffies;
  396. dev->tbusy = 0;
  397. lp->stats.tx_packets++;
  398. lp->stats.tx_bytes+=length;
  399. }
  400. dev_kfree_skb(skb);
  401. return 0;
  402. }
  403. /* We have a good packet(s), get it/them out of the buffers.
  404. */
  405. static void
  406. bionet_poll_rx(struct net_device *dev) {
  407. struct net_local *lp = netdev_priv(dev);
  408. int boguscount = 10;
  409. int pkt_len, status;
  410. unsigned long flags;
  411. local_irq_save(flags);
  412. /* ++roman: Take care at locking the ST-DMA... This must be done with ints
  413. * off, since otherwise an int could slip in between the question and the
  414. * locking itself, and then we'd go to sleep... And locking itself is
  415. * necessary to keep the floppy_change timer from working with ST-DMA
  416. * registers. */
  417. if (stdma_islocked()) {
  418. local_irq_restore(flags);
  419. return;
  420. }
  421. stdma_lock(bionet_intr, NULL);
  422. DISABLE_IRQ();
  423. local_irq_restore(flags);
  424. if( lp->poll_time < MAX_POLL_TIME ) lp->poll_time++;
  425. while(boguscount--) {
  426. status = get_frame((unsigned long)phys_nic_packet, 0);
  427. if( status == 0 ) break;
  428. /* Good packet... */
  429. dma_cache_maintenance((unsigned long)phys_nic_packet, 1520, 0);
  430. pkt_len = (nic_packet->l_hi << 8) | nic_packet->l_lo;
  431. lp->poll_time = bionet_min_poll_time; /* fast poll */
  432. if( pkt_len >= 60 && pkt_len <= 1520 ) {
  433. /* ^^^^ war 1514 KHL */
  434. /* Malloc up new buffer.
  435. */
  436. struct sk_buff *skb = dev_alloc_skb( pkt_len + 2 );
  437. if (skb == NULL) {
  438. printk("%s: Memory squeeze, dropping packet.\n",
  439. dev->name);
  440. lp->stats.rx_dropped++;
  441. break;
  442. }
  443. skb->dev = dev;
  444. skb_reserve( skb, 2 ); /* 16 Byte align */
  445. skb_put( skb, pkt_len ); /* make room */
  446. /* 'skb->data' points to the start of sk_buff data area.
  447. */
  448. memcpy(skb->data, nic_packet->buffer, pkt_len);
  449. skb->protocol = eth_type_trans( skb, dev );
  450. netif_rx(skb);
  451. dev->last_rx = jiffies;
  452. lp->stats.rx_packets++;
  453. lp->stats.rx_bytes+=pkt_len;
  454. /* If any worth-while packets have been received, dev_rint()
  455. has done a mark_bh(INET_BH) for us and will work on them
  456. when we get to the bottom-half routine.
  457. */
  458. if (bionet_debug >1) {
  459. u_char *data = nic_packet->buffer, *p;
  460. int i;
  461. printk( "%s: RX pkt type 0x%4x from ", dev->name,
  462. ((u_short *)data)[6]);
  463. for( p = &data[6], i = 0; i < 6; i++ )
  464. printk("%02x%s", *p++,i != 5 ? ":" : "" );
  465. printk(" to ");
  466. for( p = data, i = 0; i < 6; i++ )
  467. printk("%02x%s", *p++,i != 5 ? ":" : "" "\n" );
  468. printk( "%s: ", dev->name );
  469. printk(" data %02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x"
  470. " %02x%02x%02x%02x len %d\n",
  471. data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19],
  472. data[20], data[21], data[22], data[23], data[24], data[25], data[26], data[27],
  473. data[28], data[29], data[30], data[31], data[32], data[33],
  474. pkt_len );
  475. }
  476. }
  477. else {
  478. printk(" Packet has wrong length: %04d bytes\n", pkt_len);
  479. lp->stats.rx_errors++;
  480. }
  481. }
  482. stdma_release();
  483. ENABLE_IRQ();
  484. return;
  485. }
  486. /* bionet_tick: called by bionet_timer. Reads packets from the adapter,
  487. * passes them to the higher layers and restarts the timer.
  488. */
  489. static void
  490. bionet_tick(unsigned long data) {
  491. struct net_device *dev = (struct net_device *)data;
  492. struct net_local *lp = netdev_priv(dev);
  493. if( bionet_debug > 0 && (lp->open_time++ & 7) == 8 )
  494. printk("bionet_tick: %ld\n", lp->open_time);
  495. if( !stdma_islocked() ) bionet_poll_rx(dev);
  496. bionet_timer.expires = jiffies + lp->poll_time;
  497. add_timer(&bionet_timer);
  498. }
  499. /* The inverse routine to bionet_open().
  500. */
  501. static int
  502. bionet_close(struct net_device *dev) {
  503. struct net_local *lp = netdev_priv(dev);
  504. if (bionet_debug > 0)
  505. printk("bionet_close, open_time=%ld\n", lp->open_time);
  506. del_timer(&bionet_timer);
  507. stdma_lock(bionet_intr, NULL);
  508. set_status(0);
  509. lp->open_time = 0;
  510. dev->tbusy = 1;
  511. dev->start = 0;
  512. stdma_release();
  513. return 0;
  514. }
  515. /* Get the current statistics.
  516. This may be called with the card open or closed.
  517. */
  518. static struct net_device_stats *net_get_stats(struct net_device *dev)
  519. {
  520. struct net_local *lp = netdev_priv(dev);
  521. return &lp->stats;
  522. }
  523. #ifdef MODULE
  524. static struct net_device *bio_dev;
  525. int init_module(void)
  526. {
  527. bio_dev = bionet_probe(-1);
  528. if (IS_ERR(bio_dev))
  529. return PTR_ERR(bio_dev);
  530. return 0;
  531. }
  532. void cleanup_module(void)
  533. {
  534. unregister_netdev(bio_dev);
  535. free_netdev(bio_dev);
  536. }
  537. #endif /* MODULE */
  538. /* Local variables:
  539. * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/include
  540. -b m68k-linuxaout -Wall -Wstrict-prototypes -O2
  541. -fomit-frame-pointer -pipe -DMODULE -I../../net/inet -c bionet.c"
  542. * version-control: t
  543. * kept-new-versions: 5
  544. * tab-width: 8
  545. * End:
  546. */