aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tulip/xircom_cb.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-05-26 21:39:03 -0400
committerJeff Garzik <jeff@garzik.org>2006-05-26 21:39:03 -0400
commitf3b197ac26ed0e57989856494c495818dcc7f9ac (patch)
tree5451adb0bc6c219d0a794ea32e3c598740c82bdf /drivers/net/tulip/xircom_cb.c
parent4c0c2fd486b6598e37c77b5d81a08bc2d948aa7b (diff)
[netdrvr] trim trailing whitespace: 8139*.c, epic100, forcedeth, tulip/*
Diffstat (limited to 'drivers/net/tulip/xircom_cb.c')
-rw-r--r--drivers/net/tulip/xircom_cb.c208
1 files changed, 104 insertions, 104 deletions
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 56344103ac23..63c2175ed138 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * xircom_cb: A driver for the (tulip-like) Xircom Cardbus ethernet cards 2 * xircom_cb: A driver for the (tulip-like) Xircom Cardbus ethernet cards
3 * 3 *
4 * This software is (C) by the respective authors, and licensed under the GPL 4 * This software is (C) by the respective authors, and licensed under the GPL
5 * License. 5 * License.
6 * 6 *
7 * Written by Arjan van de Ven for Red Hat, Inc. 7 * Written by Arjan van de Ven for Red Hat, Inc.
8 * Based on work by Jeff Garzik, Doug Ledford and Donald Becker 8 * Based on work by Jeff Garzik, Doug Ledford and Donald Becker
9 * 9 *
10 * This software may be used and distributed according to the terms 10 * This software may be used and distributed according to the terms
11 * of the GNU General Public License, incorporated herein by reference. 11 * of the GNU General Public License, incorporated herein by reference.
@@ -93,7 +93,7 @@ struct xircom_private {
93 93
94 unsigned long io_port; 94 unsigned long io_port;
95 int open; 95 int open;
96 96
97 /* transmit_used is the rotating counter that indicates which transmit 97 /* transmit_used is the rotating counter that indicates which transmit
98 descriptor has to be used next */ 98 descriptor has to be used next */
99 int transmit_used; 99 int transmit_used;
@@ -153,10 +153,10 @@ static struct pci_device_id xircom_pci_table[] = {
153MODULE_DEVICE_TABLE(pci, xircom_pci_table); 153MODULE_DEVICE_TABLE(pci, xircom_pci_table);
154 154
155static struct pci_driver xircom_ops = { 155static struct pci_driver xircom_ops = {
156 .name = "xircom_cb", 156 .name = "xircom_cb",
157 .id_table = xircom_pci_table, 157 .id_table = xircom_pci_table,
158 .probe = xircom_probe, 158 .probe = xircom_probe,
159 .remove = xircom_remove, 159 .remove = xircom_remove,
160 .suspend =NULL, 160 .suspend =NULL,
161 .resume =NULL 161 .resume =NULL
162}; 162};
@@ -174,7 +174,7 @@ static void print_binary(unsigned int number)
174 buffer[i2++]='1'; 174 buffer[i2++]='1';
175 else 175 else
176 buffer[i2++]='0'; 176 buffer[i2++]='0';
177 if ((i&3)==0) 177 if ((i&3)==0)
178 buffer[i2++]=' '; 178 buffer[i2++]=' ';
179 } 179 }
180 printk("%s\n",buffer); 180 printk("%s\n",buffer);
@@ -196,10 +196,10 @@ static struct ethtool_ops netdev_ethtool_ops = {
196 196
197/* xircom_probe is the code that gets called on device insertion. 197/* xircom_probe is the code that gets called on device insertion.
198 it sets up the hardware and registers the device to the networklayer. 198 it sets up the hardware and registers the device to the networklayer.
199 199
200 TODO: Send 1 or 2 "dummy" packets here as the card seems to discard the 200 TODO: Send 1 or 2 "dummy" packets here as the card seems to discard the
201 first two packets that get send, and pump hates that. 201 first two packets that get send, and pump hates that.
202 202
203 */ 203 */
204static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_id *id) 204static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_id *id)
205{ 205{
@@ -209,7 +209,7 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
209 unsigned long flags; 209 unsigned long flags;
210 unsigned short tmp16; 210 unsigned short tmp16;
211 enter("xircom_probe"); 211 enter("xircom_probe");
212 212
213 /* First do the PCI initialisation */ 213 /* First do the PCI initialisation */
214 214
215 if (pci_enable_device(pdev)) 215 if (pci_enable_device(pdev))
@@ -217,24 +217,24 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
217 217
218 /* disable all powermanagement */ 218 /* disable all powermanagement */
219 pci_write_config_dword(pdev, PCI_POWERMGMT, 0x0000); 219 pci_write_config_dword(pdev, PCI_POWERMGMT, 0x0000);
220 220
221 pci_set_master(pdev); /* Why isn't this done by pci_enable_device ?*/ 221 pci_set_master(pdev); /* Why isn't this done by pci_enable_device ?*/
222 222
223 /* clear PCI status, if any */ 223 /* clear PCI status, if any */
224 pci_read_config_word (pdev,PCI_STATUS, &tmp16); 224 pci_read_config_word (pdev,PCI_STATUS, &tmp16);
225 pci_write_config_word (pdev, PCI_STATUS,tmp16); 225 pci_write_config_word (pdev, PCI_STATUS,tmp16);
226 226
227 pci_read_config_byte(pdev, PCI_REVISION_ID, &chip_rev); 227 pci_read_config_byte(pdev, PCI_REVISION_ID, &chip_rev);
228 228
229 if (!request_region(pci_resource_start(pdev, 0), 128, "xircom_cb")) { 229 if (!request_region(pci_resource_start(pdev, 0), 128, "xircom_cb")) {
230 printk(KERN_ERR "xircom_probe: failed to allocate io-region\n"); 230 printk(KERN_ERR "xircom_probe: failed to allocate io-region\n");
231 return -ENODEV; 231 return -ENODEV;
232 } 232 }
233 233
234 /* 234 /*
235 Before changing the hardware, allocate the memory. 235 Before changing the hardware, allocate the memory.
236 This way, we can fail gracefully if not enough memory 236 This way, we can fail gracefully if not enough memory
237 is available. 237 is available.
238 */ 238 */
239 dev = alloc_etherdev(sizeof(struct xircom_private)); 239 dev = alloc_etherdev(sizeof(struct xircom_private));
240 if (!dev) { 240 if (!dev) {
@@ -242,13 +242,13 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
242 goto device_fail; 242 goto device_fail;
243 } 243 }
244 private = netdev_priv(dev); 244 private = netdev_priv(dev);
245 245
246 /* Allocate the send/receive buffers */ 246 /* Allocate the send/receive buffers */
247 private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle); 247 private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle);
248 if (private->rx_buffer == NULL) { 248 if (private->rx_buffer == NULL) {
249 printk(KERN_ERR "xircom_probe: no memory for rx buffer \n"); 249 printk(KERN_ERR "xircom_probe: no memory for rx buffer \n");
250 goto rx_buf_fail; 250 goto rx_buf_fail;
251 } 251 }
252 private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle); 252 private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle);
253 if (private->tx_buffer == NULL) { 253 if (private->tx_buffer == NULL) {
254 printk(KERN_ERR "xircom_probe: no memory for tx buffer \n"); 254 printk(KERN_ERR "xircom_probe: no memory for tx buffer \n");
@@ -265,11 +265,11 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
265 spin_lock_init(&private->lock); 265 spin_lock_init(&private->lock);
266 dev->irq = pdev->irq; 266 dev->irq = pdev->irq;
267 dev->base_addr = private->io_port; 267 dev->base_addr = private->io_port;
268 268
269 initialize_card(private); 269 initialize_card(private);
270 read_mac_address(private); 270 read_mac_address(private);
271 setup_descriptors(private); 271 setup_descriptors(private);
272 272
273 dev->open = &xircom_open; 273 dev->open = &xircom_open;
274 dev->hard_start_xmit = &xircom_start_xmit; 274 dev->hard_start_xmit = &xircom_start_xmit;
275 dev->stop = &xircom_close; 275 dev->stop = &xircom_close;
@@ -285,19 +285,19 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
285 printk(KERN_ERR "xircom_probe: netdevice registration failed.\n"); 285 printk(KERN_ERR "xircom_probe: netdevice registration failed.\n");
286 goto reg_fail; 286 goto reg_fail;
287 } 287 }
288 288
289 printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq); 289 printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq);
290 /* start the transmitter to get a heartbeat */ 290 /* start the transmitter to get a heartbeat */
291 /* TODO: send 2 dummy packets here */ 291 /* TODO: send 2 dummy packets here */
292 transceiver_voodoo(private); 292 transceiver_voodoo(private);
293 293
294 spin_lock_irqsave(&private->lock,flags); 294 spin_lock_irqsave(&private->lock,flags);
295 activate_transmitter(private); 295 activate_transmitter(private);
296 activate_receiver(private); 296 activate_receiver(private);
297 spin_unlock_irqrestore(&private->lock,flags); 297 spin_unlock_irqrestore(&private->lock,flags);
298 298
299 trigger_receive(private); 299 trigger_receive(private);
300 300
301 leave("xircom_probe"); 301 leave("xircom_probe");
302 return 0; 302 return 0;
303 303
@@ -332,7 +332,7 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
332 free_netdev(dev); 332 free_netdev(dev);
333 pci_set_drvdata(pdev, NULL); 333 pci_set_drvdata(pdev, NULL);
334 leave("xircom_remove"); 334 leave("xircom_remove");
335} 335}
336 336
337static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 337static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
338{ 338{
@@ -346,11 +346,11 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs
346 spin_lock(&card->lock); 346 spin_lock(&card->lock);
347 status = inl(card->io_port+CSR5); 347 status = inl(card->io_port+CSR5);
348 348
349#ifdef DEBUG 349#ifdef DEBUG
350 print_binary(status); 350 print_binary(status);
351 printk("tx status 0x%08x 0x%08x \n",card->tx_buffer[0],card->tx_buffer[4]); 351 printk("tx status 0x%08x 0x%08x \n",card->tx_buffer[0],card->tx_buffer[4]);
352 printk("rx status 0x%08x 0x%08x \n",card->rx_buffer[0],card->rx_buffer[4]); 352 printk("rx status 0x%08x 0x%08x \n",card->rx_buffer[0],card->rx_buffer[4]);
353#endif 353#endif
354 /* Handle shared irq and hotplug */ 354 /* Handle shared irq and hotplug */
355 if (status == 0 || status == 0xffffffff) { 355 if (status == 0 || status == 0xffffffff) {
356 spin_unlock(&card->lock); 356 spin_unlock(&card->lock);
@@ -366,21 +366,21 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs
366 netif_carrier_on(dev); 366 netif_carrier_on(dev);
367 else 367 else
368 netif_carrier_off(dev); 368 netif_carrier_off(dev);
369 369
370 } 370 }
371 371
372 /* Clear all remaining interrupts */ 372 /* Clear all remaining interrupts */
373 status |= 0xffffffff; /* FIXME: make this clear only the 373 status |= 0xffffffff; /* FIXME: make this clear only the
374 real existing bits */ 374 real existing bits */
375 outl(status,card->io_port+CSR5); 375 outl(status,card->io_port+CSR5);
376
377 376
378 for (i=0;i<NUMDESCRIPTORS;i++) 377
378 for (i=0;i<NUMDESCRIPTORS;i++)
379 investigate_write_descriptor(dev,card,i,bufferoffsets[i]); 379 investigate_write_descriptor(dev,card,i,bufferoffsets[i]);
380 for (i=0;i<NUMDESCRIPTORS;i++) 380 for (i=0;i<NUMDESCRIPTORS;i++)
381 investigate_read_descriptor(dev,card,i,bufferoffsets[i]); 381 investigate_read_descriptor(dev,card,i,bufferoffsets[i]);
382 382
383 383
384 spin_unlock(&card->lock); 384 spin_unlock(&card->lock);
385 leave("xircom_interrupt"); 385 leave("xircom_interrupt");
386 return IRQ_HANDLED; 386 return IRQ_HANDLED;
@@ -393,38 +393,38 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
393 int nextdescriptor; 393 int nextdescriptor;
394 int desc; 394 int desc;
395 enter("xircom_start_xmit"); 395 enter("xircom_start_xmit");
396 396
397 card = netdev_priv(dev); 397 card = netdev_priv(dev);
398 spin_lock_irqsave(&card->lock,flags); 398 spin_lock_irqsave(&card->lock,flags);
399 399
400 /* First see if we can free some descriptors */ 400 /* First see if we can free some descriptors */
401 for (desc=0;desc<NUMDESCRIPTORS;desc++) 401 for (desc=0;desc<NUMDESCRIPTORS;desc++)
402 investigate_write_descriptor(dev,card,desc,bufferoffsets[desc]); 402 investigate_write_descriptor(dev,card,desc,bufferoffsets[desc]);
403 403
404 404
405 nextdescriptor = (card->transmit_used +1) % (NUMDESCRIPTORS); 405 nextdescriptor = (card->transmit_used +1) % (NUMDESCRIPTORS);
406 desc = card->transmit_used; 406 desc = card->transmit_used;
407 407
408 /* only send the packet if the descriptor is free */ 408 /* only send the packet if the descriptor is free */
409 if (card->tx_buffer[4*desc]==0) { 409 if (card->tx_buffer[4*desc]==0) {
410 /* Copy the packet data; zero the memory first as the card 410 /* Copy the packet data; zero the memory first as the card
411 sometimes sends more than you ask it to. */ 411 sometimes sends more than you ask it to. */
412 412
413 memset(&card->tx_buffer[bufferoffsets[desc]/4],0,1536); 413 memset(&card->tx_buffer[bufferoffsets[desc]/4],0,1536);
414 memcpy(&(card->tx_buffer[bufferoffsets[desc]/4]),skb->data,skb->len); 414 memcpy(&(card->tx_buffer[bufferoffsets[desc]/4]),skb->data,skb->len);
415 415
416 416
417 /* FIXME: The specification tells us that the length we send HAS to be a multiple of 417 /* FIXME: The specification tells us that the length we send HAS to be a multiple of
418 4 bytes. */ 418 4 bytes. */
419 419
420 card->tx_buffer[4*desc+1] = skb->len; 420 card->tx_buffer[4*desc+1] = skb->len;
421 if (desc == NUMDESCRIPTORS-1) 421 if (desc == NUMDESCRIPTORS-1)
422 card->tx_buffer[4*desc+1] |= (1<<25); /* bit 25: last descriptor of the ring */ 422 card->tx_buffer[4*desc+1] |= (1<<25); /* bit 25: last descriptor of the ring */
423 423
424 card->tx_buffer[4*desc+1] |= 0xF0000000; 424 card->tx_buffer[4*desc+1] |= 0xF0000000;
425 /* 0xF0... means want interrupts*/ 425 /* 0xF0... means want interrupts*/
426 card->tx_skb[desc] = skb; 426 card->tx_skb[desc] = skb;
427 427
428 wmb(); 428 wmb();
429 /* This gives the descriptor to the card */ 429 /* This gives the descriptor to the card */
430 card->tx_buffer[4*desc] = 0x80000000; 430 card->tx_buffer[4*desc] = 0x80000000;
@@ -433,18 +433,18 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
433 netif_stop_queue(dev); 433 netif_stop_queue(dev);
434 } 434 }
435 card->transmit_used = nextdescriptor; 435 card->transmit_used = nextdescriptor;
436 leave("xircom-start_xmit - sent"); 436 leave("xircom-start_xmit - sent");
437 spin_unlock_irqrestore(&card->lock,flags); 437 spin_unlock_irqrestore(&card->lock,flags);
438 return 0; 438 return 0;
439 } 439 }
440 440
441 441
442 442
443 /* Uh oh... no free descriptor... drop the packet */ 443 /* Uh oh... no free descriptor... drop the packet */
444 netif_stop_queue(dev); 444 netif_stop_queue(dev);
445 spin_unlock_irqrestore(&card->lock,flags); 445 spin_unlock_irqrestore(&card->lock,flags);
446 trigger_transmit(card); 446 trigger_transmit(card);
447 447
448 return -EIO; 448 return -EIO;
449} 449}
450 450
@@ -462,7 +462,7 @@ static int xircom_open(struct net_device *dev)
462 leave("xircom_open - No IRQ"); 462 leave("xircom_open - No IRQ");
463 return retval; 463 return retval;
464 } 464 }
465 465
466 xircom_up(xp); 466 xircom_up(xp);
467 xp->open = 1; 467 xp->open = 1;
468 leave("xircom_open"); 468 leave("xircom_open");
@@ -473,31 +473,31 @@ static int xircom_close(struct net_device *dev)
473{ 473{
474 struct xircom_private *card; 474 struct xircom_private *card;
475 unsigned long flags; 475 unsigned long flags;
476 476
477 enter("xircom_close"); 477 enter("xircom_close");
478 card = netdev_priv(dev); 478 card = netdev_priv(dev);
479 netif_stop_queue(dev); /* we don't want new packets */ 479 netif_stop_queue(dev); /* we don't want new packets */
480 480
481 481
482 spin_lock_irqsave(&card->lock,flags); 482 spin_lock_irqsave(&card->lock,flags);
483 483
484 disable_all_interrupts(card); 484 disable_all_interrupts(card);
485#if 0 485#if 0
486 /* We can enable this again once we send dummy packets on ifconfig ethX up */ 486 /* We can enable this again once we send dummy packets on ifconfig ethX up */
487 deactivate_receiver(card); 487 deactivate_receiver(card);
488 deactivate_transmitter(card); 488 deactivate_transmitter(card);
489#endif 489#endif
490 remove_descriptors(card); 490 remove_descriptors(card);
491 491
492 spin_unlock_irqrestore(&card->lock,flags); 492 spin_unlock_irqrestore(&card->lock,flags);
493 493
494 card->open = 0; 494 card->open = 0;
495 free_irq(dev->irq,dev); 495 free_irq(dev->irq,dev);
496 496
497 leave("xircom_close"); 497 leave("xircom_close");
498 498
499 return 0; 499 return 0;
500 500
501} 501}
502 502
503 503
@@ -506,8 +506,8 @@ static struct net_device_stats *xircom_get_stats(struct net_device *dev)
506{ 506{
507 struct xircom_private *card = netdev_priv(dev); 507 struct xircom_private *card = netdev_priv(dev);
508 return &card->stats; 508 return &card->stats;
509} 509}
510 510
511 511
512#ifdef CONFIG_NET_POLL_CONTROLLER 512#ifdef CONFIG_NET_POLL_CONTROLLER
513static void xircom_poll_controller(struct net_device *dev) 513static void xircom_poll_controller(struct net_device *dev)
@@ -540,7 +540,7 @@ static void initialize_card(struct xircom_private *card)
540 outl(val, card->io_port + CSR0); 540 outl(val, card->io_port + CSR0);
541 541
542 542
543 val = 0; /* Value 0x00 is a safe and conservative value 543 val = 0; /* Value 0x00 is a safe and conservative value
544 for the PCI configuration settings */ 544 for the PCI configuration settings */
545 outl(val, card->io_port + CSR0); 545 outl(val, card->io_port + CSR0);
546 546
@@ -617,23 +617,23 @@ static void setup_descriptors(struct xircom_private *card)
617 617
618 /* Rx Descr2: address of the buffer 618 /* Rx Descr2: address of the buffer
619 we store the buffer at the 2nd half of the page */ 619 we store the buffer at the 2nd half of the page */
620 620
621 address = (unsigned long) card->rx_dma_handle; 621 address = (unsigned long) card->rx_dma_handle;
622 card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]); 622 card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]);
623 /* Rx Desc3: address of 2nd buffer -> 0 */ 623 /* Rx Desc3: address of 2nd buffer -> 0 */
624 card->rx_buffer[i*4 + 3] = 0; 624 card->rx_buffer[i*4 + 3] = 0;
625 } 625 }
626 626
627 wmb(); 627 wmb();
628 /* Write the receive descriptor ring address to the card */ 628 /* Write the receive descriptor ring address to the card */
629 address = (unsigned long) card->rx_dma_handle; 629 address = (unsigned long) card->rx_dma_handle;
630 val = cpu_to_le32(address); 630 val = cpu_to_le32(address);
631 outl(val, card->io_port + CSR3); /* Receive descr list address */ 631 outl(val, card->io_port + CSR3); /* Receive descr list address */
632 632
633 633
634 /* transmit descriptors */ 634 /* transmit descriptors */
635 memset(card->tx_buffer, 0, 128); /* clear the descriptors */ 635 memset(card->tx_buffer, 0, 128); /* clear the descriptors */
636 636
637 for (i=0;i<NUMDESCRIPTORS;i++ ) { 637 for (i=0;i<NUMDESCRIPTORS;i++ ) {
638 /* Tx Descr0: Empty, we own it, no errors -> 0x00000000 */ 638 /* Tx Descr0: Empty, we own it, no errors -> 0x00000000 */
639 card->tx_buffer[i*4 + 0] = 0x00000000; 639 card->tx_buffer[i*4 + 0] = 0x00000000;
@@ -641,7 +641,7 @@ static void setup_descriptors(struct xircom_private *card)
641 card->tx_buffer[i*4 + 1] = 1536; 641 card->tx_buffer[i*4 + 1] = 1536;
642 if (i==NUMDESCRIPTORS-1) 642 if (i==NUMDESCRIPTORS-1)
643 card->tx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */ 643 card->tx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */
644 644
645 /* Tx Descr2: address of the buffer 645 /* Tx Descr2: address of the buffer
646 we store the buffer at the 2nd half of the page */ 646 we store the buffer at the 2nd half of the page */
647 address = (unsigned long) card->tx_dma_handle; 647 address = (unsigned long) card->tx_dma_handle;
@@ -748,7 +748,7 @@ static int receive_active(struct xircom_private *card)
748activate_receiver enables the receiver on the card. 748activate_receiver enables the receiver on the card.
749Before being allowed to active the receiver, the receiver 749Before being allowed to active the receiver, the receiver
750must be completely de-activated. To achieve this, 750must be completely de-activated. To achieve this,
751this code actually disables the receiver first; then it waits for the 751this code actually disables the receiver first; then it waits for the
752receiver to become inactive, then it activates the receiver and then 752receiver to become inactive, then it activates the receiver and then
753it waits for the receiver to be active. 753it waits for the receiver to be active.
754 754
@@ -762,13 +762,13 @@ static void activate_receiver(struct xircom_private *card)
762 762
763 763
764 val = inl(card->io_port + CSR6); /* Operation mode */ 764 val = inl(card->io_port + CSR6); /* Operation mode */
765 765
766 /* If the "active" bit is set and the receiver is already 766 /* If the "active" bit is set and the receiver is already
767 active, no need to do the expensive thing */ 767 active, no need to do the expensive thing */
768 if ((val&2) && (receive_active(card))) 768 if ((val&2) && (receive_active(card)))
769 return; 769 return;
770 770
771 771
772 val = val & ~2; /* disable the receiver */ 772 val = val & ~2; /* disable the receiver */
773 outl(val, card->io_port + CSR6); 773 outl(val, card->io_port + CSR6);
774 774
@@ -805,7 +805,7 @@ static void activate_receiver(struct xircom_private *card)
805 805
806/* 806/*
807deactivate_receiver disables the receiver on the card. 807deactivate_receiver disables the receiver on the card.
808To achieve this this code disables the receiver first; 808To achieve this this code disables the receiver first;
809then it waits for the receiver to become inactive. 809then it waits for the receiver to become inactive.
810 810
811must be called with the lock held and interrupts disabled. 811must be called with the lock held and interrupts disabled.
@@ -840,7 +840,7 @@ static void deactivate_receiver(struct xircom_private *card)
840activate_transmitter enables the transmitter on the card. 840activate_transmitter enables the transmitter on the card.
841Before being allowed to active the transmitter, the transmitter 841Before being allowed to active the transmitter, the transmitter
842must be completely de-activated. To achieve this, 842must be completely de-activated. To achieve this,
843this code actually disables the transmitter first; then it waits for the 843this code actually disables the transmitter first; then it waits for the
844transmitter to become inactive, then it activates the transmitter and then 844transmitter to become inactive, then it activates the transmitter and then
845it waits for the transmitter to be active again. 845it waits for the transmitter to be active again.
846 846
@@ -856,7 +856,7 @@ static void activate_transmitter(struct xircom_private *card)
856 val = inl(card->io_port + CSR6); /* Operation mode */ 856 val = inl(card->io_port + CSR6); /* Operation mode */
857 857
858 /* If the "active" bit is set and the receiver is already 858 /* If the "active" bit is set and the receiver is already
859 active, no need to do the expensive thing */ 859 active, no need to do the expensive thing */
860 if ((val&(1<<13)) && (transmit_active(card))) 860 if ((val&(1<<13)) && (transmit_active(card)))
861 return; 861 return;
862 862
@@ -896,7 +896,7 @@ static void activate_transmitter(struct xircom_private *card)
896 896
897/* 897/*
898deactivate_transmitter disables the transmitter on the card. 898deactivate_transmitter disables the transmitter on the card.
899To achieve this this code disables the transmitter first; 899To achieve this this code disables the transmitter first;
900then it waits for the transmitter to become inactive. 900then it waits for the transmitter to become inactive.
901 901
902must be called with the lock held and interrupts disabled. 902must be called with the lock held and interrupts disabled.
@@ -990,7 +990,7 @@ static void disable_all_interrupts(struct xircom_private *card)
990{ 990{
991 unsigned int val; 991 unsigned int val;
992 enter("enable_all_interrupts"); 992 enter("enable_all_interrupts");
993 993
994 val = 0; /* disable all interrupts */ 994 val = 0; /* disable all interrupts */
995 outl(val, card->io_port + CSR7); 995 outl(val, card->io_port + CSR7);
996 996
@@ -1031,8 +1031,8 @@ static int enable_promisc(struct xircom_private *card)
1031 unsigned int val; 1031 unsigned int val;
1032 enter("enable_promisc"); 1032 enter("enable_promisc");
1033 1033
1034 val = inl(card->io_port + CSR6); 1034 val = inl(card->io_port + CSR6);
1035 val = val | (1 << 6); 1035 val = val | (1 << 6);
1036 outl(val, card->io_port + CSR6); 1036 outl(val, card->io_port + CSR6);
1037 1037
1038 leave("enable_promisc"); 1038 leave("enable_promisc");
@@ -1042,7 +1042,7 @@ static int enable_promisc(struct xircom_private *card)
1042 1042
1043 1043
1044 1044
1045/* 1045/*
1046link_status() checks the the links status and will return 0 for no link, 10 for 10mbit link and 100 for.. guess what. 1046link_status() checks the the links status and will return 0 for no link, 10 for 10mbit link and 100 for.. guess what.
1047 1047
1048Must be called in locked state with interrupts disabled 1048Must be called in locked state with interrupts disabled
@@ -1051,15 +1051,15 @@ static int link_status(struct xircom_private *card)
1051{ 1051{
1052 unsigned int val; 1052 unsigned int val;
1053 enter("link_status"); 1053 enter("link_status");
1054 1054
1055 val = inb(card->io_port + CSR12); 1055 val = inb(card->io_port + CSR12);
1056 1056
1057 if (!(val&(1<<2))) /* bit 2 is 0 for 10mbit link, 1 for not an 10mbit link */ 1057 if (!(val&(1<<2))) /* bit 2 is 0 for 10mbit link, 1 for not an 10mbit link */
1058 return 10; 1058 return 10;
1059 if (!(val&(1<<1))) /* bit 1 is 0 for 100mbit link, 1 for not an 100mbit link */ 1059 if (!(val&(1<<1))) /* bit 1 is 0 for 100mbit link, 1 for not an 100mbit link */
1060 return 100; 1060 return 100;
1061 1061
1062 /* If we get here -> no link at all */ 1062 /* If we get here -> no link at all */
1063 1063
1064 leave("link_status"); 1064 leave("link_status");
1065 return 0; 1065 return 0;
@@ -1071,7 +1071,7 @@ static int link_status(struct xircom_private *card)
1071 1071
1072/* 1072/*
1073 read_mac_address() reads the MAC address from the NIC and stores it in the "dev" structure. 1073 read_mac_address() reads the MAC address from the NIC and stores it in the "dev" structure.
1074 1074
1075 This function will take the spinlock itself and can, as a result, not be called with the lock helt. 1075 This function will take the spinlock itself and can, as a result, not be called with the lock helt.
1076 */ 1076 */
1077static void read_mac_address(struct xircom_private *card) 1077static void read_mac_address(struct xircom_private *card)
@@ -1081,7 +1081,7 @@ static void read_mac_address(struct xircom_private *card)
1081 int i; 1081 int i;
1082 1082
1083 enter("read_mac_address"); 1083 enter("read_mac_address");
1084 1084
1085 spin_lock_irqsave(&card->lock, flags); 1085 spin_lock_irqsave(&card->lock, flags);
1086 1086
1087 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */ 1087 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */
@@ -1095,7 +1095,7 @@ static void read_mac_address(struct xircom_private *card)
1095 outl(i + 3, card->io_port + CSR10); 1095 outl(i + 3, card->io_port + CSR10);
1096 data_count = inl(card->io_port + CSR9) & 0xff; 1096 data_count = inl(card->io_port + CSR9) & 0xff;
1097 if ((tuple == 0x22) && (data_id == 0x04) && (data_count == 0x06)) { 1097 if ((tuple == 0x22) && (data_id == 0x04) && (data_count == 0x06)) {
1098 /* 1098 /*
1099 * This is it. We have the data we want. 1099 * This is it. We have the data we want.
1100 */ 1100 */
1101 for (j = 0; j < 6; j++) { 1101 for (j = 0; j < 6; j++) {
@@ -1136,12 +1136,12 @@ static void transceiver_voodoo(struct xircom_private *card)
1136 spin_lock_irqsave(&card->lock, flags); 1136 spin_lock_irqsave(&card->lock, flags);
1137 1137
1138 outl(0x0008, card->io_port + CSR15); 1138 outl(0x0008, card->io_port + CSR15);
1139 udelay(25); 1139 udelay(25);
1140 outl(0xa8050000, card->io_port + CSR15); 1140 outl(0xa8050000, card->io_port + CSR15);
1141 udelay(25); 1141 udelay(25);
1142 outl(0xa00f0000, card->io_port + CSR15); 1142 outl(0xa00f0000, card->io_port + CSR15);
1143 udelay(25); 1143 udelay(25);
1144 1144
1145 spin_unlock_irqrestore(&card->lock, flags); 1145 spin_unlock_irqrestore(&card->lock, flags);
1146 1146
1147 netif_start_queue(card->dev); 1147 netif_start_queue(card->dev);
@@ -1163,15 +1163,15 @@ static void xircom_up(struct xircom_private *card)
1163 1163
1164 spin_lock_irqsave(&card->lock, flags); 1164 spin_lock_irqsave(&card->lock, flags);
1165 1165
1166 1166
1167 enable_link_interrupt(card); 1167 enable_link_interrupt(card);
1168 enable_transmit_interrupt(card); 1168 enable_transmit_interrupt(card);
1169 enable_receive_interrupt(card); 1169 enable_receive_interrupt(card);
1170 enable_common_interrupts(card); 1170 enable_common_interrupts(card);
1171 enable_promisc(card); 1171 enable_promisc(card);
1172 1172
1173 /* The card can have received packets already, read them away now */ 1173 /* The card can have received packets already, read them away now */
1174 for (i=0;i<NUMDESCRIPTORS;i++) 1174 for (i=0;i<NUMDESCRIPTORS;i++)
1175 investigate_read_descriptor(card->dev,card,i,bufferoffsets[i]); 1175 investigate_read_descriptor(card->dev,card,i,bufferoffsets[i]);
1176 1176
1177 1177
@@ -1185,15 +1185,15 @@ static void xircom_up(struct xircom_private *card)
1185/* Bufferoffset is in BYTES */ 1185/* Bufferoffset is in BYTES */
1186static void investigate_read_descriptor(struct net_device *dev,struct xircom_private *card, int descnr, unsigned int bufferoffset) 1186static void investigate_read_descriptor(struct net_device *dev,struct xircom_private *card, int descnr, unsigned int bufferoffset)
1187{ 1187{
1188 int status; 1188 int status;
1189 1189
1190 enter("investigate_read_descriptor"); 1190 enter("investigate_read_descriptor");
1191 status = card->rx_buffer[4*descnr]; 1191 status = card->rx_buffer[4*descnr];
1192 1192
1193 if ((status > 0)) { /* packet received */ 1193 if ((status > 0)) { /* packet received */
1194 1194
1195 /* TODO: discard error packets */ 1195 /* TODO: discard error packets */
1196 1196
1197 short pkt_len = ((status >> 16) & 0x7ff) - 4; /* minus 4, we don't want the CRC */ 1197 short pkt_len = ((status >> 16) & 0x7ff) - 4; /* minus 4, we don't want the CRC */
1198 struct sk_buff *skb; 1198 struct sk_buff *skb;
1199 1199
@@ -1216,7 +1216,7 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
1216 dev->last_rx = jiffies; 1216 dev->last_rx = jiffies;
1217 card->stats.rx_packets++; 1217 card->stats.rx_packets++;
1218 card->stats.rx_bytes += pkt_len; 1218 card->stats.rx_bytes += pkt_len;
1219 1219
1220 out: 1220 out:
1221 /* give the buffer back to the card */ 1221 /* give the buffer back to the card */
1222 card->rx_buffer[4*descnr] = 0x80000000; 1222 card->rx_buffer[4*descnr] = 0x80000000;
@@ -1234,9 +1234,9 @@ static void investigate_write_descriptor(struct net_device *dev, struct xircom_p
1234 int status; 1234 int status;
1235 1235
1236 enter("investigate_write_descriptor"); 1236 enter("investigate_write_descriptor");
1237 1237
1238 status = card->tx_buffer[4*descnr]; 1238 status = card->tx_buffer[4*descnr];
1239#if 0 1239#if 0
1240 if (status & 0x8000) { /* Major error */ 1240 if (status & 0x8000) { /* Major error */
1241 printk(KERN_ERR "Major transmit error status %x \n", status); 1241 printk(KERN_ERR "Major transmit error status %x \n", status);
1242 card->tx_buffer[4*descnr] = 0; 1242 card->tx_buffer[4*descnr] = 0;
@@ -1258,7 +1258,7 @@ static void investigate_write_descriptor(struct net_device *dev, struct xircom_p
1258 } 1258 }
1259 1259
1260 leave("investigate_write_descriptor"); 1260 leave("investigate_write_descriptor");
1261 1261
1262} 1262}
1263 1263
1264 1264
@@ -1271,8 +1271,8 @@ static int __init xircom_init(void)
1271static void __exit xircom_exit(void) 1271static void __exit xircom_exit(void)
1272{ 1272{
1273 pci_unregister_driver(&xircom_ops); 1273 pci_unregister_driver(&xircom_ops);
1274} 1274}
1275 1275
1276module_init(xircom_init) 1276module_init(xircom_init)
1277module_exit(xircom_exit) 1277module_exit(xircom_exit)
1278 1278