dev: add change_max_rx_frame_size capability
Type: improvement
Change-Id: I922e216818b78f2fe7689c21a1d27d74a0ae28b8
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vnet/dev/port.c b/src/vnet/dev/port.c
index b3de37d..350c1d8 100644
--- a/src/vnet/dev/port.c
+++ b/src/vnet/dev/port.c
@@ -246,7 +246,7 @@
vnet_dev_rv_t rv = VNET_DEV_OK;
ASSERT (args->port.attr.type != VNET_DEV_PORT_TYPE_UNKNOWN);
- ASSERT (args->port.attr.max_supported_frame_size);
+ ASSERT (args->port.attr.max_supported_rx_frame_size);
port =
vnet_dev_alloc_with_data (sizeof (vnet_dev_port_t), args->port.data_size);
@@ -267,9 +267,16 @@
port->tx_node = *args->tx_node;
/* defaults out of port attributes */
- port->max_frame_size = args->port.attr.max_supported_frame_size;
+ port->max_rx_frame_size = args->port.attr.max_supported_rx_frame_size;
port->primary_hw_addr = args->port.attr.hw_addr;
+ if (port->attr.type == VNET_DEV_PORT_TYPE_ETHERNET)
+ {
+ if (port->max_rx_frame_size > 1514 &&
+ port->attr.caps.change_max_rx_frame_size)
+ port->max_rx_frame_size = 1514;
+ }
+
if (port->port_ops.alloc)
rv = port->port_ops.alloc (vm, port);
@@ -292,10 +299,10 @@
switch (req->type)
{
- case VNET_DEV_PORT_CFG_MAX_FRAME_SIZE:
- if (req->max_frame_size > port->attr.max_supported_frame_size)
+ case VNET_DEV_PORT_CFG_MAX_RX_FRAME_SIZE:
+ if (req->max_rx_frame_size > port->attr.max_supported_rx_frame_size)
return VNET_DEV_ERR_INVALID_VALUE;
- if (req->max_frame_size == port->max_frame_size)
+ if (req->max_rx_frame_size == port->max_rx_frame_size)
return VNET_DEV_ERR_NO_CHANGE;
break;
@@ -335,6 +342,8 @@
if (rv != VNET_DEV_OK)
return rv;
}
+ else
+ return VNET_DEV_ERR_NOT_SUPPORTED;
req->validated = 1;
return VNET_DEV_OK;
@@ -367,14 +376,16 @@
if (port->port_ops.config_change)
rv = port->port_ops.config_change (vm, port, req);
+ else
+ return VNET_DEV_ERR_NOT_SUPPORTED;
if (rv != VNET_DEV_OK)
return rv;
switch (req->type)
{
- case VNET_DEV_PORT_CFG_MAX_FRAME_SIZE:
- port->max_frame_size = req->max_frame_size;
+ case VNET_DEV_PORT_CFG_MAX_RX_FRAME_SIZE:
+ port->max_rx_frame_size = req->max_rx_frame_size;
break;
case VNET_DEV_PORT_CFG_PROMISC_MODE:
@@ -572,7 +583,7 @@
port->intf.hw_if_index = vnet_eth_register_interface (
vnm, &(vnet_eth_interface_registration_t){
.address = port->primary_hw_addr.eth_mac,
- .max_frame_size = port->max_frame_size,
+ .max_frame_size = port->max_rx_frame_size,
.dev_class_index = driver->dev_class_index,
.dev_instance = port->intf.dev_instance,
.cb.set_max_frame_size = vnet_dev_port_set_max_frame_size,