summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/af_xdp/device.c13
-rw-r--r--src/plugins/dpdk/device/init.c46
-rw-r--r--src/plugins/rdma/device.c10
3 files changed, 51 insertions, 18 deletions
diff --git a/src/plugins/af_xdp/device.c b/src/plugins/af_xdp/device.c
index 4aa36d95dd5..a5e0b739300 100644
--- a/src/plugins/af_xdp/device.c
+++ b/src/plugins/af_xdp/device.c
@@ -67,6 +67,15 @@ af_xdp_mac_change (vnet_hw_interface_t * hw, const u8 * old, const u8 * new)
return 0;
}
+static clib_error_t *
+af_xdp_set_mtu (vnet_main_t *vnm, vnet_hw_interface_t *hw, u32 mtu)
+{
+ af_xdp_main_t *am = &af_xdp_main;
+ af_xdp_device_t *ad = vec_elt_at_index (am->devices, hw->dev_instance);
+ af_xdp_log (VLIB_LOG_LEVEL_ERR, ad, "set mtu not supported yet");
+ return vnet_error (VNET_ERR_UNSUPPORTED, 0);
+}
+
static u32
af_xdp_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hw, u32 flags)
{
@@ -82,9 +91,6 @@ af_xdp_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hw, u32 flags)
af_xdp_log (VLIB_LOG_LEVEL_ERR, ad,
"set promiscuous not supported yet");
return ~0;
- case ETHERNET_INTERFACE_FLAG_MTU:
- af_xdp_log (VLIB_LOG_LEVEL_ERR, ad, "set mtu not supported yet");
- return ~0;
}
af_xdp_log (VLIB_LOG_LEVEL_ERR, ad, "unknown flag %x requested", flags);
@@ -651,6 +657,7 @@ af_xdp_create_if (vlib_main_t * vm, af_xdp_create_if_args_t * args)
eir.dev_instance = ad->dev_instance;
eir.address = ad->hwaddr;
eir.cb.flag_change = af_xdp_flag_change;
+ eir.cb.set_mtu = af_xdp_set_mtu;
ad->hw_if_index = vnet_eth_register_interface (vnm, &eir);
sw = vnet_get_hw_sw_interface (vnm, ad->hw_if_index);
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 5e06e48d37e..4faf6290dba 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -21,6 +21,7 @@
#include <vlib/unix/unix.h>
#include <vlib/log.h>
+#include <vnet/vnet.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/interface/rx_queue_funcs.h>
#include <dpdk/buffer.h>
@@ -68,6 +69,41 @@ const struct
{ ETH_LINK_SPEED_1G, "GigabitEthernet" },
};
+static clib_error_t *
+dpdk_set_mtu (vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 mtu)
+{
+ dpdk_main_t *dm = &dpdk_main;
+ dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance);
+ int rv;
+
+ rv = rte_eth_dev_set_mtu (xd->port_id, mtu);
+
+ if (rv < 0)
+ {
+ dpdk_log_err ("[%u] rte_eth_dev_set_mtu failed (mtu %u, rv %d)",
+ xd->port_id, mtu, rv);
+ switch (rv)
+ {
+ case -ENOTSUP:
+ return vnet_error (VNET_ERR_UNSUPPORTED,
+ "dpdk driver doesn't support MTU change");
+ case -EBUSY:
+ return vnet_error (VNET_ERR_BUSY, "port is running");
+ case -EINVAL:
+ return vnet_error (VNET_ERR_INVALID_VALUE, "invalid MTU");
+ default:
+ return vnet_error (VNET_ERR_BUG,
+ "unexpected return value %d returned from "
+ "rte_eth_dev_set_mtu(...)",
+ rv);
+ }
+ }
+ else
+ dpdk_log_debug ("[%u] mtu set to %u", xd->port_id, mtu);
+
+ return 0;
+}
+
static u32
dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
{
@@ -84,15 +120,6 @@ dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
case ETHERNET_INTERFACE_FLAG_ACCEPT_ALL:
dpdk_device_flag_set (xd, DPDK_DEVICE_FLAG_PROMISC, 1);
break;
- case ETHERNET_INTERFACE_FLAG_MTU:
- if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
- rte_eth_dev_stop (xd->port_id);
- rte_eth_dev_set_mtu (xd->port_id, hi->max_packet_bytes);
- if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
- rte_eth_dev_start (xd->port_id);
- dpdk_log_debug ("[%u] mtu changed to %u", xd->port_id,
- hi->max_packet_bytes);
- return 0;
default:
return ~0;
}
@@ -370,6 +397,7 @@ dpdk_lib_init (dpdk_main_t * dm)
eir.dev_instance = xd->device_index;
eir.address = addr;
eir.cb.flag_change = dpdk_flag_change;
+ eir.cb.set_mtu = dpdk_set_mtu;
xd->hw_if_index = vnet_eth_register_interface (vnm, &eir);
hi = vnet_get_hw_interface (vnm, xd->hw_if_index);
hi->numa_node = xd->cpu_socket = (i8) rte_eth_dev_socket_id (port_id);
diff --git a/src/plugins/rdma/device.c b/src/plugins/rdma/device.c
index cad5fdb541f..167a23213cc 100644
--- a/src/plugins/rdma/device.c
+++ b/src/plugins/rdma/device.c
@@ -183,11 +183,10 @@ rdma_mac_change (vnet_hw_interface_t * hw, const u8 * old, const u8 * new)
return 0;
}
-static u32
-rdma_dev_change_mtu (rdma_device_t * rd)
+static clib_error_t *
+rdma_set_mtu (vnet_main_t *vnm, vnet_hw_interface_t *hw, u32 mtu)
{
- rdma_log__ (VLIB_LOG_LEVEL_ERR, rd, "MTU change not supported");
- return ~0;
+ return vnet_error (VNET_ERR_UNSUPPORTED, 0);
}
static u32
@@ -202,8 +201,6 @@ rdma_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hw, u32 flags)
return rdma_dev_set_ucast (rd);
case ETHERNET_INTERFACE_FLAG_ACCEPT_ALL:
return rdma_dev_set_promisc (rd);
- case ETHERNET_INTERFACE_FLAG_MTU:
- return rdma_dev_change_mtu (rd);
}
rdma_log__ (VLIB_LOG_LEVEL_ERR, rd, "unknown flag %x requested", flags);
@@ -361,6 +358,7 @@ rdma_register_interface (vnet_main_t * vnm, rdma_device_t * rd)
eir.dev_instance = rd->dev_instance;
eir.address = rd->hwaddr.bytes;
eir.cb.flag_change = rdma_flag_change;
+ eir.cb.set_mtu = rdma_set_mtu;
rd->hw_if_index = vnet_eth_register_interface (vnm, &eir);
/* Indicate ability to support L3 DMAC filtering and
* initialize interface to L3 non-promisc mode */