diff options
author | Tom Herbert <therbert@google.com> | 2010-10-18 14:00:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-20 05:27:59 -0400 |
commit | bd25fa7ba59cd26094319dfba0011b48465f7355 (patch) | |
tree | 34527956dacf0309d30257b02272e97e729219c9 /net/core | |
parent | 55513fb4281464e97aa1ff2b9c906ca5aed917c5 (diff) |
net: cleanups in RX queue allocation
Clean up in RX queue allocation. In netif_set_real_num_rx_queues
return error on attempt to set zero queues, or requested number is
greater than number of allocated queues. In netif_alloc_rx_queues,
do BUG_ON if queue_count is zero.
Signed-off-by: Tom Herbert <therbert@google.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index f44d29ae5d6..d33adecec44 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1583,12 +1583,12 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq) | |||
1583 | { | 1583 | { |
1584 | int rc; | 1584 | int rc; |
1585 | 1585 | ||
1586 | if (rxq < 1 || rxq > dev->num_rx_queues) | ||
1587 | return -EINVAL; | ||
1588 | |||
1586 | if (dev->reg_state == NETREG_REGISTERED) { | 1589 | if (dev->reg_state == NETREG_REGISTERED) { |
1587 | ASSERT_RTNL(); | 1590 | ASSERT_RTNL(); |
1588 | 1591 | ||
1589 | if (rxq > dev->num_rx_queues) | ||
1590 | return -EINVAL; | ||
1591 | |||
1592 | rc = net_rx_queue_update_kobjects(dev, dev->real_num_rx_queues, | 1592 | rc = net_rx_queue_update_kobjects(dev, dev->real_num_rx_queues, |
1593 | rxq); | 1593 | rxq); |
1594 | if (rc) | 1594 | if (rc) |
@@ -5013,25 +5013,23 @@ static int netif_alloc_rx_queues(struct net_device *dev) | |||
5013 | { | 5013 | { |
5014 | #ifdef CONFIG_RPS | 5014 | #ifdef CONFIG_RPS |
5015 | unsigned int i, count = dev->num_rx_queues; | 5015 | unsigned int i, count = dev->num_rx_queues; |
5016 | struct netdev_rx_queue *rx; | ||
5016 | 5017 | ||
5017 | if (count) { | 5018 | BUG_ON(count < 1); |
5018 | struct netdev_rx_queue *rx; | ||
5019 | |||
5020 | rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL); | ||
5021 | if (!rx) { | ||
5022 | pr_err("netdev: Unable to allocate %u rx queues.\n", | ||
5023 | count); | ||
5024 | return -ENOMEM; | ||
5025 | } | ||
5026 | dev->_rx = rx; | ||
5027 | 5019 | ||
5028 | /* | 5020 | rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL); |
5029 | * Set a pointer to first element in the array which holds the | 5021 | if (!rx) { |
5030 | * reference count. | 5022 | pr_err("netdev: Unable to allocate %u rx queues.\n", count); |
5031 | */ | 5023 | return -ENOMEM; |
5032 | for (i = 0; i < count; i++) | ||
5033 | rx[i].first = rx; | ||
5034 | } | 5024 | } |
5025 | dev->_rx = rx; | ||
5026 | |||
5027 | /* | ||
5028 | * Set a pointer to first element in the array which holds the | ||
5029 | * reference count. | ||
5030 | */ | ||
5031 | for (i = 0; i < count; i++) | ||
5032 | rx[i].first = rx; | ||
5035 | #endif | 5033 | #endif |
5036 | return 0; | 5034 | return 0; |
5037 | } | 5035 | } |