aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/net_driver.h
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/net_driver.h
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/net_driver.h')
-rw-r--r--drivers/net/sfc/net_driver.h43
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 89c6e02c57dd..eb3537529c9c 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -909,18 +909,34 @@ struct efx_nic_type {
909 * 909 *
910 *************************************************************************/ 910 *************************************************************************/
911 911
912static inline struct efx_channel *
913efx_get_channel(struct efx_nic *efx, unsigned index)
914{
915 EFX_BUG_ON_PARANOID(index >= efx->n_channels);
916 return &efx->channel[index];
917}
918
912/* Iterate over all used channels */ 919/* Iterate over all used channels */
913#define efx_for_each_channel(_channel, _efx) \ 920#define efx_for_each_channel(_channel, _efx) \
914 for (_channel = &((_efx)->channel[0]); \ 921 for (_channel = &((_efx)->channel[0]); \
915 _channel < &((_efx)->channel[(efx)->n_channels]); \ 922 _channel < &((_efx)->channel[(efx)->n_channels]); \
916 _channel++) 923 _channel++)
917 924
918/* Iterate over all used TX queues */ 925static inline struct efx_tx_queue *
919#define efx_for_each_tx_queue(_tx_queue, _efx) \ 926efx_get_tx_queue(struct efx_nic *efx, unsigned index, unsigned type)
920 for (_tx_queue = &((_efx)->tx_queue[0]); \ 927{
921 _tx_queue < &((_efx)->tx_queue[EFX_TXQ_TYPES * \ 928 EFX_BUG_ON_PARANOID(index >= efx->n_tx_channels ||
922 (_efx)->n_tx_channels]); \ 929 type >= EFX_TXQ_TYPES);
923 _tx_queue++) 930 return &efx->tx_queue[index * EFX_TXQ_TYPES + type];
931}
932
933static inline struct efx_tx_queue *
934efx_channel_get_tx_queue(struct efx_channel *channel, unsigned type)
935{
936 struct efx_tx_queue *tx_queue = channel->tx_queue;
937 EFX_BUG_ON_PARANOID(type >= EFX_TXQ_TYPES);
938 return tx_queue ? tx_queue + type : NULL;
939}
924 940
925/* Iterate over all TX queues belonging to a channel */ 941/* Iterate over all TX queues belonging to a channel */
926#define efx_for_each_channel_tx_queue(_tx_queue, _channel) \ 942#define efx_for_each_channel_tx_queue(_tx_queue, _channel) \
@@ -928,12 +944,27 @@ struct efx_nic_type {
928 _tx_queue && _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES; \ 944 _tx_queue && _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES; \
929 _tx_queue++) 945 _tx_queue++)
930 946
947static inline struct efx_rx_queue *
948efx_get_rx_queue(struct efx_nic *efx, unsigned index)
949{
950 EFX_BUG_ON_PARANOID(index >= efx->n_rx_channels);
951 return &efx->rx_queue[index];
952}
953
931/* Iterate over all used RX queues */ 954/* Iterate over all used RX queues */
932#define efx_for_each_rx_queue(_rx_queue, _efx) \ 955#define efx_for_each_rx_queue(_rx_queue, _efx) \
933 for (_rx_queue = &((_efx)->rx_queue[0]); \ 956 for (_rx_queue = &((_efx)->rx_queue[0]); \
934 _rx_queue < &((_efx)->rx_queue[(_efx)->n_rx_channels]); \ 957 _rx_queue < &((_efx)->rx_queue[(_efx)->n_rx_channels]); \
935 _rx_queue++) 958 _rx_queue++)
936 959
960static inline struct efx_rx_queue *
961efx_channel_get_rx_queue(struct efx_channel *channel)
962{
963 struct efx_rx_queue *rx_queue =
964 &channel->efx->rx_queue[channel->channel];
965 return rx_queue->channel == channel ? rx_queue : NULL;
966}
967
937/* Iterate over all RX queues belonging to a channel */ 968/* Iterate over all RX queues belonging to a channel */
938#define efx_for_each_channel_rx_queue(_rx_queue, _channel) \ 969#define efx_for_each_channel_rx_queue(_rx_queue, _channel) \
939 for (_rx_queue = &((_channel)->efx->rx_queue[(_channel)->channel]); \ 970 for (_rx_queue = &((_channel)->efx->rx_queue[(_channel)->channel]); \