Setting a MTU larger than mbufsize is not supported by the device but
not prohibited by the driver. This change adds a restriction to the
driver to prevent setting an MTU that is too large.

While at it define the minimum MTU in the device information to describe
the complete supported MTU range.

Fixes: d4a27a3 ("nfp: add basic features")
Cc: sta...@dpdk.org

Signed-off-by: Peng Zhang <peng.zh...@corigine.com>
Signed-off-by: Chaoyong He <chaoyong...@corigine.com>
Signed-off-by: Louis Peens <louis.pe...@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderl...@corigine.com>
Reviewed-by: Walter Heymans <walter.heym...@corigine.com>
------
Depends-on: patch-109914 ("net/nfp: update how MAX MTU is read")
---
 drivers/net/nfp/nfp_common.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 52fbda1a79..be68c25fb8 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -176,6 +176,13 @@ nfp_net_configure(struct rte_eth_dev *dev)
                return -EINVAL;
        }
 
+       /* 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);
+               return -ERANGE;
+       }
+
        return 0;
 }
 
@@ -702,6 +709,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
         */
        dev_info->max_rx_pktlen = NFP_FRAME_SIZE_MAX;
        dev_info->max_mtu = hw->max_mtu;
+       dev_info->min_mtu = RTE_ETHER_MIN_MTU;
        /* Next should change when PF support is implemented */
        dev_info->max_mac_addrs = 1;
 
@@ -961,6 +969,13 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
                return -EBUSY;
        }
 
+       /* MTU larger then current mbufsize not supported */
+       if (mtu > hw->flbufsz) {
+               PMD_DRV_LOG(ERR, "MTU (%u) larger then current mbufsize (%u) 
not supported",
+                           mtu, hw->flbufsz);
+               return -ERANGE;
+       }
+
        /* writing to configuration space */
        nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
 
-- 
2.27.0

Reply via email to