[dpdk-dev,v3] i40e: configure MTU

Message ID 1463127333-10007-1-git-send-email-beilei.xing@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers

Commit Message

Xing, Beilei May 13, 2016, 8:15 a.m. UTC
  This patch enables configuring MTU for i40e.
Since changing MTU needs to reconfigure queue, stop port first
before configuring MTU.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v3 changes:
 Add frame size with extra I40E_VLAN_TAG_SIZE.
 Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

v2 changes:
 If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.
 Delete rxq reconfigure cause rxq reconfigure will be finished in
 i40e_dev_rx_init.
   
 drivers/net/i40e/i40e_ethdev.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
  

Comments

Olivier Matz May 16, 2016, 12:27 p.m. UTC | #1
Hi Beilei,

On 05/13/2016 10:15 AM, Beilei Xing wrote:
> This patch enables configuring MTU for i40e.
> Since changing MTU needs to reconfigure queue, stop port first
> before configuring MTU.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
> v3 changes:
>  Add frame size with extra I40E_VLAN_TAG_SIZE.
>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.
> 
> v2 changes:
>  If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.
>  Delete rxq reconfigure cause rxq reconfigure will be finished in
>  i40e_dev_rx_init.
>    
>  drivers/net/i40e/i40e_ethdev.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> [...]
> +static int
> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
> +{
> +	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> +	struct rte_eth_dev_data *dev_data = pf->dev_data;
> +	uint32_t frame_size = mtu + ETHER_HDR_LEN
> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;
> +	int ret = 0;
> +
> +	/* check if mtu is within the allowed range */
> +	if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))
> +		return -EINVAL;
> +
> +	/* mtu setting is forbidden if port is start */
> +	if (dev_data->dev_started) {
> +		PMD_DRV_LOG(ERR,
> +			    "port %d must be stopped before configuration\n",
> +			    dev_data->port_id);
> +		return -ENOTSUP;
> +	}

I'm not convinced that ENOTSUP is the proper return value here.
It is usually returned when a function is not implemented, which
is not the case here: the function is implemented but is forbidden
because the port is running.

I saw that Julien commented on your v1 that the return value should
be one of:
 - (0) if successful.
 - (-ENOTSUP) if operation is not supported.
 - (-ENODEV) if *port_id* invalid.
 - (-EINVAL) if *mtu* invalid.

But I think your initial value (-EBUSY) was fine. Maybe it should be
added in the API instead, with the following description:
  (-EBUSY) if the operation is not allowed when the port is running

This would allow the application to take its dispositions to stop the
port and restart it with the proper jumbo_frame argument.

+CC Thomas which maintains ethdev API.


Regards,
Olivier
  
Yong Wang June 16, 2016, 5:40 p.m. UTC | #2
On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz" <dev-bounces@dpdk.org on behalf of olivier.matz@6wind.com> wrote:

>Hi Beilei,

>

>On 05/13/2016 10:15 AM, Beilei Xing wrote:

>> This patch enables configuring MTU for i40e.

>> Since changing MTU needs to reconfigure queue, stop port first

>> before configuring MTU.

>> 

>> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

>> ---

>> v3 changes:

>>  Add frame size with extra I40E_VLAN_TAG_SIZE.

>>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

>> 

>> v2 changes:

>>  If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.

>>  Delete rxq reconfigure cause rxq reconfigure will be finished in

>>  i40e_dev_rx_init.

>>    

>>  drivers/net/i40e/i40e_ethdev.c | 34 ++++++++++++++++++++++++++++++++++

>>  1 file changed, 34 insertions(+)

>> 

>> [...]

>> +static int

>> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

>> +{

>> +	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

>> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

>> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

>> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

>> +	int ret = 0;

>> +

>> +	/* check if mtu is within the allowed range */

>> +	if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))

>> +		return -EINVAL;

>> +

>> +	/* mtu setting is forbidden if port is start */

>> +	if (dev_data->dev_started) {

>> +		PMD_DRV_LOG(ERR,

>> +			    "port %d must be stopped before configuration\n",

>> +			    dev_data->port_id);

>> +		return -ENOTSUP;

>> +	}

>

>I'm not convinced that ENOTSUP is the proper return value here.

>It is usually returned when a function is not implemented, which

>is not the case here: the function is implemented but is forbidden

>because the port is running.

>

>I saw that Julien commented on your v1 that the return value should

>be one of:

> - (0) if successful.

> - (-ENOTSUP) if operation is not supported.

> - (-ENODEV) if *port_id* invalid.

> - (-EINVAL) if *mtu* invalid.

>

>But I think your initial value (-EBUSY) was fine. Maybe it should be

>added in the API instead, with the following description:

>  (-EBUSY) if the operation is not allowed when the port is running


AFAICT, the same check is not done for other drivers that implement
the mac_set op. Wouldn’t it make more sense to have the driver disable
the port, reconfigure and re-enable it in this case, instead of returning
error code?  If the consensus in DPDK is to have the application disable
the port first, we need to enforce this policy across all devices and
clearly document this behavior.

>This would allow the application to take its dispositions to stop the

>port and restart it with the proper jumbo_frame argument.

>

>+CC Thomas which maintains ethdev API.

>

>

>Regards,

>Olivier
  
Yong Wang June 16, 2016, 5:51 p.m. UTC | #3
On 6/16/16, 10:40 AM, "dev on behalf of Yong Wang" <dev-bounces@dpdk.org on behalf of yongwang@vmware.com> wrote:

>On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz" <dev-bounces@dpdk.org on behalf of olivier.matz@6wind.com> wrote:

>

>>Hi Beilei,

>>

>>On 05/13/2016 10:15 AM, Beilei Xing wrote:

