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>
124 #include <linux/slab.h>
126 #include <net/net_namespace.h>
127 #include <net/checksum.h>
130 #include <asm/system.h>
132 #include "lanstreamer.h"
134 #if (BITS_PER_LONG == 64)
135 #error broken on 64-bit: stores pointer to rx_ring->buffer in 32-bit int
139 /* I've got to put some intelligence into the version number so that Peter and I know
140 * which version of the code somebody has got.
141 * Version Number = a.b.c.d where a.b.c is the level of code and d is the latest author.
142 * So 0.0.1.pds = Peter, 0.0.1.mlp = Mike
144 * Official releases will only have an a.b.c version number format.
147 static char version
[] = "LanStreamer.c v0.4.0 03/08/01 - Mike Sullivan\n"
148 " v0.5.3 11/13/02 - Kent Yoder";
150 static DEFINE_PCI_DEVICE_TABLE(streamer_pci_tbl
) = {
151 { PCI_VENDOR_ID_IBM
, PCI_DEVICE_ID_IBM_TR
, PCI_ANY_ID
, PCI_ANY_ID
,},
152 {} /* terminating entry */
154 MODULE_DEVICE_TABLE(pci
,streamer_pci_tbl
);
157 static char *open_maj_error
[] = {
158 "No error", "Lobe Media Test", "Physical Insertion",
159 "Address Verification", "Neighbor Notification (Ring Poll)",
160 "Request Parameters", "FDX Registration Request",
161 "FDX Lobe Media Test", "FDX Duplicate Address Check",
165 static char *open_min_error
[] = {
166 "No error", "Function Failure", "Signal Lost", "Wire Fault",
167 "Ring Speed Mismatch", "Timeout", "Ring Failure", "Ring Beaconing",
168 "Duplicate Node Address", "Request Parameters", "Remove Received",
169 "Reserved", "Reserved", "No Monitor Detected for RPL",
170 "Monitor Contention failer for RPL", "FDX Protocol Error"
173 /* Module parameters */
177 * 4,16 = Selected speed only, no autosense
178 * This allows the card to be the first on the ring
179 * and become the active monitor.
181 * WARNING: Some hubs will allow you to insert
185 static int ringspeed
[STREAMER_MAX_ADAPTERS
] = { 0, };
187 module_param_array(ringspeed
, int, NULL
, 0);
189 /* Packet buffer size */
191 static int pkt_buf_sz
[STREAMER_MAX_ADAPTERS
] = { 0, };
193 module_param_array(pkt_buf_sz
, int, NULL
, 0);
197 static int message_level
[STREAMER_MAX_ADAPTERS
] = { 1, };
199 module_param_array(message_level
, int, NULL
, 0);
202 static int streamer_ioctl(struct net_device
*, struct ifreq
*, int);
205 static int streamer_reset(struct net_device
*dev
);
206 static int streamer_open(struct net_device
*dev
);
207 static netdev_tx_t
streamer_xmit(struct sk_buff
*skb
,
208 struct net_device
*dev
);
209 static int streamer_close(struct net_device
*dev
);
210 static void streamer_set_rx_mode(struct net_device
*dev
);
211 static irqreturn_t
streamer_interrupt(int irq
, void *dev_id
);
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 const struct net_device_ops streamer_netdev_ops
= {
227 .ndo_open
= streamer_open
,
228 .ndo_stop
= streamer_close
,
229 .ndo_start_xmit
= streamer_xmit
,
230 .ndo_change_mtu
= streamer_change_mtu
,
232 .ndo_do_ioctl
= streamer_ioctl
,
234 .ndo_set_rx_mode
= streamer_set_rx_mode
,
235 .ndo_set_mac_address
= streamer_set_mac_address
,
238 static int __devinit
streamer_init_one(struct pci_dev
*pdev
,
239 const struct pci_device_id
*ent
)
241 struct net_device
*dev
;
242 struct streamer_private
*streamer_priv
;
243 unsigned long pio_start
, pio_end
, pio_flags
, pio_len
;
244 unsigned long mmio_start
, mmio_end
, mmio_flags
, mmio_len
;
246 static int card_no
=-1;
250 printk("lanstreamer::streamer_init_one, entry pdev %p\n",pdev
);
254 dev
= alloc_trdev(sizeof(*streamer_priv
));
256 printk(KERN_ERR
"lanstreamer: out of memory.\n");
260 streamer_priv
= netdev_priv(dev
);
262 #if STREAMER_NETWORK_MONITOR
263 #ifdef CONFIG_PROC_FS
265 create_proc_read_entry("streamer_tr", 0, init_net
.proc_net
,
266 streamer_proc_info
, NULL
);
267 streamer_priv
->next
= dev_streamer
;
268 dev_streamer
= streamer_priv
;
272 rc
= pci_set_dma_mask(pdev
, DMA_BIT_MASK(32));
274 printk(KERN_ERR
"%s: No suitable PCI mapping available.\n",
280 rc
= pci_enable_device(pdev
);
282 printk(KERN_ERR
"lanstreamer: unable to enable pci device\n");
287 pci_set_master(pdev
);
289 rc
= pci_set_mwi(pdev
);
291 printk(KERN_ERR
"lanstreamer: unable to enable MWI on pci device\n");
292 goto err_out_disable
;
295 pio_start
= pci_resource_start(pdev
, 0);
296 pio_end
= pci_resource_end(pdev
, 0);
297 pio_flags
= pci_resource_flags(pdev
, 0);
298 pio_len
= pci_resource_len(pdev
, 0);
300 mmio_start
= pci_resource_start(pdev
, 1);
301 mmio_end
= pci_resource_end(pdev
, 1);
302 mmio_flags
= pci_resource_flags(pdev
, 1);
303 mmio_len
= pci_resource_len(pdev
, 1);
306 printk("lanstreamer: pio_start %x pio_end %x pio_len %x pio_flags %x\n",
307 pio_start
, pio_end
, pio_len
, pio_flags
);
308 printk("lanstreamer: mmio_start %x mmio_end %x mmio_len %x mmio_flags %x\n",
309 mmio_start
, mmio_end
, mmio_flags
, mmio_len
);
312 if (!request_region(pio_start
, pio_len
, "lanstreamer")) {
313 printk(KERN_ERR
"lanstreamer: unable to get pci io addr %lx\n",
319 if (!request_mem_region(mmio_start
, mmio_len
, "lanstreamer")) {
320 printk(KERN_ERR
"lanstreamer: unable to get pci mmio addr %lx\n",
323 goto err_out_free_pio
;
326 streamer_priv
->streamer_mmio
=ioremap(mmio_start
, mmio_len
);
327 if (streamer_priv
->streamer_mmio
== NULL
) {
328 printk(KERN_ERR
"lanstreamer: unable to remap MMIO %lx\n",
331 goto err_out_free_mmio
;
334 init_waitqueue_head(&streamer_priv
->srb_wait
);
335 init_waitqueue_head(&streamer_priv
->trb_wait
);
337 dev
->netdev_ops
= &streamer_netdev_ops
;
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
=netdev_priv(dev
);
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("streamer_tr", init_net
.proc_net
);
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
= netdev_priv(dev
);
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 */
460 writew(readw(streamer_mmio
+ BCTL
) & ~BCTL_SOFTRESET
,
461 streamer_mmio
+ BCTL
);
464 printk("BCTL: %x\n", readw(streamer_mmio
+ BCTL
));
465 printk("GPR: %x\n", readw(streamer_mmio
+ GPR
));
466 printk("SISRMASK: %x\n", readw(streamer_mmio
+ SISR_MASK
));
468 writew(readw(streamer_mmio
+ BCTL
) | (BCTL_RX_FIFO_8
| BCTL_TX_FIFO_8
), streamer_mmio
+ BCTL
);
470 if (streamer_priv
->streamer_ring_speed
== 0) { /* Autosense */
471 writew(readw(streamer_mmio
+ GPR
) | GPR_AUTOSENSE
,
472 streamer_mmio
+ GPR
);
473 if (streamer_priv
->streamer_message_level
)
474 printk(KERN_INFO
"%s: Ringspeed autosense mode on\n",
476 } else if (streamer_priv
->streamer_ring_speed
== 16) {
477 if (streamer_priv
->streamer_message_level
)
478 printk(KERN_INFO
"%s: Trying to open at 16 Mbps as requested\n",
480 writew(GPR_16MBPS
, streamer_mmio
+ GPR
);
481 } else if (streamer_priv
->streamer_ring_speed
== 4) {
482 if (streamer_priv
->streamer_message_level
)
483 printk(KERN_INFO
"%s: Trying to open at 4 Mbps as requested\n",
485 writew(0, streamer_mmio
+ GPR
);
488 skb
= dev_alloc_skb(streamer_priv
->pkt_buf_sz
);
490 printk(KERN_INFO
"%s: skb allocation for diagnostics failed...proceeding\n",
493 struct streamer_rx_desc
*rx_ring
;
496 rx_ring
=(struct streamer_rx_desc
*)skb
->data
;
497 data
=((u8
*)skb
->data
)+sizeof(struct streamer_rx_desc
);
500 rx_ring
->buffer
=cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, data
,
501 512, PCI_DMA_FROMDEVICE
));
502 rx_ring
->framelen_buflen
=512;
503 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, rx_ring
, 512, PCI_DMA_FROMDEVICE
)),
504 streamer_mmio
+RXBDA
);
508 printk("GPR = %x\n", readw(streamer_mmio
+ GPR
));
510 /* start solo init */
511 writew(SISR_MI
, streamer_mmio
+ SISR_MASK_SUM
);
513 while (!((readw(streamer_mmio
+ SISR
)) & SISR_SRB_REPLY
)) {
514 msleep_interruptible(100);
515 if (time_after(jiffies
, t
+ 40 * HZ
)) {
517 "IBM PCI tokenring card not responding\n");
518 release_region(dev
->base_addr
, STREAMER_IO_SPACE
);
524 writew(~SISR_SRB_REPLY
, streamer_mmio
+ SISR_RUM
);
525 misr
= readw(streamer_mmio
+ MISR_RUM
);
526 writew(~misr
, streamer_mmio
+ MISR_RUM
);
529 dev_kfree_skb(skb
); /* release skb used for diagnostics */
532 printk("LAPWWO: %x, LAPA: %x LAPE: %x\n",
533 readw(streamer_mmio
+ LAPWWO
), readw(streamer_mmio
+ LAPA
),
534 readw(streamer_mmio
+ LAPE
));
540 writew(readw(streamer_mmio
+ LAPWWO
),
541 streamer_mmio
+ LAPA
);
542 printk("initialization response srb dump: ");
543 for (i
= 0; i
< 10; i
++)
545 ntohs(readw(streamer_mmio
+ LAPDINC
)));
550 writew(readw(streamer_mmio
+ LAPWWO
) + 6, streamer_mmio
+ LAPA
);
551 if (readw(streamer_mmio
+ LAPD
)) {
552 printk(KERN_INFO
"tokenring card initialization failed. errorcode : %x\n",
553 ntohs(readw(streamer_mmio
+ LAPD
)));
554 release_region(dev
->base_addr
, STREAMER_IO_SPACE
);
558 writew(readw(streamer_mmio
+ LAPWWO
) + 8, streamer_mmio
+ LAPA
);
559 uaa_addr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
560 readw(streamer_mmio
+ LAPDINC
); /* skip over Level.Addr field */
561 streamer_priv
->streamer_addr_table_addr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
562 streamer_priv
->streamer_parms_addr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
565 printk("UAA resides at %x\n", uaa_addr
);
568 /* setup uaa area for access with LAPD */
572 writew(uaa_addr
, streamer_mmio
+ LAPA
);
573 for (i
= 0; i
< 6; i
+= 2) {
574 addr
=ntohs(readw(streamer_mmio
+LAPDINC
));
575 dev
->dev_addr
[i
]= (addr
>> 8) & 0xff;
576 dev
->dev_addr
[i
+1]= addr
& 0xff;
579 printk("Adapter address: %pM\n", dev
->dev_addr
);
585 static int streamer_open(struct net_device
*dev
)
587 struct streamer_private
*streamer_priv
= netdev_priv(dev
);
588 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
590 char open_error
[255];
591 int i
, open_finished
= 1;
596 if (readw(streamer_mmio
+BMCTL_SUM
) & BMCTL_RX_ENABLED
) {
597 rc
=streamer_reset(dev
);
600 if (request_irq(dev
->irq
, streamer_interrupt
, IRQF_SHARED
, "lanstreamer", dev
)) {
604 printk("BMCTL: %x\n", readw(streamer_mmio
+ BMCTL_SUM
));
605 printk("pending ints: %x\n", readw(streamer_mmio
+ SISR
));
608 writew(SISR_MI
| SISR_SRB_REPLY
, streamer_mmio
+ SISR_MASK
); /* more ints later, doesn't stop arb cmd interrupt */
609 writew(LISR_LIE
, streamer_mmio
+ LISR
); /* more ints later */
611 /* adapter is closed, so SRB is pointed to by LAPWWO */
612 writew(readw(streamer_mmio
+ LAPWWO
), streamer_mmio
+ LAPA
);
615 printk("LAPWWO: %x, LAPA: %x\n", readw(streamer_mmio
+ LAPWWO
),
616 readw(streamer_mmio
+ LAPA
));
617 printk("LAPE: %x\n", readw(streamer_mmio
+ LAPE
));
618 printk("SISR Mask = %04x\n", readw(streamer_mmio
+ SISR_MASK
));
621 for (i
= 0; i
< SRB_COMMAND_SIZE
; i
+= 2) {
622 writew(0, streamer_mmio
+ LAPDINC
);
625 writew(readw(streamer_mmio
+LAPWWO
),streamer_mmio
+LAPA
);
626 writew(htons(SRB_OPEN_ADAPTER
<<8),streamer_mmio
+LAPDINC
) ; /* open */
627 writew(htons(STREAMER_CLEAR_RET_CODE
<<8),streamer_mmio
+LAPDINC
);
628 writew(STREAMER_CLEAR_RET_CODE
, streamer_mmio
+ LAPDINC
);
630 writew(readw(streamer_mmio
+ LAPWWO
) + 8, streamer_mmio
+ LAPA
);
631 #if STREAMER_NETWORK_MONITOR
632 /* If Network Monitor, instruct card to copy MAC frames through the ARB */
633 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 */
635 writew(htons(OPEN_ADAPTER_ENABLE_FDX
), streamer_mmio
+ LAPDINC
); /* Offset 8 word contains Open.Options */
638 if (streamer_priv
->streamer_laa
[0]) {
639 writew(readw(streamer_mmio
+ LAPWWO
) + 12, streamer_mmio
+ LAPA
);
640 writew(htons((streamer_priv
->streamer_laa
[0] << 8) |
641 streamer_priv
->streamer_laa
[1]),streamer_mmio
+LAPDINC
);
642 writew(htons((streamer_priv
->streamer_laa
[2] << 8) |
643 streamer_priv
->streamer_laa
[3]),streamer_mmio
+LAPDINC
);
644 writew(htons((streamer_priv
->streamer_laa
[4] << 8) |
645 streamer_priv
->streamer_laa
[5]),streamer_mmio
+LAPDINC
);
646 memcpy(dev
->dev_addr
, streamer_priv
->streamer_laa
, dev
->addr_len
);
649 /* save off srb open offset */
650 srb_open
= readw(streamer_mmio
+ LAPWWO
);
652 writew(readw(streamer_mmio
+ LAPWWO
),
653 streamer_mmio
+ LAPA
);
654 printk("srb open request:\n");
655 for (i
= 0; i
< 16; i
++) {
656 printk("%x:", ntohs(readw(streamer_mmio
+ LAPDINC
)));
660 spin_lock_irqsave(&streamer_priv
->streamer_lock
, flags
);
661 streamer_priv
->srb_queued
= 1;
663 /* signal solo that SRB command has been issued */
664 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
665 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
, flags
);
667 while (streamer_priv
->srb_queued
) {
668 interruptible_sleep_on_timeout(&streamer_priv
->srb_wait
, 5 * HZ
);
669 if (signal_pending(current
)) {
670 printk(KERN_WARNING
"%s: SRB timed out.\n", dev
->name
);
671 printk(KERN_WARNING
"SISR=%x MISR=%x, LISR=%x\n",
672 readw(streamer_mmio
+ SISR
),
673 readw(streamer_mmio
+ MISR_RUM
),
674 readw(streamer_mmio
+ LISR
));
675 streamer_priv
->srb_queued
= 0;
681 printk("SISR_MASK: %x\n", readw(streamer_mmio
+ SISR_MASK
));
682 printk("srb open response:\n");
683 writew(srb_open
, streamer_mmio
+ LAPA
);
684 for (i
= 0; i
< 10; i
++) {
686 ntohs(readw(streamer_mmio
+ LAPDINC
)));
690 /* If we get the same return response as we set, the interrupt wasn't raised and the open
693 writew(srb_open
+ 2, streamer_mmio
+ LAPA
);
694 srb_word
= ntohs(readw(streamer_mmio
+ LAPD
)) >> 8;
695 if (srb_word
== STREAMER_CLEAR_RET_CODE
) {
696 printk(KERN_WARNING
"%s: Adapter Open time out or error.\n",
702 if (srb_word
== 0x07) {
703 if (!streamer_priv
->streamer_ring_speed
&& open_finished
) { /* Autosense , first time around */
704 printk(KERN_WARNING
"%s: Retrying at different ring speed\n",
710 writew(srb_open
+ 6, streamer_mmio
+ LAPA
);
711 error_code
= ntohs(readw(streamer_mmio
+ LAPD
));
712 strcpy(open_error
, open_maj_error
[(error_code
& 0xf0) >> 4]);
713 strcat(open_error
, " - ");
714 strcat(open_error
, open_min_error
[(error_code
& 0x0f)]);
716 if (!streamer_priv
->streamer_ring_speed
&&
717 ((error_code
& 0x0f) == 0x0d))
719 printk(KERN_WARNING
"%s: Tried to autosense ring speed with no monitors present\n", dev
->name
);
720 printk(KERN_WARNING
"%s: Please try again with a specified ring speed\n", dev
->name
);
721 free_irq(dev
->irq
, dev
);
725 printk(KERN_WARNING
"%s: %s\n",
726 dev
->name
, open_error
);
727 free_irq(dev
->irq
, dev
);
730 } /* if autosense && open_finished */
732 printk(KERN_WARNING
"%s: Bad OPEN response: %x\n",
733 dev
->name
, srb_word
);
734 free_irq(dev
->irq
, dev
);
739 } while (!(open_finished
)); /* Will only loop if ring speed mismatch re-open attempted && autosense is on */
741 writew(srb_open
+ 18, streamer_mmio
+ LAPA
);
742 srb_word
=ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
743 if (srb_word
& (1 << 3))
744 if (streamer_priv
->streamer_message_level
)
745 printk(KERN_INFO
"%s: Opened in FDX Mode\n", dev
->name
);
748 streamer_priv
->streamer_ring_speed
= 16;
750 streamer_priv
->streamer_ring_speed
= 4;
752 if (streamer_priv
->streamer_message_level
)
753 printk(KERN_INFO
"%s: Opened in %d Mbps mode\n",
755 streamer_priv
->streamer_ring_speed
);
757 writew(srb_open
+ 8, streamer_mmio
+ LAPA
);
758 streamer_priv
->asb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
759 streamer_priv
->srb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
760 streamer_priv
->arb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
761 readw(streamer_mmio
+ LAPDINC
); /* offset 14 word is rsvd */
762 streamer_priv
->trb
= ntohs(readw(streamer_mmio
+ LAPDINC
));
764 streamer_priv
->streamer_receive_options
= 0x00;
765 streamer_priv
->streamer_copy_all_options
= 0;
768 /* enable rx channel */
769 writew(~BMCTL_RX_DIS
, streamer_mmio
+ BMCTL_RUM
);
771 /* setup rx descriptors */
772 streamer_priv
->streamer_rx_ring
=
773 kmalloc( sizeof(struct streamer_rx_desc
)*
774 STREAMER_RX_RING_SIZE
,GFP_KERNEL
);
775 if (!streamer_priv
->streamer_rx_ring
) {
776 printk(KERN_WARNING
"%s ALLOC of streamer rx ring FAILED!!\n",dev
->name
);
780 for (i
= 0; i
< STREAMER_RX_RING_SIZE
; i
++) {
783 skb
= dev_alloc_skb(streamer_priv
->pkt_buf_sz
);
789 streamer_priv
->streamer_rx_ring
[i
].forward
=
790 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[i
+ 1],
791 sizeof(struct streamer_rx_desc
), PCI_DMA_FROMDEVICE
));
792 streamer_priv
->streamer_rx_ring
[i
].status
= 0;
793 streamer_priv
->streamer_rx_ring
[i
].buffer
=
794 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, skb
->data
,
795 streamer_priv
->pkt_buf_sz
, PCI_DMA_FROMDEVICE
));
796 streamer_priv
->streamer_rx_ring
[i
].framelen_buflen
= streamer_priv
->pkt_buf_sz
;
797 streamer_priv
->rx_ring_skb
[i
] = skb
;
799 streamer_priv
->streamer_rx_ring
[STREAMER_RX_RING_SIZE
- 1].forward
=
800 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[0],
801 sizeof(struct streamer_rx_desc
), PCI_DMA_FROMDEVICE
));
804 printk(KERN_WARNING
"%s: Not enough memory to allocate rx buffers. Adapter disabled\n", dev
->name
);
805 free_irq(dev
->irq
, dev
);
809 streamer_priv
->rx_ring_last_received
= STREAMER_RX_RING_SIZE
- 1; /* last processed rx status */
811 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[0],
812 sizeof(struct streamer_rx_desc
), PCI_DMA_TODEVICE
)),
813 streamer_mmio
+ RXBDA
);
814 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_rx_ring
[STREAMER_RX_RING_SIZE
- 1],
815 sizeof(struct streamer_rx_desc
), PCI_DMA_TODEVICE
)),
816 streamer_mmio
+ RXLBDA
);
818 /* set bus master interrupt event mask */
819 writew(MISR_RX_NOBUF
| MISR_RX_EOF
, streamer_mmio
+ MISR_MASK
);
823 streamer_priv
->streamer_tx_ring
=kmalloc(sizeof(struct streamer_tx_desc
)*
824 STREAMER_TX_RING_SIZE
,GFP_KERNEL
);
825 if (!streamer_priv
->streamer_tx_ring
) {
826 printk(KERN_WARNING
"%s ALLOC of streamer_tx_ring FAILED\n",dev
->name
);
830 writew(~BMCTL_TX2_DIS
, streamer_mmio
+ BMCTL_RUM
); /* Enables TX channel 2 */
831 for (i
= 0; i
< STREAMER_TX_RING_SIZE
; i
++) {
832 streamer_priv
->streamer_tx_ring
[i
].forward
= cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
833 &streamer_priv
->streamer_tx_ring
[i
+ 1],
834 sizeof(struct streamer_tx_desc
),
836 streamer_priv
->streamer_tx_ring
[i
].status
= 0;
837 streamer_priv
->streamer_tx_ring
[i
].bufcnt_framelen
= 0;
838 streamer_priv
->streamer_tx_ring
[i
].buffer
= 0;
839 streamer_priv
->streamer_tx_ring
[i
].buflen
= 0;
840 streamer_priv
->streamer_tx_ring
[i
].rsvd1
= 0;
841 streamer_priv
->streamer_tx_ring
[i
].rsvd2
= 0;
842 streamer_priv
->streamer_tx_ring
[i
].rsvd3
= 0;
844 streamer_priv
->streamer_tx_ring
[STREAMER_TX_RING_SIZE
- 1].forward
=
845 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, &streamer_priv
->streamer_tx_ring
[0],
846 sizeof(struct streamer_tx_desc
), PCI_DMA_TODEVICE
));
848 streamer_priv
->free_tx_ring_entries
= STREAMER_TX_RING_SIZE
;
849 streamer_priv
->tx_ring_free
= 0; /* next entry in tx ring to use */
850 streamer_priv
->tx_ring_last_status
= STREAMER_TX_RING_SIZE
- 1;
852 /* set Busmaster interrupt event mask (handle receives on interrupt only */
853 writew(MISR_TX2_EOF
| MISR_RX_NOBUF
| MISR_RX_EOF
, streamer_mmio
+ MISR_MASK
);
854 /* set system event interrupt mask */
855 writew(SISR_ADAPTER_CHECK
| SISR_ARB_CMD
| SISR_TRB_REPLY
| SISR_ASB_FREE
, streamer_mmio
+ SISR_MASK_SUM
);
858 printk("BMCTL: %x\n", readw(streamer_mmio
+ BMCTL_SUM
));
859 printk("SISR MASK: %x\n", readw(streamer_mmio
+ SISR_MASK
));
862 #if STREAMER_NETWORK_MONITOR
864 writew(streamer_priv
->streamer_addr_table_addr
, streamer_mmio
+ LAPA
);
865 printk("%s: Node Address: %04x:%04x:%04x\n", dev
->name
,
866 ntohs(readw(streamer_mmio
+ LAPDINC
)),
867 ntohs(readw(streamer_mmio
+ LAPDINC
)),
868 ntohs(readw(streamer_mmio
+ LAPDINC
)));
869 readw(streamer_mmio
+ LAPDINC
);
870 readw(streamer_mmio
+ LAPDINC
);
871 printk("%s: Functional Address: %04x:%04x\n", dev
->name
,
872 ntohs(readw(streamer_mmio
+ LAPDINC
)),
873 ntohs(readw(streamer_mmio
+ LAPDINC
)));
875 writew(streamer_priv
->streamer_parms_addr
+ 4,
876 streamer_mmio
+ LAPA
);
877 printk("%s: NAUN Address: %04x:%04x:%04x\n", dev
->name
,
878 ntohs(readw(streamer_mmio
+ LAPDINC
)),
879 ntohs(readw(streamer_mmio
+ LAPDINC
)),
880 ntohs(readw(streamer_mmio
+ LAPDINC
)));
883 netif_start_queue(dev
);
884 netif_carrier_on(dev
);
889 * When we enter the rx routine we do not know how many frames have been
890 * queued on the rx channel. Therefore we start at the next rx status
891 * position and travel around the receive ring until we have completed
894 * This means that we may process the frame before we receive the end
895 * of frame interrupt. This is why we always test the status instead
896 * of blindly processing the next frame.
899 static void streamer_rx(struct net_device
*dev
)
901 struct streamer_private
*streamer_priv
=
903 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
904 struct streamer_rx_desc
*rx_desc
;
905 int rx_ring_last_received
, length
, frame_length
, buffer_cnt
= 0;
906 struct sk_buff
*skb
, *skb2
;
908 /* setup the next rx descriptor to be received */
909 rx_desc
= &streamer_priv
->streamer_rx_ring
[(streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1)];
910 rx_ring_last_received
= streamer_priv
->rx_ring_last_received
;
912 while (rx_desc
->status
& 0x01000000) { /* While processed descriptors are available */
913 if (rx_ring_last_received
!= streamer_priv
->rx_ring_last_received
)
915 printk(KERN_WARNING
"RX Error 1 rx_ring_last_received not the same %x %x\n",
916 rx_ring_last_received
, streamer_priv
->rx_ring_last_received
);
918 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1);
919 rx_ring_last_received
= streamer_priv
->rx_ring_last_received
;
921 length
= rx_desc
->framelen_buflen
& 0xffff; /* buffer length */
922 frame_length
= (rx_desc
->framelen_buflen
>> 16) & 0xffff;
924 if (rx_desc
->status
& 0x7E830000) { /* errors */
925 if (streamer_priv
->streamer_message_level
) {
926 printk(KERN_WARNING
"%s: Rx Error %x\n",
927 dev
->name
, rx_desc
->status
);
929 } else { /* received without errors */
930 if (rx_desc
->status
& 0x80000000) { /* frame complete */
932 skb
= dev_alloc_skb(streamer_priv
->pkt_buf_sz
);
934 skb
= dev_alloc_skb(frame_length
);
939 printk(KERN_WARNING
"%s: Not enough memory to copy packet to upper layers.\n", dev
->name
);
940 dev
->stats
.rx_dropped
++;
941 } else { /* we allocated an skb OK */
942 if (buffer_cnt
== 1) {
943 /* release the DMA mapping */
944 pci_unmap_single(streamer_priv
->pci_dev
,
945 le32_to_cpu(streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].buffer
),
946 streamer_priv
->pkt_buf_sz
,
948 skb2
= streamer_priv
->rx_ring_skb
[rx_ring_last_received
];
949 #if STREAMER_DEBUG_PACKETS
952 printk("streamer_rx packet print: skb->data2 %p skb->head %p\n", skb2
->data
, skb2
->head
);
953 for (i
= 0; i
< frame_length
; i
++)
955 printk("%x:", skb2
->data
[i
]);
956 if (((i
+ 1) % 16) == 0)
962 skb_put(skb2
, length
);
963 skb2
->protocol
= tr_type_trans(skb2
, dev
);
964 /* recycle this descriptor */
965 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].status
= 0;
966 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].framelen_buflen
= streamer_priv
->pkt_buf_sz
;
967 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].buffer
=
968 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, skb
->data
, streamer_priv
->pkt_buf_sz
,
969 PCI_DMA_FROMDEVICE
));
970 streamer_priv
->rx_ring_skb
[rx_ring_last_received
] = skb
;
971 /* place recycled descriptor back on the adapter */
972 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
973 &streamer_priv
->streamer_rx_ring
[rx_ring_last_received
],
974 sizeof(struct streamer_rx_desc
), PCI_DMA_FROMDEVICE
)),
975 streamer_mmio
+ RXLBDA
);
976 /* pass the received skb up to the protocol */
979 do { /* Walk the buffers */
980 pci_unmap_single(streamer_priv
->pci_dev
, le32_to_cpu(rx_desc
->buffer
), length
, PCI_DMA_FROMDEVICE
),
981 memcpy(skb_put(skb
, length
), (void *)rx_desc
->buffer
, length
); /* copy this fragment */
982 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].status
= 0;
983 streamer_priv
->streamer_rx_ring
[rx_ring_last_received
].framelen_buflen
= streamer_priv
->pkt_buf_sz
;
985 /* give descriptor back to the adapter */
986 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
987 &streamer_priv
->streamer_rx_ring
[rx_ring_last_received
],
988 length
, PCI_DMA_FROMDEVICE
)),
989 streamer_mmio
+ RXLBDA
);
991 if (rx_desc
->status
& 0x80000000)
992 break; /* this descriptor completes the frame */
994 /* else get the next pending descriptor */
995 if (rx_ring_last_received
!= streamer_priv
->rx_ring_last_received
)
997 printk("RX Error rx_ring_last_received not the same %x %x\n",
998 rx_ring_last_received
,
999 streamer_priv
->rx_ring_last_received
);
1001 rx_desc
= &streamer_priv
->streamer_rx_ring
[(streamer_priv
->rx_ring_last_received
+1) & (STREAMER_RX_RING_SIZE
-1)];
1003 length
= rx_desc
->framelen_buflen
& 0xffff; /* buffer length */
1004 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+1) & (STREAMER_RX_RING_SIZE
- 1);
1005 rx_ring_last_received
= streamer_priv
->rx_ring_last_received
;
1008 skb
->protocol
= tr_type_trans(skb
, dev
);
1009 /* send up to the protocol */
1012 dev
->stats
.rx_packets
++;
1013 dev
->stats
.rx_bytes
+= length
;
1014 } /* if skb == null */
1015 } /* end received without errors */
1017 /* try the next one */
1018 rx_desc
= &streamer_priv
->streamer_rx_ring
[(rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1)];
1019 } /* end for all completed rx descriptors */
1022 static irqreturn_t
streamer_interrupt(int irq
, void *dev_id
)
1024 struct net_device
*dev
= (struct net_device
*) dev_id
;
1025 struct streamer_private
*streamer_priv
=
1027 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1030 u8 max_intr
= MAX_INTR
;
1032 spin_lock(&streamer_priv
->streamer_lock
);
1033 sisr
= readw(streamer_mmio
+ SISR
);
1035 while((sisr
& (SISR_MI
| SISR_SRB_REPLY
| SISR_ADAPTER_CHECK
| SISR_ASB_FREE
|
1036 SISR_ARB_CMD
| SISR_TRB_REPLY
| SISR_PAR_ERR
| SISR_SERR_ERR
)) &&
1039 if(sisr
& SISR_PAR_ERR
) {
1040 writew(~SISR_PAR_ERR
, streamer_mmio
+ SISR_RUM
);
1041 (void)readw(streamer_mmio
+ SISR_RUM
);
1044 else if(sisr
& SISR_SERR_ERR
) {
1045 writew(~SISR_SERR_ERR
, streamer_mmio
+ SISR_RUM
);
1046 (void)readw(streamer_mmio
+ SISR_RUM
);
1049 else if(sisr
& SISR_MI
) {
1050 misr
= readw(streamer_mmio
+ MISR_RUM
);
1052 if (misr
& MISR_TX2_EOF
) {
1053 while(streamer_priv
->streamer_tx_ring
[(streamer_priv
->tx_ring_last_status
+ 1) & (STREAMER_TX_RING_SIZE
- 1)].status
) {
1054 streamer_priv
->tx_ring_last_status
= (streamer_priv
->tx_ring_last_status
+ 1) & (STREAMER_TX_RING_SIZE
- 1);
1055 streamer_priv
->free_tx_ring_entries
++;
1056 dev
->stats
.tx_bytes
+= streamer_priv
->tx_ring_skb
[streamer_priv
->tx_ring_last_status
]->len
;
1057 dev
->stats
.tx_packets
++;
1058 dev_kfree_skb_irq(streamer_priv
->tx_ring_skb
[streamer_priv
->tx_ring_last_status
]);
1059 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].buffer
= 0xdeadbeef;
1060 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].status
= 0;
1061 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].bufcnt_framelen
= 0;
1062 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].buflen
= 0;
1063 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].rsvd1
= 0;
1064 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].rsvd2
= 0;
1065 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_last_status
].rsvd3
= 0;
1067 netif_wake_queue(dev
);
1070 if (misr
& MISR_RX_EOF
) {
1075 if (misr
& MISR_RX_NOBUF
) {
1076 /* According to the documentation, we don't have to do anything,
1077 * but trapping it keeps it out of /var/log/messages.
1079 } /* SISR_RX_NOBUF */
1081 writew(~misr
, streamer_mmio
+ MISR_RUM
);
1082 (void)readw(streamer_mmio
+ MISR_RUM
);
1085 else if (sisr
& SISR_SRB_REPLY
) {
1086 if (streamer_priv
->srb_queued
== 1) {
1087 wake_up_interruptible(&streamer_priv
->srb_wait
);
1088 } else if (streamer_priv
->srb_queued
== 2) {
1089 streamer_srb_bh(dev
);
1091 streamer_priv
->srb_queued
= 0;
1093 writew(~SISR_SRB_REPLY
, streamer_mmio
+ SISR_RUM
);
1094 (void)readw(streamer_mmio
+ SISR_RUM
);
1097 else if (sisr
& SISR_ADAPTER_CHECK
) {
1098 printk(KERN_WARNING
"%s: Adapter Check Interrupt Raised, 8 bytes of information follow:\n", dev
->name
);
1099 writel(readl(streamer_mmio
+ LAPWWO
), streamer_mmio
+ LAPA
);
1100 printk(KERN_WARNING
"%s: Words %x:%x:%x:%x:\n",
1101 dev
->name
, readw(streamer_mmio
+ LAPDINC
),
1102 ntohs(readw(streamer_mmio
+ LAPDINC
)),
1103 ntohs(readw(streamer_mmio
+ LAPDINC
)),
1104 ntohs(readw(streamer_mmio
+ LAPDINC
)));
1105 netif_stop_queue(dev
);
1106 netif_carrier_off(dev
);
1107 printk(KERN_WARNING
"%s: Adapter must be manually reset.\n", dev
->name
);
1110 /* SISR_ADAPTER_CHECK */
1111 else if (sisr
& SISR_ASB_FREE
) {
1112 /* Wake up anything that is waiting for the asb response */
1113 if (streamer_priv
->asb_queued
) {
1114 streamer_asb_bh(dev
);
1116 writew(~SISR_ASB_FREE
, streamer_mmio
+ SISR_RUM
);
1117 (void)readw(streamer_mmio
+ SISR_RUM
);
1120 else if (sisr
& SISR_ARB_CMD
) {
1121 streamer_arb_cmd(dev
);
1122 writew(~SISR_ARB_CMD
, streamer_mmio
+ SISR_RUM
);
1123 (void)readw(streamer_mmio
+ SISR_RUM
);
1126 else if (sisr
& SISR_TRB_REPLY
) {
1127 /* Wake up anything that is waiting for the trb response */
1128 if (streamer_priv
->trb_queued
) {
1129 wake_up_interruptible(&streamer_priv
->
1132 streamer_priv
->trb_queued
= 0;
1133 writew(~SISR_TRB_REPLY
, streamer_mmio
+ SISR_RUM
);
1134 (void)readw(streamer_mmio
+ SISR_RUM
);
1136 /* SISR_TRB_REPLY */
1138 sisr
= readw(streamer_mmio
+ SISR
);
1142 spin_unlock(&streamer_priv
->streamer_lock
) ;
1146 static netdev_tx_t
streamer_xmit(struct sk_buff
*skb
,
1147 struct net_device
*dev
)
1149 struct streamer_private
*streamer_priv
=
1151 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1152 unsigned long flags
;
1154 spin_lock_irqsave(&streamer_priv
->streamer_lock
, flags
);
1156 if (streamer_priv
->free_tx_ring_entries
) {
1157 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].status
= 0;
1158 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].bufcnt_framelen
= 0x00020000 | skb
->len
;
1159 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].buffer
=
1160 cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
, skb
->data
, skb
->len
, PCI_DMA_TODEVICE
));
1161 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].rsvd1
= skb
->len
;
1162 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].rsvd2
= 0;
1163 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].rsvd3
= 0;
1164 streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
].buflen
= skb
->len
;
1166 streamer_priv
->tx_ring_skb
[streamer_priv
->tx_ring_free
] = skb
;
1167 streamer_priv
->free_tx_ring_entries
--;
1168 #if STREAMER_DEBUG_PACKETS
1171 printk("streamer_xmit packet print:\n");
1172 for (i
= 0; i
< skb
->len
; i
++) {
1173 printk("%x:", skb
->data
[i
]);
1174 if (((i
+ 1) % 16) == 0)
1181 writel(cpu_to_le32(pci_map_single(streamer_priv
->pci_dev
,
1182 &streamer_priv
->streamer_tx_ring
[streamer_priv
->tx_ring_free
],
1183 sizeof(struct streamer_tx_desc
), PCI_DMA_TODEVICE
)),
1184 streamer_mmio
+ TX2LFDA
);
1185 (void)readl(streamer_mmio
+ TX2LFDA
);
1187 streamer_priv
->tx_ring_free
= (streamer_priv
->tx_ring_free
+ 1) & (STREAMER_TX_RING_SIZE
- 1);
1188 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
,flags
);
1189 return NETDEV_TX_OK
;
1191 netif_stop_queue(dev
);
1192 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
,flags
);
1193 return NETDEV_TX_BUSY
;
1198 static int streamer_close(struct net_device
*dev
)
1200 struct streamer_private
*streamer_priv
=
1202 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1203 unsigned long flags
;
1206 netif_stop_queue(dev
);
1207 netif_carrier_off(dev
);
1208 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1209 writew(htons(SRB_CLOSE_ADAPTER
<< 8),streamer_mmio
+LAPDINC
);
1210 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1212 spin_lock_irqsave(&streamer_priv
->streamer_lock
, flags
);
1214 streamer_priv
->srb_queued
= 1;
1215 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1217 spin_unlock_irqrestore(&streamer_priv
->streamer_lock
, flags
);
1219 while (streamer_priv
->srb_queued
)
1221 interruptible_sleep_on_timeout(&streamer_priv
->srb_wait
,
1223 if (signal_pending(current
))
1225 printk(KERN_WARNING
"%s: SRB timed out.\n", dev
->name
);
1226 printk(KERN_WARNING
"SISR=%x MISR=%x LISR=%x\n",
1227 readw(streamer_mmio
+ SISR
),
1228 readw(streamer_mmio
+ MISR_RUM
),
1229 readw(streamer_mmio
+ LISR
));
1230 streamer_priv
->srb_queued
= 0;
1235 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1);
1237 for (i
= 0; i
< STREAMER_RX_RING_SIZE
; i
++) {
1238 if (streamer_priv
->rx_ring_skb
[streamer_priv
->rx_ring_last_received
]) {
1239 dev_kfree_skb(streamer_priv
->rx_ring_skb
[streamer_priv
->rx_ring_last_received
]);
1241 streamer_priv
->rx_ring_last_received
= (streamer_priv
->rx_ring_last_received
+ 1) & (STREAMER_RX_RING_SIZE
- 1);
1244 /* reset tx/rx fifo's and busmaster logic */
1246 /* TBD. Add graceful way to reset the LLC channel without doing a soft reset.
1247 writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
1249 writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL);
1253 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1255 for (i
= 0; i
< 2; i
++) {
1256 printk("%x ", ntohs(readw(streamer_mmio
+ LAPDINC
)));
1260 free_irq(dev
->irq
, dev
);
1264 static void streamer_set_rx_mode(struct net_device
*dev
)
1266 struct streamer_private
*streamer_priv
=
1268 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1270 struct netdev_hw_addr
*ha
;
1271 unsigned char dev_mc_address
[5];
1273 writel(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1274 options
= streamer_priv
->streamer_copy_all_options
;
1276 if (dev
->flags
& IFF_PROMISC
)
1277 options
|= (3 << 5); /* All LLC and MAC frames, all through the main rx channel */
1279 options
&= ~(3 << 5);
1281 /* Only issue the srb if there is a change in options */
1283 if ((options
^ streamer_priv
->streamer_copy_all_options
))
1285 /* Now to issue the srb command to alter the copy.all.options */
1286 writew(htons(SRB_MODIFY_RECEIVE_OPTIONS
<< 8), streamer_mmio
+LAPDINC
);
1287 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1288 writew(htons((streamer_priv
->streamer_receive_options
<< 8) | options
),streamer_mmio
+LAPDINC
);
1289 writew(htons(0x4a41),streamer_mmio
+LAPDINC
);
1290 writew(htons(0x4d45),streamer_mmio
+LAPDINC
);
1291 writew(htons(0x5320),streamer_mmio
+LAPDINC
);
1292 writew(0x2020, streamer_mmio
+ LAPDINC
);
1294 streamer_priv
->srb_queued
= 2; /* Can't sleep, use srb_bh */
1296 writel(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1298 streamer_priv
->streamer_copy_all_options
= options
;
1302 /* Set the functional addresses we need for multicast */
1303 writel(streamer_priv
->srb
,streamer_mmio
+LAPA
);
1304 dev_mc_address
[0] = dev_mc_address
[1] = dev_mc_address
[2] = dev_mc_address
[3] = 0 ;
1306 netdev_for_each_mc_addr(ha
, dev
) {
1307 dev_mc_address
[0] |= ha
->addr
[2];
1308 dev_mc_address
[1] |= ha
->addr
[3];
1309 dev_mc_address
[2] |= ha
->addr
[4];
1310 dev_mc_address
[3] |= ha
->addr
[5];
1313 writew(htons(SRB_SET_FUNC_ADDRESS
<< 8),streamer_mmio
+LAPDINC
);
1314 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1315 writew(0,streamer_mmio
+LAPDINC
);
1316 writew(htons( (dev_mc_address
[0] << 8) | dev_mc_address
[1]),streamer_mmio
+LAPDINC
);
1317 writew(htons( (dev_mc_address
[2] << 8) | dev_mc_address
[3]),streamer_mmio
+LAPDINC
);
1318 streamer_priv
->srb_queued
= 2 ;
1319 writel(LISR_SRB_CMD
,streamer_mmio
+LISR_SUM
);
1322 static void streamer_srb_bh(struct net_device
*dev
)
1324 struct streamer_private
*streamer_priv
= netdev_priv(dev
);
1325 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1328 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1329 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1333 /* SRB_MODIFY_RECEIVE_OPTIONS i.e. set_multicast_list options (promiscuous)
1334 * At some point we should do something if we get an error, such as
1335 * resetting the IFF_PROMISC flag in dev
1338 case SRB_MODIFY_RECEIVE_OPTIONS
:
1339 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1343 printk(KERN_WARNING
"%s: Unrecognized srb command\n", dev
->name
);
1346 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1349 if (streamer_priv
->streamer_message_level
)
1350 printk(KERN_WARNING
"%s: Receive Options Modified to %x,%x\n",
1352 streamer_priv
->streamer_copy_all_options
,
1353 streamer_priv
->streamer_receive_options
);
1355 } /* switch srb[2] */
1359 /* SRB_SET_GROUP_ADDRESS - Multicast group setting
1361 case SRB_SET_GROUP_ADDRESS
:
1362 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1367 printk(KERN_WARNING
"%s: Unrecognized srb command\n",dev
->name
);
1370 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1373 printk(KERN_WARNING
"%s: Group/Functional address indicator bits not set correctly\n", dev
->name
);
1375 case 0x3e: /* If we ever implement individual multicast addresses, will need to deal with this */
1376 printk(KERN_WARNING
"%s: Group address registers full\n", dev
->name
);
1379 printk(KERN_INFO
"%s: Group Address already set.\n", dev
->name
);
1383 } /* switch srb[2] */
1387 /* SRB_RESET_GROUP_ADDRESS - Remove a multicast address from group list
1389 case SRB_RESET_GROUP_ADDRESS
:
1390 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1395 printk(KERN_WARNING
"%s: Unrecognized srb command\n", dev
->name
);
1398 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1400 case 0x39: /* Must deal with this if individual multicast addresses used */
1401 printk(KERN_INFO
"%s: Group address not found\n", dev
->name
);
1405 } /* switch srb[2] */
1409 /* SRB_SET_FUNC_ADDRESS - Called by the set_rx_mode
1412 case SRB_SET_FUNC_ADDRESS
:
1413 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1416 if (streamer_priv
->streamer_message_level
)
1417 printk(KERN_INFO
"%s: Functional Address Mask Set\n", dev
->name
);
1420 printk(KERN_WARNING
"%s: Unrecognized srb command\n", dev
->name
);
1423 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1427 } /* switch srb[2] */
1430 /* SRB_READ_LOG - Read and reset the adapter error counters
1434 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1439 if (streamer_priv
->streamer_message_level
)
1440 printk(KERN_INFO
"%s: Read Log command complete\n", dev
->name
);
1441 printk("Read Log statistics: ");
1442 writew(streamer_priv
->srb
+ 6,
1443 streamer_mmio
+ LAPA
);
1444 for (i
= 0; i
< 5; i
++) {
1445 printk("%x:", ntohs(readw(streamer_mmio
+ LAPDINC
)));
1451 printk(KERN_WARNING
"%s: Unrecognized srb command\n", dev
->name
);
1454 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1457 } /* switch srb[2] */
1460 /* SRB_READ_SR_COUNTERS - Read and reset the source routing bridge related counters */
1462 case SRB_READ_SR_COUNTERS
:
1463 srb_word
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8;
1466 if (streamer_priv
->streamer_message_level
)
1467 printk(KERN_INFO
"%s: Read Source Routing Counters issued\n", dev
->name
);
1470 printk(KERN_WARNING
"%s: Unrecognized srb command\n", dev
->name
);
1473 printk(KERN_WARNING
"%s: Adapter must be open for this operation, doh!!\n", dev
->name
);
1477 } /* switch srb[2] */
1481 printk(KERN_WARNING
"%s: Unrecognized srb bh return value.\n", dev
->name
);
1483 } /* switch srb[0] */
1486 static int streamer_set_mac_address(struct net_device
*dev
, void *addr
)
1488 struct sockaddr
*saddr
= addr
;
1489 struct streamer_private
*streamer_priv
= netdev_priv(dev
);
1491 if (netif_running(dev
))
1493 printk(KERN_WARNING
"%s: Cannot set mac/laa address while card is open\n", dev
->name
);
1497 memcpy(streamer_priv
->streamer_laa
, saddr
->sa_data
, dev
->addr_len
);
1499 if (streamer_priv
->streamer_message_level
) {
1500 printk(KERN_INFO
"%s: MAC/LAA Set to = %x.%x.%x.%x.%x.%x\n",
1501 dev
->name
, streamer_priv
->streamer_laa
[0],
1502 streamer_priv
->streamer_laa
[1],
1503 streamer_priv
->streamer_laa
[2],
1504 streamer_priv
->streamer_laa
[3],
1505 streamer_priv
->streamer_laa
[4],
1506 streamer_priv
->streamer_laa
[5]);
1511 static void streamer_arb_cmd(struct net_device
*dev
)
1513 struct streamer_private
*streamer_priv
=
1515 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1517 __u16 frame_len
, buffer_len
;
1518 struct sk_buff
*mac_frame
;
1519 __u8 frame_data
[256];
1521 __u16 lan_status
= 0, lan_status_diff
; /* Initialize to stop compiler warning */
1522 __u8 fdx_prot_error
;
1526 #if STREAMER_NETWORK_MONITOR
1527 struct trh_hdr
*mac_hdr
;
1530 writew(streamer_priv
->arb
, streamer_mmio
+ LAPA
);
1531 arb_word
=ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
1533 if (arb_word
== ARB_RECEIVE_DATA
) { /* Receive.data, MAC frames */
1534 writew(streamer_priv
->arb
+ 6, streamer_mmio
+ LAPA
);
1535 streamer_priv
->mac_rx_buffer
= buff_off
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1536 header_len
=ntohs(readw(streamer_mmio
+LAPDINC
)) >> 8; /* 802.5 Token-Ring Header Length */
1537 frame_len
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1546 writew(ntohs(buff_off
), streamer_mmio
+ LAPA
); /*setup window to frame data */
1547 next
= htons(readw(streamer_mmio
+ LAPDINC
));
1549 ntohs(readw(streamer_mmio
+ LAPDINC
)) & 0xff;
1550 len
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1552 /* print out 1st 14 bytes of frame data */
1553 for (i
= 0; i
< 7; i
++) {
1554 printk("Loc %d = %04x\n", i
,
1556 (streamer_mmio
+ LAPDINC
)));
1559 printk("next %04x, fs %02x, len %04x\n", next
,
1563 if (!(mac_frame
= dev_alloc_skb(frame_len
))) {
1564 printk(KERN_WARNING
"%s: Memory squeeze, dropping frame.\n",
1568 /* Walk the buffer chain, creating the frame */
1574 writew(htons(buff_off
), streamer_mmio
+ LAPA
); /* setup window to frame data */
1575 next_ptr
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1576 readw(streamer_mmio
+ LAPDINC
); /* read thru status word */
1577 buffer_len
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1579 if (buffer_len
> 256)
1583 while (i
< buffer_len
) {
1584 rx_word
=ntohs(readw(streamer_mmio
+LAPDINC
));
1585 frame_data
[i
]=rx_word
>> 8;
1586 frame_data
[i
+1]=rx_word
& 0xff;
1590 memcpy(skb_put(mac_frame
, buffer_len
),
1591 frame_data
, buffer_len
);
1592 } while (next_ptr
&& (buff_off
= next_ptr
));
1594 mac_frame
->protocol
= tr_type_trans(mac_frame
, dev
);
1595 #if STREAMER_NETWORK_MONITOR
1596 printk(KERN_WARNING
"%s: Received MAC Frame, details:\n",
1598 mac_hdr
= tr_hdr(mac_frame
);
1600 "%s: MAC Frame Dest. Addr: %pM\n",
1601 dev
->name
, mac_hdr
->daddr
);
1603 "%s: MAC Frame Srce. Addr: %pM\n",
1604 dev
->name
, mac_hdr
->saddr
);
1606 netif_rx(mac_frame
);
1608 /* Now tell the card we have dealt with the received frame */
1610 /* Set LISR Bit 1 */
1611 writel(LISR_ARB_FREE
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1613 /* Is the ASB free ? */
1615 if (!(readl(streamer_priv
->streamer_mmio
+ SISR
) & SISR_ASB_FREE
))
1617 streamer_priv
->asb_queued
= 1;
1618 writel(LISR_ASB_FREE_REQ
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1620 /* Drop out and wait for the bottom half to be run */
1624 writew(streamer_priv
->asb
, streamer_mmio
+ LAPA
);
1625 writew(htons(ASB_RECEIVE_DATA
<< 8), streamer_mmio
+LAPDINC
);
1626 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1627 writew(0, streamer_mmio
+ LAPDINC
);
1628 writew(htons(streamer_priv
->mac_rx_buffer
), streamer_mmio
+ LAPD
);
1630 writel(LISR_ASB_REPLY
| LISR_ASB_FREE_REQ
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1632 streamer_priv
->asb_queued
= 2;
1635 } else if (arb_word
== ARB_LAN_CHANGE_STATUS
) { /* Lan.change.status */
1636 writew(streamer_priv
->arb
+ 6, streamer_mmio
+ LAPA
);
1637 lan_status
= ntohs(readw(streamer_mmio
+ LAPDINC
));
1638 fdx_prot_error
= ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
1640 /* Issue ARB Free */
1641 writew(LISR_ARB_FREE
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1643 lan_status_diff
= (streamer_priv
->streamer_lan_status
^ lan_status
) &
1646 if (lan_status_diff
& (LSC_LWF
| LSC_ARW
| LSC_FPE
| LSC_RR
))
1648 if (lan_status_diff
& LSC_LWF
)
1649 printk(KERN_WARNING
"%s: Short circuit detected on the lobe\n", dev
->name
);
1650 if (lan_status_diff
& LSC_ARW
)
1651 printk(KERN_WARNING
"%s: Auto removal error\n", dev
->name
);
1652 if (lan_status_diff
& LSC_FPE
)
1653 printk(KERN_WARNING
"%s: FDX Protocol Error\n", dev
->name
);
1654 if (lan_status_diff
& LSC_RR
)
1655 printk(KERN_WARNING
"%s: Force remove MAC frame received\n", dev
->name
);
1657 /* Adapter has been closed by the hardware */
1659 /* reset tx/rx fifo's and busmaster logic */
1661 /* @TBD. no llc reset on autostreamer writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
1663 writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL); */
1665 netif_stop_queue(dev
);
1666 netif_carrier_off(dev
);
1667 printk(KERN_WARNING
"%s: Adapter must be manually reset.\n", dev
->name
);
1669 /* If serious error */
1670 if (streamer_priv
->streamer_message_level
) {
1671 if (lan_status_diff
& LSC_SIG_LOSS
)
1672 printk(KERN_WARNING
"%s: No receive signal detected\n", dev
->name
);
1673 if (lan_status_diff
& LSC_HARD_ERR
)
1674 printk(KERN_INFO
"%s: Beaconing\n", dev
->name
);
1675 if (lan_status_diff
& LSC_SOFT_ERR
)
1676 printk(KERN_WARNING
"%s: Adapter transmitted Soft Error Report Mac Frame\n", dev
->name
);
1677 if (lan_status_diff
& LSC_TRAN_BCN
)
1678 printk(KERN_INFO
"%s: We are transmitting the beacon, aaah\n", dev
->name
);
1679 if (lan_status_diff
& LSC_SS
)
1680 printk(KERN_INFO
"%s: Single Station on the ring\n", dev
->name
);
1681 if (lan_status_diff
& LSC_RING_REC
)
1682 printk(KERN_INFO
"%s: Ring recovery ongoing\n", dev
->name
);
1683 if (lan_status_diff
& LSC_FDX_MODE
)
1684 printk(KERN_INFO
"%s: Operating in FDX mode\n", dev
->name
);
1687 if (lan_status_diff
& LSC_CO
) {
1688 if (streamer_priv
->streamer_message_level
)
1689 printk(KERN_INFO
"%s: Counter Overflow\n", dev
->name
);
1691 /* Issue READ.LOG command */
1693 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1694 writew(htons(SRB_READ_LOG
<< 8),streamer_mmio
+LAPDINC
);
1695 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1696 writew(0, streamer_mmio
+ LAPDINC
);
1697 streamer_priv
->srb_queued
= 2; /* Can't sleep, use srb_bh */
1699 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1702 if (lan_status_diff
& LSC_SR_CO
) {
1703 if (streamer_priv
->streamer_message_level
)
1704 printk(KERN_INFO
"%s: Source routing counters overflow\n", dev
->name
);
1706 /* Issue a READ.SR.COUNTERS */
1707 writew(streamer_priv
->srb
, streamer_mmio
+ LAPA
);
1708 writew(htons(SRB_READ_SR_COUNTERS
<< 8),
1709 streamer_mmio
+LAPDINC
);
1710 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8),
1711 streamer_mmio
+LAPDINC
);
1712 streamer_priv
->srb_queued
= 2; /* Can't sleep, use srb_bh */
1713 writew(LISR_SRB_CMD
, streamer_mmio
+ LISR_SUM
);
1716 streamer_priv
->streamer_lan_status
= lan_status
;
1717 } /* Lan.change.status */
1719 printk(KERN_WARNING
"%s: Unknown arb command\n", dev
->name
);
1722 static void streamer_asb_bh(struct net_device
*dev
)
1724 struct streamer_private
*streamer_priv
=
1726 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1728 if (streamer_priv
->asb_queued
== 1)
1730 /* Dropped through the first time */
1732 writew(streamer_priv
->asb
, streamer_mmio
+ LAPA
);
1733 writew(htons(ASB_RECEIVE_DATA
<< 8),streamer_mmio
+LAPDINC
);
1734 writew(htons(STREAMER_CLEAR_RET_CODE
<< 8), streamer_mmio
+LAPDINC
);
1735 writew(0, streamer_mmio
+ LAPDINC
);
1736 writew(htons(streamer_priv
->mac_rx_buffer
), streamer_mmio
+ LAPD
);
1738 writel(LISR_ASB_REPLY
| LISR_ASB_FREE_REQ
, streamer_priv
->streamer_mmio
+ LISR_SUM
);
1739 streamer_priv
->asb_queued
= 2;
1744 if (streamer_priv
->asb_queued
== 2) {
1746 writew(streamer_priv
->asb
+ 2, streamer_mmio
+ LAPA
);
1747 rc
=ntohs(readw(streamer_mmio
+LAPD
)) >> 8;
1750 printk(KERN_WARNING
"%s: Unrecognized command code\n", dev
->name
);
1753 printk(KERN_WARNING
"%s: Unrecognized buffer address\n", dev
->name
);
1756 /* Valid response, everything should be ok again */
1759 printk(KERN_WARNING
"%s: Invalid return code in asb\n", dev
->name
);
1763 streamer_priv
->asb_queued
= 0;
1766 static int streamer_change_mtu(struct net_device
*dev
, int mtu
)
1768 struct streamer_private
*streamer_priv
=
1772 if (streamer_priv
->streamer_ring_speed
== 4)
1783 streamer_priv
->pkt_buf_sz
= mtu
+ TR_HLEN
;
1788 #if STREAMER_NETWORK_MONITOR
1789 #ifdef CONFIG_PROC_FS
1790 static int streamer_proc_info(char *buffer
, char **start
, off_t offset
,
1791 int length
, int *eof
, void *data
)
1793 struct streamer_private
*sdev
=NULL
;
1794 struct pci_dev
*pci_device
= NULL
;
1800 struct net_device
*dev
;
1802 size
= sprintf(buffer
, "IBM LanStreamer/MPC Chipset Token Ring Adapters\n");
1807 for(sdev
=dev_streamer
; sdev
; sdev
=sdev
->next
) {
1808 pci_device
=sdev
->pci_dev
;
1809 dev
=pci_get_drvdata(pci_device
);
1811 size
= sprintf_info(buffer
+ len
, dev
);
1819 if (pos
> offset
+ length
)
1823 *start
= buffer
+ (offset
- begin
); /* Start of wanted data */
1824 len
-= (offset
- begin
); /* Start slop */
1826 len
= length
; /* Ending slop */
1830 static int sprintf_info(char *buffer
, struct net_device
*dev
)
1832 struct streamer_private
*streamer_priv
=
1834 __u8 __iomem
*streamer_mmio
= streamer_priv
->streamer_mmio
;
1835 struct streamer_adapter_addr_table sat
;
1836 struct streamer_parameters_table spt
;
1840 writew(streamer_priv
->streamer_addr_table_addr
, streamer_mmio
+ LAPA
);
1841 for (i
= 0; i
< 14; i
+= 2) {
1843 __u8
*datap
= (__u8
*) & sat
;
1844 io_word
=ntohs(readw(streamer_mmio
+LAPDINC
));
1845 datap
[size
]=io_word
>> 8;
1846 datap
[size
+1]=io_word
& 0xff;
1848 writew(streamer_priv
->streamer_parms_addr
, streamer_mmio
+ LAPA
);
1849 for (i
= 0; i
< 68; i
+= 2) {
1851 __u8
*datap
= (__u8
*) & spt
;
1852 io_word
=ntohs(readw(streamer_mmio
+LAPDINC
));
1853 datap
[size
]=io_word
>> 8;
1854 datap
[size
+1]=io_word
& 0xff;
1857 size
= sprintf(buffer
, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev
->name
);
1859 size
+= sprintf(buffer
+ size
,
1860 "%6s: %pM : %pM : %02x:%02x:%02x:%02x\n",
1861 dev
->name
, dev
->dev_addr
, sat
.node_addr
,
1862 sat
.func_addr
[0], sat
.func_addr
[1],
1863 sat
.func_addr
[2], sat
.func_addr
[3]);
1865 size
+= sprintf(buffer
+ size
, "\n%6s: Token Ring Parameters Table:\n", dev
->name
);
1867 size
+= sprintf(buffer
+ size
, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", dev
->name
);
1869 size
+= sprintf(buffer
+ size
,
1870 "%6s: %02x:%02x:%02x:%02x : %pM : %pM : %04x : %04x : %04x :\n",
1871 dev
->name
, spt
.phys_addr
[0], spt
.phys_addr
[1],
1872 spt
.phys_addr
[2], spt
.phys_addr
[3],
1873 spt
.up_node_addr
, spt
.poll_addr
,
1874 ntohs(spt
.acc_priority
), ntohs(spt
.auth_source_class
),
1875 ntohs(spt
.att_code
));
1877 size
+= sprintf(buffer
+ size
, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", dev
->name
);
1879 size
+= sprintf(buffer
+ size
,
1880 "%6s: %pM : %04x : %04x : %04x : %04x : %04x : %04x : \n",
1881 dev
->name
, spt
.source_addr
,
1882 ntohs(spt
.beacon_type
), ntohs(spt
.major_vector
),
1883 ntohs(spt
.lan_status
), ntohs(spt
.local_ring
),
1884 ntohs(spt
.mon_error
), ntohs(spt
.frame_correl
));
1886 size
+= sprintf(buffer
+ size
, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n",
1889 size
+= sprintf(buffer
+ size
,
1890 "%6s: : %02x : %02x : %pM : %02x:%02x:%02x:%02x : \n",
1891 dev
->name
, ntohs(spt
.beacon_transmit
),
1892 ntohs(spt
.beacon_receive
),
1894 spt
.beacon_phys
[0], spt
.beacon_phys
[1],
1895 spt
.beacon_phys
[2], spt
.beacon_phys
[3]);
1901 static struct pci_driver streamer_pci_driver
= {
1902 .name
= "lanstreamer",
1903 .id_table
= streamer_pci_tbl
,
1904 .probe
= streamer_init_one
,
1905 .remove
= __devexit_p(streamer_remove_one
),
1908 static int __init
streamer_init_module(void) {
1909 return pci_register_driver(&streamer_pci_driver
);
1912 static void __exit
streamer_cleanup_module(void) {
1913 pci_unregister_driver(&streamer_pci_driver
);
1916 module_init(streamer_init_module
);
1917 module_exit(streamer_cleanup_module
);
1918 MODULE_LICENSE("GPL");