aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sky2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r--drivers/net/sky2.c157
1 files changed, 95 insertions, 62 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index d6577084ce70..39996bf3b247 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1917,8 +1917,10 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1917 netif_printk(sky2, tx_done, KERN_DEBUG, dev, 1917 netif_printk(sky2, tx_done, KERN_DEBUG, dev,
1918 "tx done %u\n", idx); 1918 "tx done %u\n", idx);
1919 1919
1920 dev->stats.tx_packets++; 1920 u64_stats_update_begin(&sky2->tx_stats.syncp);
1921 dev->stats.tx_bytes += skb->len; 1921 ++sky2->tx_stats.packets;
1922 sky2->tx_stats.bytes += skb->len;
1923 u64_stats_update_end(&sky2->tx_stats.syncp);
1922 1924
1923 re->skb = NULL; 1925 re->skb = NULL;
1924 dev_kfree_skb_any(skb); 1926 dev_kfree_skb_any(skb);
@@ -2460,7 +2462,7 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
2460 2462
2461 /* if length reported by DMA does not match PHY, packet was truncated */ 2463 /* if length reported by DMA does not match PHY, packet was truncated */
2462 if (length != count) 2464 if (length != count)
2463 goto len_error; 2465 goto error;
2464 2466
2465okay: 2467okay:
2466 if (length < copybreak) 2468 if (length < copybreak)
@@ -2475,34 +2477,13 @@ resubmit:
2475 2477
2476 return skb; 2478 return skb;
2477 2479
2478len_error:
2479 /* Truncation of overlength packets
2480 causes PHY length to not match MAC length */
2481 ++dev->stats.rx_length_errors;
2482 if (net_ratelimit())
2483 netif_info(sky2, rx_err, dev,
2484 "rx length error: status %#x length %d\n",
2485 status, length);
2486 goto resubmit;
2487
2488error: 2480error:
2489 ++dev->stats.rx_errors; 2481 ++dev->stats.rx_errors;
2490 if (status & GMR_FS_RX_FF_OV) {
2491 dev->stats.rx_over_errors++;
2492 goto resubmit;
2493 }
2494 2482
2495 if (net_ratelimit()) 2483 if (net_ratelimit())
2496 netif_info(sky2, rx_err, dev, 2484 netif_info(sky2, rx_err, dev,
2497 "rx error, status 0x%x length %d\n", status, length); 2485 "rx error, status 0x%x length %d\n", status, length);
2498 2486
2499 if (status & (GMR_FS_LONG_ERR | GMR_FS_UN_SIZE))
2500 dev->stats.rx_length_errors++;
2501 if (status & GMR_FS_FRAGMENT)
2502 dev->stats.rx_frame_errors++;
2503 if (status & GMR_FS_CRC_ERR)
2504 dev->stats.rx_crc_errors++;
2505
2506 goto resubmit; 2487 goto resubmit;
2507} 2488}
2508 2489
@@ -2543,14 +2524,19 @@ static inline void sky2_skb_rx(const struct sky2_port *sky2,
2543static inline void sky2_rx_done(struct sky2_hw *hw, unsigned port, 2524static inline void sky2_rx_done(struct sky2_hw *hw, unsigned port,
2544 unsigned packets, unsigned bytes) 2525 unsigned packets, unsigned bytes)
2545{ 2526{
2546 if (packets) { 2527 struct net_device *dev = hw->dev[port];
2547 struct net_device *dev = hw->dev[port]; 2528 struct sky2_port *sky2 = netdev_priv(dev);
2548 2529
2549 dev->stats.rx_packets += packets; 2530 if (packets == 0)
2550 dev->stats.rx_bytes += bytes; 2531 return;
2551 dev->last_rx = jiffies; 2532
2552 sky2_rx_update(netdev_priv(dev), rxqaddr[port]); 2533 u64_stats_update_begin(&sky2->rx_stats.syncp);
2553 } 2534 sky2->rx_stats.packets += packets;
2535 sky2->rx_stats.bytes += bytes;
2536 u64_stats_update_end(&sky2->rx_stats.syncp);
2537
2538 dev->last_rx = jiffies;
2539 sky2_rx_update(netdev_priv(dev), rxqaddr[port]);
2554} 2540}
2555 2541
2556static void sky2_rx_checksum(struct sky2_port *sky2, u32 status) 2542static void sky2_rx_checksum(struct sky2_port *sky2, u32 status)
@@ -3398,12 +3384,24 @@ static int sky2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
3398{ 3384{
3399 struct sky2_port *sky2 = netdev_priv(dev); 3385 struct sky2_port *sky2 = netdev_priv(dev);
3400 struct sky2_hw *hw = sky2->hw; 3386 struct sky2_hw *hw = sky2->hw;
3387 bool enable_wakeup = false;
3388 int i;
3401 3389
3402 if ((wol->wolopts & ~sky2_wol_supported(sky2->hw)) || 3390 if ((wol->wolopts & ~sky2_wol_supported(sky2->hw)) ||
3403 !device_can_wakeup(&hw->pdev->dev)) 3391 !device_can_wakeup(&hw->pdev->dev))
3404 return -EOPNOTSUPP; 3392 return -EOPNOTSUPP;
3405 3393
3406 sky2->wol = wol->wolopts; 3394 sky2->wol = wol->wolopts;
3395
3396 for (i = 0; i < hw->ports; i++) {
3397 struct net_device *dev = hw->dev[i];
3398 struct sky2_port *sky2 = netdev_priv(dev);
3399
3400 if (sky2->wol)
3401 enable_wakeup = true;
3402 }
3403 device_set_wakeup_enable(&hw->pdev->dev, enable_wakeup);
3404
3407 return 0; 3405 return 0;
3408} 3406}
3409 3407
@@ -3614,13 +3612,11 @@ static void sky2_phy_stats(struct sky2_port *sky2, u64 * data, unsigned count)
3614 unsigned port = sky2->port; 3612 unsigned port = sky2->port;
3615 int i; 3613 int i;
3616 3614
3617 data[0] = (u64) gma_read32(hw, port, GM_TXO_OK_HI) << 32 3615 data[0] = get_stats64(hw, port, GM_TXO_OK_LO);
3618 | (u64) gma_read32(hw, port, GM_TXO_OK_LO); 3616 data[1] = get_stats64(hw, port, GM_RXO_OK_LO);
3619 data[1] = (u64) gma_read32(hw, port, GM_RXO_OK_HI) << 32
3620 | (u64) gma_read32(hw, port, GM_RXO_OK_LO);
3621 3617
3622 for (i = 2; i < count; i++) 3618 for (i = 2; i < count; i++)
3623 data[i] = (u64) gma_read32(hw, port, sky2_stats[i].offset); 3619 data[i] = get_stats32(hw, port, sky2_stats[i].offset);
3624} 3620}
3625 3621
3626static void sky2_set_msglevel(struct net_device *netdev, u32 value) 3622static void sky2_set_msglevel(struct net_device *netdev, u32 value)
@@ -3738,6 +3734,51 @@ static void sky2_set_multicast(struct net_device *dev)
3738 gma_write16(hw, port, GM_RX_CTRL, reg); 3734 gma_write16(hw, port, GM_RX_CTRL, reg);
3739} 3735}
3740 3736
3737static struct rtnl_link_stats64 *sky2_get_stats(struct net_device *dev,
3738 struct rtnl_link_stats64 *stats)
3739{
3740 struct sky2_port *sky2 = netdev_priv(dev);
3741 struct sky2_hw *hw = sky2->hw;
3742 unsigned port = sky2->port;
3743 unsigned int start;
3744 u64 _bytes, _packets;
3745
3746 do {
3747 start = u64_stats_fetch_begin_bh(&sky2->rx_stats.syncp);
3748 _bytes = sky2->rx_stats.bytes;
3749 _packets = sky2->rx_stats.packets;
3750 } while (u64_stats_fetch_retry_bh(&sky2->rx_stats.syncp, start));
3751
3752 stats->rx_packets = _packets;
3753 stats->rx_bytes = _bytes;
3754
3755 do {
3756 start = u64_stats_fetch_begin_bh(&sky2->tx_stats.syncp);
3757 _bytes = sky2->tx_stats.bytes;
3758 _packets = sky2->tx_stats.packets;
3759 } while (u64_stats_fetch_retry_bh(&sky2->tx_stats.syncp, start));
3760
3761 stats->tx_packets = _packets;
3762 stats->tx_bytes = _bytes;
3763
3764 stats->multicast = get_stats32(hw, port, GM_RXF_MC_OK)
3765 + get_stats32(hw, port, GM_RXF_BC_OK);
3766
3767 stats->collisions = get_stats32(hw, port, GM_TXF_COL);
3768
3769 stats->rx_length_errors = get_stats32(hw, port, GM_RXF_LNG_ERR);
3770 stats->rx_crc_errors = get_stats32(hw, port, GM_RXF_FCS_ERR);
3771 stats->rx_frame_errors = get_stats32(hw, port, GM_RXF_SHT)
3772 + get_stats32(hw, port, GM_RXE_FRAG);
3773 stats->rx_over_errors = get_stats32(hw, port, GM_RXE_FIFO_OV);
3774
3775 stats->rx_dropped = dev->stats.rx_dropped;
3776 stats->rx_fifo_errors = dev->stats.rx_fifo_errors;
3777 stats->tx_fifo_errors = dev->stats.tx_fifo_errors;
3778
3779 return stats;
3780}
3781
3741/* Can have one global because blinking is controlled by 3782/* Can have one global because blinking is controlled by
3742 * ethtool and that is always under RTNL mutex 3783 * ethtool and that is always under RTNL mutex
3743 */ 3784 */
@@ -4512,6 +4553,7 @@ static const struct net_device_ops sky2_netdev_ops[2] = {
4512 .ndo_set_multicast_list = sky2_set_multicast, 4553 .ndo_set_multicast_list = sky2_set_multicast,
4513 .ndo_change_mtu = sky2_change_mtu, 4554 .ndo_change_mtu = sky2_change_mtu,
4514 .ndo_tx_timeout = sky2_tx_timeout, 4555 .ndo_tx_timeout = sky2_tx_timeout,
4556 .ndo_get_stats64 = sky2_get_stats,
4515#ifdef SKY2_VLAN_TAG_USED 4557#ifdef SKY2_VLAN_TAG_USED
4516 .ndo_vlan_rx_register = sky2_vlan_rx_register, 4558 .ndo_vlan_rx_register = sky2_vlan_rx_register,
4517#endif 4559#endif
@@ -4529,6 +4571,7 @@ static const struct net_device_ops sky2_netdev_ops[2] = {
4529 .ndo_set_multicast_list = sky2_set_multicast, 4571 .ndo_set_multicast_list = sky2_set_multicast,
4530 .ndo_change_mtu = sky2_change_mtu, 4572 .ndo_change_mtu = sky2_change_mtu,
4531 .ndo_tx_timeout = sky2_tx_timeout, 4573 .ndo_tx_timeout = sky2_tx_timeout,
4574 .ndo_get_stats64 = sky2_get_stats,
4532#ifdef SKY2_VLAN_TAG_USED 4575#ifdef SKY2_VLAN_TAG_USED
4533 .ndo_vlan_rx_register = sky2_vlan_rx_register, 4576 .ndo_vlan_rx_register = sky2_vlan_rx_register,
4534#endif 4577#endif
@@ -4920,10 +4963,11 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
4920 pci_set_drvdata(pdev, NULL); 4963 pci_set_drvdata(pdev, NULL);
4921} 4964}
4922 4965
4923static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) 4966static int sky2_suspend(struct device *dev)
4924{ 4967{
4968 struct pci_dev *pdev = to_pci_dev(dev);
4925 struct sky2_hw *hw = pci_get_drvdata(pdev); 4969 struct sky2_hw *hw = pci_get_drvdata(pdev);
4926 int i, wol = 0; 4970 int i;
4927 4971
4928 if (!hw) 4972 if (!hw)
4929 return 0; 4973 return 0;
@@ -4940,41 +4984,24 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
4940 4984
4941 if (sky2->wol) 4985 if (sky2->wol)
4942 sky2_wol_init(sky2); 4986 sky2_wol_init(sky2);
4943
4944 wol |= sky2->wol;
4945 } 4987 }
4946 4988
4947 device_set_wakeup_enable(&pdev->dev, wol != 0);
4948
4949 sky2_power_aux(hw); 4989 sky2_power_aux(hw);
4950 rtnl_unlock(); 4990 rtnl_unlock();
4951 4991
4952 pci_save_state(pdev);
4953 pci_enable_wake(pdev, pci_choose_state(pdev, state), wol);
4954 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4955
4956 return 0; 4992 return 0;
4957} 4993}
4958 4994
4959#ifdef CONFIG_PM 4995#ifdef CONFIG_PM
4960static int sky2_resume(struct pci_dev *pdev) 4996static int sky2_resume(struct device *dev)
4961{ 4997{
4998 struct pci_dev *pdev = to_pci_dev(dev);
4962 struct sky2_hw *hw = pci_get_drvdata(pdev); 4999 struct sky2_hw *hw = pci_get_drvdata(pdev);
4963 int err; 5000 int err;
4964 5001
4965 if (!hw) 5002 if (!hw)
4966 return 0; 5003 return 0;
4967 5004
4968 err = pci_set_power_state(pdev, PCI_D0);
4969 if (err)
4970 goto out;
4971
4972 err = pci_restore_state(pdev);
4973 if (err)
4974 goto out;
4975
4976 pci_enable_wake(pdev, PCI_D0, 0);
4977
4978 /* Re-enable all clocks */ 5005 /* Re-enable all clocks */
4979 err = pci_write_config_dword(pdev, PCI_DEV_REG3, 0); 5006 err = pci_write_config_dword(pdev, PCI_DEV_REG3, 0);
4980 if (err) { 5007 if (err) {
@@ -4994,11 +5021,20 @@ out:
4994 pci_disable_device(pdev); 5021 pci_disable_device(pdev);
4995 return err; 5022 return err;
4996} 5023}
5024
5025static SIMPLE_DEV_PM_OPS(sky2_pm_ops, sky2_suspend, sky2_resume);
5026#define SKY2_PM_OPS (&sky2_pm_ops)
5027
5028#else
5029
5030#define SKY2_PM_OPS NULL
4997#endif 5031#endif
4998 5032
4999static void sky2_shutdown(struct pci_dev *pdev) 5033static void sky2_shutdown(struct pci_dev *pdev)
5000{ 5034{
5001 sky2_suspend(pdev, PMSG_SUSPEND); 5035 sky2_suspend(&pdev->dev);
5036 pci_wake_from_d3(pdev, device_may_wakeup(&pdev->dev));
5037 pci_set_power_state(pdev, PCI_D3hot);
5002} 5038}
5003 5039
5004static struct pci_driver sky2_driver = { 5040static struct pci_driver sky2_driver = {
@@ -5006,11 +5042,8 @@ static struct pci_driver sky2_driver = {
5006 .id_table = sky2_id_table, 5042 .id_table = sky2_id_table,
5007 .probe = sky2_probe, 5043 .probe = sky2_probe,
5008 .remove = __devexit_p(sky2_remove), 5044 .remove = __devexit_p(sky2_remove),
5009#ifdef CONFIG_PM
5010 .suspend = sky2_suspend,
5011 .resume = sky2_resume,
5012#endif
5013 .shutdown = sky2_shutdown, 5045 .shutdown = sky2_shutdown,
5046 .driver.pm = SKY2_PM_OPS,
5014}; 5047};
5015 5048
5016static int __init sky2_init_module(void) 5049static int __init sky2_init_module(void)