patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/ixgbe: check jumbo frame enable parameter
@ 2018-11-01  7:55 wei zhao
  2018-11-01  8:28 ` [dpdk-stable] [PATCH v2] " wei zhao
  2018-11-01 17:46 ` [dpdk-stable] [dpdk-dev] [PATCH] " Stephen Hemminger
  0 siblings, 2 replies; 7+ messages in thread
From: wei zhao @ 2018-11-01  7:55 UTC (permalink / raw)
  To: wei.zhao1, dev; +Cc: stable, qi.z.zhang

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-11-06  2:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01  7:55 [dpdk-stable] [PATCH] net/ixgbe: check jumbo frame enable parameter wei zhao
2018-11-01  8:28 ` [dpdk-stable] [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-stable] [dpdk-dev] [PATCH] " Stephen Hemminger
2018-11-05  9:13   ` Zhao1, Wei

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).