>>> This patch enables configuring MTU for i40e.

>>> Since changing MTU needs to reconfigure queue, stop port first

>>> before configuring MTU.

>>> 

>>> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

>>> ---

>>> v3 changes:

>>>  Add frame size with extra I40E_VLAN_TAG_SIZE.

>>>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

>>> 

>>> v2 changes:

>>>  If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.

>>>  Delete rxq reconfigure cause rxq reconfigure will be finished in

>>>  i40e_dev_rx_init.

>>>    

>>>  drivers/net/i40e/i40e_ethdev.c | 34 ++++++++++++++++++++++++++++++++++

>>>  1 file changed, 34 insertions(+)

>>> 

>>> [...]

>>> +static int

>>> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

>>> +{

>>> +	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

>>> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

>>> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

>>> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

>>> +	int ret = 0;

>>> +

>>> +	/* check if mtu is within the allowed range */

>>> +	if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))

>>> +		return -EINVAL;

>>> +

>>> +	/* mtu setting is forbidden if port is start */

>>> +	if (dev_data->dev_started) {

>>> +		PMD_DRV_LOG(ERR,

>>> +			    "port %d must be stopped before configuration\n",

>>> +			    dev_data->port_id);

>>> +		return -ENOTSUP;

>>> +	}

>>

>>I'm not convinced that ENOTSUP is the proper return value here.

>>It is usually returned when a function is not implemented, which

>>is not the case here: the function is implemented but is forbidden

>>because the port is running.

>>

>>I saw that Julien commented on your v1 that the return value should

>>be one of:

>> - (0) if successful.

>> - (-ENOTSUP) if operation is not supported.

>> - (-ENODEV) if *port_id* invalid.

>> - (-EINVAL) if *mtu* invalid.

>>

>>But I think your initial value (-EBUSY) was fine. Maybe it should be

>>added in the API instead, with the following description:

>>  (-EBUSY) if the operation is not allowed when the port is running

>

>AFAICT, the same check is not done for other drivers that implement

>the mac_set op. Wouldn’t it make more sense to have the driver disable


Correction: this should read as mtu_set.

>the port, reconfigure and re-enable it in this case, instead of returning

>error code?  If the consensus in DPDK is to have the application disable

>the port first, we need to enforce this policy across all devices and

>clearly document this behavior.

>

>>This would allow the application to take its dispositions to stop the

>>port and restart it with the proper jumbo_frame argument.

>>

>>+CC Thomas which maintains ethdev API.

>>

>>

>>Regards,

>>Olivier

>
  
Ananyev, Konstantin June 17, 2016, 12:03 a.m. UTC | #4
> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yong Wang

> Sent: Thursday, June 16, 2016 6:52 PM

> To: Olivier Matz; Xing, Beilei; Wu, Jingjing

> Cc: dev@dpdk.org; Julien Meunier; Thomas Monjalon

> Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> 

> On 6/16/16, 10:40 AM, "dev on behalf of Yong Wang" <dev-bounces@dpdk.org on behalf of yongwang@vmware.com> wrote:

> 

> >On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz" <dev-bounces@dpdk.org on behalf of olivier.matz@6wind.com> wrote:

> >

> >>Hi Beilei,

> >>

> >>On 05/13/2016 10:15 AM, Beilei Xing wrote:

> >>> This patch enables configuring MTU for i40e.

> >>> Since changing MTU needs to reconfigure queue, stop port first

> >>> before configuring MTU.

> >>>

> >>> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

> >>> ---

> >>> v3 changes:

> >>>  Add frame size with extra I40E_VLAN_TAG_SIZE.

> >>>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

> >>>

> >>> v2 changes:

> >>>  If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.

> >>>  Delete rxq reconfigure cause rxq reconfigure will be finished in

> >>>  i40e_dev_rx_init.

> >>>

> >>>  drivers/net/i40e/i40e_ethdev.c | 34 ++++++++++++++++++++++++++++++++++

> >>>  1 file changed, 34 insertions(+)

> >>>

> >>> [...]

> >>> +static int

> >>> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)

> >>> +{

> >>> +	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

> >>> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

> >>> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

> >>> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

> >>> +	int ret = 0;

> >>> +

> >>> +	/* check if mtu is within the allowed range */

> >>> +	if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))

> >>> +		return -EINVAL;

> >>> +

> >>> +	/* mtu setting is forbidden if port is start */

> >>> +	if (dev_data->dev_started) {

> >>> +		PMD_DRV_LOG(ERR,

> >>> +			    "port %d must be stopped before configuration\n",

> >>> +			    dev_data->port_id);

> >>> +		return -ENOTSUP;

> >>> +	}

> >>

> >>I'm not convinced that ENOTSUP is the proper return value here.

> >>It is usually returned when a function is not implemented, which

> >>is not the case here: the function is implemented but is forbidden

> >>because the port is running.

> >>

> >>I saw that Julien commented on your v1 that the return value should

> >>be one of:

> >> - (0) if successful.

> >> - (-ENOTSUP) if operation is not supported.

> >> - (-ENODEV) if *port_id* invalid.

> >> - (-EINVAL) if *mtu* invalid.

> >>

> >>But I think your initial value (-EBUSY) was fine. Maybe it should be

> >>added in the API instead, with the following description:

> >>  (-EBUSY) if the operation is not allowed when the port is running

> >

> >AFAICT, the same check is not done for other drivers that implement

> >the mac_set op. Wouldn’t it make more sense to have the driver disable

> 

> Correction: this should read as mtu_set.

> 

> >the port, reconfigure and re-enable it in this case, instead of returning

> >error code?  If the consensus in DPDK is to have the application disable

> >the port first, we need to enforce this policy across all devices and

> >clearly document this behavior.


