Skip to contentSkip to conversation

netdev: Fix queue count initialisation

PATCH In review Ben Hutchings 6 participants 28 messages Sep 27, 2010 – Sep 28, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover netdev: Fix queue count initialisation

This adds the functions:
- netif_set_real_num_rx_queues() - set actual number of RX queues used
- netif_copy_real_num_queues() - copy queue counts from another device

and changes all drivers that currently set net_device::real_num_tx_queues to use netif_set_real_num_tx_queues() and/or these functions.

The changes are compile-tested only, except that:
- sfc and 8021q have been briefly tested
- gianfar and mv643xx_eth have not been compiled, since they are platform-specific

I noticed that the bonding driver sets its numbers of queues without regard to its slave devices. This makes some sense since a bond device initially has no slave devices. However, it seems to mean that a bond device can pass up an skb with an out-of-range queue_index, triggering a warning in get_rps_cpu().

Ben.

Ben Hutchings (17):
net: Allow changing number of RX queues after device allocation
net: Add netif_copy_real_num_queues() for use by virtual net drivers
bnx2: Use netif_set_real_num_{rx,tx}_queues()
bnx2x: Use netif_set_real_num_{rx,tx}_queues()
cxgb3: Use netif_set_real_num_{rx,tx}_queues()
cxgb4: Use netif_set_real_num_{rx,tx}_queues()
cxgb4vf: Use netif_set_real_num_{rx,tx}_queues()
gianfar: Use netif_set_real_num_rx_queues()
igb: Use netif_set_real_num_{rx,tx}_queues()
ixgbe: Use netif_set_real_num_{rx,tx}_queues()
mlx4_en: Use netif_set_real_num_{rx,tx}_queues()
mv643xx_eth: Use netif_set_real_num_{rx,tx}_queues()
myri10ge: Use netif_set_real_num_{rx,tx}_queues()
niu: Use netif_set_real_num_{rx,tx}_queues()
sfc: Use netif_set_real_num_{rx,tx}_queues()
tg3: Use netif_set_real_num_{rx,tx}_queues()
8021q: Use netif_copy_real_num_queues() to set queue counts

 drivers/net/bnx2.c                 |    9 ++++--
 drivers/net/bnx2x/bnx2x_cmn.c      |    6 +++-
 drivers/net/cxgb3/cxgb3_main.c     |    5 +++-
 drivers/net/cxgb4/cxgb4_main.c     |    5 +++-
 drivers/net/cxgb4vf/cxgb4vf_main.c |    5 +++-
 drivers/net/gianfar.c              |    3 +-
 drivers/net/igb/igb_main.c         |   12 ++++++---
 drivers/net/ixgbe/ixgbe_main.c     |   16 ++++++++----
 drivers/net/mlx4/en_netdev.c       |    3 +-
 drivers/net/mv643xx_eth.c          |    3 +-
 drivers/net/myri10ge/myri10ge.c    |    5 ++-
 drivers/net/niu.c                  |    3 +-
 drivers/net/sfc/efx.c              |    3 +-
 drivers/net/tg3.c                  |    8 ++++-
 include/linux/netdevice.h          |   28 +++++++++++++++++++++-
 net/8021q/vlan.c                   |    2 +-
 net/core/dev.c                     |   45 ++++++++++++++++++++++++++++++++---
 net/core/net-sysfs.c               |   34 +++++++++++++++------------
 net/core/net-sysfs.h               |    4 +++
 19 files changed, 151 insertions(+), 48 deletions(-)
Signature · 6 lines
1.7.2.1

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#1 lore raw

PATCH 1/17 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().

---
 include/linux/netdevice.h |   16 +++++++++++++++-
 net/core/dev.c            |   45 +++++++++++++++++++++++++++++++++++++++++----
 net/core/net-sysfs.c      |   34 +++++++++++++++++++---------------
 net/core/net-sysfs.h      |    4 ++++
 4 files changed, 79 insertions(+), 20 deletions(-)
