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/module.h>
104 #include <linux/kernel.h>
105 #include <linux/errno.h>
106 #include <linux/timer.h>
107 #include <linux/in.h>
108 #include <linux/ioport.h>
109 #include <linux/string.h>
110 #include <linux/proc_fs.h>
111 #include <linux/ptrace.h>
112 #include <linux/skbuff.h>
113 #include <linux/interrupt.h>
114 #include <linux/delay.h>
115 #include <linux/netdevice.h>
116 #include <linux/trdevice.h>
117 #include <linux/stddef.h>
118 #include <linux/init.h>
119 #include <linux/pci.h>
120 #include <linux/dma-mapping.h>
121 #include <linux/spinlock.h>
122 #include <linux/bitops.h>
123 #include <linux/jiffies.h>
125 #include <net/net_namespace.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 static int streamer_set_mac_address(struct net_device
*dev
, void *addr
);
211 static void streamer_arb_cmd(struct net_device
*dev
);
212 static int streamer_change_mtu(struct net_device
*dev
, int mtu
);
213 static void streamer_srb_bh(struct net_device
*dev
);
214 static void streamer_asb_bh(struct net_device
*dev
);
215 #if STREAMER_NETWORK_MONITOR
216 #ifdef CONFIG_PROC_FS
217 static int streamer_proc_info(char *buffer
, char **start
, off_t offset
,
218 int length
, int *eof
, void *data
);
219 static int sprintf_info(char *buffer
, struct net_device
*dev
);
220 struct streamer_private
*dev_streamer
=NULL
;
224 static const struct net_device_ops streamer_netdev_ops
= {
225 .ndo_open
= streamer_open
,
226 .ndo_stop
= streamer_close
,
227 .ndo_start_xmit
= streamer_xmit
,
228 .ndo_change_mtu
= streamer_change_mtu
,
230 .ndo_do_ioctl
= streamer_ioctl
,
232 .ndo_set_multicast_list
= streamer_set_rx_mode
,
233 .ndo_set_mac_address
= streamer_set_mac_address
,
236 static int __devinit
streamer_init_one(struct pci_dev
*pdev
,
237 const struct pci_device_id
*ent
)
239 struct net_device
*dev
;
240 struct streamer_private
*streamer_priv
;
241 unsigned long pio_start
, pio_end
, pio_flags
, pio_len
;
242 unsigned long mmio_start
, mmio_end
, mmio_flags
, mmio_len
;
244 static int card_no
=-1;
248 printk("lanstreamer::streamer_init_one, entry pdev %p\n",pdev
);
252 dev
= alloc_trdev(sizeof(*streamer_priv
));
254 printk(KERN_ERR
"lanstreamer: out of memory.\n");
258 streamer_priv
= netdev_priv(dev
);
260 #if STREAMER_NETWORK_MONITOR
261 #ifdef CONFIG_PROC_FS
263 create_proc_read_entry("streamer_tr", 0, init_net
.proc_net
,
264 streamer_proc_info
, NULL
);
265 streamer_priv
->next
= dev_streamer
;
266 dev_streamer
= streamer_priv
;
270 rc
= pci_set_dma_mask(pdev
, DMA_32BIT_MASK
);
272 printk(KERN_ERR
"%s: No suitable PCI mapping available.\n",
278 rc
= pci_enable_device(pdev
);
280 printk(KERN_ERR
"lanstreamer: unable to enable pci device\n");
285 pci_set_master(pdev
);
287 rc
= pci_set_mwi(pdev
);
289 printk(KERN_ERR
"lanstreamer: unable to enable MWI on pci device\n");
290 goto err_out_disable
;
293 pio_start
= pci_resource_start(pdev
, 0);
294 pio_end
= pci_resource_end(pdev
, 0);
295 pio_flags
= pci_resource_flags(pdev
, 0);
296 pio_len
= pci_resource_len(pdev
, 0);
298 mmio_start
= pci_resource_start(pdev
, 1);
299 mmio_end
= pci_resource_end(pdev
, 1);
300 mmio_flags
= pci_resource_flags(pdev
, 1);
301 mmio_len
= pci_resource_len(pdev
, 1);
304 printk("lanstreamer: pio_start %x pio_end %x pio_len %x pio_flags %x\n",
305 pio_start
, pio_end
, pio_len
, pio_flags
);
306 printk("lanstreamer: mmio_start %x mmio_end %x mmio_len %x mmio_flags %x\n",
307 mmio_start
, mmio_end
, mmio_flags
, mmio_len
);
310 if (!request_region(pio_start
, pio_len
, "lanstreamer")) {
311 printk(KERN_ERR
"lanstreamer: unable to get pci io addr %lx\n",
317 if (!request_mem_region(mmio_start
, mmio_len
, "lanstreamer")) {
318 printk(KERN_ERR
"lanstreamer: unable to get pci mmio addr %lx\n",
321 goto err_out_free_pio
;
324 streamer_priv
->streamer_mmio
=ioremap(mmio_start
, mmio_len
);
325 if (streamer_priv
->streamer_mmio
== NULL
) {
326 printk(KERN_ERR
"lanstreamer: unable to remap MMIO %lx\n",
329 goto err_out_free_mmio
;
332 init_waitqueue_head(&streamer_priv
->srb_wait
);
333 init_waitqueue_head(&streamer_priv
->trb_wait
);
335 dev
->netdev_ops
= &streamer_netdev_ops
;
336 dev
->irq
= pdev
->irq
;
337 dev
->base_addr
=pio_start
;
338 SET_NETDEV_DEV(dev
, &pdev
->dev
);
340 streamer_priv
->streamer_card_name
= (char *)pdev
->resource
[0].name
;
341 streamer_priv
->pci_dev
= pdev
;
343 if ((pkt_buf_sz
[card_no
] < 100) || (pkt_buf_sz
[card_no
] > 18000))
344 streamer_priv
->pkt_buf_sz
= PKT_BUF_SZ
;
346 streamer_priv
->pkt_buf_sz
= pkt_buf_sz
[card_no
];
348 streamer_priv
->streamer_ring_speed
= ringspeed
[card_no
];
349 streamer_priv
->streamer_message_level
= message_level
[card_no
];
351 pci_set_drvdata(pdev
, dev
);
353 spin_lock_init(&streamer_priv
->streamer_lock
);
355 pci_read_config_word (pdev
, PCI_COMMAND
, &pcr
);
356 pcr
|= PCI_COMMAND_SERR
;
357 pci_write_config_word (pdev
, PCI_COMMAND
, pcr
);
359 printk("%s \n", version
);
360 printk("%s: %s. I/O at %hx, MMIO at %p, using irq %d\n",dev
->name
,
361 streamer_priv
->streamer_card_name
,
362 (unsigned int) dev
->base_addr
,
363 streamer_priv
->streamer_mmio
,
366 if (streamer_reset(dev
))
369 rc
= register_netdev(dev
);
375 iounmap(streamer_priv
->streamer_mmio
);
377 release_mem_region(mmio_start
, mmio_len
);
379 release_region(pio_start
, pio_len
);
383 pci_disable_device(pdev
);
387 printk("lanstreamer: Exit error %x\n",rc
);
392 static void __devexit
streamer_remove_one(struct pci_dev
*pdev
)
394 struct net_device
*dev
=pci_get_drvdata(pdev
);
395 struct streamer_private
*streamer_priv
;
398 printk("lanstreamer::streamer_remove_one entry pdev %p\n",pdev
);
402 printk(KERN_ERR
"lanstreamer::streamer_remove_one, ERROR dev is NULL\n");
406 streamer_priv
=netdev_priv(dev
);
407 if (streamer_priv
== NULL
) {
408 printk(KERN_ERR
"lanstreamer::streamer_remove_one, ERROR dev->priv is NULL\n");
412 #if STREAMER_NETWORK_MONITOR
413 #ifdef CONFIG_PROC_FS
415 struct streamer_private
**p
, **next
;
417 for (p
= &dev_streamer
; *p
; p
= next
) {
419 if (*p
== streamer_priv
) {
425 remove_proc_entry("streamer_tr", init_net
.proc_net
);
430 unregister_netdev(dev
);
431 iounmap(streamer_priv
->streamer_mmio
);
432 release_mem_region(pci_resource_start(pdev
, 1), pci_resource_len(pdev
,1));
433 release_region(pci_resource_start(pdev
, 0), pci_resource_len(pdev
,0));
435 pci_disable_device(pdev
);
437 pci_set_drvdata(pdev
, NULL
);
441 static int streamer_reset(struct net_device
*dev
)
443 struct streamer_private
*streamer_priv
;
444 __u8 __iomem
*streamer_mmio
;
446 unsigned int uaa_addr
;
447 struct sk_buff
*skb
= NULL
;
450 streamer_priv
= netdev_priv(dev
);
451 streamer_mmio
= streamer_priv
->streamer_mmio
;
453 writew(readw(streamer_mmio
+ BCTL
) | BCTL_SOFTRESET
, streamer_mmio
+ BCTL
);
455 /* Hold soft reset bit for a while */
458 writew(readw(streamer_mmio
+ BCTL
) & ~BCTL_SOFTRESET
,
459 streamer_mmio
+ BCTL
);
462 printk("BCTL: %x\n", readw(streamer_mmio
+ BCTL
));
463 printk("GPR: %x\n", readw(streamer_mmio
+ GPR
));
464 printk("SISRMASK: %x\n", readw(streamer_mmio
+ SISR_MASK
));
466 writew(readw(streamer_mmio
+ BCTL
) | (BCTL_RX_FIFO_8
| BCTL_TX_FIFO_8
), streamer_mmio
+ BCTL
);
468 if (streamer_priv
->streamer_ring_speed
== 0) { /* Autosense */
469 writew(readw(streamer_mmio
+ GPR
) | GPR_AUTOSENSE
,
470 streamer_mmio
+ GPR
);
471 if (streamer_priv
->streamer_message_level
)
472 printk(KERN_INFO
"%s: Ringspeed autosense mode on\n",
474 } else if (streamer_priv
->streamer_ring_speed
== 16) {
475 if (streamer_priv
->streamer_message_level
)
476 printk(KERN_INFO
"%s: Trying to open at 16 Mbps as requested\n",
478 writew(GPR_16MBPS
, streamer_mmio
+ GPR
);
479 } else if (streamer_priv
->streamer_ring_speed
== 4) {
480 if (streamer_priv
->streamer_message_level
)
481 printk(KERN_INFO
"%s: Trying to open at 4 Mbps as requested\n",
483 writew(0, streamer_mmio
+ GPR
);
486 skb
= dev_alloc_skb(streamer_priv
->pkt_buf_sz
);
488 printk(KERN_INFO
"%s: skb allocation for diagnostics failed...proceeding\n",
491 struct streamer_rx_desc
*rx_ring
;
494 rx_ring
=(struct streamer_rx_desc
*)skb
->data
;
495 data
=((u8
*)skb
->data
)+sizeof(struct streamer_rx_desc
);
498 rx_ring
->buffer
=cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, data
,
499 512, PCI_DMA_FROMDEVICE
));
500 rx_ring
->framelen_buflen
=512;
501 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, rx_ring
, 512, PCI_DMA_FROMDEVICE
)),
502 streamer_mmio
+RXBDA
);
506 printk("GPR = %x\n", readw(streamer_mmio
+ GPR
));
508 /* start solo init */
509 writew(SISR_MI
, streamer_mmio
+ SISR_MASK_SUM
);
511 while (!((readw(streamer_mmio
+ SISR
)) & SISR_SRB_REPLY
)) {
512 msleep_interruptible(100);
513 if (time_after(jiffies
, t
+ 40 * HZ
)) {
515 "IBM PCI tokenring card not responding\n");
516 release_region(dev
->base_addr
, STREAMER_IO_SPACE
);
522 writew(~SISR_SRB_REPLY
, streamer_mmio
+ SISR_RUM
);
523 misr
= readw(streamer_mmio
+ MISR_RUM
);
524 writew(~misr
, streamer_mmio
+ MISR_RUM
);
527 dev_kfree_skb(skb
); /* release skb used for diagnostics */
530 printk("LAPWWO: %x, LAPA: %x LAPE: %x\n",
531 readw(streamer_mmio
+ LAPWWO
), readw(streamer_mmio
+ LAPA
),
532 readw(streamer_mmio
+ LAPE
));
538 writew(readw(streamer_mmio
+ LAPWWO
),
539 streamer_mmio
+ LAPA
);
540 printk("initialization response srb dump: ");
541 for (i
= 0; i
< 10; i
++)
543 ntohs(readw(streamer_mmio
+ LAPDINC
)));
548 writew(readw(streamer_mmio
+ LAPWWO
) + 6, streamer_mmio
+ LAPA
);
549 if (readw(streamer_mmio
+ LAPD
)) {
550 printk(KERN_INFO
"tokenring card initialization failed. errorcode : %x\n",
551 ntohs(readw(streamer_mmio
+ LAPD
)));
552 release_region(dev
->base_addr
, STREAMER_IO_SPACE
);
556 writew(readw(streamer_mmio
+ LAPWWO
) + 8, streamer_mmio
+ LAPA
);
557 uaa_addr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
558 readw(streamer_mmio
+ LAPDINC
); /* skip over Level.Addr field */
559 streamer_priv
->streamer_addr_table_addr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
560 streamer_priv
->streamer_parms_addr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
563 printk("UAA resides at %x\n", uaa_addr
);
566 /* setup uaa area for access with LAPD */
570 writew(uaa_addr
, streamer_mmio
+ LAPA
);
571 for (i
= 0; i
< 6; i
+= 2) {
572 addr
=ntohs(readw(streamer_mmio
+LAPDINC
));
573 dev
->dev_addr
[i
]= (addr
>> 8) & 0xff;
574 dev
->dev_addr
[i
+1]= addr
& 0xff;
577 printk("Adapter address: %pM\n", dev
->dev_addr
);
583 static int streamer_open(struct net_device
*dev
)
585 struct streamer_private
*streamer_priv
= netdev_priv(dev
);
586 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
588 char open_error
[255];
589 int i
, open_finished
= 1;
594 if (readw(streamer_mmio
+BMCTL_SUM
) & BMCTL_RX_ENABLED
) {
595 rc
=streamer_reset(dev
);
598 if (request_irq(dev
->irq
, &streamer_interrupt
, IRQF_SHARED
, "lanstreamer", dev
)) {
602 printk("BMCTL: %x\n", readw(streamer_mmio
+ BMCTL_SUM
));
603 printk("pending ints: %x\n", readw(streamer_mmio
+ SISR
));
606 writew(SISR_MI
| SISR_SRB_REPLY
, streamer_mmio
+ SISR_MASK
); /* more ints later, doesn't stop arb cmd interrupt */
607 writew(LISR_LIE
, streamer_mmio
+ LISR
); /* more ints later */
609 /* adapter is closed, so SRB is pointed to by LAPWWO */
610 writew(readw(streamer_mmio
+ LAPWWO
), streamer_mmio
+ LAPA
);
613 printk("LAPWWO: %x, LAPA: %x\n", readw(streamer_mmio
+ LAPWWO
),
614 readw(streamer_mmio
+ LAPA
));
615 printk("LAPE: %x\n", readw(streamer_mmio
+ LAPE
));
616 printk("SISR Mask = %04x\n", readw(streamer_mmio
+ SISR_MASK
));
619 for (i
= 0; i
< SRB_COMMAND_SIZE
; i
+= 2) {
620 writew(0, streamer_mmio
+ LAPDINC
);
623 writew(readw(streamer_mmio
+LAPWWO
),streamer_mmio
+LAPA
);
624 writew(htons(SRB_OPEN_ADAPTER
<<8),streamer_mmio
+LAPDINC
) ; /* open */
625 writew(htons(STREAMER_CLEAR_RET_CODE
<<8),streamer_mmio
+LAPDINC
);
626 writew(STREAMER_CLEAR_RET_CODE
, streamer_mmio
+ LAPDINC
);
628 writew(readw(streamer_mmio
+ LAPWWO
) + 8, streamer_mmio
+ LAPA
);
629 #if STREAMER_NETWORK_MONITOR
630 /* If Network Monitor, instruct card to copy MAC frames through the ARB */
631 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 */
633 writew(htons(OPEN_ADAPTER_ENABLE_FDX
), streamer_mmio
+ LAPDINC
); /* Offset 8 word contains Open.Options */
636 if (streamer_priv
->streamer_laa
[0]) {
637 writew(readw(streamer_mmio
+ LAPWWO
) + 12, streamer_mmio
+ LAPA
);
638 writew(htons((streamer_priv
->streamer_laa
[0] << 8) |
639 streamer_priv
->streamer_laa
[1]),streamer_mmio
+LAPDINC
);
640 writew(htons((streamer_priv
->streamer_laa
[2] << 8) |
641 streamer_priv
->streamer_laa
[3]),streamer_mmio
+LAPDINC
);
642 writew(htons((streamer_priv
->streamer_laa
[4] << 8) |
643 streamer_priv
->streamer_laa
[5]),streamer_mmio
+LAPDINC
);
644 memcpy(dev
->dev_addr
, streamer_priv
->streamer_laa
, dev
->addr_len
);
647 /* save off srb open offset */
648 srb_open
= readw(streamer_mmio
+ LAPWWO
);
650 writew(readw(streamer_mmio
+ LAPWWO
),
651 streamer_mmio
+ LAPA
);
652 printk("srb open request: \n");
653 for (i
= 0; i
< 16; i
++) {
654 printk("%x:", ntohs(readw(streamer_mmio
+ LAPDINC
)));
658 spin_lock_irqsave(&streamer_priv
->streamer_lock
, flags
);
659 streamer_priv
->srb_queued
= 1;
661 /* signal solo that SRB command has been issued */
662 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
663 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
, flags
);
665 while (streamer_priv
->srb_queued
) {
666 interruptible_sleep_on_timeout(&streamer_priv
->srb_wait
, 5 * HZ
);
667 if (signal_pending(current
)) {
668 printk(KERN_WARNING
"%s: SRB timed out.\n", dev
->name
);
669 printk(KERN_WARNING
"SISR=%x MISR=%x, LISR=%x\n",
670 readw(streamer_mmio
+ SISR
),
671 readw(streamer_mmio
+ MISR_RUM
),
672 readw(streamer_mmio
+ LISR
));
673 streamer_priv
->srb_queued
= 0;
679 printk("SISR_MASK: %x\n", readw(streamer_mmio
+ SISR_MASK
));
680 printk("srb open response:\n");
681 writew(srb_open
, streamer_mmio
+ LAPA
);
682 for (i
= 0; i
< 10; i
++) {
684 ntohs(readw(streamer_mmio
+ LAPDINC
)));
688 /* If we get the same return response as we set, the interrupt wasn't raised and the open
691 writew(srb_open
+ 2, streamer_mmio
+ LAPA
);
692 srb_word
= ntohs(readw(streamer_mmio
+ LAPD
)) >> 8;
693 if (srb_word
== STREAMER_CLEAR_RET_CODE
) {
694 printk(KERN_WARNING
"%s: Adapter Open time out or error.\n",
700 if (srb_word
== 0x07) {
701 if (!streamer_priv
->streamer_ring_speed
&& open_finished
) { /* Autosense , first time around */
702 printk(KERN_WARNING
"%s: Retrying at different ring speed \n",
708 writew(srb_open
+ 6, streamer_mmio
+ LAPA
);
709 error_code
= ntohs(readw(streamer_mmio
+ LAPD
));
710 strcpy(open_error
, open_maj_error
[(error_code
& 0xf0) >> 4]);
711 strcat(open_error
, " - ");
712 strcat(open_error
, open_min_error
[(error_code
& 0x0f)]);
714 if (!streamer_priv
->streamer_ring_speed
715 && ((error_code
& 0x0f) == 0x0d))
717 printk(KERN_WARNING
"%s: Tried to autosense ring speed with no monitors present\n", dev
->name
);
718 printk(KERN_WARNING
"%s: Please try again with a specified ring speed \n", dev
->name
);
719 free_irq(dev
->irq
, dev
);
723 printk(KERN_WARNING
"%s: %s\n",
724 dev
->name
, open_error
);
725 free_irq(dev
->irq
, dev
);
728 } /* if autosense && open_finished */
730 printk(KERN_WARNING
"%s: Bad OPEN response: %x\n",
731 dev
->name
, srb_word
);
732 free_irq(dev
->irq
, dev
);
737 } while (!(open_finished
)); /* Will only loop if ring speed mismatch re-open attempted && autosense is on */
739 writew(srb_open
+ 18, streamer_mmio
+ LAPA
);
740 srb_word
=ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
741 if (srb_word
& (1 << 3))
742 if (streamer_priv
->streamer_message_level
)
743 printk(KERN_INFO
"%s: Opened in FDX Mode\n", dev
->name
);
746 streamer_priv
->streamer_ring_speed
= 16;
748 streamer_priv
->streamer_ring_speed
= 4;
750 if (streamer_priv
->streamer_message_level
)
751 printk(KERN_INFO
"%s: Opened in %d Mbps mode\n",
753 streamer_priv
->streamer_ring_speed
);
755 writew(srb_open
+ 8, streamer_mmio
+ LAPA
);
756 streamer_priv
->asb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
757 streamer_priv
->srb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
758 streamer_priv
->arb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
759 readw(streamer_mmio
+ LAPDINC
); /* offset 14 word is rsvd */
760 streamer_priv
->trb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
762 streamer_priv
->streamer_receive_options
= 0x00;
763 streamer_priv
->streamer_copy_all_options
= 0;
766 /* enable rx channel */
767 writew(~BMCTL_RX_DIS
, streamer_mmio
+ BMCTL_RUM
);
769 /* setup rx descriptors */
770 streamer_priv
->streamer_rx_ring
=
771 kmalloc( sizeof(struct streamer_rx_desc
)*
772 STREAMER_RX_RING_SIZE
,GFP_KERNEL
);
773 if (!streamer_priv
->streamer_rx_ring
) {
774 printk(KERN_WARNING
"%s ALLOC of streamer rx ring FAILED!!\n",dev
->name
);
778 for (i
= 0; i
< STREAMER_RX_RING_SIZE
; i
++) {
781 skb
= dev_alloc_skb(streamer_priv
->pkt_buf_sz
);
787 streamer_priv
->streamer_rx_ring
[i
].forward
=
788 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[i
+ 1],
789 sizeof(struct streamer_rx_desc
), PCI_DMA_FROMDEVICE
));
790 streamer_priv
->streamer_rx_ring
[i
].status
= 0;
791 streamer_priv
->streamer_rx_ring
[i
].buffer
=
792 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, skb
->data
,
793 streamer_priv
->pkt_buf_sz
, PCI_DMA_FROMDEVICE
));
794 streamer_priv
->streamer_rx_ring
[i
].framelen_buflen
= streamer_priv
->pkt_buf_sz
;
795 streamer_priv
->rx_ring_skb
[i
] = skb
;
797 streamer_priv
->streamer_rx_ring
[STREAMER_RX_RING_SIZE
- 1].forward
=
798 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[0],
799 sizeof(struct streamer_rx_desc
), PCI_DMA_FROMDEVICE
));
802 printk(KERN_WARNING
"%s: Not enough memory to allocate rx buffers. Adapter disabled\n", dev
->name
);
803 free_irq(dev
->irq
, dev
);
807 streamer_priv
->rx_ring_last_received
= STREAMER_RX_RING_SIZE
- 1; /* last processed rx status */
809 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[0],
810 sizeof(struct streamer_rx_desc
), PCI_DMA_TODEVICE
)),
811 streamer_mmio
+ RXBDA
);
812 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[STREAMER_RX_RING_SIZE
- 1],
813 sizeof(struct streamer_rx_desc
), PCI_DMA_TODEVICE
)),
814 streamer_mmio
+ RXLBDA
);
816 /* set bus master interrupt event mask */
817 writew(MISR_RX_NOBUF
| MISR_RX_EOF
, streamer_mmio
+ MISR_MASK
);
821 streamer_priv
->streamer_tx_ring
=kmalloc(sizeof(struct streamer_tx_desc
)*
822 STREAMER_TX_RING_SIZE
,GFP_KERNEL
);
823 if (!streamer_priv
->streamer_tx_ring
) {
824 printk(KERN_WARNING
"%s ALLOC of streamer_tx_ring FAILED\n",dev
->name
);
828 writew(~BMCTL_TX2_DIS
, streamer_mmio
+ BMCTL_RUM
); /* Enables TX channel 2 */
829 for (i
= 0; i
< STREAMER_TX_RING_SIZE
; i
++) {
830 streamer_priv
->streamer_tx_ring
[i
].forward
= cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
831 &streamer_priv
->streamer_tx_ring
[i
+ 1],
832 sizeof(struct streamer_tx_desc
),
834 streamer_priv
->streamer_tx_ring
[i
].status
= 0;
835 streamer_priv
->streamer_tx_ring
[i
].bufcnt_framelen
= 0;
836 streamer_priv
->streamer_tx_ring
[i
].buffer
= 0;
837 streamer_priv
->streamer_tx_ring
[i
].buflen
= 0;
838 streamer_priv
->streamer_tx_ring
[i
].rsvd1
= 0;
839 streamer_priv
->streamer_tx_ring
[i
].rsvd2
= 0;
840 streamer_priv
->streamer_tx_ring
[i
].rsvd3
= 0;
842 streamer_priv
->streamer_tx_ring
[STREAMER_TX_RING_SIZE
- 1].forward
=
843 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_tx_ring
[0],
844 sizeof(struct streamer_tx_desc
), PCI_DMA_TODEVICE
));
846 streamer_priv
->free_tx_ring_entries
= STREAMER_TX_RING_SIZE
;
847 streamer_priv
->tx_ring_free
= 0; /* next entry in tx ring to use */
848 streamer_priv
->tx_ring_last_status
= STREAMER_TX_RING_SIZE
- 1;
850 /* set Busmaster interrupt event mask (handle receives on interrupt only */
851 writew(MISR_TX2_EOF
| MISR_RX_NOBUF
| MISR_RX_EOF
, streamer_mmio
+ MISR_MASK
);
852 /* set system event interrupt mask */
853 writew(SISR_ADAPTER_CHECK
| SISR_ARB_CMD
| SISR_TRB_REPLY
| SISR_ASB_FREE
, streamer_mmio
+ SISR_MASK_SUM
);
856 printk("BMCTL: %x\n", readw(streamer_mmio
+ BMCTL_SUM
));
857 printk("SISR MASK: %x\n", readw(streamer_mmio
+ SISR_MASK
));
860 #if STREAMER_NETWORK_MONITOR
862 writew(streamer_priv
->streamer_addr_table_addr
, streamer_mmio
+ LAPA
);
863 printk("%s: Node Address: %04x:%04x:%04x\n", dev
->name
,
864 ntohs(readw(streamer_mmio
+ LAPDINC
)),
865 ntohs(readw(streamer_mmio
+ LAPDINC
)),
866 ntohs(readw(streamer_mmio
+ LAPDINC
)));
867 readw(streamer_mmio
+ LAPDINC
);
868 readw(streamer_mmio
+ LAPDINC
);
869 printk("%s: Functional Address: %04x:%04x\n", dev
->name
,
870 ntohs(readw(streamer_mmio
+ LAPDINC
)),
871 ntohs(readw(streamer_mmio
+ LAPDINC
)));
873 writew(streamer_priv
->streamer_parms_addr
+ 4,
874 streamer_mmio
+ LAPA
);
875 printk("%s: NAUN Address: %04x:%04x:%04x\n", dev
->name
,
876 ntohs(readw(streamer_mmio
+ LAPDINC
)),
877 ntohs(readw(streamer_mmio
+ LAPDINC
)),
878 ntohs(readw(streamer_mmio
+ LAPDINC
)));
881 netif_start_queue(dev
);
882 netif_carrier_on(dev
);
887 * When we enter the rx routine we do not know how many frames have been
888 * queued on the rx channel. Therefore we start at the next rx status
889 * position and travel around the receive ring until we have completed
892 * This means that we may process the frame before we receive the end
893 * of frame interrupt. This is why we always test the status instead
894 * of blindly processing the next frame.
897 static void streamer_rx(struct net_device
*dev
)
899 struct streamer_private
*streamer_priv
=
901 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
902 struct streamer_rx_desc
*rx_desc
;
903 int rx_ring_last_received
, length
, frame_length
, buffer_cnt
= 0;
904 struct sk_buff
*skb
, *skb2
;
906 /* setup the next rx descriptor to be received */
907 rx_desc
= &streamer_priv
->streamer_rx_ring
[(streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1)];
908 rx_ring_last_received
= streamer_priv
->rx_ring_last_received
;
910 while (rx_desc
->status
& 0x01000000) { /* While processed descriptors are available */
911 if (rx_ring_last_received
!= streamer_priv
->rx_ring_last_received
)
913 printk(KERN_WARNING
"RX Error 1 rx_ring_last_received not the same %x %x\n",
914 rx_ring_last_received
, streamer_priv
->rx_ring_last_received
);
916 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1);
917 rx_ring_last_received
= streamer_priv
->rx_ring_last_received
;
919 length
= rx_desc
->framelen_buflen
& 0xffff; /* buffer length */
920 frame_length
= (rx_desc
->framelen_buflen
>> 16) & 0xffff;
922 if (rx_desc
->status
& 0x7E830000) { /* errors */
923 if (streamer_priv
->streamer_message_level
) {
924 printk(KERN_WARNING
"%s: Rx Error %x \n",
925 dev
->name
, rx_desc
->status
);
927 } else { /* received without errors */
928 if (rx_desc
->status
& 0x80000000) { /* frame complete */
930 skb
= dev_alloc_skb(streamer_priv
->pkt_buf_sz
);
932 skb
= dev_alloc_skb(frame_length
);
937 printk(KERN_WARNING
"%s: Not enough memory to copy packet to upper layers. \n", dev
->name
);
938 dev
->stats
.rx_dropped
++;
939 } else { /* we allocated an skb OK */
940 if (buffer_cnt
== 1) {
941 /* release the DMA mapping */
942 pci_unmap_single(streamer_priv
->pci_dev
,
943 le32_to_cpu(streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].buffer
),
944 streamer_priv
->pkt_buf_sz
,
946 skb2
= streamer_priv
->rx_ring_skb
[rx_ring_last_received
];
947 #if STREAMER_DEBUG_PACKETS
950 printk("streamer_rx packet print: skb->data2 %p skb->head %p\n", skb2
->data
, skb2
->head
);
951 for (i
= 0; i
< frame_length
; i
++)
953 printk("%x:", skb2
->data
[i
]);
954 if (((i
+ 1) % 16) == 0)
960 skb_put(skb2
, length
);
961 skb2
->protocol
= tr_type_trans(skb2
, dev
);
962 /* recycle this descriptor */
963 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].status
= 0;
964 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].framelen_buflen
= streamer_priv
->pkt_buf_sz
;
965 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].buffer
=
966 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, skb
->data
, streamer_priv
->pkt_buf_sz
,
967 PCI_DMA_FROMDEVICE
));
968 streamer_priv
->rx_ring_skb
[rx_ring_last_received
] = skb
;
969 /* place recycled descriptor back on the adapter */
970 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
971 &streamer_priv
->streamer_rx_ring
[rx_ring_last_received
],
972 sizeof(struct streamer_rx_desc
), PCI_DMA_FROMDEVICE
)),
973 streamer_mmio
+ RXLBDA
);
974 /* pass the received skb up to the protocol */
977 do { /* Walk the buffers */
978 pci_unmap_single(streamer_priv
->pci_dev
, le32_to_cpu(rx_desc
->buffer
), length
, PCI_DMA_FROMDEVICE
),
979 memcpy(skb_put(skb
, length
), (void *)rx_desc
->buffer
, length
); /* copy this fragment */
980 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].status
= 0;
981 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].framelen_buflen
= streamer_priv
->pkt_buf_sz
;
983 /* give descriptor back to the adapter */
984 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
985 &streamer_priv
->streamer_rx_ring
[rx_ring_last_received
],
986 length
, PCI_DMA_FROMDEVICE
)),
987 streamer_mmio
+ RXLBDA
);
989 if (rx_desc
->status
& 0x80000000)
990 break; /* this descriptor completes the frame */
992 /* else get the next pending descriptor */
993 if (rx_ring_last_received
!= streamer_priv
->rx_ring_last_received
)
995 printk("RX Error rx_ring_last_received not the same %x %x\n",
996 rx_ring_last_received
,
997 streamer_priv
->rx_ring_last_received
);
999 rx_desc
= &streamer_priv
->streamer_rx_ring
[(streamer_priv
->rx_ring_last_received
+1) & (STREAMER_RX_RING_SIZE
-1)];
1001 length
= rx_desc
->framelen_buflen
& 0xffff; /* buffer length */
1002 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+1) & (STREAMER_RX_RING_SIZE
- 1);
1003 rx_ring_last_received
= streamer_priv
->rx_ring_last_received
;
1006 skb
->protocol
= tr_type_trans(skb
, dev
);
1007 /* send up to the protocol */
1010 dev
->stats
.rx_packets
++;
1011 dev
->stats
.rx_bytes
+= length
;
1012 } /* if skb == null */
1013 } /* end received without errors */
1015 /* try the next one */
1016 rx_desc
= &streamer_priv
->streamer_rx_ring
[(rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1)];
1017 } /* end for all completed rx descriptors */
1020 static irqreturn_t
streamer_interrupt(int irq
, void *dev_id
)
1022 struct net_device
*dev
= (struct net_device
*) dev_id
;
1023 struct streamer_private
*streamer_priv
=
1025 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1028 u8 max_intr
= MAX_INTR
;
1030 spin_lock(&streamer_priv
->streamer_lock
);
1031 sisr
= readw(streamer_mmio
+ SISR
);
1033 while((sisr
& (SISR_MI
| SISR_SRB_REPLY
| SISR_ADAPTER_CHECK
| SISR_ASB_FREE
|
1034 SISR_ARB_CMD
| SISR_TRB_REPLY
| SISR_PAR_ERR
| SISR_SERR_ERR
))
1035 && (max_intr
> 0)) {
1037 if(sisr
& SISR_PAR_ERR
) {
1038 writew(~SISR_PAR_ERR
, streamer_mmio
+ SISR_RUM
);
1039 (void)readw(streamer_mmio
+ SISR_RUM
);
1042 else if(sisr
& SISR_SERR_ERR
) {
1043 writew(~SISR_SERR_ERR
, streamer_mmio
+ SISR_RUM
);
1044 (void)readw(streamer_mmio
+ SISR_RUM
);
1047 else if(sisr
& SISR_MI
) {
1048 misr
= readw(streamer_mmio
+ MISR_RUM
);
1050 if (misr
& MISR_TX2_EOF
) {
1051 while(streamer_priv
->streamer_tx_ring
[(streamer_priv
->tx_ring_last_status
+ 1) & (STREAMER_TX_RING_SIZE
- 1)].status
) {
1052 streamer_priv
->tx_ring_last_status
= (streamer_priv
->tx_ring_last_status
+ 1) & (STREAMER_TX_RING_SIZE
- 1);
1053 streamer_priv
->free_tx_ring_entries
++;
1054 dev
->stats
.tx_bytes
+= streamer_priv
->tx_ring_skb
[streamer_priv
->tx_ring_last_status
]->len
;
1055 dev
->stats
.tx_packets
++;
1056 dev_kfree_skb_irq(streamer_priv
->tx_ring_skb
[streamer_priv
->tx_ring_last_status
]);
1057 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].buffer
= 0xdeadbeef;
1058 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].status
= 0;
1059 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].bufcnt_framelen
= 0;
1060 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].buflen
= 0;
1061 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].rsvd1
= 0;
1062 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].rsvd2
= 0;
1063 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].rsvd3
= 0;
1065 netif_wake_queue(dev
);
1068 if (misr
& MISR_RX_EOF
) {
1073 if (misr
& MISR_RX_NOBUF
) {
1074 /* According to the documentation, we don't have to do anything,
1075 * but trapping it keeps it out of /var/log/messages.
1077 } /* SISR_RX_NOBUF */
1079 writew(~misr
, streamer_mmio
+ MISR_RUM
);
1080 (void)readw(streamer_mmio
+ MISR_RUM
);
1083 else if (sisr
& SISR_SRB_REPLY
) {
1084 if (streamer_priv
->srb_queued
== 1) {
1085 wake_up_interruptible(&streamer_priv
->srb_wait
);
1086 } else if (streamer_priv
->srb_queued
== 2) {
1087 streamer_srb_bh(dev
);
1089 streamer_priv
->srb_queued
= 0;
1091 writew(~SISR_SRB_REPLY
, streamer_mmio
+ SISR_RUM
);
1092 (void)readw(streamer_mmio
+ SISR_RUM
);
1095 else if (sisr
& SISR_ADAPTER_CHECK
) {
1096 printk(KERN_WARNING
"%s: Adapter Check Interrupt Raised, 8 bytes of information follow:\n", dev
->name
);
1097 writel(readl(streamer_mmio
+ LAPWWO
), streamer_mmio
+ LAPA
);
1098 printk(KERN_WARNING
"%s: Words %x:%x:%x:%x:\n",
1099 dev
->name
, readw(streamer_mmio
+ LAPDINC
),
1100 ntohs(readw(streamer_mmio
+ LAPDINC
)),
1101 ntohs(readw(streamer_mmio
+ LAPDINC
)),
1102 ntohs(readw(streamer_mmio
+ LAPDINC
)));
1103 netif_stop_queue(dev
);
1104 netif_carrier_off(dev
);
1105 printk(KERN_WARNING
"%s: Adapter must be manually reset.\n", dev
->name
);
1108 /* SISR_ADAPTER_CHECK */
1109 else if (sisr
& SISR_ASB_FREE
) {
1110 /* Wake up anything that is waiting for the asb response */
1111 if (streamer_priv
->asb_queued
) {
1112 streamer_asb_bh(dev
);
1114 writew(~SISR_ASB_FREE
, streamer_mmio
+ SISR_RUM
);
1115 (void)readw(streamer_mmio
+ SISR_RUM
);
1118 else if (sisr
& SISR_ARB_CMD
) {
1119 streamer_arb_cmd(dev
);
1120 writew(~SISR_ARB_CMD
, streamer_mmio
+ SISR_RUM
);
1121 (void)readw(streamer_mmio
+ SISR_RUM
);
1124 else if (sisr
& SISR_TRB_REPLY
) {
1125 /* Wake up anything that is waiting for the trb response */
1126 if (streamer_priv
->trb_queued
) {
1127 wake_up_interruptible(&streamer_priv
->
1130 streamer_priv
->trb_queued
= 0;
1131 writew(~SISR_TRB_REPLY
, streamer_mmio
+ SISR_RUM
);
1132 (void)readw(streamer_mmio
+ SISR_RUM
);
1134 /* SISR_TRB_REPLY */
1136 sisr
= readw(streamer_mmio
+ SISR
);
1140 spin_unlock(&streamer_priv
->streamer_lock
) ;
1144 static int streamer_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
1146 struct streamer_private
*streamer_priv
=
1148 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1149 unsigned long flags
;
1151 spin_lock_irqsave(&streamer_priv
->streamer_lock
, flags
);
1153 if (streamer_priv
->free_tx_ring_entries
) {
1154 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].status
= 0;
1155 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].bufcnt_framelen
= 0x00020000 | skb
->len
;
1156 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].buffer
=
1157 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, skb
->data
, skb
->len
, PCI_DMA_TODEVICE
));
1158 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].rsvd1
= skb
->len
;
1159 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].rsvd2
= 0;
1160 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].rsvd3
= 0;
1161 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].buflen
= skb
->len
;
1163 streamer_priv
->tx_ring_skb
[streamer_priv
->tx_ring_free
] = skb
;
1164 streamer_priv
->free_tx_ring_entries
--;
1165 #if STREAMER_DEBUG_PACKETS
1168 printk("streamer_xmit packet print:\n");
1169 for (i
= 0; i
< skb
->len
; i
++) {
1170 printk("%x:", skb
->data
[i
]);
1171 if (((i
+ 1) % 16) == 0)
1178 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
1179 &streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
],
1180 sizeof(struct streamer_tx_desc
), PCI_DMA_TODEVICE
)),
1181 streamer_mmio
+ TX2LFDA
);
1182 (void)readl(streamer_mmio
+ TX2LFDA
);
1184 streamer_priv
->tx_ring_free
= (streamer_priv
->tx_ring_free
+ 1) & (STREAMER_TX_RING_SIZE
- 1);
1185 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
,flags
);
1188 netif_stop_queue(dev
);
1189 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
,flags
);
1195 static int streamer_close(struct net_device
*dev
)
1197 struct streamer_private
*streamer_priv
=
1199 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1200 unsigned long flags
;
1203 netif_stop_queue(dev
);
1204 netif_carrier_off(dev
);
1205 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1206 writew(htons(SRB_CLOSE_ADAPTER
<< 8),streamer_mmio
+LAPDINC
);
1207 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1209 spin_lock_irqsave(&streamer_priv
->streamer_lock
, flags
);
1211 streamer_priv
->srb_queued
= 1;
1212 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1214 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
, flags
);
1216 while (streamer_priv
->srb_queued
)
1218 interruptible_sleep_on_timeout(&streamer_priv
->srb_wait
,
1220 if (signal_pending(current
))
1222 printk(KERN_WARNING
"%s: SRB timed out.\n", dev
->name
);
1223 printk(KERN_WARNING
"SISR=%x MISR=%x LISR=%x\n",
1224 readw(streamer_mmio
+ SISR
),
1225 readw(streamer_mmio
+ MISR_RUM
),
1226 readw(streamer_mmio
+ LISR
));
1227 streamer_priv
->srb_queued
= 0;
1232 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1);
1234 for (i
= 0; i
< STREAMER_RX_RING_SIZE
; i
++) {
1235 if (streamer_priv
->rx_ring_skb
[streamer_priv
->rx_ring_last_received
]) {
1236 dev_kfree_skb(streamer_priv
->rx_ring_skb
[streamer_priv
->rx_ring_last_received
]);
1238 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1);
1241 /* reset tx/rx fifo's and busmaster logic */
1243 /* TBD. Add graceful way to reset the LLC channel without doing a soft reset.
1244 writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
1246 writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL);
1250 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1252 for (i
= 0; i
< 2; i
++) {
1253 printk("%x ", ntohs(readw(streamer_mmio
+ LAPDINC
)));
1257 free_irq(dev
->irq
, dev
);
1261 static void streamer_set_rx_mode(struct net_device
*dev
)
1263 struct streamer_private
*streamer_priv
=
1265 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1267 struct dev_mc_list
*dmi
;
1268 unsigned char dev_mc_address
[5];
1271 writel(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1272 options
= streamer_priv
->streamer_copy_all_options
;
1274 if (dev
->flags
& IFF_PROMISC
)
1275 options
|= (3 << 5); /* All LLC and MAC frames, all through the main rx channel */
1277 options
&= ~(3 << 5);
1279 /* Only issue the srb if there is a change in options */
1281 if ((options
^ streamer_priv
->streamer_copy_all_options
))
1283 /* Now to issue the srb command to alter the copy.all.options */
1284 writew(htons(SRB_MODIFY_RECEIVE_OPTIONS
<< 8), streamer_mmio
+LAPDINC
);
1285 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1286 writew(htons((streamer_priv
->streamer_receive_options
<< 8) | options
),streamer_mmio
+LAPDINC
);
1287 writew(htons(0x4a41),streamer_mmio
+LAPDINC
);
1288 writew(htons(0x4d45),streamer_mmio
+LAPDINC
);
1289 writew(htons(0x5320),streamer_mmio
+LAPDINC
);
1290 writew(0x2020, streamer_mmio
+ LAPDINC
);
1292 streamer_priv
->srb_queued
= 2; /* Can't sleep, use srb_bh */
1294 writel(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1296 streamer_priv
->streamer_copy_all_options
= options
;
1300 /* Set the functional addresses we need for multicast */
1301 writel(streamer_priv
->srb
,streamer_mmio
+LAPA
);
1302 dev_mc_address
[0] = dev_mc_address
[1] = dev_mc_address
[2] = dev_mc_address
[3] = 0 ;
1304 for (i
=0,dmi
=dev
->mc_list
;i
< dev
->mc_count
; i
++,dmi
= dmi
->next
)
1306 dev_mc_address
[0] |= dmi
->dmi_addr
[2] ;
1307 dev_mc_address
[1] |= dmi
->dmi_addr
[3] ;
1308 dev_mc_address
[2] |= dmi
->dmi_addr
[4] ;
1309 dev_mc_address
[3] |= dmi
->dmi_addr
[5] ;
1312 writew(htons(SRB_SET_FUNC_ADDRESS
<< 8),streamer_mmio
+LAPDINC
);
1313 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1314 writew(0,streamer_mmio
+LAPDINC
);
1315 writew(htons( (dev_mc_address
[0] << 8) | dev_mc_address
[1]),streamer_mmio
+LAPDINC
);
1316 writew(htons( (dev_mc_address
[2] << 8) | dev_mc_address
[3]),streamer_mmio
+LAPDINC
);
1317 streamer_priv
->srb_queued
= 2 ;
1318 writel(LISR_SRB_CMD
,streamer_mmio
+LISR_SUM
);
1321 static void streamer_srb_bh(struct net_device
*dev
)
1323 struct streamer_private
*streamer_priv
= netdev_priv(dev
);
1324 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1327 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1328 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1332 /* SRB_MODIFY_RECEIVE_OPTIONS i.e. set_multicast_list options (promiscuous)
1333 * At some point we should do something if we get an error, such as
1334 * resetting the IFF_PROMISC flag in dev
1337 case SRB_MODIFY_RECEIVE_OPTIONS
:
1338 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1342 printk(KERN_WARNING
"%s: Unrecognized srb command\n", dev
->name
);
1345 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1348 if (streamer_priv
->streamer_message_level
)
1349 printk(KERN_WARNING
"%s: Receive Options Modified to %x,%x\n",
1351 streamer_priv
->streamer_copy_all_options
,
1352 streamer_priv
->streamer_receive_options
);
1354 } /* switch srb[2] */
1358 /* SRB_SET_GROUP_ADDRESS - Multicast group setting
1360 case SRB_SET_GROUP_ADDRESS
:
1361 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1366 printk(KERN_WARNING
"%s: Unrecognized srb command \n",dev
->name
);
1369 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1372 printk(KERN_WARNING
"%s: Group/Functional address indicator bits not set correctly\n", dev
->name
);
1374 case 0x3e: /* If we ever implement individual multicast addresses, will need to deal with this */
1375 printk(KERN_WARNING
"%s: Group address registers full\n", dev
->name
);
1378 printk(KERN_INFO
"%s: Group Address already set.\n", dev
->name
);
1382 } /* switch srb[2] */
1386 /* SRB_RESET_GROUP_ADDRESS - Remove a multicast address from group list
1388 case SRB_RESET_GROUP_ADDRESS
:
1389 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1394 printk(KERN_WARNING
"%s: Unrecognized srb command \n", dev
->name
);
1397 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1399 case 0x39: /* Must deal with this if individual multicast addresses used */
1400 printk(KERN_INFO
"%s: Group address not found \n", dev
->name
);
1404 } /* switch srb[2] */
1408 /* SRB_SET_FUNC_ADDRESS - Called by the set_rx_mode
1411 case SRB_SET_FUNC_ADDRESS
:
1412 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1415 if (streamer_priv
->streamer_message_level
)
1416 printk(KERN_INFO
"%s: Functional Address Mask Set \n", dev
->name
);
1419 printk(KERN_WARNING
"%s: Unrecognized srb command \n", dev
->name
);
1422 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1426 } /* switch srb[2] */
1429 /* SRB_READ_LOG - Read and reset the adapter error counters
1433 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1438 if (streamer_priv
->streamer_message_level
)
1439 printk(KERN_INFO
"%s: Read Log command complete\n", dev
->name
);
1440 printk("Read Log statistics: ");
1441 writew(streamer_priv
->srb
+ 6,
1442 streamer_mmio
+ LAPA
);
1443 for (i
= 0; i
< 5; i
++) {
1444 printk("%x:", ntohs(readw(streamer_mmio
+ LAPDINC
)));
1450 printk(KERN_WARNING
"%s: Unrecognized srb command \n", dev
->name
);
1453 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1456 } /* switch srb[2] */
1459 /* SRB_READ_SR_COUNTERS - Read and reset the source routing bridge related counters */
1461 case SRB_READ_SR_COUNTERS
:
1462 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1465 if (streamer_priv
->streamer_message_level
)
1466 printk(KERN_INFO
"%s: Read Source Routing Counters issued\n", dev
->name
);
1469 printk(KERN_WARNING
"%s: Unrecognized srb command \n", dev
->name
);
1472 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1476 } /* switch srb[2] */
1480 printk(KERN_WARNING
"%s: Unrecognized srb bh return value.\n", dev
->name
);
1482 } /* switch srb[0] */
1485 static int streamer_set_mac_address(struct net_device
*dev
, void *addr
)
1487 struct sockaddr
*saddr
= addr
;
1488 struct streamer_private
*streamer_priv
= netdev_priv(dev
);
1490 if (netif_running(dev
))
1492 printk(KERN_WARNING
"%s: Cannot set mac/laa address while card is open\n", dev
->name
);
1496 memcpy(streamer_priv
->streamer_laa
, saddr
->sa_data
, dev
->addr_len
);
1498 if (streamer_priv
->streamer_message_level
) {
1499 printk(KERN_INFO
"%s: MAC/LAA Set to = %x.%x.%x.%x.%x.%x\n",
1500 dev
->name
, streamer_priv
->streamer_laa
[0],
1501 streamer_priv
->streamer_laa
[1],
1502 streamer_priv
->streamer_laa
[2],
1503 streamer_priv
->streamer_laa
[3],
1504 streamer_priv
->streamer_laa
[4],
1505 streamer_priv
->streamer_laa
[5]);
1510 static void streamer_arb_cmd(struct net_device
*dev
)
1512 struct streamer_private
*streamer_priv
=
1514 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1516 __u16 frame_len
, buffer_len
;
1517 struct sk_buff
*mac_frame
;
1518 __u8 frame_data
[256];
1520 __u16 lan_status
= 0, lan_status_diff
; /* Initialize to stop compiler warning */
1521 __u8 fdx_prot_error
;
1525 #if STREAMER_NETWORK_MONITOR
1526 struct trh_hdr
*mac_hdr
;
1529 writew(streamer_priv
->arb
, streamer_mmio
+ LAPA
);
1530 arb_word
=ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
1532 if (arb_word
== ARB_RECEIVE_DATA
) { /* Receive.data, MAC frames */
1533 writew(streamer_priv
->arb
+ 6, streamer_mmio
+ LAPA
);
1534 streamer_priv
->mac_rx_buffer
= buff_off
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1535 header_len
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8; /* 802.5 Token-Ring Header Length */
1536 frame_len
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1545 writew(ntohs(buff_off
), streamer_mmio
+ LAPA
); /*setup window to frame data */
1546 next
= htons(readw(streamer_mmio
+ LAPDINC
));
1548 ntohs(readw(streamer_mmio
+ LAPDINC
)) & 0xff;
1549 len
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1551 /* print out 1st 14 bytes of frame data */
1552 for (i
= 0; i
< 7; i
++) {
1553 printk("Loc %d = %04x\n", i
,
1555 (streamer_mmio
+ LAPDINC
)));
1558 printk("next %04x, fs %02x, len %04x \n", next
,
1562 if (!(mac_frame
= dev_alloc_skb(frame_len
))) {
1563 printk(KERN_WARNING
"%s: Memory squeeze, dropping frame.\n",
1567 /* Walk the buffer chain, creating the frame */
1573 writew(htons(buff_off
), streamer_mmio
+ LAPA
); /* setup window to frame data */
1574 next_ptr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1575 readw(streamer_mmio
+ LAPDINC
); /* read thru status word */
1576 buffer_len
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1578 if (buffer_len
> 256)
1582 while (i
< buffer_len
) {
1583 rx_word
=ntohs(readw(streamer_mmio
+LAPDINC
));
1584 frame_data
[i
]=rx_word
>> 8;
1585 frame_data
[i
+1]=rx_word
& 0xff;
1589 memcpy(skb_put(mac_frame
, buffer_len
),
1590 frame_data
, buffer_len
);
1591 } while (next_ptr
&& (buff_off
= next_ptr
));
1593 mac_frame
->protocol
= tr_type_trans(mac_frame
, dev
);
1594 #if STREAMER_NETWORK_MONITOR
1595 printk(KERN_WARNING
"%s: Received MAC Frame, details: \n",
1597 mac_hdr
= tr_hdr(mac_frame
);
1599 "%s: MAC Frame Dest. Addr: %pM\n",
1600 dev
->name
, mac_hdr
->daddr
);
1602 "%s: MAC Frame Srce. Addr: %pM\n",
1603 dev
->name
, mac_hdr
->saddr
);
1605 netif_rx(mac_frame
);
1607 /* Now tell the card we have dealt with the received frame */
1609 /* Set LISR Bit 1 */
1610 writel(LISR_ARB_FREE
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1612 /* Is the ASB free ? */
1614 if (!(readl(streamer_priv
->streamer_mmio
+ SISR
) & SISR_ASB_FREE
))
1616 streamer_priv
->asb_queued
= 1;
1617 writel(LISR_ASB_FREE_REQ
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1619 /* Drop out and wait for the bottom half to be run */
1623 writew(streamer_priv
->asb
, streamer_mmio
+ LAPA
);
1624 writew(htons(ASB_RECEIVE_DATA
<< 8), streamer_mmio
+LAPDINC
);
1625 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1626 writew(0, streamer_mmio
+ LAPDINC
);
1627 writew(htons(streamer_priv
->mac_rx_buffer
), streamer_mmio
+ LAPD
);
1629 writel(LISR_ASB_REPLY
| LISR_ASB_FREE_REQ
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1631 streamer_priv
->asb_queued
= 2;
1634 } else if (arb_word
== ARB_LAN_CHANGE_STATUS
) { /* Lan.change.status */
1635 writew(streamer_priv
->arb
+ 6, streamer_mmio
+ LAPA
);
1636 lan_status
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1637 fdx_prot_error
= ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
1639 /* Issue ARB Free */
1640 writew(LISR_ARB_FREE
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1642 lan_status_diff
= (streamer_priv
->streamer_lan_status
^ lan_status
) &
1645 if (lan_status_diff
& (LSC_LWF
| LSC_ARW
| LSC_FPE
| LSC_RR
))
1647 if (lan_status_diff
& LSC_LWF
)
1648 printk(KERN_WARNING
"%s: Short circuit detected on the lobe\n", dev
->name
);
1649 if (lan_status_diff
& LSC_ARW
)
1650 printk(KERN_WARNING
"%s: Auto removal error\n", dev
->name
);
1651 if (lan_status_diff
& LSC_FPE
)
1652 printk(KERN_WARNING
"%s: FDX Protocol Error\n", dev
->name
);
1653 if (lan_status_diff
& LSC_RR
)
1654 printk(KERN_WARNING
"%s: Force remove MAC frame received\n", dev
->name
);
1656 /* Adapter has been closed by the hardware */
1658 /* reset tx/rx fifo's and busmaster logic */
1660 /* @TBD. no llc reset on autostreamer writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
1662 writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL); */
1664 netif_stop_queue(dev
);
1665 netif_carrier_off(dev
);
1666 printk(KERN_WARNING
"%s: Adapter must be manually reset.\n", dev
->name
);
1668 /* If serious error */
1669 if (streamer_priv
->streamer_message_level
) {
1670 if (lan_status_diff
& LSC_SIG_LOSS
)
1671 printk(KERN_WARNING
"%s: No receive signal detected \n", dev
->name
);
1672 if (lan_status_diff
& LSC_HARD_ERR
)
1673 printk(KERN_INFO
"%s: Beaconing \n", dev
->name
);
1674 if (lan_status_diff
& LSC_SOFT_ERR
)
1675 printk(KERN_WARNING
"%s: Adapter transmitted Soft Error Report Mac Frame \n", dev
->name
);
1676 if (lan_status_diff
& LSC_TRAN_BCN
)
1677 printk(KERN_INFO
"%s: We are tranmitting the beacon, aaah\n", dev
->name
);
1678 if (lan_status_diff
& LSC_SS
)
1679 printk(KERN_INFO
"%s: Single Station on the ring \n", dev
->name
);
1680 if (lan_status_diff
& LSC_RING_REC
)
1681 printk(KERN_INFO
"%s: Ring recovery ongoing\n", dev
->name
);
1682 if (lan_status_diff
& LSC_FDX_MODE
)
1683 printk(KERN_INFO
"%s: Operating in FDX mode\n", dev
->name
);
1686 if (lan_status_diff
& LSC_CO
) {
1687 if (streamer_priv
->streamer_message_level
)
1688 printk(KERN_INFO
"%s: Counter Overflow \n", dev
->name
);
1690 /* Issue READ.LOG command */
1692 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1693 writew(htons(SRB_READ_LOG
<< 8),streamer_mmio
+LAPDINC
);
1694 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1695 writew(0, streamer_mmio
+ LAPDINC
);
1696 streamer_priv
->srb_queued
= 2; /* Can't sleep, use srb_bh */
1698 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1701 if (lan_status_diff
& LSC_SR_CO
) {
1702 if (streamer_priv
->streamer_message_level
)
1703 printk(KERN_INFO
"%s: Source routing counters overflow\n", dev
->name
);
1705 /* Issue a READ.SR.COUNTERS */
1706 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1707 writew(htons(SRB_READ_SR_COUNTERS
<< 8),
1708 streamer_mmio
+LAPDINC
);
1709 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8),
1710 streamer_mmio
+LAPDINC
);
1711 streamer_priv
->srb_queued
= 2; /* Can't sleep, use srb_bh */
1712 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1715 streamer_priv
->streamer_lan_status
= lan_status
;
1716 } /* Lan.change.status */
1718 printk(KERN_WARNING
"%s: Unknown arb command \n", dev
->name
);
1721 static void streamer_asb_bh(struct net_device
*dev
)
1723 struct streamer_private
*streamer_priv
=
1725 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1727 if (streamer_priv
->asb_queued
== 1)
1729 /* Dropped through the first time */
1731 writew(streamer_priv
->asb
, streamer_mmio
+ LAPA
);
1732 writew(htons(ASB_RECEIVE_DATA
<< 8),streamer_mmio
+LAPDINC
);
1733 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1734 writew(0, streamer_mmio
+ LAPDINC
);
1735 writew(htons(streamer_priv
->mac_rx_buffer
), streamer_mmio
+ LAPD
);
1737 writel(LISR_ASB_REPLY
| LISR_ASB_FREE_REQ
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1738 streamer_priv
->asb_queued
= 2;
1743 if (streamer_priv
->asb_queued
== 2) {
1745 writew(streamer_priv
->asb
+ 2, streamer_mmio
+ LAPA
);
1746 rc
=ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
1749 printk(KERN_WARNING
"%s: Unrecognized command code \n", dev
->name
);
1752 printk(KERN_WARNING
"%s: Unrecognized buffer address \n", dev
->name
);
1755 /* Valid response, everything should be ok again */
1758 printk(KERN_WARNING
"%s: Invalid return code in asb\n", dev
->name
);
1762 streamer_priv
->asb_queued
= 0;
1765 static int streamer_change_mtu(struct net_device
*dev
, int mtu
)
1767 struct streamer_private
*streamer_priv
=
1771 if (streamer_priv
->streamer_ring_speed
== 4)
1782 streamer_priv
->pkt_buf_sz
= mtu
+ TR_HLEN
;
1787 #if STREAMER_NETWORK_MONITOR
1788 #ifdef CONFIG_PROC_FS
1789 static int streamer_proc_info(char *buffer
, char **start
, off_t offset
,
1790 int length
, int *eof
, void *data
)
1792 struct streamer_private
*sdev
=NULL
;
1793 struct pci_dev
*pci_device
= NULL
;
1799 struct net_device
*dev
;
1801 size
= sprintf(buffer
, "IBM LanStreamer/MPC Chipset Token Ring Adapters\n");
1806 for(sdev
=dev_streamer
; sdev
; sdev
=sdev
->next
) {
1807 pci_device
=sdev
->pci_dev
;
1808 dev
=pci_get_drvdata(pci_device
);
1810 size
= sprintf_info(buffer
+ len
, dev
);
1818 if (pos
> offset
+ length
)
1822 *start
= buffer
+ (offset
- begin
); /* Start of wanted data */
1823 len
-= (offset
- begin
); /* Start slop */
1825 len
= length
; /* Ending slop */
1829 static int sprintf_info(char *buffer
, struct net_device
*dev
)
1831 struct streamer_private
*streamer_priv
=
1833 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1834 struct streamer_adapter_addr_table sat
;
1835 struct streamer_parameters_table spt
;
1839 writew(streamer_priv
->streamer_addr_table_addr
, streamer_mmio
+ LAPA
);
1840 for (i
= 0; i
< 14; i
+= 2) {
1842 __u8
*datap
= (__u8
*) & sat
;
1843 io_word
=ntohs(readw(streamer_mmio
+LAPDINC
));
1844 datap
[size
]=io_word
>> 8;
1845 datap
[size
+1]=io_word
& 0xff;
1847 writew(streamer_priv
->streamer_parms_addr
, streamer_mmio
+ LAPA
);
1848 for (i
= 0; i
< 68; i
+= 2) {
1850 __u8
*datap
= (__u8
*) & spt
;
1851 io_word
=ntohs(readw(streamer_mmio
+LAPDINC
));
1852 datap
[size
]=io_word
>> 8;
1853 datap
[size
+1]=io_word
& 0xff;
1856 size
= sprintf(buffer
, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev
->name
);
1858 size
+= sprintf(buffer
+ size
,
1859 "%6s: %pM : %pM : %02x:%02x:%02x:%02x\n",
1860 dev
->name
, dev
->dev_addr
, sat
.node_addr
,
1861 sat
.func_addr
[0], sat
.func_addr
[1],
1862 sat
.func_addr
[2], sat
.func_addr
[3]);
1864 size
+= sprintf(buffer
+ size
, "\n%6s: Token Ring Parameters Table:\n", dev
->name
);
1866 size
+= sprintf(buffer
+ size
, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", dev
->name
);
1868 size
+= sprintf(buffer
+ size
,
1869 "%6s: %02x:%02x:%02x:%02x : %pM : %pM : %04x : %04x : %04x :\n",
1870 dev
->name
, spt
.phys_addr
[0], spt
.phys_addr
[1],
1871 spt
.phys_addr
[2], spt
.phys_addr
[3],
1872 spt
.up_node_addr
, spt
.poll_addr
,
1873 ntohs(spt
.acc_priority
), ntohs(spt
.auth_source_class
),
1874 ntohs(spt
.att_code
));
1876 size
+= sprintf(buffer
+ size
, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", dev
->name
);
1878 size
+= sprintf(buffer
+ size
,
1879 "%6s: %pM : %04x : %04x : %04x : %04x : %04x : %04x : \n",
1880 dev
->name
, spt
.source_addr
,
1881 ntohs(spt
.beacon_type
), ntohs(spt
.major_vector
),
1882 ntohs(spt
.lan_status
), ntohs(spt
.local_ring
),
1883 ntohs(spt
.mon_error
), ntohs(spt
.frame_correl
));
1885 size
+= sprintf(buffer
+ size
, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n",
1888 size
+= sprintf(buffer
+ size
,
1889 "%6s: : %02x : %02x : %pM : %02x:%02x:%02x:%02x : \n",
1890 dev
->name
, ntohs(spt
.beacon_transmit
),
1891 ntohs(spt
.beacon_receive
),
1893 spt
.beacon_phys
[0], spt
.beacon_phys
[1],
1894 spt
.beacon_phys
[2], spt
.beacon_phys
[3]);
1900 static struct pci_driver streamer_pci_driver
= {
1901 .name
= "lanstreamer",
1902 .id_table
= streamer_pci_tbl
,
1903 .probe
= streamer_init_one
,
1904 .remove
= __devexit_p(streamer_remove_one
),
1907 static int __init
streamer_init_module(void) {
1908 return pci_register_driver(&streamer_pci_driver
);
1911 static void __exit
streamer_cleanup_module(void) {
1912 pci_unregister_driver(&streamer_pci_driver
);
1915 module_init(streamer_init_module
);
1916 module_exit(streamer_cleanup_module
);
1917 MODULE_LICENSE("GPL");