diff options
Diffstat (limited to 'drivers/net/typhoon.c')
-rw-r--r-- | drivers/net/typhoon.c | 272 |
1 files changed, 110 insertions, 162 deletions
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c index 5921f5bdd764..98d818daa77e 100644 --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c | |||
@@ -98,14 +98,10 @@ static const int multicast_filter_limit = 32; | |||
98 | #define TX_TIMEOUT (2*HZ) | 98 | #define TX_TIMEOUT (2*HZ) |
99 | 99 | ||
100 | #define PKT_BUF_SZ 1536 | 100 | #define PKT_BUF_SZ 1536 |
101 | |||
102 | #define DRV_MODULE_NAME "typhoon" | ||
103 | #define DRV_MODULE_VERSION "1.5.9" | ||
104 | #define DRV_MODULE_RELDATE "Mar 2, 2009" | ||
105 | #define PFX DRV_MODULE_NAME ": " | ||
106 | #define ERR_PFX KERN_ERR PFX | ||
107 | #define FIRMWARE_NAME "3com/typhoon.bin" | 101 | #define FIRMWARE_NAME "3com/typhoon.bin" |
108 | 102 | ||
103 | #define pr_fmt(fmt) KBUILD_MODNAME " " fmt | ||
104 | |||
109 | #include <linux/module.h> | 105 | #include <linux/module.h> |
110 | #include <linux/kernel.h> | 106 | #include <linux/kernel.h> |
111 | #include <linux/sched.h> | 107 | #include <linux/sched.h> |
@@ -113,7 +109,6 @@ static const int multicast_filter_limit = 32; | |||
113 | #include <linux/timer.h> | 109 | #include <linux/timer.h> |
114 | #include <linux/errno.h> | 110 | #include <linux/errno.h> |
115 | #include <linux/ioport.h> | 111 | #include <linux/ioport.h> |
116 | #include <linux/slab.h> | ||
117 | #include <linux/interrupt.h> | 112 | #include <linux/interrupt.h> |
118 | #include <linux/pci.h> | 113 | #include <linux/pci.h> |
119 | #include <linux/netdevice.h> | 114 | #include <linux/netdevice.h> |
@@ -132,14 +127,12 @@ static const int multicast_filter_limit = 32; | |||
132 | #include <linux/in6.h> | 127 | #include <linux/in6.h> |
133 | #include <linux/dma-mapping.h> | 128 | #include <linux/dma-mapping.h> |
134 | #include <linux/firmware.h> | 129 | #include <linux/firmware.h> |
130 | #include <generated/utsrelease.h> | ||
135 | 131 | ||
136 | #include "typhoon.h" | 132 | #include "typhoon.h" |
137 | 133 | ||
138 | static char version[] __devinitdata = | ||
139 | "typhoon.c: version " DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; | ||
140 | |||
141 | MODULE_AUTHOR("David Dillow <dave@thedillows.org>"); | 134 | MODULE_AUTHOR("David Dillow <dave@thedillows.org>"); |
142 | MODULE_VERSION(DRV_MODULE_VERSION); | 135 | MODULE_VERSION(UTS_RELEASE); |
143 | MODULE_LICENSE("GPL"); | 136 | MODULE_LICENSE("GPL"); |
144 | MODULE_FIRMWARE(FIRMWARE_NAME); | 137 | MODULE_FIRMWARE(FIRMWARE_NAME); |
145 | MODULE_DESCRIPTION("3Com Typhoon Family (3C990, 3CR990, and variants)"); | 138 | MODULE_DESCRIPTION("3Com Typhoon Family (3C990, 3CR990, and variants)"); |
@@ -161,8 +154,8 @@ module_param(use_mmio, int, 0); | |||
161 | #endif | 154 | #endif |
162 | 155 | ||
163 | struct typhoon_card_info { | 156 | struct typhoon_card_info { |
164 | char *name; | 157 | const char *name; |
165 | int capabilities; | 158 | const int capabilities; |
166 | }; | 159 | }; |
167 | 160 | ||
168 | #define TYPHOON_CRYPTO_NONE 0x00 | 161 | #define TYPHOON_CRYPTO_NONE 0x00 |
@@ -215,7 +208,7 @@ static struct typhoon_card_info typhoon_card_info[] __devinitdata = { | |||
215 | * bit 8 indicates if this is a (0) copper or (1) fiber card | 208 | * bit 8 indicates if this is a (0) copper or (1) fiber card |
216 | * bits 12-16 indicate card type: (0) client and (1) server | 209 | * bits 12-16 indicate card type: (0) client and (1) server |
217 | */ | 210 | */ |
218 | static struct pci_device_id typhoon_pci_tbl[] = { | 211 | static DEFINE_PCI_DEVICE_TABLE(typhoon_pci_tbl) = { |
219 | { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990, | 212 | { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990, |
220 | PCI_ANY_ID, PCI_ANY_ID, 0, 0,TYPHOON_TX }, | 213 | PCI_ANY_ID, PCI_ANY_ID, 0, 0,TYPHOON_TX }, |
221 | { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990_TX_95, | 214 | { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990_TX_95, |
@@ -299,7 +292,6 @@ struct typhoon { | |||
299 | struct basic_ring respRing; | 292 | struct basic_ring respRing; |
300 | struct net_device_stats stats; | 293 | struct net_device_stats stats; |
301 | struct net_device_stats stats_saved; | 294 | struct net_device_stats stats_saved; |
302 | const char * name; | ||
303 | struct typhoon_shared * shared; | 295 | struct typhoon_shared * shared; |
304 | dma_addr_t shared_dma; | 296 | dma_addr_t shared_dma; |
305 | __le16 xcvr_select; | 297 | __le16 xcvr_select; |
@@ -487,7 +479,7 @@ typhoon_hello(struct typhoon *tp) | |||
487 | typhoon_inc_cmd_index(&ring->lastWrite, 1); | 479 | typhoon_inc_cmd_index(&ring->lastWrite, 1); |
488 | 480 | ||
489 | INIT_COMMAND_NO_RESPONSE(cmd, TYPHOON_CMD_HELLO_RESP); | 481 | INIT_COMMAND_NO_RESPONSE(cmd, TYPHOON_CMD_HELLO_RESP); |
490 | smp_wmb(); | 482 | wmb(); |
491 | iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY); | 483 | iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY); |
492 | spin_unlock(&tp->command_lock); | 484 | spin_unlock(&tp->command_lock); |
493 | } | 485 | } |
@@ -534,13 +526,13 @@ typhoon_process_response(struct typhoon *tp, int resp_size, | |||
534 | } else if(resp->cmd == TYPHOON_CMD_HELLO_RESP) { | 526 | } else if(resp->cmd == TYPHOON_CMD_HELLO_RESP) { |
535 | typhoon_hello(tp); | 527 | typhoon_hello(tp); |
536 | } else { | 528 | } else { |
537 | printk(KERN_ERR "%s: dumping unexpected response " | 529 | netdev_err(tp->dev, |
538 | "0x%04x:%d:0x%02x:0x%04x:%08x:%08x\n", | 530 | "dumping unexpected response 0x%04x:%d:0x%02x:0x%04x:%08x:%08x\n", |
539 | tp->name, le16_to_cpu(resp->cmd), | 531 | le16_to_cpu(resp->cmd), |
540 | resp->numDesc, resp->flags, | 532 | resp->numDesc, resp->flags, |
541 | le16_to_cpu(resp->parm1), | 533 | le16_to_cpu(resp->parm1), |
542 | le32_to_cpu(resp->parm2), | 534 | le32_to_cpu(resp->parm2), |
543 | le32_to_cpu(resp->parm3)); | 535 | le32_to_cpu(resp->parm3)); |
544 | } | 536 | } |
545 | 537 | ||
546 | cleanup: | 538 | cleanup: |
@@ -606,9 +598,8 @@ typhoon_issue_command(struct typhoon *tp, int num_cmd, struct cmd_desc *cmd, | |||
606 | freeResp = typhoon_num_free_resp(tp); | 598 | freeResp = typhoon_num_free_resp(tp); |
607 | 599 | ||
608 | if(freeCmd < num_cmd || freeResp < num_resp) { | 600 | if(freeCmd < num_cmd || freeResp < num_resp) { |
609 | printk("%s: no descs for cmd, had (needed) %d (%d) cmd, " | 601 | netdev_err(tp->dev, "no descs for cmd, had (needed) %d (%d) cmd, %d (%d) resp\n", |
610 | "%d (%d) resp\n", tp->name, freeCmd, num_cmd, | 602 | freeCmd, num_cmd, freeResp, num_resp); |
611 | freeResp, num_resp); | ||
612 | err = -ENOMEM; | 603 | err = -ENOMEM; |
613 | goto out; | 604 | goto out; |
614 | } | 605 | } |
@@ -733,7 +724,7 @@ typhoon_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | |||
733 | spin_unlock_bh(&tp->state_lock); | 724 | spin_unlock_bh(&tp->state_lock); |
734 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); | 725 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
735 | if(err < 0) | 726 | if(err < 0) |
736 | printk("%s: vlan offload error %d\n", tp->name, -err); | 727 | netdev_err(tp->dev, "vlan offload error %d\n", -err); |
737 | spin_lock_bh(&tp->state_lock); | 728 | spin_lock_bh(&tp->state_lock); |
738 | } | 729 | } |
739 | 730 | ||
@@ -924,17 +915,15 @@ typhoon_set_rx_mode(struct net_device *dev) | |||
924 | filter = TYPHOON_RX_FILTER_DIRECTED | TYPHOON_RX_FILTER_BROADCAST; | 915 | filter = TYPHOON_RX_FILTER_DIRECTED | TYPHOON_RX_FILTER_BROADCAST; |
925 | if(dev->flags & IFF_PROMISC) { | 916 | if(dev->flags & IFF_PROMISC) { |
926 | filter |= TYPHOON_RX_FILTER_PROMISCOUS; | 917 | filter |= TYPHOON_RX_FILTER_PROMISCOUS; |
927 | } else if((dev->mc_count > multicast_filter_limit) || | 918 | } else if ((netdev_mc_count(dev) > multicast_filter_limit) || |
928 | (dev->flags & IFF_ALLMULTI)) { | 919 | (dev->flags & IFF_ALLMULTI)) { |
929 | /* Too many to match, or accept all multicasts. */ | 920 | /* Too many to match, or accept all multicasts. */ |
930 | filter |= TYPHOON_RX_FILTER_ALL_MCAST; | 921 | filter |= TYPHOON_RX_FILTER_ALL_MCAST; |
931 | } else if(dev->mc_count) { | 922 | } else if (!netdev_mc_empty(dev)) { |
932 | struct dev_mc_list *mclist; | 923 | struct dev_mc_list *mclist; |
933 | int i; | ||
934 | 924 | ||
935 | memset(mc_filter, 0, sizeof(mc_filter)); | 925 | memset(mc_filter, 0, sizeof(mc_filter)); |
936 | for(i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; | 926 | netdev_for_each_mc_addr(mclist, dev) { |
937 | i++, mclist = mclist->next) { | ||
938 | int bit = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3f; | 927 | int bit = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3f; |
939 | mc_filter[bit >> 5] |= 1 << (bit & 0x1f); | 928 | mc_filter[bit >> 5] |= 1 << (bit & 0x1f); |
940 | } | 929 | } |
@@ -1020,7 +1009,7 @@ typhoon_get_stats(struct net_device *dev) | |||
1020 | return saved; | 1009 | return saved; |
1021 | 1010 | ||
1022 | if(typhoon_do_get_stats(tp) < 0) { | 1011 | if(typhoon_do_get_stats(tp) < 0) { |
1023 | printk(KERN_ERR "%s: error getting stats\n", dev->name); | 1012 | netdev_err(dev, "error getting stats\n"); |
1024 | return saved; | 1013 | return saved; |
1025 | } | 1014 | } |
1026 | 1015 | ||
@@ -1062,8 +1051,8 @@ typhoon_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
1062 | } | 1051 | } |
1063 | } | 1052 | } |
1064 | 1053 | ||
1065 | strcpy(info->driver, DRV_MODULE_NAME); | 1054 | strcpy(info->driver, KBUILD_MODNAME); |
1066 | strcpy(info->version, DRV_MODULE_VERSION); | 1055 | strcpy(info->version, UTS_RELEASE); |
1067 | strcpy(info->bus_info, pci_name(pci_dev)); | 1056 | strcpy(info->bus_info, pci_name(pci_dev)); |
1068 | } | 1057 | } |
1069 | 1058 | ||
@@ -1321,13 +1310,15 @@ typhoon_init_interface(struct typhoon *tp) | |||
1321 | 1310 | ||
1322 | tp->txlo_dma_addr = le32_to_cpu(iface->txLoAddr); | 1311 | tp->txlo_dma_addr = le32_to_cpu(iface->txLoAddr); |
1323 | tp->card_state = Sleeping; | 1312 | tp->card_state = Sleeping; |
1324 | smp_wmb(); | ||
1325 | 1313 | ||
1326 | tp->offload = TYPHOON_OFFLOAD_IP_CHKSUM | TYPHOON_OFFLOAD_TCP_CHKSUM; | 1314 | tp->offload = TYPHOON_OFFLOAD_IP_CHKSUM | TYPHOON_OFFLOAD_TCP_CHKSUM; |
1327 | tp->offload |= TYPHOON_OFFLOAD_UDP_CHKSUM | TSO_OFFLOAD_ON; | 1315 | tp->offload |= TYPHOON_OFFLOAD_UDP_CHKSUM | TSO_OFFLOAD_ON; |
1328 | 1316 | ||
1329 | spin_lock_init(&tp->command_lock); | 1317 | spin_lock_init(&tp->command_lock); |
1330 | spin_lock_init(&tp->state_lock); | 1318 | spin_lock_init(&tp->state_lock); |
1319 | |||
1320 | /* Force the writes to the shared memory area out before continuing. */ | ||
1321 | wmb(); | ||
1331 | } | 1322 | } |
1332 | 1323 | ||
1333 | static void | 1324 | static void |
@@ -1365,8 +1356,8 @@ typhoon_request_firmware(struct typhoon *tp) | |||
1365 | 1356 | ||
1366 | err = request_firmware(&typhoon_fw, FIRMWARE_NAME, &tp->pdev->dev); | 1357 | err = request_firmware(&typhoon_fw, FIRMWARE_NAME, &tp->pdev->dev); |
1367 | if (err) { | 1358 | if (err) { |
1368 | printk(KERN_ERR "%s: Failed to load firmware \"%s\"\n", | 1359 | netdev_err(tp->dev, "Failed to load firmware \"%s\"\n", |
1369 | tp->name, FIRMWARE_NAME); | 1360 | FIRMWARE_NAME); |
1370 | return err; | 1361 | return err; |
1371 | } | 1362 | } |
1372 | 1363 | ||
@@ -1401,7 +1392,7 @@ typhoon_request_firmware(struct typhoon *tp) | |||
1401 | return 0; | 1392 | return 0; |
1402 | 1393 | ||
1403 | invalid_fw: | 1394 | invalid_fw: |
1404 | printk(KERN_ERR "%s: Invalid firmware image\n", tp->name); | 1395 | netdev_err(tp->dev, "Invalid firmware image\n"); |
1405 | release_firmware(typhoon_fw); | 1396 | release_firmware(typhoon_fw); |
1406 | typhoon_fw = NULL; | 1397 | typhoon_fw = NULL; |
1407 | return -EINVAL; | 1398 | return -EINVAL; |
@@ -1438,7 +1429,7 @@ typhoon_download_firmware(struct typhoon *tp) | |||
1438 | err = -ENOMEM; | 1429 | err = -ENOMEM; |
1439 | dpage = pci_alloc_consistent(pdev, PAGE_SIZE, &dpage_dma); | 1430 | dpage = pci_alloc_consistent(pdev, PAGE_SIZE, &dpage_dma); |
1440 | if(!dpage) { | 1431 | if(!dpage) { |
1441 | printk(KERN_ERR "%s: no DMA mem for firmware\n", tp->name); | 1432 | netdev_err(tp->dev, "no DMA mem for firmware\n"); |
1442 | goto err_out; | 1433 | goto err_out; |
1443 | } | 1434 | } |
1444 | 1435 | ||
@@ -1451,7 +1442,7 @@ typhoon_download_firmware(struct typhoon *tp) | |||
1451 | 1442 | ||
1452 | err = -ETIMEDOUT; | 1443 | err = -ETIMEDOUT; |
1453 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { | 1444 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
1454 | printk(KERN_ERR "%s: card ready timeout\n", tp->name); | 1445 | netdev_err(tp->dev, "card ready timeout\n"); |
1455 | goto err_out_irq; | 1446 | goto err_out_irq; |
1456 | } | 1447 | } |
1457 | 1448 | ||
@@ -1491,8 +1482,7 @@ typhoon_download_firmware(struct typhoon *tp) | |||
1491 | if(typhoon_wait_interrupt(ioaddr) < 0 || | 1482 | if(typhoon_wait_interrupt(ioaddr) < 0 || |
1492 | ioread32(ioaddr + TYPHOON_REG_STATUS) != | 1483 | ioread32(ioaddr + TYPHOON_REG_STATUS) != |
1493 | TYPHOON_STATUS_WAITING_FOR_SEGMENT) { | 1484 | TYPHOON_STATUS_WAITING_FOR_SEGMENT) { |
1494 | printk(KERN_ERR "%s: segment ready timeout\n", | 1485 | netdev_err(tp->dev, "segment ready timeout\n"); |
1495 | tp->name); | ||
1496 | goto err_out_irq; | 1486 | goto err_out_irq; |
1497 | } | 1487 | } |
1498 | 1488 | ||
@@ -1502,8 +1492,8 @@ typhoon_download_firmware(struct typhoon *tp) | |||
1502 | * the checksum, we can do this once, at the end. | 1492 | * the checksum, we can do this once, at the end. |
1503 | */ | 1493 | */ |
1504 | csum = csum_fold(csum_partial_copy_nocheck(image_data, | 1494 | csum = csum_fold(csum_partial_copy_nocheck(image_data, |
1505 | dpage, len, | 1495 | dpage, len, |
1506 | 0)); | 1496 | 0)); |
1507 | 1497 | ||
1508 | iowrite32(len, ioaddr + TYPHOON_REG_BOOT_LENGTH); | 1498 | iowrite32(len, ioaddr + TYPHOON_REG_BOOT_LENGTH); |
1509 | iowrite32(le16_to_cpu((__force __le16)csum), | 1499 | iowrite32(le16_to_cpu((__force __le16)csum), |
@@ -1514,7 +1504,7 @@ typhoon_download_firmware(struct typhoon *tp) | |||
1514 | iowrite32(dpage_dma, ioaddr + TYPHOON_REG_BOOT_DATA_LO); | 1504 | iowrite32(dpage_dma, ioaddr + TYPHOON_REG_BOOT_DATA_LO); |
1515 | typhoon_post_pci_writes(ioaddr); | 1505 | typhoon_post_pci_writes(ioaddr); |
1516 | iowrite32(TYPHOON_BOOTCMD_SEG_AVAILABLE, | 1506 | iowrite32(TYPHOON_BOOTCMD_SEG_AVAILABLE, |
1517 | ioaddr + TYPHOON_REG_COMMAND); | 1507 | ioaddr + TYPHOON_REG_COMMAND); |
1518 | 1508 | ||
1519 | image_data += len; | 1509 | image_data += len; |
1520 | load_addr += len; | 1510 | load_addr += len; |
@@ -1525,15 +1515,15 @@ typhoon_download_firmware(struct typhoon *tp) | |||
1525 | if(typhoon_wait_interrupt(ioaddr) < 0 || | 1515 | if(typhoon_wait_interrupt(ioaddr) < 0 || |
1526 | ioread32(ioaddr + TYPHOON_REG_STATUS) != | 1516 | ioread32(ioaddr + TYPHOON_REG_STATUS) != |
1527 | TYPHOON_STATUS_WAITING_FOR_SEGMENT) { | 1517 | TYPHOON_STATUS_WAITING_FOR_SEGMENT) { |
1528 | printk(KERN_ERR "%s: final segment ready timeout\n", tp->name); | 1518 | netdev_err(tp->dev, "final segment ready timeout\n"); |
1529 | goto err_out_irq; | 1519 | goto err_out_irq; |
1530 | } | 1520 | } |
1531 | 1521 | ||
1532 | iowrite32(TYPHOON_BOOTCMD_DNLD_COMPLETE, ioaddr + TYPHOON_REG_COMMAND); | 1522 | iowrite32(TYPHOON_BOOTCMD_DNLD_COMPLETE, ioaddr + TYPHOON_REG_COMMAND); |
1533 | 1523 | ||
1534 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { | 1524 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { |
1535 | printk(KERN_ERR "%s: boot ready timeout, status 0x%0x\n", | 1525 | netdev_err(tp->dev, "boot ready timeout, status 0x%0x\n", |
1536 | tp->name, ioread32(ioaddr + TYPHOON_REG_STATUS)); | 1526 | ioread32(ioaddr + TYPHOON_REG_STATUS)); |
1537 | goto err_out_irq; | 1527 | goto err_out_irq; |
1538 | } | 1528 | } |
1539 | 1529 | ||
@@ -1555,7 +1545,7 @@ typhoon_boot_3XP(struct typhoon *tp, u32 initial_status) | |||
1555 | void __iomem *ioaddr = tp->ioaddr; | 1545 | void __iomem *ioaddr = tp->ioaddr; |
1556 | 1546 | ||
1557 | if(typhoon_wait_status(ioaddr, initial_status) < 0) { | 1547 | if(typhoon_wait_status(ioaddr, initial_status) < 0) { |
1558 | printk(KERN_ERR "%s: boot ready timeout\n", tp->name); | 1548 | netdev_err(tp->dev, "boot ready timeout\n"); |
1559 | goto out_timeout; | 1549 | goto out_timeout; |
1560 | } | 1550 | } |
1561 | 1551 | ||
@@ -1566,8 +1556,8 @@ typhoon_boot_3XP(struct typhoon *tp, u32 initial_status) | |||
1566 | ioaddr + TYPHOON_REG_COMMAND); | 1556 | ioaddr + TYPHOON_REG_COMMAND); |
1567 | 1557 | ||
1568 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_RUNNING) < 0) { | 1558 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_RUNNING) < 0) { |
1569 | printk(KERN_ERR "%s: boot finish timeout (status 0x%x)\n", | 1559 | netdev_err(tp->dev, "boot finish timeout (status 0x%x)\n", |
1570 | tp->name, ioread32(ioaddr + TYPHOON_REG_STATUS)); | 1560 | ioread32(ioaddr + TYPHOON_REG_STATUS)); |
1571 | goto out_timeout; | 1561 | goto out_timeout; |
1572 | } | 1562 | } |
1573 | 1563 | ||
@@ -1769,8 +1759,8 @@ typhoon_rx(struct typhoon *tp, struct basic_ring *rxRing, volatile __le32 * read | |||
1769 | csum_bits = rx->rxStatus & (TYPHOON_RX_IP_CHK_GOOD | | 1759 | csum_bits = rx->rxStatus & (TYPHOON_RX_IP_CHK_GOOD | |
1770 | TYPHOON_RX_UDP_CHK_GOOD | TYPHOON_RX_TCP_CHK_GOOD); | 1760 | TYPHOON_RX_UDP_CHK_GOOD | TYPHOON_RX_TCP_CHK_GOOD); |
1771 | if(csum_bits == | 1761 | if(csum_bits == |
1772 | (TYPHOON_RX_IP_CHK_GOOD | TYPHOON_RX_TCP_CHK_GOOD) | 1762 | (TYPHOON_RX_IP_CHK_GOOD | TYPHOON_RX_TCP_CHK_GOOD) || |
1773 | || csum_bits == | 1763 | csum_bits == |
1774 | (TYPHOON_RX_IP_CHK_GOOD | TYPHOON_RX_UDP_CHK_GOOD)) { | 1764 | (TYPHOON_RX_IP_CHK_GOOD | TYPHOON_RX_UDP_CHK_GOOD)) { |
1775 | new_skb->ip_summed = CHECKSUM_UNNECESSARY; | 1765 | new_skb->ip_summed = CHECKSUM_UNNECESSARY; |
1776 | } else | 1766 | } else |
@@ -1866,8 +1856,7 @@ typhoon_interrupt(int irq, void *dev_instance) | |||
1866 | typhoon_post_pci_writes(ioaddr); | 1856 | typhoon_post_pci_writes(ioaddr); |
1867 | __napi_schedule(&tp->napi); | 1857 | __napi_schedule(&tp->napi); |
1868 | } else { | 1858 | } else { |
1869 | printk(KERN_ERR "%s: Error, poll already scheduled\n", | 1859 | netdev_err(dev, "Error, poll already scheduled\n"); |
1870 | dev->name); | ||
1871 | } | 1860 | } |
1872 | return IRQ_HANDLED; | 1861 | return IRQ_HANDLED; |
1873 | } | 1862 | } |
@@ -1900,16 +1889,15 @@ typhoon_sleep(struct typhoon *tp, pci_power_t state, __le16 events) | |||
1900 | xp_cmd.parm1 = events; | 1889 | xp_cmd.parm1 = events; |
1901 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); | 1890 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
1902 | if(err < 0) { | 1891 | if(err < 0) { |
1903 | printk(KERN_ERR "%s: typhoon_sleep(): wake events cmd err %d\n", | 1892 | netdev_err(tp->dev, "typhoon_sleep(): wake events cmd err %d\n", |
1904 | tp->name, err); | 1893 | err); |
1905 | return err; | 1894 | return err; |
1906 | } | 1895 | } |
1907 | 1896 | ||
1908 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_GOTO_SLEEP); | 1897 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_GOTO_SLEEP); |
1909 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); | 1898 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
1910 | if(err < 0) { | 1899 | if(err < 0) { |
1911 | printk(KERN_ERR "%s: typhoon_sleep(): sleep cmd err %d\n", | 1900 | netdev_err(tp->dev, "typhoon_sleep(): sleep cmd err %d\n", err); |
1912 | tp->name, err); | ||
1913 | return err; | 1901 | return err; |
1914 | } | 1902 | } |
1915 | 1903 | ||
@@ -1960,12 +1948,12 @@ typhoon_start_runtime(struct typhoon *tp) | |||
1960 | 1948 | ||
1961 | err = typhoon_download_firmware(tp); | 1949 | err = typhoon_download_firmware(tp); |
1962 | if(err < 0) { | 1950 | if(err < 0) { |
1963 | printk("%s: cannot load runtime on 3XP\n", tp->name); | 1951 | netdev_err(tp->dev, "cannot load runtime on 3XP\n"); |
1964 | goto error_out; | 1952 | goto error_out; |
1965 | } | 1953 | } |
1966 | 1954 | ||
1967 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { | 1955 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { |
1968 | printk("%s: cannot boot 3XP\n", tp->name); | 1956 | netdev_err(tp->dev, "cannot boot 3XP\n"); |
1969 | err = -EIO; | 1957 | err = -EIO; |
1970 | goto error_out; | 1958 | goto error_out; |
1971 | } | 1959 | } |
@@ -2069,9 +2057,7 @@ typhoon_stop_runtime(struct typhoon *tp, int wait_type) | |||
2069 | } | 2057 | } |
2070 | 2058 | ||
2071 | if(i == TYPHOON_WAIT_TIMEOUT) | 2059 | if(i == TYPHOON_WAIT_TIMEOUT) |
2072 | printk(KERN_ERR | 2060 | netdev_err(tp->dev, "halt timed out waiting for Tx to complete\n"); |
2073 | "%s: halt timed out waiting for Tx to complete\n", | ||
2074 | tp->name); | ||
2075 | 2061 | ||
2076 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_TX_DISABLE); | 2062 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_TX_DISABLE); |
2077 | typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); | 2063 | typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
@@ -2088,11 +2074,10 @@ typhoon_stop_runtime(struct typhoon *tp, int wait_type) | |||
2088 | typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); | 2074 | typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
2089 | 2075 | ||
2090 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_HALTED) < 0) | 2076 | if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_HALTED) < 0) |
2091 | printk(KERN_ERR "%s: timed out waiting for 3XP to halt\n", | 2077 | netdev_err(tp->dev, "timed out waiting for 3XP to halt\n"); |
2092 | tp->name); | ||
2093 | 2078 | ||
2094 | if(typhoon_reset(ioaddr, wait_type) < 0) { | 2079 | if(typhoon_reset(ioaddr, wait_type) < 0) { |
2095 | printk(KERN_ERR "%s: unable to reset 3XP\n", tp->name); | 2080 | netdev_err(tp->dev, "unable to reset 3XP\n"); |
2096 | return -ETIMEDOUT; | 2081 | return -ETIMEDOUT; |
2097 | } | 2082 | } |
2098 | 2083 | ||
@@ -2111,9 +2096,8 @@ typhoon_tx_timeout(struct net_device *dev) | |||
2111 | struct typhoon *tp = netdev_priv(dev); | 2096 | struct typhoon *tp = netdev_priv(dev); |
2112 | 2097 | ||
2113 | if(typhoon_reset(tp->ioaddr, WaitNoSleep) < 0) { | 2098 | if(typhoon_reset(tp->ioaddr, WaitNoSleep) < 0) { |
2114 | printk(KERN_WARNING "%s: could not reset in tx timeout\n", | 2099 | netdev_warn(dev, "could not reset in tx timeout\n"); |
2115 | dev->name); | 2100 | goto truly_dead; |
2116 | goto truely_dead; | ||
2117 | } | 2101 | } |
2118 | 2102 | ||
2119 | /* If we ever start using the Hi ring, it will need cleaning too */ | 2103 | /* If we ever start using the Hi ring, it will need cleaning too */ |
@@ -2121,15 +2105,14 @@ typhoon_tx_timeout(struct net_device *dev) | |||
2121 | typhoon_free_rx_rings(tp); | 2105 | typhoon_free_rx_rings(tp); |
2122 | 2106 | ||
2123 | if(typhoon_start_runtime(tp) < 0) { | 2107 | if(typhoon_start_runtime(tp) < 0) { |
2124 | printk(KERN_ERR "%s: could not start runtime in tx timeout\n", | 2108 | netdev_err(dev, "could not start runtime in tx timeout\n"); |
2125 | dev->name); | 2109 | goto truly_dead; |
2126 | goto truely_dead; | ||
2127 | } | 2110 | } |
2128 | 2111 | ||
2129 | netif_wake_queue(dev); | 2112 | netif_wake_queue(dev); |
2130 | return; | 2113 | return; |
2131 | 2114 | ||
2132 | truely_dead: | 2115 | truly_dead: |
2133 | /* Reset the hardware, and turn off carrier to avoid more timeouts */ | 2116 | /* Reset the hardware, and turn off carrier to avoid more timeouts */ |
2134 | typhoon_reset(tp->ioaddr, NoWait); | 2117 | typhoon_reset(tp->ioaddr, NoWait); |
2135 | netif_carrier_off(dev); | 2118 | netif_carrier_off(dev); |
@@ -2147,11 +2130,11 @@ typhoon_open(struct net_device *dev) | |||
2147 | 2130 | ||
2148 | err = typhoon_wakeup(tp, WaitSleep); | 2131 | err = typhoon_wakeup(tp, WaitSleep); |
2149 | if(err < 0) { | 2132 | if(err < 0) { |
2150 | printk(KERN_ERR "%s: unable to wakeup device\n", dev->name); | 2133 | netdev_err(dev, "unable to wakeup device\n"); |
2151 | goto out_sleep; | 2134 | goto out_sleep; |
2152 | } | 2135 | } |
2153 | 2136 | ||
2154 | err = request_irq(dev->irq, &typhoon_interrupt, IRQF_SHARED, | 2137 | err = request_irq(dev->irq, typhoon_interrupt, IRQF_SHARED, |
2155 | dev->name, dev); | 2138 | dev->name, dev); |
2156 | if(err < 0) | 2139 | if(err < 0) |
2157 | goto out_sleep; | 2140 | goto out_sleep; |
@@ -2172,14 +2155,13 @@ out_irq: | |||
2172 | 2155 | ||
2173 | out_sleep: | 2156 | out_sleep: |
2174 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { | 2157 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
2175 | printk(KERN_ERR "%s: unable to reboot into sleep img\n", | 2158 | netdev_err(dev, "unable to reboot into sleep img\n"); |
2176 | dev->name); | ||
2177 | typhoon_reset(tp->ioaddr, NoWait); | 2159 | typhoon_reset(tp->ioaddr, NoWait); |
2178 | goto out; | 2160 | goto out; |
2179 | } | 2161 | } |
2180 | 2162 | ||
2181 | if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) | 2163 | if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) |
2182 | printk(KERN_ERR "%s: unable to go back to sleep\n", dev->name); | 2164 | netdev_err(dev, "unable to go back to sleep\n"); |
2183 | 2165 | ||
2184 | out: | 2166 | out: |
2185 | return err; | 2167 | return err; |
@@ -2194,7 +2176,7 @@ typhoon_close(struct net_device *dev) | |||
2194 | napi_disable(&tp->napi); | 2176 | napi_disable(&tp->napi); |
2195 | 2177 | ||
2196 | if(typhoon_stop_runtime(tp, WaitSleep) < 0) | 2178 | if(typhoon_stop_runtime(tp, WaitSleep) < 0) |
2197 | printk(KERN_ERR "%s: unable to stop runtime\n", dev->name); | 2179 | netdev_err(dev, "unable to stop runtime\n"); |
2198 | 2180 | ||
2199 | /* Make sure there is no irq handler running on a different CPU. */ | 2181 | /* Make sure there is no irq handler running on a different CPU. */ |
2200 | free_irq(dev->irq, dev); | 2182 | free_irq(dev->irq, dev); |
@@ -2203,10 +2185,10 @@ typhoon_close(struct net_device *dev) | |||
2203 | typhoon_init_rings(tp); | 2185 | typhoon_init_rings(tp); |
2204 | 2186 | ||
2205 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) | 2187 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) |
2206 | printk(KERN_ERR "%s: unable to boot sleep image\n", dev->name); | 2188 | netdev_err(dev, "unable to boot sleep image\n"); |
2207 | 2189 | ||
2208 | if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) | 2190 | if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) |
2209 | printk(KERN_ERR "%s: unable to put card to sleep\n", dev->name); | 2191 | netdev_err(dev, "unable to put card to sleep\n"); |
2210 | 2192 | ||
2211 | return 0; | 2193 | return 0; |
2212 | } | 2194 | } |
@@ -2224,14 +2206,12 @@ typhoon_resume(struct pci_dev *pdev) | |||
2224 | return 0; | 2206 | return 0; |
2225 | 2207 | ||
2226 | if(typhoon_wakeup(tp, WaitNoSleep) < 0) { | 2208 | if(typhoon_wakeup(tp, WaitNoSleep) < 0) { |
2227 | printk(KERN_ERR "%s: critical: could not wake up in resume\n", | 2209 | netdev_err(dev, "critical: could not wake up in resume\n"); |
2228 | dev->name); | ||
2229 | goto reset; | 2210 | goto reset; |
2230 | } | 2211 | } |
2231 | 2212 | ||
2232 | if(typhoon_start_runtime(tp) < 0) { | 2213 | if(typhoon_start_runtime(tp) < 0) { |
2233 | printk(KERN_ERR "%s: critical: could not start runtime in " | 2214 | netdev_err(dev, "critical: could not start runtime in resume\n"); |
2234 | "resume\n", dev->name); | ||
2235 | goto reset; | 2215 | goto reset; |
2236 | } | 2216 | } |
2237 | 2217 | ||
@@ -2258,8 +2238,7 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2258 | spin_lock_bh(&tp->state_lock); | 2238 | spin_lock_bh(&tp->state_lock); |
2259 | if(tp->vlgrp && tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) { | 2239 | if(tp->vlgrp && tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) { |
2260 | spin_unlock_bh(&tp->state_lock); | 2240 | spin_unlock_bh(&tp->state_lock); |
2261 | printk(KERN_ERR "%s: cannot do WAKE_MAGIC with VLANS\n", | 2241 | netdev_err(dev, "cannot do WAKE_MAGIC with VLANS\n"); |
2262 | dev->name); | ||
2263 | return -EBUSY; | 2242 | return -EBUSY; |
2264 | } | 2243 | } |
2265 | spin_unlock_bh(&tp->state_lock); | 2244 | spin_unlock_bh(&tp->state_lock); |
@@ -2267,7 +2246,7 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2267 | netif_device_detach(dev); | 2246 | netif_device_detach(dev); |
2268 | 2247 | ||
2269 | if(typhoon_stop_runtime(tp, WaitNoSleep) < 0) { | 2248 | if(typhoon_stop_runtime(tp, WaitNoSleep) < 0) { |
2270 | printk(KERN_ERR "%s: unable to stop runtime\n", dev->name); | 2249 | netdev_err(dev, "unable to stop runtime\n"); |
2271 | goto need_resume; | 2250 | goto need_resume; |
2272 | } | 2251 | } |
2273 | 2252 | ||
@@ -2275,7 +2254,7 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2275 | typhoon_init_rings(tp); | 2254 | typhoon_init_rings(tp); |
2276 | 2255 | ||
2277 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { | 2256 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
2278 | printk(KERN_ERR "%s: unable to boot sleep image\n", dev->name); | 2257 | netdev_err(dev, "unable to boot sleep image\n"); |
2279 | goto need_resume; | 2258 | goto need_resume; |
2280 | } | 2259 | } |
2281 | 2260 | ||
@@ -2283,21 +2262,19 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2283 | xp_cmd.parm1 = cpu_to_le16(ntohs(*(__be16 *)&dev->dev_addr[0])); | 2262 | xp_cmd.parm1 = cpu_to_le16(ntohs(*(__be16 *)&dev->dev_addr[0])); |
2284 | xp_cmd.parm2 = cpu_to_le32(ntohl(*(__be32 *)&dev->dev_addr[2])); | 2263 | xp_cmd.parm2 = cpu_to_le32(ntohl(*(__be32 *)&dev->dev_addr[2])); |
2285 | if(typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { | 2264 | if(typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { |
2286 | printk(KERN_ERR "%s: unable to set mac address in suspend\n", | 2265 | netdev_err(dev, "unable to set mac address in suspend\n"); |
2287 | dev->name); | ||
2288 | goto need_resume; | 2266 | goto need_resume; |
2289 | } | 2267 | } |
2290 | 2268 | ||
2291 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_RX_FILTER); | 2269 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_RX_FILTER); |
2292 | xp_cmd.parm1 = TYPHOON_RX_FILTER_DIRECTED | TYPHOON_RX_FILTER_BROADCAST; | 2270 | xp_cmd.parm1 = TYPHOON_RX_FILTER_DIRECTED | TYPHOON_RX_FILTER_BROADCAST; |
2293 | if(typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { | 2271 | if(typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { |
2294 | printk(KERN_ERR "%s: unable to set rx filter in suspend\n", | 2272 | netdev_err(dev, "unable to set rx filter in suspend\n"); |
2295 | dev->name); | ||
2296 | goto need_resume; | 2273 | goto need_resume; |
2297 | } | 2274 | } |
2298 | 2275 | ||
2299 | if(typhoon_sleep(tp, pci_choose_state(pdev, state), tp->wol_events) < 0) { | 2276 | if(typhoon_sleep(tp, pci_choose_state(pdev, state), tp->wol_events) < 0) { |
2300 | printk(KERN_ERR "%s: unable to put card to sleep\n", dev->name); | 2277 | netdev_err(dev, "unable to put card to sleep\n"); |
2301 | goto need_resume; | 2278 | goto need_resume; |
2302 | } | 2279 | } |
2303 | 2280 | ||
@@ -2351,7 +2328,7 @@ out_unmap: | |||
2351 | 2328 | ||
2352 | out: | 2329 | out: |
2353 | if(!mode) | 2330 | if(!mode) |
2354 | printk(KERN_INFO PFX "falling back to port IO\n"); | 2331 | pr_info("%s: falling back to port IO\n", pci_name(pdev)); |
2355 | return mode; | 2332 | return mode; |
2356 | } | 2333 | } |
2357 | 2334 | ||
@@ -2371,7 +2348,6 @@ static const struct net_device_ops typhoon_netdev_ops = { | |||
2371 | static int __devinit | 2348 | static int __devinit |
2372 | typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 2349 | typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
2373 | { | 2350 | { |
2374 | static int did_version = 0; | ||
2375 | struct net_device *dev; | 2351 | struct net_device *dev; |
2376 | struct typhoon *tp; | 2352 | struct typhoon *tp; |
2377 | int card_id = (int) ent->driver_data; | 2353 | int card_id = (int) ent->driver_data; |
@@ -2381,14 +2357,11 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2381 | struct cmd_desc xp_cmd; | 2357 | struct cmd_desc xp_cmd; |
2382 | struct resp_desc xp_resp[3]; | 2358 | struct resp_desc xp_resp[3]; |
2383 | int err = 0; | 2359 | int err = 0; |
2384 | 2360 | const char *err_msg; | |
2385 | if(!did_version++) | ||
2386 | printk(KERN_INFO "%s", version); | ||
2387 | 2361 | ||
2388 | dev = alloc_etherdev(sizeof(*tp)); | 2362 | dev = alloc_etherdev(sizeof(*tp)); |
2389 | if(dev == NULL) { | 2363 | if(dev == NULL) { |
2390 | printk(ERR_PFX "%s: unable to alloc new net device\n", | 2364 | err_msg = "unable to alloc new net device"; |
2391 | pci_name(pdev)); | ||
2392 | err = -ENOMEM; | 2365 | err = -ENOMEM; |
2393 | goto error_out; | 2366 | goto error_out; |
2394 | } | 2367 | } |
@@ -2396,57 +2369,48 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2396 | 2369 | ||
2397 | err = pci_enable_device(pdev); | 2370 | err = pci_enable_device(pdev); |
2398 | if(err < 0) { | 2371 | if(err < 0) { |
2399 | printk(ERR_PFX "%s: unable to enable device\n", | 2372 | err_msg = "unable to enable device"; |
2400 | pci_name(pdev)); | ||
2401 | goto error_out_dev; | 2373 | goto error_out_dev; |
2402 | } | 2374 | } |
2403 | 2375 | ||
2404 | err = pci_set_mwi(pdev); | 2376 | err = pci_set_mwi(pdev); |
2405 | if(err < 0) { | 2377 | if(err < 0) { |
2406 | printk(ERR_PFX "%s: unable to set MWI\n", pci_name(pdev)); | 2378 | err_msg = "unable to set MWI"; |
2407 | goto error_out_disable; | 2379 | goto error_out_disable; |
2408 | } | 2380 | } |
2409 | 2381 | ||
2410 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 2382 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
2411 | if(err < 0) { | 2383 | if(err < 0) { |
2412 | printk(ERR_PFX "%s: No usable DMA configuration\n", | 2384 | err_msg = "No usable DMA configuration"; |
2413 | pci_name(pdev)); | ||
2414 | goto error_out_mwi; | 2385 | goto error_out_mwi; |
2415 | } | 2386 | } |
2416 | 2387 | ||
2417 | /* sanity checks on IO and MMIO BARs | 2388 | /* sanity checks on IO and MMIO BARs |
2418 | */ | 2389 | */ |
2419 | if(!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) { | 2390 | if(!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) { |
2420 | printk(ERR_PFX | 2391 | err_msg = "region #1 not a PCI IO resource, aborting"; |
2421 | "%s: region #1 not a PCI IO resource, aborting\n", | ||
2422 | pci_name(pdev)); | ||
2423 | err = -ENODEV; | 2392 | err = -ENODEV; |
2424 | goto error_out_mwi; | 2393 | goto error_out_mwi; |
2425 | } | 2394 | } |
2426 | if(pci_resource_len(pdev, 0) < 128) { | 2395 | if(pci_resource_len(pdev, 0) < 128) { |
2427 | printk(ERR_PFX "%s: Invalid PCI IO region size, aborting\n", | 2396 | err_msg = "Invalid PCI IO region size, aborting"; |
2428 | pci_name(pdev)); | ||
2429 | err = -ENODEV; | 2397 | err = -ENODEV; |
2430 | goto error_out_mwi; | 2398 | goto error_out_mwi; |
2431 | } | 2399 | } |
2432 | if(!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { | 2400 | if(!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { |
2433 | printk(ERR_PFX | 2401 | err_msg = "region #1 not a PCI MMIO resource, aborting"; |
2434 | "%s: region #1 not a PCI MMIO resource, aborting\n", | ||
2435 | pci_name(pdev)); | ||
2436 | err = -ENODEV; | 2402 | err = -ENODEV; |
2437 | goto error_out_mwi; | 2403 | goto error_out_mwi; |
2438 | } | 2404 | } |
2439 | if(pci_resource_len(pdev, 1) < 128) { | 2405 | if(pci_resource_len(pdev, 1) < 128) { |
2440 | printk(ERR_PFX "%s: Invalid PCI MMIO region size, aborting\n", | 2406 | err_msg = "Invalid PCI MMIO region size, aborting"; |
2441 | pci_name(pdev)); | ||
2442 | err = -ENODEV; | 2407 | err = -ENODEV; |
2443 | goto error_out_mwi; | 2408 | goto error_out_mwi; |
2444 | } | 2409 | } |
2445 | 2410 | ||
2446 | err = pci_request_regions(pdev, "typhoon"); | 2411 | err = pci_request_regions(pdev, KBUILD_MODNAME); |
2447 | if(err < 0) { | 2412 | if(err < 0) { |
2448 | printk(ERR_PFX "%s: could not request regions\n", | 2413 | err_msg = "could not request regions"; |
2449 | pci_name(pdev)); | ||
2450 | goto error_out_mwi; | 2414 | goto error_out_mwi; |
2451 | } | 2415 | } |
2452 | 2416 | ||
@@ -2457,8 +2421,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2457 | 2421 | ||
2458 | ioaddr = pci_iomap(pdev, use_mmio, 128); | 2422 | ioaddr = pci_iomap(pdev, use_mmio, 128); |
2459 | if (!ioaddr) { | 2423 | if (!ioaddr) { |
2460 | printk(ERR_PFX "%s: cannot remap registers, aborting\n", | 2424 | err_msg = "cannot remap registers, aborting"; |
2461 | pci_name(pdev)); | ||
2462 | err = -EIO; | 2425 | err = -EIO; |
2463 | goto error_out_regions; | 2426 | goto error_out_regions; |
2464 | } | 2427 | } |
@@ -2468,8 +2431,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2468 | shared = pci_alloc_consistent(pdev, sizeof(struct typhoon_shared), | 2431 | shared = pci_alloc_consistent(pdev, sizeof(struct typhoon_shared), |
2469 | &shared_dma); | 2432 | &shared_dma); |
2470 | if(!shared) { | 2433 | if(!shared) { |
2471 | printk(ERR_PFX "%s: could not allocate DMA memory\n", | 2434 | err_msg = "could not allocate DMA memory"; |
2472 | pci_name(pdev)); | ||
2473 | err = -ENOMEM; | 2435 | err = -ENOMEM; |
2474 | goto error_out_remap; | 2436 | goto error_out_remap; |
2475 | } | 2437 | } |
@@ -2492,7 +2454,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2492 | * 5) Put the card to sleep. | 2454 | * 5) Put the card to sleep. |
2493 | */ | 2455 | */ |
2494 | if (typhoon_reset(ioaddr, WaitSleep) < 0) { | 2456 | if (typhoon_reset(ioaddr, WaitSleep) < 0) { |
2495 | printk(ERR_PFX "%s: could not reset 3XP\n", pci_name(pdev)); | 2457 | err_msg = "could not reset 3XP"; |
2496 | err = -EIO; | 2458 | err = -EIO; |
2497 | goto error_out_dma; | 2459 | goto error_out_dma; |
2498 | } | 2460 | } |
@@ -2504,26 +2466,18 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2504 | pci_set_master(pdev); | 2466 | pci_set_master(pdev); |
2505 | pci_save_state(pdev); | 2467 | pci_save_state(pdev); |
2506 | 2468 | ||
2507 | /* dev->name is not valid until we register, but we need to | ||
2508 | * use some common routines to initialize the card. So that those | ||
2509 | * routines print the right name, we keep our oun pointer to the name | ||
2510 | */ | ||
2511 | tp->name = pci_name(pdev); | ||
2512 | |||
2513 | typhoon_init_interface(tp); | 2469 | typhoon_init_interface(tp); |
2514 | typhoon_init_rings(tp); | 2470 | typhoon_init_rings(tp); |
2515 | 2471 | ||
2516 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { | 2472 | if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
2517 | printk(ERR_PFX "%s: cannot boot 3XP sleep image\n", | 2473 | err_msg = "cannot boot 3XP sleep image"; |
2518 | pci_name(pdev)); | ||
2519 | err = -EIO; | 2474 | err = -EIO; |
2520 | goto error_out_reset; | 2475 | goto error_out_reset; |
2521 | } | 2476 | } |
2522 | 2477 | ||
2523 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_MAC_ADDRESS); | 2478 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_MAC_ADDRESS); |
2524 | if(typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp) < 0) { | 2479 | if(typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp) < 0) { |
2525 | printk(ERR_PFX "%s: cannot read MAC address\n", | 2480 | err_msg = "cannot read MAC address"; |
2526 | pci_name(pdev)); | ||
2527 | err = -EIO; | 2481 | err = -EIO; |
2528 | goto error_out_reset; | 2482 | goto error_out_reset; |
2529 | } | 2483 | } |
@@ -2532,8 +2486,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2532 | *(__be32 *)&dev->dev_addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2)); | 2486 | *(__be32 *)&dev->dev_addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2)); |
2533 | 2487 | ||
2534 | if(!is_valid_ether_addr(dev->dev_addr)) { | 2488 | if(!is_valid_ether_addr(dev->dev_addr)) { |
2535 | printk(ERR_PFX "%s: Could not obtain valid ethernet address, " | 2489 | err_msg = "Could not obtain valid ethernet address, aborting"; |
2536 | "aborting\n", pci_name(pdev)); | ||
2537 | goto error_out_reset; | 2490 | goto error_out_reset; |
2538 | } | 2491 | } |
2539 | 2492 | ||
@@ -2542,8 +2495,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2542 | */ | 2495 | */ |
2543 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS); | 2496 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS); |
2544 | if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) { | 2497 | if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) { |
2545 | printk(ERR_PFX "%s: Could not get Sleep Image version\n", | 2498 | err_msg = "Could not get Sleep Image version"; |
2546 | pci_name(pdev)); | ||
2547 | goto error_out_reset; | 2499 | goto error_out_reset; |
2548 | } | 2500 | } |
2549 | 2501 | ||
@@ -2560,8 +2512,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2560 | tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET; | 2512 | tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET; |
2561 | 2513 | ||
2562 | if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) { | 2514 | if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) { |
2563 | printk(ERR_PFX "%s: cannot put adapter to sleep\n", | 2515 | err_msg = "cannot put adapter to sleep"; |
2564 | pci_name(pdev)); | ||
2565 | err = -EIO; | 2516 | err = -EIO; |
2566 | goto error_out_reset; | 2517 | goto error_out_reset; |
2567 | } | 2518 | } |
@@ -2580,19 +2531,18 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2580 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | 2531 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; |
2581 | dev->features |= NETIF_F_TSO; | 2532 | dev->features |= NETIF_F_TSO; |
2582 | 2533 | ||
2583 | if(register_netdev(dev) < 0) | 2534 | if(register_netdev(dev) < 0) { |
2535 | err_msg = "unable to register netdev"; | ||
2584 | goto error_out_reset; | 2536 | goto error_out_reset; |
2585 | 2537 | } | |
2586 | /* fixup our local name */ | ||
2587 | tp->name = dev->name; | ||
2588 | 2538 | ||
2589 | pci_set_drvdata(pdev, dev); | 2539 | pci_set_drvdata(pdev, dev); |
2590 | 2540 | ||
2591 | printk(KERN_INFO "%s: %s at %s 0x%llx, %pM\n", | 2541 | netdev_info(dev, "%s at %s 0x%llx, %pM\n", |
2592 | dev->name, typhoon_card_info[card_id].name, | 2542 | typhoon_card_info[card_id].name, |
2593 | use_mmio ? "MMIO" : "IO", | 2543 | use_mmio ? "MMIO" : "IO", |
2594 | (unsigned long long)pci_resource_start(pdev, use_mmio), | 2544 | (unsigned long long)pci_resource_start(pdev, use_mmio), |
2595 | dev->dev_addr); | 2545 | dev->dev_addr); |
2596 | 2546 | ||
2597 | /* xp_resp still contains the response to the READ_VERSIONS command. | 2547 | /* xp_resp still contains the response to the READ_VERSIONS command. |
2598 | * For debugging, let the user know what version he has. | 2548 | * For debugging, let the user know what version he has. |
@@ -2602,23 +2552,20 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2602 | * of version is Month/Day of build. | 2552 | * of version is Month/Day of build. |
2603 | */ | 2553 | */ |
2604 | u16 monthday = le32_to_cpu(xp_resp[0].parm2) & 0xffff; | 2554 | u16 monthday = le32_to_cpu(xp_resp[0].parm2) & 0xffff; |
2605 | printk(KERN_INFO "%s: Typhoon 1.0 Sleep Image built " | 2555 | netdev_info(dev, "Typhoon 1.0 Sleep Image built %02u/%02u/2000\n", |
2606 | "%02u/%02u/2000\n", dev->name, monthday >> 8, | 2556 | monthday >> 8, monthday & 0xff); |
2607 | monthday & 0xff); | ||
2608 | } else if(xp_resp[0].numDesc == 2) { | 2557 | } else if(xp_resp[0].numDesc == 2) { |
2609 | /* This is the Typhoon 1.1+ type Sleep Image | 2558 | /* This is the Typhoon 1.1+ type Sleep Image |
2610 | */ | 2559 | */ |
2611 | u32 sleep_ver = le32_to_cpu(xp_resp[0].parm2); | 2560 | u32 sleep_ver = le32_to_cpu(xp_resp[0].parm2); |
2612 | u8 *ver_string = (u8 *) &xp_resp[1]; | 2561 | u8 *ver_string = (u8 *) &xp_resp[1]; |
2613 | ver_string[25] = 0; | 2562 | ver_string[25] = 0; |
2614 | printk(KERN_INFO "%s: Typhoon 1.1+ Sleep Image version " | 2563 | netdev_info(dev, "Typhoon 1.1+ Sleep Image version %02x.%03x.%03x %s\n", |
2615 | "%02x.%03x.%03x %s\n", dev->name, sleep_ver >> 24, | 2564 | sleep_ver >> 24, (sleep_ver >> 12) & 0xfff, |
2616 | (sleep_ver >> 12) & 0xfff, sleep_ver & 0xfff, | 2565 | sleep_ver & 0xfff, ver_string); |
2617 | ver_string); | ||
2618 | } else { | 2566 | } else { |
2619 | printk(KERN_WARNING "%s: Unknown Sleep Image version " | 2567 | netdev_warn(dev, "Unknown Sleep Image version (%u:%04x)\n", |
2620 | "(%u:%04x)\n", dev->name, xp_resp[0].numDesc, | 2568 | xp_resp[0].numDesc, le32_to_cpu(xp_resp[0].parm2)); |
2621 | le32_to_cpu(xp_resp[0].parm2)); | ||
2622 | } | 2569 | } |
2623 | 2570 | ||
2624 | return 0; | 2571 | return 0; |
@@ -2640,6 +2587,7 @@ error_out_disable: | |||
2640 | error_out_dev: | 2587 | error_out_dev: |
2641 | free_netdev(dev); | 2588 | free_netdev(dev); |
2642 | error_out: | 2589 | error_out: |
2590 | pr_err("%s: %s\n", pci_name(pdev), err_msg); | ||
2643 | return err; | 2591 | return err; |
2644 | } | 2592 | } |
2645 | 2593 | ||
@@ -2664,7 +2612,7 @@ typhoon_remove_one(struct pci_dev *pdev) | |||
2664 | } | 2612 | } |
2665 | 2613 | ||
2666 | static struct pci_driver typhoon_driver = { | 2614 | static struct pci_driver typhoon_driver = { |
2667 | .name = DRV_MODULE_NAME, | 2615 | .name = KBUILD_MODNAME, |
2668 | .id_table = typhoon_pci_tbl, | 2616 | .id_table = typhoon_pci_tbl, |
2669 | .probe = typhoon_init_one, | 2617 | .probe = typhoon_init_one, |
2670 | .remove = __devexit_p(typhoon_remove_one), | 2618 | .remove = __devexit_p(typhoon_remove_one), |