* [PATCH 19.11] net/nfp: fix internal buffer size and MTU check
@ 2022-11-17 14:25 Niklas Söderlund
2022-11-18 7:01 ` Christian Ehrhardt
0 siblings, 1 reply; 2+ messages in thread
From: Niklas Söderlund @ 2022-11-17 14:25 UTC (permalink / raw)
To: stable; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Niklas Söderlund
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 19.11] net/nfp: fix internal buffer size and MTU check
2022-11-17 14:25 [PATCH 19.11] net/nfp: fix internal buffer size and MTU check Niklas Söderlund
@ 2022-11-18 7:01 ` Christian Ehrhardt
0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2022-11-18 7:01 UTC (permalink / raw)
To: Niklas Söderlund; +Cc: stable, oss-drivers, Peng Zhang, Chaoyong He
On Thu, Nov 17, 2022 at 3:27 PM Niklas Söderlund
<niklas.soderlund@corigine.com> wrote:
>
> From: Peng Zhang <peng.zhang@corigine.com>
>
> [ upstream commit dbad6f64f9210afc50566a87f0e25f925c3b0f90 ]
Thanks, applied.
> 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
>
--
Christian Ehrhardt
Senior Staff Engineer, Ubuntu Server
Canonical Ltd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-18 7:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 14:25 [PATCH 19.11] net/nfp: fix internal buffer size and MTU check Niklas Söderlund
2022-11-18 7:01 ` Christian Ehrhardt
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).