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

Message ID 1666333666-38183-1-git-send-email-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/nfp: ensure the MTU can work |

Checks

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

Commit Message

Chaoyong He Oct. 21, 2022, 6:27 a.m. UTC
  From: Peng Zhang <peng.zhang@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@dpdk.org

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@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(-)
  

Comments

Ferruh Yigit Oct. 21, 2022, 9:59 a.m. UTC | #1
On 10/21/2022 7:27 AM, Chaoyong He wrote:
> From: Peng Zhang <peng.zhang@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@dpdk.org
> 
> Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

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)