summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/interface.api8
-rw-r--r--src/vnet/interface.c3
-rw-r--r--src/vnet/interface.h31
-rw-r--r--src/vnet/interface_api.c3
-rw-r--r--src/vnet/interface_format.c21
-rw-r--r--src/vnet/interface_funcs.h8
-rw-r--r--src/vnet/unix/tapcli.c6
7 files changed, 41 insertions, 39 deletions
diff --git a/src/vnet/interface.api b/src/vnet/interface.api
index fdf34f0da34..2010d8b5f54 100644
--- a/src/vnet/interface.api
+++ b/src/vnet/interface.api
@@ -1,4 +1,4 @@
-option version = "2.1.0";
+option version = "2.2.0";
service {
rpc want_interface_events returns want_interface_events_reply
@@ -99,7 +99,7 @@ autoreply define want_interface_events
@param pid - the interface's l2 address
@param interface_name - name of the interface
@param link_duplex - 1 if half duplex, 2 if full duplex
- @param link_speed - 1 = 10M, 2 = 100M, 4 = 1G, 8 = 10G, 16 = 40G, 32 = 100G
+ @param link_speed - value in kbps
@param link_MTU - max. transmission unit
@param sub_if_id - A number 0-N to uniquely identify this subif on super if
@param sub_dot1ad - 0 = dot1q, 1 = dot1ad
@@ -144,8 +144,8 @@ define sw_interface_details
/* 1 = half duplex, 2 = full duplex */
u8 link_duplex;
- /* 1 = 10M, 2 = 100M, 4 = 1G, 8 = 10G, 16 = 40G, 32 = 100G */
- u8 link_speed;
+ /* link speed in kbps */
+ u32 link_speed;
/* MTU */
u16 link_mtu;
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 0ee3093f383..37f27ea49ea 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -305,8 +305,7 @@ vnet_hw_interface_set_flags_helper (vnet_main_t * vnm, u32 hw_if_index,
(helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE) != 0;
mask =
- (VNET_HW_INTERFACE_FLAG_LINK_UP | VNET_HW_INTERFACE_FLAG_DUPLEX_MASK |
- VNET_HW_INTERFACE_FLAG_SPEED_MASK);
+ (VNET_HW_INTERFACE_FLAG_LINK_UP | VNET_HW_INTERFACE_FLAG_DUPLEX_MASK);
flags &= mask;
/* Call hardware interface add/del callbacks. */
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 9be38709020..01d61afb5e8 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -491,20 +491,6 @@ typedef enum vnet_hw_interface_flags_t_
VNET_HW_INTERFACE_FLAG_HALF_DUPLEX = (1 << 1),
VNET_HW_INTERFACE_FLAG_FULL_DUPLEX = (1 << 2),
- /* Hardware link speed */
- VNET_HW_INTERFACE_FLAG_SPEED_10M = (1 << 3),
- VNET_HW_INTERFACE_FLAG_SPEED_100M = (1 << 4),
- VNET_HW_INTERFACE_FLAG_SPEED_1G = (1 << 5),
- VNET_HW_INTERFACE_FLAG_SPEED_2_5G = (1 << 6),
- VNET_HW_INTERFACE_FLAG_SPEED_5G = (1 << 7),
- VNET_HW_INTERFACE_FLAG_SPEED_10G = (1 << 8),
- VNET_HW_INTERFACE_FLAG_SPEED_20G = (1 << 9),
- VNET_HW_INTERFACE_FLAG_SPEED_25G = (1 << 10),
- VNET_HW_INTERFACE_FLAG_SPEED_40G = (1 << 11),
- VNET_HW_INTERFACE_FLAG_SPEED_50G = (1 << 12),
- VNET_HW_INTERFACE_FLAG_SPEED_56G = (1 << 13),
- VNET_HW_INTERFACE_FLAG_SPEED_100G = (1 << 14),
-
/* rx mode flags */
VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE = (1 << 16),
@@ -517,19 +503,6 @@ typedef enum vnet_hw_interface_flags_t_
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK \
(VNET_HW_INTERFACE_FLAG_HALF_DUPLEX | \
VNET_HW_INTERFACE_FLAG_FULL_DUPLEX)
-#define VNET_HW_INTERFACE_FLAG_SPEED_MASK \
- (VNET_HW_INTERFACE_FLAG_SPEED_10M | \
- VNET_HW_INTERFACE_FLAG_SPEED_100M | \
- VNET_HW_INTERFACE_FLAG_SPEED_1G | \
- VNET_HW_INTERFACE_FLAG_SPEED_2_5G | \
- VNET_HW_INTERFACE_FLAG_SPEED_5G | \
- VNET_HW_INTERFACE_FLAG_SPEED_10G | \
- VNET_HW_INTERFACE_FLAG_SPEED_20G | \
- VNET_HW_INTERFACE_FLAG_SPEED_25G | \
- VNET_HW_INTERFACE_FLAG_SPEED_40G | \
- VNET_HW_INTERFACE_FLAG_SPEED_50G | \
- VNET_HW_INTERFACE_FLAG_SPEED_56G | \
- VNET_HW_INTERFACE_FLAG_SPEED_100G)
/* Hardware-interface. This corresponds to a physical wire
that packets flow over. */
@@ -541,6 +514,10 @@ typedef struct vnet_hw_interface_t
/* flags */
vnet_hw_interface_flags_t flags;
+
+ /* link speed in kbps */
+ u32 link_speed;
+
/* Hardware address as vector. Zero (e.g. zero-length vector) if no
address for this class (e.g. PPP). */
u8 *hw_address;
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index c27f3e87975..e4faeed76b0 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -202,8 +202,7 @@ send_sw_interface_details (vpe_api_main_t * am,
mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
mp->link_duplex = ((hi->flags & VNET_HW_INTERFACE_FLAG_DUPLEX_MASK) >>
VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT);
- mp->link_speed = ((hi->flags & VNET_HW_INTERFACE_FLAG_SPEED_MASK) >>
- VNET_HW_INTERFACE_FLAG_SPEED_SHIFT);
+ mp->link_speed = hi->link_speed;
mp->link_mtu = ntohs (hi->max_packet_bytes);
mp->mtu[VNET_MTU_L3] = ntohl (swif->mtu[VNET_MTU_L3]);
mp->mtu[VNET_MTU_IP4] = ntohl (swif->mtu[VNET_MTU_IP4]);
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)
diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h
index b7d900740d5..c4c66179bb5 100644
--- a/src/vnet/interface_funcs.h
+++ b/src/vnet/interface_funcs.h
@@ -325,6 +325,14 @@ vnet_put_frame_to_sw_interface (vnet_main_t * vnm, u32 sw_if_index,
return vlib_put_frame_to_node (vlib_get_main (), hw->output_node_index, f);
}
+always_inline void
+vnet_hw_interface_set_link_speed (vnet_main_t * vnm, u32 hw_if_index,
+ u32 link_speed)
+{
+ vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
+ hw->link_speed = link_speed;
+}
+
/* Change interface flags (e.g. up, down, enable, disable). */
clib_error_t *vnet_hw_interface_set_flags (vnet_main_t * vnm, u32 hw_if_index,
vnet_hw_interface_flags_t flags);
diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c
index d183c3a9ea8..765e857f387 100644
--- a/src/vnet/unix/tapcli.c
+++ b/src/vnet/unix/tapcli.c
@@ -746,13 +746,11 @@ tapcli_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
{
uword is_admin_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
u32 hw_flags;
- u32 speed_duplex = VNET_HW_INTERFACE_FLAG_FULL_DUPLEX
- | VNET_HW_INTERFACE_FLAG_SPEED_1G;
if (is_admin_up)
- hw_flags = VNET_HW_INTERFACE_FLAG_LINK_UP | speed_duplex;
+ hw_flags = VNET_HW_INTERFACE_FLAG_LINK_UP;
else
- hw_flags = speed_duplex;
+ hw_flags = 0;
vnet_hw_interface_set_flags (vnm, hw_if_index, hw_flags);
return 0;