aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_format.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-11-08 15:30:16 +0100
committerFlorin Coras <florin.coras@gmail.com>2018-11-08 17:08:11 +0000
commit5100aa9cb9e7acff35fa3bfde8aa95b5ace60344 (patch)
treea42bb046ea2933042b2722e7b4fe229e3070cac5 /src/vnet/interface_format.c
parenta71844f27a0be91fcda25b19604d16122ccc3e73 (diff)
vnet: store hw interface speed in kbps instead of using flags
Change-Id: Idd4471a3adf7023e48e85717f00c786b1dde0cca Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/interface_format.c')
-rw-r--r--src/vnet/interface_format.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/vnet/interface_format.c b/src/vnet/interface_format.c
index 631120b96ac..c62e770e57b 100644
--- a/src/vnet/interface_format.c
+++ b/src/vnet/interface_format.c
@@ -78,6 +78,24 @@ format_vnet_hw_interface_rx_mode (u8 * s, va_list * args)
}
u8 *
+format_vnet_hw_interface_link_speed (u8 * s, va_list * args)
+{
+ u32 link_speed = va_arg (*args, u32);
+
+ if (link_speed == 0)
+ return format (s, "unknown");
+
+ if (link_speed >= 1000000)
+ return format (s, "%f Gbps", (f64) link_speed / 1000000);
+
+ if (link_speed >= 1000)
+ return format (s, "%f Mbps", (f64) link_speed / 1000);
+
+ return format (s, "%u Kbps", link_speed);
+}
+
+
+u8 *
format_vnet_hw_interface (u8 * s, va_list * args)
{
vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
@@ -115,6 +133,9 @@ format_vnet_hw_interface (u8 * s, va_list * args)
else
s = format (s, "%s%d", dev_class->name, hi->dev_instance);
+ s = format (s, "\n%ULink speed: %U", format_white_space, indent + 2,
+ format_vnet_hw_interface_link_speed, hi->link_speed);
+
if (verbose)
{
if (hw_class->format_device)