aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2010-11-26 03:36:09 -0500
committerDavid S. Miller <davem@davemloft.net>2010-11-28 21:24:14 -0500
commitbf26414510103448ad3dc069c7422462f03ea3d7 (patch)
treeb8930bb2850dbc65f1e1f4e8bc6574f3c956b772 /net/core
parent8fa9208e305e24978b897d6ea057604444ce77e1 (diff)
xps: Add CONFIG_XPS
This patch adds XPS_CONFIG option to enable and disable XPS. This is done in the same manner as RPS_CONFIG. This is also fixes build failure in XPS code when SMP is not enabled. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c9
-rw-r--r--net/core/net-sysfs.c47
-rw-r--r--net/core/net-sysfs.h3
3 files changed, 40 insertions, 19 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index c852f0038a0..3259d2c323a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1567,6 +1567,9 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
1567 1567
1568 rc = netdev_queue_update_kobjects(dev, dev->real_num_tx_queues, 1568 rc = netdev_queue_update_kobjects(dev, dev->real_num_tx_queues,
1569 txq); 1569 txq);
1570 if (rc)
1571 return rc;
1572
1570 if (txq < dev->real_num_tx_queues) 1573 if (txq < dev->real_num_tx_queues)
1571 qdisc_reset_all_tx_gt(dev, txq); 1574 qdisc_reset_all_tx_gt(dev, txq);
1572 } 1575 }
@@ -2148,7 +2151,7 @@ static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index)
2148 2151
2149static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb) 2152static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
2150{ 2153{
2151#ifdef CONFIG_RPS 2154#ifdef CONFIG_XPS
2152 struct xps_dev_maps *dev_maps; 2155 struct xps_dev_maps *dev_maps;
2153 struct xps_map *map; 2156 struct xps_map *map;
2154 int queue_index = -1; 2157 int queue_index = -1;
@@ -5085,9 +5088,9 @@ void netif_stacked_transfer_operstate(const struct net_device *rootdev,
5085} 5088}
5086EXPORT_SYMBOL(netif_stacked_transfer_operstate); 5089EXPORT_SYMBOL(netif_stacked_transfer_operstate);
5087 5090
5091#ifdef CONFIG_RPS
5088static int netif_alloc_rx_queues(struct net_device *dev) 5092static int netif_alloc_rx_queues(struct net_device *dev)
5089{ 5093{
5090#ifdef CONFIG_RPS
5091 unsigned int i, count = dev->num_rx_queues; 5094 unsigned int i, count = dev->num_rx_queues;
5092 struct netdev_rx_queue *rx; 5095 struct netdev_rx_queue *rx;
5093 5096
@@ -5102,9 +5105,9 @@ static int netif_alloc_rx_queues(struct net_device *dev)
5102 5105
5103 for (i = 0; i < count; i++) 5106 for (i = 0; i < count; i++)
5104 rx[i].dev = dev; 5107 rx[i].dev = dev;
5105#endif
5106 return 0; 5108 return 0;
5107} 5109}
5110#endif
5108 5111
5109static int netif_alloc_netdev_queues(struct net_device *dev) 5112static int netif_alloc_netdev_queues(struct net_device *dev)
5110{ 5113{
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 68dbbfdee27..99c11294623 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}
diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h
index 25ec2ee57df..bd7751ec1c4 100644
--- a/net/core/net-sysfs.h
+++ b/net/core/net-sysfs.h
@@ -4,11 +4,8 @@
4int netdev_kobject_init(void); 4int netdev_kobject_init(void);
5int netdev_register_kobject(struct net_device *); 5int netdev_register_kobject(struct net_device *);
6void netdev_unregister_kobject(struct net_device *); 6void netdev_unregister_kobject(struct net_device *);
7#ifdef CONFIG_RPS
8int net_rx_queue_update_kobjects(struct net_device *, int old_num, int new_num); 7int net_rx_queue_update_kobjects(struct net_device *, int old_num, int new_num);
9int netdev_queue_update_kobjects(struct net_device *net, 8int netdev_queue_update_kobjects(struct net_device *net,
10 int old_num, int new_num); 9 int old_num, int new_num);
11 10
12#endif 11#endif
13
14#endif