[dpdk-dev] [PATCH v3] net/vmxnet3: Added mtu_set() function to allow setting MTU.

Myers, Charles Charles.Myers at spirent.com
Wed Aug 21 07:19:22 CEST 2019


MTU change is currently only allowed when device is stopped.

Current code in master branch already sets MTU in shared data correctly when starting the device:

static int
vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
{
        struct rte_eth_conf port_conf = dev->data->dev_conf;
        struct vmxnet3_hw *hw = dev->data->dev_private;
        uint32_t mtu = dev->data->mtu;
...
        devRead->misc.mtu = rte_le_to_cpu_32(mtu);
...
}

However current code in master branch does not implement a mtu_set() function so MTU in the dev->data is never changed from default of 1500:

int
rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu)
{
        int ret;
        struct rte_eth_dev_info dev_info;
        struct rte_eth_dev *dev;

        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);

        /*
         * Check if the device supports dev_infos_get, if it does not
         * skip min_mtu/max_mtu validation here as this requires values
         * that are populated within the call to rte_eth_dev_info_get()
         * which relies on dev->dev_ops->dev_infos_get.
         */
        if (*dev->dev_ops->dev_infos_get != NULL) {
                rte_eth_dev_info_get(port_id, &dev_info);
                if (mtu < dev_info.min_mtu || mtu > dev_info.max_mtu)
                        return -EINVAL;
        }

        ret = (*dev->dev_ops->mtu_set)(dev, mtu);
        if (!ret)
                dev->data->mtu = mtu;

        return eth_err(port_id, ret);
}

The vmxnet3 driver just needs to implement mtu_set() so that rte_eth_dev_set_mtu() allows changing the MTU and puts the value in dev->data->mtu .


-----Original Message-----
From: Stephen Hemminger <stephen at networkplumber.org> 
Sent: Tuesday, August 20, 2019 6:43 PM
To: Myers, Charles <Charles.Myers at spirent.com>
Cc: Yong Wang <yongwang at vmware.com>; dev at dpdk.org
Subject: Re: [PATCH v3] net/vmxnet3: Added mtu_set() function to allow setting MTU.

On Wed, 21 Aug 2019 02:16:58 +0000
"Myers, Charles" <Charles.Myers at spirent.com> wrote:

>  
>  static int
> +vmxnet3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
> +	if (dev->data->dev_started) {
> +		PMD_DRV_LOG(ERR, "Port %d must be stopped to configure MTU",
> +			    dev->data->port_id);
> +		return -EBUSY;
> +	}
> +
> +	return 0;
> +}
> +

Don't you need to reset the rx ring to change mtu on the fly?
At a minimum you need to communicate this value to host through the shared driver page.



More information about the dev mailing list