Thread (7 messages) 7 messages, 3 authors, 2015-02-13

Re: [PATCH V2 1/1] tun: change speed from 10M to dynamically configured

flat view

From: Sergei Shtylyov <hidden>
Date: 2015-02-13 10:38:01

Hello.

On 2/13/2015 6:35 AM, Zhu Yanjun wrote:
The default speed of normal nic is 1000M while the default speed
of tun is 10M. Now the default speed of tun is changed to 1000M.
And there are 3 options: 10M, 100M and 1000M to the speed of tun.
The command "ethtool -s tun0 speed 10/100/1000" can configure the
speed of tun dynamically.
CC: Michael S. Tsirkin <mst@redhat.com>
CC: Jason Wang <redacted>
CC: Al Viro <viro@zeniv.linux.org.uk>
Reviewed-by: Sergei Shtylyov <redacted>
Signed-off-by: Zhu Yanjun <redacted>
---
  drivers/net/tun.c           | 42 +++++++++++++++++++++++++++++++++++++++++-
  include/uapi/linux/if_tun.h |  5 +++++
  2 files changed, 46 insertions(+), 1 deletion(-)
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8c8dc16..0ee36f1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
[...]
quoted hunk ↗ jump to hunk
@@ -2257,9 +2260,18 @@ static struct miscdevice tun_miscdev = {

  static int tun_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  {
+	struct tun_struct *tun = netdev_priv(dev);
+
+	/* Get the speed of tun */
+	if (tun->flags & TUN_CTRL_SPD_1000) {
+		ethtool_cmd_speed_set(cmd, SPEED_1000);
+	} else if (tun->flags & TUN_CTRL_SPD_100) {
+		ethtool_cmd_speed_set(cmd, SPEED_100);
+	} else
+		ethtool_cmd_speed_set(cmd, SPEED_10);
   I probably missed it in the previous version: {} not needed here at all. Please remove to comply with Documentation/CodingStyle.

[...]

WBR, Sergei
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help