From 398882cbddd79534b8068a94f279caf115583de7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 3 Dec 2012 17:36:15 -0800 Subject: [PATCH] compat: backport netif_set_real_num_rx_queues() 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 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 Signed-off-by: David S. Miller 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 --- compat/compat-2.6.35.c | 13 +++++++++++++ include/linux/compat-2.6.37.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index c2c54bb8734a..d33db4648e4d 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -12,6 +12,19 @@ #include #include +#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. diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 7e14853bccb7..d1e7db95b69b 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -9,6 +9,18 @@ #include #include #include +#include + +#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) { -- 2.30.2