aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/forcedeth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/forcedeth.c')
-rw-r--r--drivers/net/forcedeth.c168
1 files changed, 98 insertions, 70 deletions
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index dae30b731342..cfbb7aacfe94 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -128,7 +128,7 @@
128#else 128#else
129#define DRIVERNAPI 129#define DRIVERNAPI
130#endif 130#endif
131#define FORCEDETH_VERSION "0.60" 131#define FORCEDETH_VERSION "0.61"
132#define DRV_NAME "forcedeth" 132#define DRV_NAME "forcedeth"
133 133
134#include <linux/module.h> 134#include <linux/module.h>
@@ -752,7 +752,6 @@ struct fe_priv {
752 752
753 /* General data: 753 /* General data:
754 * Locking: spin_lock(&np->lock); */ 754 * Locking: spin_lock(&np->lock); */
755 struct net_device_stats stats;
756 struct nv_ethtool_stats estats; 755 struct nv_ethtool_stats estats;
757 int in_shutdown; 756 int in_shutdown;
758 u32 linkspeed; 757 u32 linkspeed;
@@ -1505,15 +1504,16 @@ static struct net_device_stats *nv_get_stats(struct net_device *dev)
1505 nv_get_hw_stats(dev); 1504 nv_get_hw_stats(dev);
1506 1505
1507 /* copy to net_device stats */ 1506 /* copy to net_device stats */
1508 np->stats.tx_bytes = np->estats.tx_bytes; 1507 dev->stats.tx_bytes = np->estats.tx_bytes;
1509 np->stats.tx_fifo_errors = np->estats.tx_fifo_errors; 1508 dev->stats.tx_fifo_errors = np->estats.tx_fifo_errors;
1510 np->stats.tx_carrier_errors = np->estats.tx_carrier_errors; 1509 dev->stats.tx_carrier_errors = np->estats.tx_carrier_errors;
1511 np->stats.rx_crc_errors = np->estats.rx_crc_errors; 1510 dev->stats.rx_crc_errors = np->estats.rx_crc_errors;
1512 np->stats.rx_over_errors = np->estats.rx_over_errors; 1511 dev->stats.rx_over_errors = np->estats.rx_over_errors;
1513 np->stats.rx_errors = np->estats.rx_errors_total; 1512 dev->stats.rx_errors = np->estats.rx_errors_total;
1514 np->stats.tx_errors = np->estats.tx_errors_total; 1513 dev->stats.tx_errors = np->estats.tx_errors_total;
1515 } 1514 }
1516 return &np->stats; 1515
1516 return &dev->stats;
1517} 1517}
1518 1518
1519/* 1519/*
@@ -1733,7 +1733,7 @@ static void nv_drain_tx(struct net_device *dev)
1733 np->tx_ring.ex[i].buflow = 0; 1733 np->tx_ring.ex[i].buflow = 0;
1734 } 1734 }
1735 if (nv_release_txskb(dev, &np->tx_skb[i])) 1735 if (nv_release_txskb(dev, &np->tx_skb[i]))
1736 np->stats.tx_dropped++; 1736 dev->stats.tx_dropped++;
1737 } 1737 }
1738} 1738}
1739 1739
@@ -2049,13 +2049,13 @@ static void nv_tx_done(struct net_device *dev)
2049 if (flags & NV_TX_LASTPACKET) { 2049 if (flags & NV_TX_LASTPACKET) {
2050 if (flags & NV_TX_ERROR) { 2050 if (flags & NV_TX_ERROR) {
2051 if (flags & NV_TX_UNDERFLOW) 2051 if (flags & NV_TX_UNDERFLOW)
2052 np->stats.tx_fifo_errors++; 2052 dev->stats.tx_fifo_errors++;
2053 if (flags & NV_TX_CARRIERLOST) 2053 if (flags & NV_TX_CARRIERLOST)
2054 np->stats.tx_carrier_errors++; 2054 dev->stats.tx_carrier_errors++;
2055 np->stats.tx_errors++; 2055 dev->stats.tx_errors++;
2056 } else { 2056 } else {
2057 np->stats.tx_packets++; 2057 dev->stats.tx_packets++;
2058 np->stats.tx_bytes += np->get_tx_ctx->skb->len; 2058 dev->stats.tx_bytes += np->get_tx_ctx->skb->len;
2059 } 2059 }
2060 dev_kfree_skb_any(np->get_tx_ctx->skb); 2060 dev_kfree_skb_any(np->get_tx_ctx->skb);
2061 np->get_tx_ctx->skb = NULL; 2061 np->get_tx_ctx->skb = NULL;
@@ -2064,13 +2064,13 @@ static void nv_tx_done(struct net_device *dev)
2064 if (flags & NV_TX2_LASTPACKET) { 2064 if (flags & NV_TX2_LASTPACKET) {
2065 if (flags & NV_TX2_ERROR) { 2065 if (flags & NV_TX2_ERROR) {
2066 if (flags & NV_TX2_UNDERFLOW) 2066 if (flags & NV_TX2_UNDERFLOW)
2067 np->stats.tx_fifo_errors++; 2067 dev->stats.tx_fifo_errors++;
2068 if (flags & NV_TX2_CARRIERLOST) 2068 if (flags & NV_TX2_CARRIERLOST)
2069 np->stats.tx_carrier_errors++; 2069 dev->stats.tx_carrier_errors++;
2070 np->stats.tx_errors++; 2070 dev->stats.tx_errors++;
2071 } else { 2071 } else {
2072 np->stats.tx_packets++; 2072 dev->stats.tx_packets++;
2073 np->stats.tx_bytes += np->get_tx_ctx->skb->len; 2073 dev->stats.tx_bytes += np->get_tx_ctx->skb->len;
2074 } 2074 }
2075 dev_kfree_skb_any(np->get_tx_ctx->skb); 2075 dev_kfree_skb_any(np->get_tx_ctx->skb);
2076 np->get_tx_ctx->skb = NULL; 2076 np->get_tx_ctx->skb = NULL;
@@ -2107,7 +2107,7 @@ static void nv_tx_done_optimized(struct net_device *dev, int limit)
2107 2107
2108 if (flags & NV_TX2_LASTPACKET) { 2108 if (flags & NV_TX2_LASTPACKET) {
2109 if (!(flags & NV_TX2_ERROR)) 2109 if (!(flags & NV_TX2_ERROR))
2110 np->stats.tx_packets++; 2110 dev->stats.tx_packets++;
2111 dev_kfree_skb_any(np->get_tx_ctx->skb); 2111 dev_kfree_skb_any(np->get_tx_ctx->skb);
2112 np->get_tx_ctx->skb = NULL; 2112 np->get_tx_ctx->skb = NULL;
2113 } 2113 }
@@ -2268,13 +2268,13 @@ static int nv_rx_process(struct net_device *dev, int limit)
2268{ 2268{
2269 struct fe_priv *np = netdev_priv(dev); 2269 struct fe_priv *np = netdev_priv(dev);
2270 u32 flags; 2270 u32 flags;
2271 u32 rx_processed_cnt = 0; 2271 int rx_work = 0;
2272 struct sk_buff *skb; 2272 struct sk_buff *skb;
2273 int len; 2273 int len;
2274 2274
2275 while((np->get_rx.orig != np->put_rx.orig) && 2275 while((np->get_rx.orig != np->put_rx.orig) &&
2276 !((flags = le32_to_cpu(np->get_rx.orig->flaglen)) & NV_RX_AVAIL) && 2276 !((flags = le32_to_cpu(np->get_rx.orig->flaglen)) & NV_RX_AVAIL) &&
2277 (rx_processed_cnt++ < limit)) { 2277 (rx_work < limit)) {
2278 2278
2279 dprintk(KERN_DEBUG "%s: nv_rx_process: flags 0x%x.\n", 2279 dprintk(KERN_DEBUG "%s: nv_rx_process: flags 0x%x.\n",
2280 dev->name, flags); 2280 dev->name, flags);
@@ -2308,7 +2308,7 @@ static int nv_rx_process(struct net_device *dev, int limit)
2308 if (flags & NV_RX_ERROR4) { 2308 if (flags & NV_RX_ERROR4) {
2309 len = nv_getlen(dev, skb->data, len); 2309 len = nv_getlen(dev, skb->data, len);
2310 if (len < 0) { 2310 if (len < 0) {
2311 np->stats.rx_errors++; 2311 dev->stats.rx_errors++;
2312 dev_kfree_skb(skb); 2312 dev_kfree_skb(skb);
2313 goto next_pkt; 2313 goto next_pkt;
2314 } 2314 }
@@ -2322,12 +2322,12 @@ static int nv_rx_process(struct net_device *dev, int limit)
2322 /* the rest are hard errors */ 2322 /* the rest are hard errors */
2323 else { 2323 else {
2324 if (flags & NV_RX_MISSEDFRAME) 2324 if (flags & NV_RX_MISSEDFRAME)
2325 np->stats.rx_missed_errors++; 2325 dev->stats.rx_missed_errors++;
2326 if (flags & NV_RX_CRCERR) 2326 if (flags & NV_RX_CRCERR)
2327 np->stats.rx_crc_errors++; 2327 dev->stats.rx_crc_errors++;
2328 if (flags & NV_RX_OVERFLOW) 2328 if (flags & NV_RX_OVERFLOW)
2329 np->stats.rx_over_errors++; 2329 dev->stats.rx_over_errors++;
2330 np->stats.rx_errors++; 2330 dev->stats.rx_errors++;
2331 dev_kfree_skb(skb); 2331 dev_kfree_skb(skb);
2332 goto next_pkt; 2332 goto next_pkt;
2333 } 2333 }
@@ -2343,7 +2343,7 @@ static int nv_rx_process(struct net_device *dev, int limit)
2343 if (flags & NV_RX2_ERROR4) { 2343 if (flags & NV_RX2_ERROR4) {
2344 len = nv_getlen(dev, skb->data, len); 2344 len = nv_getlen(dev, skb->data, len);
2345 if (len < 0) { 2345 if (len < 0) {
2346 np->stats.rx_errors++; 2346 dev->stats.rx_errors++;
2347 dev_kfree_skb(skb); 2347 dev_kfree_skb(skb);
2348 goto next_pkt; 2348 goto next_pkt;
2349 } 2349 }
@@ -2357,10 +2357,10 @@ static int nv_rx_process(struct net_device *dev, int limit)
2357 /* the rest are hard errors */ 2357 /* the rest are hard errors */
2358 else { 2358 else {
2359 if (flags & NV_RX2_CRCERR) 2359 if (flags & NV_RX2_CRCERR)
2360 np->stats.rx_crc_errors++; 2360 dev->stats.rx_crc_errors++;
2361 if (flags & NV_RX2_OVERFLOW) 2361 if (flags & NV_RX2_OVERFLOW)
2362 np->stats.rx_over_errors++; 2362 dev->stats.rx_over_errors++;
2363 np->stats.rx_errors++; 2363 dev->stats.rx_errors++;
2364 dev_kfree_skb(skb); 2364 dev_kfree_skb(skb);
2365 goto next_pkt; 2365 goto next_pkt;
2366 } 2366 }
@@ -2389,16 +2389,18 @@ static int nv_rx_process(struct net_device *dev, int limit)
2389 netif_rx(skb); 2389 netif_rx(skb);
2390#endif 2390#endif
2391 dev->last_rx = jiffies; 2391 dev->last_rx = jiffies;
2392 np->stats.rx_packets++; 2392 dev->stats.rx_packets++;
2393 np->stats.rx_bytes += len; 2393 dev->stats.rx_bytes += len;
2394next_pkt: 2394next_pkt:
2395 if (unlikely(np->get_rx.orig++ == np->last_rx.orig)) 2395 if (unlikely(np->get_rx.orig++ == np->last_rx.orig))
2396 np->get_rx.orig = np->first_rx.orig; 2396 np->get_rx.orig = np->first_rx.orig;
2397 if (unlikely(np->get_rx_ctx++ == np->last_rx_ctx)) 2397 if (unlikely(np->get_rx_ctx++ == np->last_rx_ctx))
2398 np->get_rx_ctx = np->first_rx_ctx; 2398 np->get_rx_ctx = np->first_rx_ctx;
2399
2400 rx_work++;
2399 } 2401 }
2400 2402
2401 return rx_processed_cnt; 2403 return rx_work;
2402} 2404}
2403 2405
2404static int nv_rx_process_optimized(struct net_device *dev, int limit) 2406static int nv_rx_process_optimized(struct net_device *dev, int limit)
@@ -2505,8 +2507,8 @@ static int nv_rx_process_optimized(struct net_device *dev, int limit)
2505 } 2507 }
2506 2508
2507 dev->last_rx = jiffies; 2509 dev->last_rx = jiffies;
2508 np->stats.rx_packets++; 2510 dev->stats.rx_packets++;
2509 np->stats.rx_bytes += len; 2511 dev->stats.rx_bytes += len;
2510 } else { 2512 } else {
2511 dev_kfree_skb(skb); 2513 dev_kfree_skb(skb);
2512 } 2514 }
@@ -3727,7 +3729,7 @@ static void nv_do_stats_poll(unsigned long data)
3727static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 3729static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
3728{ 3730{
3729 struct fe_priv *np = netdev_priv(dev); 3731 struct fe_priv *np = netdev_priv(dev);
3730 strcpy(info->driver, "forcedeth"); 3732 strcpy(info->driver, DRV_NAME);
3731 strcpy(info->version, FORCEDETH_VERSION); 3733 strcpy(info->version, FORCEDETH_VERSION);
3732 strcpy(info->bus_info, pci_name(np->pci_dev)); 3734 strcpy(info->bus_info, pci_name(np->pci_dev));
3733} 3735}
@@ -4991,6 +4993,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4991 u32 phystate_orig = 0, phystate; 4993 u32 phystate_orig = 0, phystate;
4992 int phyinitialized = 0; 4994 int phyinitialized = 0;
4993 DECLARE_MAC_BUF(mac); 4995 DECLARE_MAC_BUF(mac);
4996 static int printed_version;
4997
4998 if (!printed_version++)
4999 printk(KERN_INFO "%s: Reverse Engineered nForce ethernet"
5000 " driver. Version %s.\n", DRV_NAME, FORCEDETH_VERSION);
4994 5001
4995 dev = alloc_etherdev(sizeof(struct fe_priv)); 5002 dev = alloc_etherdev(sizeof(struct fe_priv));
4996 err = -ENOMEM; 5003 err = -ENOMEM;
@@ -5014,11 +5021,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5014 np->stats_poll.function = &nv_do_stats_poll; /* timer handler */ 5021 np->stats_poll.function = &nv_do_stats_poll; /* timer handler */
5015 5022
5016 err = pci_enable_device(pci_dev); 5023 err = pci_enable_device(pci_dev);
5017 if (err) { 5024 if (err)
5018 printk(KERN_INFO "forcedeth: pci_enable_dev failed (%d) for device %s\n",
5019 err, pci_name(pci_dev));
5020 goto out_free; 5025 goto out_free;
5021 }
5022 5026
5023 pci_set_master(pci_dev); 5027 pci_set_master(pci_dev);
5024 5028
@@ -5047,8 +5051,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5047 } 5051 }
5048 } 5052 }
5049 if (i == DEVICE_COUNT_RESOURCE) { 5053 if (i == DEVICE_COUNT_RESOURCE) {
5050 printk(KERN_INFO "forcedeth: Couldn't find register window for device %s.\n", 5054 dev_printk(KERN_INFO, &pci_dev->dev,
5051 pci_name(pci_dev)); 5055 "Couldn't find register window\n");
5052 goto out_relreg; 5056 goto out_relreg;
5053 } 5057 }
5054 5058
@@ -5061,16 +5065,14 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5061 np->desc_ver = DESC_VER_3; 5065 np->desc_ver = DESC_VER_3;
5062 np->txrxctl_bits = NVREG_TXRXCTL_DESC_3; 5066 np->txrxctl_bits = NVREG_TXRXCTL_DESC_3;
5063 if (dma_64bit) { 5067 if (dma_64bit) {
5064 if (pci_set_dma_mask(pci_dev, DMA_39BIT_MASK)) { 5068 if (pci_set_dma_mask(pci_dev, DMA_39BIT_MASK))
5065 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", 5069 dev_printk(KERN_INFO, &pci_dev->dev,
5066 pci_name(pci_dev)); 5070 "64-bit DMA failed, using 32-bit addressing\n");
5067 } else { 5071 else
5068 dev->features |= NETIF_F_HIGHDMA; 5072 dev->features |= NETIF_F_HIGHDMA;
5069 printk(KERN_INFO "forcedeth: using HIGHDMA\n");
5070 }
5071 if (pci_set_consistent_dma_mask(pci_dev, DMA_39BIT_MASK)) { 5073 if (pci_set_consistent_dma_mask(pci_dev, DMA_39BIT_MASK)) {
5072 printk(KERN_INFO "forcedeth: 64-bit DMA (consistent) failed, using 32-bit ring buffers for device %s.\n", 5074 dev_printk(KERN_INFO, &pci_dev->dev,
5073 pci_name(pci_dev)); 5075 "64-bit DMA (consistent) failed, using 32-bit ring buffers\n");
5074 } 5076 }
5075 } 5077 }
5076 } else if (id->driver_data & DEV_HAS_LARGEDESC) { 5078 } else if (id->driver_data & DEV_HAS_LARGEDESC) {
@@ -5205,9 +5207,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5205 * Bad mac address. At least one bios sets the mac address 5207 * Bad mac address. At least one bios sets the mac address
5206 * to 01:23:45:67:89:ab 5208 * to 01:23:45:67:89:ab
5207 */ 5209 */
5208 printk(KERN_ERR "%s: Invalid Mac address detected: %s\n", 5210 dev_printk(KERN_ERR, &pci_dev->dev,
5209 pci_name(pci_dev), print_mac(mac, dev->dev_addr)); 5211 "Invalid Mac address detected: %s\n",
5210 printk(KERN_ERR "Please complain to your hardware vendor. Switching to a random MAC.\n"); 5212 print_mac(mac, dev->dev_addr));
5213 dev_printk(KERN_ERR, &pci_dev->dev,
5214 "Please complain to your hardware vendor. Switching to a random MAC.\n");
5211 dev->dev_addr[0] = 0x00; 5215 dev->dev_addr[0] = 0x00;
5212 dev->dev_addr[1] = 0x00; 5216 dev->dev_addr[1] = 0x00;
5213 dev->dev_addr[2] = 0x6c; 5217 dev->dev_addr[2] = 0x6c;
@@ -5321,8 +5325,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5321 break; 5325 break;
5322 } 5326 }
5323 if (i == 33) { 5327 if (i == 33) {
5324 printk(KERN_INFO "%s: open: Could not find a valid PHY.\n", 5328 dev_printk(KERN_INFO, &pci_dev->dev,
5325 pci_name(pci_dev)); 5329 "open: Could not find a valid PHY.\n");
5326 goto out_error; 5330 goto out_error;
5327 } 5331 }
5328 5332
@@ -5344,12 +5348,37 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5344 5348
5345 err = register_netdev(dev); 5349 err = register_netdev(dev);
5346 if (err) { 5350 if (err) {
5347 printk(KERN_INFO "forcedeth: unable to register netdev: %d\n", err); 5351 dev_printk(KERN_INFO, &pci_dev->dev,
5352 "unable to register netdev: %d\n", err);
5348 goto out_error; 5353 goto out_error;
5349 } 5354 }
5350 printk(KERN_INFO "%s: forcedeth.c: subsystem: %05x:%04x bound to %s\n", 5355
5351 dev->name, pci_dev->subsystem_vendor, pci_dev->subsystem_device, 5356 dev_printk(KERN_INFO, &pci_dev->dev, "ifname %s, PHY OUI 0x%x @ %d, "
5352 pci_name(pci_dev)); 5357 "addr %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
5358 dev->name,
5359 np->phy_oui,
5360 np->phyaddr,
5361 dev->dev_addr[0],
5362 dev->dev_addr[1],
5363 dev->dev_addr[2],
5364 dev->dev_addr[3],
5365 dev->dev_addr[4],
5366 dev->dev_addr[5]);
5367
5368 dev_printk(KERN_INFO, &pci_dev->dev, "%s%s%s%s%s%s%s%s%s%sdesc-v%u\n",
5369 dev->features & NETIF_F_HIGHDMA ? "highdma " : "",
5370 dev->features & (NETIF_F_HW_CSUM | NETIF_F_SG) ?
5371 "csum " : "",
5372 dev->features & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX) ?
5373 "vlan " : "",
5374 id->driver_data & DEV_HAS_POWER_CNTRL ? "pwrctl " : "",
5375 id->driver_data & DEV_HAS_MGMT_UNIT ? "mgmt " : "",
5376 id->driver_data & DEV_NEED_TIMERIRQ ? "timirq " : "",
5377 np->gigabit == PHY_GIGABIT ? "gbit " : "",
5378 np->need_linktimer ? "lnktim " : "",
5379 np->msi_flags & NV_MSI_CAPABLE ? "msi " : "",
5380 np->msi_flags & NV_MSI_X_CAPABLE ? "msi-x " : "",
5381 np->desc_ver);
5353 5382
5354 return 0; 5383 return 0;
5355 5384
@@ -5567,17 +5596,16 @@ static struct pci_device_id pci_tbl[] = {
5567}; 5596};
5568 5597
5569static struct pci_driver driver = { 5598static struct pci_driver driver = {
5570 .name = "forcedeth", 5599 .name = DRV_NAME,
5571 .id_table = pci_tbl, 5600 .id_table = pci_tbl,
5572 .probe = nv_probe, 5601 .probe = nv_probe,
5573 .remove = __devexit_p(nv_remove), 5602 .remove = __devexit_p(nv_remove),
5574 .suspend = nv_suspend, 5603 .suspend = nv_suspend,
5575 .resume = nv_resume, 5604 .resume = nv_resume,
5576}; 5605};
5577 5606
5578static int __init init_nic(void) 5607static int __init init_nic(void)
5579{ 5608{
5580 printk(KERN_INFO "forcedeth.c: Reverse Engineered nForce ethernet driver. Version %s.\n", FORCEDETH_VERSION);
5581 return pci_register_driver(&driver); 5609 return pci_register_driver(&driver);
5582} 5610}
5583 5611