Skip to content

Commit

Permalink
net/e1000: remove MTU setting limitation
Browse files Browse the repository at this point in the history
[ upstream commit 0984d19 ]

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: 59d0ecd ("ethdev: MTU accessors")

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
Acked-by: Jeff Guo <jia.guo@intel.com>
  • Loading branch information
yudapengx authored and cpaelzer committed May 11, 2021
1 parent d0dbb7c commit 8e81ce2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions drivers/net/e1000/em_ethdev.c
Expand Up @@ -1801,11 +1801,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);
Expand Down
12 changes: 8 additions & 4 deletions drivers/net/e1000/igb_ethdev.c
Expand Up @@ -4568,11 +4568,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);

Expand Down

0 comments on commit 8e81ce2

Please sign in to comment.