diff options
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r-- | net/core/net-sysfs.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 49843bf7e43e..7eeadeecc5a2 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -498,17 +498,7 @@ static struct attribute_group wireless_group = { | |||
498 | #define net_class_groups NULL | 498 | #define net_class_groups NULL |
499 | #endif /* CONFIG_SYSFS */ | 499 | #endif /* CONFIG_SYSFS */ |
500 | 500 | ||
501 | #ifdef CONFIG_RPS | 501 | #ifdef CONFIG_SYSFS |
502 | /* | ||
503 | * RX queue sysfs structures and functions. | ||
504 | */ | ||
505 | struct rx_queue_attribute { | ||
506 | struct attribute attr; | ||
507 | ssize_t (*show)(struct netdev_rx_queue *queue, | ||
508 | struct rx_queue_attribute *attr, char *buf); | ||
509 | ssize_t (*store)(struct netdev_rx_queue *queue, | ||
510 | struct rx_queue_attribute *attr, const char *buf, size_t len); | ||
511 | }; | ||
512 | #define to_rx_queue_attr(_attr) container_of(_attr, \ | 502 | #define to_rx_queue_attr(_attr) container_of(_attr, \ |
513 | struct rx_queue_attribute, attr) | 503 | struct rx_queue_attribute, attr) |
514 | 504 | ||
@@ -543,6 +533,7 @@ static const struct sysfs_ops rx_queue_sysfs_ops = { | |||
543 | .store = rx_queue_attr_store, | 533 | .store = rx_queue_attr_store, |
544 | }; | 534 | }; |
545 | 535 | ||
536 | #ifdef CONFIG_RPS | ||
546 | static ssize_t show_rps_map(struct netdev_rx_queue *queue, | 537 | static ssize_t show_rps_map(struct netdev_rx_queue *queue, |
547 | struct rx_queue_attribute *attribute, char *buf) | 538 | struct rx_queue_attribute *attribute, char *buf) |
548 | { | 539 | { |
@@ -718,16 +709,20 @@ static struct rx_queue_attribute rps_cpus_attribute = | |||
718 | static struct rx_queue_attribute rps_dev_flow_table_cnt_attribute = | 709 | static struct rx_queue_attribute rps_dev_flow_table_cnt_attribute = |
719 | __ATTR(rps_flow_cnt, S_IRUGO | S_IWUSR, | 710 | __ATTR(rps_flow_cnt, S_IRUGO | S_IWUSR, |
720 | show_rps_dev_flow_table_cnt, store_rps_dev_flow_table_cnt); | 711 | show_rps_dev_flow_table_cnt, store_rps_dev_flow_table_cnt); |
712 | #endif /* CONFIG_RPS */ | ||
721 | 713 | ||
722 | static struct attribute *rx_queue_default_attrs[] = { | 714 | static struct attribute *rx_queue_default_attrs[] = { |
715 | #ifdef CONFIG_RPS | ||
723 | &rps_cpus_attribute.attr, | 716 | &rps_cpus_attribute.attr, |
724 | &rps_dev_flow_table_cnt_attribute.attr, | 717 | &rps_dev_flow_table_cnt_attribute.attr, |
718 | #endif | ||
725 | NULL | 719 | NULL |
726 | }; | 720 | }; |
727 | 721 | ||
728 | static void rx_queue_release(struct kobject *kobj) | 722 | static void rx_queue_release(struct kobject *kobj) |
729 | { | 723 | { |
730 | struct netdev_rx_queue *queue = to_rx_queue(kobj); | 724 | struct netdev_rx_queue *queue = to_rx_queue(kobj); |
725 | #ifdef CONFIG_RPS | ||
731 | struct rps_map *map; | 726 | struct rps_map *map; |
732 | struct rps_dev_flow_table *flow_table; | 727 | struct rps_dev_flow_table *flow_table; |
733 | 728 | ||
@@ -743,6 +738,7 @@ static void rx_queue_release(struct kobject *kobj) | |||
743 | RCU_INIT_POINTER(queue->rps_flow_table, NULL); | 738 | RCU_INIT_POINTER(queue->rps_flow_table, NULL); |
744 | call_rcu(&flow_table->rcu, rps_dev_flow_table_release); | 739 | call_rcu(&flow_table->rcu, rps_dev_flow_table_release); |
745 | } | 740 | } |
741 | #endif | ||
746 | 742 | ||
747 | memset(kobj, 0, sizeof(*kobj)); | 743 | memset(kobj, 0, sizeof(*kobj)); |
748 | dev_put(queue->dev); | 744 | dev_put(queue->dev); |
@@ -763,25 +759,36 @@ static int rx_queue_add_kobject(struct net_device *net, int index) | |||
763 | kobj->kset = net->queues_kset; | 759 | kobj->kset = net->queues_kset; |
764 | error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL, | 760 | error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL, |
765 | "rx-%u", index); | 761 | "rx-%u", index); |
766 | if (error) { | 762 | if (error) |
767 | kobject_put(kobj); | 763 | goto exit; |
768 | return error; | 764 | |
765 | if (net->sysfs_rx_queue_group) { | ||
766 | error = sysfs_create_group(kobj, net->sysfs_rx_queue_group); | ||
767 | if (error) | ||
768 | goto exit; | ||
769 | } | 769 | } |
770 | 770 | ||
771 | kobject_uevent(kobj, KOBJ_ADD); | 771 | kobject_uevent(kobj, KOBJ_ADD); |
772 | dev_hold(queue->dev); | 772 | dev_hold(queue->dev); |
773 | 773 | ||
774 | return error; | 774 | return error; |
775 | exit: | ||
776 | kobject_put(kobj); | ||
777 | return error; | ||
775 | } | 778 | } |
776 | #endif /* CONFIG_RPS */ | 779 | #endif /* CONFIG_SYFS */ |
777 | 780 | ||
778 | int | 781 | int |
779 | net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num) | 782 | net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num) |
780 | { | 783 | { |
781 | #ifdef CONFIG_RPS | 784 | #ifdef CONFIG_SYSFS |
782 | int i; | 785 | int i; |
783 | int error = 0; | 786 | int error = 0; |
784 | 787 | ||
788 | #ifndef CONFIG_RPS | ||
789 | if (!net->sysfs_rx_queue_group) | ||
790 | return 0; | ||
791 | #endif | ||
785 | for (i = old_num; i < new_num; i++) { | 792 | for (i = old_num; i < new_num; i++) { |
786 | error = rx_queue_add_kobject(net, i); | 793 | error = rx_queue_add_kobject(net, i); |
787 | if (error) { | 794 | if (error) { |
@@ -790,8 +797,12 @@ net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num) | |||
790 | } | 797 | } |
791 | } | 798 | } |
792 | 799 | ||
793 | while (--i >= new_num) | 800 | while (--i >= new_num) { |
801 | if (net->sysfs_rx_queue_group) | ||
802 | sysfs_remove_group(&net->_rx[i].kobj, | ||
803 | net->sysfs_rx_queue_group); | ||
794 | kobject_put(&net->_rx[i].kobj); | 804 | kobject_put(&net->_rx[i].kobj); |
805 | } | ||
795 | 806 | ||
796 | return error; | 807 | return error; |
797 | #else | 808 | #else |
@@ -1155,9 +1166,6 @@ static int register_queue_kobjects(struct net_device *net) | |||
1155 | NULL, &net->dev.kobj); | 1166 | NULL, &net->dev.kobj); |
1156 | if (!net->queues_kset) | 1167 | if (!net->queues_kset) |
1157 | return -ENOMEM; | 1168 | return -ENOMEM; |
1158 | #endif | ||
1159 | |||
1160 | #ifdef CONFIG_RPS | ||
1161 | real_rx = net->real_num_rx_queues; | 1169 | real_rx = net->real_num_rx_queues; |
1162 | #endif | 1170 | #endif |
1163 | real_tx = net->real_num_tx_queues; | 1171 | real_tx = net->real_num_tx_queues; |
@@ -1184,7 +1192,7 @@ static void remove_queue_kobjects(struct net_device *net) | |||
1184 | { | 1192 | { |
1185 | int real_rx = 0, real_tx = 0; | 1193 | int real_rx = 0, real_tx = 0; |
1186 | 1194 | ||
1187 | #ifdef CONFIG_RPS | 1195 | #ifdef CONFIG_SYSFS |
1188 | real_rx = net->real_num_rx_queues; | 1196 | real_rx = net->real_num_rx_queues; |
1189 | #endif | 1197 | #endif |
1190 | real_tx = net->real_num_tx_queues; | 1198 | real_tx = net->real_num_tx_queues; |