From c75e69e48bf9b082d06fc3968d33dc8a02b6c186 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 15 Jun 2013 15:17:50 +0200 Subject: [PATCH] backports: move netif_set_real_num_rx_queues() to compat-2.6.37.c netif_set_real_num_rx_queues() was added to kernel version 2.6.37 and not to kernel 2.6.35 therefore it should also be added to the corresponding compat-*.c file. This also adds a missing EXPORT_SYMBOL, documentation and a check. Signed-off-by: Hauke Mehrtens --- backport/compat/compat-2.6.35.c | 15 --------------- backport/compat/compat-2.6.37.c | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/backport/compat/compat-2.6.35.c b/backport/compat/compat-2.6.35.c index 86ea5570b81e..e59cdc1cfab0 100644 --- a/backport/compat/compat-2.6.35.c +++ b/backport/compat/compat-2.6.35.c @@ -17,21 +17,6 @@ #include #include -#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4)) -#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 -#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/backport/compat/compat-2.6.37.c b/backport/compat/compat-2.6.37.c index 5c6cc7b236c9..cc85b1505178 100644 --- a/backport/compat/compat-2.6.37.c +++ b/backport/compat/compat-2.6.37.c @@ -357,3 +357,30 @@ void *vzalloc(unsigned long size) return buf; } EXPORT_SYMBOL_GPL(vzalloc); + +#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4)) +#ifdef CONFIG_RPS +/** + * netif_set_real_num_rx_queues - set actual number of RX queues used + * @dev: Network device + * @rxq: Actual number of RX queues + * + * This must be called either with the rtnl_lock held or before + * registration of the net device. Returns 0 on success, or a + * negative error code. If called before registration, it always + * succeeds. + */ +int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq) +{ + if (rxq < 1 || rxq > dev->num_rx_queues) + return -EINVAL; + + /* 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; +} +EXPORT_SYMBOL(netif_set_real_num_rx_queues); +#endif +#endif -- 2.30.2