diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2010-11-16 22:26:49 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2010-11-16 22:26:49 -0500 |
commit | b6ec895ecd32c0070c3b2b17918c030275cd834d (patch) | |
tree | cf21df02228b0b8ef9296abb6b465f36bf142474 /drivers/net/ixgbe/ixgbe_ethtool.c | |
parent | 84ea2591e4a24775c2735511a1cc3cf88edd249d (diff) |
ixgbe: move device pointer into the ring structure
This change is meant to simplify DMA map/unmap by providing a device
pointer. As a result the adapter pointer can be dropped from many of
the calls.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_ethtool.c')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_ethtool.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c index 81fa1ac1c9ba..cc7804962b2e 100644 --- a/drivers/net/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ixgbe/ixgbe_ethtool.c | |||
@@ -900,13 +900,11 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
900 | memcpy(&temp_tx_ring[i], adapter->tx_ring[i], | 900 | memcpy(&temp_tx_ring[i], adapter->tx_ring[i], |
901 | sizeof(struct ixgbe_ring)); | 901 | sizeof(struct ixgbe_ring)); |
902 | temp_tx_ring[i].count = new_tx_count; | 902 | temp_tx_ring[i].count = new_tx_count; |
903 | err = ixgbe_setup_tx_resources(adapter, | 903 | err = ixgbe_setup_tx_resources(&temp_tx_ring[i]); |
904 | &temp_tx_ring[i]); | ||
905 | if (err) { | 904 | if (err) { |
906 | while (i) { | 905 | while (i) { |
907 | i--; | 906 | i--; |
908 | ixgbe_free_tx_resources(adapter, | 907 | ixgbe_free_tx_resources(&temp_tx_ring[i]); |
909 | &temp_tx_ring[i]); | ||
910 | } | 908 | } |
911 | goto clear_reset; | 909 | goto clear_reset; |
912 | } | 910 | } |
@@ -925,13 +923,11 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
925 | memcpy(&temp_rx_ring[i], adapter->rx_ring[i], | 923 | memcpy(&temp_rx_ring[i], adapter->rx_ring[i], |
926 | sizeof(struct ixgbe_ring)); | 924 | sizeof(struct ixgbe_ring)); |
927 | temp_rx_ring[i].count = new_rx_count; | 925 | temp_rx_ring[i].count = new_rx_count; |
928 | err = ixgbe_setup_rx_resources(adapter, | 926 | err = ixgbe_setup_rx_resources(&temp_rx_ring[i]); |
929 | &temp_rx_ring[i]); | ||
930 | if (err) { | 927 | if (err) { |
931 | while (i) { | 928 | while (i) { |
932 | i--; | 929 | i--; |
933 | ixgbe_free_rx_resources(adapter, | 930 | ixgbe_free_rx_resources(&temp_rx_ring[i]); |
934 | &temp_rx_ring[i]); | ||
935 | } | 931 | } |
936 | goto err_setup; | 932 | goto err_setup; |
937 | } | 933 | } |
@@ -946,8 +942,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
946 | /* tx */ | 942 | /* tx */ |
947 | if (new_tx_count != adapter->tx_ring_count) { | 943 | if (new_tx_count != adapter->tx_ring_count) { |
948 | for (i = 0; i < adapter->num_tx_queues; i++) { | 944 | for (i = 0; i < adapter->num_tx_queues; i++) { |
949 | ixgbe_free_tx_resources(adapter, | 945 | ixgbe_free_tx_resources(adapter->tx_ring[i]); |
950 | adapter->tx_ring[i]); | ||
951 | memcpy(adapter->tx_ring[i], &temp_tx_ring[i], | 946 | memcpy(adapter->tx_ring[i], &temp_tx_ring[i], |
952 | sizeof(struct ixgbe_ring)); | 947 | sizeof(struct ixgbe_ring)); |
953 | } | 948 | } |
@@ -957,8 +952,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
957 | /* rx */ | 952 | /* rx */ |
958 | if (new_rx_count != adapter->rx_ring_count) { | 953 | if (new_rx_count != adapter->rx_ring_count) { |
959 | for (i = 0; i < adapter->num_rx_queues; i++) { | 954 | for (i = 0; i < adapter->num_rx_queues; i++) { |
960 | ixgbe_free_rx_resources(adapter, | 955 | ixgbe_free_rx_resources(adapter->rx_ring[i]); |
961 | adapter->rx_ring[i]); | ||
962 | memcpy(adapter->rx_ring[i], &temp_rx_ring[i], | 956 | memcpy(adapter->rx_ring[i], &temp_rx_ring[i], |
963 | sizeof(struct ixgbe_ring)); | 957 | sizeof(struct ixgbe_ring)); |
964 | } | 958 | } |
@@ -1463,8 +1457,8 @@ static void ixgbe_free_desc_rings(struct ixgbe_adapter *adapter) | |||
1463 | 1457 | ||
1464 | ixgbe_reset(adapter); | 1458 | ixgbe_reset(adapter); |
1465 | 1459 | ||
1466 | ixgbe_free_tx_resources(adapter, &adapter->test_tx_ring); | 1460 | ixgbe_free_tx_resources(&adapter->test_tx_ring); |
1467 | ixgbe_free_rx_resources(adapter, &adapter->test_rx_ring); | 1461 | ixgbe_free_rx_resources(&adapter->test_rx_ring); |
1468 | } | 1462 | } |
1469 | 1463 | ||
1470 | static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) | 1464 | static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) |
@@ -1478,10 +1472,11 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) | |||
1478 | /* Setup Tx descriptor ring and Tx buffers */ | 1472 | /* Setup Tx descriptor ring and Tx buffers */ |
1479 | tx_ring->count = IXGBE_DEFAULT_TXD; | 1473 | tx_ring->count = IXGBE_DEFAULT_TXD; |
1480 | tx_ring->queue_index = 0; | 1474 | tx_ring->queue_index = 0; |
1475 | tx_ring->dev = &adapter->pdev->dev; | ||
1481 | tx_ring->reg_idx = adapter->tx_ring[0]->reg_idx; | 1476 | tx_ring->reg_idx = adapter->tx_ring[0]->reg_idx; |
1482 | tx_ring->numa_node = adapter->node; | 1477 | tx_ring->numa_node = adapter->node; |
1483 | 1478 | ||
1484 | err = ixgbe_setup_tx_resources(adapter, tx_ring); | 1479 | err = ixgbe_setup_tx_resources(tx_ring); |
1485 | if (err) | 1480 | if (err) |
1486 | return 1; | 1481 | return 1; |
1487 | 1482 | ||
@@ -1496,11 +1491,12 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) | |||
1496 | /* Setup Rx Descriptor ring and Rx buffers */ | 1491 | /* Setup Rx Descriptor ring and Rx buffers */ |
1497 | rx_ring->count = IXGBE_DEFAULT_RXD; | 1492 | rx_ring->count = IXGBE_DEFAULT_RXD; |
1498 | rx_ring->queue_index = 0; | 1493 | rx_ring->queue_index = 0; |
1494 | rx_ring->dev = &adapter->pdev->dev; | ||
1499 | rx_ring->reg_idx = adapter->rx_ring[0]->reg_idx; | 1495 | rx_ring->reg_idx = adapter->rx_ring[0]->reg_idx; |
1500 | rx_ring->rx_buf_len = IXGBE_RXBUFFER_2048; | 1496 | rx_ring->rx_buf_len = IXGBE_RXBUFFER_2048; |
1501 | rx_ring->numa_node = adapter->node; | 1497 | rx_ring->numa_node = adapter->node; |
1502 | 1498 | ||
1503 | err = ixgbe_setup_rx_resources(adapter, rx_ring); | 1499 | err = ixgbe_setup_rx_resources(rx_ring); |
1504 | if (err) { | 1500 | if (err) { |
1505 | ret_val = 4; | 1501 | ret_val = 4; |
1506 | goto err_nomem; | 1502 | goto err_nomem; |
@@ -1622,7 +1618,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter, | |||
1622 | rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc]; | 1618 | rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc]; |
1623 | 1619 | ||
1624 | /* unmap Rx buffer, will be remapped by alloc_rx_buffers */ | 1620 | /* unmap Rx buffer, will be remapped by alloc_rx_buffers */ |
1625 | dma_unmap_single(&adapter->pdev->dev, | 1621 | dma_unmap_single(rx_ring->dev, |
1626 | rx_buffer_info->dma, | 1622 | rx_buffer_info->dma, |
1627 | bufsz, | 1623 | bufsz, |
1628 | DMA_FROM_DEVICE); | 1624 | DMA_FROM_DEVICE); |
@@ -1634,7 +1630,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter, | |||
1634 | 1630 | ||
1635 | /* unmap buffer on Tx side */ | 1631 | /* unmap buffer on Tx side */ |
1636 | tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc]; | 1632 | tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc]; |
1637 | ixgbe_unmap_and_free_tx_resource(adapter, tx_buffer_info); | 1633 | ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer_info); |
1638 | 1634 | ||
1639 | /* increment Rx/Tx next to clean counters */ | 1635 | /* increment Rx/Tx next to clean counters */ |
1640 | rx_ntc++; | 1636 | rx_ntc++; |