summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2016-12-05 01:05:35 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2016-12-05 12:54:10 +0000
commitd162f3dcfd54c133fdb335a1c1c89223e8e1a1cd (patch)
tree44377b841ba70e84c266dd8b2b9d54a2b61fc60b /vnet
parentff82ed6ccf09b93e1bf1432d9f26e66f91b60191 (diff)
api: set interface MTU API (VPP-442)
Change-Id: I67178f2703febb8ad3eb011606cb8a86fab5ee94 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/interface.api24
-rw-r--r--vnet/vnet/interface_api.c48
2 files changed, 71 insertions, 1 deletions
diff --git a/vnet/vnet/interface.api b/vnet/vnet/interface.api
index acc52a81724..77f5cfe3e2a 100644
--- a/vnet/vnet/interface.api
+++ b/vnet/vnet/interface.api
@@ -29,3 +29,27 @@ define sw_interface_set_flags_reply
i32 retval;
};
+/** \brief Set interface MTU
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - index of the interface to set MTU on
+ @param mtu - MTU
+*/
+define sw_interface_set_mtu
+{
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ u16 mtu;
+};
+
+/** \brief Reply to sw_interface_set_mtu
+ @param context - sender context which was passed in the request
+ @param retval - return code of the set flags request
+*/
+define sw_interface_set_mtu_reply
+{
+ u32 context;
+ i32 retval;
+};
+
diff --git a/vnet/vnet/interface_api.c b/vnet/vnet/interface_api.c
index eeb1d81d4d0..41fded791d9 100644
--- a/vnet/vnet/interface_api.c
+++ b/vnet/vnet/interface_api.c
@@ -22,6 +22,7 @@
#include <vnet/interface.h>
#include <vnet/api_errno.h>
+#include <vnet/ethernet/ethernet.h>
#include <vnet/vnet_msg_enum.h>
@@ -42,7 +43,8 @@
#include <vlibapi/api_helper_macros.h>
#define foreach_vpe_api_msg \
-_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags)
+_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
+_(SW_INTERFACE_SET_MTU, sw_interface_set_mtu)
static void
vl_api_sw_interface_set_flags_t_handler (vl_api_sw_interface_set_flags_t * mp)
@@ -68,6 +70,50 @@ vl_api_sw_interface_set_flags_t_handler (vl_api_sw_interface_set_flags_t * mp)
REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
}
+static void
+vl_api_sw_interface_set_mtu_t_handler (vl_api_sw_interface_set_mtu_t * mp)
+{
+ vl_api_sw_interface_set_mtu_reply_t *rmp;
+ vnet_main_t *vnm = vnet_get_main ();
+ u32 flags = ETHERNET_INTERFACE_FLAG_MTU;
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u16 mtu = ntohs (mp->mtu);
+ ethernet_main_t *em = &ethernet_main;
+ int rv = 0;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, sw_if_index);
+ ethernet_interface_t *eif = ethernet_get_interface (em, sw_if_index);
+
+ if (!eif)
+ {
+ rv = VNET_API_ERROR_FEATURE_DISABLED;
+ goto bad_sw_if_index;
+ }
+
+ if (mtu < hi->min_supported_packet_bytes)
+ {
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto bad_sw_if_index;
+ }
+
+ if (mtu > hi->max_supported_packet_bytes)
+ {
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto bad_sw_if_index;
+ }
+
+ if (hi->max_packet_bytes != mtu)
+ {
+ hi->max_packet_bytes = mtu;
+ ethernet_set_flags (vnm, sw_if_index, flags);
+ }
+
+ BAD_SW_IF_INDEX_LABEL;
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_MTU_REPLY);
+}
+
/*
* vpe_api_hookup