From: "Niklas Söderlund" <niklas.soderlund@corigine.com>
To: stable@dpdk.org
Cc: oss-drivers@corigine.com, "Peng Zhang" <peng.zhang@corigine.com>,
"Chaoyong He" <chaoyong.he@corigine.com>,
"Niklas Söderlund" <niklas.soderlund@corigine.com>
Subject: [PATCH 19.11] net/nfp: fix internal buffer size and MTU check
Date: Thu, 17 Nov 2022 15:25:24 +0100 [thread overview]
Message-ID: <20221117142524.3144353-1-niklas.soderlund@corigine.com> (raw)
From: Peng Zhang <peng.zhang@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@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@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
next reply other threads:[~2022-11-17 14:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 14:25 Niklas Söderlund [this message]
2022-11-18 7:01 ` Christian Ehrhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221117142524.3144353-1-niklas.soderlund@corigine.com \
--to=niklas.soderlund@corigine.com \
--cc=chaoyong.he@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).