Other PMDs do allow to change mtu without stopping/reconfiguration the port
(under certain conditions of course).
As I remember that's why that function was introduced at the first place.
It is a bit strange that i40e doesn't allow that, might be the author can
comment why it is necessary.
Again the whole i40e_dev_mtu_set() looks a bit strange to me -
I can't see where the actual change of HW state is happening.
Konstantin

> >

> >>This would allow the application to take its dispositions to stop the

> >>port and restart it with the proper jumbo_frame argument.

> >>

> >>+CC Thomas which maintains ethdev API.

> >>

> >>

> >>Regards,

> >>Olivier

> >
  
Xing, Beilei June 20, 2016, 4:49 a.m. UTC | #5
> -----Original Message-----

> From: Yong Wang [mailto:yongwang@vmware.com]

> Sent: Friday, June 17, 2016 1:40 AM

> To: Olivier Matz <olivier.matz@6wind.com>; Xing, Beilei <beilei.xing@intel.com>;

> Wu, Jingjing <jingjing.wu@intel.com>

> Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> Monjalon <thomas.monjalon@6wind.com>

> Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> 

> On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz" <dev-bounces@dpdk.org

> on behalf of olivier.matz@6wind.com> wrote:

> 

> >Hi Beilei,

> >

> >On 05/13/2016 10:15 AM, Beilei Xing wrote:

> >> This patch enables configuring MTU for i40e.

> >> Since changing MTU needs to reconfigure queue, stop port first before

> >> configuring MTU.

> >>

> >> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

> >> ---

> >> v3 changes:

> >>  Add frame size with extra I40E_VLAN_TAG_SIZE.

> >>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

> >>

> >> v2 changes:

> >>  If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.

> >>  Delete rxq reconfigure cause rxq reconfigure will be finished in

> >> i40e_dev_rx_init.

> >>

> >>  drivers/net/i40e/i40e_ethdev.c | 34

> >> ++++++++++++++++++++++++++++++++++

> >>  1 file changed, 34 insertions(+)

> >>

> >> [...]

> >> +static int

> >> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {

> >> +	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

> >> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

> >> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

> >> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

> >> +	int ret = 0;

> >> +

> >> +	/* check if mtu is within the allowed range */

> >> +	if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))

> >> +		return -EINVAL;

> >> +

> >> +	/* mtu setting is forbidden if port is start */

> >> +	if (dev_data->dev_started) {

> >> +		PMD_DRV_LOG(ERR,

> >> +			    "port %d must be stopped before configuration\n",

> >> +			    dev_data->port_id);

> >> +		return -ENOTSUP;

> >> +	}

> >

> >I'm not convinced that ENOTSUP is the proper return value here.

> >It is usually returned when a function is not implemented, which is not

> >the case here: the function is implemented but is forbidden because the

> >port is running.

> >

> >I saw that Julien commented on your v1 that the return value should be

> >one of:

> > - (0) if successful.

> > - (-ENOTSUP) if operation is not supported.

> > - (-ENODEV) if *port_id* invalid.

> > - (-EINVAL) if *mtu* invalid.

> >

> >But I think your initial value (-EBUSY) was fine. Maybe it should be

> >added in the API instead, with the following description:

> >  (-EBUSY) if the operation is not allowed when the port is running

> 

> AFAICT, the same check is not done for other drivers that implement the mac_set

> op. Wouldn’t it make more sense to have the driver disable the port,

> reconfigure and re-enable it in this case, instead of returning error code?  If the

> consensus in DPDK is to have the application disable the port first, we need to

> enforce this policy across all devices and clearly document this behavior.

> 

Hi,
For ixgbe/igb, there's register for MTU during runtime, but for i40e, setting MTU is finished by firmware during configuration. There'll be some risk when disable the port, reconfigure and re-enable the port, so return error code in this case currently.
Thanks for your comments, we'll improve the document later.

> >This would allow the application to take its dispositions to stop the

> >port and restart it with the proper jumbo_frame argument.

> >

> >+CC Thomas which maintains ethdev API.

> >

> >

> >Regards,

> >Olivier
  
Xing, Beilei June 20, 2016, 4:59 a.m. UTC | #6
> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei

> Sent: Monday, June 20, 2016 12:50 PM

> To: Yong Wang <yongwang@vmware.com>; Olivier Matz

> <olivier.matz@6wind.com>; Wu, Jingjing <jingjing.wu@intel.com>

> Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> Monjalon <thomas.monjalon@6wind.com>

> Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> 

> 

> > -----Original Message-----

> > From: Yong Wang [mailto:yongwang@vmware.com]

> > Sent: Friday, June 17, 2016 1:40 AM

> > To: Olivier Matz <olivier.matz@6wind.com>; Xing, Beilei

> > <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>

> > Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> > Monjalon <thomas.monjalon@6wind.com>

> > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> >

> > On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz"

> > <dev-bounces@dpdk.org on behalf of olivier.matz@6wind.com> wrote:

> >

> > >Hi Beilei,

> > >

> > >On 05/13/2016 10:15 AM, Beilei Xing wrote:

> > >> This patch enables configuring MTU for i40e.

> > >> Since changing MTU needs to reconfigure queue, stop port first

> > >> before configuring MTU.

> > >>

> > >> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

> > >> ---

> > >> v3 changes:

> > >>  Add frame size with extra I40E_VLAN_TAG_SIZE.

> > >>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

> > >>

> > >> v2 changes:

> > >>  If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.

> > >>  Delete rxq reconfigure cause rxq reconfigure will be finished in

> > >> i40e_dev_rx_init.

> > >>

> > >>  drivers/net/i40e/i40e_ethdev.c | 34

> > >> ++++++++++++++++++++++++++++++++++