include/linux/netdevice.h +15 -1
index 01bd4c8..cf3d5a3 100644
@@ -976,8 +976,11 @@ struct net_device {
 
 	struct netdev_rx_queue	*_rx;
 
-	/* Number of RX queues allocated at alloc_netdev_mq() time  */
+	/* Number of RX queues allocated at register_netdev() time */
 	unsigned int		num_rx_queues;
+
+	/* Number of RX queues currently active in device */
+	unsigned int		real_num_rx_queues;
 #endif
 
 	rx_handler_func_t	*rx_handler;
@@ -1684,6 +1687,17 @@ static inline int netif_is_multiqueue(const struct net_device *dev)
 extern void netif_set_real_num_tx_queues(struct net_device *dev,
 					 unsigned int txq);
 
+#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
+
 /* Use this variant when it is known for sure that it
  * is executing from hardware interrupt context or with hardware interrupts
  * disabled.
net/core/dev.c +41 -4

63 lines not on this page · raw message

net/core/net-sysfs.c +19 -15
index 76485a3..4791cfc 100644
@@ -742,34 +742,38 @@ static int rx_queue_add_kobject(struct net_device *net, int index)
 	return error;
 }
 
-static int rx_queue_register_kobjects(struct net_device *net)
+int
+net_rx_queue_update_kobjects(struct net_device *net, int old_num, int new_num)
 {
 	int i;
 	int error = 0;
-
-	net->queues_kset = kset_create_and_add("queues",
-	    NULL, &net->dev.kobj);
-	if (!net->queues_kset)
-		return -ENOMEM;
-	for (i = 0; i < net->num_rx_queues; i++) {
+	
+	for (i = old_num; i < new_num; i++) {
 		error = rx_queue_add_kobject(net, i);
-		if (error)
+		if (error) {
+			new_num = old_num;
 			break;
+		}
 	}
 
-	if (error)
-		while (--i >= 0)
-			kobject_put(&net->_rx[i].kobj);
+	while (--i >= new_num)
+		kobject_put(&net->_rx[i].kobj);
 
 	return error;
 }
 
-static void rx_queue_remove_kobjects(struct net_device *net)
+static int rx_queue_register_kobjects(struct net_device *net)
 {
-	int i;
+	net->queues_kset = kset_create_and_add("queues",
+	    NULL, &net->dev.kobj);
+	if (!net->queues_kset)
+		return -ENOMEM;
+	return net_rx_queue_update_kobjects(net, 0, net->real_num_rx_queues);
+}
 
-	for (i = 0; i < net->num_rx_queues; i++)
-		kobject_put(&net->_rx[i].kobj);
+static void rx_queue_remove_kobjects(struct net_device *net)
+{
+	net_rx_queue_update_kobjects(net, net->real_num_rx_queues, 0);
 	kset_unregister(net->queues_kset);
 }
 #endif /* CONFIG_RPS */
net/core/net-sysfs.h +4 -0
index 805555e..778e157 100644
@@ -4,4 +4,8 @@
 int netdev_kobject_init(void);
 int netdev_register_kobject(struct net_device *);
 void netdev_unregister_kobject(struct net_device *);
+#ifdef CONFIG_RPS
+int net_rx_queue_update_kobjects(struct net_device *, int old_num, int new_num);
+#endif
+
 #endif
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#2 lore raw

PATCH 2/17 net: Add netif_copy_real_num_queues() for use by virtual net drivers

In reply to Ben Hutchings

This sets the active numbers of queues on a net device to match another.

---
 include/linux/netdevice.h |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
include/linux/netdevice.h +12 -0
index cf3d5a3..7fd39b3 100644
@@ -1698,6 +1698,18 @@ static inline int netif_set_real_num_rx_queues(struct net_device *dev,
 }
 #endif
 
+static inline int netif_copy_real_num_queues(struct net_device *to_dev,
+					     const struct net_device *from_dev)
+{
+	netif_set_real_num_tx_queues(to_dev, from_dev->real_num_tx_queues);
+#ifdef CONFIG_RPS
+	return netif_set_real_num_rx_queues(to_dev,
+					    from_dev->real_num_rx_queues);
+#else
+	return 0;
+#endif
+}
+
 /* Use this variant when it is known for sure that it
  * is executing from hardware interrupt context or with hardware interrupts
  * disabled.
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#3 lore raw

PATCH 3/17 bnx2: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/bnx2.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/bnx2.c +6 -3
index 3d1a5da..b10be27 100644
@@ -6202,7 +6202,7 @@ bnx2_enable_msix(struct bnx2 *bp, int msix_vecs)
 	}
 }
 
-static void
+static int
 bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
 {
 	int cpus = num_online_cpus();
@@ -6231,9 +6231,10 @@ bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
 	}
 
 	bp->num_tx_rings = rounddown_pow_of_two(bp->irq_nvecs);
-	bp->dev->real_num_tx_queues = bp->num_tx_rings;
+	netif_set_real_num_tx_queues(bp->dev, bp->num_tx_rings);
 
 	bp->num_rx_rings = bp->irq_nvecs;
+	return netif_set_real_num_rx_queues(bp->dev, bp->num_rx_rings);
 }
 
 /* Called with rtnl_lock */
@@ -6248,7 +6249,9 @@ bnx2_open(struct net_device *dev)
 	bnx2_set_power_state(bp, PCI_D0);
 	bnx2_disable_int(bp);
 
-	bnx2_setup_int_mode(bp, disable_msi);
+	rc = bnx2_setup_int_mode(bp, disable_msi);
+	if (rc)
+		goto open_err;
 	bnx2_init_napi(bp);
 	bnx2_napi_enable(bp);
 	rc = bnx2_alloc_mem(bp);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#4 lore raw

PATCH 4/17 bnx2x: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/bnx2x/bnx2x_cmn.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/bnx2x/bnx2x_cmn.c +4 -2
index efc7be4..05c05a4 100644
@@ -1207,8 +1207,8 @@ static int bnx2x_set_num_queues(struct bnx2x *bp)
 			bp->num_queues = 1;
 		break;
 	}
