aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2008-09-01 07:47:48 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-03 09:53:46 -0400
commit8831da7b6c4b15c0be0ba849be4aea5eed3999c6 (patch)
tree6bdfd5433f9eb4358a67504d85fb903fe17fd9d9 /drivers/net
parent64ee3120f73b9e904d97ba66386b1e8e93b81385 (diff)
sfc: Cleanup RX queue information
Rename efx_nic::rss_queues to the more obvious n_rx_queues Remove efx_rx_queue::used and other stuff that's redundant with it. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/sfc/efx.c43
-rw-r--r--drivers/net/sfc/falcon.c4
-rw-r--r--drivers/net/sfc/net_driver.h16
-rw-r--r--drivers/net/sfc/rx.c22
4 files changed, 27 insertions, 58 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 2deac7b04282..ba4369c8a834 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -859,20 +859,20 @@ static void efx_probe_interrupts(struct efx_nic *efx)
859 * We will need one channel per interrupt. 859 * We will need one channel per interrupt.
860 */ 860 */
861 wanted_ints = rss_cpus ? rss_cpus : efx_wanted_rx_queues(); 861 wanted_ints = rss_cpus ? rss_cpus : efx_wanted_rx_queues();
862 efx->rss_queues = min(wanted_ints, max_channels); 862 efx->n_rx_queues = min(wanted_ints, max_channels);
863 863
864 for (i = 0; i < efx->rss_queues; i++) 864 for (i = 0; i < efx->n_rx_queues; i++)
865 xentries[i].entry = i; 865 xentries[i].entry = i;
866 rc = pci_enable_msix(efx->pci_dev, xentries, efx->rss_queues); 866 rc = pci_enable_msix(efx->pci_dev, xentries, efx->n_rx_queues);
867 if (rc > 0) { 867 if (rc > 0) {
868 EFX_BUG_ON_PARANOID(rc >= efx->rss_queues); 868 EFX_BUG_ON_PARANOID(rc >= efx->n_rx_queues);
869 efx->rss_queues = rc; 869 efx->n_rx_queues = rc;
870 rc = pci_enable_msix(efx->pci_dev, xentries, 870 rc = pci_enable_msix(efx->pci_dev, xentries,
871 efx->rss_queues); 871 efx->n_rx_queues);
872 } 872 }
873 873
874 if (rc == 0) { 874 if (rc == 0) {
875 for (i = 0; i < efx->rss_queues; i++) 875 for (i = 0; i < efx->n_rx_queues; i++)
876 efx->channel[i].irq = xentries[i].vector; 876 efx->channel[i].irq = xentries[i].vector;
877 } else { 877 } else {
878 /* Fall back to single channel MSI */ 878 /* Fall back to single channel MSI */
@@ -883,7 +883,7 @@ static void efx_probe_interrupts(struct efx_nic *efx)
883 883
884 /* Try single interrupt MSI */ 884 /* Try single interrupt MSI */
885 if (efx->interrupt_mode == EFX_INT_MODE_MSI) { 885 if (efx->interrupt_mode == EFX_INT_MODE_MSI) {
886 efx->rss_queues = 1; 886 efx->n_rx_queues = 1;
887 rc = pci_enable_msi(efx->pci_dev); 887 rc = pci_enable_msi(efx->pci_dev);
888 if (rc == 0) { 888 if (rc == 0) {
889 efx->channel[0].irq = efx->pci_dev->irq; 889 efx->channel[0].irq = efx->pci_dev->irq;
@@ -895,7 +895,7 @@ static void efx_probe_interrupts(struct efx_nic *efx)
895 895
896 /* Assume legacy interrupts */ 896 /* Assume legacy interrupts */
897 if (efx->interrupt_mode == EFX_INT_MODE_LEGACY) { 897 if (efx->interrupt_mode == EFX_INT_MODE_LEGACY) {
898 efx->rss_queues = 1; 898 efx->n_rx_queues = 1;
899 efx->legacy_irq = efx->pci_dev->irq; 899 efx->legacy_irq = efx->pci_dev->irq;
900 } 900 }
901} 901}
@@ -914,14 +914,10 @@ static void efx_remove_interrupts(struct efx_nic *efx)
914 efx->legacy_irq = 0; 914 efx->legacy_irq = 0;
915} 915}
916 916
917/* Select number of used resources 917static void efx_set_channels(struct efx_nic *efx)
918 * Should be called after probe_interrupts()
919 */
920static void efx_select_used(struct efx_nic *efx)
921{ 918{
922 struct efx_tx_queue *tx_queue; 919 struct efx_tx_queue *tx_queue;
923 struct efx_rx_queue *rx_queue; 920 struct efx_rx_queue *rx_queue;
924 int i;
925 921
926 efx_for_each_tx_queue(tx_queue, efx) { 922 efx_for_each_tx_queue(tx_queue, efx) {
927 if (!EFX_INT_MODE_USE_MSI(efx) && separate_tx_and_rx_channels) 923 if (!EFX_INT_MODE_USE_MSI(efx) && separate_tx_and_rx_channels)
@@ -931,19 +927,9 @@ static void efx_select_used(struct efx_nic *efx)
931 tx_queue->channel->used_flags |= EFX_USED_BY_TX; 927 tx_queue->channel->used_flags |= EFX_USED_BY_TX;
932 } 928 }
933 929
934 /* RX queues. Each has a dedicated channel. */ 930 efx_for_each_rx_queue(rx_queue, efx) {
935 for (i = 0; i < EFX_MAX_RX_QUEUES; i++) { 931 rx_queue->channel = &efx->channel[rx_queue->queue];
936 rx_queue = &efx->rx_queue[i]; 932 rx_queue->channel->used_flags |= EFX_USED_BY_RX;
937
938 if (i < efx->rss_queues) {
939 rx_queue->used = true;
940 /* If we allow multiple RX queues per channel
941 * we need to decide that here
942 */
943 rx_queue->channel = &efx->channel[rx_queue->queue];
944 rx_queue->channel->used_flags |= EFX_USED_BY_RX;
945 rx_queue++;
946 }
947 } 933 }
948} 934}
949 935
@@ -962,8 +948,7 @@ static int efx_probe_nic(struct efx_nic *efx)
962 * in MSI-X interrupts. */ 948 * in MSI-X interrupts. */
963 efx_probe_interrupts(efx); 949 efx_probe_interrupts(efx);
964 950
965 /* Determine number of RX queues and TX queues */ 951 efx_set_channels(efx);
966 efx_select_used(efx);
967 952
968 /* Initialise the interrupt moderation settings */ 953 /* Initialise the interrupt moderation settings */
969 efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec); 954 efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec);
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 40dd643e930d..03194d6034ef 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1535,7 +1535,7 @@ static void falcon_setup_rss_indir_table(struct efx_nic *efx)
1535 offset < RX_RSS_INDIR_TBL_B0 + 0x800; 1535 offset < RX_RSS_INDIR_TBL_B0 + 0x800;
1536 offset += 0x10) { 1536 offset += 0x10) {
1537 EFX_POPULATE_DWORD_1(dword, RX_RSS_INDIR_ENT_B0, 1537 EFX_POPULATE_DWORD_1(dword, RX_RSS_INDIR_ENT_B0,
1538 i % efx->rss_queues); 1538 i % efx->n_rx_queues);
1539 falcon_writel(efx, &dword, offset); 1539 falcon_writel(efx, &dword, offset);
1540 i++; 1540 i++;
1541 } 1541 }
@@ -2785,7 +2785,7 @@ int falcon_init_nic(struct efx_nic *efx)
2785 if (falcon_rev(efx) >= FALCON_REV_B0) 2785 if (falcon_rev(efx) >= FALCON_REV_B0)
2786 EFX_SET_OWORD_FIELD(temp, NUM_KER, 0); 2786 EFX_SET_OWORD_FIELD(temp, NUM_KER, 0);
2787 else 2787 else
2788 EFX_SET_OWORD_FIELD(temp, NUM_KER, efx->rss_queues - 1); 2788 EFX_SET_OWORD_FIELD(temp, NUM_KER, efx->n_rx_queues - 1);
2789 if (EFX_WORKAROUND_7244(efx)) { 2789 if (EFX_WORKAROUND_7244(efx)) {
2790 EFX_SET_OWORD_FIELD(temp, UDP_FULL_SRCH_LIMIT, 8); 2790 EFX_SET_OWORD_FIELD(temp, UDP_FULL_SRCH_LIMIT, 8);
2791 EFX_SET_OWORD_FIELD(temp, UDP_WILD_SRCH_LIMIT, 8); 2791 EFX_SET_OWORD_FIELD(temp, UDP_WILD_SRCH_LIMIT, 8);
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 1fa134ab8eb8..b5649b16cd43 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -231,7 +231,6 @@ struct efx_rx_buffer {
231 * struct efx_rx_queue - An Efx RX queue 231 * struct efx_rx_queue - An Efx RX queue
232 * @efx: The associated Efx NIC 232 * @efx: The associated Efx NIC
233 * @queue: DMA queue number 233 * @queue: DMA queue number
234 * @used: Queue is used by net driver
235 * @channel: The associated channel 234 * @channel: The associated channel
236 * @buffer: The software buffer ring 235 * @buffer: The software buffer ring
237 * @rxd: The hardware descriptor ring 236 * @rxd: The hardware descriptor ring
@@ -265,7 +264,6 @@ struct efx_rx_buffer {
265struct efx_rx_queue { 264struct efx_rx_queue {
266 struct efx_nic *efx; 265 struct efx_nic *efx;
267 int queue; 266 int queue;
268 bool used;
269 struct efx_channel *channel; 267 struct efx_channel *channel;
270 struct efx_rx_buffer *buffer; 268 struct efx_rx_buffer *buffer;
271 struct efx_special_buffer rxd; 269 struct efx_special_buffer rxd;
@@ -628,7 +626,7 @@ union efx_multicast_hash {
628 * @tx_queue: TX DMA queues 626 * @tx_queue: TX DMA queues
629 * @rx_queue: RX DMA queues 627 * @rx_queue: RX DMA queues
630 * @channel: Channels 628 * @channel: Channels
631 * @rss_queues: Number of RSS queues 629 * @n_rx_queues: Number of RX queues
632 * @rx_buffer_len: RX buffer length 630 * @rx_buffer_len: RX buffer length
633 * @rx_buffer_order: Order (log2) of number of pages for each RX buffer 631 * @rx_buffer_order: Order (log2) of number of pages for each RX buffer
634 * @irq_status: Interrupt status buffer 632 * @irq_status: Interrupt status buffer
@@ -704,7 +702,7 @@ struct efx_nic {
704 struct efx_rx_queue rx_queue[EFX_MAX_RX_QUEUES]; 702 struct efx_rx_queue rx_queue[EFX_MAX_RX_QUEUES];
705 struct efx_channel channel[EFX_MAX_CHANNELS]; 703 struct efx_channel channel[EFX_MAX_CHANNELS];
706 704
707 int rss_queues; 705 int n_rx_queues;
708 unsigned int rx_buffer_len; 706 unsigned int rx_buffer_len;
709 unsigned int rx_buffer_order; 707 unsigned int rx_buffer_order;
710 708
@@ -850,19 +848,15 @@ struct efx_nic_type {
850/* Iterate over all used RX queues */ 848/* Iterate over all used RX queues */
851#define efx_for_each_rx_queue(_rx_queue, _efx) \ 849#define efx_for_each_rx_queue(_rx_queue, _efx) \
852 for (_rx_queue = &_efx->rx_queue[0]; \ 850 for (_rx_queue = &_efx->rx_queue[0]; \
853 _rx_queue < &_efx->rx_queue[EFX_MAX_RX_QUEUES]; \ 851 _rx_queue < &_efx->rx_queue[_efx->n_rx_queues]; \
854 _rx_queue++) \ 852 _rx_queue++)
855 if (!_rx_queue->used) \
856 continue; \
857 else
858 853
859/* Iterate over all RX queues belonging to a channel */ 854/* Iterate over all RX queues belonging to a channel */
860#define efx_for_each_channel_rx_queue(_rx_queue, _channel) \ 855#define efx_for_each_channel_rx_queue(_rx_queue, _channel) \
861 for (_rx_queue = &_channel->efx->rx_queue[0]; \ 856 for (_rx_queue = &_channel->efx->rx_queue[0]; \
862 _rx_queue < &_channel->efx->rx_queue[EFX_MAX_RX_QUEUES]; \ 857 _rx_queue < &_channel->efx->rx_queue[EFX_MAX_RX_QUEUES]; \
863 _rx_queue++) \ 858 _rx_queue++) \
864 if ((!_rx_queue->used) || \ 859 if (_rx_queue->channel != _channel) \
865 (_rx_queue->channel != _channel)) \
866 continue; \ 860 continue; \
867 else 861 else
868 862
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index fa1a62aacbae..7d2dc20d0ca3 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -789,23 +789,14 @@ int efx_probe_rx_queue(struct efx_rx_queue *rx_queue)
789 /* Allocate RX buffers */ 789 /* Allocate RX buffers */
790 rxq_size = (efx->type->rxd_ring_mask + 1) * sizeof(*rx_queue->buffer); 790 rxq_size = (efx->type->rxd_ring_mask + 1) * sizeof(*rx_queue->buffer);
791 rx_queue->buffer = kzalloc(rxq_size, GFP_KERNEL); 791 rx_queue->buffer = kzalloc(rxq_size, GFP_KERNEL);
792 if (!rx_queue->buffer) { 792 if (!rx_queue->buffer)
793 rc = -ENOMEM; 793 return -ENOMEM;
794 goto fail1;
795 }
796 794
797 rc = falcon_probe_rx(rx_queue); 795 rc = falcon_probe_rx(rx_queue);
798 if (rc) 796 if (rc) {
799 goto fail2; 797 kfree(rx_queue->buffer);
800 798 rx_queue->buffer = NULL;
801 return 0; 799 }
802
803 fail2:
804 kfree(rx_queue->buffer);
805 rx_queue->buffer = NULL;
806 fail1:
807 rx_queue->used = 0;
808
809 return rc; 800 return rc;
810} 801}
811 802
@@ -872,7 +863,6 @@ void efx_remove_rx_queue(struct efx_rx_queue *rx_queue)
872 863
873 kfree(rx_queue->buffer); 864 kfree(rx_queue->buffer);
874 rx_queue->buffer = NULL; 865 rx_queue->buffer = NULL;
875 rx_queue->used = 0;
876} 866}
877 867
878void efx_flush_lro(struct efx_channel *channel) 868void efx_flush_lro(struct efx_channel *channel)