> > >>  1 file changed, 34 insertions(+)

> > >>

> > >> [...]

> > >> +static int

> > >> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {

> > >> +	struct i40e_pf *pf =

> I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

> > >> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

> > >> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

> > >> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

> > >> +	int ret = 0;

> > >> +

> > >> +	/* check if mtu is within the allowed range */

> > >> +	if ((mtu < ETHER_MIN_MTU) || (frame_size >

> I40E_FRAME_SIZE_MAX))

> > >> +		return -EINVAL;

> > >> +

> > >> +	/* mtu setting is forbidden if port is start */

> > >> +	if (dev_data->dev_started) {

> > >> +		PMD_DRV_LOG(ERR,

> > >> +			    "port %d must be stopped before configuration\n",

> > >> +			    dev_data->port_id);

> > >> +		return -ENOTSUP;

> > >> +	}

> > >

> > >I'm not convinced that ENOTSUP is the proper return value here.

> > >It is usually returned when a function is not implemented, which is

> > >not the case here: the function is implemented but is forbidden

> > >because the port is running.

> > >

> > >I saw that Julien commented on your v1 that the return value should

> > >be one of:

> > > - (0) if successful.

> > > - (-ENOTSUP) if operation is not supported.

> > > - (-ENODEV) if *port_id* invalid.

> > > - (-EINVAL) if *mtu* invalid.

> > >

> > >But I think your initial value (-EBUSY) was fine. Maybe it should be

> > >added in the API instead, with the following description:

> > >  (-EBUSY) if the operation is not allowed when the port is running

> >

> > AFAICT, the same check is not done for other drivers that implement

> > the mac_set op. Wouldn’t it make more sense to have the driver disable

> > the port, reconfigure and re-enable it in this case, instead of

> > returning error code?  If the consensus in DPDK is to have the

> > application disable the port first, we need to enforce this policy across all

> devices and clearly document this behavior.

> >

> Hi,

> For ixgbe/igb, there's register for MTU during runtime, but for i40e, setting MTU

> is finished by firmware during configuration. There'll be some risk when disable

> the port, reconfigure and re-enable the port, so return error code in this case

> currently.

Correction: register for max packet length.
> Thanks for your comments, we'll improve the document later.

> 

> > >This would allow the application to take its dispositions to stop the

> > >port and restart it with the proper jumbo_frame argument.

> > >

> > >+CC Thomas which maintains ethdev API.

> > >

> > >

> > >Regards,

> > >Olivier
  
Ananyev, Konstantin June 20, 2016, 8:05 a.m. UTC | #7
> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei

> Sent: Monday, June 20, 2016 5:50 AM

> To: Yong Wang; Olivier Matz; Wu, Jingjing

> Cc: dev@dpdk.org; Julien Meunier; Thomas Monjalon

> Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> 

> 

> > -----Original Message-----

> > From: Yong Wang [mailto:yongwang@vmware.com]

> > Sent: Friday, June 17, 2016 1:40 AM

> > To: Olivier Matz <olivier.matz@6wind.com>; Xing, Beilei <beilei.xing@intel.com>;

> > Wu, Jingjing <jingjing.wu@intel.com>

> > Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> > Monjalon <thomas.monjalon@6wind.com>

> > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> >

> > On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz" <dev-bounces@dpdk.org

> > on behalf of olivier.matz@6wind.com> wrote:

> >

> > >Hi Beilei,

> > >

> > >On 05/13/2016 10:15 AM, Beilei Xing wrote:

> > >> This patch enables configuring MTU for i40e.

> > >> Since changing MTU needs to reconfigure queue, stop port first before

> > >> configuring MTU.

> > >>

> > >> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

> > >> ---

> > >> v3 changes:

> > >>  Add frame size with extra I40E_VLAN_TAG_SIZE.

> > >>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

> > >>

> > >> v2 changes:

> > >>  If mtu is not within the allowed range, return -EINVAL instead of -EBUSY.

> > >>  Delete rxq reconfigure cause rxq reconfigure will be finished in

> > >> i40e_dev_rx_init.

> > >>

> > >>  drivers/net/i40e/i40e_ethdev.c | 34

> > >> ++++++++++++++++++++++++++++++++++

> > >>  1 file changed, 34 insertions(+)

> > >>

> > >> [...]

> > >> +static int

> > >> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {

> > >> +	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

> > >> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

> > >> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

> > >> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

> > >> +	int ret = 0;

> > >> +

> > >> +	/* check if mtu is within the allowed range */

> > >> +	if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))

> > >> +		return -EINVAL;

> > >> +

> > >> +	/* mtu setting is forbidden if port is start */

> > >> +	if (dev_data->dev_started) {

> > >> +		PMD_DRV_LOG(ERR,

> > >> +			    "port %d must be stopped before configuration\n",

> > >> +			    dev_data->port_id);

> > >> +		return -ENOTSUP;

> > >> +	}

> > >

> > >I'm not convinced that ENOTSUP is the proper return value here.

> > >It is usually returned when a function is not implemented, which is not

> > >the case here: the function is implemented but is forbidden because the

> > >port is running.

> > >

> > >I saw that Julien commented on your v1 that the return value should be

> > >one of:

> > > - (0) if successful.

> > > - (-ENOTSUP) if operation is not supported.

> > > - (-ENODEV) if *port_id* invalid.

> > > - (-EINVAL) if *mtu* invalid.

> > >

> > >But I think your initial value (-EBUSY) was fine. Maybe it should be

> > >added in the API instead, with the following description:

> > >  (-EBUSY) if the operation is not allowed when the port is running

> >

> > AFAICT, the same check is not done for other drivers that implement the mac_set

> > op. Wouldn’t it make more sense to have the driver disable the port,

