aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2010-09-27 04:24:33 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-28 01:09:49 -0400
commit62fe0b40abb3484413800edaef9b087a20059acf (patch)
tree1fbd745de235b3a1d97931412fa9ff3e7228fd88 /net/core/net-sysfs.c
parentf91ff5b9ff529be8aac2039af63b2c8ea6cd6ebe (diff)
net: Allow changing number of RX queues after device allocation
For RPS, we create a kobject for each RX queue based on the number of queues passed to alloc_netdev_mq(). However, drivers generally do not determine the numbers of hardware queues to use until much later, so this usually represents the maximum number the driver may use and not the actual number in use. For TX queues, drivers can update the actual number using netif_set_real_num_tx_queues(). Add a corresponding function for RX queues, netif_set_real_num_rx_queues(). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r--net/core/net-sysfs.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 76485a3f910b..fa81fd0a488f 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -742,34 +742,38 @@ static int rx_queue_add_kobject(struct net_device *net, int index)
742 return error; 742 return error;
743} 743}
744 744
745static int rx_queue_register_kobjects(struct net_device *net) 745int
746net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
746{ 747{
747 int i; 748 int i;
748 int error = 0; 749 int error = 0;
749 750
750 net->queues_kset = kset_create_and_add("queues", 751 for (i = old_num; i < new_num; i++) {
751 NULL, &net->dev.kobj);
752 if (!net->queues_kset)
753 return -ENOMEM;
754 for (i = 0; i < net->num_rx_queues; i++) {
755 error = rx_queue_add_kobject(net, i); 752 error = rx_queue_add_kobject(net, i);
756 if (error) 753 if (error) {
754 new_num = old_num;
757 break; 755 break;
756 }
758 } 757 }
759 758
760 if (error) 759 while (--i >= new_num)
761 while (--i >= 0) 760 kobject_put(&net->_rx[i].kobj);
762 kobject_put(&net->_rx[i].kobj);
763 761
764 return error; 762 return error;
765} 763}
766 764
767static void rx_queue_remove_kobjects(struct net_device *net) 765static int rx_queue_register_kobjects(struct net_device *net)
768{ 766{
769 int i; 767 net->queues_kset = kset_create_and_add("queues",
768 NULL, &net->dev.kobj);
769 if (!net->queues_kset)
770 return -ENOMEM;
771 return net_rx_queue_update_kobjects(net, 0, net->real_num_rx_queues);
772}
770 773
771 for (i = 0; i < net->num_rx_queues; i++) 774static void rx_queue_remove_kobjects(struct net_device *net)
772 kobject_put(&net->_rx[i].kobj); 775{
776 net_rx_queue_update_kobjects(net, net->real_num_rx_queues, 0);
773 kset_unregister(net->queues_kset); 777 kset_unregister(net->queues_kset);
774} 778}
775#endif /* CONFIG_RPS */ 779#endif /* CONFIG_RPS */