vnet: distinguish between max_frame_size and MTU
Type: improvement
Change-Id: I3659de6599f402c92e3855e3bf0e5e3388f2bea0
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vnet/ethernet/ethernet.h b/src/vnet/ethernet/ethernet.h
index b6adeb6..858400d 100644
--- a/src/vnet/ethernet/ethernet.h
+++ b/src/vnet/ethernet/ethernet.h
@@ -133,8 +133,8 @@
/* ethernet interface flags change */
ethernet_flag_change_function_t *flag_change;
- /* set MTU callback */
- vnet_interface_set_mtu_function_t *set_mtu;
+ /* set Max Frame Size callback */
+ vnet_interface_set_max_frame_size_function_t *set_max_frame_size;
} vnet_eth_if_callbacks_t;
#define ETHERNET_MIN_PACKET_BYTES 64
@@ -576,6 +576,8 @@
{
u32 dev_class_index;
u32 dev_instance;
+ u16 max_frame_size;
+ u16 frame_overhead;
vnet_eth_if_callbacks_t cb;
const u8 *address;
} vnet_eth_interface_registration_t;
diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c
index bac8822..a0ad798 100644
--- a/src/vnet/ethernet/interface.c
+++ b/src/vnet/ethernet/interface.c
@@ -311,15 +311,18 @@
}
static clib_error_t *
-ethernet_set_mtu (vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 mtu)
+ethernet_set_max_frame_size (vnet_main_t *vnm, vnet_hw_interface_t *hi,
+ u32 frame_size)
{
ethernet_interface_t *ei =
pool_elt_at_index (ethernet_main.interfaces, hi->hw_instance);
- if (ei->cb.set_mtu)
- return ei->cb.set_mtu (vnm, hi, mtu);
+ if (ei->cb.set_max_frame_size)
+ return ei->cb.set_max_frame_size (vnm, hi, frame_size);
- return 0;
+ return vnet_error (
+ VNET_ERR_UNSUPPORTED,
+ "underlying driver doesn't support changing Max Frame Size");
}
/* *INDENT-OFF* */
@@ -333,7 +336,7 @@
.build_rewrite = ethernet_build_rewrite,
.update_adjacency = ethernet_update_adjacency,
.mac_addr_change_function = ethernet_mac_change,
- .set_mtu = ethernet_set_mtu,
+ .set_max_frame_size = ethernet_set_max_frame_size,
};
/* *INDENT-ON* */
@@ -378,10 +381,15 @@
ethernet_setup_node (vnm->vlib_main, hi->output_node_index);
- hi->min_packet_bytes = hi->min_supported_packet_bytes =
- ETHERNET_MIN_PACKET_BYTES;
- hi->max_supported_packet_bytes = ETHERNET_MAX_PACKET_BYTES;
- hi->max_packet_bytes = em->default_mtu;
+ hi->min_frame_size = ETHERNET_MIN_PACKET_BYTES;
+ hi->frame_overhead =
+ r->frame_overhead ?
+ r->max_frame_size :
+ sizeof (ethernet_header_t) + 2 * sizeof (ethernet_vlan_header_t);
+ hi->max_frame_size = r->max_frame_size ?
+ r->max_frame_size :
+ ethernet_main.default_mtu + hi->frame_overhead;
+ ;
/* Default ethernet MTU, 9000 unless set by ethernet_config see below */
vnet_sw_interface_set_mtu (vnm, hi->sw_if_index, em->default_mtu);