netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhu Yanjun <yanjun.zhu@oracle.com>
To: j.vosburgh@gmail.com, vfalico@gmail.com, andy@greyhouse.net,
	netdev@vger.kernel.org
Subject: [PATCH 1/1] bonding: use 'M' or 'G' based on the speed
Date: Thu, 20 Apr 2017 05:06:35 -0400	[thread overview]
Message-ID: <1492679195-19938-1-git-send-email-yanjun.zhu@oracle.com> (raw)

If the speed of the slave netdev is more than 1000M,
it is better to use 'G' instead of 'M'.

Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
---
 drivers/net/bonding/bond_main.c   | 8 ++++++--
 drivers/net/bonding/bond_procfs.c | 6 +++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index af9f0ce..1aad13d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2147,9 +2147,13 @@ static void bond_miimon_commit(struct bonding *bond)
 				bond_set_backup_slave(slave);
 			}
 
-			netdev_info(bond->dev, "link status definitely up for interface %s, %u Mbps %s duplex\n",
+			netdev_info(bond->dev, "link status definitely up for interface %s, %u%sbps %s duplex\n",
 				    slave->dev->name,
-				    slave->speed == SPEED_UNKNOWN ? 0 : slave->speed,
+				    slave->speed == SPEED_UNKNOWN ? 0 :
+				    (slave->speed > 1000 ?
+				    slave->speed / 1000 : slave->speed),
+				    slave->speed > 1000 ?
+				    slave->speed % 1000 ? ".5 G" : " G" : " M",
 				    slave->duplex ? "full" : "half");
 
 			/* notify ad that the link status has changed */
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
index f514fe5..4c31055 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -173,7 +173,11 @@ static void bond_info_show_slave(struct seq_file *seq,
 	if (slave->speed == SPEED_UNKNOWN)
 		seq_printf(seq, "Speed: %s\n", "Unknown");
 	else
-		seq_printf(seq, "Speed: %d Mbps\n", slave->speed);
+		seq_printf(seq, "Speed: %d%sbps\n",
+			   slave->speed > 1000 ?
+			   slave->speed / 1000 : slave->speed,
+			   slave->speed > 1000 ?
+			   (slave->speed % 1000 ? ".5 G" : " G") : " M");
 
 	if (slave->duplex == DUPLEX_UNKNOWN)
 		seq_printf(seq, "Duplex: %s\n", "Unknown");
-- 
2.7.4

             reply	other threads:[~2017-04-20  9:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20  9:06 Zhu Yanjun [this message]
2017-04-20 21:53 ` [PATCH 1/1] bonding: use 'M' or 'G' based on the speed Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492679195-19938-1-git-send-email-yanjun.zhu@oracle.com \
    --to=yanjun.zhu@oracle.com \
    --cc=andy@greyhouse.net \
    --cc=j.vosburgh@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vfalico@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).