aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/efx.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2010-09-10 02:41:47 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-10 15:27:32 -0400
commitf7d12cdcbb28207b3bdcf4affbf3935e4c015d03 (patch)
treeab94c3e81e355c8df47102ede2d5d0aa02738945 /drivers/net/sfc/efx.c
parentba1e8a35b77f3bc7d109696dbd2a7fd5af208b62 (diff)
sfc: Refactor channel and queue lookup and iteration
In preparation for changes to the way channels and queue structures are allocated, revise the macros and functions used to look up and iterator over them. - Replace efx_for_each_tx_queue() with iteration over channels then TX queues - Replace efx_for_each_rx_queue() with iteration over channels then RX queues (with one exception, shortly to be removed) - Introduce efx_get_{channel,rx_queue,tx_queue}() functions to look up channels and queues by index - Introduce efx_channel_get_{rx,tx}_queue() functions to look up a channel's queues Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc/efx.c')
-rw-r--r--drivers/net/sfc/efx.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index a57604527a42..3dd71aa310cd 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -248,7 +248,7 @@ static int efx_process_channel(struct efx_channel *channel, int budget)
248 248
249 efx_rx_strategy(channel); 249 efx_rx_strategy(channel);
250 250
251 efx_fast_push_rx_descriptors(&efx->rx_queue[channel->channel]); 251 efx_fast_push_rx_descriptors(efx_channel_get_rx_queue(channel));
252 252
253 return spent; 253 return spent;
254} 254}
@@ -1050,7 +1050,8 @@ static void efx_probe_interrupts(struct efx_nic *efx)
1050 efx->n_rx_channels = efx->n_channels; 1050 efx->n_rx_channels = efx->n_channels;
1051 } 1051 }
1052 for (i = 0; i < n_channels; i++) 1052 for (i = 0; i < n_channels; i++)
1053 efx->channel[i].irq = xentries[i].vector; 1053 efx_get_channel(efx, i)->irq =
1054 xentries[i].vector;
1054 } else { 1055 } else {
1055 /* Fall back to single channel MSI */ 1056 /* Fall back to single channel MSI */
1056 efx->interrupt_mode = EFX_INT_MODE_MSI; 1057 efx->interrupt_mode = EFX_INT_MODE_MSI;
@@ -1066,7 +1067,7 @@ static void efx_probe_interrupts(struct efx_nic *efx)
1066 efx->n_tx_channels = 1; 1067 efx->n_tx_channels = 1;
1067 rc = pci_enable_msi(efx->pci_dev); 1068 rc = pci_enable_msi(efx->pci_dev);
1068 if (rc == 0) { 1069 if (rc == 0) {
1069 efx->channel[0].irq = efx->pci_dev->irq; 1070 efx_get_channel(efx, 0)->irq = efx->pci_dev->irq;
1070 } else { 1071 } else {
1071 netif_err(efx, drv, efx->net_dev, 1072 netif_err(efx, drv, efx->net_dev,
1072 "could not enable MSI\n"); 1073 "could not enable MSI\n");
@@ -1355,20 +1356,20 @@ static unsigned irq_mod_ticks(int usecs, int resolution)
1355void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs, 1356void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs,
1356 bool rx_adaptive) 1357 bool rx_adaptive)
1357{ 1358{
1358 struct efx_tx_queue *tx_queue; 1359 struct efx_channel *channel;
1359 struct efx_rx_queue *rx_queue;
1360 unsigned tx_ticks = irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION); 1360 unsigned tx_ticks = irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION);
1361 unsigned rx_ticks = irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION); 1361 unsigned rx_ticks = irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION);
1362 1362
1363 EFX_ASSERT_RESET_SERIALISED(efx); 1363 EFX_ASSERT_RESET_SERIALISED(efx);
1364 1364
1365 efx_for_each_tx_queue(tx_queue, efx)
1366 tx_queue->channel->irq_moderation = tx_ticks;
1367
1368 efx->irq_rx_adaptive = rx_adaptive; 1365 efx->irq_rx_adaptive = rx_adaptive;
1369 efx->irq_rx_moderation = rx_ticks; 1366 efx->irq_rx_moderation = rx_ticks;
1370 efx_for_each_rx_queue(rx_queue, efx) 1367 efx_for_each_channel(channel, efx) {
1371 rx_queue->channel->irq_moderation = rx_ticks; 1368 if (efx_channel_get_rx_queue(channel))
1369 channel->irq_moderation = rx_ticks;
1370 else if (efx_channel_get_tx_queue(channel, 0))
1371 channel->irq_moderation = tx_ticks;
1372 }
1372} 1373}
1373 1374
1374/************************************************************************** 1375/**************************************************************************
@@ -1767,6 +1768,7 @@ fail_registered:
1767 1768
1768static void efx_unregister_netdev(struct efx_nic *efx) 1769static void efx_unregister_netdev(struct efx_nic *efx)
1769{ 1770{
1771 struct efx_channel *channel;
1770 struct efx_tx_queue *tx_queue; 1772 struct efx_tx_queue *tx_queue;
1771 1773
1772 if (!efx->net_dev) 1774 if (!efx->net_dev)
@@ -1777,8 +1779,10 @@ static void efx_unregister_netdev(struct efx_nic *efx)
1777 /* Free up any skbs still remaining. This has to happen before 1779 /* Free up any skbs still remaining. This has to happen before
1778 * we try to unregister the netdev as running their destructors 1780 * we try to unregister the netdev as running their destructors
1779 * may be needed to get the device ref. count to 0. */ 1781 * may be needed to get the device ref. count to 0. */
1780 efx_for_each_tx_queue(tx_queue, efx) 1782 efx_for_each_channel(channel, efx) {
1781 efx_release_tx_buffers(tx_queue); 1783 efx_for_each_channel_tx_queue(tx_queue, channel)
1784 efx_release_tx_buffers(tx_queue);
1785 }
1782 1786
1783 if (efx_dev_registered(efx)) { 1787 if (efx_dev_registered(efx)) {
1784 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); 1788 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));