[PATCH v2] net/nfp: ensure the MTU can work

Chaoyong He chaoyong.he at corigine.com
Fri Oct 21 08:27:46 CEST 2022


From: Peng Zhang <peng.zhang at corigine.com>

When MTU is bigger than hw->flbufsz, it can't work. hw->flbufsz is set in
the nfp_net_rx_queue_setup().

At first, in the nfp_net_configure(), the hw->flbufsz isn't set the value,
it just judge the initialized value and MTU, it is unreasonable.

Now, it just check the MTU can't be more than the NFP_FRAME_SIZE_MAX in
the nfp_net_configure(), when hw->flbufsz is set the value, in the
nfp_net_start(), judge the hw->flbufsz and MTU.

Fixes: 5c305e218f15 ("net/nfp: fix initialization")
Cc: stable at dpdk.org

Signed-off-by: Peng Zhang <peng.zhang at corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he at corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at corigine.com>

* Changes since v1
- Remove the assignment in init() and move the check to nfp_net_start().

---
 drivers/net/nfp/nfp_common.c    | 6 +++---
 drivers/net/nfp/nfp_ethdev.c    | 8 +++++++-
 drivers/net/nfp/nfp_ethdev_vf.c | 1 -
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 0e55f0c..289c70f 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -177,9 +177,9 @@
 	}
 
 	/* 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);
+	if (rxmode->mtu > NFP_FRAME_SIZE_MAX) {
+		PMD_INIT_LOG(ERR, "MTU (%u) larger than NFP_FRAME_SIZE_MAX (%u) not supported",
+				    rxmode->mtu, NFP_FRAME_SIZE_MAX);
 		return -ERANGE;
 	}
 
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 5cdd34e..3b952fa 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -110,6 +110,13 @@
 		update = NFP_NET_CFG_UPDATE_MSIX;
 	}
 
+	/* Checking MTU set */
+	if (dev->data->mtu > hw->flbufsz) {
+		PMD_INIT_LOG(ERR, "MTU (%u) can't be larger than the current NFP_FRAME_SIZE (%u)",
+				dev->data->mtu, hw->flbufsz);
+		return -ERANGE;
+	}
+
 	rte_intr_enable(intr_handle);
 
 	new_ctrl = nfp_check_offloads(dev);
@@ -517,7 +524,6 @@
 	hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
 	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
 	hw->mtu = RTE_ETHER_MTU;
-	hw->flbufsz = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
 	if (hw->cap & NFP_NET_CFG_CTRL_LSO2)
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index d304d78..3f4ad3e 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -396,7 +396,6 @@
 	hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
 	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
 	hw->mtu = RTE_ETHER_MTU;
-	hw->flbufsz = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
 	if (hw->cap & NFP_NET_CFG_CTRL_LSO2)
-- 
1.8.3.1



More information about the stable mailing list