[v2] net/nfp: ensure the MTU can work
Checks
Commit Message
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
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.
@@ -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;
}
@@ -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)
@@ -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)