patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Peng Zhang <peng.zhang@corigine.com>
To: dev@dpdk.org
Cc: niklas.soderlund@corigine.com,
	Peng Zhang <peng.zhang@corigine.com>,
	stable@dpdk.org, Chaoyong He <chaoyong.he@corigine.com>,
	Louis Peens <louis.peens@corigine.com>,
	Walter Heymans <walter.heymans@corigine.com>
Subject: [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize
Date: Wed, 11 May 2022 03:15:53 +0200	[thread overview]
Message-ID: <20220511011553.2905582-1-peng.zhang@corigine.com> (raw)
In-Reply-To: <20220330031751.119830-1-peng.zhang@corigine.com>

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: stable@dpdk.org

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Walter Heymans <walter.heymans@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


  parent reply	other threads:[~2022-05-11  1:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220317143917.499138-1-peng.zhang@corigine.com>
2022-03-18 11:38 ` [PATCH v2] net/nfp: fix mtu settings Peng Zhang
2022-03-30  3:17   ` [PATCH v3] " Peng Zhang
2022-04-20 18:54     ` Ferruh Yigit
2022-04-21  0:55       ` Nole Zhang
2022-05-11  1:15     ` Peng Zhang [this message]
2022-05-19  7:08       ` [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize Andrew Rybchenko

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=20220511011553.2905582-1-peng.zhang@corigine.com \
    --to=peng.zhang@corigine.com \
    --cc=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=louis.peens@corigine.com \
    --cc=niklas.soderlund@corigine.com \
    --cc=stable@dpdk.org \
    --cc=walter.heymans@corigine.com \
    /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).