DPDK patches and discussions
 help / color / mirror / Atom feed
From: wei zhao <wei.zhao1@intel.com>
To: wei.zhao1@intel.com, dev@dpdk.org
Cc: stable@dpdk.org, qi.z.zhang@intel.com
Subject: [dpdk-dev] [PATCH] net/ixgbe: check jumbo frame enable parameter
Date: Thu,  1 Nov 2018 15:55:26 +0800	[thread overview]
Message-ID: <1541058926-3576-1-git-send-email-wei.zhao1@intel.com> (raw)

There is necessary to do some check of max packet size boundary
for code safe when enable jumbo frame.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 2f0262a..d304dee 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -4814,6 +4814,34 @@ void __attribute__((cold))
 	return 0;
 }
 
+int __attribute__((cold))
+ixgbe_dev_jumboenable_check(struct rte_eth_dev *dev,
+				uint16_t max_rx_pkt_len)
+{
+	struct rte_eth_dev_info dev_info;
+
+	ixgbe_dev_info_get(dev, &dev_info);
+
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}
+
+	/* check jumbo mode if needed */
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * Initializes Receive Unit.
  */
@@ -4865,6 +4893,9 @@ int __attribute__((cold))
 	 * Configure jumbo frame support, if any.
 	 */
 	if (rx_conf->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		if (ixgbe_dev_jumboenable_check(dev, rx_conf->max_rx_pkt_len))
+			return -EINVAL;
+
 		hlreg0 |= IXGBE_HLREG0_JUMBOEN;
 		maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
 		maxfrs &= 0x0000FFFF;
-- 
1.8.3.1

             reply	other threads:[~2018-11-01  8:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01  7:55 wei zhao [this message]
2018-11-01  8:28 ` [dpdk-dev] [PATCH v2] " wei zhao
2018-11-01  8:40   ` Zhao1, Wei
2018-11-05 16:34     ` Zhang, Qi Z
2018-11-06  2:49       ` Zhao1, Wei
2018-11-01 17:46 ` [dpdk-dev] [PATCH] " Stephen Hemminger
2018-11-05  9:13   ` Zhao1, Wei

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=1541058926-3576-1-git-send-email-wei.zhao1@intel.com \
    --to=wei.zhao1@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.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).