7 ** ---------------------------------------------------------------------
8 ** --- Copyright (c) 1998, 1999, RedCreek Communications Inc. ---
9 ** --- All rights reserved. ---
10 ** ---------------------------------------------------------------------
12 ** Written by Pete Popov and Brian Moyle.
16 ** None known at this time.
18 ** This program is free software; you can redistribute it and/or modify
19 ** it under the terms of the GNU General Public License as published by
20 ** the Free Software Foundation; either version 2 of the License, or
21 ** (at your option) any later version.
23 ** This program is distributed in the hope that it will be useful,
24 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
25 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ** GNU General Public License for more details.
28 ** You should have received a copy of the GNU General Public License
29 ** along with this program; if not, write to the Free Software
30 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 ** Pete Popov, Oct 2001: Fixed a few bugs to make the driver functional
33 ** again. Note that this card is not supported or manufactured by
36 ** Rasmus Andersen, December 2000: Converted to new PCI API and general
39 ** Pete Popov, January 11,99: Fixed a couple of 2.1.x problems
40 ** (virt_to_bus() not called), tested it under 2.2pre5 (as a module), and
41 ** added a #define(s) to enable the use of the same file for both, the 2.0.x
42 ** kernels as well as the 2.1.x.
44 ** Ported to 2.1.x by Alan Cox 1998/12/9.
46 ** Sometime in mid 1998, written by Pete Popov and Brian Moyle.
48 ***************************************************************************/
50 #include <linux/module.h>
51 #include <linux/kernel.h>
52 #include <linux/sched.h>
53 #include <linux/string.h>
54 #include <linux/ptrace.h>
55 #include <linux/errno.h>
57 #include <linux/init.h>
58 #include <linux/ioport.h>
59 #include <linux/slab.h>
60 #include <linux/interrupt.h>
61 #include <linux/pci.h>
62 #include <linux/timer.h>
63 #include <asm/irq.h> /* For NR_IRQS only. */
64 #include <asm/bitops.h>
65 #include <asm/uaccess.h>
67 static char version[] __initdata =
68 "RedCreek Communications PCI linux driver version 2.20\n";
70 #define RC_LINUX_MODULE
74 #define RUN_AT(x) (jiffies + (x))
78 /* PCI/45 Configuration space values */
79 #define RC_PCI45_VENDOR_ID 0x4916
80 #define RC_PCI45_DEVICE_ID 0x1960
82 #define MAX_ETHER_SIZE 1520
83 #define MAX_NMBR_RCV_BUFFERS 96
84 #define RC_POSTED_BUFFERS_LOW_MARK MAX_NMBR_RCV_BUFFERS-16
85 #define BD_SIZE 3 /* Bucket Descriptor size */
86 #define BD_LEN_OFFSET 2 /* Bucket Descriptor offset to length field */
88 /* RedCreek LAN device Target ID */
89 #define RC_LAN_TARGET_ID 0x10
90 /* RedCreek's OSM default LAN receive Initiator */
91 #define DEFAULT_RECV_INIT_CONTEXT 0xA17
93 /* minimum msg buffer size needed by the card
94 * Note that the size of this buffer is hard code in the
95 * ipsec card's firmware. Thus, the size MUST be a minimum
96 * of 16K. Otherwise the card will end up using memory
97 * that does not belong to it.
99 #define MSG_BUF_SIZE 16384
101 static U32 DriverControlWord;
103 static void rc_timer (unsigned long);
105 static int RCopen (struct net_device *);
106 static int RC_xmit_packet (struct sk_buff *, struct net_device *);
107 static void RCinterrupt (int, void *, struct pt_regs *);
108 static int RCclose (struct net_device *dev);
109 static struct net_device_stats *RCget_stats (struct net_device *);
110 static int RCioctl (struct net_device *, struct ifreq *, int);
111 static int RCconfig (struct net_device *, struct ifmap *);
112 static void RCxmit_callback (U32, U16, PU32, struct net_device *);
113 static void RCrecv_callback (U32, U8, U32, PU32, struct net_device *);
114 static void RCreset_callback (U32, U32, U32, struct net_device *);
115 static void RCreboot_callback (U32, U32, U32, struct net_device *);
116 static int RC_allocate_and_post_buffers (struct net_device *, int);
118 static struct pci_device_id rcpci45_pci_table[] __devinitdata = {
119 {RC_PCI45_VENDOR_ID, RC_PCI45_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
122 MODULE_DEVICE_TABLE (pci, rcpci45_pci_table);
123 MODULE_LICENSE("GPL");
125 static void __devexit
126 rcpci45_remove_one (struct pci_dev *pdev)
128 struct net_device *dev = pci_get_drvdata (pdev);
129 PDPA pDpa = dev->priv;
132 printk (KERN_ERR "%s: remove non-existent device\n",
138 unregister_netdev (dev);
139 free_irq (dev->irq, dev);
140 iounmap ((void *) dev->base_addr);
141 pci_release_regions (pdev);
143 kfree (pDpa->msgbuf);
147 pci_set_drvdata (pdev, NULL);
151 rcpci45_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
153 unsigned long *vaddr;
156 static int card_idx = -1;
157 struct net_device *dev;
158 unsigned long pci_start, pci_len;
163 * Allocate and fill new device structure.
164 * We need enough for struct net_device plus DPA plus the LAN
165 * API private area, which requires a minimum of 16KB. The top
166 * of the allocated area will be assigned to struct net_device;
167 * the next chunk will be assigned to DPA; and finally, the rest
168 * will be assigned to the LAN API layer.
171 dev = init_etherdev (NULL, sizeof (*pDpa));
174 "(rcpci45 driver:) init_etherdev alloc failed\n");
179 error = pci_enable_device (pdev);
182 "(rcpci45 driver:) %d: pci enable device error\n",
187 pci_start = pci_resource_start (pdev, 0);
188 pci_len = pci_resource_len (pdev, 0);
189 printk("pci_start %lx pci_len %lx\n", pci_start, pci_len);
191 pci_set_drvdata (pdev, dev);
195 pDpa->pci_addr = pci_start;
197 if (!pci_start || !(pci_resource_flags (pdev, 0) & IORESOURCE_MEM)) {
199 "(rcpci45 driver:) No PCI mem resources! Aborting\n");
201 goto err_out_free_dev;
205 * pDpa->msgbuf is where the card will dma the I2O
206 * messages. Thus, we need contiguous physical pages of
209 pDpa->msgbuf = kmalloc (MSG_BUF_SIZE, GFP_DMA|GFP_ATOMIC|GFP_KERNEL);
211 printk (KERN_ERR "(rcpci45 driver:) \
212 Could not allocate %d byte memory for the \
213 private msgbuf!\n", MSG_BUF_SIZE);
214 goto err_out_free_dev;
218 * Save the starting address of the LAN API private area. We'll
219 * pass that to RCInitI2OMsgLayer().
222 pDpa->PLanApiPA = (void *) (((long) pDpa->msgbuf + 0xff) & ~0xff);
224 /* The adapter is accessible through memory-access read/write, not
225 * I/O read/write. Thus, we need to map it to some virtual address
226 * area in order to access the registers as normal memory.
228 error = pci_request_regions (pdev, dev->name);
230 goto err_out_free_msgbuf;
232 vaddr = (ulong *) ioremap (pci_start, pci_len);
236 Unable to remap address range from %lu to %lu\n",
237 pci_start, pci_start + pci_len);
238 goto err_out_free_region;
241 dev->base_addr = (unsigned long) vaddr;
242 dev->irq = pdev->irq;
244 dev->hard_start_xmit = &RC_xmit_packet;
245 dev->stop = &RCclose;
246 dev->get_stats = &RCget_stats;
247 dev->do_ioctl = &RCioctl;
248 dev->set_config = &RCconfig;
250 return 0; /* success */
253 pci_release_regions (pdev);
255 kfree (pDpa->msgbuf);
257 unregister_netdev (dev);
264 static struct pci_driver rcpci45_driver = {
266 id_table: rcpci45_pci_table,
267 probe: rcpci45_init_one,
268 remove: __devexit_p(rcpci45_remove_one),
272 rcpci_init_module (void)
274 int rc = pci_module_init (&rcpci45_driver);
276 printk (KERN_ERR "%s", version);
281 RCopen (struct net_device *dev)
283 int post_buffers = MAX_NMBR_RCV_BUFFERS;
284 PDPA pDpa = dev->priv;
291 /* This is not the first time RCopen is called. Thus,
292 * the interface was previously opened and later closed
293 * by RCclose(). RCclose() does a Shutdown; to wake up
294 * the adapter, a reset is mandatory before we can post
295 * receive buffers. However, if the adapter initiated
296 * a reboot while the interface was closed -- and interrupts
297 * were turned off -- we need will need to reinitialize
298 * the adapter, rather than simply waking it up.
300 printk (KERN_INFO "Waking up adapter...\n");
301 RCResetLANCard (dev, 0, 0, 0);
305 * RCInitI2OMsgLayer is done only once, unless the
306 * adapter was sent a warm reboot
308 error = RCInitI2OMsgLayer (dev, (PFNTXCALLBACK) RCxmit_callback,
309 (PFNRXCALLBACK) RCrecv_callback,
310 (PFNCALLBACK) RCreboot_callback);
312 printk (KERN_ERR "%s: Unable to init msg layer (%x)\n",
316 if ((error = RCGetMAC (dev, NULL))) {
317 printk (KERN_ERR "%s: Unable to get adapter MAC\n",
323 /* Request a shared interrupt line. */
324 error = request_irq (dev->irq, RCinterrupt, SA_SHIRQ, dev->name, dev);
326 printk (KERN_ERR "%s: unable to get IRQ %d\n",
327 dev->name, dev->irq);
331 DriverControlWord |= WARM_REBOOT_CAPABLE;
332 RCReportDriverCapability (dev, DriverControlWord);
334 printk (KERN_INFO "%s: RedCreek Communications IPSEC VPN adapter\n",
337 RCEnableI2OInterrupts (dev);
339 while (post_buffers) {
340 if (post_buffers > MAX_NMBR_POST_BUFFERS_PER_MSG)
341 requested = MAX_NMBR_POST_BUFFERS_PER_MSG;
343 requested = post_buffers;
344 count = RC_allocate_and_post_buffers (dev, requested);
346 if (count < requested) {
348 * Check to see if we were able to post
349 * any buffers at all.
351 if (post_buffers == MAX_NMBR_RCV_BUFFERS) {
352 printk (KERN_ERR "%s: \
353 unable to allocate any buffers\n",
355 goto err_out_free_irq;
357 printk (KERN_WARNING "%s: \
358 unable to allocate all requested buffers\n", dev->name);
359 break; /* we'll try to post more buffers later */
361 post_buffers -= count;
363 pDpa->numOutRcvBuffers = MAX_NMBR_RCV_BUFFERS - post_buffers;
364 pDpa->shutdown = 0; /* just in case */
365 netif_start_queue (dev);
369 free_irq (dev->irq, dev);
376 RC_xmit_packet (struct sk_buff *skb, struct net_device *dev)
379 PDPA pDpa = dev->priv;
381 psingleTCB ptcb = &tcb;
382 RC_RETURN status = 0;
384 netif_stop_queue (dev);
386 if (pDpa->shutdown || pDpa->reboot) {
387 printk ("RC_xmit_packet: tbusy!\n");
392 * The user is free to reuse the TCB after RCI2OSendPacket()
393 * returns, since the function copies the necessary info into its
394 * own private space. Thus, our TCB can be a local structure.
395 * The skb, on the other hand, will be freed up in our interrupt
402 * we'll get the context when the adapter interrupts us to tell us that
403 * the transmission is done. At that time, we can free skb.
405 ptcb->b.context = (U32) skb;
407 ptcb->b.size = skb->len;
408 ptcb->b.addr = virt_to_bus ((void *) skb->data);
410 if ((status = RCI2OSendPacket (dev, (U32) NULL, (PRCTCB) ptcb))
411 != RC_RTN_NO_ERROR) {
412 printk ("%s: send error 0x%x\n", dev->name, (uint) status);
415 dev->trans_start = jiffies;
416 netif_wake_queue (dev);
427 * The transmit callback routine. It's called by RCProcI2OMsgQ()
428 * because the adapter is done with one or more transmit buffers and
429 * it's returning them to us, or we asked the adapter to return the
430 * outstanding transmit buffers by calling RCResetLANCard() with
431 * RC_RESOURCE_RETURN_PEND_TX_BUFFERS flag.
432 * All we need to do is free the buffers.
435 RCxmit_callback (U32 Status,
436 U16 PcktCount, PU32 BufferContext, struct net_device *dev)
439 PDPA pDpa = dev->priv;
442 printk (KERN_ERR "%s: Fatal Error in xmit callback, !pDpa\n",
447 if (Status != I2O_REPLY_STATUS_SUCCESS)
448 printk (KERN_INFO "%s: xmit_callback: Status = 0x%x\n",
449 dev->name, (uint) Status);
450 if (pDpa->shutdown || pDpa->reboot)
451 printk (KERN_INFO "%s: xmit callback: shutdown||reboot\n",
454 while (PcktCount--) {
455 skb = (struct sk_buff *) (BufferContext[0]);
457 dev_kfree_skb_irq (skb);
459 netif_wake_queue (dev);
463 RCreset_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
465 PDPA pDpa = dev->priv;
467 printk ("RCreset_callback Status 0x%x\n", (uint) Status);
469 * Check to see why we were called.
471 if (pDpa->shutdown) {
472 printk (KERN_INFO "%s: shutting down interface\n",
476 } else if (pDpa->reboot) {
477 printk (KERN_INFO "%s: reboot, shutdown adapter\n",
480 * We don't set any of the flags in RCShutdownLANCard()
481 * and we don't pass a callback routine to it.
482 * The adapter will have already initiated the reboot by
483 * the time the function returns.
485 RCDisableI2OInterrupts (dev);
486 RCShutdownLANCard (dev, 0, 0, 0);
487 printk (KERN_INFO "%s: scheduling timer...\n", dev->name);
488 init_timer (&pDpa->timer);
489 pDpa->timer.expires = RUN_AT ((40 * HZ) / 10); /* 4 sec. */
490 pDpa->timer.data = (unsigned long) dev;
491 pDpa->timer.function = &rc_timer; /* timer handler */
492 add_timer (&pDpa->timer);
497 RCreboot_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
499 PDPA pDpa = dev->priv;
501 printk (KERN_INFO "%s: reboot: rcv buffers outstanding = %d\n",
502 dev->name, (uint) pDpa->numOutRcvBuffers);
504 if (pDpa->shutdown) {
505 printk (KERN_INFO "%s: skip reboot, shutdown initiated\n",
511 * OK, we reset the adapter and ask it to return all
512 * outstanding transmit buffers as well as the posted
513 * receive buffers. When the adapter is done returning
514 * those buffers, it will call our RCreset_callback()
515 * routine. In that routine, we'll call RCShutdownLANCard()
516 * to tell the adapter that it's OK to start the reboot and
517 * schedule a timer callback routine to execute 3 seconds
518 * later; this routine will reinitialize the adapter at that time.
520 RCResetLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
521 RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
522 (PFNCALLBACK) RCreset_callback);
526 broadcast_packet (unsigned char *address)
529 for (i = 0; i < 6; i++)
530 if (address[i] != 0xff)
539 * The receive packet callback routine. This is called by
540 * RCProcI2OMsgQ() after the adapter posts buffers which have been
541 * filled (one ethernet packet per buffer).
544 RCrecv_callback (U32 Status,
547 PU32 PacketDescBlock, struct net_device *dev)
551 PDPA pDpa = dev->priv;
554 psingleTCB ptcb = &tcb;
558 if ((pDpa->shutdown || pDpa->reboot) && !Status)
559 printk (KERN_INFO "%s: shutdown||reboot && !Status (%d)\n",
560 dev->name, PktCount);
562 if ((Status != I2O_REPLY_STATUS_SUCCESS) || pDpa->shutdown) {
564 * Free whatever buffers the adapter returned, but don't
565 * pass them to the kernel.
568 if (!pDpa->shutdown && !pDpa->reboot)
569 printk (KERN_INFO "%s: recv error status = 0x%x\n",
570 dev->name, (uint) Status);
572 printk (KERN_DEBUG "%s: Returning %d buffs stat 0x%x\n",
573 dev->name, PktCount, (uint) Status);
575 * TO DO: check the nature of the failure and put the
576 * adapter in failed mode if it's a hard failure.
577 * Send a reset to the adapter and free all outstanding memory.
579 if (PacketDescBlock) {
581 skb = (struct sk_buff *) PacketDescBlock[0];
583 pDpa->numOutRcvBuffers--;
584 /* point to next context field */
585 PacketDescBlock += BD_SIZE;
591 skb = (struct sk_buff *) PacketDescBlock[0];
592 len = PacketDescBlock[2];
594 skb_put (skb, len); /* adjust length and tail */
595 skb->protocol = eth_type_trans (skb, dev);
596 netif_rx (skb); /* send the packet to the kernel */
597 dev->last_rx = jiffies;
598 pDpa->numOutRcvBuffers--;
599 /* point to next context field */
600 PacketDescBlock += BD_SIZE;
605 * Replenish the posted receive buffers.
606 * DO NOT replenish buffers if the driver has already
607 * initiated a reboot or shutdown!
610 if (!pDpa->shutdown && !pDpa->reboot) {
611 count = RC_allocate_and_post_buffers (dev,
612 MAX_NMBR_RCV_BUFFERS -
613 pDpa->numOutRcvBuffers);
614 pDpa->numOutRcvBuffers += count;
623 * This routine sets up a couple of pointers and calls
624 * RCProcI2OMsgQ(), which in turn process the message and
625 * calls one of our callback functions.
628 RCinterrupt (int irq, void *dev_id, struct pt_regs *regs)
632 struct net_device *dev = dev_id;
637 printk (KERN_DEBUG "%s: shutdown, service irq\n",
643 #define REBOOT_REINIT_RETRY_LIMIT 4
645 rc_timer (unsigned long data)
647 struct net_device *dev = (struct net_device *) data;
648 PDPA pDpa = dev->priv;
651 int post_buffers = MAX_NMBR_RCV_BUFFERS;
657 RCInitI2OMsgLayer (dev, (PFNTXCALLBACK) RCxmit_callback,
658 (PFNRXCALLBACK) RCrecv_callback,
659 (PFNCALLBACK) RCreboot_callback);
661 switch (init_status) {
662 case RC_RTN_NO_ERROR:
665 pDpa->shutdown = 0; /* just in case */
666 RCReportDriverCapability (dev, DriverControlWord);
667 RCEnableI2OInterrupts (dev);
670 if (!(dev->flags & IFF_UP)) {
674 while (post_buffers) {
676 MAX_NMBR_POST_BUFFERS_PER_MSG)
678 MAX_NMBR_POST_BUFFERS_PER_MSG;
680 requested = post_buffers;
682 RC_allocate_and_post_buffers (dev,
684 post_buffers -= count;
685 if (count < requested)
688 pDpa->numOutRcvBuffers =
689 MAX_NMBR_RCV_BUFFERS - post_buffers;
690 printk ("Initialization done.\n");
691 netif_wake_queue (dev);
694 case RC_RTN_FREE_Q_EMPTY:
696 printk (KERN_WARNING "%s inbound free q empty\n",
701 printk (KERN_WARNING "%s bad stat after reboot: %d\n",
702 dev->name, init_status);
706 if (retry > REBOOT_REINIT_RETRY_LIMIT) {
707 printk (KERN_WARNING "%s unable to reinitialize adapter after reboot\n", dev->name);
708 printk (KERN_WARNING "%s decrementing driver and closing interface\n", dev->name);
709 RCDisableI2OInterrupts (dev);
710 dev->flags &= ~IFF_UP;
713 printk (KERN_INFO "%s: rescheduling timer...\n",
715 init_timer (&pDpa->timer);
716 pDpa->timer.expires = RUN_AT ((40 * HZ) / 10);
717 pDpa->timer.data = (unsigned long) dev;
718 pDpa->timer.function = &rc_timer;
719 add_timer (&pDpa->timer);
722 printk (KERN_WARNING "%s: unexpected timer irq\n", dev->name);
726 RCclose (struct net_device *dev)
728 PDPA pDpa = dev->priv;
731 netif_stop_queue (dev);
734 printk (KERN_INFO "%s skipping reset -- adapter already in reboot mode\n", dev->name);
735 dev->flags &= ~IFF_UP;
744 * We can't allow the driver to be unloaded until the adapter returns
745 * all posted receive buffers. It doesn't hurt to tell the adapter
746 * to return all posted receive buffers and outstanding xmit buffers,
747 * even if there are none.
750 RCShutdownLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
751 RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
752 (PFNCALLBACK) RCreset_callback);
754 dev->flags &= ~IFF_UP;
759 static struct net_device_stats *
760 RCget_stats (struct net_device *dev)
764 PDPA pDpa = dev->priv;
768 } else if (!(dev->flags & IFF_UP)) {
772 memset (&RCstats, 0, sizeof (RCLINKSTATS));
773 if ((RCGetLinkStatistics (dev, &RCstats, (void *) 0)) ==
776 /* total packets received */
777 pDpa->stats.rx_packets = RCstats.Rcv_good
778 /* total packets transmitted */;
779 pDpa->stats.tx_packets = RCstats.TX_good;
781 pDpa->stats.rx_errors = RCstats.Rcv_CRCerr +
782 RCstats.Rcv_alignerr + RCstats.Rcv_reserr +
783 RCstats.Rcv_orun + RCstats.Rcv_cdt + RCstats.Rcv_runt;
785 pDpa->stats.tx_errors = RCstats.TX_urun + RCstats.TX_crs +
786 RCstats.TX_def + RCstats.TX_totcol;
789 * This needs improvement.
791 pDpa->stats.rx_dropped = 0; /* no space in linux buffers */
792 pDpa->stats.tx_dropped = 0; /* no space available in linux */
793 pDpa->stats.multicast = 0; /* multicast packets received */
794 pDpa->stats.collisions = RCstats.TX_totcol;
796 /* detailed rx_errors: */
797 pDpa->stats.rx_length_errors = 0;
798 pDpa->stats.rx_over_errors = RCstats.Rcv_orun;
799 pDpa->stats.rx_crc_errors = RCstats.Rcv_CRCerr;
800 pDpa->stats.rx_frame_errors = 0;
801 pDpa->stats.rx_fifo_errors = 0;
802 pDpa->stats.rx_missed_errors = 0;
804 /* detailed tx_errors */
805 pDpa->stats.tx_aborted_errors = 0;
806 pDpa->stats.tx_carrier_errors = 0;
807 pDpa->stats.tx_fifo_errors = 0;
808 pDpa->stats.tx_heartbeat_errors = 0;
809 pDpa->stats.tx_window_errors = 0;
811 return ((struct net_device_stats *) &(pDpa->stats));
817 RCioctl (struct net_device *dev, struct ifreq *rq, int cmd)
819 RCuser_struct RCuser;
820 PDPA pDpa = dev->priv;
822 if (!capable (CAP_NET_ADMIN))
827 case RCU_PROTOCOL_REV:
829 * Assign user protocol revision, to tell user-level
830 * controller program whether or not it's in sync.
832 rq->ifr_ifru.ifru_data = (caddr_t) USER_PROTOCOL_REV;
838 (&RCuser, rq->ifr_data, sizeof (RCuser)))
841 dprintk ("RCioctl: RCuser_cmd = 0x%x\n", RCuser.cmd);
843 switch (RCuser.cmd) {
845 RCUD_GETFWVER = &RCuser.RCUS_GETFWVER;
846 RCGetFirmwareVer (dev,
847 (PU8) & RCUD_GETFWVER->
851 RCUD_GETINFO = &RCuser.RCUS_GETINFO;
852 RCUD_GETINFO->mem_start = dev->base_addr;
853 RCUD_GETINFO->mem_end =
854 dev->base_addr + pDpa->pci_addr_len;
855 RCUD_GETINFO->base_addr = pDpa->pci_addr;
856 RCUD_GETINFO->irq = dev->irq;
858 case RCUC_GETIPANDMASK:
859 RCUD_GETIPANDMASK = &RCuser.RCUS_GETIPANDMASK;
860 RCGetRavlinIPandMask (dev,
862 RCUD_GETIPANDMASK->IpAddr,
867 case RCUC_GETLINKSTATISTICS:
868 RCUD_GETLINKSTATISTICS =
869 &RCuser.RCUS_GETLINKSTATISTICS;
870 RCGetLinkStatistics (dev,
872 RCUD_GETLINKSTATISTICS->
875 case RCUC_GETLINKSTATUS:
876 RCUD_GETLINKSTATUS = &RCuser.RCUS_GETLINKSTATUS;
877 RCGetLinkStatus (dev,
878 (PU32) & RCUD_GETLINKSTATUS->
882 RCUD_GETMAC = &RCuser.RCUS_GETMAC;
883 RCGetMAC (dev, NULL);
884 memcpy(RCUD_GETMAC, dev->dev_addr, 8);
887 RCUD_GETPROM = &RCuser.RCUS_GETPROM;
888 RCGetPromiscuousMode (dev,
889 (PU32) & RCUD_GETPROM->
892 case RCUC_GETBROADCAST:
893 RCUD_GETBROADCAST = &RCuser.RCUS_GETBROADCAST;
894 RCGetBroadcastMode (dev,
895 (PU32) & RCUD_GETBROADCAST->
896 BroadcastMode, NULL);
899 if (!(dev->flags & IFF_UP)) {
902 RCUD_GETSPEED = &RCuser.RCUS_GETSPEED;
904 (PU32) & RCUD_GETSPEED->
905 LinkSpeedCode, NULL);
907 case RCUC_SETIPANDMASK:
908 RCUD_SETIPANDMASK = &RCuser.RCUS_SETIPANDMASK;
909 RCSetRavlinIPandMask (dev,
910 (U32) RCUD_SETIPANDMASK->
912 (U32) RCUD_SETIPANDMASK->
916 RCSetMAC (dev, (PU8) & RCUD_SETMAC->mac);
919 RCUD_SETSPEED = &RCuser.RCUS_SETSPEED;
921 (U16) RCUD_SETSPEED->
925 RCUD_SETPROM = &RCuser.RCUS_SETPROM;
926 RCSetPromiscuousMode (dev,
930 case RCUC_SETBROADCAST:
931 RCUD_SETBROADCAST = &RCuser.RCUS_SETBROADCAST;
932 RCSetBroadcastMode (dev,
933 (U16) RCUD_SETBROADCAST->
937 RCUD_DEFAULT = &RCuser.RCUS_DEFAULT;
938 RCUD_DEFAULT->rc = 0x11223344;
941 if (copy_to_user (rq->ifr_data, &RCuser,
948 rq->ifr_ifru.ifru_data = (caddr_t) 0x12345678;
955 RCconfig (struct net_device *dev, struct ifmap *map)
958 * To be completed ...
961 if (dev->flags & IFF_UP) /* can't act on a running interface */
964 /* Don't allow changing the I/O address */
965 if (map->base_addr != dev->base_addr) {
966 printk (KERN_WARNING "%s Change I/O address not implemented\n",
974 rcpci_cleanup_module (void)
976 pci_unregister_driver (&rcpci45_driver);
979 module_init (rcpci_init_module);
980 module_exit (rcpci_cleanup_module);
983 RC_allocate_and_post_buffers (struct net_device *dev, int numBuffers)
995 else if (numBuffers > MAX_NMBR_POST_BUFFERS_PER_MSG) {
996 printk (KERN_ERR "%s: Too many buffers requested!\n",
1001 p = (PU32) kmalloc (sizeof (U32) + numBuffers * sizeof (singleB),
1002 GFP_DMA|GFP_ATOMIC|GFP_KERNEL);
1005 printk (KERN_WARNING "%s unable to allocate TCB\n",
1010 p[0] = 0; /* Buffer Count */
1011 pB = (psingleB) ((U32) p + sizeof (U32));/* point to the first buffer */
1013 for (i = 0; i < numBuffers; i++) {
1014 skb = dev_alloc_skb (MAX_ETHER_SIZE + 2);
1016 printk (KERN_WARNING
1017 "%s: unable to allocate enough skbs!\n",
1019 if (*p != 0) { /* did we allocate any buffers */
1022 kfree (p); /* Free the TCB */
1026 skb_reserve (skb, 2); /* Align IP on 16 byte boundaries */
1027 pB->context = (U32) skb;
1028 pB->scount = 1; /* segment count */
1029 pB->size = MAX_ETHER_SIZE;
1030 pB->addr = virt_to_bus ((void *) skb->data);
1035 if ((status = RCPostRecvBuffers (dev, (PRCTCB) p)) != RC_RTN_NO_ERROR) {
1036 printk (KERN_WARNING "%s: Post buffer failed, error 0x%x\n",
1038 /* point to the first buffer */
1039 pB = (psingleB) ((U32) p + sizeof (U32));
1041 skb = (struct sk_buff *) pB->context;
1042 dev_kfree_skb (skb);
1049 return (res); /* return the number of posted buffers */