-	bp->dev->real_num_tx_queues = bp->num_queues;
-	return rc;
+	netif_set_real_num_tx_queues(bp->dev, bp->num_queues);
+	return netif_set_real_num_rx_queues(bp->dev, bp->num_queues);
 }
 
 static void bnx2x_release_firmware(struct bnx2x *bp)
@@ -1240,6 +1240,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 	bp->state = BNX2X_STATE_OPENING_WAIT4_LOAD;
 
 	rc = bnx2x_set_num_queues(bp);
+	if (rc)
+		return rc;
 
 	if (bnx2x_alloc_mem(bp)) {
 		bnx2x_free_irq(bp, true);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#5 lore raw

RE: [PATCH net-next-2.6 04/17] bnx2x: Use netif_set_real_num_{rx,tx}_queues()

Quoted 42 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Ben Hutchings
Sent: Monday, September 27, 2010 8:25 PM
To: David Miller
Cc: [email protected]; [email protected]; Eilon Greenstein
Subject: [PATCH net-next-2.6 04/17] bnx2x: Use netif_set_real_num_{rx,tx}_queues()

---
 drivers/net/bnx2x/bnx2x_cmn.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/bnx2x/bnx2x_cmn.c +4 -2
index efc7be4..05c05a4 100644
@@ -1207,8 +1207,8 @@ static int bnx2x_set_num_queues(struct bnx2x *bp)
 			bp->num_queues = 1;
 		break;
 	}
-	bp->dev->real_num_tx_queues = bp->num_queues;
-	return rc;
+	netif_set_real_num_tx_queues(bp->dev, bp->num_queues);
+	return netif_set_real_num_rx_queues(bp->dev, bp->num_queues);
 }
 
 static void bnx2x_release_firmware(struct bnx2x *bp)
@@ -1240,6 +1240,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int
 load_mode)
 	bp->state = BNX2X_STATE_OPENING_WAIT4_LOAD;
 
 	rc = bnx2x_set_num_queues(bp);
+	if (rc)
+		return rc;
 
 	if (bnx2x_alloc_mem(bp)) {
Quoted 4 lines

bnx2x_free_irq(bp, true);
--
1.7.2.1

This patch breaks our interrupt enablement flow. I'll send the new one that incorporates the netif_set_real_num_rx_queues() shortly.

Thanks,
vlad

Quoted 11 lines

--
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

RE: [PATCH net-next-2.6 04/17] bnx2x: Use netif_set_real_num_{rx,tx}_queues()

Quoted 54 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Vladislav Zolotarov
Sent: Tuesday, September 28, 2010 11:26 AM
To: Ben Hutchings; David Miller
Cc: [email protected]; [email protected]; Eilon Greenstein
Subject: RE: [PATCH net-next-2.6 04/17] bnx2x: Use netif_set_real_num_{rx,tx}_queues()

drivers/net/bnx2x/bnx2x_cmn.c static int bnx2x_set_num_queues(struct bnx2x

Quoted 21 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Ben Hutchings
Sent: Monday, September 27, 2010 8:25 PM
To: David Miller
Cc: [email protected]; [email protected]; Eilon Greenstein
Subject: [PATCH net-next-2.6 04/17] bnx2x: Use netif_set_real_num_{rx,tx}_queues()

---
 drivers/net/bnx2x/bnx2x_cmn.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/bnx2x/bnx2x_cmn.c +0 -0
index efc7be4..05c05a4 100644
@@ -1207,8 +1207,8 @@ static int bnx2x_set_num_queues(struct bnx2x

*bp)

Quoted 18 lines
drivers/net/bnx2x/bnx2x_cmn.c +4 -2
 			bp->num_queues = 1;
 		break;
 	}
-	bp->dev->real_num_tx_queues = bp->num_queues;
-	return rc;
+	netif_set_real_num_tx_queues(bp->dev, bp->num_queues);
+	return netif_set_real_num_rx_queues(bp->dev, bp->num_queues);
 }
 
 static void bnx2x_release_firmware(struct bnx2x *bp)
