aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/ethtool.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/ethtool.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/ethtool.c')
-rw-r--r--drivers/net/sfc/ethtool.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index fd19d6ab97a2..b9291db023bb 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -328,9 +328,10 @@ static int efx_fill_loopback_test(struct efx_nic *efx,
328 unsigned int test_index, 328 unsigned int test_index,
329 struct ethtool_string *strings, u64 *data) 329 struct ethtool_string *strings, u64 *data)
330{ 330{
331 struct efx_channel *channel = efx_get_channel(efx, 0);
331 struct efx_tx_queue *tx_queue; 332 struct efx_tx_queue *tx_queue;
332 333
333 efx_for_each_channel_tx_queue(tx_queue, &efx->channel[0]) { 334 efx_for_each_channel_tx_queue(tx_queue, channel) {
334 efx_fill_test(test_index++, strings, data, 335 efx_fill_test(test_index++, strings, data,
335 &lb_tests->tx_sent[tx_queue->queue], 336 &lb_tests->tx_sent[tx_queue->queue],
336 EFX_TX_QUEUE_NAME(tx_queue), 337 EFX_TX_QUEUE_NAME(tx_queue),
@@ -673,15 +674,15 @@ static int efx_ethtool_get_coalesce(struct net_device *net_dev,
673 struct ethtool_coalesce *coalesce) 674 struct ethtool_coalesce *coalesce)
674{ 675{
675 struct efx_nic *efx = netdev_priv(net_dev); 676 struct efx_nic *efx = netdev_priv(net_dev);
676 struct efx_tx_queue *tx_queue;
677 struct efx_channel *channel; 677 struct efx_channel *channel;
678 678
679 memset(coalesce, 0, sizeof(*coalesce)); 679 memset(coalesce, 0, sizeof(*coalesce));
680 680
681 /* Find lowest IRQ moderation across all used TX queues */ 681 /* Find lowest IRQ moderation across all used TX queues */
682 coalesce->tx_coalesce_usecs_irq = ~((u32) 0); 682 coalesce->tx_coalesce_usecs_irq = ~((u32) 0);
683 efx_for_each_tx_queue(tx_queue, efx) { 683 efx_for_each_channel(channel, efx) {
684 channel = tx_queue->channel; 684 if (!efx_channel_get_tx_queue(channel, 0))
685 continue;
685 if (channel->irq_moderation < coalesce->tx_coalesce_usecs_irq) { 686 if (channel->irq_moderation < coalesce->tx_coalesce_usecs_irq) {
686 if (channel->channel < efx->n_rx_channels) 687 if (channel->channel < efx->n_rx_channels)
687 coalesce->tx_coalesce_usecs_irq = 688 coalesce->tx_coalesce_usecs_irq =
@@ -708,7 +709,6 @@ static int efx_ethtool_set_coalesce(struct net_device *net_dev,
708{ 709{
709 struct efx_nic *efx = netdev_priv(net_dev); 710 struct efx_nic *efx = netdev_priv(net_dev);
710 struct efx_channel *channel; 711 struct efx_channel *channel;
711 struct efx_tx_queue *tx_queue;
712 unsigned tx_usecs, rx_usecs, adaptive; 712 unsigned tx_usecs, rx_usecs, adaptive;
713 713
714 if (coalesce->use_adaptive_tx_coalesce) 714 if (coalesce->use_adaptive_tx_coalesce)
@@ -725,8 +725,9 @@ static int efx_ethtool_set_coalesce(struct net_device *net_dev,
725 adaptive = coalesce->use_adaptive_rx_coalesce; 725 adaptive = coalesce->use_adaptive_rx_coalesce;
726 726
727 /* If the channel is shared only allow RX parameters to be set */ 727 /* If the channel is shared only allow RX parameters to be set */
728 efx_for_each_tx_queue(tx_queue, efx) { 728 efx_for_each_channel(channel, efx) {
729 if ((tx_queue->channel->channel < efx->n_rx_channels) && 729 if (efx_channel_get_rx_queue(channel) &&
730 efx_channel_get_tx_queue(channel, 0) &&
730 tx_usecs) { 731 tx_usecs) {
731 netif_err(efx, drv, efx->net_dev, "Channel is shared. " 732 netif_err(efx, drv, efx->net_dev, "Channel is shared. "
732 "Only RX coalescing may be set\n"); 733 "Only RX coalescing may be set\n");