aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r--net/core/net-sysfs.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index c71c434a4c05..db6c2f83633f 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -606,9 +606,12 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
606 rcu_assign_pointer(queue->rps_map, map); 606 rcu_assign_pointer(queue->rps_map, map);
607 spin_unlock(&rps_map_lock); 607 spin_unlock(&rps_map_lock);
608 608
609 if (old_map) 609 if (map)
610 jump_label_inc(&rps_needed);
611 if (old_map) {
610 kfree_rcu(old_map, rcu); 612 kfree_rcu(old_map, rcu);
611 613 jump_label_dec(&rps_needed);
614 }
612 free_cpumask_var(mask); 615 free_cpumask_var(mask);
613 return len; 616 return len;
614} 617}
@@ -780,7 +783,7 @@ net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
780#endif 783#endif
781} 784}
782 785
783#ifdef CONFIG_XPS 786#ifdef CONFIG_SYSFS
784/* 787/*
785 * netdev_queue sysfs structures and functions. 788 * netdev_queue sysfs structures and functions.
786 */ 789 */
@@ -826,6 +829,23 @@ static const struct sysfs_ops netdev_queue_sysfs_ops = {
826 .store = netdev_queue_attr_store, 829 .store = netdev_queue_attr_store,
827}; 830};
828 831
832static ssize_t show_trans_timeout(struct netdev_queue *queue,
833 struct netdev_queue_attribute *attribute,
834 char *buf)
835{
836 unsigned long trans_timeout;
837
838 spin_lock_irq(&queue->_xmit_lock);
839 trans_timeout = queue->trans_timeout;
840 spin_unlock_irq(&queue->_xmit_lock);
841
842 return sprintf(buf, "%lu", trans_timeout);
843}
844
845static struct netdev_queue_attribute queue_trans_timeout =
846 __ATTR(tx_timeout, S_IRUGO, show_trans_timeout, NULL);
847
848#ifdef CONFIG_XPS
829static inline unsigned int get_netdev_queue_index(struct netdev_queue *queue) 849static inline unsigned int get_netdev_queue_index(struct netdev_queue *queue)
830{ 850{
831 struct net_device *dev = queue->dev; 851 struct net_device *dev = queue->dev;
@@ -901,7 +921,7 @@ static ssize_t store_xps_map(struct netdev_queue *queue,
901 struct xps_map *map, *new_map; 921 struct xps_map *map, *new_map;
902 struct xps_dev_maps *dev_maps, *new_dev_maps; 922 struct xps_dev_maps *dev_maps, *new_dev_maps;
903 int nonempty = 0; 923 int nonempty = 0;
904 int numa_node = -2; 924 int numa_node_id = -2;
905 925
906 if (!capable(CAP_NET_ADMIN)) 926 if (!capable(CAP_NET_ADMIN))
907 return -EPERM; 927 return -EPERM;
@@ -944,10 +964,10 @@ static ssize_t store_xps_map(struct netdev_queue *queue,
944 need_set = cpumask_test_cpu(cpu, mask) && cpu_online(cpu); 964 need_set = cpumask_test_cpu(cpu, mask) && cpu_online(cpu);
945#ifdef CONFIG_NUMA 965#ifdef CONFIG_NUMA
946 if (need_set) { 966 if (need_set) {
947 if (numa_node == -2) 967 if (numa_node_id == -2)
948 numa_node = cpu_to_node(cpu); 968 numa_node_id = cpu_to_node(cpu);
949 else if (numa_node != cpu_to_node(cpu)) 969 else if (numa_node_id != cpu_to_node(cpu))
950 numa_node = -1; 970 numa_node_id = -1;
951 } 971 }
952#endif 972#endif
953 if (need_set && pos >= map_len) { 973 if (need_set && pos >= map_len) {
@@ -997,7 +1017,7 @@ static ssize_t store_xps_map(struct netdev_queue *queue,
997 if (dev_maps) 1017 if (dev_maps)
998 kfree_rcu(dev_maps, rcu); 1018 kfree_rcu(dev_maps, rcu);
999 1019
1000 netdev_queue_numa_node_write(queue, (numa_node >= 0) ? numa_node : 1020 netdev_queue_numa_node_write(queue, (numa_node_id >= 0) ? numa_node_id :
1001 NUMA_NO_NODE); 1021 NUMA_NO_NODE);
1002 1022
1003 mutex_unlock(&xps_map_mutex); 1023 mutex_unlock(&xps_map_mutex);
@@ -1020,12 +1040,17 @@ error:
1020 1040
1021static struct netdev_queue_attribute xps_cpus_attribute = 1041static struct netdev_queue_attribute xps_cpus_attribute =
1022 __ATTR(xps_cpus, S_IRUGO | S_IWUSR, show_xps_map, store_xps_map); 1042 __ATTR(xps_cpus, S_IRUGO | S_IWUSR, show_xps_map, store_xps_map);
1043#endif /* CONFIG_XPS */
1023 1044
1024static struct attribute *netdev_queue_default_attrs[] = { 1045static struct attribute *netdev_queue_default_attrs[] = {
1046 &queue_trans_timeout.attr,
1047#ifdef CONFIG_XPS
1025 &xps_cpus_attribute.attr, 1048 &xps_cpus_attribute.attr,
1049#endif
1026 NULL 1050 NULL
1027}; 1051};
1028 1052
1053#ifdef CONFIG_XPS
1029static void netdev_queue_release(struct kobject *kobj) 1054static void netdev_queue_release(struct kobject *kobj)
1030{ 1055{
1031 struct netdev_queue *queue = to_netdev_queue(kobj); 1056 struct netdev_queue *queue = to_netdev_queue(kobj);
@@ -1076,10 +1101,13 @@ static void netdev_queue_release(struct kobject *kobj)
1076 memset(kobj, 0, sizeof(*kobj)); 1101 memset(kobj, 0, sizeof(*kobj));
1077 dev_put(queue->dev); 1102 dev_put(queue->dev);
1078} 1103}
1104#endif /* CONFIG_XPS */
1079 1105
1080static struct kobj_type netdev_queue_ktype = { 1106static struct kobj_type netdev_queue_ktype = {
1081 .sysfs_ops = &netdev_queue_sysfs_ops, 1107 .sysfs_ops = &netdev_queue_sysfs_ops,
1108#ifdef CONFIG_XPS
1082 .release = netdev_queue_release, 1109 .release = netdev_queue_release,
1110#endif
1083 .default_attrs = netdev_queue_default_attrs, 1111 .default_attrs = netdev_queue_default_attrs,
1084}; 1112};
1085 1113
@@ -1102,12 +1130,12 @@ static int netdev_queue_add_kobject(struct net_device *net, int index)
1102 1130
1103 return error; 1131 return error;
1104} 1132}
1105#endif /* CONFIG_XPS */ 1133#endif /* CONFIG_SYSFS */
1106 1134
1107int 1135int
1108netdev_queue_update_kobjects(struct net_device *net, int old_num, int new_num) 1136netdev_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
1109{ 1137{
1110#ifdef CONFIG_XPS 1138#ifdef CONFIG_SYSFS
1111 int i; 1139 int i;
1112 int error = 0; 1140 int error = 0;
1113 1141
@@ -1125,14 +1153,14 @@ netdev_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
1125 return error; 1153 return error;
1126#else 1154#else
1127 return 0; 1155 return 0;
1128#endif 1156#endif /* CONFIG_SYSFS */
1129} 1157}
1130 1158
1131static int register_queue_kobjects(struct net_device *net) 1159static int register_queue_kobjects(struct net_device *net)
1132{ 1160{
1133 int error = 0, txq = 0, rxq = 0, real_rx = 0, real_tx = 0; 1161 int error = 0, txq = 0, rxq = 0, real_rx = 0, real_tx = 0;
1134 1162
1135#if defined(CONFIG_RPS) || defined(CONFIG_XPS) 1163#ifdef CONFIG_SYSFS
1136 net->queues_kset = kset_create_and_add("queues", 1164 net->queues_kset = kset_create_and_add("queues",
1137 NULL, &net->dev.kobj); 1165 NULL, &net->dev.kobj);
1138 if (!net->queues_kset) 1166 if (!net->queues_kset)
@@ -1173,7 +1201,7 @@ static void remove_queue_kobjects(struct net_device *net)
1173 1201
1174 net_rx_queue_update_kobjects(net, real_rx, 0); 1202 net_rx_queue_update_kobjects(net, real_rx, 0);
1175 netdev_queue_update_kobjects(net, real_tx, 0); 1203 netdev_queue_update_kobjects(net, real_tx, 0);
1176#if defined(CONFIG_RPS) || defined(CONFIG_XPS) 1204#ifdef CONFIG_SYSFS
1177 kset_unregister(net->queues_kset); 1205 kset_unregister(net->queues_kset);
1178#endif 1206#endif
1179} 1207}