aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_ethtool.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000/e1000_ethtool.c')
-rw-r--r--drivers/net/e1000/e1000_ethtool.c75
1 files changed, 51 insertions, 24 deletions
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 5f9a36bb77f5..6e7e34f59a34 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -39,10 +39,10 @@ extern int e1000_up(struct e1000_adapter *adapter);
39extern void e1000_down(struct e1000_adapter *adapter); 39extern void e1000_down(struct e1000_adapter *adapter);
40extern void e1000_reset(struct e1000_adapter *adapter); 40extern void e1000_reset(struct e1000_adapter *adapter);
41extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx); 41extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
42extern int e1000_setup_rx_resources(struct e1000_adapter *adapter); 42extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
43extern int e1000_setup_tx_resources(struct e1000_adapter *adapter); 43extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
44extern void e1000_free_rx_resources(struct e1000_adapter *adapter); 44extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
45extern void e1000_free_tx_resources(struct e1000_adapter *adapter); 45extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
46extern void e1000_update_stats(struct e1000_adapter *adapter); 46extern void e1000_update_stats(struct e1000_adapter *adapter);
47 47
48struct e1000_stats { 48struct e1000_stats {
@@ -576,8 +576,8 @@ e1000_get_ringparam(struct net_device *netdev,
576{ 576{
577 struct e1000_adapter *adapter = netdev_priv(netdev); 577 struct e1000_adapter *adapter = netdev_priv(netdev);
578 e1000_mac_type mac_type = adapter->hw.mac_type; 578 e1000_mac_type mac_type = adapter->hw.mac_type;
579 struct e1000_desc_ring *txdr = &adapter->tx_ring; 579 struct e1000_tx_ring *txdr = adapter->tx_ring;
580 struct e1000_desc_ring *rxdr = &adapter->rx_ring; 580 struct e1000_rx_ring *rxdr = adapter->rx_ring;
581 581
582 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD : 582 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD :
583 E1000_MAX_82544_RXD; 583 E1000_MAX_82544_RXD;
@@ -597,20 +597,40 @@ e1000_set_ringparam(struct net_device *netdev,
597{ 597{
598 struct e1000_adapter *adapter = netdev_priv(netdev); 598 struct e1000_adapter *adapter = netdev_priv(netdev);
599 e1000_mac_type mac_type = adapter->hw.mac_type; 599 e1000_mac_type mac_type = adapter->hw.mac_type;
600 struct e1000_desc_ring *txdr = &adapter->tx_ring; 600 struct e1000_tx_ring *txdr, *tx_old, *tx_new;
601 struct e1000_desc_ring *rxdr = &adapter->rx_ring; 601 struct e1000_rx_ring *rxdr, *rx_old, *rx_new;
602 struct e1000_desc_ring tx_old, tx_new, rx_old, rx_new; 602 int i, err, tx_ring_size, rx_ring_size;
603 int err; 603
604 tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_queues;
605 rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_queues;
606
607 if (netif_running(adapter->netdev))
608 e1000_down(adapter);
604 609
605 tx_old = adapter->tx_ring; 610 tx_old = adapter->tx_ring;
606 rx_old = adapter->rx_ring; 611 rx_old = adapter->rx_ring;
607 612
613 adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL);
614 if (!adapter->tx_ring) {
615 err = -ENOMEM;
616 goto err_setup_rx;
617 }
618 memset(adapter->tx_ring, 0, tx_ring_size);
619
620 adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL);
621 if (!adapter->rx_ring) {
622 kfree(adapter->tx_ring);
623 err = -ENOMEM;
624 goto err_setup_rx;
625 }
626 memset(adapter->rx_ring, 0, rx_ring_size);
627
628 txdr = adapter->tx_ring;
629 rxdr = adapter->rx_ring;
630
608 if((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 631 if((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
609 return -EINVAL; 632 return -EINVAL;
610 633
611 if(netif_running(adapter->netdev))
612 e1000_down(adapter);
613
614 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD); 634 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
615 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ? 635 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
616 E1000_MAX_RXD : E1000_MAX_82544_RXD)); 636 E1000_MAX_RXD : E1000_MAX_82544_RXD));
@@ -621,11 +641,16 @@ e1000_set_ringparam(struct net_device *netdev,
621 E1000_MAX_TXD : E1000_MAX_82544_TXD)); 641 E1000_MAX_TXD : E1000_MAX_82544_TXD));
622 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE); 642 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
623 643
644 for (i = 0; i < adapter->num_queues; i++) {
645 txdr[i].count = txdr->count;
646 rxdr[i].count = rxdr->count;
647 }
648
624 if(netif_running(adapter->netdev)) { 649 if(netif_running(adapter->netdev)) {
625 /* Try to get new resources before deleting old */ 650 /* Try to get new resources before deleting old */
626 if((err = e1000_setup_rx_resources(adapter))) 651 if ((err = e1000_setup_all_rx_resources(adapter)))
627 goto err_setup_rx; 652 goto err_setup_rx;
628 if((err = e1000_setup_tx_resources(adapter))) 653 if ((err = e1000_setup_all_tx_resources(adapter)))
629 goto err_setup_tx; 654 goto err_setup_tx;
630 655
631 /* save the new, restore the old in order to free it, 656 /* save the new, restore the old in order to free it,
@@ -635,8 +660,10 @@ e1000_set_ringparam(struct net_device *netdev,
635 tx_new = adapter->tx_ring; 660 tx_new = adapter->tx_ring;
636 adapter->rx_ring = rx_old; 661 adapter->rx_ring = rx_old;
637 adapter->tx_ring = tx_old; 662 adapter->tx_ring = tx_old;
638 e1000_free_rx_resources(adapter); 663 e1000_free_all_rx_resources(adapter);
639 e1000_free_tx_resources(adapter); 664 e1000_free_all_tx_resources(adapter);
665 kfree(tx_old);
666 kfree(rx_old);
640 adapter->rx_ring = rx_new; 667 adapter->rx_ring = rx_new;
641 adapter->tx_ring = tx_new; 668 adapter->tx_ring = tx_new;
642 if((err = e1000_up(adapter))) 669 if((err = e1000_up(adapter)))
@@ -645,7 +672,7 @@ e1000_set_ringparam(struct net_device *netdev,
645 672
646 return 0; 673 return 0;
647err_setup_tx: 674err_setup_tx:
648 e1000_free_rx_resources(adapter); 675 e1000_free_all_rx_resources(adapter);
649err_setup_rx: 676err_setup_rx:
650 adapter->rx_ring = rx_old; 677 adapter->rx_ring = rx_old;
651 adapter->tx_ring = tx_old; 678 adapter->tx_ring = tx_old;
@@ -903,8 +930,8 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
903static void 930static void
904e1000_free_desc_rings(struct e1000_adapter *adapter) 931e1000_free_desc_rings(struct e1000_adapter *adapter)
905{ 932{
906 struct e1000_desc_ring *txdr = &adapter->test_tx_ring; 933 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
907 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring; 934 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
908 struct pci_dev *pdev = adapter->pdev; 935 struct pci_dev *pdev = adapter->pdev;
909 int i; 936 int i;
910 937
@@ -946,8 +973,8 @@ e1000_free_desc_rings(struct e1000_adapter *adapter)
946static int 973static int
947e1000_setup_desc_rings(struct e1000_adapter *adapter) 974e1000_setup_desc_rings(struct e1000_adapter *adapter)
948{ 975{
949 struct e1000_desc_ring *txdr = &adapter->test_tx_ring; 976 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
950 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring; 977 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
951 struct pci_dev *pdev = adapter->pdev; 978 struct pci_dev *pdev = adapter->pdev;
952 uint32_t rctl; 979 uint32_t rctl;
953 int size, i, ret_val; 980 int size, i, ret_val;
@@ -1347,8 +1374,8 @@ e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
1347static int 1374static int
1348e1000_run_loopback_test(struct e1000_adapter *adapter) 1375e1000_run_loopback_test(struct e1000_adapter *adapter)
1349{ 1376{
1350 struct e1000_desc_ring *txdr = &adapter->test_tx_ring; 1377 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
1351 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring; 1378 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1352 struct pci_dev *pdev = adapter->pdev; 1379 struct pci_dev *pdev = adapter->pdev;
1353 int i, j, k, l, lc, good_cnt, ret_val=0; 1380 int i, j, k, l, lc, good_cnt, ret_val=0;
1354 unsigned long time; 1381 unsigned long time;