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 ** Francois Romieu, Apr 2003: Converted to pci DMA mapping API.
34 ** Pete Popov, Oct 2001: Fixed a few bugs to make the driver functional
35 ** again. Note that this card is not supported or manufactured by
38 ** Rasmus Andersen, December 2000: Converted to new PCI API and general
41 ** Pete Popov, January 11,99: Fixed a couple of 2.1.x problems
42 ** (virt_to_bus() not called), tested it under 2.2pre5 (as a module), and
43 ** added a #define(s) to enable the use of the same file for both, the 2.0.x
44 ** kernels as well as the 2.1.x.
46 ** Ported to 2.1.x by Alan Cox 1998/12/9.
48 ** Sometime in mid 1998, written by Pete Popov and Brian Moyle.
50 ***************************************************************************/
52 #include <linux/module.h>
53 #include <linux/kernel.h>
54 #include <linux/string.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>
64 #include <asm/irq.h> /* For NR_IRQS only. */
65 #include <asm/bitops.h>
66 #include <asm/uaccess.h>
68 static char version[] __initdata =
69 "RedCreek Communications PCI linux driver version 2.21\n";
71 #define RC_LINUX_MODULE
75 #define RUN_AT(x) (jiffies + (x))
79 #define MAX_ETHER_SIZE 1520
80 #define MAX_NMBR_RCV_BUFFERS 96
81 #define RC_POSTED_BUFFERS_LOW_MARK MAX_NMBR_RCV_BUFFERS-16
82 #define BD_SIZE 3 /* Bucket Descriptor size */
83 #define BD_LEN_OFFSET 2 /* Bucket Descriptor offset to length field */
85 /* RedCreek LAN device Target ID */
86 #define RC_LAN_TARGET_ID 0x10
87 /* RedCreek's OSM default LAN receive Initiator */
88 #define DEFAULT_RECV_INIT_CONTEXT 0xA17
90 /* minimum msg buffer size needed by the card
91 * Note that the size of this buffer is hard code in the
92 * ipsec card's firmware. Thus, the size MUST be a minimum
93 * of 16K. Otherwise the card will end up using memory
94 * that does not belong to it.
96 #define MSG_BUF_SIZE 16384
98 /* 2003/04/20: I don't know about the hardware ability but the driver won't
99 * play safe with 64 bit addressing and DAC without NETIF_F_HIGHDMA doesn't
100 * really make sense anyway. Let's play safe - romieu.
102 #define RCPCI45_DMA_MASK ((u64) 0xffffffff)
104 static U32 DriverControlWord;
106 static void rc_timer (unsigned long);
108 static int RCopen (struct net_device *);
109 static int RC_xmit_packet (struct sk_buff *, struct net_device *);
110 static irqreturn_t RCinterrupt (int, void *, struct pt_regs *);
111 static int RCclose (struct net_device *dev);
112 static struct net_device_stats *RCget_stats (struct net_device *);
113 static int RCioctl (struct net_device *, struct ifreq *, int);
114 static int RCconfig (struct net_device *, struct ifmap *);
115 static void RCxmit_callback (U32, U16, PU32, struct net_device *);
116 static void RCrecv_callback (U32, U8, U32, PU32, struct net_device *);
117 static void RCreset_callback (U32, U32, U32, struct net_device *);
118 static void RCreboot_callback (U32, U32, U32, struct net_device *);
119 static int RC_allocate_and_post_buffers (struct net_device *, int);
121 static struct pci_device_id rcpci45_pci_table[] = {
122 { PCI_VENDOR_ID_REDCREEK, PCI_DEVICE_ID_RC45, PCI_ANY_ID, PCI_ANY_ID,},
125 MODULE_DEVICE_TABLE (pci, rcpci45_pci_table);
126 MODULE_LICENSE("GPL");
128 static void __devexit
129 rcpci45_remove_one (struct pci_dev *pdev)
131 struct net_device *dev = pci_get_drvdata (pdev);
132 PDPA pDpa = dev->priv;
135 unregister_netdev (dev);
136 free_irq (dev->irq, dev);
137 iounmap ((void *) dev->base_addr);
138 pci_release_regions (pdev);
139 pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
144 pci_set_drvdata (pdev, NULL);
148 rcpci45_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
150 unsigned long *vaddr;
153 static int card_idx = -1;
154 struct net_device *dev;
155 unsigned long pci_start, pci_len;
160 * Allocate and fill new device structure.
161 * We need enough for struct net_device plus DPA plus the LAN
162 * API private area, which requires a minimum of 16KB. The top
163 * of the allocated area will be assigned to struct net_device;
164 * the next chunk will be assigned to DPA; and finally, the rest
165 * will be assigned to the LAN API layer.
168 dev = alloc_etherdev(sizeof(*pDpa));
171 "(rcpci45 driver:) alloc_etherdev alloc failed\n");
176 SET_MODULE_OWNER(dev);
177 SET_NETDEV_DEV(dev, &pdev->dev);
179 error = pci_enable_device (pdev);
182 "(rcpci45 driver:) %d: pci enable device error\n",
186 pci_start = pci_resource_start (pdev, 0);
187 pci_len = pci_resource_len (pdev, 0);
188 printk("pci_start %lx pci_len %lx\n", pci_start, pci_len);
190 pci_set_drvdata (pdev, dev);
194 pDpa->pci_dev = pdev;
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 memory.
207 * 2003/04/20: pci_alloc_consistent() provides well over the needed
208 * alignment on a 256 bytes boundary for the LAN API private area.
209 * Thus it isn't needed anymore to align it by hand.
211 pDpa->msgbuf = pci_alloc_consistent (pdev, MSG_BUF_SIZE,
214 printk (KERN_ERR "(rcpci45 driver:) \
215 Could not allocate %d byte memory for the \
216 private msgbuf!\n", MSG_BUF_SIZE);
218 goto err_out_free_dev;
221 /* The adapter is accessible through memory-access read/write, not
222 * I/O read/write. Thus, we need to map it to some virtual address
223 * area in order to access the registers as normal memory.
225 error = pci_request_regions (pdev, dev->name);
227 goto err_out_free_msgbuf;
229 error = pci_set_dma_mask (pdev, RCPCI45_DMA_MASK);
232 "(rcpci45 driver:) pci_set_dma_mask failed!\n");
233 goto err_out_free_region;
236 vaddr = (ulong *) ioremap (pci_start, pci_len);
240 Unable to remap address range from %lu to %lu\n",
241 pci_start, pci_start + pci_len);
243 goto err_out_free_region;
246 dev->base_addr = (unsigned long) vaddr;
247 dev->irq = pdev->irq;
249 dev->hard_start_xmit = &RC_xmit_packet;
250 dev->stop = &RCclose;
251 dev->get_stats = &RCget_stats;
252 dev->do_ioctl = &RCioctl;
253 dev->set_config = &RCconfig;
255 if ((error = register_netdev(dev)))
256 goto err_out_iounmap;
258 return 0; /* success */
261 iounmap((void *) dev->base_addr);
263 pci_release_regions (pdev);
265 pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
274 static struct pci_driver rcpci45_driver = {
276 .id_table = rcpci45_pci_table,
277 .probe = rcpci45_init_one,
278 .remove = __devexit_p(rcpci45_remove_one),
282 rcpci_init_module (void)
284 int rc = pci_module_init (&rcpci45_driver);
286 printk (KERN_ERR "%s", version);
291 RCopen (struct net_device *dev)
293 int post_buffers = MAX_NMBR_RCV_BUFFERS;
294 PDPA pDpa = dev->priv;
300 /* This is not the first time RCopen is called. Thus,
301 * the interface was previously opened and later closed
302 * by RCclose(). RCclose() does a Shutdown; to wake up
303 * the adapter, a reset is mandatory before we can post
304 * receive buffers. However, if the adapter initiated
305 * a reboot while the interface was closed -- and interrupts
306 * were turned off -- we need will need to reinitialize
307 * the adapter, rather than simply waking it up.
309 printk (KERN_INFO "Waking up adapter...\n");
310 RCResetLANCard (dev, 0, 0, 0);
314 * RCInitI2OMsgLayer is done only once, unless the
315 * adapter was sent a warm reboot
317 error = RCInitI2OMsgLayer (dev, (PFNTXCALLBACK) RCxmit_callback,
318 (PFNRXCALLBACK) RCrecv_callback,
319 (PFNCALLBACK) RCreboot_callback);
321 printk (KERN_ERR "%s: Unable to init msg layer (%x)\n",
325 if ((error = RCGetMAC (dev, NULL))) {
326 printk (KERN_ERR "%s: Unable to get adapter MAC\n",
332 /* Request a shared interrupt line. */
333 error = request_irq (dev->irq, RCinterrupt, SA_SHIRQ, dev->name, dev);
335 printk (KERN_ERR "%s: unable to get IRQ %d\n",
336 dev->name, dev->irq);
340 DriverControlWord |= WARM_REBOOT_CAPABLE;
341 RCReportDriverCapability (dev, DriverControlWord);
343 printk (KERN_INFO "%s: RedCreek Communications IPSEC VPN adapter\n",
346 RCEnableI2OInterrupts (dev);
348 while (post_buffers) {
349 if (post_buffers > MAX_NMBR_POST_BUFFERS_PER_MSG)
350 requested = MAX_NMBR_POST_BUFFERS_PER_MSG;
352 requested = post_buffers;
353 count = RC_allocate_and_post_buffers (dev, requested);
355 if (count < requested) {
357 * Check to see if we were able to post
358 * any buffers at all.
360 if (post_buffers == MAX_NMBR_RCV_BUFFERS) {
361 printk (KERN_ERR "%s: \
362 unable to allocate any buffers\n",
364 goto err_out_free_irq;
366 printk (KERN_WARNING "%s: \
367 unable to allocate all requested buffers\n", dev->name);
368 break; /* we'll try to post more buffers later */
370 post_buffers -= count;
372 pDpa->numOutRcvBuffers = MAX_NMBR_RCV_BUFFERS - post_buffers;
373 pDpa->shutdown = 0; /* just in case */
374 netif_start_queue (dev);
378 free_irq (dev->irq, dev);
384 RC_xmit_packet (struct sk_buff *skb, struct net_device *dev)
387 PDPA pDpa = dev->priv;
389 psingleTCB ptcb = &tcb;
390 RC_RETURN status = 0;
392 netif_stop_queue (dev);
394 if (pDpa->shutdown || pDpa->reboot) {
395 printk ("RC_xmit_packet: tbusy!\n");
400 * The user is free to reuse the TCB after RCI2OSendPacket()
401 * returns, since the function copies the necessary info into its
402 * own private space. Thus, our TCB can be a local structure.
403 * The skb, on the other hand, will be freed up in our interrupt
410 * we'll get the context when the adapter interrupts us to tell us that
411 * the transmission is done. At that time, we can free skb.
413 ptcb->b.context = (U32) skb;
415 ptcb->b.size = skb->len;
416 ptcb->b.addr = pci_map_single(pDpa->pci_dev, skb->data, skb->len,
419 if ((status = RCI2OSendPacket (dev, (U32) NULL, (PRCTCB) ptcb))
420 != RC_RTN_NO_ERROR) {
421 printk ("%s: send error 0x%x\n", dev->name, (uint) status);
424 dev->trans_start = jiffies;
425 netif_wake_queue (dev);
436 * The transmit callback routine. It's called by RCProcI2OMsgQ()
437 * because the adapter is done with one or more transmit buffers and
438 * it's returning them to us, or we asked the adapter to return the
439 * outstanding transmit buffers by calling RCResetLANCard() with
440 * RC_RESOURCE_RETURN_PEND_TX_BUFFERS flag.
441 * All we need to do is free the buffers.
444 RCxmit_callback (U32 Status,
445 U16 PcktCount, PU32 BufferContext, struct net_device *dev)
448 PDPA pDpa = dev->priv;
451 printk (KERN_ERR "%s: Fatal Error in xmit callback, !pDpa\n",
456 if (Status != I2O_REPLY_STATUS_SUCCESS)
457 printk (KERN_INFO "%s: xmit_callback: Status = 0x%x\n",
458 dev->name, (uint) Status);
459 if (pDpa->shutdown || pDpa->reboot)
460 printk (KERN_INFO "%s: xmit callback: shutdown||reboot\n",
463 while (PcktCount--) {
464 skb = (struct sk_buff *) (BufferContext[0]);
466 pci_unmap_single(pDpa->pci_dev, BufferContext[1], skb->len,
468 dev_kfree_skb_irq (skb);
470 netif_wake_queue (dev);
474 RCreset_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
476 PDPA pDpa = dev->priv;
478 printk ("RCreset_callback Status 0x%x\n", (uint) Status);
480 * Check to see why we were called.
482 if (pDpa->shutdown) {
483 printk (KERN_INFO "%s: shutting down interface\n",
487 } else if (pDpa->reboot) {
488 printk (KERN_INFO "%s: reboot, shutdown adapter\n",
491 * We don't set any of the flags in RCShutdownLANCard()
492 * and we don't pass a callback routine to it.
493 * The adapter will have already initiated the reboot by
494 * the time the function returns.
496 RCDisableI2OInterrupts (dev);
497 RCShutdownLANCard (dev, 0, 0, 0);
498 printk (KERN_INFO "%s: scheduling timer...\n", dev->name);
499 init_timer (&pDpa->timer);
500 pDpa->timer.expires = RUN_AT ((40 * HZ) / 10); /* 4 sec. */
501 pDpa->timer.data = (unsigned long) dev;
502 pDpa->timer.function = &rc_timer; /* timer handler */
503 add_timer (&pDpa->timer);
508 RCreboot_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
510 PDPA pDpa = dev->priv;
512 printk (KERN_INFO "%s: reboot: rcv buffers outstanding = %d\n",
513 dev->name, (uint) pDpa->numOutRcvBuffers);
515 if (pDpa->shutdown) {
516 printk (KERN_INFO "%s: skip reboot, shutdown initiated\n",
522 * OK, we reset the adapter and ask it to return all
523 * outstanding transmit buffers as well as the posted
524 * receive buffers. When the adapter is done returning
525 * those buffers, it will call our RCreset_callback()
526 * routine. In that routine, we'll call RCShutdownLANCard()
527 * to tell the adapter that it's OK to start the reboot and
528 * schedule a timer callback routine to execute 3 seconds
529 * later; this routine will reinitialize the adapter at that time.
531 RCResetLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
532 RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
533 (PFNCALLBACK) RCreset_callback);
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",
640 return RCProcI2OMsgQ (dev);
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 shutting down interface\n", dev->name);
709 RCDisableI2OInterrupts (dev);
710 dev->flags &= ~IFF_UP;
712 printk (KERN_INFO "%s: rescheduling timer...\n",
714 init_timer (&pDpa->timer);
715 pDpa->timer.expires = RUN_AT ((40 * HZ) / 10);
716 pDpa->timer.data = (unsigned long) dev;
717 pDpa->timer.function = &rc_timer;
718 add_timer (&pDpa->timer);
721 printk (KERN_WARNING "%s: unexpected timer irq\n", dev->name);
725 RCclose (struct net_device *dev)
727 PDPA pDpa = dev->priv;
730 netif_stop_queue (dev);
733 printk (KERN_INFO "%s skipping reset -- adapter already in reboot mode\n", dev->name);
734 dev->flags &= ~IFF_UP;
742 * We can't allow the driver to be unloaded until the adapter returns
743 * all posted receive buffers. It doesn't hurt to tell the adapter
744 * to return all posted receive buffers and outstanding xmit buffers,
745 * even if there are none.
748 RCShutdownLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
749 RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
750 (PFNCALLBACK) RCreset_callback);
752 dev->flags &= ~IFF_UP;
756 static struct net_device_stats *
757 RCget_stats (struct net_device *dev)
761 PDPA pDpa = dev->priv;
765 } else if (!(dev->flags & IFF_UP)) {
769 memset (&RCstats, 0, sizeof (RCLINKSTATS));
770 if ((RCGetLinkStatistics (dev, &RCstats, (void *) 0)) ==
773 /* total packets received */
774 pDpa->stats.rx_packets = RCstats.Rcv_good
775 /* total packets transmitted */;
776 pDpa->stats.tx_packets = RCstats.TX_good;
778 pDpa->stats.rx_errors = RCstats.Rcv_CRCerr +
779 RCstats.Rcv_alignerr + RCstats.Rcv_reserr +
780 RCstats.Rcv_orun + RCstats.Rcv_cdt + RCstats.Rcv_runt;
782 pDpa->stats.tx_errors = RCstats.TX_urun + RCstats.TX_crs +
783 RCstats.TX_def + RCstats.TX_totcol;
786 * This needs improvement.
788 pDpa->stats.rx_dropped = 0; /* no space in linux buffers */
789 pDpa->stats.tx_dropped = 0; /* no space available in linux */
790 pDpa->stats.multicast = 0; /* multicast packets received */
791 pDpa->stats.collisions = RCstats.TX_totcol;
793 /* detailed rx_errors: */
794 pDpa->stats.rx_length_errors = 0;
795 pDpa->stats.rx_over_errors = RCstats.Rcv_orun;
796 pDpa->stats.rx_crc_errors = RCstats.Rcv_CRCerr;
797 pDpa->stats.rx_frame_errors = 0;
798 pDpa->stats.rx_fifo_errors = 0;
799 pDpa->stats.rx_missed_errors = 0;
801 /* detailed tx_errors */
802 pDpa->stats.tx_aborted_errors = 0;
803 pDpa->stats.tx_carrier_errors = 0;
804 pDpa->stats.tx_fifo_errors = 0;
805 pDpa->stats.tx_heartbeat_errors = 0;
806 pDpa->stats.tx_window_errors = 0;
808 return ((struct net_device_stats *) &(pDpa->stats));
814 RCioctl (struct net_device *dev, struct ifreq *rq, int cmd)
816 RCuser_struct RCuser;
817 PDPA pDpa = dev->priv;
819 if (!capable (CAP_NET_ADMIN))
824 case RCU_PROTOCOL_REV:
826 * Assign user protocol revision, to tell user-level
827 * controller program whether or not it's in sync.
829 rq->ifr_ifru.ifru_data = (caddr_t) USER_PROTOCOL_REV;
835 (&RCuser, rq->ifr_data, sizeof (RCuser)))
838 dprintk ("RCioctl: RCuser_cmd = 0x%x\n", RCuser.cmd);
840 switch (RCuser.cmd) {
842 RCUD_GETFWVER = &RCuser.RCUS_GETFWVER;
843 RCGetFirmwareVer (dev,
844 (PU8) & RCUD_GETFWVER->
848 RCUD_GETINFO = &RCuser.RCUS_GETINFO;
849 RCUD_GETINFO->mem_start = dev->base_addr;
850 RCUD_GETINFO->mem_end =
851 dev->base_addr + pDpa->pci_addr_len;
852 RCUD_GETINFO->base_addr = pDpa->pci_addr;
853 RCUD_GETINFO->irq = dev->irq;
855 case RCUC_GETIPANDMASK:
856 RCUD_GETIPANDMASK = &RCuser.RCUS_GETIPANDMASK;
857 RCGetRavlinIPandMask (dev,
859 RCUD_GETIPANDMASK->IpAddr,
864 case RCUC_GETLINKSTATISTICS:
865 RCUD_GETLINKSTATISTICS =
866 &RCuser.RCUS_GETLINKSTATISTICS;
867 RCGetLinkStatistics (dev,
869 RCUD_GETLINKSTATISTICS->
872 case RCUC_GETLINKSTATUS:
873 RCUD_GETLINKSTATUS = &RCuser.RCUS_GETLINKSTATUS;
874 RCGetLinkStatus (dev,
875 (PU32) & RCUD_GETLINKSTATUS->
879 RCUD_GETMAC = &RCuser.RCUS_GETMAC;
880 RCGetMAC (dev, NULL);
881 memcpy(RCUD_GETMAC, dev->dev_addr, 8);
884 RCUD_GETPROM = &RCuser.RCUS_GETPROM;
885 RCGetPromiscuousMode (dev,
886 (PU32) & RCUD_GETPROM->
889 case RCUC_GETBROADCAST:
890 RCUD_GETBROADCAST = &RCuser.RCUS_GETBROADCAST;
891 RCGetBroadcastMode (dev,
892 (PU32) & RCUD_GETBROADCAST->
893 BroadcastMode, NULL);
896 if (!(dev->flags & IFF_UP)) {
899 RCUD_GETSPEED = &RCuser.RCUS_GETSPEED;
901 (PU32) & RCUD_GETSPEED->
902 LinkSpeedCode, NULL);
904 case RCUC_SETIPANDMASK:
905 RCUD_SETIPANDMASK = &RCuser.RCUS_SETIPANDMASK;
906 RCSetRavlinIPandMask (dev,
907 (U32) RCUD_SETIPANDMASK->
909 (U32) RCUD_SETIPANDMASK->
913 RCSetMAC (dev, (PU8) & RCUD_SETMAC->mac);
916 RCUD_SETSPEED = &RCuser.RCUS_SETSPEED;
918 (U16) RCUD_SETSPEED->
922 RCUD_SETPROM = &RCuser.RCUS_SETPROM;
923 RCSetPromiscuousMode (dev,
927 case RCUC_SETBROADCAST:
928 RCUD_SETBROADCAST = &RCuser.RCUS_SETBROADCAST;
929 RCSetBroadcastMode (dev,
930 (U16) RCUD_SETBROADCAST->
934 RCUD_DEFAULT = &RCuser.RCUS_DEFAULT;
935 RCUD_DEFAULT->rc = 0x11223344;
938 if (copy_to_user (rq->ifr_data, &RCuser,
945 rq->ifr_ifru.ifru_data = (caddr_t) 0x12345678;
952 RCconfig (struct net_device *dev, struct ifmap *map)
955 * To be completed ...
958 if (dev->flags & IFF_UP) /* can't act on a running interface */
961 /* Don't allow changing the I/O address */
962 if (map->base_addr != dev->base_addr) {
963 printk (KERN_WARNING "%s Change I/O address not implemented\n",
971 rcpci_cleanup_module (void)
973 pci_unregister_driver (&rcpci45_driver);
976 module_init (rcpci_init_module);
977 module_exit (rcpci_cleanup_module);
980 RC_allocate_and_post_buffers (struct net_device *dev, int numBuffers)
987 PDPA pDpa = dev->priv;
993 else if (numBuffers > MAX_NMBR_POST_BUFFERS_PER_MSG) {
994 printk (KERN_ERR "%s: Too many buffers requested!\n",
999 p = (PU32) kmalloc (sizeof (U32) + numBuffers * sizeof (singleB),
1000 GFP_DMA | GFP_ATOMIC);
1003 printk (KERN_WARNING "%s unable to allocate TCB\n",
1008 p[0] = 0; /* Buffer Count */
1009 pB = (psingleB) ((U32) p + sizeof (U32));/* point to the first buffer */
1011 for (i = 0; i < numBuffers; i++) {
1012 skb = dev_alloc_skb (MAX_ETHER_SIZE + 2);
1014 printk (KERN_WARNING
1015 "%s: unable to allocate enough skbs!\n",
1019 skb_reserve (skb, 2); /* Align IP on 16 byte boundaries */
1020 pB->context = (U32) skb;
1021 pB->scount = 1; /* segment count */
1022 pB->size = MAX_ETHER_SIZE;
1023 pB->addr = pci_map_single(pDpa->pci_dev, skb->data,
1024 MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE);
1029 if ((status = RCPostRecvBuffers (dev, (PRCTCB) p)) != RC_RTN_NO_ERROR) {
1030 printk (KERN_WARNING "%s: Post buffer failed, error 0x%x\n",
1038 return (res); /* return the number of posted buffers */
1041 for (; p[0] > 0; p[0]--) {
1043 skb = (struct sk_buff *) pB->context;
1044 pci_unmap_single(pDpa->pci_dev, pB->addr, MAX_ETHER_SIZE,
1045 PCI_DMA_FROMDEVICE);
1046 dev_kfree_skb (skb);