@@ -1240,6 +1240,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int
 load_mode)
 	bp->state = BNX2X_STATE_OPENING_WAIT4_LOAD;
 
 	rc = bnx2x_set_num_queues(bp);
+	if (rc)
+		return rc;
 
Quoted 8 lines
Quoted 5 lines
drivers/net/bnx2x/bnx2x_cmn.c +0 -0
 	if (bnx2x_alloc_mem(bp)) {

bnx2x_free_irq(bp, true);
--
1.7.2.1

This patch breaks our interrupt enablement flow. I'll send the new one that incorporates the netif_set_real_num_rx_queues() shortly.

Ben, I'm going to fix the bnx2x the way your patch would apply. I suspect this would probably require u to respin the bnx2x patch. Sorry for the inconvenience.

Thanks,
vlad

Quoted 19 lines

Thanks,
vlad

Quoted 11 lines

--
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

��칻�&�~�&���+-��ݶ��w��˛���m�޵ׯ�{ay�ʇڙ�,j ��f���h���z��w���

���j:+v���w�j�m���� ����zZ+�����ݢj"��!�i

maintainer
#7 lore raw

Re: [PATCH net-next-2.6 04/17] bnx2x: Use netif_set_real_num_{rx,tx}_queues()

From: "Vladislav Zolotarov" <[email protected]>
Date: Tue, 28 Sep 2010 05:59:15 -0700

Quoted 3 lines

Ben, I'm going to fix the bnx2x the way your patch would apply. I suspect this would probably require u to respin the bnx2x patch. Sorry for the inconvenience.

Ben's patch is already in the tree, so you need to send me patches relative to his.

#8 lore raw

PATCH 5/17 cxgb3: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/cxgb3/cxgb3_main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/cxgb3/cxgb3_main.c +4 -1
index f9eede0..a04ce6a 100644
@@ -1399,7 +1399,10 @@ static int cxgb_open(struct net_device *dev)
 			       "Could not initialize offload capabilities\n");
 	}
 
-	dev->real_num_tx_queues = pi->nqsets;
+	netif_set_real_num_tx_queues(dev, pi->nqsets);
+	err = netif_set_real_num_rx_queues(dev, pi->nqsets);
+	if (err)
+		return err;
 	link_start(dev);
 	t3_port_intr_enable(adapter, pi->port_id);
 	netif_tx_start_all_queues(dev);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#9 lore raw

PATCH 6/17 cxgb4: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/cxgb4/cxgb4_main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/cxgb4/cxgb4_main.c +4 -1
index 75b9401..4fb08e3 100644
@@ -2763,7 +2763,10 @@ static int cxgb_open(struct net_device *dev)
 			return err;
 	}
 
-	dev->real_num_tx_queues = pi->nqsets;
+	netif_set_real_num_tx_queues(dev, pi->nqsets);
+	err = netif_set_real_num_rx_queues(dev, pi->nqsets);
+	if (err)
+		return err;
 	err = link_start(dev);
 	if (!err)
 		netif_tx_start_all_queues(dev);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#10 lore raw

PATCH 7/17 cxgb4vf: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/cxgb4vf/cxgb4vf_main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/cxgb4vf/cxgb4vf_main.c +4 -1
index 7b6d07f..555ecc5 100644
@@ -748,7 +748,10 @@ static int cxgb4vf_open(struct net_device *dev)
 	/*
 	 * Note that this interface is up and start everything up ...
 	 */
