Commit b6ec895e authored by Alexander Duyck's avatar Alexander Duyck Committed by Jeff Kirsher

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: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Tested-by: default avatarRoss Brattain <ross.b.brattain@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 84ea2591
...@@ -148,6 +148,7 @@ struct ixgbe_queue_stats { ...@@ -148,6 +148,7 @@ struct ixgbe_queue_stats {
struct ixgbe_ring { struct ixgbe_ring {
void *desc; /* descriptor ring memory */ void *desc; /* descriptor ring memory */
struct device *dev; /* device for DMA mapping */
union { union {
struct ixgbe_tx_buffer *tx_buffer_info; struct ixgbe_tx_buffer *tx_buffer_info;
struct ixgbe_rx_buffer *rx_buffer_info; struct ixgbe_rx_buffer *rx_buffer_info;
...@@ -454,10 +455,10 @@ extern void ixgbe_down(struct ixgbe_adapter *adapter); ...@@ -454,10 +455,10 @@ extern void ixgbe_down(struct ixgbe_adapter *adapter);
extern void ixgbe_reinit_locked(struct ixgbe_adapter *adapter); extern void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
extern void ixgbe_reset(struct ixgbe_adapter *adapter); extern void ixgbe_reset(struct ixgbe_adapter *adapter);
extern void ixgbe_set_ethtool_ops(struct net_device *netdev); extern void ixgbe_set_ethtool_ops(struct net_device *netdev);
extern int ixgbe_setup_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *); extern int ixgbe_setup_rx_resources(struct ixgbe_ring *);
extern int ixgbe_setup_tx_resources(struct ixgbe_adapter *, struct ixgbe_ring *); extern int ixgbe_setup_tx_resources(struct ixgbe_ring *);
extern void ixgbe_free_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *); extern void ixgbe_free_rx_resources(struct ixgbe_ring *);
extern void ixgbe_free_tx_resources(struct ixgbe_adapter *, struct ixgbe_ring *); extern void ixgbe_free_tx_resources(struct ixgbe_ring *);
extern void ixgbe_configure_rx_ring(struct ixgbe_adapter *,struct ixgbe_ring *); extern void ixgbe_configure_rx_ring(struct ixgbe_adapter *,struct ixgbe_ring *);
extern void ixgbe_configure_tx_ring(struct ixgbe_adapter *,struct ixgbe_ring *); extern void ixgbe_configure_tx_ring(struct ixgbe_adapter *,struct ixgbe_ring *);
extern void ixgbe_update_stats(struct ixgbe_adapter *adapter); extern void ixgbe_update_stats(struct ixgbe_adapter *adapter);
...@@ -467,7 +468,7 @@ extern netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, ...@@ -467,7 +468,7 @@ extern netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *,
struct net_device *, struct net_device *,
struct ixgbe_adapter *, struct ixgbe_adapter *,
struct ixgbe_ring *); struct ixgbe_ring *);
extern void ixgbe_unmap_and_free_tx_resource(struct ixgbe_adapter *, extern void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *,
struct ixgbe_tx_buffer *); struct ixgbe_tx_buffer *);
extern void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter, extern void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter,
struct ixgbe_ring *rx_ring, struct ixgbe_ring *rx_ring,
......
...@@ -900,13 +900,11 @@ static int ixgbe_set_ringparam(struct net_device *netdev, ...@@ -900,13 +900,11 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
memcpy(&temp_tx_ring[i], adapter->tx_ring[i], memcpy(&temp_tx_ring[i], adapter->tx_ring[i],
sizeof(struct ixgbe_ring)); sizeof(struct ixgbe_ring));
temp_tx_ring[i].count = new_tx_count; temp_tx_ring[i].count = new_tx_count;
err = ixgbe_setup_tx_resources(adapter, err = ixgbe_setup_tx_resources(&temp_tx_ring[i]);
&temp_tx_ring[i]);
if (err) { if (err) {
while (i) { while (i) {
i--; i--;
ixgbe_free_tx_resources(adapter, ixgbe_free_tx_resources(&temp_tx_ring[i]);
&temp_tx_ring[i]);
} }
goto clear_reset; goto clear_reset;
} }
...@@ -925,13 +923,11 @@ static int ixgbe_set_ringparam(struct net_device *netdev, ...@@ -925,13 +923,11 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
memcpy(&temp_rx_ring[i], adapter->rx_ring[i], memcpy(&temp_rx_ring[i], adapter->rx_ring[i],
sizeof(struct ixgbe_ring)); sizeof(struct ixgbe_ring));
temp_rx_ring[i].count = new_rx_count; temp_rx_ring[i].count = new_rx_count;
err = ixgbe_setup_rx_resources(adapter, err = ixgbe_setup_rx_resources(&temp_rx_ring[i]);
&temp_rx_ring[i]);
if (err) { if (err) {
while (i) { while (i) {
i--; i--;
ixgbe_free_rx_resources(adapter, ixgbe_free_rx_resources(&temp_rx_ring[i]);
&temp_rx_ring[i]);
} }
goto err_setup; goto err_setup;
} }
...@@ -946,8 +942,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, ...@@ -946,8 +942,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
/* tx */ /* tx */
if (new_tx_count != adapter->tx_ring_count) { if (new_tx_count != adapter->tx_ring_count) {
for (i = 0; i < adapter->num_tx_queues; i++) { for (i = 0; i < adapter->num_tx_queues; i++) {
ixgbe_free_tx_resources(adapter, ixgbe_free_tx_resources(adapter->tx_ring[i]);
adapter->tx_ring[i]);
memcpy(adapter->tx_ring[i], &temp_tx_ring[i], memcpy(adapter->tx_ring[i], &temp_tx_ring[i],
sizeof(struct ixgbe_ring)); sizeof(struct ixgbe_ring));
} }
...@@ -957,8 +952,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, ...@@ -957,8 +952,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
/* rx */ /* rx */
if (new_rx_count != adapter->rx_ring_count) { if (new_rx_count != adapter->rx_ring_count) {
for (i = 0; i < adapter->num_rx_queues; i++) { for (i = 0; i < adapter->num_rx_queues; i++) {
ixgbe_free_rx_resources(adapter, ixgbe_free_rx_resources(adapter->rx_ring[i]);
adapter->rx_ring[i]);
memcpy(adapter->rx_ring[i], &temp_rx_ring[i], memcpy(adapter->rx_ring[i], &temp_rx_ring[i],
sizeof(struct ixgbe_ring)); sizeof(struct ixgbe_ring));
} }
...@@ -1463,8 +1457,8 @@ static void ixgbe_free_desc_rings(struct ixgbe_adapter *adapter) ...@@ -1463,8 +1457,8 @@ static void ixgbe_free_desc_rings(struct ixgbe_adapter *adapter)
ixgbe_reset(adapter); ixgbe_reset(adapter);
ixgbe_free_tx_resources(adapter, &adapter->test_tx_ring); ixgbe_free_tx_resources(&adapter->test_tx_ring);
ixgbe_free_rx_resources(adapter, &adapter->test_rx_ring); ixgbe_free_rx_resources(&adapter->test_rx_ring);
} }
static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) 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,10 +1472,11 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter)
/* Setup Tx descriptor ring and Tx buffers */ /* Setup Tx descriptor ring and Tx buffers */
tx_ring->count = IXGBE_DEFAULT_TXD; tx_ring->count = IXGBE_DEFAULT_TXD;
tx_ring->queue_index = 0; tx_ring->queue_index = 0;
tx_ring->dev = &adapter->pdev->dev;
tx_ring->reg_idx = adapter->tx_ring[0]->reg_idx; tx_ring->reg_idx = adapter->tx_ring[0]->reg_idx;
tx_ring->numa_node = adapter->node; tx_ring->numa_node = adapter->node;
err = ixgbe_setup_tx_resources(adapter, tx_ring); err = ixgbe_setup_tx_resources(tx_ring);
if (err) if (err)
return 1; return 1;
...@@ -1496,11 +1491,12 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) ...@@ -1496,11 +1491,12 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter)
/* Setup Rx Descriptor ring and Rx buffers */ /* Setup Rx Descriptor ring and Rx buffers */
rx_ring->count = IXGBE_DEFAULT_RXD; rx_ring->count = IXGBE_DEFAULT_RXD;
rx_ring->queue_index = 0; rx_ring->queue_index = 0;
rx_ring->dev = &adapter->pdev->dev;
rx_ring->reg_idx = adapter->rx_ring[0]->reg_idx; rx_ring->reg_idx = adapter->rx_ring[0]->reg_idx;
rx_ring->rx_buf_len = IXGBE_RXBUFFER_2048; rx_ring->rx_buf_len = IXGBE_RXBUFFER_2048;
rx_ring->numa_node = adapter->node; rx_ring->numa_node = adapter->node;
err = ixgbe_setup_rx_resources(adapter, rx_ring); err = ixgbe_setup_rx_resources(rx_ring);
if (err) { if (err) {
ret_val = 4; ret_val = 4;
goto err_nomem; goto err_nomem;
...@@ -1622,7 +1618,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter, ...@@ -1622,7 +1618,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter,
rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc]; rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc];
/* unmap Rx buffer, will be remapped by alloc_rx_buffers */ /* unmap Rx buffer, will be remapped by alloc_rx_buffers */
dma_unmap_single(&adapter->pdev->dev, dma_unmap_single(rx_ring->dev,
rx_buffer_info->dma, rx_buffer_info->dma,
bufsz, bufsz,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
...@@ -1634,7 +1630,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter, ...@@ -1634,7 +1630,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter,
/* unmap buffer on Tx side */ /* unmap buffer on Tx side */
tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc]; tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc];
ixgbe_unmap_and_free_tx_resource(adapter, tx_buffer_info); ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer_info);
/* increment Rx/Tx next to clean counters */ /* increment Rx/Tx next to clean counters */
rx_ntc++; rx_ntc++;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment