DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2] net/nfp: fix mtu settings
@ 2022-03-18 11:21 Peng Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Peng Zhang @ 2022-03-18 11:21 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] 2+ messages in thread
* [PATCH] net/nfp: add the restrict of setting the mtu
@ 2022-03-17 14:39 Peng Zhang
  2022-03-18 11:38 ` [PATCH v2] net/nfp: fix mtu settings Peng Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Zhang @ 2022-03-17 14:39 UTC (permalink / raw)
  To: dev; +Cc: heinrich.kuhn, Peng Zhang, 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.when the setting mtu isn't in the range, it doesn't have any notice.

This patch will add the notice about these restrict.

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>
---
 drivers/net/nfp/nfp_common.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index f8978e803a..2ea9853548 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -956,6 +956,20 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 		return -EBUSY;
 	}
 
+	/* the setting mtu is in the range */
+	if (mtu < 68 || mtu > hw->max_mtu) {
+		PMD_DRV_LOG(ERR, "the setting mtu cannot be less than 68 or more than %d",
+			    hw->max_mtu);
+		return -ERANGE;
+	}
+
+	/* 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] 2+ messages in thread

end of thread, other threads:[~2022-03-18 11:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18 11:21 [PATCH v2] net/nfp: fix mtu settings Peng Zhang
  -- strict thread matches above, loose matches on Subject: below --
2022-03-17 14:39 [PATCH] net/nfp: add the restrict of setting the mtu Peng Zhang
2022-03-18 11:38 ` [PATCH v2] net/nfp: fix mtu settings Peng Zhang

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