-	dev->real_num_tx_queues = pi->nqsets;
+	netif_set_real_num_tx_queues(dev, pi->nqsets);
+	err = netif_set_real_num_rx_queues(dev, pi->nqsets);
+	if (err)
+		return err;
 	set_bit(pi->port_id, &adapter->open_device_map);
 	link_start(dev);
 	netif_tx_start_all_queues(dev);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#11 lore raw

PATCH 8/17 gianfar: Use netif_set_real_num_rx_queues()

In reply to Ben Hutchings

Do not set num_tx_queues or real_num_tx_queues, since alloc_etherdev_mq() does that.

---
 drivers/net/gianfar.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/gianfar.c +1 -2
index f30adbf..6180089 100644
@@ -654,9 +654,8 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
 	priv->node = ofdev->dev.of_node;
 	priv->ndev = dev;
 
-	dev->num_tx_queues = num_tx_qs;
-	dev->real_num_tx_queues = num_tx_qs;
 	priv->num_tx_queues = num_tx_qs;
+	netif_set_real_num_rx_queues(dev, num_rx_qs);
 	priv->num_rx_queues = num_rx_qs;
 	priv->num_grps = 0x0;
 
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#12 lore raw

PATCH 9/17 igb: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/igb/igb_main.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/igb/igb_main.c +8 -4
index 0394ca9..55edcb7 100644
@@ -988,7 +988,7 @@ static void igb_clear_interrupt_scheme(struct igb_adapter *adapter)
  * Attempt to configure interrupts using the best available
  * capabilities of the hardware and kernel.
  **/
-static void igb_set_interrupt_capability(struct igb_adapter *adapter)
+static int igb_set_interrupt_capability(struct igb_adapter *adapter)
 {
 	int err;
 	int numvecs, i;
@@ -1054,8 +1054,10 @@ msi_only:
 	if (!pci_enable_msi(adapter->pdev))
 		adapter->flags |= IGB_FLAG_HAS_MSI;
 out:
-	/* Notify the stack of the (possibly) reduced Tx Queue count. */
-	adapter->netdev->real_num_tx_queues = adapter->num_tx_queues;
+	/* Notify the stack of the (possibly) reduced queue counts. */
+	netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues);
+	return netif_set_real_num_rx_queues(adapter->netdev,
+					    adapter->num_rx_queues);
 }
 
 /**
@@ -1154,7 +1156,9 @@ static int igb_init_interrupt_scheme(struct igb_adapter *adapter)
 	struct pci_dev *pdev = adapter->pdev;
 	int err;
 
-	igb_set_interrupt_capability(adapter);
+	err = igb_set_interrupt_capability(adapter);
+	if (err)
+		return err;
 
 	err = igb_alloc_q_vectors(adapter);
 	if (err) {
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#13 lore raw

PATCH 10/17 ixgbe: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/ixgbe/ixgbe_main.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_main.c +11 -5
index 4e0ce91..c35185c 100644
@@ -4088,7 +4088,7 @@ static inline bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
  * fallthrough conditions.
  *
  **/
-static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
+static int ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
 {
 	/* Start with base case */
 	adapter->num_rx_queues = 1;
@@ -4097,7 +4097,7 @@ static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
 	adapter->num_rx_queues_per_pool = 1;
 
 	if (ixgbe_set_sriov_queues(adapter))
-		return;
+		goto done;
 
 #ifdef IXGBE_FCOE
 	if (ixgbe_set_fcoe_queues(adapter))
@@ -4120,8 +4120,10 @@ static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
 	adapter->num_tx_queues = 1;
 
 done:
-	/* Notify the stack of the (possibly) reduced Tx Queue count. */
+	/* Notify the stack of the (possibly) reduced queue counts. */
 	netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues);
+	return netif_set_real_num_rx_queues(adapter->netdev,
+					    adapter->num_rx_queues);
 }
 
 static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
@@ -4550,7 +4552,9 @@ static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter)
 	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
 		ixgbe_disable_sriov(adapter);
 
