2 * lanstreamer.c -- driver for the IBM Auto LANStreamer PCI Adapter
4 * Written By: Mike Sullivan, IBM Corporation
6 * Copyright (C) 1999 IBM Corporation
8 * Linux driver for IBM PCI tokenring cards based on the LanStreamer MPC
11 * This driver is based on the olympic driver for IBM PCI TokenRing cards (Pit/Pit-Phy/Olympic
12 * chipsets) written by:
13 * 1999 Peter De Schrijver All Rights Reserved
14 * 1999 Mike Phillips (phillim@amtrak.com)
16 * Base Driver Skeleton:
17 * Written 1993-94 by Donald Becker.
19 * Copyright 1993 United States Government as represented by the
20 * Director, National Security Agency.
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
33 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
34 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
35 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
36 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
37 * solely responsible for determining the appropriateness of using and
38 * distributing the Program and assumes all risks associated with its
39 * exercise of rights under this Agreement, including but not limited to
40 * the risks and costs of program errors, damage to or loss of data,
41 * programs or equipment, and unavailability or interruption of operations.
43 * DISCLAIMER OF LIABILITY
44 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
45 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
47 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
48 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
49 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
50 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
52 * You should have received a copy of the GNU General Public License
53 * along with this program; if not, write to the Free Software
54 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57 * 12/10/99 - Alpha Release 0.1.0
58 * First release to the public
59 * 03/03/00 - Merged to kernel, indented -kr -i8 -bri0, fixed some missing
60 * malloc free checks, reviewed code. <alan@redhat.com>
61 * 03/13/00 - Added spinlocks for smp
62 * 03/08/01 - Added support for module_init() and module_exit()
63 * 08/15/01 - Added ioctl() functionality for debugging, changed netif_*_queue
64 * calls and other incorrectness - Kent Yoder <yoder1@us.ibm.com>
65 * 11/05/01 - Restructured the interrupt function, added delays, reduced the
66 * the number of TX descriptors to 1, which together can prevent
67 * the card from locking up the box - <yoder1@us.ibm.com>
68 * 09/27/02 - New PCI interface + bug fix. - <yoder1@us.ibm.com>
69 * 11/13/02 - Removed free_irq calls which could cause a hang, added
70 * netif_carrier_{on|off} - <yoder1@us.ibm.com>
75 * If Problems do Occur
76 * Most problems can be rectified by either closing and opening the interface
77 * (ifconfig down and up) or rmmod and insmod'ing the driver (a bit difficult
78 * if compiled into the kernel).
81 /* Change STREAMER_DEBUG to 1 to get verbose, and I mean really verbose, messages */
83 #define STREAMER_DEBUG 0
84 #define STREAMER_DEBUG_PACKETS 0
86 /* Change STREAMER_NETWORK_MONITOR to receive mac frames through the arb channel.
87 * Will also create a /proc/net/streamer_tr entry if proc_fs is compiled into the
89 * Intended to be used to create a ring-error reporting network module
90 * i.e. it will give you the source address of beaconers on the ring
93 #define STREAMER_NETWORK_MONITOR 0
95 /* #define CONFIG_PROC_FS */
98 * Allow or disallow ioctl's for debugging
101 #define STREAMER_IOCTL 0
103 #include <linux/config.h>
104 #include <linux/module.h>
105 #include <linux/kernel.h>
106 #include <linux/errno.h>
107 #include <linux/timer.h>
108 #include <linux/in.h>
109 #include <linux/ioport.h>
110 #include <linux/string.h>
111 #include <linux/proc_fs.h>
112 #include <linux/ptrace.h>
113 #include <linux/skbuff.h>
114 #include <linux/interrupt.h>
115 #include <linux/delay.h>
116 #include <linux/netdevice.h>
117 #include <linux/trdevice.h>
118 #include <linux/stddef.h>
119 #include <linux/init.h>
120 #include <linux/pci.h>
121 #include <linux/dma-mapping.h>
122 #include <linux/spinlock.h>
123 #include <linux/version.h>
124 #include <linux/bitops.h>
126 #include <net/checksum.h>
129 #include <asm/system.h>
131 #include "lanstreamer.h"
133 #if (BITS_PER_LONG == 64)
134 #error broken on 64-bit: stores pointer to rx_ring->buffer in 32-bit int
138 /* I've got to put some intelligence into the version number so that Peter and I know
139 * which version of the code somebody has got.
140 * Version Number = a.b.c.d where a.b.c is the level of code and d is the latest author.
141 * So 0.0.1.pds = Peter, 0.0.1.mlp = Mike
143 * Official releases will only have an a.b.c version number format.
146 static char version[] = "LanStreamer.c v0.4.0 03/08/01 - Mike Sullivan\n"
147 " v0.5.3 11/13/02 - Kent Yoder";
149 static struct pci_device_id streamer_pci_tbl[] = {
150 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_TR, PCI_ANY_ID, PCI_ANY_ID,},
151 {} /* terminating entry */
153 MODULE_DEVICE_TABLE(pci,streamer_pci_tbl);
156 static char *open_maj_error[] = {
157 "No error", "Lobe Media Test", "Physical Insertion",
158 "Address Verification", "Neighbor Notification (Ring Poll)",
159 "Request Parameters", "FDX Registration Request",
160 "FDX Lobe Media Test", "FDX Duplicate Address Check",
164 static char *open_min_error[] = {
165 "No error", "Function Failure", "Signal Lost", "Wire Fault",
166 "Ring Speed Mismatch", "Timeout", "Ring Failure", "Ring Beaconing",
167 "Duplicate Node Address", "Request Parameters", "Remove Received",
168 "Reserved", "Reserved", "No Monitor Detected for RPL",
169 "Monitor Contention failer for RPL", "FDX Protocol Error"
172 /* Module paramters */
176 * 4,16 = Selected speed only, no autosense
177 * This allows the card to be the first on the ring
178 * and become the active monitor.
180 * WARNING: Some hubs will allow you to insert
184 static int ringspeed[STREAMER_MAX_ADAPTERS] = { 0, };
186 module_param_array(ringspeed, int, NULL, 0);
188 /* Packet buffer size */
190 static int pkt_buf_sz[STREAMER_MAX_ADAPTERS] = { 0, };
192 module_param_array(pkt_buf_sz, int, NULL, 0);
196 static int message_level[STREAMER_MAX_ADAPTERS] = { 1, };
198 module_param_array(message_level, int, NULL, 0);
201 static int streamer_ioctl(struct net_device *, struct ifreq *, int);
204 static int streamer_reset(struct net_device *dev);
205 static int streamer_open(struct net_device *dev);
206 static int streamer_xmit(struct sk_buff *skb, struct net_device *dev);
207 static int streamer_close(struct net_device *dev);
208 static void streamer_set_rx_mode(struct net_device *dev);
209 static irqreturn_t streamer_interrupt(int irq, void *dev_id,
210 struct pt_regs *regs);
211 static struct net_device_stats *streamer_get_stats(struct net_device *dev);
212 static int streamer_set_mac_address(struct net_device *dev, void *addr);
213 static void streamer_arb_cmd(struct net_device *dev);
214 static int streamer_change_mtu(struct net_device *dev, int mtu);
215 static void streamer_srb_bh(struct net_device *dev);
216 static void streamer_asb_bh(struct net_device *dev);
217 #if STREAMER_NETWORK_MONITOR
218 #ifdef CONFIG_PROC_FS
219 static int streamer_proc_info(char *buffer, char **start, off_t offset,
220 int length, int *eof, void *data);
221 static int sprintf_info(char *buffer, struct net_device *dev);
222 struct streamer_private *dev_streamer=NULL;
226 static int __devinit streamer_init_one(struct pci_dev *pdev,
227 const struct pci_device_id *ent)
229 struct net_device *dev;
230 struct streamer_private *streamer_priv;
231 unsigned long pio_start, pio_end, pio_flags, pio_len;
232 unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
234 static int card_no=-1;
238 printk("lanstreamer::streamer_init_one, entry pdev %p\n",pdev);
242 dev = alloc_trdev(sizeof(*streamer_priv));
244 printk(KERN_ERR "lanstreamer: out of memory.\n");
248 SET_MODULE_OWNER(dev);
249 streamer_priv = dev->priv;
251 #if STREAMER_NETWORK_MONITOR
252 #ifdef CONFIG_PROC_FS
254 create_proc_read_entry("net/streamer_tr", 0, 0,
255 streamer_proc_info, NULL);
256 streamer_priv->next = dev_streamer;
257 dev_streamer = streamer_priv;
261 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
263 printk(KERN_ERR "%s: No suitable PCI mapping available.\n",
269 rc = pci_enable_device(pdev);
271 printk(KERN_ERR "lanstreamer: unable to enable pci device\n");
276 pci_set_master(pdev);
278 rc = pci_set_mwi(pdev);
280 printk(KERN_ERR "lanstreamer: unable to enable MWI on pci device\n");
281 goto err_out_disable;
284 pio_start = pci_resource_start(pdev, 0);
285 pio_end = pci_resource_end(pdev, 0);
286 pio_flags = pci_resource_flags(pdev, 0);
287 pio_len = pci_resource_len(pdev, 0);
289 mmio_start = pci_resource_start(pdev, 1);
290 mmio_end = pci_resource_end(pdev, 1);
291 mmio_flags = pci_resource_flags(pdev, 1);
292 mmio_len = pci_resource_len(pdev, 1);
295 printk("lanstreamer: pio_start %x pio_end %x pio_len %x pio_flags %x\n",
296 pio_start, pio_end, pio_len, pio_flags);
297 printk("lanstreamer: mmio_start %x mmio_end %x mmio_len %x mmio_flags %x\n",
298 mmio_start, mmio_end, mmio_flags, mmio_len);
301 if (!request_region(pio_start, pio_len, "lanstreamer")) {
302 printk(KERN_ERR "lanstreamer: unable to get pci io addr %lx\n",
308 if (!request_mem_region(mmio_start, mmio_len, "lanstreamer")) {
309 printk(KERN_ERR "lanstreamer: unable to get pci mmio addr %lx\n",
312 goto err_out_free_pio;
315 streamer_priv->streamer_mmio=ioremap(mmio_start, mmio_len);
316 if (streamer_priv->streamer_mmio == NULL) {
317 printk(KERN_ERR "lanstreamer: unable to remap MMIO %lx\n",
320 goto err_out_free_mmio;
323 init_waitqueue_head(&streamer_priv->srb_wait);
324 init_waitqueue_head(&streamer_priv->trb_wait);
326 dev->open = &streamer_open;
327 dev->hard_start_xmit = &streamer_xmit;
328 dev->change_mtu = &streamer_change_mtu;
329 dev->stop = &streamer_close;
331 dev->do_ioctl = &streamer_ioctl;
333 dev->do_ioctl = NULL;
335 dev->set_multicast_list = &streamer_set_rx_mode;
336 dev->get_stats = &streamer_get_stats;
337 dev->set_mac_address = &streamer_set_mac_address;
338 dev->irq = pdev->irq;
339 dev->base_addr=pio_start;
340 SET_NETDEV_DEV(dev, &pdev->dev);
342 streamer_priv->streamer_card_name = (char *)pdev->resource[0].name;
343 streamer_priv->pci_dev = pdev;
345 if ((pkt_buf_sz[card_no] < 100) || (pkt_buf_sz[card_no] > 18000))
346 streamer_priv->pkt_buf_sz = PKT_BUF_SZ;
348 streamer_priv->pkt_buf_sz = pkt_buf_sz[card_no];
350 streamer_priv->streamer_ring_speed = ringspeed[card_no];
351 streamer_priv->streamer_message_level = message_level[card_no];
353 pci_set_drvdata(pdev, dev);
355 spin_lock_init(&streamer_priv->streamer_lock);
357 pci_read_config_word (pdev, PCI_COMMAND, &pcr);
358 pcr |= PCI_COMMAND_SERR;
359 pci_write_config_word (pdev, PCI_COMMAND, pcr);
361 printk("%s \n", version);
362 printk("%s: %s. I/O at %hx, MMIO at %p, using irq %d\n",dev->name,
363 streamer_priv->streamer_card_name,
364 (unsigned int) dev->base_addr,
365 streamer_priv->streamer_mmio,
368 if (streamer_reset(dev))
371 rc = register_netdev(dev);
377 iounmap(streamer_priv->streamer_mmio);
379 release_mem_region(mmio_start, mmio_len);
381 release_region(pio_start, pio_len);
385 pci_disable_device(pdev);
389 printk("lanstreamer: Exit error %x\n",rc);
394 static void __devexit streamer_remove_one(struct pci_dev *pdev)
396 struct net_device *dev=pci_get_drvdata(pdev);
397 struct streamer_private *streamer_priv;
400 printk("lanstreamer::streamer_remove_one entry pdev %p\n",pdev);
404 printk(KERN_ERR "lanstreamer::streamer_remove_one, ERROR dev is NULL\n");
408 streamer_priv=dev->priv;
409 if (streamer_priv == NULL) {
410 printk(KERN_ERR "lanstreamer::streamer_remove_one, ERROR dev->priv is NULL\n");
414 #if STREAMER_NETWORK_MONITOR
415 #ifdef CONFIG_PROC_FS
417 struct streamer_private **p, **next;
419 for (p = &dev_streamer; *p; p = next) {
421 if (*p == streamer_priv) {
427 remove_proc_entry("net/streamer_tr", NULL);
432 unregister_netdev(dev);
433 iounmap(streamer_priv->streamer_mmio);
434 release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev,1));
435 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
437 pci_disable_device(pdev);
439 pci_set_drvdata(pdev, NULL);
443 static int streamer_reset(struct net_device *dev)
445 struct streamer_private *streamer_priv;
446 __u8 __iomem *streamer_mmio;
448 unsigned int uaa_addr;
449 struct sk_buff *skb = NULL;
452 streamer_priv = (struct streamer_private *) dev->priv;
453 streamer_mmio = streamer_priv->streamer_mmio;
455 writew(readw(streamer_mmio + BCTL) | BCTL_SOFTRESET, streamer_mmio + BCTL);
457 /* Hold soft reset bit for a while */
458 current->state = TASK_UNINTERRUPTIBLE;
459 schedule_timeout(HZ);
461 writew(readw(streamer_mmio + BCTL) & ~BCTL_SOFTRESET,
462 streamer_mmio + BCTL);
465 printk("BCTL: %x\n", readw(streamer_mmio + BCTL));
466 printk("GPR: %x\n", readw(streamer_mmio + GPR));
467 printk("SISRMASK: %x\n", readw(streamer_mmio + SISR_MASK));
469 writew(readw(streamer_mmio + BCTL) | (BCTL_RX_FIFO_8 | BCTL_TX_FIFO_8), streamer_mmio + BCTL );
471 if (streamer_priv->streamer_ring_speed == 0) { /* Autosense */
472 writew(readw(streamer_mmio + GPR) | GPR_AUTOSENSE,
473 streamer_mmio + GPR);
474 if (streamer_priv->streamer_message_level)
475 printk(KERN_INFO "%s: Ringspeed autosense mode on\n",
477 } else if (streamer_priv->streamer_ring_speed == 16) {
478 if (streamer_priv->streamer_message_level)
479 printk(KERN_INFO "%s: Trying to open at 16 Mbps as requested\n",
481 writew(GPR_16MBPS, streamer_mmio + GPR);
482 } else if (streamer_priv->streamer_ring_speed == 4) {
483 if (streamer_priv->streamer_message_level)
484 printk(KERN_INFO "%s: Trying to open at 4 Mbps as requested\n",
486 writew(0, streamer_mmio + GPR);
489 skb = dev_alloc_skb(streamer_priv->pkt_buf_sz);
491 printk(KERN_INFO "%s: skb allocation for diagnostics failed...proceeding\n",
494 struct streamer_rx_desc *rx_ring;
497 rx_ring=(struct streamer_rx_desc *)skb->data;
498 data=((u8 *)skb->data)+sizeof(struct streamer_rx_desc);
501 rx_ring->buffer=cpu_to_le32(pci_map_single(streamer_priv->pci_dev, data,
502 512, PCI_DMA_FROMDEVICE));
503 rx_ring->framelen_buflen=512;
504 writel(cpu_to_le32(pci_map_single(streamer_priv->pci_dev, rx_ring, 512, PCI_DMA_FROMDEVICE)),
505 streamer_mmio+RXBDA);
509 printk("GPR = %x\n", readw(streamer_mmio + GPR));
511 /* start solo init */
512 writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
514 while (!((readw(streamer_mmio + SISR)) & SISR_SRB_REPLY)) {
515 current->state = TASK_INTERRUPTIBLE;
516 schedule_timeout(HZ/10);
517 if (jiffies - t > 40 * HZ) {
519 "IBM PCI tokenring card not responding\n");
520 release_region(dev->base_addr, STREAMER_IO_SPACE);
526 writew(~SISR_SRB_REPLY, streamer_mmio + SISR_RUM);
527 misr = readw(streamer_mmio + MISR_RUM);
528 writew(~misr, streamer_mmio + MISR_RUM);
531 dev_kfree_skb(skb); /* release skb used for diagnostics */
534 printk("LAPWWO: %x, LAPA: %x LAPE: %x\n",
535 readw(streamer_mmio + LAPWWO), readw(streamer_mmio + LAPA),
536 readw(streamer_mmio + LAPE));
542 writew(readw(streamer_mmio + LAPWWO),
543 streamer_mmio + LAPA);
544 printk("initialization response srb dump: ");
545 for (i = 0; i < 10; i++)
547 ntohs(readw(streamer_mmio + LAPDINC)));
552 writew(readw(streamer_mmio + LAPWWO) + 6, streamer_mmio + LAPA);
553 if (readw(streamer_mmio + LAPD)) {
554 printk(KERN_INFO "tokenring card initialization failed. errorcode : %x\n",
555 ntohs(readw(streamer_mmio + LAPD)));
556 release_region(dev->base_addr, STREAMER_IO_SPACE);
560 writew(readw(streamer_mmio + LAPWWO) + 8, streamer_mmio + LAPA);
561 uaa_addr = ntohs(readw(streamer_mmio + LAPDINC));
562 readw(streamer_mmio + LAPDINC); /* skip over Level.Addr field */
563 streamer_priv->streamer_addr_table_addr = ntohs(readw(streamer_mmio + LAPDINC));
564 streamer_priv->streamer_parms_addr = ntohs(readw(streamer_mmio + LAPDINC));
567 printk("UAA resides at %x\n", uaa_addr);
570 /* setup uaa area for access with LAPD */
574 writew(uaa_addr, streamer_mmio + LAPA);
575 for (i = 0; i < 6; i += 2) {
576 addr=ntohs(readw(streamer_mmio+LAPDINC));
577 dev->dev_addr[i]= (addr >> 8) & 0xff;
578 dev->dev_addr[i+1]= addr & 0xff;
581 printk("Adapter address: ");
582 for (i = 0; i < 6; i++) {
583 printk("%02x:", dev->dev_addr[i]);
591 static int streamer_open(struct net_device *dev)
593 struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
594 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
596 char open_error[255];
597 int i, open_finished = 1;
602 if (readw(streamer_mmio+BMCTL_SUM) & BMCTL_RX_ENABLED) {
603 rc=streamer_reset(dev);
606 if (request_irq(dev->irq, &streamer_interrupt, SA_SHIRQ, "lanstreamer", dev)) {
610 printk("BMCTL: %x\n", readw(streamer_mmio + BMCTL_SUM));
611 printk("pending ints: %x\n", readw(streamer_mmio + SISR));
614 writew(SISR_MI | SISR_SRB_REPLY, streamer_mmio + SISR_MASK); /* more ints later, doesn't stop arb cmd interrupt */
615 writew(LISR_LIE, streamer_mmio + LISR); /* more ints later */
617 /* adapter is closed, so SRB is pointed to by LAPWWO */
618 writew(readw(streamer_mmio + LAPWWO), streamer_mmio + LAPA);
621 printk("LAPWWO: %x, LAPA: %x\n", readw(streamer_mmio + LAPWWO),
622 readw(streamer_mmio + LAPA));
623 printk("LAPE: %x\n", readw(streamer_mmio + LAPE));
624 printk("SISR Mask = %04x\n", readw(streamer_mmio + SISR_MASK));
629 for (i = 0; i < SRB_COMMAND_SIZE; i += 2) {
630 writew(0, streamer_mmio + LAPDINC);
633 writew(readw(streamer_mmio+LAPWWO),streamer_mmio+LAPA);
634 writew(htons(SRB_OPEN_ADAPTER<<8),streamer_mmio+LAPDINC) ; /* open */
635 writew(htons(STREAMER_CLEAR_RET_CODE<<8),streamer_mmio+LAPDINC);
636 writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);
638 writew(readw(streamer_mmio + LAPWWO) + 8, streamer_mmio + LAPA);
639 #if STREAMER_NETWORK_MONITOR
640 /* If Network Monitor, instruct card to copy MAC frames through the ARB */
641 writew(htons(OPEN_ADAPTER_ENABLE_FDX | OPEN_ADAPTER_PASS_ADC_MAC | OPEN_ADAPTER_PASS_ATT_MAC | OPEN_ADAPTER_PASS_BEACON), streamer_mmio + LAPDINC); /* offset 8 word contains open options */
643 writew(htons(OPEN_ADAPTER_ENABLE_FDX), streamer_mmio + LAPDINC); /* Offset 8 word contains Open.Options */
646 if (streamer_priv->streamer_laa[0]) {
647 writew(readw(streamer_mmio + LAPWWO) + 12, streamer_mmio + LAPA);
648 writew(htons((streamer_priv->streamer_laa[0] << 8) |
649 streamer_priv->streamer_laa[1]),streamer_mmio+LAPDINC);
650 writew(htons((streamer_priv->streamer_laa[2] << 8) |
651 streamer_priv->streamer_laa[3]),streamer_mmio+LAPDINC);
652 writew(htons((streamer_priv->streamer_laa[4] << 8) |
653 streamer_priv->streamer_laa[5]),streamer_mmio+LAPDINC);
654 memcpy(dev->dev_addr, streamer_priv->streamer_laa, dev->addr_len);
657 /* save off srb open offset */
658 srb_open = readw(streamer_mmio + LAPWWO);
660 writew(readw(streamer_mmio + LAPWWO),
661 streamer_mmio + LAPA);
662 printk("srb open request: \n");
663 for (i = 0; i < 16; i++) {
664 printk("%x:", ntohs(readw(streamer_mmio + LAPDINC)));
668 spin_lock_irqsave(&streamer_priv->streamer_lock, flags);
669 streamer_priv->srb_queued = 1;
671 /* signal solo that SRB command has been issued */
672 writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
673 spin_unlock_irqrestore(&streamer_priv->streamer_lock, flags);
675 while (streamer_priv->srb_queued) {
676 interruptible_sleep_on_timeout(&streamer_priv->srb_wait, 5 * HZ);
677 if (signal_pending(current)) {
678 printk(KERN_WARNING "%s: SRB timed out.\n", dev->name);
679 printk(KERN_WARNING "SISR=%x MISR=%x, LISR=%x\n",
680 readw(streamer_mmio + SISR),
681 readw(streamer_mmio + MISR_RUM),
682 readw(streamer_mmio + LISR));
683 streamer_priv->srb_queued = 0;
689 printk("SISR_MASK: %x\n", readw(streamer_mmio + SISR_MASK));
690 printk("srb open response:\n");
691 writew(srb_open, streamer_mmio + LAPA);
692 for (i = 0; i < 10; i++) {
694 ntohs(readw(streamer_mmio + LAPDINC)));
698 /* If we get the same return response as we set, the interrupt wasn't raised and the open
701 writew(srb_open + 2, streamer_mmio + LAPA);
702 srb_word = ntohs(readw(streamer_mmio + LAPD)) >> 8;
703 if (srb_word == STREAMER_CLEAR_RET_CODE) {
704 printk(KERN_WARNING "%s: Adapter Open time out or error.\n",
710 if (srb_word == 0x07) {
711 if (!streamer_priv->streamer_ring_speed && open_finished) { /* Autosense , first time around */
712 printk(KERN_WARNING "%s: Retrying at different ring speed \n",
718 writew(srb_open + 6, streamer_mmio + LAPA);
719 error_code = ntohs(readw(streamer_mmio + LAPD));
720 strcpy(open_error, open_maj_error[(error_code & 0xf0) >> 4]);
721 strcat(open_error, " - ");
722 strcat(open_error, open_min_error[(error_code & 0x0f)]);
724 if (!streamer_priv->streamer_ring_speed
725 && ((error_code & 0x0f) == 0x0d))
727 printk(KERN_WARNING "%s: Tried to autosense ring speed with no monitors present\n", dev->name);
728 printk(KERN_WARNING "%s: Please try again with a specified ring speed \n", dev->name);
729 free_irq(dev->irq, dev);
733 printk(KERN_WARNING "%s: %s\n",
734 dev->name, open_error);
735 free_irq(dev->irq, dev);
738 } /* if autosense && open_finished */
740 printk(KERN_WARNING "%s: Bad OPEN response: %x\n",
741 dev->name, srb_word);
742 free_irq(dev->irq, dev);
747 } while (!(open_finished)); /* Will only loop if ring speed mismatch re-open attempted && autosense is on */
749 writew(srb_open + 18, streamer_mmio + LAPA);
750 srb_word=ntohs(readw(streamer_mmio+LAPD)) >> 8;
751 if (srb_word & (1 << 3))
752 if (streamer_priv->streamer_message_level)
753 printk(KERN_INFO "%s: Opened in FDX Mode\n", dev->name);
756 streamer_priv->streamer_ring_speed = 16;
758 streamer_priv->streamer_ring_speed = 4;
760 if (streamer_priv->streamer_message_level)
761 printk(KERN_INFO "%s: Opened in %d Mbps mode\n",
763 streamer_priv->streamer_ring_speed);
765 writew(srb_open + 8, streamer_mmio + LAPA);
766 streamer_priv->asb = ntohs(readw(streamer_mmio + LAPDINC));
767 streamer_priv->srb = ntohs(readw(streamer_mmio + LAPDINC));
768 streamer_priv->arb = ntohs(readw(streamer_mmio + LAPDINC));
769 readw(streamer_mmio + LAPDINC); /* offset 14 word is rsvd */
770 streamer_priv->trb = ntohs(readw(streamer_mmio + LAPDINC));
772 streamer_priv->streamer_receive_options = 0x00;
773 streamer_priv->streamer_copy_all_options = 0;
776 /* enable rx channel */
777 writew(~BMCTL_RX_DIS, streamer_mmio + BMCTL_RUM);
779 /* setup rx descriptors */
780 streamer_priv->streamer_rx_ring=
781 kmalloc( sizeof(struct streamer_rx_desc)*
782 STREAMER_RX_RING_SIZE,GFP_KERNEL);
783 if (!streamer_priv->streamer_rx_ring) {
784 printk(KERN_WARNING "%s ALLOC of streamer rx ring FAILED!!\n",dev->name);
788 for (i = 0; i < STREAMER_RX_RING_SIZE; i++) {
791 skb = dev_alloc_skb(streamer_priv->pkt_buf_sz);
797 streamer_priv->streamer_rx_ring[i].forward =
798 cpu_to_le32(pci_map_single(streamer_priv->pci_dev, &streamer_priv->streamer_rx_ring[i + 1],
799 sizeof(struct streamer_rx_desc), PCI_DMA_FROMDEVICE));
800 streamer_priv->streamer_rx_ring[i].status = 0;
801 streamer_priv->streamer_rx_ring[i].buffer =
802 cpu_to_le32(pci_map_single(streamer_priv->pci_dev, skb->data,
803 streamer_priv->pkt_buf_sz, PCI_DMA_FROMDEVICE));
804 streamer_priv->streamer_rx_ring[i].framelen_buflen = streamer_priv->pkt_buf_sz;
805 streamer_priv->rx_ring_skb[i] = skb;
807 streamer_priv->streamer_rx_ring[STREAMER_RX_RING_SIZE - 1].forward =
808 cpu_to_le32(pci_map_single(streamer_priv->pci_dev, &streamer_priv->streamer_rx_ring[0],
809 sizeof(struct streamer_rx_desc), PCI_DMA_FROMDEVICE));
812 printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers. Adapter disabled\n", dev->name);
813 free_irq(dev->irq, dev);
817 streamer_priv->rx_ring_last_received = STREAMER_RX_RING_SIZE - 1; /* last processed rx status */
819 writel(cpu_to_le32(pci_map_single(streamer_priv->pci_dev, &streamer_priv->streamer_rx_ring[0],
820 sizeof(struct streamer_rx_desc), PCI_DMA_TODEVICE)),
821 streamer_mmio + RXBDA);
822 writel(cpu_to_le32(pci_map_single(streamer_priv->pci_dev, &streamer_priv->streamer_rx_ring[STREAMER_RX_RING_SIZE - 1],
823 sizeof(struct streamer_rx_desc), PCI_DMA_TODEVICE)),
824 streamer_mmio + RXLBDA);
826 /* set bus master interrupt event mask */
827 writew(MISR_RX_NOBUF | MISR_RX_EOF, streamer_mmio + MISR_MASK);
831 streamer_priv->streamer_tx_ring=kmalloc(sizeof(struct streamer_tx_desc)*
832 STREAMER_TX_RING_SIZE,GFP_KERNEL);
833 if (!streamer_priv->streamer_tx_ring) {
834 printk(KERN_WARNING "%s ALLOC of streamer_tx_ring FAILED\n",dev->name);
838 writew(~BMCTL_TX2_DIS, streamer_mmio + BMCTL_RUM); /* Enables TX channel 2 */
839 for (i = 0; i < STREAMER_TX_RING_SIZE; i++) {
840 streamer_priv->streamer_tx_ring[i].forward = cpu_to_le32(pci_map_single(streamer_priv->pci_dev,
841 &streamer_priv->streamer_tx_ring[i + 1],
842 sizeof(struct streamer_tx_desc),
844 streamer_priv->streamer_tx_ring[i].status = 0;
845 streamer_priv->streamer_tx_ring[i].bufcnt_framelen = 0;
846 streamer_priv->streamer_tx_ring[i].buffer = 0;
847 streamer_priv->streamer_tx_ring[i].buflen = 0;
848 streamer_priv->streamer_tx_ring[i].rsvd1 = 0;
849 streamer_priv->streamer_tx_ring[i].rsvd2 = 0;
850 streamer_priv->streamer_tx_ring[i].rsvd3 = 0;
852 streamer_priv->streamer_tx_ring[STREAMER_TX_RING_SIZE - 1].forward =
853 cpu_to_le32(pci_map_single(streamer_priv->pci_dev, &streamer_priv->streamer_tx_ring[0],
854 sizeof(struct streamer_tx_desc), PCI_DMA_TODEVICE));
856 streamer_priv->free_tx_ring_entries = STREAMER_TX_RING_SIZE;
857 streamer_priv->tx_ring_free = 0; /* next entry in tx ring to use */
858 streamer_priv->tx_ring_last_status = STREAMER_TX_RING_SIZE - 1;
860 /* set Busmaster interrupt event mask (handle receives on interrupt only */
861 writew(MISR_TX2_EOF | MISR_RX_NOBUF | MISR_RX_EOF, streamer_mmio + MISR_MASK);
862 /* set system event interrupt mask */
863 writew(SISR_ADAPTER_CHECK | SISR_ARB_CMD | SISR_TRB_REPLY | SISR_ASB_FREE, streamer_mmio + SISR_MASK_SUM);
866 printk("BMCTL: %x\n", readw(streamer_mmio + BMCTL_SUM));
867 printk("SISR MASK: %x\n", readw(streamer_mmio + SISR_MASK));
870 #if STREAMER_NETWORK_MONITOR
872 writew(streamer_priv->streamer_addr_table_addr, streamer_mmio + LAPA);
873 printk("%s: Node Address: %04x:%04x:%04x\n", dev->name,
874 ntohs(readw(streamer_mmio + LAPDINC)),
875 ntohs(readw(streamer_mmio + LAPDINC)),
876 ntohs(readw(streamer_mmio + LAPDINC)));
877 readw(streamer_mmio + LAPDINC);
878 readw(streamer_mmio + LAPDINC);
879 printk("%s: Functional Address: %04x:%04x\n", dev->name,
880 ntohs(readw(streamer_mmio + LAPDINC)),
881 ntohs(readw(streamer_mmio + LAPDINC)));
883 writew(streamer_priv->streamer_parms_addr + 4,
884 streamer_mmio + LAPA);
885 printk("%s: NAUN Address: %04x:%04x:%04x\n", dev->name,
886 ntohs(readw(streamer_mmio + LAPDINC)),
887 ntohs(readw(streamer_mmio + LAPDINC)),
888 ntohs(readw(streamer_mmio + LAPDINC)));
891 netif_start_queue(dev);
892 netif_carrier_on(dev);
897 * When we enter the rx routine we do not know how many frames have been
898 * queued on the rx channel. Therefore we start at the next rx status
899 * position and travel around the receive ring until we have completed
902 * This means that we may process the frame before we receive the end
903 * of frame interrupt. This is why we always test the status instead
904 * of blindly processing the next frame.
907 static void streamer_rx(struct net_device *dev)
909 struct streamer_private *streamer_priv =
910 (struct streamer_private *) dev->priv;
911 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
912 struct streamer_rx_desc *rx_desc;
913 int rx_ring_last_received, length, frame_length, buffer_cnt = 0;
914 struct sk_buff *skb, *skb2;
916 /* setup the next rx descriptor to be received */
917 rx_desc = &streamer_priv->streamer_rx_ring[(streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1)];
918 rx_ring_last_received = streamer_priv->rx_ring_last_received;
920 while (rx_desc->status & 0x01000000) { /* While processed descriptors are available */
921 if (rx_ring_last_received != streamer_priv->rx_ring_last_received)
923 printk(KERN_WARNING "RX Error 1 rx_ring_last_received not the same %x %x\n",
924 rx_ring_last_received, streamer_priv->rx_ring_last_received);
926 streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1);
927 rx_ring_last_received = streamer_priv->rx_ring_last_received;
929 length = rx_desc->framelen_buflen & 0xffff; /* buffer length */
930 frame_length = (rx_desc->framelen_buflen >> 16) & 0xffff;
932 if (rx_desc->status & 0x7E830000) { /* errors */
933 if (streamer_priv->streamer_message_level) {
934 printk(KERN_WARNING "%s: Rx Error %x \n",
935 dev->name, rx_desc->status);
937 } else { /* received without errors */
938 if (rx_desc->status & 0x80000000) { /* frame complete */
940 skb = dev_alloc_skb(streamer_priv->pkt_buf_sz);
942 skb = dev_alloc_skb(frame_length);
947 printk(KERN_WARNING "%s: Not enough memory to copy packet to upper layers. \n", dev->name);
948 streamer_priv->streamer_stats.rx_dropped++;
949 } else { /* we allocated an skb OK */
952 if (buffer_cnt == 1) {
953 /* release the DMA mapping */
954 pci_unmap_single(streamer_priv->pci_dev,
955 le32_to_cpu(streamer_priv->streamer_rx_ring[rx_ring_last_received].buffer),
956 streamer_priv->pkt_buf_sz,
958 skb2 = streamer_priv->rx_ring_skb[rx_ring_last_received];
959 #if STREAMER_DEBUG_PACKETS
962 printk("streamer_rx packet print: skb->data2 %p skb->head %p\n", skb2->data, skb2->head);
963 for (i = 0; i < frame_length; i++)
965 printk("%x:", skb2->data[i]);
966 if (((i + 1) % 16) == 0)
972 skb_put(skb2, length);
973 skb2->protocol = tr_type_trans(skb2, dev);
974 /* recycle this descriptor */
975 streamer_priv->streamer_rx_ring[rx_ring_last_received].status = 0;
976 streamer_priv->streamer_rx_ring[rx_ring_last_received].framelen_buflen = streamer_priv->pkt_buf_sz;
977 streamer_priv->streamer_rx_ring[rx_ring_last_received].buffer =
978 cpu_to_le32(pci_map_single(streamer_priv->pci_dev, skb->data, streamer_priv->pkt_buf_sz,
979 PCI_DMA_FROMDEVICE));
980 streamer_priv->rx_ring_skb[rx_ring_last_received] = skb;
981 /* place recycled descriptor back on the adapter */
982 writel(cpu_to_le32(pci_map_single(streamer_priv->pci_dev,
983 &streamer_priv->streamer_rx_ring[rx_ring_last_received],
984 sizeof(struct streamer_rx_desc), PCI_DMA_FROMDEVICE)),
985 streamer_mmio + RXLBDA);
986 /* pass the received skb up to the protocol */
989 do { /* Walk the buffers */
990 pci_unmap_single(streamer_priv->pci_dev, le32_to_cpu(rx_desc->buffer), length, PCI_DMA_FROMDEVICE),
991 memcpy(skb_put(skb, length), (void *)rx_desc->buffer, length); /* copy this fragment */
992 streamer_priv->streamer_rx_ring[rx_ring_last_received].status = 0;
993 streamer_priv->streamer_rx_ring[rx_ring_last_received].framelen_buflen = streamer_priv->pkt_buf_sz;
995 /* give descriptor back to the adapter */
996 writel(cpu_to_le32(pci_map_single(streamer_priv->pci_dev,
997 &streamer_priv->streamer_rx_ring[rx_ring_last_received],
998 length, PCI_DMA_FROMDEVICE)),
999 streamer_mmio + RXLBDA);
1001 if (rx_desc->status & 0x80000000)
1002 break; /* this descriptor completes the frame */
1004 /* else get the next pending descriptor */
1005 if (rx_ring_last_received!= streamer_priv->rx_ring_last_received)
1007 printk("RX Error rx_ring_last_received not the same %x %x\n",
1008 rx_ring_last_received,
1009 streamer_priv->rx_ring_last_received);
1011 rx_desc = &streamer_priv->streamer_rx_ring[(streamer_priv->rx_ring_last_received+1) & (STREAMER_RX_RING_SIZE-1)];
1013 length = rx_desc->framelen_buflen & 0xffff; /* buffer length */
1014 streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received+1) & (STREAMER_RX_RING_SIZE - 1);
1015 rx_ring_last_received = streamer_priv->rx_ring_last_received;
1018 skb->protocol = tr_type_trans(skb, dev);
1019 /* send up to the protocol */
1022 dev->last_rx = jiffies;
1023 streamer_priv->streamer_stats.rx_packets++;
1024 streamer_priv->streamer_stats.rx_bytes += length;
1025 } /* if skb == null */
1026 } /* end received without errors */
1028 /* try the next one */
1029 rx_desc = &streamer_priv->streamer_rx_ring[(rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1)];
1030 } /* end for all completed rx descriptors */
1033 static irqreturn_t streamer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1035 struct net_device *dev = (struct net_device *) dev_id;
1036 struct streamer_private *streamer_priv =
1037 (struct streamer_private *) dev->priv;
1038 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1041 u8 max_intr = MAX_INTR;
1043 spin_lock(&streamer_priv->streamer_lock);
1044 sisr = readw(streamer_mmio + SISR);
1046 while((sisr & (SISR_MI | SISR_SRB_REPLY | SISR_ADAPTER_CHECK | SISR_ASB_FREE |
1047 SISR_ARB_CMD | SISR_TRB_REPLY | SISR_PAR_ERR | SISR_SERR_ERR))
1048 && (max_intr > 0)) {
1050 if(sisr & SISR_PAR_ERR) {
1051 writew(~SISR_PAR_ERR, streamer_mmio + SISR_RUM);
1052 (void)readw(streamer_mmio + SISR_RUM);
1055 else if(sisr & SISR_SERR_ERR) {
1056 writew(~SISR_SERR_ERR, streamer_mmio + SISR_RUM);
1057 (void)readw(streamer_mmio + SISR_RUM);
1060 else if(sisr & SISR_MI) {
1061 misr = readw(streamer_mmio + MISR_RUM);
1063 if (misr & MISR_TX2_EOF) {
1064 while(streamer_priv->streamer_tx_ring[(streamer_priv->tx_ring_last_status + 1) & (STREAMER_TX_RING_SIZE - 1)].status) {
1065 streamer_priv->tx_ring_last_status = (streamer_priv->tx_ring_last_status + 1) & (STREAMER_TX_RING_SIZE - 1);
1066 streamer_priv->free_tx_ring_entries++;
1067 streamer_priv->streamer_stats.tx_bytes += streamer_priv->tx_ring_skb[streamer_priv->tx_ring_last_status]->len;
1068 streamer_priv->streamer_stats.tx_packets++;
1069 dev_kfree_skb_irq(streamer_priv->tx_ring_skb[streamer_priv->tx_ring_last_status]);
1070 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].buffer = 0xdeadbeef;
1071 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].status = 0;
1072 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].bufcnt_framelen = 0;
1073 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].buflen = 0;
1074 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].rsvd1 = 0;
1075 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].rsvd2 = 0;
1076 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].rsvd3 = 0;
1078 netif_wake_queue(dev);
1081 if (misr & MISR_RX_EOF) {
1086 if (misr & MISR_RX_NOBUF) {
1087 /* According to the documentation, we don't have to do anything,
1088 * but trapping it keeps it out of /var/log/messages.
1090 } /* SISR_RX_NOBUF */
1092 writew(~misr, streamer_mmio + MISR_RUM);
1093 (void)readw(streamer_mmio + MISR_RUM);
1096 else if (sisr & SISR_SRB_REPLY) {
1097 if (streamer_priv->srb_queued == 1) {
1098 wake_up_interruptible(&streamer_priv->srb_wait);
1099 } else if (streamer_priv->srb_queued == 2) {
1100 streamer_srb_bh(dev);
1102 streamer_priv->srb_queued = 0;
1104 writew(~SISR_SRB_REPLY, streamer_mmio + SISR_RUM);
1105 (void)readw(streamer_mmio + SISR_RUM);
1108 else if (sisr & SISR_ADAPTER_CHECK) {
1109 printk(KERN_WARNING "%s: Adapter Check Interrupt Raised, 8 bytes of information follow:\n", dev->name);
1110 writel(readl(streamer_mmio + LAPWWO), streamer_mmio + LAPA);
1111 printk(KERN_WARNING "%s: Words %x:%x:%x:%x:\n",
1112 dev->name, readw(streamer_mmio + LAPDINC),
1113 ntohs(readw(streamer_mmio + LAPDINC)),
1114 ntohs(readw(streamer_mmio + LAPDINC)),
1115 ntohs(readw(streamer_mmio + LAPDINC)));
1116 netif_stop_queue(dev);
1117 netif_carrier_off(dev);
1118 printk(KERN_WARNING "%s: Adapter must be manually reset.\n", dev->name);
1121 /* SISR_ADAPTER_CHECK */
1122 else if (sisr & SISR_ASB_FREE) {
1123 /* Wake up anything that is waiting for the asb response */
1124 if (streamer_priv->asb_queued) {
1125 streamer_asb_bh(dev);
1127 writew(~SISR_ASB_FREE, streamer_mmio + SISR_RUM);
1128 (void)readw(streamer_mmio + SISR_RUM);
1131 else if (sisr & SISR_ARB_CMD) {
1132 streamer_arb_cmd(dev);
1133 writew(~SISR_ARB_CMD, streamer_mmio + SISR_RUM);
1134 (void)readw(streamer_mmio + SISR_RUM);
1137 else if (sisr & SISR_TRB_REPLY) {
1138 /* Wake up anything that is waiting for the trb response */
1139 if (streamer_priv->trb_queued) {
1140 wake_up_interruptible(&streamer_priv->
1143 streamer_priv->trb_queued = 0;
1144 writew(~SISR_TRB_REPLY, streamer_mmio + SISR_RUM);
1145 (void)readw(streamer_mmio + SISR_RUM);
1147 /* SISR_TRB_REPLY */
1149 sisr = readw(streamer_mmio + SISR);
1153 spin_unlock(&streamer_priv->streamer_lock) ;
1157 static int streamer_xmit(struct sk_buff *skb, struct net_device *dev)
1159 struct streamer_private *streamer_priv =
1160 (struct streamer_private *) dev->priv;
1161 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1162 unsigned long flags ;
1164 spin_lock_irqsave(&streamer_priv->streamer_lock, flags);
1166 if (streamer_priv->free_tx_ring_entries) {
1167 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].status = 0;
1168 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].bufcnt_framelen = 0x00020000 | skb->len;
1169 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].buffer =
1170 cpu_to_le32(pci_map_single(streamer_priv->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE));
1171 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].rsvd1 = skb->len;
1172 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].rsvd2 = 0;
1173 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].rsvd3 = 0;
1174 streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].buflen = skb->len;
1176 streamer_priv->tx_ring_skb[streamer_priv->tx_ring_free] = skb;
1177 streamer_priv->free_tx_ring_entries--;
1178 #if STREAMER_DEBUG_PACKETS
1181 printk("streamer_xmit packet print:\n");
1182 for (i = 0; i < skb->len; i++) {
1183 printk("%x:", skb->data[i]);
1184 if (((i + 1) % 16) == 0)
1191 writel(cpu_to_le32(pci_map_single(streamer_priv->pci_dev,
1192 &streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free],
1193 sizeof(struct streamer_tx_desc), PCI_DMA_TODEVICE)),
1194 streamer_mmio + TX2LFDA);
1195 (void)readl(streamer_mmio + TX2LFDA);
1197 streamer_priv->tx_ring_free = (streamer_priv->tx_ring_free + 1) & (STREAMER_TX_RING_SIZE - 1);
1198 spin_unlock_irqrestore(&streamer_priv->streamer_lock,flags);
1201 netif_stop_queue(dev);
1202 spin_unlock_irqrestore(&streamer_priv->streamer_lock,flags);
1208 static int streamer_close(struct net_device *dev)
1210 struct streamer_private *streamer_priv =
1211 (struct streamer_private *) dev->priv;
1212 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1213 unsigned long flags;
1216 netif_stop_queue(dev);
1217 netif_carrier_off(dev);
1218 writew(streamer_priv->srb, streamer_mmio + LAPA);
1219 writew(htons(SRB_CLOSE_ADAPTER << 8),streamer_mmio+LAPDINC);
1220 writew(htons(STREAMER_CLEAR_RET_CODE << 8), streamer_mmio+LAPDINC);
1222 spin_lock_irqsave(&streamer_priv->streamer_lock, flags);
1224 streamer_priv->srb_queued = 1;
1225 writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
1227 spin_unlock_irqrestore(&streamer_priv->streamer_lock, flags);
1229 while (streamer_priv->srb_queued)
1231 interruptible_sleep_on_timeout(&streamer_priv->srb_wait,
1233 if (signal_pending(current))
1235 printk(KERN_WARNING "%s: SRB timed out.\n", dev->name);
1236 printk(KERN_WARNING "SISR=%x MISR=%x LISR=%x\n",
1237 readw(streamer_mmio + SISR),
1238 readw(streamer_mmio + MISR_RUM),
1239 readw(streamer_mmio + LISR));
1240 streamer_priv->srb_queued = 0;
1245 streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1);
1247 for (i = 0; i < STREAMER_RX_RING_SIZE; i++) {
1248 if (streamer_priv->rx_ring_skb[streamer_priv->rx_ring_last_received]) {
1249 dev_kfree_skb(streamer_priv->rx_ring_skb[streamer_priv->rx_ring_last_received]);
1251 streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1);
1254 /* reset tx/rx fifo's and busmaster logic */
1256 /* TBD. Add graceful way to reset the LLC channel without doing a soft reset.
1257 writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
1259 writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL);
1263 writew(streamer_priv->srb, streamer_mmio + LAPA);
1265 for (i = 0; i < 2; i++) {
1266 printk("%x ", ntohs(readw(streamer_mmio + LAPDINC)));
1270 free_irq(dev->irq, dev);
1274 static void streamer_set_rx_mode(struct net_device *dev)
1276 struct streamer_private *streamer_priv =
1277 (struct streamer_private *) dev->priv;
1278 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1280 struct dev_mc_list *dmi;
1281 unsigned char dev_mc_address[5];
1284 writel(streamer_priv->srb, streamer_mmio + LAPA);
1285 options = streamer_priv->streamer_copy_all_options;
1287 if (dev->flags & IFF_PROMISC)
1288 options |= (3 << 5); /* All LLC and MAC frames, all through the main rx channel */
1290 options &= ~(3 << 5);
1292 /* Only issue the srb if there is a change in options */
1294 if ((options ^ streamer_priv->streamer_copy_all_options))
1296 /* Now to issue the srb command to alter the copy.all.options */
1297 writew(htons(SRB_MODIFY_RECEIVE_OPTIONS << 8), streamer_mmio+LAPDINC);
1298 writew(htons(STREAMER_CLEAR_RET_CODE << 8), streamer_mmio+LAPDINC);
1299 writew(htons((streamer_priv->streamer_receive_options << 8) | options),streamer_mmio+LAPDINC);
1300 writew(htons(0x4a41),streamer_mmio+LAPDINC);
1301 writew(htons(0x4d45),streamer_mmio+LAPDINC);
1302 writew(htons(0x5320),streamer_mmio+LAPDINC);
1303 writew(0x2020, streamer_mmio + LAPDINC);
1305 streamer_priv->srb_queued = 2; /* Can't sleep, use srb_bh */
1307 writel(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
1309 streamer_priv->streamer_copy_all_options = options;
1313 /* Set the functional addresses we need for multicast */
1314 writel(streamer_priv->srb,streamer_mmio+LAPA);
1315 dev_mc_address[0] = dev_mc_address[1] = dev_mc_address[2] = dev_mc_address[3] = 0 ;
1317 for (i=0,dmi=dev->mc_list;i < dev->mc_count; i++,dmi = dmi->next)
1319 dev_mc_address[0] |= dmi->dmi_addr[2] ;
1320 dev_mc_address[1] |= dmi->dmi_addr[3] ;
1321 dev_mc_address[2] |= dmi->dmi_addr[4] ;
1322 dev_mc_address[3] |= dmi->dmi_addr[5] ;
1325 writew(htons(SRB_SET_FUNC_ADDRESS << 8),streamer_mmio+LAPDINC);
1326 writew(htons(STREAMER_CLEAR_RET_CODE << 8), streamer_mmio+LAPDINC);
1327 writew(0,streamer_mmio+LAPDINC);
1328 writew(htons( (dev_mc_address[0] << 8) | dev_mc_address[1]),streamer_mmio+LAPDINC);
1329 writew(htons( (dev_mc_address[2] << 8) | dev_mc_address[3]),streamer_mmio+LAPDINC);
1330 streamer_priv->srb_queued = 2 ;
1331 writel(LISR_SRB_CMD,streamer_mmio+LISR_SUM);
1334 static void streamer_srb_bh(struct net_device *dev)
1336 struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
1337 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1340 writew(streamer_priv->srb, streamer_mmio + LAPA);
1341 srb_word=ntohs(readw(streamer_mmio+LAPDINC)) >> 8;
1345 /* SRB_MODIFY_RECEIVE_OPTIONS i.e. set_multicast_list options (promiscuous)
1346 * At some point we should do something if we get an error, such as
1347 * resetting the IFF_PROMISC flag in dev
1350 case SRB_MODIFY_RECEIVE_OPTIONS:
1351 srb_word=ntohs(readw(streamer_mmio+LAPDINC)) >> 8;
1355 printk(KERN_WARNING "%s: Unrecognized srb command\n", dev->name);
1358 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
1361 if (streamer_priv->streamer_message_level)
1362 printk(KERN_WARNING "%s: Receive Options Modified to %x,%x\n",
1364 streamer_priv->streamer_copy_all_options,
1365 streamer_priv->streamer_receive_options);
1367 } /* switch srb[2] */
1371 /* SRB_SET_GROUP_ADDRESS - Multicast group setting
1373 case SRB_SET_GROUP_ADDRESS:
1374 srb_word=ntohs(readw(streamer_mmio+LAPDINC)) >> 8;
1379 printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name);
1382 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
1385 printk(KERN_WARNING "%s: Group/Functional address indicator bits not set correctly\n", dev->name);
1387 case 0x3e: /* If we ever implement individual multicast addresses, will need to deal with this */
1388 printk(KERN_WARNING "%s: Group address registers full\n", dev->name);
1391 printk(KERN_INFO "%s: Group Address already set.\n", dev->name);
1395 } /* switch srb[2] */
1399 /* SRB_RESET_GROUP_ADDRESS - Remove a multicast address from group list
1401 case SRB_RESET_GROUP_ADDRESS:
1402 srb_word=ntohs(readw(streamer_mmio+LAPDINC)) >> 8;
1407 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
1410 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
1412 case 0x39: /* Must deal with this if individual multicast addresses used */
1413 printk(KERN_INFO "%s: Group address not found \n", dev->name);
1417 } /* switch srb[2] */
1421 /* SRB_SET_FUNC_ADDRESS - Called by the set_rx_mode
1424 case SRB_SET_FUNC_ADDRESS:
1425 srb_word=ntohs(readw(streamer_mmio+LAPDINC)) >> 8;
1428 if (streamer_priv->streamer_message_level)
1429 printk(KERN_INFO "%s: Functional Address Mask Set \n", dev->name);
1432 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
1435 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
1439 } /* switch srb[2] */
1442 /* SRB_READ_LOG - Read and reset the adapter error counters
1446 srb_word=ntohs(readw(streamer_mmio+LAPDINC)) >> 8;
1451 if (streamer_priv->streamer_message_level)
1452 printk(KERN_INFO "%s: Read Log command complete\n", dev->name);
1453 printk("Read Log statistics: ");
1454 writew(streamer_priv->srb + 6,
1455 streamer_mmio + LAPA);
1456 for (i = 0; i < 5; i++) {
1457 printk("%x:", ntohs(readw(streamer_mmio + LAPDINC)));
1463 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
1466 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
1469 } /* switch srb[2] */
1472 /* SRB_READ_SR_COUNTERS - Read and reset the source routing bridge related counters */
1474 case SRB_READ_SR_COUNTERS:
1475 srb_word=ntohs(readw(streamer_mmio+LAPDINC)) >> 8;
1478 if (streamer_priv->streamer_message_level)
1479 printk(KERN_INFO "%s: Read Source Routing Counters issued\n", dev->name);
1482 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
1485 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
1489 } /* switch srb[2] */
1493 printk(KERN_WARNING "%s: Unrecognized srb bh return value.\n", dev->name);
1495 } /* switch srb[0] */
1498 static struct net_device_stats *streamer_get_stats(struct net_device *dev)
1500 struct streamer_private *streamer_priv;
1501 streamer_priv = (struct streamer_private *) dev->priv;
1502 return (struct net_device_stats *) &streamer_priv->streamer_stats;
1505 static int streamer_set_mac_address(struct net_device *dev, void *addr)
1507 struct sockaddr *saddr = addr;
1508 struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
1510 if (netif_running(dev))
1512 printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name);
1516 memcpy(streamer_priv->streamer_laa, saddr->sa_data, dev->addr_len);
1518 if (streamer_priv->streamer_message_level) {
1519 printk(KERN_INFO "%s: MAC/LAA Set to = %x.%x.%x.%x.%x.%x\n",
1520 dev->name, streamer_priv->streamer_laa[0],
1521 streamer_priv->streamer_laa[1],
1522 streamer_priv->streamer_laa[2],
1523 streamer_priv->streamer_laa[3],
1524 streamer_priv->streamer_laa[4],
1525 streamer_priv->streamer_laa[5]);
1530 static void streamer_arb_cmd(struct net_device *dev)
1532 struct streamer_private *streamer_priv =
1533 (struct streamer_private *) dev->priv;
1534 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1536 __u16 frame_len, buffer_len;
1537 struct sk_buff *mac_frame;
1538 __u8 frame_data[256];
1540 __u16 lan_status = 0, lan_status_diff; /* Initialize to stop compiler warning */
1541 __u8 fdx_prot_error;
1545 #if STREAMER_NETWORK_MONITOR
1546 struct trh_hdr *mac_hdr;
1549 writew(streamer_priv->arb, streamer_mmio + LAPA);
1550 arb_word=ntohs(readw(streamer_mmio+LAPD)) >> 8;
1552 if (arb_word == ARB_RECEIVE_DATA) { /* Receive.data, MAC frames */
1553 writew(streamer_priv->arb + 6, streamer_mmio + LAPA);
1554 streamer_priv->mac_rx_buffer = buff_off = ntohs(readw(streamer_mmio + LAPDINC));
1555 header_len=ntohs(readw(streamer_mmio+LAPDINC)) >> 8; /* 802.5 Token-Ring Header Length */
1556 frame_len = ntohs(readw(streamer_mmio + LAPDINC));
1565 writew(ntohs(buff_off), streamer_mmio + LAPA); /*setup window to frame data */
1566 next = htons(readw(streamer_mmio + LAPDINC));
1568 ntohs(readw(streamer_mmio + LAPDINC)) & 0xff;
1569 len = ntohs(readw(streamer_mmio + LAPDINC));
1571 /* print out 1st 14 bytes of frame data */
1572 for (i = 0; i < 7; i++) {
1573 printk("Loc %d = %04x\n", i,
1575 (streamer_mmio + LAPDINC)));
1578 printk("next %04x, fs %02x, len %04x \n", next,
1582 if (!(mac_frame = dev_alloc_skb(frame_len))) {
1583 printk(KERN_WARNING "%s: Memory squeeze, dropping frame.\n",
1587 /* Walk the buffer chain, creating the frame */
1593 writew(htons(buff_off), streamer_mmio + LAPA); /* setup window to frame data */
1594 next_ptr = ntohs(readw(streamer_mmio + LAPDINC));
1595 readw(streamer_mmio + LAPDINC); /* read thru status word */
1596 buffer_len = ntohs(readw(streamer_mmio + LAPDINC));
1598 if (buffer_len > 256)
1602 while (i < buffer_len) {
1603 rx_word=ntohs(readw(streamer_mmio+LAPDINC));
1604 frame_data[i]=rx_word >> 8;
1605 frame_data[i+1]=rx_word & 0xff;
1609 memcpy(skb_put(mac_frame, buffer_len),
1610 frame_data, buffer_len);
1611 } while (next_ptr && (buff_off = next_ptr));
1613 #if STREAMER_NETWORK_MONITOR
1614 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",
1616 mac_hdr = (struct trh_hdr *) mac_frame->data;
1618 "%s: MAC Frame Dest. Addr: %02x:%02x:%02x:%02x:%02x:%02x \n",
1619 dev->name, mac_hdr->daddr[0], mac_hdr->daddr[1],
1620 mac_hdr->daddr[2], mac_hdr->daddr[3],
1621 mac_hdr->daddr[4], mac_hdr->daddr[5]);
1623 "%s: MAC Frame Srce. Addr: %02x:%02x:%02x:%02x:%02x:%02x \n",
1624 dev->name, mac_hdr->saddr[0], mac_hdr->saddr[1],
1625 mac_hdr->saddr[2], mac_hdr->saddr[3],
1626 mac_hdr->saddr[4], mac_hdr->saddr[5]);
1628 mac_frame->dev = dev;
1629 mac_frame->protocol = tr_type_trans(mac_frame, dev);
1630 netif_rx(mac_frame);
1632 /* Now tell the card we have dealt with the received frame */
1634 /* Set LISR Bit 1 */
1635 writel(LISR_ARB_FREE, streamer_priv->streamer_mmio + LISR_SUM);
1637 /* Is the ASB free ? */
1639 if (!(readl(streamer_priv->streamer_mmio + SISR) & SISR_ASB_FREE))
1641 streamer_priv->asb_queued = 1;
1642 writel(LISR_ASB_FREE_REQ, streamer_priv->streamer_mmio + LISR_SUM);
1644 /* Drop out and wait for the bottom half to be run */
1648 writew(streamer_priv->asb, streamer_mmio + LAPA);
1649 writew(htons(ASB_RECEIVE_DATA << 8), streamer_mmio+LAPDINC);
1650 writew(htons(STREAMER_CLEAR_RET_CODE << 8), streamer_mmio+LAPDINC);
1651 writew(0, streamer_mmio + LAPDINC);
1652 writew(htons(streamer_priv->mac_rx_buffer), streamer_mmio + LAPD);
1654 writel(LISR_ASB_REPLY | LISR_ASB_FREE_REQ, streamer_priv->streamer_mmio + LISR_SUM);
1656 streamer_priv->asb_queued = 2;
1659 } else if (arb_word == ARB_LAN_CHANGE_STATUS) { /* Lan.change.status */
1660 writew(streamer_priv->arb + 6, streamer_mmio + LAPA);
1661 lan_status = ntohs(readw(streamer_mmio + LAPDINC));
1662 fdx_prot_error = ntohs(readw(streamer_mmio+LAPD)) >> 8;
1664 /* Issue ARB Free */
1665 writew(LISR_ARB_FREE, streamer_priv->streamer_mmio + LISR_SUM);
1667 lan_status_diff = (streamer_priv->streamer_lan_status ^ lan_status) &
1670 if (lan_status_diff & (LSC_LWF | LSC_ARW | LSC_FPE | LSC_RR))
1672 if (lan_status_diff & LSC_LWF)
1673 printk(KERN_WARNING "%s: Short circuit detected on the lobe\n", dev->name);
1674 if (lan_status_diff & LSC_ARW)
1675 printk(KERN_WARNING "%s: Auto removal error\n", dev->name);
1676 if (lan_status_diff & LSC_FPE)
1677 printk(KERN_WARNING "%s: FDX Protocol Error\n", dev->name);
1678 if (lan_status_diff & LSC_RR)
1679 printk(KERN_WARNING "%s: Force remove MAC frame received\n", dev->name);
1681 /* Adapter has been closed by the hardware */
1683 /* reset tx/rx fifo's and busmaster logic */
1685 /* @TBD. no llc reset on autostreamer writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
1687 writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL); */
1689 netif_stop_queue(dev);
1690 netif_carrier_off(dev);
1691 printk(KERN_WARNING "%s: Adapter must be manually reset.\n", dev->name);
1693 /* If serious error */
1694 if (streamer_priv->streamer_message_level) {
1695 if (lan_status_diff & LSC_SIG_LOSS)
1696 printk(KERN_WARNING "%s: No receive signal detected \n", dev->name);
1697 if (lan_status_diff & LSC_HARD_ERR)
1698 printk(KERN_INFO "%s: Beaconing \n", dev->name);
1699 if (lan_status_diff & LSC_SOFT_ERR)
1700 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame \n", dev->name);
1701 if (lan_status_diff & LSC_TRAN_BCN)
1702 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n", dev->name);
1703 if (lan_status_diff & LSC_SS)
1704 printk(KERN_INFO "%s: Single Station on the ring \n", dev->name);
1705 if (lan_status_diff & LSC_RING_REC)
1706 printk(KERN_INFO "%s: Ring recovery ongoing\n", dev->name);
1707 if (lan_status_diff & LSC_FDX_MODE)
1708 printk(KERN_INFO "%s: Operating in FDX mode\n", dev->name);
1711 if (lan_status_diff & LSC_CO) {
1712 if (streamer_priv->streamer_message_level)
1713 printk(KERN_INFO "%s: Counter Overflow \n", dev->name);
1715 /* Issue READ.LOG command */
1717 writew(streamer_priv->srb, streamer_mmio + LAPA);
1718 writew(htons(SRB_READ_LOG << 8),streamer_mmio+LAPDINC);
1719 writew(htons(STREAMER_CLEAR_RET_CODE << 8), streamer_mmio+LAPDINC);
1720 writew(0, streamer_mmio + LAPDINC);
1721 streamer_priv->srb_queued = 2; /* Can't sleep, use srb_bh */
1723 writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
1726 if (lan_status_diff & LSC_SR_CO) {
1727 if (streamer_priv->streamer_message_level)
1728 printk(KERN_INFO "%s: Source routing counters overflow\n", dev->name);
1730 /* Issue a READ.SR.COUNTERS */
1731 writew(streamer_priv->srb, streamer_mmio + LAPA);
1732 writew(htons(SRB_READ_SR_COUNTERS << 8),
1733 streamer_mmio+LAPDINC);
1734 writew(htons(STREAMER_CLEAR_RET_CODE << 8),
1735 streamer_mmio+LAPDINC);
1736 streamer_priv->srb_queued = 2; /* Can't sleep, use srb_bh */
1737 writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
1740 streamer_priv->streamer_lan_status = lan_status;
1741 } /* Lan.change.status */
1743 printk(KERN_WARNING "%s: Unknown arb command \n", dev->name);
1746 static void streamer_asb_bh(struct net_device *dev)
1748 struct streamer_private *streamer_priv =
1749 (struct streamer_private *) dev->priv;
1750 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1752 if (streamer_priv->asb_queued == 1)
1754 /* Dropped through the first time */
1756 writew(streamer_priv->asb, streamer_mmio + LAPA);
1757 writew(htons(ASB_RECEIVE_DATA << 8),streamer_mmio+LAPDINC);
1758 writew(htons(STREAMER_CLEAR_RET_CODE << 8), streamer_mmio+LAPDINC);
1759 writew(0, streamer_mmio + LAPDINC);
1760 writew(htons(streamer_priv->mac_rx_buffer), streamer_mmio + LAPD);
1762 writel(LISR_ASB_REPLY | LISR_ASB_FREE_REQ, streamer_priv->streamer_mmio + LISR_SUM);
1763 streamer_priv->asb_queued = 2;
1768 if (streamer_priv->asb_queued == 2) {
1770 writew(streamer_priv->asb + 2, streamer_mmio + LAPA);
1771 rc=ntohs(readw(streamer_mmio+LAPD)) >> 8;
1774 printk(KERN_WARNING "%s: Unrecognized command code \n", dev->name);
1777 printk(KERN_WARNING "%s: Unrecognized buffer address \n", dev->name);
1780 /* Valid response, everything should be ok again */
1783 printk(KERN_WARNING "%s: Invalid return code in asb\n", dev->name);
1787 streamer_priv->asb_queued = 0;
1790 static int streamer_change_mtu(struct net_device *dev, int mtu)
1792 struct streamer_private *streamer_priv =
1793 (struct streamer_private *) dev->priv;
1796 if (streamer_priv->streamer_ring_speed == 4)
1807 streamer_priv->pkt_buf_sz = mtu + TR_HLEN;
1812 #if STREAMER_NETWORK_MONITOR
1813 #ifdef CONFIG_PROC_FS
1814 static int streamer_proc_info(char *buffer, char **start, off_t offset,
1815 int length, int *eof, void *data)
1817 struct streamer_private *sdev=NULL;
1818 struct pci_dev *pci_device = NULL;
1824 struct net_device *dev;
1826 size = sprintf(buffer, "IBM LanStreamer/MPC Chipset Token Ring Adapters\n");
1831 for(sdev=dev_streamer; sdev; sdev=sdev->next) {
1832 pci_device=sdev->pci_dev;
1833 dev=pci_get_drvdata(pci_device);
1835 size = sprintf_info(buffer + len, dev);
1843 if (pos > offset + length)
1847 *start = buffer + (offset - begin); /* Start of wanted data */
1848 len -= (offset - begin); /* Start slop */
1850 len = length; /* Ending slop */
1854 static int sprintf_info(char *buffer, struct net_device *dev)
1856 struct streamer_private *streamer_priv =
1857 (struct streamer_private *) dev->priv;
1858 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1859 struct streamer_adapter_addr_table sat;
1860 struct streamer_parameters_table spt;
1864 writew(streamer_priv->streamer_addr_table_addr, streamer_mmio + LAPA);
1865 for (i = 0; i < 14; i += 2) {
1867 __u8 *datap = (__u8 *) & sat;
1868 io_word=ntohs(readw(streamer_mmio+LAPDINC));
1869 datap[size]=io_word >> 8;
1870 datap[size+1]=io_word & 0xff;
1872 writew(streamer_priv->streamer_parms_addr, streamer_mmio + LAPA);
1873 for (i = 0; i < 68; i += 2) {
1875 __u8 *datap = (__u8 *) & spt;
1876 io_word=ntohs(readw(streamer_mmio+LAPDINC));
1877 datap[size]=io_word >> 8;
1878 datap[size+1]=io_word & 0xff;
1882 size = sprintf(buffer, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev->name);
1884 size += sprintf(buffer + size,
1885 "%6s: %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x\n",
1886 dev->name, dev->dev_addr[0], dev->dev_addr[1],
1887 dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4],
1888 dev->dev_addr[5], sat.node_addr[0], sat.node_addr[1],
1889 sat.node_addr[2], sat.node_addr[3], sat.node_addr[4],
1890 sat.node_addr[5], sat.func_addr[0], sat.func_addr[1],
1891 sat.func_addr[2], sat.func_addr[3]);
1893 size += sprintf(buffer + size, "\n%6s: Token Ring Parameters Table:\n", dev->name);
1895 size += sprintf(buffer + size, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", dev->name);
1897 size += sprintf(buffer + size,
1898 "%6s: %02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %04x : %04x : %04x :\n",
1899 dev->name, spt.phys_addr[0], spt.phys_addr[1],
1900 spt.phys_addr[2], spt.phys_addr[3],
1901 spt.up_node_addr[0], spt.up_node_addr[1],
1902 spt.up_node_addr[2], spt.up_node_addr[3],
1903 spt.up_node_addr[4], spt.up_node_addr[4],
1904 spt.poll_addr[0], spt.poll_addr[1], spt.poll_addr[2],
1905 spt.poll_addr[3], spt.poll_addr[4], spt.poll_addr[5],
1906 ntohs(spt.acc_priority), ntohs(spt.auth_source_class),
1907 ntohs(spt.att_code));
1909 size += sprintf(buffer + size, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", dev->name);
1911 size += sprintf(buffer + size,
1912 "%6s: %02x:%02x:%02x:%02x:%02x:%02x : %04x : %04x : %04x : %04x : %04x : %04x : \n",
1913 dev->name, spt.source_addr[0], spt.source_addr[1],
1914 spt.source_addr[2], spt.source_addr[3],
1915 spt.source_addr[4], spt.source_addr[5],
1916 ntohs(spt.beacon_type), ntohs(spt.major_vector),
1917 ntohs(spt.lan_status), ntohs(spt.local_ring),
1918 ntohs(spt.mon_error), ntohs(spt.frame_correl));
1920 size += sprintf(buffer + size, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n",
1923 size += sprintf(buffer + size,
1924 "%6s: : %02x : %02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x : \n",
1925 dev->name, ntohs(spt.beacon_transmit),
1926 ntohs(spt.beacon_receive), spt.beacon_naun[0],
1927 spt.beacon_naun[1], spt.beacon_naun[2],
1928 spt.beacon_naun[3], spt.beacon_naun[4],
1929 spt.beacon_naun[5], spt.beacon_phys[0],
1930 spt.beacon_phys[1], spt.beacon_phys[2],
1931 spt.beacon_phys[3]);
1937 #if STREAMER_IOCTL && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1938 static int streamer_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1941 struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
1942 u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1945 case IOCTL_SISR_MASK:
1946 writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
1948 case IOCTL_SPIN_LOCK_TEST:
1949 printk(KERN_INFO "spin_lock() called.\n");
1950 spin_lock(&streamer_priv->streamer_lock);
1951 spin_unlock(&streamer_priv->streamer_lock);
1952 printk(KERN_INFO "spin_unlock() finished.\n");
1954 case IOCTL_PRINT_BDAS:
1955 printk(KERN_INFO "bdas: RXBDA: %x RXLBDA: %x TX2FDA: %x TX2LFDA: %x\n",
1956 readw(streamer_mmio + RXBDA),
1957 readw(streamer_mmio + RXLBDA),
1958 readw(streamer_mmio + TX2FDA),
1959 readw(streamer_mmio + TX2LFDA));
1961 case IOCTL_PRINT_REGISTERS:
1962 printk(KERN_INFO "registers:\n");
1963 printk(KERN_INFO "SISR: %04x MISR: %04x LISR: %04x BCTL: %04x BMCTL: %04x\nmask %04x mask %04x\n",
1964 readw(streamer_mmio + SISR),
1965 readw(streamer_mmio + MISR_RUM),
1966 readw(streamer_mmio + LISR),
1967 readw(streamer_mmio + BCTL),
1968 readw(streamer_mmio + BMCTL_SUM),
1969 readw(streamer_mmio + SISR_MASK),
1970 readw(streamer_mmio + MISR_MASK));
1972 case IOCTL_PRINT_RX_BUFS:
1973 printk(KERN_INFO "Print rx bufs:\n");
1974 for(i=0; i<STREAMER_RX_RING_SIZE; i++)
1975 printk(KERN_INFO "rx_ring %d status: 0x%x\n", i,
1976 streamer_priv->streamer_rx_ring[i].status);
1978 case IOCTL_PRINT_TX_BUFS:
1979 printk(KERN_INFO "Print tx bufs:\n");
1980 for(i=0; i<STREAMER_TX_RING_SIZE; i++)
1981 printk(KERN_INFO "tx_ring %d status: 0x%x\n", i,
1982 streamer_priv->streamer_tx_ring[i].status);
1986 printk(KERN_INFO "Sent rx command.\n");
1989 printk(KERN_INFO "Bad ioctl!\n");
1995 static struct pci_driver streamer_pci_driver = {
1996 .name = "lanstreamer",
1997 .id_table = streamer_pci_tbl,
1998 .probe = streamer_init_one,
1999 .remove = __devexit_p(streamer_remove_one),
2002 static int __init streamer_init_module(void) {
2003 return pci_module_init(&streamer_pci_driver);
2006 static void __exit streamer_cleanup_module(void) {
2007 pci_unregister_driver(&streamer_pci_driver);
2010 module_init(streamer_init_module);
2011 module_exit(streamer_cleanup_module);
2012 MODULE_LICENSE("GPL");