From: Dapeng Yu Date: Fri, 19 Feb 2021 10:03:23 +0000 (+0800) Subject: net/e1000: remove MTU setting limitation X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0984d196be2a92eb6e2e0b926fdb4a06a1d7d823;p=dpdk.git net/e1000: remove MTU setting limitation Currently, if requested MTU is bigger than mbuf size and scattered receive is not enabled, setting MTU to that value fails. This patch allows setting this special MTU when device is stopped, because scattered_rx will be re-configured during next port start and driver may enable scattered receive according new MTU value. After this patch, driver may select different receive function automatically after MTU set, according MTU values selected. Fixes: 59d0ecdbf0e1 ("ethdev: MTU accessors") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu Acked-by: Jeff Guo --- diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index 9b8c4a7de5..3c6f643c19 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -1805,11 +1805,15 @@ eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) return -EINVAL; - /* refuse mtu that requires the support of scattered packets when this - * feature has not been enabled before. */ - if (!dev->data->scattered_rx && - frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) + /* + * If device is started, refuse mtu that requires the support of + * scattered packets when this feature has not been enabled before. + */ + if (dev->data->dev_started && !dev->data->scattered_rx && + frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) { + PMD_INIT_LOG(ERR, "Stop port first."); return -EINVAL; + } hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); rctl = E1000_READ_REG(hw, E1000_RCTL); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 5323504e98..1716d6b904 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -4394,11 +4394,15 @@ eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) frame_size > dev_info.max_rx_pktlen) return -EINVAL; - /* refuse mtu that requires the support of scattered packets when this - * feature has not been enabled before. */ - if (!dev->data->scattered_rx && - frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) + /* + * If device is started, refuse mtu that requires the support of + * scattered packets when this feature has not been enabled before. + */ + if (dev->data->dev_started && !dev->data->scattered_rx && + frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) { + PMD_INIT_LOG(ERR, "Stop port first."); return -EINVAL; + } rctl = E1000_READ_REG(hw, E1000_RCTL);