-	ixgbe_set_num_queues(adapter);
+	err = ixgbe_set_num_queues(adapter);
+	if (err)
+		return err;
 
 	err = pci_enable_msi(adapter->pdev);
 	if (!err) {
@@ -4675,7 +4679,9 @@ int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
 	int err;
 
 	/* Number of supported queues */
-	ixgbe_set_num_queues(adapter);
+	err = ixgbe_set_num_queues(adapter);
+	if (err)
+		return err;
 
 	err = ixgbe_set_interrupt_capability(adapter);
 	if (err) {
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#14 lore raw

PATCH 11/17 mlx4_en: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/mlx4/en_netdev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/mlx4/en_netdev.c +2 -1
index 411bda5..79478bd 100644
@@ -1025,7 +1025,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
 	 */
 	dev->netdev_ops = &mlx4_netdev_ops;
 	dev->watchdog_timeo = MLX4_EN_WATCHDOG_TIMEOUT;
-	dev->real_num_tx_queues = MLX4_EN_NUM_TX_RINGS;
+	netif_set_real_num_tx_queues(dev, priv->tx_ring_num);
+	netif_set_real_num_rx_queues(dev, priv->rx_ring_num);
 
 	SET_ETHTOOL_OPS(dev, &mlx4_en_ethtool_ops);
 
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#15 lore raw

PATCH 12/17 mv643xx_eth: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/mv643xx_eth.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/mv643xx_eth.c +2 -1
index 2d488ab..dd2b6a7 100644
@@ -2901,7 +2901,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 	mp->dev = dev;
 
 	set_params(mp, pd);
-	dev->real_num_tx_queues = mp->txq_count;
+	netif_set_real_num_tx_queues(dev, mp->txq_count);
+	netif_set_real_num_rx_queues(dev, mp->rxq_count);
 
 	if (pd->phy_addr != MV643XX_ETH_PHY_NONE)
 		mp->phy = phy_scan(mp, pd->phy_addr);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#17 lore raw

PATCH 13/17 myri10ge: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/myri10ge/myri10ge.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/myri10ge/myri10ge.c +3 -2
index 4f3a3c0..3ad1a21 100644
@@ -990,7 +990,7 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
 		 * RX queues, so if we get an error, first retry using a
 		 * single TX queue before giving up */
 		if (status != 0 && mgp->dev->real_num_tx_queues > 1) {
-			mgp->dev->real_num_tx_queues = 1;
+			netif_set_real_num_tx_queues(mgp->dev, 1);
 			cmd.data0 = mgp->num_slices;
 			cmd.data1 = MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE;
 			status = myri10ge_send_cmd(mgp,
@@ -3923,7 +3923,8 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		dev_err(&pdev->dev, "failed to alloc slice state\n");
 		goto abort_with_firmware;
 	}
-	netdev->real_num_tx_queues = mgp->num_slices;
+	netif_set_real_num_tx_queues(netdev, mgp->num_slices);
+	netif_set_real_num_rx_queues(netdev, mgp->num_slices);
 	status = myri10ge_reset(mgp);
 	if (status != 0) {
 		dev_err(&pdev->dev, "failed reset\n");
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#18 lore raw

PATCH 14/17 niu: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/niu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/niu.c +2 -1
index 4cd9242..c0437fd 100644
@@ -4501,7 +4501,8 @@ static int niu_alloc_channels(struct niu *np)
 	np->num_rx_rings = parent->rxchan_per_port[port];
 	np->num_tx_rings = parent->txchan_per_port[port];
 
-	np->dev->real_num_tx_queues = np->num_tx_rings;
+	netif_set_real_num_rx_queues(np->dev, np->num_rx_rings);
+	netif_set_real_num_tx_queues(np->dev, np->num_tx_rings);
 
 	np->rx_rings = kcalloc(np->num_rx_rings, sizeof(struct rx_ring_info),
 			       GFP_KERNEL);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#19 lore raw

PATCH 15/17 sfc: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings
---
 drivers/net/sfc/efx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/sfc/efx.c +2 -1
index 5be71f4..fa6e020 100644
@@ -1315,7 +1315,8 @@ static int efx_probe_nic(struct efx_nic *efx)
 		efx->rx_indir_table[i] = i % efx->n_rx_channels;
 
 	efx_set_channels(efx);
-	efx->net_dev->real_num_tx_queues = efx->n_tx_channels;
+	netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels);
+	netif_set_real_num_rx_queues(efx->net_dev, efx->n_rx_channels);
 
 	/* Initialise the interrupt moderation settings */
 	efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true);
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#20 lore raw

PATCH 16/17 tg3: Use netif_set_real_num_{rx,tx}_queues()

In reply to Ben Hutchings

---
This *always* sets real_num_tx_queues to 1, so this could be improved. For now, do a simple conversion.

Ben.

 drivers/net/tg3.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/tg3.c +6 -2
index fdb438d..ca41140 100644
@@ -8821,7 +8821,11 @@ static bool tg3_enable_msix(struct tg3 *tp)
 	for (i = 0; i < tp->irq_max; i++)
 		tp->napi[i].irq_vec = msix_ent[i].vector;
 
-	tp->dev->real_num_tx_queues = 1;
+	netif_set_real_num_tx_queues(tp->dev, 1);
+	if (netif_set_real_num_rx_queues(tp->dev, tp->irq_cnt)) {
+		pci_disable_msix(tp->pdev);
+		return false;
+	}
 	if (tp->irq_cnt > 1)
 		tp->tg3_flags3 |= TG3_FLG3_ENABLE_RSS;
 
@@ -8856,7 +8860,7 @@ defcfg:
 	if (!(tp->tg3_flags2 & TG3_FLG2_USING_MSIX)) {
 		tp->irq_cnt = 1;
 		tp->napi[0].irq_vec = tp->pdev->irq;
-		tp->dev->real_num_tx_queues = 1;
+		netif_set_real_num_tx_queues(tp->dev, 1);
 	}
 }
 
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#21 lore raw

Re: [PATCH net-next-2.6 16/17] tg3: Use netif_set_real_num_{rx,tx}_queues()

Quoted 15 lines · Ben Hutchings

---
This *always* sets real_num_tx_queues to 1, so this could be improved. For now, do a simple conversion.

Ben.

 drivers/net/tg3.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/tg3.c +0 -0
index fdb438d..ca41140 100644

drivers/net/tg3.c static bool tg3_enable_msix(struct tg3 *tp) · line 8825

Quoted 6 lines
drivers/net/tg3.c +2 -1
@@ -8821,7 +8821,11 @@ static bool tg3_enable_msix(struct tg3 *tp)
 	for (i = 0; i < tp->irq_max; i++)
 		tp->napi[i].irq_vec = msix_ent[i].vector;
 
-	tp->dev->real_num_tx_queues = 1;
+	netif_set_real_num_tx_queues(tp->dev, 1);
+	if (netif_set_real_num_rx_queues(tp->dev, tp->irq_cnt)) {

This should be tp->irq_cnt - 1, not tp->irq_cnt. The first MSI-X vector only handles link interrupts and device errors.

Quoted 26 lines
drivers/net/tg3.c +4 -1
+		pci_disable_msix(tp->pdev);
+		return false;
+	}
 	if (tp->irq_cnt > 1)
 		tp->tg3_flags3 |= TG3_FLG3_ENABLE_RSS;
 
@@ -8856,7 +8860,7 @@ defcfg:
 	if (!(tp->tg3_flags2 & TG3_FLG2_USING_MSIX)) {
 		tp->irq_cnt = 1;
 		tp->napi[0].irq_vec = tp->pdev->irq;
-		tp->dev->real_num_tx_queues = 1;
+		netif_set_real_num_tx_queues(tp->dev, 1);
 	}
 }
 
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#22 lore raw

