netif_set_real_num_rx_queues() was added on v2.6.37 but
requires CONFIG_RPS support which was added on v2.6.35.
A few updates were done on the net core though to support
changing the number of RX queues if the device was already
registered. We can't support this on older kernels though
so the best we can do is for kernels >= 2.6.35 simply try
to update the num_rx_queues and if the device is registered
fail.
mcgrof@frijol ~/linux-next (git::master)$ git describe --contains
62fe0b40
v2.6.37-rc1~147^2~340
commit
62fe0b40abb3484413800edaef9b087a20059acf
Author: Ben Hutchings <bhutchings@solarflare.com>
Date: Mon Sep 27 08:24:33 2010 +0000
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>
mcgrof@drvbp1 ~/compat (git::master)$ time ckmake
Trying kernel 3.6.5-030605-generic [OK]
Trying kernel 3.5.7-030507-generic [OK]
Trying kernel 3.4.17-030417-generic [OK]
Trying kernel 3.3.8-030308-generic [OK]
Trying kernel 3.2.33-030233-generic [OK]
Trying kernel 3.1.10-030110-generic [OK]
Trying kernel 3.0.50-030050-generic [OK]
Trying kernel 2.6.39-
02063904-generic [OK]
Trying kernel 2.6.38-
02063808-generic [OK]
Trying kernel 2.6.37-
02063706-generic [OK]
Trying kernel 2.6.36-
02063604-generic [OK]
Trying kernel 2.6.35-
02063513-generic [OK]
Trying kernel 2.6.34-
02063413-generic [OK]
Trying kernel 2.6.33-
02063320-generic [OK]
Trying kernel 2.6.32-
02063260-generic [OK]
Trying kernel 2.6.31-
02063113-generic [OK]
Trying kernel 2.6.30-
02063010-generic [OK]
Trying kernel 2.6.29-
02062906-generic [OK]
Trying kernel 2.6.28-
02062810-generic [OK]
Trying kernel 2.6.27-020627-generic [OK]
Trying kernel 2.6.26-020626-generic [OK]
Trying kernel 2.6.25-020625-generic [OK]
Trying kernel 2.6.24-020624-generic [OK]
real 2m5.270s
user 8m51.501s
sys 2m1.576s
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
#include <linux/compat.h>
#include <linux/ctype.h>
+#ifdef CONFIG_RPS
+int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq)
+{
+ int rc;
+
+ /* we can't update the sysfs object for older kernels */
+ if (dev->reg_state == NETREG_REGISTERED)
+ return -EINVAL;
+ dev->num_rx_queues = rxq;
+ return 0;
+}
+#endif
+
/*
* Routine to help set real_num_tx_queues. To avoid skbs mapped to queues
* greater then real_num_tx_queues stale skbs on the qdisc must be flushed.
#include <linux/leds.h>
#include <linux/in.h>
#include <linux/errno.h>
+#include <linux/netdevice.h>
+
+#ifdef CONFIG_RPS
+extern int netif_set_real_num_rx_queues(struct net_device *dev,
+ unsigned int rxq);
+#else
+static inline int netif_set_real_num_rx_queues(struct net_device *dev,
+ unsigned int rxq)
+{
+ return 0;
+}
+#endif
static inline int proto_ports_offset(int proto)
{