[PATCH 19.11] net/nfp: fix internal buffer size and MTU check
Niklas Söderlund
niklas.soderlund at corigine.com
Thu Nov 17 15:25:24 CET 2022
From: Peng Zhang <peng.zhang at corigine.com>
[ upstream commit dbad6f64f9210afc50566a87f0e25f925c3b0f90 ]
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")
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>
Signed-off-by: Niklas Söderlund <niklas.soderlund at corigine.com>
---
drivers/net/nfp/nfp_net.c | 15 ++++++++++++++-
drivers/net/nfp/nfp_net_pmd.h | 3 +++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index f427fad4875f..76222ca5affd 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -397,6 +397,13 @@ nfp_net_configure(struct rte_eth_dev *dev)
return -EINVAL;
}
+ /* Checking MTU set */
+ if (rxmode->max_rx_pkt_len > NFP_FRAME_SIZE_MAX) {
+ PMD_INIT_LOG(ERR, "max_rx_pkt_len (%u) larger than NFP_FRAME_SIZE_MAX (%u) not supported",
+ rxmode->max_rx_pkt_len, NFP_FRAME_SIZE_MAX);
+ return -ERANGE;
+ }
+
return 0;
}
@@ -718,6 +725,13 @@ nfp_net_start(struct rte_eth_dev *dev)
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);
@@ -2922,7 +2936,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
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_net_pmd.h b/drivers/net/nfp/nfp_net_pmd.h
index 42ab369cff46..2331967a11bd 100644
--- a/drivers/net/nfp/nfp_net_pmd.h
+++ b/drivers/net/nfp/nfp_net_pmd.h
@@ -102,6 +102,9 @@ struct nfp_net_adapter;
#define NFD_CFG_MINOR_VERSION(x) (((x) & 0xff) << 0)
#define NFD_CFG_MINOR_VERSION_of(x) (((x) >> 0) & 0xff)
+/* Maximum supported NFP frame size (MTU + layer 2 headers) */
+#define NFP_FRAME_SIZE_MAX 10048
+
#include <linux/types.h>
#include <rte_io.h>
--
2.38.1
More information about the stable
mailing list