[v3] net/nfp: fix mtu settings

Message ID 20220330031751.119830-1-peng.zhang@corigine.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series [v3] net/nfp: fix mtu settings |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Nole Zhang March 30, 2022, 3:17 a.m. UTC
  1.When the setting mtu is higher than flbufsz, the mtu doesn't work.
But it doesn't have any notice about this restrict.
2.add the min_mtu and max_mtu in the nfp_net_infos_get() to avoid
the setting mtu isn't in the range

This patch will add these restrict of nfp mtu.

Fixes: d4a27a3b092a ("nfp: add basic features")
Cc: stable@dpdk.org

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
---
v3:
* git summary

v2:
* add the min_mtu and max_mtu in the nfp_net_infos_get()
---

 drivers/net/nfp/nfp_common.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Ferruh Yigit April 20, 2022, 6:54 p.m. UTC | #1
On 3/30/2022 4:17 AM, Peng Zhang wrote:
> 1.When the setting mtu is higher than flbufsz, the mtu doesn't work.
> But it doesn't have any notice about this restrict.
> 2.add the min_mtu and max_mtu in the nfp_net_infos_get() to avoid
> the setting mtu isn't in the range
> 
> This patch will add these restrict of nfp mtu.
> 

+Niklas, as he is the maintainer of the PMD.

Can you please prefer uppercase 'MTU' in title/commit log and error log?

I assume scattered_rx is not supported by the device, which enables 
receiving packets bigger than mbuf data size.

> Fixes: d4a27a3b092a ("nfp: add basic features")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Signed-off-by: Louis Peens <louis.peens@corigine.com>
> ---
> v3:
> * git summary
> 
> v2:
> * add the min_mtu and max_mtu in the nfp_net_infos_get()
> ---
> 
>   drivers/net/nfp/nfp_common.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
> index f8978e803a..4e48e33a63 100644
> --- a/drivers/net/nfp/nfp_common.c
> +++ b/drivers/net/nfp/nfp_common.c
> @@ -693,6 +693,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>   
>   	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
>   
> +	dev_info->max_mtu = (uint16_t)hw->max_mtu;
> +	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
>   	dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
>   	dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
>   	dev_info->min_rx_bufsize = RTE_ETHER_MIN_MTU;
> @@ -956,6 +958,13 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
>   		return -EBUSY;
>   	}
>   
> +	/* the setting mtu is lower than flbufsz */
> +	if (mtu > hw->flbufsz) {
> +		PMD_DRV_LOG(ERR, "the setting mtu must be lower than current mbufsize of %d",

You may want to start log with uppercase as done in other logs, for 
consistency.
Also may want to print the MTU value in the log.

> +			    hw->flbufsz);
> +		return -ERANGE;
> +	}

Should this be checked in 'nfb_eth_dev_configure()' too, where 
'dev->data->mtu' can be set?

> +
>   	/* writing to configuration space */
>   	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
>
  
Nole Zhang April 21, 2022, 12:55 a.m. UTC | #2
Thanks for your advice.

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@xilinx.com>
> Sent: 2022年4月21日 2:55
> To: Nole Zhang <peng.zhang@corigine.com>; dev@dpdk.org; Niklas
> Soderlund <niklas.soderlund@corigine.com>
> Cc: Heinrich Kuhn <heinrich.kuhn@corigine.com>; stable@dpdk.org;
> Chaoyong He <chaoyong.he@corigine.com>; Louis Peens
> <louis.peens@corigine.com>
> Subject: Re: [PATCH v3] net/nfp: fix mtu settings
> 
> On 3/30/2022 4:17 AM, Peng Zhang wrote:
> > 1.When the setting mtu is higher than flbufsz, the mtu doesn't work.
> > But it doesn't have any notice about this restrict.
> > 2.add the min_mtu and max_mtu in the nfp_net_infos_get() to avoid the
> > setting mtu isn't in the range
> >
> > This patch will add these restrict of nfp mtu.
> >
> 
> +Niklas, as he is the maintainer of the PMD.
> 
> Can you please prefer uppercase 'MTU' in title/commit log and error log?
> 

Yes,  I will use the MTU replace the mtu.

> I assume scattered_rx is not supported by the device, which enables
> receiving packets bigger than mbuf data size.
> 
> > Fixes: d4a27a3b092a ("nfp: add basic features")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> > Signed-off-by: Louis Peens <louis.peens@corigine.com>
> > ---
> > v3:
> > * git summary
> >
> > v2:
> > * add the min_mtu and max_mtu in the nfp_net_infos_get()
> > ---
> >
> >   drivers/net/nfp/nfp_common.c | 9 +++++++++
> >   1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/net/nfp/nfp_common.c
> > b/drivers/net/nfp/nfp_common.c index f8978e803a..4e48e33a63 100644
> > --- a/drivers/net/nfp/nfp_common.c
> > +++ b/drivers/net/nfp/nfp_common.c
> > @@ -693,6 +693,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct
> > rte_eth_dev_info *dev_info)
> >
> >   	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> >
> > +	dev_info->max_mtu = (uint16_t)hw->max_mtu;
> > +	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
> >   	dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
> >   	dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
> >   	dev_info->min_rx_bufsize = RTE_ETHER_MIN_MTU; @@ -956,6
> +958,13 @@
> > nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
> >   		return -EBUSY;
> >   	}
> >
> > +	/* the setting mtu is lower than flbufsz */
> > +	if (mtu > hw->flbufsz) {
> > +		PMD_DRV_LOG(ERR, "the setting mtu must be lower than
> current
> > +mbufsize of %d",
> 
> You may want to start log with uppercase as done in other logs, for
> consistency.
> Also may want to print the MTU value in the log.
> 

Yes,  I will use the MTU replace the mtu.

> > +			    hw->flbufsz);
> > +		return -ERANGE;
> > +	}
> 
> Should this be checked in 'nfb_eth_dev_configure()' too, where 'dev->data-
> >mtu' can be set?
> 

You mean in the nfp_net_configure(), we need through the rxmode->mtu to check the mtu?
I will consider it.

Thanks for your advice again.
> > +
> >   	/* writing to configuration space */
> >   	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
> >
  

Patch

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index f8978e803a..4e48e33a63 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -693,6 +693,8 @@  nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
+	dev_info->max_mtu = (uint16_t)hw->max_mtu;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 	dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
 	dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
 	dev_info->min_rx_bufsize = RTE_ETHER_MIN_MTU;
@@ -956,6 +958,13 @@  nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 		return -EBUSY;
 	}
 
+	/* the setting mtu is lower than flbufsz */
+	if (mtu > hw->flbufsz) {
+		PMD_DRV_LOG(ERR, "the setting mtu must be lower than current mbufsize of %d",
+			    hw->flbufsz);
+		return -ERANGE;
+	}
+
 	/* writing to configuration space */
 	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);