Re: [PATCH net-next-2.6 16/17] tg3: Use netif_set_real_num_{rx,tx}_queues()

Quoted 19 lines · Matt Carlson
Quoted 18 lines · Ben Hutchings

---
This *always* sets real_num_tx_queues to 1, so this could be improved. For now, do a simple conversion.

Ben.

 drivers/net/tg3.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/tg3.c +0 -0
index fdb438d..ca41140 100644
@@ -8821,7 +8821,11 @@ static bool tg3_enable_msix(struct tg3 *tp)
 	for (i = 0; i < tp->irq_max; i++)
 		tp->napi[i].irq_vec = msix_ent[i].vector;
 
Quoted 6 lines

drivers/net/tg3.c static bool tg3_enable_msix(struct tg3 *tp) · line 8825

Quoted 3 lines
drivers/net/tg3.c +2 -1
-	tp->dev->real_num_tx_queues = 1;
+	netif_set_real_num_tx_queues(tp->dev, 1);
+	if (netif_set_real_num_rx_queues(tp->dev, tp->irq_cnt)) {

This should be tp->irq_cnt - 1, not tp->irq_cnt. The first MSI-X vector only handles link interrupts and device errors.

I need to correct myself. If the irq_cnt > 1, then it needs to be tp->irq_cnt - 1. If the irq_cnt == 1, then it should be 1.

Quoted 27 lines
Quoted 26 lines
drivers/net/tg3.c +4 -1
+		pci_disable_msix(tp->pdev);
+		return false;
+	}
 	if (tp->irq_cnt > 1)
 		tp->tg3_flags3 |= TG3_FLG3_ENABLE_RSS;
 
