The E800 series PFs transmit the maximum supported MTU as part of the
VIRTCHNL_OP_GET_VF_RESOURCES in the max_mtu field of the
virtchnl_vf_resource structure.

The iavf driver currently only applies this value as part of the assignment
of the max_frame value used for setting the max_pkt_size when programming
Rx queues. This potentially means a user can request an MTU outside this
range. Doing so causes the Tx resources to fail to initialize since the
E800 PF driver will validate the programmed maximum packet sizes and reject
the queue configuration.

Ensure that the netdev->max_mtu field respects the provided maximum MTU.

The X700 series hardware (operated by the i40e PF) does not transmit the
max_mtu field, and instead sends the value as 0. To avoid breaking
functionality, use min_not_zero and keep the existing default for the X700
hardware.

This ensures that the driver will not allow user space to set an MTU which
the PF will reject.

Signed-off-by: Jacob Keller <[email protected]>
Acked-by: Alexander Lobakin <[email protected]>
---
I noticed this while investigating differences between the upstream iAVF
driver and the logic for handling the Rx max frame size in the out-of-tree
sourceforge driver. I think in practice that LIBIE_MAX_MTU is less than the
max_mtu provided by all existing PFs, so this may not be able to trigger an
issue with existing PF software. I still believe it is good to ensure we
check this since a PF might report a smaller maximum MTU for some reason,
and the VF should respect this.
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c 
b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 69054af4689a..f15e87bb204f 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -2797,7 +2797,7 @@ static void iavf_init_config_adapter(struct iavf_adapter 
*adapter)
        netdev->watchdog_timeo = 5 * HZ;
 
        netdev->min_mtu = ETH_MIN_MTU;
-       netdev->max_mtu = LIBIE_MAX_MTU;
+       netdev->max_mtu = min_not_zero(adapter->vf_res->max_mtu, LIBIE_MAX_MTU);
 
        if (!is_valid_ether_addr(adapter->hw.mac.addr)) {
                dev_info(&pdev->dev, "Invalid MAC address %pM, using random\n",

---
base-commit: 856951290c2d5da80fec5356fadce87addcf0b69
change-id: 20250625-jk-iavf-max-pkt-size-mtu-9af1fb28165b

Best regards,
--  
Jacob Keller <[email protected]>

Reply via email to