when application presets the max rx packet length and expected mtu at
the same time, driver need identify if the preset max frame size can
hold mtu data and Ether overhead completely.

if not, adjust the max frame size via mtu_set ops within dev_configure.

Fixes: 50cc9d2a6e9d ("net/ice: fix max frame size")

Signed-off-by: SteveX Yang <stevex.y...@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0056da78a..a707612c2 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3305,6 +3305,7 @@ ice_dev_configure(struct rte_eth_dev *dev)
        struct ice_adapter *ad =
                ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
        struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+       uint32_t frame_size = dev->data->mtu + ICE_ETH_OVERHEAD;
        int ret;
 
        /* Initialize to TRUE. If any of Rx queues doesn't meet the
@@ -3316,6 +3317,16 @@ ice_dev_configure(struct rte_eth_dev *dev)
        if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
                dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
 
+       /**
+        * Reset the max frame size via mtu_set ops if preset max frame
+        * cannot hold MTU data and Ether overhead.
+        */
+       if (frame_size > dev->data->dev_conf.rxmode.max_rx_pkt_len) {
+               ret = ice_mtu_set(dev, dev->data->mtu);
+               if (ret != 0)
+                       return ret;
+       }
+
        ret = ice_init_rss(pf);
        if (ret) {
                PMD_DRV_LOG(ERR, "Failed to enable rss for PF");
-- 
2.17.1

Reply via email to