diff options
Diffstat (limited to 'drivers/net/igb/igb_ethtool.c')
-rw-r--r-- | drivers/net/igb/igb_ethtool.c | 131 |
1 files changed, 63 insertions, 68 deletions
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index 89964fa739a0..3c831f1472ad 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -101,8 +101,8 @@ static const struct igb_stats igb_gstrings_stats[] = { | |||
101 | }; | 101 | }; |
102 | 102 | ||
103 | #define IGB_QUEUE_STATS_LEN \ | 103 | #define IGB_QUEUE_STATS_LEN \ |
104 | ((((struct igb_adapter *)netdev->priv)->num_rx_queues + \ | 104 | ((((struct igb_adapter *)netdev_priv(netdev))->num_rx_queues + \ |
105 | ((struct igb_adapter *)netdev->priv)->num_tx_queues) * \ | 105 | ((struct igb_adapter *)netdev_priv(netdev))->num_tx_queues) * \ |
106 | (sizeof(struct igb_queue_stats) / sizeof(u64))) | 106 | (sizeof(struct igb_queue_stats) / sizeof(u64))) |
107 | #define IGB_GLOBAL_STATS_LEN \ | 107 | #define IGB_GLOBAL_STATS_LEN \ |
108 | sizeof(igb_gstrings_stats) / sizeof(struct igb_stats) | 108 | sizeof(igb_gstrings_stats) / sizeof(struct igb_stats) |
@@ -494,8 +494,6 @@ static void igb_get_regs(struct net_device *netdev, | |||
494 | 494 | ||
495 | /* These should probably be added to e1000_regs.h instead */ | 495 | /* These should probably be added to e1000_regs.h instead */ |
496 | #define E1000_PSRTYPE_REG(_i) (0x05480 + ((_i) * 4)) | 496 | #define E1000_PSRTYPE_REG(_i) (0x05480 + ((_i) * 4)) |
497 | #define E1000_RAL(_i) (0x05400 + ((_i) * 8)) | ||
498 | #define E1000_RAH(_i) (0x05404 + ((_i) * 8)) | ||
499 | #define E1000_IP4AT_REG(_i) (0x05840 + ((_i) * 8)) | 497 | #define E1000_IP4AT_REG(_i) (0x05840 + ((_i) * 8)) |
500 | #define E1000_IP6AT_REG(_i) (0x05880 + ((_i) * 4)) | 498 | #define E1000_IP6AT_REG(_i) (0x05880 + ((_i) * 4)) |
501 | #define E1000_WUPM_REG(_i) (0x05A00 + ((_i) * 4)) | 499 | #define E1000_WUPM_REG(_i) (0x05A00 + ((_i) * 4)) |
@@ -714,15 +712,13 @@ static void igb_get_ringparam(struct net_device *netdev, | |||
714 | struct ethtool_ringparam *ring) | 712 | struct ethtool_ringparam *ring) |
715 | { | 713 | { |
716 | struct igb_adapter *adapter = netdev_priv(netdev); | 714 | struct igb_adapter *adapter = netdev_priv(netdev); |
717 | struct igb_ring *tx_ring = adapter->tx_ring; | ||
718 | struct igb_ring *rx_ring = adapter->rx_ring; | ||
719 | 715 | ||
720 | ring->rx_max_pending = IGB_MAX_RXD; | 716 | ring->rx_max_pending = IGB_MAX_RXD; |
721 | ring->tx_max_pending = IGB_MAX_TXD; | 717 | ring->tx_max_pending = IGB_MAX_TXD; |
722 | ring->rx_mini_max_pending = 0; | 718 | ring->rx_mini_max_pending = 0; |
723 | ring->rx_jumbo_max_pending = 0; | 719 | ring->rx_jumbo_max_pending = 0; |
724 | ring->rx_pending = rx_ring->count; | 720 | ring->rx_pending = adapter->rx_ring_count; |
725 | ring->tx_pending = tx_ring->count; | 721 | ring->tx_pending = adapter->tx_ring_count; |
726 | ring->rx_mini_pending = 0; | 722 | ring->rx_mini_pending = 0; |
727 | ring->rx_jumbo_pending = 0; | 723 | ring->rx_jumbo_pending = 0; |
728 | } | 724 | } |
@@ -731,12 +727,9 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
731 | struct ethtool_ringparam *ring) | 727 | struct ethtool_ringparam *ring) |
732 | { | 728 | { |
733 | struct igb_adapter *adapter = netdev_priv(netdev); | 729 | struct igb_adapter *adapter = netdev_priv(netdev); |
734 | struct igb_buffer *old_buf; | 730 | struct igb_ring *temp_ring; |
735 | struct igb_buffer *old_rx_buf; | ||
736 | void *old_desc; | ||
737 | int i, err; | 731 | int i, err; |
738 | u32 new_rx_count, new_tx_count, old_size; | 732 | u32 new_rx_count, new_tx_count; |
739 | dma_addr_t old_dma; | ||
740 | 733 | ||
741 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) | 734 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
742 | return -EINVAL; | 735 | return -EINVAL; |
@@ -749,12 +742,19 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
749 | new_tx_count = min(new_tx_count, (u32)IGB_MAX_TXD); | 742 | new_tx_count = min(new_tx_count, (u32)IGB_MAX_TXD); |
750 | new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE); | 743 | new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE); |
751 | 744 | ||
752 | if ((new_tx_count == adapter->tx_ring->count) && | 745 | if ((new_tx_count == adapter->tx_ring_count) && |
753 | (new_rx_count == adapter->rx_ring->count)) { | 746 | (new_rx_count == adapter->rx_ring_count)) { |
754 | /* nothing to do */ | 747 | /* nothing to do */ |
755 | return 0; | 748 | return 0; |
756 | } | 749 | } |
757 | 750 | ||
751 | if (adapter->num_tx_queues > adapter->num_rx_queues) | ||
752 | temp_ring = vmalloc(adapter->num_tx_queues * sizeof(struct igb_ring)); | ||
753 | else | ||
754 | temp_ring = vmalloc(adapter->num_rx_queues * sizeof(struct igb_ring)); | ||
755 | if (!temp_ring) | ||
756 | return -ENOMEM; | ||
757 | |||
758 | while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) | 758 | while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) |
759 | msleep(1); | 759 | msleep(1); |
760 | 760 | ||
@@ -766,62 +766,55 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
766 | * because the ISRs in MSI-X mode get passed pointers | 766 | * because the ISRs in MSI-X mode get passed pointers |
767 | * to the tx and rx ring structs. | 767 | * to the tx and rx ring structs. |
768 | */ | 768 | */ |
769 | if (new_tx_count != adapter->tx_ring->count) { | 769 | if (new_tx_count != adapter->tx_ring_count) { |
770 | memcpy(temp_ring, adapter->tx_ring, | ||
771 | adapter->num_tx_queues * sizeof(struct igb_ring)); | ||
772 | |||
770 | for (i = 0; i < adapter->num_tx_queues; i++) { | 773 | for (i = 0; i < adapter->num_tx_queues; i++) { |
771 | /* Save existing descriptor ring */ | 774 | temp_ring[i].count = new_tx_count; |
772 | old_buf = adapter->tx_ring[i].buffer_info; | 775 | err = igb_setup_tx_resources(adapter, &temp_ring[i]); |
773 | old_desc = adapter->tx_ring[i].desc; | ||
774 | old_size = adapter->tx_ring[i].size; | ||
775 | old_dma = adapter->tx_ring[i].dma; | ||
776 | /* Try to allocate a new one */ | ||
777 | adapter->tx_ring[i].buffer_info = NULL; | ||
778 | adapter->tx_ring[i].desc = NULL; | ||
779 | adapter->tx_ring[i].count = new_tx_count; | ||
780 | err = igb_setup_tx_resources(adapter, | ||
781 | &adapter->tx_ring[i]); | ||
782 | if (err) { | 776 | if (err) { |
783 | /* Restore the old one so at least | 777 | while (i) { |
784 | the adapter still works, even if | 778 | i--; |
785 | we failed the request */ | 779 | igb_free_tx_resources(&temp_ring[i]); |
786 | adapter->tx_ring[i].buffer_info = old_buf; | 780 | } |
787 | adapter->tx_ring[i].desc = old_desc; | ||
788 | adapter->tx_ring[i].size = old_size; | ||
789 | adapter->tx_ring[i].dma = old_dma; | ||
790 | goto err_setup; | 781 | goto err_setup; |
791 | } | 782 | } |
792 | /* Free the old buffer manually */ | ||
793 | vfree(old_buf); | ||
794 | pci_free_consistent(adapter->pdev, old_size, | ||
795 | old_desc, old_dma); | ||
796 | } | 783 | } |
784 | |||
785 | for (i = 0; i < adapter->num_tx_queues; i++) | ||
786 | igb_free_tx_resources(&adapter->tx_ring[i]); | ||
787 | |||
788 | memcpy(adapter->tx_ring, temp_ring, | ||
789 | adapter->num_tx_queues * sizeof(struct igb_ring)); | ||
790 | |||
791 | adapter->tx_ring_count = new_tx_count; | ||
797 | } | 792 | } |
798 | 793 | ||
799 | if (new_rx_count != adapter->rx_ring->count) { | 794 | if (new_rx_count != adapter->rx_ring->count) { |
800 | for (i = 0; i < adapter->num_rx_queues; i++) { | 795 | memcpy(temp_ring, adapter->rx_ring, |
796 | adapter->num_rx_queues * sizeof(struct igb_ring)); | ||
801 | 797 | ||
802 | old_rx_buf = adapter->rx_ring[i].buffer_info; | 798 | for (i = 0; i < adapter->num_rx_queues; i++) { |
803 | old_desc = adapter->rx_ring[i].desc; | 799 | temp_ring[i].count = new_rx_count; |
804 | old_size = adapter->rx_ring[i].size; | 800 | err = igb_setup_rx_resources(adapter, &temp_ring[i]); |
805 | old_dma = adapter->rx_ring[i].dma; | ||
806 | |||
807 | adapter->rx_ring[i].buffer_info = NULL; | ||
808 | adapter->rx_ring[i].desc = NULL; | ||
809 | adapter->rx_ring[i].dma = 0; | ||
810 | adapter->rx_ring[i].count = new_rx_count; | ||
811 | err = igb_setup_rx_resources(adapter, | ||
812 | &adapter->rx_ring[i]); | ||
813 | if (err) { | 801 | if (err) { |
814 | adapter->rx_ring[i].buffer_info = old_rx_buf; | 802 | while (i) { |
815 | adapter->rx_ring[i].desc = old_desc; | 803 | i--; |
816 | adapter->rx_ring[i].size = old_size; | 804 | igb_free_rx_resources(&temp_ring[i]); |
817 | adapter->rx_ring[i].dma = old_dma; | 805 | } |
818 | goto err_setup; | 806 | goto err_setup; |
819 | } | 807 | } |
820 | 808 | ||
821 | vfree(old_rx_buf); | ||
822 | pci_free_consistent(adapter->pdev, old_size, old_desc, | ||
823 | old_dma); | ||
824 | } | 809 | } |
810 | |||
811 | for (i = 0; i < adapter->num_rx_queues; i++) | ||
812 | igb_free_rx_resources(&adapter->rx_ring[i]); | ||
813 | |||
814 | memcpy(adapter->rx_ring, temp_ring, | ||
815 | adapter->num_rx_queues * sizeof(struct igb_ring)); | ||
816 | |||
817 | adapter->rx_ring_count = new_rx_count; | ||
825 | } | 818 | } |
826 | 819 | ||
827 | err = 0; | 820 | err = 0; |
@@ -830,6 +823,7 @@ err_setup: | |||
830 | igb_up(adapter); | 823 | igb_up(adapter); |
831 | 824 | ||
832 | clear_bit(__IGB_RESETTING, &adapter->state); | 825 | clear_bit(__IGB_RESETTING, &adapter->state); |
826 | vfree(temp_ring); | ||
833 | return err; | 827 | return err; |
834 | } | 828 | } |
835 | 829 | ||
@@ -1343,8 +1337,9 @@ static int igb_setup_desc_rings(struct igb_adapter *adapter) | |||
1343 | wr32(E1000_RDLEN(0), rx_ring->size); | 1337 | wr32(E1000_RDLEN(0), rx_ring->size); |
1344 | wr32(E1000_RDH(0), 0); | 1338 | wr32(E1000_RDH(0), 0); |
1345 | wr32(E1000_RDT(0), 0); | 1339 | wr32(E1000_RDT(0), 0); |
1340 | rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); | ||
1346 | rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 | | 1341 | rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 | |
1347 | E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | | 1342 | E1000_RCTL_RDMTS_HALF | |
1348 | (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT); | 1343 | (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT); |
1349 | wr32(E1000_RCTL, rctl); | 1344 | wr32(E1000_RCTL, rctl); |
1350 | wr32(E1000_SRRCTL(0), 0); | 1345 | wr32(E1000_SRRCTL(0), 0); |
@@ -1380,10 +1375,10 @@ static void igb_phy_disable_receiver(struct igb_adapter *adapter) | |||
1380 | struct e1000_hw *hw = &adapter->hw; | 1375 | struct e1000_hw *hw = &adapter->hw; |
1381 | 1376 | ||
1382 | /* Write out to PHY registers 29 and 30 to disable the Receiver. */ | 1377 | /* Write out to PHY registers 29 and 30 to disable the Receiver. */ |
1383 | hw->phy.ops.write_phy_reg(hw, 29, 0x001F); | 1378 | igb_write_phy_reg(hw, 29, 0x001F); |
1384 | hw->phy.ops.write_phy_reg(hw, 30, 0x8FFC); | 1379 | igb_write_phy_reg(hw, 30, 0x8FFC); |
1385 | hw->phy.ops.write_phy_reg(hw, 29, 0x001A); | 1380 | igb_write_phy_reg(hw, 29, 0x001A); |
1386 | hw->phy.ops.write_phy_reg(hw, 30, 0x8FF0); | 1381 | igb_write_phy_reg(hw, 30, 0x8FF0); |
1387 | } | 1382 | } |
1388 | 1383 | ||
1389 | static int igb_integrated_phy_loopback(struct igb_adapter *adapter) | 1384 | static int igb_integrated_phy_loopback(struct igb_adapter *adapter) |
@@ -1396,17 +1391,17 @@ static int igb_integrated_phy_loopback(struct igb_adapter *adapter) | |||
1396 | 1391 | ||
1397 | if (hw->phy.type == e1000_phy_m88) { | 1392 | if (hw->phy.type == e1000_phy_m88) { |
1398 | /* Auto-MDI/MDIX Off */ | 1393 | /* Auto-MDI/MDIX Off */ |
1399 | hw->phy.ops.write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, 0x0808); | 1394 | igb_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, 0x0808); |
1400 | /* reset to update Auto-MDI/MDIX */ | 1395 | /* reset to update Auto-MDI/MDIX */ |
1401 | hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, 0x9140); | 1396 | igb_write_phy_reg(hw, PHY_CONTROL, 0x9140); |
1402 | /* autoneg off */ | 1397 | /* autoneg off */ |
1403 | hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, 0x8140); | 1398 | igb_write_phy_reg(hw, PHY_CONTROL, 0x8140); |
1404 | } | 1399 | } |
1405 | 1400 | ||
1406 | ctrl_reg = rd32(E1000_CTRL); | 1401 | ctrl_reg = rd32(E1000_CTRL); |
1407 | 1402 | ||
1408 | /* force 1000, set loopback */ | 1403 | /* force 1000, set loopback */ |
1409 | hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, 0x4140); | 1404 | igb_write_phy_reg(hw, PHY_CONTROL, 0x4140); |
1410 | 1405 | ||
1411 | /* Now set up the MAC to the same speed/duplex as the PHY. */ | 1406 | /* Now set up the MAC to the same speed/duplex as the PHY. */ |
1412 | ctrl_reg = rd32(E1000_CTRL); | 1407 | ctrl_reg = rd32(E1000_CTRL); |
@@ -1500,10 +1495,10 @@ static void igb_loopback_cleanup(struct igb_adapter *adapter) | |||
1500 | wr32(E1000_RCTL, rctl); | 1495 | wr32(E1000_RCTL, rctl); |
1501 | 1496 | ||
1502 | hw->mac.autoneg = true; | 1497 | hw->mac.autoneg = true; |
1503 | hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &phy_reg); | 1498 | igb_read_phy_reg(hw, PHY_CONTROL, &phy_reg); |
1504 | if (phy_reg & MII_CR_LOOPBACK) { | 1499 | if (phy_reg & MII_CR_LOOPBACK) { |
1505 | phy_reg &= ~MII_CR_LOOPBACK; | 1500 | phy_reg &= ~MII_CR_LOOPBACK; |
1506 | hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, phy_reg); | 1501 | igb_write_phy_reg(hw, PHY_CONTROL, phy_reg); |
1507 | igb_phy_sw_reset(hw); | 1502 | igb_phy_sw_reset(hw); |
1508 | } | 1503 | } |
1509 | } | 1504 | } |