> > reconfigure and re-enable it in this case, instead of returning error code?  If the

> > consensus in DPDK is to have the application disable the port first, we need to

> > enforce this policy across all devices and clearly document this behavior.

> >

> Hi,

> For ixgbe/igb, there's register for MTU during runtime, but for i40e, setting MTU is finished by firmware during configuration. There'll

> be some risk when disable the port, reconfigure and re-enable the port, so return error code in this case currently.


Ok, but then what is the point to introduce mtu_set() for i40e at all?
Let's just leave it unimplemented, as it is right now.
Then users would know that for that device they have to do dev_stop/dev_configure().
Konstantin

> Thanks for your comments, we'll improve the document later.

> 

> > >This would allow the application to take its dispositions to stop the

> > >port and restart it with the proper jumbo_frame argument.

> > >

> > >+CC Thomas which maintains ethdev API.

> > >

> > >

> > >Regards,

> > >Olivier
  
Xing, Beilei June 20, 2016, 12:04 p.m. UTC | #8
> -----Original Message-----

> From: Ananyev, Konstantin

> Sent: Monday, June 20, 2016 4:05 PM

> To: Xing, Beilei <beilei.xing@intel.com>; Yong Wang

> <yongwang@vmware.com>; Olivier Matz <olivier.matz@6wind.com>; Wu,

> Jingjing <jingjing.wu@intel.com>

> Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> Monjalon <thomas.monjalon@6wind.com>

> Subject: RE: [dpdk-dev] [PATCH v3] i40e: configure MTU

> 

> 

> 

> > -----Original Message-----

> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei

> > Sent: Monday, June 20, 2016 5:50 AM

> > To: Yong Wang; Olivier Matz; Wu, Jingjing

> > Cc: dev@dpdk.org; Julien Meunier; Thomas Monjalon

> > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> >

> >

> > > -----Original Message-----

> > > From: Yong Wang [mailto:yongwang@vmware.com]

> > > Sent: Friday, June 17, 2016 1:40 AM

> > > To: Olivier Matz <olivier.matz@6wind.com>; Xing, Beilei

> > > <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>

> > > Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> > > Monjalon <thomas.monjalon@6wind.com>

> > > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> > >

> > > On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz"

> > > <dev-bounces@dpdk.org on behalf of olivier.matz@6wind.com> wrote:

> > >

> > > >Hi Beilei,

> > > >

> > > >On 05/13/2016 10:15 AM, Beilei Xing wrote:

> > > >> This patch enables configuring MTU for i40e.

> > > >> Since changing MTU needs to reconfigure queue, stop port first

> > > >> before configuring MTU.

> > > >>

> > > >> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

> > > >> ---

> > > >> v3 changes:

> > > >>  Add frame size with extra I40E_VLAN_TAG_SIZE.

> > > >>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

> > > >>

> > > >> v2 changes:

> > > >>  If mtu is not within the allowed range, return -EINVAL instead of

> -EBUSY.

> > > >>  Delete rxq reconfigure cause rxq reconfigure will be finished in

> > > >> i40e_dev_rx_init.

> > > >>

> > > >>  drivers/net/i40e/i40e_ethdev.c | 34

> > > >> ++++++++++++++++++++++++++++++++++

> > > >>  1 file changed, 34 insertions(+)

> > > >>

> > > >> [...]

> > > >> +static int

