From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 9202810A3; Thu, 1 Nov 2018 09:02:04 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2018 01:02:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,451,1534834800"; d="scan'208";a="96802307" Received: from dpdk7.bj.intel.com ([172.16.182.151]) by orsmga003.jf.intel.com with ESMTP; 01 Nov 2018 01:02:02 -0700 From: wei zhao To: wei.zhao1@intel.com, dev@dpdk.org Cc: stable@dpdk.org, qi.z.zhang@intel.com Date: Thu, 1 Nov 2018 15:55:26 +0800 Message-Id: <1541058926-3576-1-git-send-email-wei.zhao1@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/ixgbe: check jumbo frame enable parameter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2018 08:02:05 -0000 There is necessary to do some check of max packet size boundary for code safe when enable jumbo frame. Signed-off-by: Wei Zhao --- 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