@@ -8856,7 +8860,7 @@ defcfg:
 	if (!(tp->tg3_flags2 & TG3_FLG2_USING_MSIX)) {
 		tp->irq_cnt = 1;
 		tp->napi[0].irq_vec = tp->pdev->irq;
-		tp->dev->real_num_tx_queues = 1;
+		netif_set_real_num_tx_queues(tp->dev, 1);
 	}
 }
 
Signature · 8 lines
1.7.2.1



-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer
#23 lore raw

Re: [PATCH net-next-2.6 16/17] tg3: Use netif_set_real_num_{rx,tx}_queues()

From: "Matt Carlson" <[email protected]>
Date: Mon, 27 Sep 2010 14:44:16 -0700

Quoted 6 lines · Matt Carlson
Quoted 2 lines

This should be tp->irq_cnt - 1, not tp->irq_cnt. The first MSI-X vector only handles link interrupts and device errors.

I need to correct myself. If the irq_cnt > 1, then it needs to be tp->irq_cnt - 1. If the irq_cnt == 1, then it should be 1.

I fixed this when I applied Ben's patch, thanks!

#24 lore raw

PATCH 17/17 8021q: Use netif_copy_real_num_queues() to set queue counts

In reply to Ben Hutchings

This covers RX if necessary, as well as TX.

---
 net/8021q/vlan.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/8021q/vlan.c +1 -1
index 2c6c2bd..25c2133 100644
@@ -321,7 +321,7 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
 	if (new_dev == NULL)
 		return -ENOBUFS;
 
-	new_dev->real_num_tx_queues = real_dev->real_num_tx_queues;
+	netif_copy_real_num_queues(new_dev, real_dev);
 	dev_net_set(new_dev, net);
 	/* need 4 bytes for extra VLAN header info,
 	 * hope the underlying device can handle it.
Signature · 7 lines
1.7.2.1


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer
#25 lore raw
In reply to Ben Hutchings

From: Ben Hutchings <[email protected]>
Date: Mon, 27 Sep 2010 19:23:11 +0100

Quoted 13 lines

This adds the functions:
- netif_set_real_num_rx_queues() - set actual number of RX queues used
- netif_copy_real_num_queues() - copy queue counts from another device

and changes all drivers that currently set net_device::real_num_tx_queues to use netif_set_real_num_tx_queues() and/or these functions.

The changes are compile-tested only, except that:
- sfc and 8021q have been briefly tested
- gianfar and mv643xx_eth have not been compiled, since they are platform-specific

Quoted 5 lines

I noticed that the bonding driver sets its numbers of queues without regard to its slave devices. This makes some sense since a bond device initially has no slave devices. However, it seems to mean that a bond device can pass up an skb with an out-of-range queue_index, triggering a warning in get_rps_cpu().

Series applied, thanks Ben.

#26 lore raw
Quoted 16 lines · David Miller

From: Ben Hutchings <[email protected]>
Date: Mon, 27 Sep 2010 19:23:11 +0100

Quoted 13 lines

This adds the functions:
- netif_set_real_num_rx_queues() - set actual number of RX queues used
- netif_copy_real_num_queues() - copy queue counts from another device

and changes all drivers that currently set net_device::real_num_tx_queues to use netif_set_real_num_tx_queues() and/or these functions.

The changes are compile-tested only, except that:
- sfc and 8021q have been briefly tested
- gianfar and mv643xx_eth have not been compiled, since they are platform-specific

Quoted 7 lines
Quoted 5 lines

I noticed that the bonding driver sets its numbers of queues without regard to its slave devices. This makes some sense since a bond device initially has no slave devices. However, it seems to mean that a bond device can pass up an skb with an out-of-range queue_index, triggering a warning in get_rps_cpu().

Series applied, thanks Ben.

That seems a bit premature, as the driver maintainers have not had a chance to review these. If it's not too late, perhaps you could roll these changes back for now.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#27 lore raw
Quoted 3 lines · Ben Hutchings

That seems a bit premature, as the driver maintainers have not had a chance to review these. If it's not too late, perhaps you could roll these changes back for now.

I am afraid its not possible.

If you want to revert, please submit a patch.

However, changes should be small and we have some time before Linus opens 2.6.37, dont you think ?