diff options
-rw-r--r-- | src/plugins/dev_iavf/iavf.c | 3 | ||||
-rw-r--r-- | src/plugins/dev_iavf/port.c | 6 | ||||
-rw-r--r-- | src/vnet/dev/config.c | 2 | ||||
-rw-r--r-- | src/vnet/dev/dev.c | 18 | ||||
-rw-r--r-- | src/vnet/dev/dev.h | 11 | ||||
-rw-r--r-- | src/vnet/dev/dev_funcs.h | 8 | ||||
-rw-r--r-- | src/vnet/dev/format.c | 6 | ||||
-rw-r--r-- | src/vnet/dev/handlers.c | 4 | ||||
-rw-r--r-- | src/vnet/dev/port.c | 27 |
9 files changed, 55 insertions, 30 deletions
diff --git a/src/plugins/dev_iavf/iavf.c b/src/plugins/dev_iavf/iavf.c index f45bea0e669..1a17f46fb52 100644 --- a/src/plugins/dev_iavf/iavf.c +++ b/src/plugins/dev_iavf/iavf.c @@ -160,7 +160,8 @@ iavf_init (vlib_main_t *vm, vnet_dev_t *dev) .type = VNET_DEV_PORT_TYPE_ETHERNET, .max_rx_queues = res.num_queue_pairs, .max_tx_queues = res.num_queue_pairs, - .max_supported_frame_size = res.max_mtu, + .max_supported_rx_frame_size = res.max_mtu, + .caps.change_max_rx_frame_size = 1, }, .ops = { .init = iavf_port_init, diff --git a/src/plugins/dev_iavf/port.c b/src/plugins/dev_iavf/port.c index 7888fcef0a6..c2dd13b476e 100644 --- a/src/plugins/dev_iavf/port.c +++ b/src/plugins/dev_iavf/port.c @@ -132,7 +132,7 @@ iavf_port_init_vsi_queues (vlib_main_t *vm, vnet_dev_port_t *port) virtchnl_queue_pair_info_t *qpi; u16 vsi_id = ap->vsi_id; u16 data_size = vlib_buffer_get_default_data_size (vm); - u16 max_frame_size = port->max_frame_size; + u16 max_frame_size = port->max_rx_frame_size; u8 buffer[VIRTCHNL_MSG_SZ (virtchnl_vsi_queue_config_info_t, qpair, ap->num_qp)]; virtchnl_vsi_queue_config_info_t *ci = @@ -388,7 +388,7 @@ iavf_port_cfg_change_validate (vlib_main_t *vm, vnet_dev_port_t *port, switch (req->type) { - case VNET_DEV_PORT_CFG_MAX_FRAME_SIZE: + case VNET_DEV_PORT_CFG_MAX_RX_FRAME_SIZE: if (port->started) rv = VNET_DEV_ERR_PORT_STARTED; break; @@ -520,7 +520,7 @@ iavf_port_cfg_change (vlib_main_t *vm, vnet_dev_port_t *port, /* is_primary */ 0); break; - case VNET_DEV_PORT_CFG_MAX_FRAME_SIZE: + case VNET_DEV_PORT_CFG_MAX_RX_FRAME_SIZE: break; case VNET_DEV_PORT_CFG_RXQ_INTR_MODE_ENABLE: diff --git a/src/vnet/dev/config.c b/src/vnet/dev/config.c index c98524c9b7e..091d83ecfec 100644 --- a/src/vnet/dev/config.c +++ b/src/vnet/dev/config.c @@ -148,7 +148,7 @@ dev_config_process_node_fn (vlib_main_t *vm, vlib_node_runtime_t *rt, else { err = clib_error_return (0, "unknown input '%U'", - format_unformat_error, input); + format_unformat_error, &input); break; } } diff --git a/src/vnet/dev/dev.c b/src/vnet/dev/dev.c index bedc7fb9aec..9b99fe432a4 100644 --- a/src/vnet/dev/dev.c +++ b/src/vnet/dev/dev.c @@ -92,14 +92,18 @@ vnet_dev_init (vlib_main_t *vm, vnet_dev_t *dev) if ((rv = bus->ops.device_open (vm, dev)) != VNET_DEV_OK) return rv; - if ((rv = dev->ops.alloc (vm, dev)) != VNET_DEV_OK) + if (dev->ops.alloc) { - log_err (dev, "device init failed [rv %d]", rv); - if (dev->ops.deinit) - dev->ops.deinit (vm, dev); - if (dev->ops.free) - dev->ops.free (vm, dev); - return rv; + rv = dev->ops.alloc (vm, dev); + if (rv != VNET_DEV_OK) + { + log_err (dev, "device init failed [rv %d]", rv); + if (dev->ops.deinit) + dev->ops.deinit (vm, dev); + if (dev->ops.free) + dev->ops.free (vm, dev); + return rv; + } } if ((rv = dev->ops.init (vm, dev)) != VNET_DEV_OK) diff --git a/src/vnet/dev/dev.h b/src/vnet/dev/dev.h index dc426667058..e3421b91978 100644 --- a/src/vnet/dev/dev.h +++ b/src/vnet/dev/dev.h @@ -28,7 +28,8 @@ typedef enum #define foreach_vnet_dev_port_caps \ _ (interrupt_mode) \ - _ (rss) + _ (rss) \ + _ (change_max_rx_frame_size) typedef union { @@ -107,7 +108,7 @@ typedef struct #define foreach_vnet_dev_port_cfg_type \ _ (PROMISC_MODE) \ - _ (MAX_FRAME_SIZE) \ + _ (MAX_RX_FRAME_SIZE) \ _ (CHANGE_PRIMARY_HW_ADDR) \ _ (ADD_SECONDARY_HW_ADDR) \ _ (REMOVE_SECONDARY_HW_ADDR) \ @@ -132,7 +133,7 @@ typedef struct vnet_dev_port_cfg_change_req { u8 promisc : 1; vnet_dev_hw_addr_t addr; - u16 max_frame_size; + u16 max_rx_frame_size; vnet_dev_queue_id_t queue_id; }; @@ -143,7 +144,7 @@ typedef struct vnet_dev_hw_addr_t hw_addr; u16 max_rx_queues; u16 max_tx_queues; - u16 max_supported_frame_size; + u16 max_supported_rx_frame_size; vnet_dev_port_type_t type; vnet_dev_port_caps_t caps; } vnet_dev_port_attr_t; @@ -278,7 +279,7 @@ typedef struct vnet_dev_port vnet_dev_queue_config_t rx_queue_config; vnet_dev_queue_config_t tx_queue_config; vnet_dev_port_attr_t attr; - u32 max_frame_size; + u32 max_rx_frame_size; vnet_dev_hw_addr_t primary_hw_addr; vnet_dev_hw_addr_t *secondary_hw_addr; u32 index; diff --git a/src/vnet/dev/dev_funcs.h b/src/vnet/dev/dev_funcs.h index e725dd40564..33159ffa65d 100644 --- a/src/vnet/dev/dev_funcs.h +++ b/src/vnet/dev/dev_funcs.h @@ -195,6 +195,14 @@ vnet_dev_get_rx_queue_buffer_pool_index (vnet_dev_rx_queue_t *rxq) return rxq->buffer_template.buffer_pool_index; } +static_always_inline u32 +vnet_dev_get_rx_queue_buffer_data_size (vlib_main_t *vm, + vnet_dev_rx_queue_t *rxq) +{ + u8 bpi = vnet_dev_get_rx_queue_buffer_pool_index (rxq); + return vlib_get_buffer_pool (vm, bpi)->data_size; +} + static_always_inline void vnet_dev_rx_queue_rt_request (vlib_main_t *vm, vnet_dev_rx_queue_t *rxq, vnet_dev_rx_queue_rt_req_t req) diff --git a/src/vnet/dev/format.c b/src/vnet/dev/format.c index 2c95e3adf25..8816c0e552c 100644 --- a/src/vnet/dev/format.c +++ b/src/vnet/dev/format.c @@ -117,9 +117,9 @@ format_vnet_dev_port_info (u8 *s, va_list *args) s = format (s, " %U", format_vnet_dev_hw_addr, a); } } - s = format (s, "\n%UMax frame size is %u (max supported %u)", - format_white_space, indent, port->max_frame_size, - port->attr.max_supported_frame_size); + s = format (s, "\n%UMax RX frame size is %u (max supported %u)", + format_white_space, indent, port->max_rx_frame_size, + port->attr.max_supported_rx_frame_size); if (port->port_ops.format_status) s = format (s, "\n%U%U", format_white_space, indent, port->port_ops.format_status, a, port); diff --git a/src/vnet/dev/handlers.c b/src/vnet/dev/handlers.c index 41d4cba963b..fcaef14221f 100644 --- a/src/vnet/dev/handlers.c +++ b/src/vnet/dev/handlers.c @@ -23,8 +23,8 @@ vnet_dev_port_set_max_frame_size (vnet_main_t *vnm, vnet_hw_interface_t *hw, vnet_dev_rv_t rv; vnet_dev_port_cfg_change_req_t req = { - .type = VNET_DEV_PORT_CFG_MAX_FRAME_SIZE, - .max_frame_size = frame_size, + .type = VNET_DEV_PORT_CFG_MAX_RX_FRAME_SIZE, + .max_rx_frame_size = frame_size, }; log_debug (p->dev, "size %u", frame_size); diff --git a/src/vnet/dev/port.c b/src/vnet/dev/port.c index b3de37d7bf3..350c1d84c73 100644 --- a/src/vnet/dev/port.c +++ b/src/vnet/dev/port.c @@ -246,7 +246,7 @@ vnet_dev_port_add (vlib_main_t *vm, vnet_dev_t *dev, vnet_dev_port_id_t id, 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 @@ vnet_dev_port_add (vlib_main_t *vm, vnet_dev_t *dev, vnet_dev_port_id_t id, 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 @@ vnet_dev_port_cfg_change_req_validate (vlib_main_t *vm, vnet_dev_port_t *port, 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 @@ vnet_dev_port_cfg_change_req_validate (vlib_main_t *vm, vnet_dev_port_t *port, 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 @@ vnet_dev_port_cfg_change (vlib_main_t *vm, vnet_dev_port_t *port, 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 @@ vnet_dev_port_if_create (vlib_main_t *vm, vnet_dev_port_t *port) 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, |