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.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 68dbbfdee274..99c11294623f 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -751,10 +751,12 @@ static int rx_queue_add_kobject(struct net_device *net, int index)
751 751
752 return error; 752 return error;
753} 753}
754#endif /* CONFIG_RPS */
754 755
755int 756int
756net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num) 757net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
757{ 758{
759#ifdef CONFIG_RPS
758 int i; 760 int i;
759 int error = 0; 761 int error = 0;
760 762
@@ -770,8 +772,12 @@ net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
770 kobject_put(&net->_rx[i].kobj); 772 kobject_put(&net->_rx[i].kobj);
771 773
772 return error; 774 return error;
775#else
776 return 0;
777#endif
773} 778}
774 779
780#ifdef CONFIG_XPS
775/* 781/*
776 * netdev_queue sysfs structures and functions. 782 * netdev_queue sysfs structures and functions.
777 */ 783 */
@@ -1090,10 +1096,12 @@ static int netdev_queue_add_kobject(struct net_device *net, int index)
1090 1096
1091 return error; 1097 return error;
1092} 1098}
1099#endif /* CONFIG_XPS */
1093 1100
1094int 1101int
1095netdev_queue_update_kobjects(struct net_device *net, int old_num, int new_num) 1102netdev_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
1096{ 1103{
1104#ifdef CONFIG_XPS
1097 int i; 1105 int i;
1098 int error = 0; 1106 int error = 0;
1099 1107
@@ -1109,27 +1117,36 @@ netdev_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
1109 kobject_put(&net->_tx[i].kobj); 1117 kobject_put(&net->_tx[i].kobj);
1110 1118
1111 return error; 1119 return error;
1120#else
1121 return 0;
1122#endif
1112} 1123}
1113 1124
1114static int register_queue_kobjects(struct net_device *net) 1125static int register_queue_kobjects(struct net_device *net)
1115{ 1126{
1116 int error = 0, txq = 0, rxq = 0; 1127 int error = 0, txq = 0, rxq = 0, real_rx = 0, real_tx = 0;
1117 1128
1129#if defined(CONFIG_RPS) || defined(CONFIG_XPS)
1118 net->queues_kset = kset_create_and_add("queues", 1130 net->queues_kset = kset_create_and_add("queues",
1119 NULL, &net->dev.kobj); 1131 NULL, &net->dev.kobj);
1120 if (!net->queues_kset) 1132 if (!net->queues_kset)
1121 return -ENOMEM; 1133 return -ENOMEM;
1134#endif
1135
1136#ifdef CONFIG_RPS
1137 real_rx = net->real_num_rx_queues;
1138#endif
1139 real_tx = net->real_num_tx_queues;
1122 1140
1123 error = net_rx_queue_update_kobjects(net, 0, net->real_num_rx_queues); 1141 error = net_rx_queue_update_kobjects(net, 0, real_rx);
1124 if (error) 1142 if (error)
1125 goto error; 1143 goto error;
1126 rxq = net->real_num_rx_queues; 1144 rxq = real_rx;
1127 1145
1128 error = netdev_queue_update_kobjects(net, 0, 1146 error = netdev_queue_update_kobjects(net, 0, real_tx);
1129 net->real_num_tx_queues);
1130 if (error) 1147 if (error)
1131 goto error; 1148 goto error;
1132 txq = net->real_num_tx_queues; 1149 txq = real_tx;
1133 1150
1134 return 0; 1151 return 0;
1135 1152
@@ -1141,11 +1158,19 @@ error:
1141 1158
1142static void remove_queue_kobjects(struct net_device *net) 1159static void remove_queue_kobjects(struct net_device *net)
1143{ 1160{
1144 net_rx_queue_update_kobjects(net, net->real_num_rx_queues, 0); 1161 int real_rx = 0, real_tx = 0;
1145 netdev_queue_update_kobjects(net, net->real_num_tx_queues, 0); 1162
1163#ifdef CONFIG_RPS
1164 real_rx = net->real_num_rx_queues;
1165#endif
1166 real_tx = net->real_num_tx_queues;
1167
1168 net_rx_queue_update_kobjects(net, real_rx, 0);
1169 netdev_queue_update_kobjects(net, real_tx, 0);
1170#if defined(CONFIG_RPS) || defined(CONFIG_XPS)
1146 kset_unregister(net->queues_kset); 1171 kset_unregister(net->queues_kset);
1172#endif
1147} 1173}
1148#endif /* CONFIG_RPS */
1149 1174
1150static const void *net_current_ns(void) 1175static const void *net_current_ns(void)
1151{ 1176{
@@ -1244,9 +1269,7 @@ void netdev_unregister_kobject(struct net_device * net)
1244 1269
1245 kobject_get(&dev->kobj); 1270 kobject_get(&dev->kobj);
1246 1271
1247#ifdef CONFIG_RPS
1248 remove_queue_kobjects(net); 1272 remove_queue_kobjects(net);
1249#endif
1250 1273
1251 device_del(dev); 1274 device_del(dev);
1252} 1275}
@@ -1285,13 +1308,11 @@ int netdev_register_kobject(struct net_device *net)
1285 if (error) 1308 if (error)
1286 return error; 1309 return error;
1287 1310
1288#ifdef CONFIG_RPS
1289 error = register_queue_kobjects(net); 1311 error = register_queue_kobjects(net);
1290 if (error) { 1312 if (error) {
1291 device_del(dev); 1313 device_del(dev);
1292 return error; 1314 return error;
1293 } 1315 }
1294#endif
1295 1316
1296 return error; 1317 return error;
1297} 1318}