patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v2] net/nfp: fix mtu settings
       [not found] <20220317143917.499138-1-peng.zhang@corigine.com>
@ 2022-03-18 11:38 ` Peng Zhang
  2022-03-30  3:17   ` [PATCH v3] " Peng Zhang
  0 siblings, 1 reply; 6+ messages in thread
From: Peng Zhang @ 2022-03-18 11:38 UTC (permalink / raw)
  To: dev; +Cc: heinrich.kuhn, Peng Zhang, stable, Chaoyong He, Louis Peens

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: d4a27a3 ("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>
---
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",
+			    hw->flbufsz);
+		return -ERANGE;
+	}
+
 	/* writing to configuration space */
 	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
 
-- 
2.27.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3] net/nfp: fix mtu settings
  2022-03-18 11:38 ` [PATCH v2] net/nfp: fix mtu settings Peng Zhang
@ 2022-03-30  3:17   ` Peng Zhang
  2022-04-20 18:54     ` Ferruh Yigit
  2022-05-11  1:15     ` [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize Peng Zhang
  0 siblings, 2 replies; 6+ messages in thread
From: Peng Zhang @ 2022-03-30  3:17 UTC (permalink / raw)
  To: dev; +Cc: heinrich.kuhn, Peng Zhang, stable, Chaoyong He, Louis Peens

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(+)

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);
 
-- 
2.27.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] net/nfp: fix mtu settings
  2022-03-30  3:17   ` [PATCH v3] " Peng Zhang
@ 2022-04-20 18:54     ` Ferruh Yigit
  2022-04-21  0:55       ` Nole Zhang
  2022-05-11  1:15     ` [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize Peng Zhang
  1 sibling, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2022-04-20 18:54 UTC (permalink / raw)
  To: Peng Zhang, dev, Niklas Soderlund
  Cc: heinrich.kuhn, stable, Chaoyong He, Louis Peens

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);
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v3] net/nfp: fix mtu settings
  2022-04-20 18:54     ` Ferruh Yigit
@ 2022-04-21  0:55       ` Nole Zhang
  0 siblings, 0 replies; 6+ messages in thread
From: Nole Zhang @ 2022-04-21  0:55 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: Niklas Soderlund, Chaoyong He, Louis Peens, stable


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);
> >


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize
  2022-03-30  3:17   ` [PATCH v3] " Peng Zhang
  2022-04-20 18:54     ` Ferruh Yigit
@ 2022-05-11  1:15     ` Peng Zhang
  2022-05-19  7:08       ` Andrew Rybchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Peng Zhang @ 2022-05-11  1:15 UTC (permalink / raw)
  To: dev
  Cc: niklas.soderlund, Peng Zhang, stable, Chaoyong He, Louis Peens,
	Walter Heymans

Setting a MTU larger than mbufsize is not supported by the device but
not prohibited by the driver. This change adds a restriction to the
driver to prevent setting an MTU that is too large.

While at it define the minimum MTU in the device information to describe
the complete supported MTU range.

Fixes: d4a27a3 ("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>
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Walter Heymans <walter.heymans@corigine.com>
------
Depends-on: patch-109914 ("net/nfp: update how MAX MTU is read")
---
 drivers/net/nfp/nfp_common.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 52fbda1a79..be68c25fb8 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -176,6 +176,13 @@ nfp_net_configure(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
+	/* Checking MTU set */
+	if (rxmode->mtu > hw->flbufsz) {
+		PMD_INIT_LOG(INFO, "MTU (%u) larger then current mbufsize (%u) not supported",
+				    rxmode->mtu, hw->flbufsz);
+		return -ERANGE;
+	}
+
 	return 0;
 }
 
@@ -702,6 +709,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	 */
 	dev_info->max_rx_pktlen = NFP_FRAME_SIZE_MAX;
 	dev_info->max_mtu = hw->max_mtu;
+	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
@@ -961,6 +969,13 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 		return -EBUSY;
 	}
 
+	/* MTU larger then current mbufsize not supported */
+	if (mtu > hw->flbufsz) {
+		PMD_DRV_LOG(ERR, "MTU (%u) larger then current mbufsize (%u) not supported",
+			    mtu, hw->flbufsz);
+		return -ERANGE;
+	}
+
 	/* writing to configuration space */
 	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
 
-- 
2.27.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize
  2022-05-11  1:15     ` [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize Peng Zhang
@ 2022-05-19  7:08       ` Andrew Rybchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Rybchenko @ 2022-05-19  7:08 UTC (permalink / raw)
  To: Peng Zhang, dev
  Cc: niklas.soderlund, stable, Chaoyong He, Louis Peens, Walter Heymans

On 5/11/22 04:15, Peng Zhang wrote:
> Setting a MTU larger than mbufsize is not supported by the device but
> not prohibited by the driver. This change adds a restriction to the
> driver to prevent setting an MTU that is too large.
> 
> While at it define the minimum MTU in the device information to describe
> the complete supported MTU range.
> 
> Fixes: d4a27a3 ("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>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> Reviewed-by: Walter Heymans <walter.heymans@corigine.com>

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Applied, thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-19  7:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220317143917.499138-1-peng.zhang@corigine.com>
2022-03-18 11:38 ` [PATCH v2] net/nfp: fix mtu settings Peng Zhang
2022-03-30  3:17   ` [PATCH v3] " Peng Zhang
2022-04-20 18:54     ` Ferruh Yigit
2022-04-21  0:55       ` Nole Zhang
2022-05-11  1:15     ` [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize Peng Zhang
2022-05-19  7:08       ` Andrew Rybchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).