> > > >> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {

> > > >> +	struct i40e_pf *pf =

> I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

> > > >> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

> > > >> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

> > > >> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

> > > >> +	int ret = 0;

> > > >> +

> > > >> +	/* check if mtu is within the allowed range */

> > > >> +	if ((mtu < ETHER_MIN_MTU) || (frame_size >

> I40E_FRAME_SIZE_MAX))

> > > >> +		return -EINVAL;

> > > >> +

> > > >> +	/* mtu setting is forbidden if port is start */

> > > >> +	if (dev_data->dev_started) {

> > > >> +		PMD_DRV_LOG(ERR,

> > > >> +			    "port %d must be stopped before configuration\n",

> > > >> +			    dev_data->port_id);

> > > >> +		return -ENOTSUP;

> > > >> +	}

> > > >

> > > >I'm not convinced that ENOTSUP is the proper return value here.

> > > >It is usually returned when a function is not implemented, which is

> > > >not the case here: the function is implemented but is forbidden

> > > >because the port is running.

> > > >

> > > >I saw that Julien commented on your v1 that the return value should

> > > >be one of:

> > > > - (0) if successful.

> > > > - (-ENOTSUP) if operation is not supported.

> > > > - (-ENODEV) if *port_id* invalid.

> > > > - (-EINVAL) if *mtu* invalid.

> > > >

> > > >But I think your initial value (-EBUSY) was fine. Maybe it should

> > > >be added in the API instead, with the following description:

> > > >  (-EBUSY) if the operation is not allowed when the port is running

> > >

> > > AFAICT, the same check is not done for other drivers that implement

> > > the mac_set op. Wouldn’t it make more sense to have the driver

> > > disable the port, reconfigure and re-enable it in this case, instead

> > > of returning error code?  If the consensus in DPDK is to have the

> > > application disable the port first, we need to enforce this policy across all

> devices and clearly document this behavior.

> > >

> > Hi,

> > For ixgbe/igb, there's register for MTU during runtime, but for i40e,

> > setting MTU is finished by firmware during configuration. There'll be some risk

> when disable the port, reconfigure and re-enable the port, so return error code

> in this case currently.

> 

> Ok, but then what is the point to introduce mtu_set() for i40e at all?

> Let's just leave it unimplemented, as it is right now.

> Then users would know that for that device they have to do

> dev_stop/dev_configure().


Hi Konstantin,
The original intention is to reduce ops gap in different PMDs, but unfortunately, setting MTU in i40e couldn’t be finished as in ixgbe, so in the function, we change the configuration and note users that if want to configure MTU, stop ports first. The sequence of configuring MTU for i40e is: port stop->set MTU->port start.
We will add according instruction in document.
Beilei

> Konstantin

> 

> > Thanks for your comments, we'll improve the document later.

> >

> > > >This would allow the application to take its dispositions to stop

> > > >the port and restart it with the proper jumbo_frame argument.

> > > >

> > > >+CC Thomas which maintains ethdev API.

> > > >

> > > >

> > > >Regards,

> > > >Olivier
  
Ananyev, Konstantin June 20, 2016, 12:15 p.m. UTC | #9
Hi Beilei,

> -----Original Message-----

> From: Xing, Beilei

> Sent: Monday, June 20, 2016 1:05 PM

> To: Ananyev, Konstantin; Yong Wang; Olivier Matz; Wu, Jingjing

> Cc: dev@dpdk.org; Julien Meunier; Thomas Monjalon

> Subject: RE: [dpdk-dev] [PATCH v3] i40e: configure MTU

> 

> 

> > -----Original Message-----

> > From: Ananyev, Konstantin

> > Sent: Monday, June 20, 2016 4:05 PM

> > To: Xing, Beilei <beilei.xing@intel.com>; Yong Wang

> > <yongwang@vmware.com>; Olivier Matz <olivier.matz@6wind.com>; Wu,

> > Jingjing <jingjing.wu@intel.com>

> > Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> > Monjalon <thomas.monjalon@6wind.com>

> > Subject: RE: [dpdk-dev] [PATCH v3] i40e: configure MTU

> >

> >

> >

> > > -----Original Message-----

> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei

> > > Sent: Monday, June 20, 2016 5:50 AM

> > > To: Yong Wang; Olivier Matz; Wu, Jingjing

> > > Cc: dev@dpdk.org; Julien Meunier; Thomas Monjalon

> > > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> > >

> > >

> > > > -----Original Message-----

> > > > From: Yong Wang [mailto:yongwang@vmware.com]

> > > > Sent: Friday, June 17, 2016 1:40 AM

> > > > To: Olivier Matz <olivier.matz@6wind.com>; Xing, Beilei

> > > > <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>

> > > > Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> > > > Monjalon <thomas.monjalon@6wind.com>

> > > > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> > > >

> > > > On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz"

> > > > <dev-bounces@dpdk.org on behalf of olivier.matz@6wind.com> wrote:

> > > >

> > > > >Hi Beilei,

> > > > >

> > > > >On 05/13/2016 10:15 AM, Beilei Xing wrote:

> > > > >> This patch enables configuring MTU for i40e.

> > > > >> Since changing MTU needs to reconfigure queue, stop port first

> > > > >> before configuring MTU.

> > > > >>

> > > > >> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

> > > > >> ---

> > > > >> v3 changes:

> > > > >>  Add frame size with extra I40E_VLAN_TAG_SIZE.

> > > > >>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

> > > > >>

> > > > >> v2 changes:

> > > > >>  If mtu is not within the allowed range, return -EINVAL instead of

> > -EBUSY.

> > > > >>  Delete rxq reconfigure cause rxq reconfigure will be finished in

> > > > >> i40e_dev_rx_init.

> > > > >>

> > > > >>  drivers/net/i40e/i40e_ethdev.c | 34

> > > > >> ++++++++++++++++++++++++++++++++++

> > > > >>  1 file changed, 34 insertions(+)

> > > > >>

> > > > >> [...]

> > > > >> +static int

> > > > >> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {

> > > > >> +	struct i40e_pf *pf =

> > I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

> > > > >> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

> > > > >> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

> > > > >> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

> > > > >> +	int ret = 0;

> > > > >> +

> > > > >> +	/* check if mtu is within the allowed range */

> > > > >> +	if ((mtu < ETHER_MIN_MTU) || (frame_size >

> > I40E_FRAME_SIZE_MAX))

> > > > >> +		return -EINVAL;

> > > > >> +

> > > > >> +	/* mtu setting is forbidden if port is start */

> > > > >> +	if (dev_data->dev_started) {

> > > > >> +		PMD_DRV_LOG(ERR,

> > > > >> +			    "port %d must be stopped before configuration\n",

> > > > >> +			    dev_data->port_id);

> > > > >> +		return -ENOTSUP;

> > > > >> +	}

> > > > >

> > > > >I'm not convinced that ENOTSUP is the proper return value here.

> > > > >It is usually returned when a function is not implemented, which is

> > > > >not the case here: the function is implemented but is forbidden

> > > > >because the port is running.

> > > > >

> > > > >I saw that Julien commented on your v1 that the return value should

> > > > >be one of:

> > > > > - (0) if successful.

> > > > > - (-ENOTSUP) if operation is not supported.

> > > > > - (-ENODEV) if *port_id* invalid.

> > > > > - (-EINVAL) if *mtu* invalid.

> > > > >

> > > > >But I think your initial value (-EBUSY) was fine. Maybe it should

> > > > >be added in the API instead, with the following description:

> > > > >  (-EBUSY) if the operation is not allowed when the port is running

> > > >

> > > > AFAICT, the same check is not done for other drivers that implement

> > > > the mac_set op. Wouldn’t it make more sense to have the driver

> > > > disable the port, reconfigure and re-enable it in this case, instead

> > > > of returning error code?  If the consensus in DPDK is to have the

> > > > application disable the port first, we need to enforce this policy across all

> > devices and clearly document this behavior.

> > > >

> > > Hi,

> > > For ixgbe/igb, there's register for MTU during runtime, but for i40e,

> > > setting MTU is finished by firmware during configuration. There'll be some risk

> > when disable the port, reconfigure and re-enable the port, so return error code

> > in this case currently.

> >

> > Ok, but then what is the point to introduce mtu_set() for i40e at all?

> > Let's just leave it unimplemented, as it is right now.

> > Then users would know that for that device they have to do

> > dev_stop/dev_configure().

> 

> Hi Konstantin,

> The original intention is to reduce ops gap in different PMDs, but unfortunately, setting MTU in i40e couldn’t be finished as in ixgbe,


Yes, I understand that from your previous explanation.

> so in the function, we change the configuration and note users that if want to configure MTU, stop ports first.


Well, you can do that now with dev_stop(); dev_configure(), right?
As I remember, the original intention of mtu_set() was to give user an ability
to change mtu (whenever possible) without stopping the port.
If the HW (i40e) doesn't support it - that's fine, we just leave mtu_set() for i40e unimplemented. 

> The sequence of > configuring MTU for i40e is: port stop->set MTU->port start.

> We will add according instruction in document.


Sorry, but I don’t agree here.
I think, in that case it is better just to leave mtu_set() unimplemented for i40e.
Konstantin

> Beilei

> 

> > Konstantin

> >

> > > Thanks for your comments, we'll improve the document later.

> > >

> > > > >This would allow the application to take its dispositions to stop

> > > > >the port and restart it with the proper jumbo_frame argument.

> > > > >

> > > > >+CC Thomas which maintains ethdev API.

> > > > >

> > > > >

> > > > >Regards,

> > > > >Olivier
  
Xing, Beilei June 20, 2016, 12:46 p.m. UTC | #10
Hi Konstantin,

> -----Original Message-----

> From: Ananyev, Konstantin

> Sent: Monday, June 20, 2016 8:15 PM

> To: Xing, Beilei <beilei.xing@intel.com>; Yong Wang <yongwang@vmware.com>;

> Olivier Matz <olivier.matz@6wind.com>; Wu, Jingjing <jingjing.wu@intel.com>

> Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> Monjalon <thomas.monjalon@6wind.com>

> Subject: RE: [dpdk-dev] [PATCH v3] i40e: configure MTU

> 

> Hi Beilei,

> 

> > -----Original Message-----

> > From: Xing, Beilei

> > Sent: Monday, June 20, 2016 1:05 PM

> > To: Ananyev, Konstantin; Yong Wang; Olivier Matz; Wu, Jingjing

> > Cc: dev@dpdk.org; Julien Meunier; Thomas Monjalon

> > Subject: RE: [dpdk-dev] [PATCH v3] i40e: configure MTU

> >

> >

> > > -----Original Message-----

> > > From: Ananyev, Konstantin

> > > Sent: Monday, June 20, 2016 4:05 PM

> > > To: Xing, Beilei <beilei.xing@intel.com>; Yong Wang

> > > <yongwang@vmware.com>; Olivier Matz <olivier.matz@6wind.com>; Wu,

> > > Jingjing <jingjing.wu@intel.com>

> > > Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>; Thomas

> > > Monjalon <thomas.monjalon@6wind.com>

> > > Subject: RE: [dpdk-dev] [PATCH v3] i40e: configure MTU

> > >

> > >

> > >

> > > > -----Original Message-----

> > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei

> > > > Sent: Monday, June 20, 2016 5:50 AM

> > > > To: Yong Wang; Olivier Matz; Wu, Jingjing

> > > > Cc: dev@dpdk.org; Julien Meunier; Thomas Monjalon

> > > > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> > > >

> > > >

> > > > > -----Original Message-----

> > > > > From: Yong Wang [mailto:yongwang@vmware.com]

> > > > > Sent: Friday, June 17, 2016 1:40 AM

> > > > > To: Olivier Matz <olivier.matz@6wind.com>; Xing, Beilei

> > > > > <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>

> > > > > Cc: dev@dpdk.org; Julien Meunier <julien.meunier@6wind.com>;

> > > > > Thomas Monjalon <thomas.monjalon@6wind.com>

> > > > > Subject: Re: [dpdk-dev] [PATCH v3] i40e: configure MTU

> > > > >

> > > > > On 5/16/16, 5:27 AM, "dev on behalf of Olivier Matz"

> > > > > <dev-bounces@dpdk.org on behalf of olivier.matz@6wind.com> wrote:

> > > > >

> > > > > >Hi Beilei,

> > > > > >

> > > > > >On 05/13/2016 10:15 AM, Beilei Xing wrote:

> > > > > >> This patch enables configuring MTU for i40e.

> > > > > >> Since changing MTU needs to reconfigure queue, stop port

> > > > > >> first before configuring MTU.

> > > > > >>

> > > > > >> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

> > > > > >> ---

> > > > > >> v3 changes:

> > > > > >>  Add frame size with extra I40E_VLAN_TAG_SIZE.

> > > > > >>  Delete i40e_dev_rx_init(pf) cause it will be called when port starts.

> > > > > >>

> > > > > >> v2 changes:

> > > > > >>  If mtu is not within the allowed range, return -EINVAL

> > > > > >> instead of

> > > -EBUSY.

> > > > > >>  Delete rxq reconfigure cause rxq reconfigure will be

> > > > > >> finished in i40e_dev_rx_init.

> > > > > >>

> > > > > >>  drivers/net/i40e/i40e_ethdev.c | 34

> > > > > >> ++++++++++++++++++++++++++++++++++

> > > > > >>  1 file changed, 34 insertions(+)

> > > > > >>

> > > > > >> [...]

> > > > > >> +static int

> > > > > >> +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {

> > > > > >> +	struct i40e_pf *pf =

> > > I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);

> > > > > >> +	struct rte_eth_dev_data *dev_data = pf->dev_data;

> > > > > >> +	uint32_t frame_size = mtu + ETHER_HDR_LEN

> > > > > >> +			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;

> > > > > >> +	int ret = 0;

> > > > > >> +

> > > > > >> +	/* check if mtu is within the allowed range */

> > > > > >> +	if ((mtu < ETHER_MIN_MTU) || (frame_size >

> > > I40E_FRAME_SIZE_MAX))

> > > > > >> +		return -EINVAL;

> > > > > >> +

> > > > > >> +	/* mtu setting is forbidden if port is start */

> > > > > >> +	if (dev_data->dev_started) {

> > > > > >> +		PMD_DRV_LOG(ERR,

> > > > > >> +			    "port %d must be stopped before

> configuration\n",

> > > > > >> +			    dev_data->port_id);

> > > > > >> +		return -ENOTSUP;

> > > > > >> +	}

> > > > > >

> > > > > >I'm not convinced that ENOTSUP is the proper return value here.

> > > > > >It is usually returned when a function is not implemented,

> > > > > >which is not the case here: the function is implemented but is

> > > > > >forbidden because the port is running.

> > > > > >

> > > > > >I saw that Julien commented on your v1 that the return value

> > > > > >should be one of:

> > > > > > - (0) if successful.

> > > > > > - (-ENOTSUP) if operation is not supported.

> > > > > > - (-ENODEV) if *port_id* invalid.

> > > > > > - (-EINVAL) if *mtu* invalid.

> > > > > >

> > > > > >But I think your initial value (-EBUSY) was fine. Maybe it

> > > > > >should be added in the API instead, with the following description:

> > > > > >  (-EBUSY) if the operation is not allowed when the port is

> > > > > >running

> > > > >

> > > > > AFAICT, the same check is not done for other drivers that

> > > > > implement the mac_set op. Wouldn’t it make more sense to have

> > > > > the driver disable the port, reconfigure and re-enable it in

> > > > > this case, instead of returning error code?  If the consensus in

> > > > > DPDK is to have the application disable the port first, we need

> > > > > to enforce this policy across all

> > > devices and clearly document this behavior.

> > > > >

> > > > Hi,

> > > > For ixgbe/igb, there's register for MTU during runtime, but for

> > > > i40e, setting MTU is finished by firmware during configuration.

> > > > There'll be some risk

> > > when disable the port, reconfigure and re-enable the port, so return

> > > error code in this case currently.

> > >

> > > Ok, but then what is the point to introduce mtu_set() for i40e at all?

> > > Let's just leave it unimplemented, as it is right now.

> > > Then users would know that for that device they have to do

> > > dev_stop/dev_configure().

> >

> > Hi Konstantin,

> > The original intention is to reduce ops gap in different PMDs, but

> > unfortunately, setting MTU in i40e couldn’t be finished as in ixgbe,

> 

> Yes, I understand that from your previous explanation.

> 

> > so in the function, we change the configuration and note users that if want to

> configure MTU, stop ports first.

> 

> Well, you can do that now with dev_stop(); dev_configure(), right?


Yes, that's right.

> As I remember, the original intention of mtu_set() was to give user an ability to

> change mtu (whenever possible) without stopping the port.

> If the HW (i40e) doesn't support it - that's fine, we just leave mtu_set() for i40e

> unimplemented.

> 

> > The sequence of > configuring MTU for i40e is: port stop->set MTU->port start.

> > We will add according instruction in document.

> 

> Sorry, but I don’t agree here.

> I think, in that case it is better just to leave mtu_set() unimplemented for i40e.


OK, I'll discuss with maintainer for this case.
Thanks for all your points:)
Beilei

> Konstantin

> 

> > Beilei

> >

> > > Konstantin

> > >

> > > > Thanks for your comments, we'll improve the document later.

> > > >

> > > > > >This would allow the application to take its dispositions to

> > > > > >stop the port and restart it with the proper jumbo_frame argument.

> > > > > >

> > > > > >+CC Thomas which maintains ethdev API.

> > > > > >

> > > > > >

> > > > > >Regards,

> > > > > >Olivier
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index d8b6bd7..96d10c2 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -447,6 +447,8 @@  static int i40e_get_eeprom(struct rte_eth_dev *dev,
 static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
 				      struct ether_addr *mac_addr);
 
+static int i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+
 static const struct rte_pci_id pci_id_i40e_map[] = {
 #define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #include "rte_pci_dev_ids.h"
@@ -520,6 +522,7 @@  static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.get_eeprom_length            = i40e_get_eeprom_length,
 	.get_eeprom                   = i40e_get_eeprom,
 	.mac_addr_set                 = i40e_set_default_mac_addr,
+	.mtu_set                      = i40e_dev_mtu_set,
 };
 
 /* store statistics names and its offset in stats structure */
@@ -9103,3 +9106,34 @@  static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
 	/* Flags: 0x3 updates port address */
 	i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL);
 }
+
+static int
+i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct rte_eth_dev_data *dev_data = pf->dev_data;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN
+			      + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;
+	int ret = 0;
+
+	/* check if mtu is within the allowed range */
+	if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_FRAME_SIZE_MAX))
+		return -EINVAL;
+
+	/* mtu setting is forbidden if port is start */
+	if (dev_data->dev_started) {
+		PMD_DRV_LOG(ERR,
+			    "port %d must be stopped before configuration\n",
+			    dev_data->port_id);
+		return -ENOTSUP;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev_data->dev_conf.rxmode.jumbo_frame = 1;
+	else
+		dev_data->dev_conf.rxmode.jumbo_frame = 0;
+
+	dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	return ret;
+}