aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/e100.c72
1 files changed, 35 insertions, 37 deletions
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index d87636dbdea5..51cf577035be 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -401,12 +401,12 @@ enum cb_command {
401}; 401};
402 402
403struct rfd { 403struct rfd {
404 u16 status; 404 __le16 status;
405 u16 command; 405 __le16 command;
406 u32 link; 406 __le32 link;
407 u32 rbd; 407 __le32 rbd;
408 u16 actual_size; 408 __le16 actual_size;
409 u16 size; 409 __le16 size;
410}; 410};
411 411
412struct rx { 412struct rx {
@@ -461,19 +461,19 @@ struct config {
461 461
462#define E100_MAX_MULTICAST_ADDRS 64 462#define E100_MAX_MULTICAST_ADDRS 64
463struct multi { 463struct multi {
464 u16 count; 464 __le16 count;
465 u8 addr[E100_MAX_MULTICAST_ADDRS * ETH_ALEN + 2/*pad*/]; 465 u8 addr[E100_MAX_MULTICAST_ADDRS * ETH_ALEN + 2/*pad*/];
466}; 466};
467 467
468/* Important: keep total struct u32-aligned */ 468/* Important: keep total struct u32-aligned */
469#define UCODE_SIZE 134 469#define UCODE_SIZE 134
470struct cb { 470struct cb {
471 u16 status; 471 __le16 status;
472 u16 command; 472 __le16 command;
473 u32 link; 473 __le32 link;
474 union { 474 union {
475 u8 iaaddr[ETH_ALEN]; 475 u8 iaaddr[ETH_ALEN];
476 u32 ucode[UCODE_SIZE]; 476 __le32 ucode[UCODE_SIZE];
477 struct config config; 477 struct config config;
478 struct multi multi; 478 struct multi multi;
479 struct { 479 struct {
@@ -482,12 +482,12 @@ struct cb {
482 u8 threshold; 482 u8 threshold;
483 u8 tbd_count; 483 u8 tbd_count;
484 struct { 484 struct {
485 u32 buf_addr; 485 __le32 buf_addr;
486 u16 size; 486 __le16 size;
487 u16 eol; 487 u16 eol;
488 } tbd; 488 } tbd;
489 } tcb; 489 } tcb;
490 u32 dump_buffer_addr; 490 __le32 dump_buffer_addr;
491 } u; 491 } u;
492 struct cb *next, *prev; 492 struct cb *next, *prev;
493 dma_addr_t dma_addr; 493 dma_addr_t dma_addr;
@@ -499,15 +499,15 @@ enum loopback {
499}; 499};
500 500
501struct stats { 501struct stats {
502 u32 tx_good_frames, tx_max_collisions, tx_late_collisions, 502 __le32 tx_good_frames, tx_max_collisions, tx_late_collisions,
503 tx_underruns, tx_lost_crs, tx_deferred, tx_single_collisions, 503 tx_underruns, tx_lost_crs, tx_deferred, tx_single_collisions,
504 tx_multiple_collisions, tx_total_collisions; 504 tx_multiple_collisions, tx_total_collisions;
505 u32 rx_good_frames, rx_crc_errors, rx_alignment_errors, 505 __le32 rx_good_frames, rx_crc_errors, rx_alignment_errors,
506 rx_resource_errors, rx_overrun_errors, rx_cdt_errors, 506 rx_resource_errors, rx_overrun_errors, rx_cdt_errors,
507 rx_short_frame_errors; 507 rx_short_frame_errors;
508 u32 fc_xmt_pause, fc_rcv_pause, fc_rcv_unsupported; 508 __le32 fc_xmt_pause, fc_rcv_pause, fc_rcv_unsupported;
509 u16 xmt_tco_frames, rcv_tco_frames; 509 __le16 xmt_tco_frames, rcv_tco_frames;
510 u32 complete; 510 __le32 complete;
511}; 511};
512 512
513struct mem { 513struct mem {
@@ -552,7 +552,7 @@ struct nic {
552 struct cb *cb_to_use; 552 struct cb *cb_to_use;
553 struct cb *cb_to_send; 553 struct cb *cb_to_send;
554 struct cb *cb_to_clean; 554 struct cb *cb_to_clean;
555 u16 tx_command; 555 __le16 tx_command;
556 /* End: frequently used values: keep adjacent for cache effect */ 556 /* End: frequently used values: keep adjacent for cache effect */
557 557
558 enum { 558 enum {
@@ -593,7 +593,7 @@ struct nic {
593 593
594 u16 leds; 594 u16 leds;
595 u16 eeprom_wc; 595 u16 eeprom_wc;
596 u16 eeprom[256]; 596 __le16 eeprom[256];
597 spinlock_t mdio_lock; 597 spinlock_t mdio_lock;
598}; 598};
599 599
@@ -671,7 +671,7 @@ static int e100_self_test(struct nic *nic)
671 return 0; 671 return 0;
672} 672}
673 673
674static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, u16 data) 674static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, __le16 data)
675{ 675{
676 u32 cmd_addr_data[3]; 676 u32 cmd_addr_data[3];
677 u8 ctrl; 677 u8 ctrl;
@@ -680,7 +680,7 @@ static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, u16 data)
680 /* Three cmds: write/erase enable, write data, write/erase disable */ 680 /* Three cmds: write/erase enable, write data, write/erase disable */
681 cmd_addr_data[0] = op_ewen << (addr_len - 2); 681 cmd_addr_data[0] = op_ewen << (addr_len - 2);
682 cmd_addr_data[1] = (((op_write << addr_len) | addr) << 16) | 682 cmd_addr_data[1] = (((op_write << addr_len) | addr) << 16) |
683 cpu_to_le16(data); 683 le16_to_cpu(data);
684 cmd_addr_data[2] = op_ewds << (addr_len - 2); 684 cmd_addr_data[2] = op_ewds << (addr_len - 2);
685 685
686 /* Bit-bang cmds to write word to eeprom */ 686 /* Bit-bang cmds to write word to eeprom */
@@ -709,7 +709,7 @@ static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, u16 data)
709}; 709};
710 710
711/* General technique stolen from the eepro100 driver - very clever */ 711/* General technique stolen from the eepro100 driver - very clever */
712static u16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr) 712static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)
713{ 713{
714 u32 cmd_addr_data; 714 u32 cmd_addr_data;
715 u16 data = 0; 715 u16 data = 0;
@@ -746,7 +746,7 @@ static u16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)
746 iowrite8(0, &nic->csr->eeprom_ctrl_lo); 746 iowrite8(0, &nic->csr->eeprom_ctrl_lo);
747 e100_write_flush(nic); udelay(4); 747 e100_write_flush(nic); udelay(4);
748 748
749 return le16_to_cpu(data); 749 return cpu_to_le16(data);
750}; 750};
751 751
752/* Load entire EEPROM image into driver cache and validate checksum */ 752/* Load entire EEPROM image into driver cache and validate checksum */
@@ -761,13 +761,12 @@ static int e100_eeprom_load(struct nic *nic)
761 for(addr = 0; addr < nic->eeprom_wc; addr++) { 761 for(addr = 0; addr < nic->eeprom_wc; addr++) {
762 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr); 762 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr);
763 if(addr < nic->eeprom_wc - 1) 763 if(addr < nic->eeprom_wc - 1)
764 checksum += cpu_to_le16(nic->eeprom[addr]); 764 checksum += le16_to_cpu(nic->eeprom[addr]);
765 } 765 }
766 766
767 /* The checksum, stored in the last word, is calculated such that 767 /* The checksum, stored in the last word, is calculated such that
768 * the sum of words should be 0xBABA */ 768 * the sum of words should be 0xBABA */
769 checksum = le16_to_cpu(0xBABA - checksum); 769 if (cpu_to_le16(0xBABA - checksum) != nic->eeprom[nic->eeprom_wc - 1]) {
770 if(checksum != nic->eeprom[nic->eeprom_wc - 1]) {
771 DPRINTK(PROBE, ERR, "EEPROM corrupted\n"); 770 DPRINTK(PROBE, ERR, "EEPROM corrupted\n");
772 if (!eeprom_bad_csum_allow) 771 if (!eeprom_bad_csum_allow)
773 return -EAGAIN; 772 return -EAGAIN;
@@ -794,8 +793,8 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)
794 /* The checksum, stored in the last word, is calculated such that 793 /* The checksum, stored in the last word, is calculated such that
795 * the sum of words should be 0xBABA */ 794 * the sum of words should be 0xBABA */
796 for(addr = 0; addr < nic->eeprom_wc - 1; addr++) 795 for(addr = 0; addr < nic->eeprom_wc - 1; addr++)
797 checksum += cpu_to_le16(nic->eeprom[addr]); 796 checksum += le16_to_cpu(nic->eeprom[addr]);
798 nic->eeprom[nic->eeprom_wc - 1] = le16_to_cpu(0xBABA - checksum); 797 nic->eeprom[nic->eeprom_wc - 1] = cpu_to_le16(0xBABA - checksum);
799 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1, 798 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1,
800 nic->eeprom[nic->eeprom_wc - 1]); 799 nic->eeprom[nic->eeprom_wc - 1]);
801 800
@@ -1493,15 +1492,15 @@ static void e100_update_stats(struct nic *nic)
1493 struct net_device *dev = nic->netdev; 1492 struct net_device *dev = nic->netdev;
1494 struct net_device_stats *ns = &dev->stats; 1493 struct net_device_stats *ns = &dev->stats;
1495 struct stats *s = &nic->mem->stats; 1494 struct stats *s = &nic->mem->stats;
1496 u32 *complete = (nic->mac < mac_82558_D101_A4) ? &s->fc_xmt_pause : 1495 __le32 *complete = (nic->mac < mac_82558_D101_A4) ? &s->fc_xmt_pause :
1497 (nic->mac < mac_82559_D101M) ? (u32 *)&s->xmt_tco_frames : 1496 (nic->mac < mac_82559_D101M) ? (__le32 *)&s->xmt_tco_frames :
1498 &s->complete; 1497 &s->complete;
1499 1498
1500 /* Device's stats reporting may take several microseconds to 1499 /* Device's stats reporting may take several microseconds to
1501 * complete, so where always waiting for results of the 1500 * complete, so where always waiting for results of the
1502 * previous command. */ 1501 * previous command. */
1503 1502
1504 if(*complete == le32_to_cpu(cuc_dump_reset_complete)) { 1503 if(*complete == cpu_to_le32(cuc_dump_reset_complete)) {
1505 *complete = 0; 1504 *complete = 0;
1506 nic->tx_frames = le32_to_cpu(s->tx_good_frames); 1505 nic->tx_frames = le32_to_cpu(s->tx_good_frames);
1507 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions); 1506 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions);
@@ -1791,7 +1790,7 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1791 rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data, 1790 rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data,
1792 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 1791 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
1793 1792
1794 if(pci_dma_mapping_error(rx->dma_addr)) { 1793 if (pci_dma_mapping_error(rx->dma_addr)) {
1795 dev_kfree_skb_any(rx->skb); 1794 dev_kfree_skb_any(rx->skb);
1796 rx->skb = NULL; 1795 rx->skb = NULL;
1797 rx->dma_addr = 0; 1796 rx->dma_addr = 0;
@@ -1801,10 +1800,9 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1801 /* Link the RFD to end of RFA by linking previous RFD to 1800 /* Link the RFD to end of RFA by linking previous RFD to
1802 * this one. We are safe to touch the previous RFD because 1801 * this one. We are safe to touch the previous RFD because
1803 * it is protected by the before last buffer's el bit being set */ 1802 * it is protected by the before last buffer's el bit being set */
1804 if(rx->prev->skb) { 1803 if (rx->prev->skb) {
1805 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; 1804 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data;
1806 put_unaligned(cpu_to_le32(rx->dma_addr), 1805 put_unaligned(cpu_to_le32(rx->dma_addr), &prev_rfd->link);
1807 (u32 *)&prev_rfd->link);
1808 } 1806 }
1809 1807
1810 return 0; 1808 return 0;