Skip to contentSkip to conversation

net/ethtool: add multiple queue support to {get,set}_ringparams

RFC PATCH In review Ajit Khaparde 5 participants 7 messages Mar 14, 2010

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

RFC PATCH 1/1 net/ethtool: add multiple queue support to {get,set}_ringparams

With network devices and hence device drivers supporting multiple Tx and Rx rings, currently there is no way for ethtool to specify which Tx/Rx ring the user wants to get/set. This patch enhances the {get,set}_ringparams by allowing the user to specify the Tx/Rx ring id of interest. Please review.

---
 include/linux/ethtool.h |    1 +
 net/core/ethtool.c      |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletions(-)
include/linux/ethtool.h +1 -0
index b33f316..de6a90a 100644
@@ -206,6 +206,7 @@ struct ethtool_coalesce {
 /* for configuring RX/TX ring parameters */
 struct ethtool_ringparam {
 	__u32	cmd;	/* ETHTOOL_{G,S}RINGPARAM */
+	__u32	ring_id;
 
 	/* Read only attributes.  These indicate the maximum number
 	 * of pending RX/TX ring entries the driver will allow the
net/core/ethtool.c +4 -1
index f4cb6b6..81e2e62 100644
@@ -881,11 +881,14 @@ static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev, void
 
 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
 {
-	struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM };
+	struct ethtool_ringparam ringparam;
 
 	if (!dev->ethtool_ops->get_ringparam)
 		return -EOPNOTSUPP;
 
+	if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
+		return -EFAULT;
+
 	dev->ethtool_ops->get_ringparam(dev, &ringparam);
 
 	if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
Signature · 1 line
1.6.3.3
maintainer
#1 lore raw

From: Ajit Khaparde <[email protected]>
Date: Sun, 14 Mar 2010 07:13:45 +0530

include/linux/ethtool.h struct ethtool_coalesce { · line 212

Quoted 12 lines
include/linux/ethtool.h +1 -0
index b33f316..de6a90a 100644
@@ -206,6 +206,7 @@ struct ethtool_coalesce {
 /* for configuring RX/TX ring parameters */
 struct ethtool_ringparam {
 	__u32	cmd;	/* ETHTOOL_{G,S}RINGPARAM */
+	__u32	ring_id;
 
 	/* Read only attributes.  These indicate the maximum number
 	 * of pending RX/TX ring entries the driver will allow the

For the millionth time, you cannot change these datastructures like this without breaking all existing userspace applications out there.

#2 lore raw

PATCH 1/1 ethtool.h: Add "structs are public" disclaimer comment

Quoted 3 lines · David Miller

For the millionth time, you cannot change these datastructures like this without breaking all existing userspace applications out there.

Maybe this might help reduce the broken record repetitiveness.

---

include/linux/ethtool.h +9 -0
index b33f316..9bd7583 100644
@@ -10,6 +10,15 @@
  * Portions Copyright (C) Sun Microsystems 2008
  */
 
+/*
+ * Do not submit patches that change the public structs not guarded by
+ * #ifdef __KERNEL__ in this file.
+ *
+ * In case the use of __u8, __u16, __u32 and other reserved types don't
+ * mean much to you, these structs are used by user-space applications
+ * and must not be changed.
+ */
+
 #ifndef _LINUX_ETHTOOL_H
 #define _LINUX_ETHTOOL_H
 
#3 lore raw

Re: [PATCH] ethtool.h: Add "structs are public" disclaimer comment

Quoted 15 lines · Joe Perches
Quoted 3 lines · David Miller

For the millionth time, you cannot change these datastructures like this without breaking all existing userspace applications out there.

Maybe this might help reduce the broken record repetitiveness.

---

include/linux/ethtool.h +0 -0
index b33f316..9bd7583 100644
@@ -10,6 +10,15 @@
  * Portions Copyright (C) Sun Microsystems 2008

include/linux/ethtool.h line 20

Quoted 10 lines
include/linux/ethtool.h +8 -0
  */
 
+/*
+ * Do not submit patches that change the public structs not guarded by
+ * #ifdef __KERNEL__ in this file.
+ *
+ * In case the use of __u8, __u16, __u32 and other reserved types don't
+ * mean much to you, these structs are used by user-space applications
+ * and must not be changed.
+ */

This comment is not quite correct: reserved fields may be replaced so long as the structure size and offsets of other fields stay the same.

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.
#4 lore raw

Re: [PATCH] ethtool.h: Add "structs are public" disclaimer comment

Quoted 18 lines · Ben Hutchings
Quoted 17 lines · Joe Perches
Quoted 3 lines · David Miller

For the millionth time, you cannot change these datastructures like this without breaking all existing userspace applications out there.

Maybe this might help reduce the broken record repetitiveness.

---

include/linux/ethtool.h +0 -0
index b33f316..9bd7583 100644
@@ -10,6 +10,15 @@
   * Portions Copyright (C) Sun Microsystems 2008
   */
 
Quoted 11 lines

include/linux/ethtool.h line 20

Quoted 8 lines
include/linux/ethtool.h +8 -0
+/*
+ * Do not submit patches that change the public structs not guarded by
+ * #ifdef __KERNEL__ in this file.
+ *
+ * In case the use of __u8, __u16, __u32 and other reserved types don't
+ * mean much to you, these structs are used by user-space applications
+ * and must not be changed.
+ */

This comment is not quite correct: reserved fields may be replaced so long as the structure size and offsets of other fields stay the same.

I don't think we need this in every ABI-related header, though, do we?

Jeff

maintainer
#5 lore raw

Re: [PATCH] ethtool.h: Add "structs are public" disclaimer comment

In reply to Joe Perches

From: Joe Perches <[email protected]>
Date: Sun, 14 Mar 2010 09:17:58 -0700

Quoted 8 lines · David Miller
Quoted 3 lines

For the millionth time, you cannot change these datastructures like this without breaking all existing userspace applications out there.

Maybe this might help reduce the broken record repetitiveness.

That's rediculious. Just about every single file in include/linux/foo.h has similar stuff.

And we already have a way to document this, the fact that a header file appears in include/linux/Kbuild shows that it provides userland interfaces.

And your comment wouldn't help this person at all, they _KNEW_ it changed userspace, because in the very next patch they patch the userland tool to change the datastructures too!

#6 lore raw
In reply to Ajit Khaparde
Quoted 6 lines · Ajit Khaparde

With network devices and hence device drivers supporting multiple Tx and Rx rings, currently there is no way for ethtool to specify which Tx/Rx ring the user wants to get/set. This patch enhances the {get,set}_ringparams by allowing the user to specify the Tx/Rx ring id of interest. Please review.

[...]

So long as queue selection is done using a hash of the flow parameters, there is no sense in setting different sizes for different queues. If drivers use additional queues that are not selected in this way and which may require different sizes, that information also needs to be exposed through ethtool (and perhaps to the networking core).

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.